LALR(1) parsing combines LR(1) power with much smaller parsing tables. LALR is widely used in parser generators because it handles most programming language grammars efficiently while remaining practical to implement.
Use Yacc/Bison to generate LALR parsers and study generated tables and state machines. Manually construct LALR states for a small grammar.
LALR loses power compared to LR(1) (LALR handles 99% of real language grammars). Parser generator bugs are your fault (always check generated tables and conflict reports).
You already know that LR(1) parsing builds a state machine where each state carries items annotated with one token of lookahead, and that this machinery is powerful enough to parse virtually all deterministic context-free grammars. The problem is scale: a canonical LR(1) parser for a real programming language can produce thousands of states, because states that differ only in their lookahead sets are treated as distinct. LALR(1) solves this by observing that many of those states have identical cores — the same set of dotted productions — and differ only in which lookahead tokens they carry. LALR construction merges all states that share a core, combining their lookahead sets into a single state.
The practical effect is dramatic. Where a canonical LR(1) parser for C might require several thousand states, the corresponding LALR(1) parser typically needs only a few hundred — comparable to an SLR parser in size, but far more powerful. The construction process starts from the LR(0) or LR(1) item sets you have already learned to build. You compute the full canonical LR(1) collection, then identify states whose cores match and merge them. Alternatively, many implementations compute LALR lookaheads directly on the LR(0) automaton using algorithms like DeRemer and Pennello's, which avoids ever building the full LR(1) collection.
Merging can, in rare cases, introduce reduce/reduce conflicts that the full LR(1) parser would not have. This happens when two states with different lookahead sets are forced to share a merged set, creating ambiguity about which reduction to apply. Importantly, merging never introduces shift/reduce conflicts — those depend on the core, not the lookahead. In practice, this loss of power is almost never a problem for real programming languages, which is why tools like Yacc and Bison default to LALR(1).
When you use a parser generator, understanding LALR construction helps you read conflict reports. A shift/reduce conflict means the grammar is genuinely ambiguous at that point (or needs restructuring). A reduce/reduce conflict may indicate a real grammar problem or, rarely, a case where LALR merging lost information that canonical LR(1) would have kept. In either case, the fix is usually to refactor the grammar or add explicit precedence and associativity declarations — not to abandon LALR for a more expensive parsing strategy.