3.4 Recursive-Descent Parsing
A seminal discovery in computer science was that the grammar used to generate sentences from the language can also be used to recognize (or parse) sentences from the language. This dual nature of a grammar is discernible in a recursive-descent parser, whose implementation follows directly from a grammar. The code for a recursive-descent parser mirrors the grammar for the language it parses. Thus, a grammar provides a design for the implementation of a recursive-descent parser.
Specifically, we construct a recursive-descent parser as a collection of functions, where each function corresponds to one non-terminal in the grammar and is responsible for recognizing the sub-language rooted at that non-terminal. The right-hand ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access