Skip to content

Are you bamboozled by Booleans? Let Bamboolean interpret them.

License

Notifications You must be signed in to change notification settings

qedsoftware/bamboolean

Repository files navigation

Bamboolean interpreter

Build Status

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)
  1. OR
  2. AND
  3. NOT
  4. == | != | < | <= | > | >=

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 :

About

Are you bamboozled by Booleans? Let Bamboolean interpret them.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages