December 2009
Intermediate to advanced
380 pages
9h 2m
English
Differentiating some language constructs is easy. For example, in the following element rule from the list-of-names language in Tokenizing Sentences, a single token of lookahead dictates which alternative to choose:
| | element : NAME | list ; // element is name or nested list |
| | list : '[' elements ']' ; // match bracketed list |
| | … |
Token NAME predicts the first alternative, and [ predicts the second because list starts with [.
Sometimes, though, the most natural way to express a given language construct does not fit in Pattern 3, LL(1) Recursive-Descent Parser or Pattern 4, LL(k) Recursive-Descent Parser. Such language constructs are typically very similar and only differ on the right side. For example, ...
Read now
Unlock full access