Cheat sheets

CD-07Cheat sheet1 pageIn a paid pack

Shift-Reduce Parsing and Handles

Bottom-up parsing as a rightmost derivation in reverse: handles, handle pruning and viable prefixes. A full SLR-driven trace of id * id + id with states, input and action, counted shifts and reductions, the four actions, and the two kinds of conflict with their usual causes. Operator-precedence parsing in brief: operator grammars, the precedence relations computed from LEADING and TRAILING sets, and the limits of the method. All tables and traces come from a script.

CD-08Cheat sheet1 pageIn a paid pack

LR(0) Automaton and SLR Tables

LR(0) items, closure and goto, and the canonical collection built step by step, with the seven-state automaton of S → AA, A → aA | b drawn and its LR(0) and SLR tables in full. How to count items versus states, when a state is free of LR(0) conflicts, why the expression grammar fails LR(0) on * and passes SLR, how ε-productions create complete items in the start state, and a solved past question that counts LR(0) shift-reduce conflicts cell by cell. Every set, table and count comes from a script.

Diagrams from CD-08

CD-09Cheat sheet1 pageIn a paid pack

CLR(1) and LALR(1) Parsing

LR(1) items and the closure rule that computes lookaheads from FIRST(βa). The ten canonical LR(1) states of S → AA, A → aA | b and how equal cores merge into the seven LALR(1) states. Why S → L = R | R is LALR(1) but not SLR(1), why a grammar can be CLR(1) but not LALR(1) (merging creates reduce-reduce conflicts, never shift-reduce ones), state-count facts for the standard grammars, LALR error detection, and a solved past question. Every state, lookahead and count comes from a script.

CD-10Cheat sheet1 pageIn a paid pack

Which Parser Accepts Which Grammar

A master comparison of LL(1), LR(0), SLR(1), LALR(1) and CLR(1) parsers: direction, items, where reductions go, state counts and the conflicts each can have. A class map with seven script-checked separating grammars, including an LL(1) grammar that is not LALR(1), an ordered conflict-detection routine, statements about grammar classes that hold and those that do not, and the difference between grammar classes and language classes.

Diagrams from CD-10