Questions: LALR Grammar Construction

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

A parser generator reports a reduce/reduce conflict in the LALR(1) parser for a grammar that had no conflicts in the canonical LR(1) parser. What is the most likely explanation?

AThe grammar is inherently ambiguous — both parsers should have reported the conflict
BLALR merging combined the lookahead sets of two LR(1) states that shared a core, creating ambiguity about which reduction to apply in the merged state
CThe parser generator has a bug; LALR and LR(1) must agree on all conflicts for any grammar
DThe conflict is a shift/reduce conflict that LALR reports differently than LR(1)
Question 2 Multiple Choice

What specifically does LALR(1) merge compared to canonical LR(1), and what is the primary practical benefit?

ALALR merges any two states whose actions agree, reducing table size at the cost of accepting slightly fewer grammars
BLALR merges LR(1) states that have identical cores (same set of dotted productions) but possibly different lookahead sets, dramatically reducing the number of states to near SLR-level compactness
CLALR merges shift and reduce actions into combined entries, reducing memory usage in the action table
DLALR merges grammars with identical start symbols, allowing multiple grammars to share a single parser
Question 3 True / False

Merging states in LALR construction can introduce shift/reduce conflicts that would not exist in the canonical LR(1) parser for the same grammar.

TTrue
FFalse
Question 4 True / False

LALR(1) parsers handle virtually all programming language grammars used in practice, making them the default choice in tools like Yacc and Bison despite being theoretically less powerful than canonical LR(1).

TTrue
FFalse
Question 5 Short Answer

Explain why LALR(1) can sometimes produce reduce/reduce conflicts that canonical LR(1) would not have, and why this rarely matters in practice.

Think about your answer, then reveal below.