Interpreter of Boolean Logic Language
Project description
# Bamboolean interpreter
[![Build Status](https://travis-ci.org/qedsoftware/bamboolean.svg?branch=master)](https://travis-ci.org/qedsoftware/bamboolean)
Supported from Python >= 3.4
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
- 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
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
statement : value
| constraint
constraint : variable (relational_operator value)?
relational_operator : ( EQ | NE | LT | LTE | GT | GTE )
value : INTEGER
| FLOAT
| STRING
| BOOL
variable : ID
empty :
```
[![Build Status](https://travis-ci.org/qedsoftware/bamboolean.svg?branch=master)](https://travis-ci.org/qedsoftware/bamboolean)
Supported from Python >= 3.4
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
- 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
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
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.2.0.tar.gz
(9.2 kB
view hashes)
Built Distribution
bamboolean-0.2.0-py3-none-any.whl
(12.8 kB
view hashes)
Close
Hashes for bamboolean-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0644f679940bd859a0c7efdd1c59d67e21d608d71cbba56c715f5ec661e2ad37 |
|
MD5 | 590a8413e3b7678153ed29be954a035b |
|
BLAKE2b-256 | c373d474072bbb7e0ab2956520aba7c05c7e9960aad9d099cdf4448c49540f77 |