This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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. |