Parsing formulas
Parsing: top-down and bottom-up parsers. 6 formulas for GATE CS Compiler Design, each with when to use it. Each is explained in the topic notes.
IAE Academy: Parsing: top-down and bottom-up parsers formulas (GATE CS)
All 6 Parsing formulas
REMOVING IMMEDIATE LEFT RECURSION
Conditions: no starts with , and no is . is a new nonterminal. The new grammar has alternatives in total: for and for .
LEFT FACTORING
Applies when two or more alternatives of share a nonempty prefix (take the longest one); is a new nonterminal, and an empty becomes . Repeat until no two alternatives of any nonterminal share a prefix.
LL(1) CONDITION
Also at most one alternative of may derive . The condition holds for every nonterminal exactly when no cell of the LL(1) table has two entries.
MOVES OF A DETERMINISTIC PARSER
Applies to LL(1) and LR parsers on an accepted string of tokens whose parse tree has internal nodes, not counting the augmented start . In LL, counts the matches and the expansions; in LR, counts the shifts and the reductions. A node for an -production counts in . Accept, and the final match of $, are not counted unless the question says so.
LR(1) CLOSURE
If is empty or nullable, itself is among the new lookaheads. The initial item is with lookahead $. Goto works exactly as in LR(0), carrying the lookaheads along unchanged. Reduce by only on the item's own lookahead.
GRAMMAR-CLASS HIERARCHY
Each inclusion is proper. A grammar class here means the set of grammars the method parses without conflict. LL(1) is not contained in LALR(1), SLR(1) or LR(0), and none of those is contained in LL(1): LL(1) is incomparable with each of them. More generally every LL(k) grammar is LR(k).
Where this was asked: 2018 (1), 2020 (1), 2022 (2), 2024 (4), 2025 (3), 2026 (2). See the 13 previous-year questions on Parsing. This shows what was asked, not what will be asked.