Skip to main content

Interpreter of Boolean Logic Language

Project description

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 :

Project details


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 details)

Uploaded Source

Built Distribution

bamboolean-0.4.0-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

Details for the file bamboolean-0.4.0.tar.gz.

File metadata

  • Download URL: bamboolean-0.4.0.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.7.5

File hashes

Hashes for bamboolean-0.4.0.tar.gz
Algorithm Hash digest
SHA256 6cc7ada7552438d6ec44ba4a90f38ade874b4606d09fe0a01f2240e9ead8cc62
MD5 ffcb0fb4c44748617a1411ed38fb77c6
BLAKE2b-256 aea20f616ab959518f1c3aca85c9935a26285faebf51445947872aa104411331

See more details on using hashes here.

File details

Details for the file bamboolean-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: bamboolean-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 16.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.7.5

File hashes

Hashes for bamboolean-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2391cef13073dc66735bcd73d2444fab2c1f360292a829ddb054ecc5261994ed
MD5 4011a9839af3b905eb6c328de93b2183
BLAKE2b-256 88752a828fb17219261b8d5c132ba9f727ef3485056a963ae1b7876f2debf73f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page