15.9. Creating the Jaql Parser

The code for the parsers (ComparisonParser and JaqlParser) is in each case almost a direct translation of the grammars, following the rules in Section 3.6 “Translating a Grammar to Code.” Both parsers require a Speller instance variable and a constructor that accepts a speller. A JaqlParser object passes its speller to a ComparisonParser object, which uses the speller when it sees a variable name.

Other than spelling, the only addition to make to ComparisonParser and JaqlParser in sjm.examples.query is to plug in their assemblers.

Get Building Parsers with Java™ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.