Which of the following statements are TRUE? I. Top-down parsers are equipped to handle left recursive grammar. II. LALR parser is more powerful than an SLR parser. III. Recursive descent parsing is an example of top-down parsing.

Which of the following statements are TRUE? I. Top-down parsers are equipped to handle left recursive grammar. II. LALR parser is more powerful than an SLR parser. III. Recursive descent parsing is an example of top-down parsing. Correct Answer II and III

The correct answer is option 4.

Concept:

Option 1: Top-down parsers are equipped to handle left recursive grammar.

False, A top-down parser cannot handle left recursive productions. To understand why not, let's take a very simple left-recursive grammar.

S → a

S → S a

There is only one token, a, and only one nonterminal, S. So the parsing table has just one entry. Both productions must go into that one table entry.

Option 2: LALR parser is more powerful than an SLR parser.

True, Canonical LR is the most powerful parser as compared to other LR parsers. Order: LR(0)< SLR < LALR < CLR.

Option 3: Recursive descent parsing is an example of top-down parsing.

True, Recursive descent is a top-down parsing technique that constructs the parse tree from the top and the input is read from left to right. It uses procedures for every terminal and non-terminal entity. This parsing technique recursively parses the input to make a parse tree, which may or may not require back-tracking.

Hence the correct answer is II and III.

Related Questions

Assume that the SLR parser for a grammar G has n1 states and the LALR parser for G has n2 states. Hence which one is true?
Assume that the SLR parser for a grammar G has n1 states and the LALR parser for G has n2 states.