Open source · Featured · 2023
Parsing, made visible.
Act I
LR(0) parsing makes sense on a whiteboard and evaporates the moment you look away. I wanted to make it tangible: type any grammar and watch the item sets, the parse table, and the parser’s every move build in front of you.
Act II
Type a grammar and the whole LR(0) pipeline builds in the browser on a two-pane workbench: the grammar and its numbered rules stay on the left while the item sets, the canonical collection drawn as a pannable SVG automaton, the ACTION/GOTO table, and a step-through parse fill the right. A conflict keeps both actions, names the items that disagree, and says whether one symbol of lookahead would settle it; the parse grows its tree with every reduce, and a separate six-phase walkthrough builds each state one move at a time. I rebuilt the engine as a framework-free set of pure functions (grammar, item sets, table, FOLLOW, parse, tree) covered by unit tests, with the React UI just rendering their output.
Intermission, the demo
S → id + id · shift, shift, shift, reduce, the table decides every move
five moves of an LR(0) parse, stepping like the classroom tool does
The cast
Read the card, then flip it to watch the mechanism run.
0x01
A worklist closure/goto loop runs to a fixed point with structural set-equality dedup, so identical item sets collapse into one state.
how it works
0x02
Reduce-state detection with explicit end-marker and accept handling. When two actions land in the same cell, both are kept and flagged as a shift/reduce or reduce/reduce conflict, and FOLLOW sets decide whether SLR(1) would resolve it.
how it works
0x03
Dual state and symbol stacks step through an input string with per-step snapshots and graceful, explained errors, and every reduce adds a node to the parse tree drawn beside the trace.
how it works