Resolving Shift-Reduce & Reduce-Reduce Conflicts
Lecture 29 of CS606 Compiler Construction investigates parsing table conflicts that arise when a grammar violates the determinism criteria of LR parsing. A Shift-Reduce conflict occurs when a state contains both an item ready to shift on terminal a [A -> alpha . a beta, b] and an item ready to reduce on lookahead a [B -> gamma ., a], leaving the parser unable to decide between shifting or reducing. A Reduce-Reduce conflict occurs when a state contains two distinct items both ready to reduce on the same lookahead a. Students explore the root causes of conflicts: inherently ambiguous grammars (such as the dangling-else problem or expression grammars without explicit operator hierarchy) and insufficient lookahead power. The lecture demonstrates how modern parser generators resolve shift-reduce conflicts using declarative %left, %right, and %nonassoc precedence directives, enabling concise grammar specifications. Shift-reduce and reduce-reduce grammatical conflicts are analyzed alongside operator precedence declarations to eliminate parsing ambiguities. The curriculum traces the progressive transformation of source text through tokens, parse trees, abstract syntax trees, and linear three-address tuples. Practical considerations for short-circuit boolean evaluation and label backpatching provide rigorous quantitative decision support for control flow compilation. Scholars examine how type checking systems enforce static semantic consistency across arithmetic expressions, assignments, and function signatures. Memory management techniques spanning static allocation, stack-based activation records, and heap allocation are evaluated in detail. The lesson explores register allocation heuristics, demonstrating how Chaitin graph coloring minimizes memory spills in CPU register starved environments. Quadruple, triple, and indirect triple data structures are compared regarding memory overhead and ease of compiler instruction reordering. Students study intermediate code generation for multidimensional array references, evaluating base addresses and row-major displacement calculations. Key compiler optimization passes spanning loop invariant code motion, constant folding, and dead code elimination are systematically demystified. By engaging with solved past papers by Moaaz and Waqar Siddhu, learners gain actionable insights into recurrent university exam questions. Interactive quiz assessments on VU SIGMA facilitate rapid knowledge verification and retention of critical compiler engineering terminology.
No questions available yet.
There are currently no examination questions published for Resolving Shift-Reduce & Reduce-Reduce Conflicts. Explore other curriculum units or build a custom quiz with the practice builder.