class: center, middle # Recursive Descent Parsing _CMPU 331 - Compilers_ --- # Recursive Descent Another kind of top-down parsing. * Is LL(k) * "left-to-right" scan of input * "left-most derivation" * Potentially infinite lookahead, "k", though limited in practice for efficiency * Must have left recursion eliminated * Unlike LL(1): * Define a function for each rule, instead of looking up the production in a parsing table * At each step, multiple choices of production to use * Backtracking used to undo bad choices --- # Parse::RecDescent * Library in Perl * [https://metacpan.org/pod/Parse::RecDescent](https://metacpan.org/pod/Parse::RecDescent) --- # Parsec * Library in Haskell * [https://wiki.haskell.org/Parsing_a_simple_imperative_language](https://wiki.haskell.org/Parsing_a_simple_imperative_language) --- # Hand-written * Simple one in C: page 97, section 5.1.1 of the textbook * Example in Python, using the same style of lexer as the project