Eliminating Left Recursion & Left Factoring
Lecture 17 of CS606 Compiler Construction investigates the two indispensable grammar transformation algorithms required to make grammars compatible with top-down LL(1) predictive parsing: eliminating left recursion and left factoring. A grammar is Left-Recursive if it contains a non-terminal A that can derive a sentential form starting with A itself (A =>+ A alpha). Immediate left recursion (A -> A alpha | beta) causes top-down parsers to enter an infinite loop. Students master the mathematical transformation that replaces left-recursive rules with right-recursive rules using a fresh non-terminal: A -> beta A_prime, and A_prime -> alpha A_prime | epsilon. The algorithm for eliminating indirect left recursion across multiple non-terminals is also detailed. Furthermore, students learn Left Factoring, a transformation that extracts common prefixes from alternative productions (A -> alpha beta1 | alpha beta2 becomes A -> alpha A_prime, A_prime -> beta1 | beta2), ensuring the parser has sufficient lookahead to make deterministic choices. 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. Comprehensive coverage of IEEE and ACM curricula standards ensures learners communicate with technical precision across global systems engineering teams. Detailed analysis of machine code selection highlights the imperative of generating instruction sequences that maximize hardware pipeline throughput. Intermediate representation taxonomy categorizes structural formats into graphical ASTs, linear tuples, and hybrid tree-address models.
No questions available yet.
There are currently no examination questions published for Eliminating Left Recursion & Left Factoring. Explore other curriculum units or build a custom quiz with the practice builder.