Skip to content

Save parser automata with --graph-snapshot - #888

Open
ydah wants to merge 5 commits into
feature/graph-pipelinefrom
feature/graph-snapshot
Open

ydah wants to merge 5 commits into
feature/graph-pipelinefrom
feature/graph-snapshot

Conversation

@ydah

@ydah ydah commented Dec 3, 2026

Copy link
Copy Markdown
Member

Save a versioned JSON snapshot of a parser automaton for comparison with another grammar or Lrama revision. For example, this saves the automaton while generating the parser as usual.

lrama --graph-snapshot=base.json -o /dev/null sample/calc.y

Lrama::Automaton::Snapshot records kernels, transitions, reductions, conflicts and precedence resolutions. Rules and kernel items use grammar symbols and production text, so renumbering a rule or a midrule action preserves its identity. An unconditional reduction has no comparable lookahead set. Lrama writes the snapshot before checking %expect, so the state that caused the failure is available for inspection.

Without an explicit filename, the snapshot is written next to the grammar as <stem>.graph.json. The reader accepts additional fields in version 1 and rejects unsupported versions, invalid state references and ambiguous transitions or reductions. All valid grammar fixtures round-trip. All 844 examples and Steep pass.

@ydah
ydah added this pull request to stack #889 December 3, 2026 06:04

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant