December 2009
Intermediate to advanced
380 pages
9h 2m
English
| Pattern 1 | Mapping Grammars to Recursive-Descent Recognizers |
This translates a grammar to a recursive-descent recognizer that matches phrases and sentences in the language specified by the grammar.
This pattern identifies the core control-flow framework for any recursive-descent lexer, parser, or tree parser.
Even when building lexers and parsers by hand, the best starting point is a grammar. Grammars are a very concise way to express the languages you intend to recognize. Not only that, but grammars are excellent documentation that can go into a reference manual and into parsing code as comments. This pattern gives us a way to build recognizers directly from grammars.
A word of caution: this pattern works for many but not all ...