Skip to main content

An interpreter for a basic logic language, inspired by two-element boolean algebra.

Project description


Interpreter for a basic logic language, inspired by two-element boolean algebra.


Here's a quick demo, based on the example that prompted its creation:

>>> from lla.interpreter import Interpreter
>>> variables = {
...     'ssh': True,
...     'website_up': True,
...     'search_up': False,
...     'elasticsearch.http': False,
...     'elasticsearch.process': True,
... }
>>> interpreter = Interpreter(variables)
>>>'ssh & website_up')
>>>'ssh & website_up & search_up')
>>>'!search_up & !elasticsearch.http & elasticsearch.process')
Traceback (most recent call last):
lla.interpreter.UndefinedVariableException: Undefined variable: undefined_variable

By replacing the variables dict with a class implementing __getitem__, it becomes incredibly flexible.


Here's the gist of it:

  1. All variables are booleans.
  2. You can't define variables in the language itself, but it be provided a dict or any object implementing __getitem__.
  3. Only fully-resolvable statements are supported. a. Anything else raises a Python exception.
  4. You provide the interpreter a single statement and it gets simplified to a single boolean value, which is then returned.


In theory, all you need is Python 3.6+.


Bug reports and pull requests are welcome on GitHub at

The code for lla is available under the MIT License.

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

lla-0.0.6.tar.gz (5.0 kB view hashes)

Uploaded Source

Built Distribution

lla-0.0.6-py3-none-any.whl (6.4 kB view hashes)

Uploaded Python 3

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