Skip to content
oschrenk edited this page Sep 8, 2012 · 6 revisions

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.

Clone this wiki locally