This is a cross-platform library for parsing boolean arithmetic expressions like
a && b && (!c || !d) and evaluating them by assigning values to the variables.
Boolean expressions are parsed into an abstract syntax tree (AST) using a lexer/parser generated by various Lex/Yacc clones for the various programming languages. This allows grammars to be fairly similar across languages.
Evaluation of the boolean expressions is done by traversing the AST with a visitor. (This is obviously overkill for something as simple as boolean expressions, keep reading to understand why).
The purpose of this library is twofold.
First, it serves as a simple example of how to build a custom interpreted language with a fast lexer/parser that build a visitor-traversable AST, and that runs on many different platforms. People who want to build a bigger cross-platform language could leverage the structure and build files in this project. A new Gherkin 3.0 project may use this project as a template.
Second, this project actually has a use. The Cucumber project may use it to evaluate tag expressions as current Cucumber implementations don't have a proper parser for this.
Building for all platforms
If you're lucky and already have all the needed software installed you can just run
If that fails for you (it probably will the first time), don't worry. Follow the OS-specific instructions below and try again. If you still run into problems, see the relevant READMEs in the sub directories.
OS X ships with an old Bison we can't use. You need to install a newer one. It's easy to do this with Homebrew. After installing Homebrew you must install Homebrew-Dupes before you can install Bison and the other requirements:
brew tap homebrew/dupes brew install bison flex wget node
Ubuntu users can install the needed software with:
sudo apt-get install bison flex wget node mingw32
Fedora 18 can install the needed software with:
yum install bison flex wget node mingw32-gcc