O'Reilly logo

Building Parsers with Java™ by Steven John Metsker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

15.8. Jaql Grammar

You can define a grammar for Jaql using a top-down approach, starting with the grammar

select = "select" variables "from" classNames optionalWhere; 

If your users are familiar with SQL, the words select and from will be familiar to them. For your own query language, you can use other words such as show or present. As a language designer, you should determine the keywords of your language according to the effect they will have on your users.

As a first cut, you can model variables and classNames as repetitions of words, separated by commas:

 select = "select" variables "from" classNames optionalWhere; variables = commaList(variable); variable = Word; classNames = commaList(className); className = Word; optionalWhere = empty ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required