Interpreter of Boolean Logic Language
Project description
Bamboolean interpreter
Supported from Python >= 3.6
Implementation of Bamboolean - Boolean Logic Language
Bamboolean is a simple language that consumes array of pre-defined variables, and returns boolean value if constraints on these variables are met.
Exemplary expressions in the language
Features
- Case in-sensitive variable names and keywords
- Comparison operators (listed below)
- Logic AND / OR / NOT
- Expressions with parentheses
- Types: Float, Int, String, Bool, Variable
- Truth value testing same as in Python
- Implicit cast of variables to boolean when no relational operator is specified
Operators associativity
All operators are left-associative
Operators precedence (the higher number the higher priority)
- OR
- AND
- NOT
- == | != | < | <= | > | >=
Testing
Run tests:
`python run_tests.py`
EBNF Grammar
compound_expr : expr
| empty
expr : simple_expr (OR simple_expr)*
simple_expr : term (AND term)*
term : statement
| LPAREN expr RPAREN
| NOT term
statement : value
| constraint
constraint : variable (relational_operator value)?
relational_operator : ( EQ | NE | LT | LTE | GT | GTE )
value : INTEGER
| FLOAT
| STRING
| BOOL
variable : ID
empty :
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
bamboolean-0.4.0.tar.gz
(11.2 kB
view hashes)
Built Distribution
bamboolean-0.4.0-py3-none-any.whl
(16.2 kB
view hashes)
Close
Hashes for bamboolean-0.4.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2391cef13073dc66735bcd73d2444fab2c1f360292a829ddb054ecc5261994ed |
|
MD5 | 4011a9839af3b905eb6c328de93b2183 |
|
BLAKE2b-256 | 88752a828fb17219261b8d5c132ba9f727ef3485056a963ae1b7876f2debf73f |