• Tutorials
  • DSA
  • Data Science
  • Web Tech
  • Courses
August 30, 2022 |12.2K Views

Recursive Descent Parser with Example in Compiler Design

  Share  1 Like
Description
Discussion

In this video, we will be discussing what is recursive descent parser & the steps for constructing recursive descent parser.

The parser which is using recursive functions or procedures to parse any given string, it is known as a Recursive descent parser. This parser uses the Top Down Parsing technique, without the involvement of backtracking. 
It uses different recursive procedures for processing the given string, with the help of Recursive languages.

The main approach of this parsing is relating every non-terminal with their corresponding procedures. Every procedure reads a sequence of given characters that can possibly be produced by that non-terminal.

Recursive descent Parser cannot parse Left Recursive or Left Factored Grammar. After removing left recursion as well as left factoring from any grammar, it is ready to be scanned/ parsed by any recursive descent parser. 

Recursive Descent Parsers aren’t as fast as some of the parsing methods. It’s quite difficult to provide good or meaningful error messages in Recursive Descent Parsers.

Steps for constructing Recursive Descent Parser:

  • The RHS of a production rule is being converted into the code one by one symbol.
  • If any non-terminal is given as input, then a procedure call is made corresponding to that non-terminal procedure.
  • If any terminal is given as input, then it’s matched with the input’s look-ahead.
  • If the production rule is having more alternates, then these alternatives should be combined into a single procedure.
  • Initially, the parser is activated by the start symbol’s procedure call.

Recursive Descent Parser
https://www.geeksforgeeks.org/recursive-descent-parser/