Skip to content

Commit 2b64d1b

Browse files
committed
Update README
1 parent f372489 commit 2b64d1b

File tree

1 file changed

+14
-148
lines changed

1 file changed

+14
-148
lines changed

README.md

+14-148
Original file line numberDiff line numberDiff line change
@@ -1,167 +1,33 @@
11
# Boolean Expression Parser <!-- omit in toc -->
22

3-
A simple boolean expression parser written in C#. It parses boolean expressions and prints out a truth table for each expression.
3+
A library and accompanying CLI and WebUI for parsing, evaluating and generating truth tables for boolean logic expressions.
44

55

66
## Contents <!-- omit in toc -->
77

8-
- [Running](#running)
9-
- [Building](#building)
10-
- [Display](#display)
11-
- [Base Command](#base-command)
12-
- [Truth table generation](#truth-table-generation)
13-
- [Notation conversion](#notation-conversion)
14-
- [Expressions](#expressions)
15-
- [Variables](#variables)
16-
- [How it works](#how-it-works)
17-
- [1. Tokenisation](#1-tokenisation)
18-
- [2. Parsing](#2-parsing)
19-
- [3. AST](#3-ast)
20-
- [4. Evaluation](#4-evaluation)
21-
- [Example expressions](#example-expressions)
22-
- [Roadmap](#roadmap)
8+
- [Make up of the project](#make-up-of-the-project)
9+
- [Wiki](#wiki)
2310
- [Found an issue?](#found-an-issue)
2411

2512

26-
## Running
2713

28-
After downloading a release from the Releases section to the right, you can run the program on either Windows or Linux by running `BooleanExpressionParser.exe` or `BooleanExpressionParser` in the terminal respectively. Note, you'll need .NET 7 installed on your machine to run the program.
14+
## Make up of the project
2915

16+
There are three main parts to the project:
3017

31-
## Building
18+
- The library, which is the core of the project. It contains the logic for parsing, evaluating and generating truth tables for boolean expressions.
19+
- This is the C# project named `BooleanExpressionParser`.
20+
- The CLI, which provides a easy-to-use command line interface for the library.
21+
- This is the C# project named `BooleanExpressionParser.CLI`.
22+
- The WebUI, which is a Blazor WebAssembly appplication built ontop of an ASP.NET server. It provides a web interface for the library.
23+
- This is the C# project named `BooleanExpressionParser.Web`.
3224

33-
To build the project, you'll need .NET 7 installed. You can then build the project with `dotnet build` or run it with `dotnet run`. Alternatively, you can open the project in Visual Studio or Visual Studio Code, the latter of which has config in the repo.
3425

26+
## Wiki
3527

36-
## Display
37-
38-
The application displays an intuitive, coloured truth table output for each boolean expression:
39-
40-
![Sample screenshot](./docs/sample-screenshot.png)
41-
42-
43-
## Base Command
44-
`./BooleanExpressionParser [command] [options]`
45-
46-
### Options: <!-- omit in toc -->
47-
- `-o`, `--output`, `--output-type` `<Basic|Display>` The output type to use.
48-
49-
50-
## Truth table generation
51-
Prints the truth table of a boolean expression(s). If none are provided, the user will be prompted to enter them.
52-
53-
### Usage: <!-- omit in toc -->
54-
`./BooleanExpressionParser table [<expression(s)>...] [options]`
55-
### Arguments: <!-- omit in toc -->
56-
- `<expression(s)>` The boolean expression(s) to evaluate.
57-
### Options: <!-- omit in toc -->
58-
- `-t`, `--true` `<true>` Character to use for true values in the truth table. [default: 1]
59-
- `-f`, `--false` `<false>` Character to use for false values in the truth table. [default: 0]
60-
- `-c`, `--colour-mode`, `--color-mode` `<Background|Foreground|None>` Colour mode to use for the truth table. [default: Foreground] (possible values: [Ff]oreground, [Bb]ackground, [Nn]one)
61-
- `--true-colour`, `--true-color` `<true-colour>` Colour to use for true values in the truth table. [default: green] (possible values: 16 ANSI colours, hex string, rgb string)
62-
- `--false-colour`, `--false-color` `<false-colour>` Colour to use for false values in the truth table. [default: red] (possible values: 16 ANSI colours, hex string, rgb string)
63-
64-
65-
## Notation conversion
66-
Converts a boolean expression(s) to postfix notation. If none are provided, the user will be prompted to enter them.
67-
68-
### Usage: <!-- omit in toc -->
69-
`./BooleanExpressionParser convert [<expression(s)>...] [options]`
70-
### Arguments: <!-- omit in toc -->
71-
- `<expression(s)>` The boolean expression(s) to convert
72-
73-
74-
More commands to be implemented in the future.
75-
76-
For help, run `./BooleanExpressionParser --help`. For help with a specific command, run `./BooleanExpressionParser [command] --help` or `./BooleanExpressionParser --help [command]`.
77-
78-
79-
80-
## Expressions
81-
82-
Shown below is a list of supported operators. Each operator's aliases are listed in brackets.
83-
84-
- AND (`&`, `.`)
85-
- OR (`|`, `+`)
86-
- NOT (`!`, `¬`)
87-
- XOR
88-
- NAND
89-
- NOR
90-
- XNOR
91-
- IMPLIES (`=>`)
92-
93-
Of course, you can also use brackets to group expressions. Every type of bracket can be used, which may help distinguish groupings: `()` `[]` `{}`
94-
95-
96-
## Variables
97-
98-
Any characters in an expression which arent operators or brackets are considered variables. The parser will automatically generate a truth table for each variable. Variables can be several characters long, which allows for numbered variables (`A1`, `A_2`, etc.).
99-
100-
To provide an order in which the variables should be printed, give a comma separated list of variables after your expression, separating these parts with a semicolon (`;`). If this isn't given, the truth table is generated in the order the variables are found in the expression.
101-
102-
For example:
103-
- The expression "D0.!S + D1.S" would generate a truth table ordered D0, D1, S.
104-
- The expression "D0.!S + D1.S;S,D0,D1" would generate a truth table ordered S, D0, D1.
105-
106-
107-
108-
## How it works
109-
110-
### 1. Tokenisation
111-
- Input is split into tokens. These tokens are internal representations of the input.
112-
- Tokens are either operators, variables, or brackets.
113-
- For example, the input `A & ! B` would be tokenised into [`A`, `AND`, `NOT`, `B`].
114-
115-
116-
### 2. Parsing
117-
- Tokens are parsed into postfix or [Reverse Polish notation](https://en.wikipedia.org/wiki/Reverse_Polish_notation), using the (slightly modified) Shunting-yard algorithm.
118-
- Postfix notation removes the need for brackets, and makes it easier to evaluate the expression. In this notation, the operator is placed before the operands (rather than in between them).
119-
- Our tokenised list, [`A`, `AND`, `NOT`, `B`] would be parsed into [`A`, `B`, `NOT`, `AND`].
120-
121-
122-
### 3. AST
123-
- The parsed tokens are then converted into an AST (Abstract Syntax Tree). This is so that the expression can be evaluated and easily traversed.
124-
- An AST consists of several nodes, each with children nodes (0, 1, or 2 depending on its type). Each node represents an operator or variable.
125-
- Our parsed list, [`A`, `B`, `NOT`, `AND`], would be converted into the following AST:
126-
```
127-
AND
128-
├── A
129-
└── NOT
130-
└── B
131-
```
132-
133-
134-
### 4. Evaluation
135-
- Finally, the AST is evaluated, and a truth table is printed out for the expression.
136-
- Evaluation simply traverses the AST and evaluates each node recursively, using the values of its children.
137-
- Each expression is evaluated using every possible set of inputs which is then collated into a truth table.
138-
139-
140-
## Example expressions
141-
142-
- `A & B`
143-
- A simple AND gate
144-
- `A OR B`
145-
- A simple OR gate
146-
- `!S . D_0 + D_1 . S`
147-
- A 2-1 multiplexer
148-
- `(!S0 AND ¬S1 . D0) | (NOT{S0} . S1 . D1) + (S0 . {¬S1 & D2}) OR [S0 . S1 AND D3]`
149-
- A 4-1 multiplexer, using several aliases for operators and brackets
150-
151-
152-
## Roadmap
153-
154-
- [x] Implement basic expression parsing and evaluation
155-
- [x] Implement truth table generation and display
156-
- [x] Improve console output with colours
157-
- [x] Implement command line arguments
158-
- [ ] Add raw output options
159-
- [x] Output postfix notation
160-
- [ ] Output specific output for given variables
161-
- [x] Output machine-readable truth table
162-
- [ ] Create UI for the application, either web-based or desktop-based
28+
For more information about usage, project structure, and functionality, please see the [wiki](https://github.com/tomc128/boolean-expression-parser/wiki).
16329

16430

16531
## Found an issue?
16632

167-
If you've found an issue, like an expression that casuses a crash or an incorrectly parsed expression, please open an issue on GitHub. Please include the expression that caused the issue, thank you!
33+
If you've found an issue, like an expression that casuses a crash or an incorrectly parsed expression, please open an issue on GitHub. Please include the expression that caused the issue, thank you! Or, if you're able to, fork the repo and fix it yourself. Pull requests are welcome!

0 commit comments

Comments
 (0)