Skip to content

Instantly share code, notes, and snippets.

View volovikariel's full-sized avatar
🦒
Stay awesome

Ariel Volovik volovikariel

🦒
Stay awesome
View GitHub Profile
@volovikariel
volovikariel / myeval.py
Last active March 28, 2024 16:39 — forked from iafisher/myeval.py
A simple implementation of a recursive-descent parser for a language of boolean expressions.
"""
A simple implementation of a recursive-descent parser for a language of boolean expressions.
Forked from: https://gist.github.com/iafisher/6f53ce4df29c91ac9276c13a113ccf9f
This fork aims to allow for strings instead of 0 and 1 symbols, and these strings themselves are then to be evaluated.
e.g: Instead of (0 or 1), you could have (is_happy or is_sad).
Additionally, allow for multiple operators within a single set of parentheses, not only boolean.
e.g: Allow for (0 or 1 or 2 or 3 or 4 or 5 ...)
Note that only a single operator type is allowed however, as it'd be ambiguous otherwise.