https://github.com/qedsoftware/bamboolean
Are you bamboozled by Booleans? Let Bamboolean interpret them.
https://github.com/qedsoftware/bamboolean
Last synced: 3 months ago
JSON representation
Are you bamboozled by Booleans? Let Bamboolean interpret them.
- Host: GitHub
- URL: https://github.com/qedsoftware/bamboolean
- Owner: qedsoftware
- License: mit
- Created: 2017-10-03T10:59:28.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-01-27T21:29:02.000Z (over 6 years ago)
- Last Synced: 2025-06-24T06:04:44.692Z (11 months ago)
- Language: Python
- Size: 62.5 KB
- Stars: 5
- Watchers: 10
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Bamboolean interpreter
[](https://travis-ci.org/qedsoftware/bamboolean)
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](./bamboolean/tests/fixtures.py)
## 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](https://docs.python.org/3/library/stdtypes.html#truth-value-testing)
- 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)
1. OR
2. AND
4. NOT
3. == | != | < | <= | > | >=
## 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 :
```