COMPILER DESIGN

SYNTAX ANALYSIS

ROLE OF THE PARSER

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Which of the following parser is a top-down parser?
A
An LALR parser
B
An LR parser
C
Operator precedence parser
D
Recursive descent parser
Explanation: 

Detailed explanation-1: -Predictive parser and recursive descent parser are example of top-down parser. Whereas LR(k) and LALR(k) parser are bottom up parser.

Detailed explanation-2: -In computer science, a recursive descent parser is a kind of top-down parser built from a set of mutually recursive procedures (or a non-recursive equivalent) where each such procedure implements one of the nonterminals of the grammar.

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

Detailed explanation-4: -A top-down parser that uses a one-token lookahead is called an LL(1) parser. The first L indicates that the input is read from left to right. The second L says that it produces a left-to-right derivation. And the 1 says that it uses one lookahead token.

Detailed explanation-5: -Examples of top-down parsing algorithms include recursive descent parsing and LL parsing. Recursive descent parsing involves writing a set of recursive procedures to recognize the language of a grammar, while LL parsing involves building a predictive parsing table from a given grammar and using it to parse the input.

There is 1 question to complete.