| Recursive Descent Parser |
Article Index for Recursive |
Website Links For Descent |
Information AboutRecursive Descent Parser |
| CATEGORIES ABOUT RECURSIVE DESCENT PARSER | |
| parsing algorithms | |
| articles with example c code | |
| SHOPPER'S DELIGHT | |
|
A predictive parser is a recursive descent parser with no backup. Predictive parsing is possible only for the class of LL(k) grammars, which are the context-free grammars for which there exists some positive integer k that allows a recursive descent parser to decide which production to use by examining only the next k tokens of input. (The LL(k) grammars therefore exclude all ambiguous grammars, as well as all grammars that contain left recursion. Any context-free grammar can be transformed into an equivalent grammar that has no left recursion, but removal of left recursion does not always yield an LL(k) grammar.) A predictive parser runs in Linear Time . Recursive descent with backup is a technique that determines which production to use by trying each production in turn. Recursive descent with backup is not limited to LL(k) grammars, but is not guaranteed to terminate unless the grammar is LL(k) . Even when they terminate, parsers that use recursive descent with backup may require Exponential Time . A Packrat Parser is a modification of recursive descent with backup that avoids nontermination by remembering its choices, so as not to make exactly the same choice twice. A Packrat Parser runs in Linear Time , but usually requires more space than a predictive parser. Although predictive parsers are widely used, programmers often prefer to create LR or LALR parsers via parser generators without transforming the grammar into LL(k) form. Some authors define the recursive descent parsers as the predictive parsers. Other authors use the term more broadly, to include recursive descent with backup and Packrat Parser s EXAMPLE PARSER The following EBNF Grammar (for Niklaus Wirth 's PL/0 programming language, from Algorithms + Data Structures = Programs ) is in LL(1) form:
|