Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Clone this wiki locally
The calculator examples live in the org.parboiled.examples.calculators package and are a series of example parsers show-casing various parboiled solution approaches around a simple calculator language.
The first one, the CalculatorParser0 is a simple recognizer for the following basic grammar, without any parser actions:
Expression ← Term ((‘+’ / ‘-’) Term)*
Term ← Factor ((‘*’ / ‘/’) Factor)*
Factor ← Number / Parens
Number ← Digit+
Parens ← ‘(’ expression ‘)’
Digit ← [0-9]
The calculator examples 1 through 4 gradually add more functionality to the parser and are a worthy source of inspiration for parboiled newbies and advanced users alike.