Questions: LL Parsing and Predictive Parsing

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

A grammar contains the rule: Expr → Expr + Term | Term. When a recursive descent parser attempts to apply this rule, what happens?

AThe parser generates an ambiguity warning and falls back to the second alternative
BThe parser correctly handles it by checking if the next token is '+' before recursing
CThe parser enters an infinite loop because it calls the Expr function without consuming any input
DThe parser fails immediately with a syntax error because '+' is not in the FIRST set of Expr
Question 2 Multiple Choice

When does an LL(1) parser fail to determine which production to apply for a given nonterminal?

AWhenever the nonterminal has more than two alternative productions
BWhen two or more alternative productions have overlapping FIRST sets — the same token could begin multiple alternatives
CWhen the lookahead token does not appear in the grammar at all
DWhenever the grammar contains epsilon (empty) productions
Question 3 True / False

In a recursive descent parser, the call stack implicitly serves as the parsing stack, with each grammar nonterminal implemented as a function.

TTrue
FFalse
Question 4 True / False

An LL(2) parser can handle left-recursive grammars that LL(1) can seldom, because it can 'look ahead' past the recursive call to see how the rule eventually terminates.

TTrue
FFalse
Question 5 Short Answer

Why must LL grammars be free of left recursion, and what does the standard transformation to eliminate it cost you?

Think about your answer, then reveal below.