Truth tables for the world!
This is Bully, my little Boolean expression calculator. I’d made a similar project in college while studying for a discrete math final, and decided to port my efforts to a TypeScript and React shell while learning a bit more about parsers. (The old one used a couple of regular expressions and eval(). I know.)
For more details see the tests and Peggy grammar file, but in short:
- Variables shown in the table (A, B, C, etc.) can be referenced by their names:
D - Boolean sums/disjunctions/OR operations are written with
+:A + B - Literal
trueandfalseare evaluated as you might expect:true + D - Boolean products/conjunctions/AND operations are written with
*or implicitly:A * D,AD - Boolean negation/NOT operations are written with a postfix
':A'D,true' - Parentheses work as you might expect.