Rule execution in Interlibr is made up of three stages: compilation, execution and revision. This library implements the compilation stage. Its role is to read source rules in Xalgo format and compile this to an internal JSON format that is (eventually) stored in MongoDB. This library merely implements the parsing of the rules using a PEG parser. It is designed to be integrated with a larger service that stores and manages rule packages.
This library parses the complete specification for Xalgo and can therefore be seen as a completed work. Eventually, for project harmony purposes this library will be ported to Scala and this implementation retired.
After cloning the repository you will need a working Ruby environment. We recommend using rbenv and ruby-build. When you have those packages installed, you should install the version of Ruby required by this library (currently: 2.4.2) and the bundler gem:
$ rbenv install 2.4.2
$ gem install bundler
The library is self-bootstrapping, so you can simply use bundler to install all of the dependancies and run the unit tests to verify your installation:
$ bundle install
$ bundle exec rspec
Both of these commands should complete successfully if the build status badge above is indicating that the latest build is successful. If you encounter an error, please log an issue in this project (include the output of the failure).
This project includes a command-line tool to create internal JSON that represents the compiled rule. To run this tool, use:
$ bundle exec ruby cli.rb <path to .rule> <path to output .rule.json>
For example:
$ bundle exec ruby cli.rb test-runs/map/map.rule test-runs/map/map.rule.json
This compiles a test rule from the interpreter project in order use the JSON to validate the interpreter. If you encounter and errors while running a compilation, log an issue (with the error output) in this project.