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

6.6. Summary

A grammar establishes the pattern of strings that make up a language. You can think of a grammar running forward, generating strings, or running backward, recognizing strings. Equivalent grammars may recognize the same strings in different orders.

This means that you can use a grammar to specify the order in which to recognize operators, and that in turn lets you control precedence and associativity.

Once you have a grammar that recognizes the strings of your language in the right order, you must consider potential infinite loops when you implement the grammar with a parser. You can remove left recursion in the grammar by transforming it to an equivalent grammar that recognizes the same strings in the same order, but without using ...

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