INTERMEDIATE🔥 High-Yield Exam Topic 4 min read 4 views
LL(1) & LR(0), SLR(1), LALR(1), CLR(1) Parsing Power & Conflicts
FIRST/FOLLOW rules, parsing hierarchy Venn relationships, state count equality between SLR(1) and LALR(1), and ambiguity.
LL(1) Grammar Necessary & Sufficient Conditions
- Grammar must be free of Left Recursion (an left-recursive grammar can never be ).
- For every non-terminal :
- If , then .
🚨 Exam Trap Alert
Ambiguous Grammars: An ambiguous grammar can NEVER be or for any ! Also, when merging states with identical cores to form , no new Shift-Reduce conflict can ever arise — only a Reduce-Reduce conflict can be introduced!
📐 Quick Revision Formula Sheet
Expressive Power Inclusion
💡 LL(1) subsetneq CLR(1), and every LL(1) or LR(k) grammar is UNAMBIGUOUS!
DFA State Count Relationship
💡 Merging CLR(1) cores to form LALR(1) can NEVER introduce Shift-Reduce conflicts (only Reduce-Reduce)!
#Compiler Design#Parsing#LL1#LR
🎯 Practice PYQs on This Topic (4)
Q1.GATE CS Compiler PYQMCQMEDIUM
+2 Marks • -0.67 NegWhich of the following statements about bottom-up LR parsers is FALSE?
Q2.GATE CS CompilerMCQEASY
+1 Marks • -0.33 NegWhich pair of bottom-up LR parsers always have the exact same number of states for any given context-free grammar?
Q3.GATE CS CompilerMCQMEDIUM
+2 Marks • -0.67 NegIf a Context-Free Grammar is ambiguous, which of the following statements is guaranteed to be TRUE?
Q4.GATE CS CompilerMCQEASY
+2 Marks • -0.67 NegHow many lexical tokens does a C lexical analyzer emit for the statement: printf("i = %d, &i = %x", i, &i);?