`: prints the parser states that can reject
+ a token, as a template for per-state messages to `errorMessage`.
### Changed
-- Breaking: the generated specification is a `Runtime.SpanGrammar` (`spanGrammarInst`);
- `grammarInst` is its derived `Grammar`, with token type `Runtime.Positioned Tok`. Each
- `semanticAction` takes the right-hand-side spans first. `ParserStartTree`,
- `toStream` and the dependent `parse` take positioned tokens. `parse_eq_dependent`,
- `parser_sound`, `parser_complete`, `parser_err_free` and `parser_ne_err` are stated on
- positioned tokens with their real spans (`E.parse input`, not
- `E.parse (input.map (⟨·, Span.dummy⟩))`); the tree value is
- `Runtime.SpanGrammar.ptSem ⟨0⟩ tree`. `parser_unambiguous` takes a start position
- (default byte 0) and also equates the spans. `parseStr_*` theorems state
- `toStream ts` instead of `toStream (ts.map (·.val))`. No generated theorem takes `hspan`.
+- Breaking: the generated specification is over positioned tokens. `parse_eq_dependent`,
+ `parser_sound`, `parser_complete`, `parser_err_free` and `parser_ne_err` are stated for
+ the real token spans (`E.parse input`, not `E.parse (input.map (⟨·, Span.dummy⟩))`); a
+ tree's value is `Runtime.SpanGrammar.ptSem ⟨0⟩ tree`; `parser_unambiguous` also equates
+ spans and returns a conjunction. Each `semanticAction
` takes the right-hand-side
+ spans first. `%option roundtrip_parser` constructors build trees over
+ `Positioned.dummy` words.
- Breaking: the span of an empty right-hand side is the empty span at the end of the last
- shifted token (byte 0 at the start), as in the Rust backend, instead of `Span.dummy`.
- This changes `run` results and span values read by actions, not `parse` values of
- span-free grammars.
-- Breaking (runtime API): `ExecTable.sem` and `FlatTable.sem` take the stack below the
- popped cells (`Nat → Stack V → List V → V`); generated parsers define
- `sem := Runtime.Exec.spanSem semV` with `semV : Nat → List Span → List V → V`.
- `StackOps` has a new field `endPos` with the law `endPos_eq`; generated stacks define
- `Stk.endPos` and `Stk.withTop`. `Runtime.Refinement.ExecRefinement` is over a
- `SpanGrammar`, with the new fields `semV` and `sem_agrees`, and `semantic_agrees` takes a
- span list. `Runtime.Refinement.Values` is now `Runtime.SpanGrammar.Values`.
-- Breaking: parse-tree constructors of `%option roundtrip_parser` build trees over
- dummy-positioned words (`(w : List Tok).map Positioned.dummy`), their `_sem` lemmas are
- stated for `SpanGrammar.ptSem pe`, and `Certificate.tree` is over
- `(tokens ++ [EOF]).map Positioned.dummy` with `semantics : SpanGrammar.ptSem ⟨0⟩ tree = value`.
-- The dependent `parse` is evaluated by `decide +kernel` in tests; plain `decide` does not
- finish on the derived span semantics.
-- Breaking: `parseStr_unambiguous` in `Verified` takes two derivations of `s`,
- `tokenize s = .ok ts₁` with a tree over `ts₁` and `tokenize s = .ok ts₂` with a tree over
- `ts₂`, and gives `ts₁ = ts₂` and equal values. It no longer takes two `Lexer.Lexing`
- derivations and two trees over an unrelated `ts`; `Lexer.Lexing.unique` gives the
- uniqueness of the steps.
-- Breaking: `parseStr_node_spans` concludes `Lexer.AllNodeText … s ⟨0⟩ tree` (every leaf
- is its lexeme in `s`, every node's span is a substring of `s` with `SpanFacts`) instead of
- `Lexes s ts ∧ SpanGrammar.AllSpanFacts ⟨0⟩ tree`.
-- Breaking: `parseStr_eq`, `parseStr_eq_dependent`, `parseStr_sound` and
- `parseStr_of_tokenize_error` in `Verified` no longer take `hlex : PosLexerAgrees`.
- A caller that passed `hlex` must drop that argument. `PosLexerAgrees` stays as an
- `abbrev`, with `posLexerAgrees : PosLexerAgrees`.
-- A `noEofEmit` proof for a rule that calls a helper falls back to `simp` with every
- `%lexerheader` definition when unfolding the helper alone fails, so a helper that calls
- another helper or branches on a `let` no longer makes the lexer fail to compile
- (`docs/LEXER.md`).
-
-- The list macros (`list`, `nonempty_list`, `separated_list`, `separated_nonempty_list`)
- are left-recursive and produce an `Array` in Lean and a `Vec` in Rust, instead of a
- `List` and a `VecDeque`. Grammars whose actions take a macro list as a `List` need
- `.toList` (Lean) or `.into()` (Rust, to a `VecDeque`). The LR stack no longer grows with
- the length of a list.
-- `separated_list(sep, X)` no longer accepts a trailing separator (`a, b,`), as documented;
- it is `ε` or `separated_nonempty_list(sep, X)`. A grammar that relies on the trailing
- separator, for example one translated from BNFC's `separator`, uses
- `separated_list_trailing(sep, X)` instead.
-- Generated Lean lexers read their actions from a table, `fastActs`, with
- `fastActs_agree` and `tokenize_eq_flat` proving the results unchanged. Lexing is
- 11–15% faster on the benchmarks.
+ shifted token, as in the Rust backend, not `Span.dummy`.
+- Breaking (runtime API): `ExecTable.sem`/`FlatTable.sem` take the stack below the popped
+ cells; generated parsers define `sem := Runtime.Exec.spanSem semV`; `StackOps` has a new
+ field `endPos`.
+- Breaking: the list macros are left-recursive and produce `Array` (Lean) / `Vec` (Rust)
+ instead of `List` / `VecDeque`. The LR stack no longer grows with the length of a list.
+- Breaking: `separated_list(sep, X)` no longer accepts a trailing separator; use
+ `separated_list_trailing`.
+- Generated lexers read their actions from a table (`fastActs`); lexing is 11–15% faster.
+- The CLI's `wrote …` lines give the dotted module name (`module MyProject.ExprParser`).
+- Tests evaluate the dependent `parse` with `decide +kernel`; plain `decide` does not finish.
### Removed
-- `Runtime.Exec.SpanIndependent`, `SemSpanFree`, `SemSpanFree.of_split`,
- `SpanIndependent.of_run`, `run_erase` and its helpers (`Runtime/ExecStream.lean`),
- `Runtime.Exec.runFast_ok_dummy` (`Runtime/ParseEnd.lean`); in generated modules,
- `semS`, `semSpanFree`, `parse_spanIndependent`, `SpanIndependent`, `spanIndependent`,
- `parse_eq_dependent_spans`, the `hspan` arguments, and the dummy-span form of
- `parse_eq_dependent`. They are not needed now that the specification has spans.
-- Lexer modules no longer emit `byteValidated{m}` (`Lexer.byteValidate`, a
- one-character-per-class check of the byte tables, `native_decide`). It does not imply
- that the byte and flat lexers agree, and no theorem used it; `byteUnicodeValidated`
- checks every character. It is removed rather than deprecated because nothing depends on
- it and versions before 1.0 may change the generated module API. `Lexer.byteValidate`
- stays in the library.
+- Lexer modules no longer emit `byteValidated{m}`; `byteUnicodeValidated` replaces it.
+
+### Fixed
+
+- The language server reports the tool version (`0.1.0-alpha.1`) instead of `0.1.0`.
### Experimental
-- Pull-based Rust API is always emitted: `TokenSource`, `SliceSource`, `NodeSink`,
+- Pull-based Rust API, always emitted: `TokenSource`, `SliceSource`, `NodeSink`,
`StreamError`, `parse_from`, `parse_values_from` and, with a `%lexer`, `Lexer`
- (`next_token`, `finish`), `parse_str` and `parse_values_str`. `tokenize`, `parse`
- and `parse_values` keep their signatures and results. `tokenize` alone is 3–4%
- slower, because it is now a loop over `Lexer::next_token`; lex+parse is unchanged.
+ (`next_token`, `finish`), `parse_str`, `parse_values_str`. `tokenize`, `parse` and
+ `parse_values` keep their signatures.
## [0.1.0-alpha.1] - 2026-11-27
diff --git a/LeanParserGenerator/Construct/Analysis.lean b/LeanParserGenerator/Construct/Analysis.lean
index f278a5d..2ba4a47 100644
--- a/LeanParserGenerator/Construct/Analysis.lean
+++ b/LeanParserGenerator/Construct/Analysis.lean
@@ -22,8 +22,6 @@ Construct the nullable and FIRST sets by a fixpoint over the grammar.
Both iterate a monotone fixpoint. They feed Pager closure and the generated
`nullableNt`/`firstNt` certificate annotations.
-
-See tests in `test/pager/ConstructionRegressionTest.lean`.
-/
public import LeanParserGenerator.IR.Grammar
@@ -35,9 +33,8 @@ namespace Construct
open IR
/-- Sorted-insert into a sorted, duplicate-free list of nats (our set repr).
- TODO: can we improve that repr and maintain the decidability of the generated
- proof obligations?
--/
+ Another set representation would have to keep the generated proof obligations
+ decidable. -/
def insertNat (x : Nat) : List Nat → List Nat
| [] => [x]
| y :: ys =>
diff --git a/LeanParserGenerator/Emit/Builder.lean b/LeanParserGenerator/Emit/Builder.lean
index 0490076..c825314 100644
--- a/LeanParserGenerator/Emit/Builder.lean
+++ b/LeanParserGenerator/Emit/Builder.lean
@@ -32,14 +32,6 @@ namespace Emit.Builder
/-- A Lean string literal for `value` (`reprStr` gives a `"…"` with standard escapes). -/
def strLit (value : String) : String := reprStr value
-/-- A `Nat` literal. -/
-def natLit (n : Nat) : String := toString n
-
-/-- An `Option Nat` literal (`none` / `some n`). -/
-def optNatLit : Option Nat → String
- | none => "none"
- | some n => s!"some {n}"
-
/-- Join fragments with a single separator. -/
def joinWith (sep : String) (parts : List String) : String := sep.intercalate parts
@@ -71,17 +63,6 @@ def publicizeImports (header : String) : String :=
else ln
"\n".intercalate ((header.splitOn "\n").map rewrite)
-/-- A Lean array literal `#[a, b, c]` from already-rendered element strings. -/
-def arrayLit (elems : List String) : String := "#[" ++ commaSep elems ++ "]"
-
-/-- A `Nat` list literal `[1, 2, 3]`. -/
-def natListLit (l : List Nat) : String := listLit (l.map natLit)
-
-/-- A top-level array-table def: `def {name} : Array {ty} := #[{elems}]`. Used for
- the flat action/goto/length tables. -/
-def arrayDef (name ty : String) (elems : List String) : String :=
- s!"def {name} : Array {ty} := " ++ arrayLit elems
-
/-- Names defined with `def` (or `abbrev`) in header text. -/
def headerDefs (header : String) : List String :=
let ws := (header.replace "\n" " ").splitOn " " |>.filter (!·.isEmpty)
diff --git a/LeanParserGenerator/Emit/Codegen.lean b/LeanParserGenerator/Emit/Codegen.lean
index bc43658..f901001 100644
--- a/LeanParserGenerator/Emit/Codegen.lean
+++ b/LeanParserGenerator/Emit/Codegen.lean
@@ -244,13 +244,6 @@ def emitSem (s : Surface) (e : TyEnv) (augProd : Nat) :
let semDef ← `(command| def $(mkIdent `sem) : $semSig := $semBody)
return #[semV, semDef]
-/-- Whether some action names a span variable (`_span` or `__s`), so its value
- may depend on token spans. -/
-def actionsReadSpans (s : Surface) : Bool :=
- s.rules.any fun r => r.alts.any fun alt =>
- alt.elems.zipIdx.any fun (elem, i) =>
- (alt.action.splitOn (spanVarName elem i)).length > 1
-
/-- The `Stk` cell constructor for a `V` constructor: `cUnit` for `unit`, `c` for
`v`. -/
def cellFor (ctor : String) : String :=
diff --git a/LeanParserGenerator/Emit/CodegenLexer.lean b/LeanParserGenerator/Emit/CodegenLexer.lean
index 2d9e5a6..1d0745f 100644
--- a/LeanParserGenerator/Emit/CodegenLexer.lean
+++ b/LeanParserGenerator/Emit/CodegenLexer.lean
@@ -310,8 +310,9 @@ def generateLexerFrom (surface : Surface) (moduleName : String) :
s!" ∀ s, ({moduleName}.fastActs.get 0 r).toAct s = ({moduleName}.fastActs.get 0 r).toAct \"\" :=\n" ++
s!" Lexer.FastActs.textIndep_of_forall₂ {moduleName}.fastActs ({moduleName}.cflat.textDep.getD 0 #[]) 0\n" ++
s!" {textChain}\n\n" ++
- s!"/-- A successful `tokenize` is a maximal-munch tokenization of the input, and the spec\n" ++
- s!" tokenizer `Lexer.tokenize` returns the same token values. -/\n" ++
+ s!"/-- If `tokenize` succeeds with `ts`, the input has a maximal-munch tokenization\n" ++
+ s!" (`Lexer.Tokenization`), and the spec tokenizer `Lexer.tokenize` returns the token values\n" ++
+ s!" of `ts`. -/\n" ++
s!"theorem {moduleName}.tokenize_sound \{input : String} \{ts : List (Runtime.Positioned {tokTy})}\n" ++
s!" (h : {moduleName}.tokenize input = .ok ts) :\n" ++
s!" Lexer.Tokenization {moduleName}.rules0 input.toList ∧\n" ++
diff --git a/LeanParserGenerator/Emit/CodegenVerified.lean b/LeanParserGenerator/Emit/CodegenVerified.lean
index 7abdf9e..ffaedc5 100644
--- a/LeanParserGenerator/Emit/CodegenVerified.lean
+++ b/LeanParserGenerator/Emit/CodegenVerified.lean
@@ -361,27 +361,6 @@ def emitToken (s : Surface) (eofIdx : Nat) : EmitM (Array (TSyntax `command)) :=
/-! ### Emitting the dependent `Automaton` instance -/
-/-- Emit an `Action` value for state `st` from the Pager tables. Either a
- `Default_reduce` (when the state has a default reduction) or a `Lookahead`
- function matching on the terminal index. Shift arms carry the `rfl` proof
- `Symbol.T term = lastSymb' target`; reduce arms name the production; `Fail`
- otherwise. -/
-def emitActionValue (tables : Tables) (numT' : Nat) (st : Nat) : String := Id.run do
- match tables.defaultReduce.getD st none with
- | some p => s!"Action.DefaultReduce ⟨{p}, of_decide_eq_true rfl⟩"
- | none =>
- let row := tables.action.getD st #[]
- let mut arms : Array String := #[]
- for t in [0:numT'] do
- let arm := match row.getD t Act.error with
- | .shift j => s!"LookaheadAction.Shift ⟨{j-1}, of_decide_eq_true rfl⟩ (by rfl)"
- | .reduce p => s!"LookaheadAction.Reduce ⟨{p}, of_decide_eq_true rfl⟩"
- | .error => "LookaheadAction.Fail"
- arms := arms.push s!" | ⟨{t}, _⟩ => {arm}"
- let body := "fun term => match term with\n" ++ "\n".intercalate arms.toList
- ++ "\n | _ => LookaheadAction.Fail"
- "Action.Lookahead (" ++ body ++ ")"
-
/-- Number of bits needed to store every value in `0 … n`. -/
def bitWidth (n : Nat) : Nat := Nat.log2 n + 1
@@ -820,8 +799,9 @@ def emitRefinement (s : Surface) (g' : IR.Grammar) (execModule : String) : Strin
" Grammar.ParseTree (G := grammarInst)",
" (.NT (startNt' (⟨0, of_decide_eq_true rfl⟩ : InitState))) word",
"",
- "/-- **Soundness.** An accepted token list starts with the word of a parse tree whose value,",
- " at the start of the input, is the result. -/",
+ "/-- **Soundness.** If `parse` accepts `input`, the EOF-padded stream of `input`",
+ " (`toStream input`) starts with the word of a parse tree whose value, at the start of the",
+ " input, is the result. -/",
"theorem parser_sound (input : List grammarInst.Token) (logNSteps : Nat)",
s!" (semantic : {nontermTy s s.ntNames realStart})",
s!" (accepted : {execModule}.parse input logNSteps = some semantic) :",
@@ -846,6 +826,8 @@ def emitRefinement (s : Surface) (g' : IR.Grammar) (execModule : String) : Strin
" refine ⟨word, tree, rest, inputEq, ?_⟩",
" rw [← valueEq, semanticEq]",
"",
+ "/-- **Error freedom.** The executable parser's `run` never returns `.err` (the result of",
+ " inconsistent tables), on every token list and fuel. -/",
"theorem parser_err_free (input : List grammarInst.Token) (logNSteps : Nat) :",
s!" Runtime.Exec.ResultErrFree ({execModule}.run input logNSteps) := by",
" have related := parserRunRefines input logNSteps",
@@ -864,6 +846,7 @@ def emitRefinement (s : Surface) (g' : IR.Grammar) (execModule : String) : Strin
" | timeout => trivial",
" | error message => exact dependentFree",
"",
+ "/-- `parser_err_free` as an inequality: `run` is not `.err message` for any `message`. -/",
"theorem parser_ne_err (input : List grammarInst.Token) (logNSteps : Nat)",
" (message : String) :",
s!" {execModule}.run input logNSteps ≠ .err message := by",
@@ -872,6 +855,7 @@ def emitRefinement (s : Surface) (g' : IR.Grammar) (execModule : String) : Strin
" rw [isError] at errorFree",
" exact errorFree",
"",
+ "/-- The EOF-padded stream of `input` is `input` followed by the stream of `[]`. -/",
"theorem toStream_eq_appList (input : List grammarInst.Token) :",
" toStream input = Runtime.AppStream.appList input (toStream []) := by",
" funext index",
@@ -1038,6 +1022,7 @@ def emitStreamTransfer (tokenType startTy E l : String) (eofIdx : Nat)
"",
s!"theorem posLexerAgrees : PosLexerAgrees := {l}.posLexerAgrees",
"",
+ "/-- When `tokenize` lexes `s` to `ts`, the positioned byte lexer `lexPos` returns `ts` too. -/",
s!"theorem lexPos_eq_of_tokenize (s : String) (ts : {posToks}) (h : {l}.tokenize s = .ok ts) :",
s!" Lexer.lexPos {l}.cbyte s = .ok ts := by",
" have hagree := posLexerAgrees s",
@@ -1047,16 +1032,21 @@ def emitStreamTransfer (tokenType startTy E l : String) (eofIdx : Nat)
" | error e => intro hc; simp [Except.toOption] at hc",
" | ok v => intro hc; simp [Except.toOption] at hc; rw [hc]",
"",
+ "/-- When `tokenize` lexes `s` to `ts`, `parseStr` on `s` is `parse` on `ts`. -/",
s!"theorem parseStr_eq (s : String) (k : Nat) (ts : {posToks})",
s!" (h : {l}.tokenize s = .ok ts) : {E}.parseStr s k = {E}.parse ts k := by",
hp,
s!" exact {E}.parseStr_eq_lexPos s k ts hp",
"",
+ "/-- When `tokenize` lexes `s` to `ts`, `parseStr` on `s` is the dependent `parse` on `ts`. -/",
"theorem parseStr_eq_dependent (s : String)",
s!" (k : Nat) (ts : {posToks}) (h : {l}.tokenize s = .ok ts) :",
s!" {E}.parseStr s k = parse ts k := by",
" rw [parseStr_eq s k ts h, parse_eq_dependent]",
"",
+ "/-- **Soundness of `parseStr`.** When `tokenize` lexes `s` to `ts` and `parseStr` accepts `s`",
+ " with value `p`, the EOF-padded stream of `ts` (`toStream ts`) starts with the word of a",
+ " parse tree whose value is `p`. -/",
"theorem parseStr_sound (s : String)",
s!" (k : Nat) (ts : {posToks}) (h : {l}.tokenize s = .ok ts) (p : {startTy})",
s!" (accepted : {E}.parseStr s k = some p) :",
@@ -1065,23 +1055,7 @@ def emitStreamTransfer (tokenType startTy E l : String) (eofIdx : Nat)
" toStream ts = Runtime.NatStream.appList word rest ∧",
" SpanGrammar.ptSem ⟨0⟩ tree = p := by",
" rw [parseStr_eq s k ts h] at accepted",
- " exact parser_sound ts k p accepted",
- "",
- "/-- When `tokenize` fails, the byte lexer delivers a prefix `ts` and fails, and `parseStr`",
- " is `none` or `parse` of an extension of `ts`. -/",
- "theorem parseStr_of_tokenize_error (s : String) (k : Nat)",
- s!" (e : Lexer.LexError) (h : {l}.tokenize s = .error e) :",
- s!" ∃ ts e', Runtime.Exec.Fails (Lexer.pullSource (Lexer.pullAux {l}.cbyte s.toUTF8))",
- s!" ⟨false, s.toUTF8.size + 1, 0, [{l}.cbyte.flat.base.start]⟩ ts e' ∧",
- s!" ∀ tail, {E}.parseStr s k = none ∨ {E}.parseStr s k = {E}.parse (ts ++ tail) k := by",
- s!" rcases {E}.parseStr_total s k with ⟨ts, hD, _⟩ | hF",
- " · exfalso",
- s!" have hp : Lexer.lexPos {l}.cbyte s = .ok ts :=",
- s!" Lexer.lexPosAux_of_denotes {l}.cbyte s.toUTF8 _ _ _ ts hD",
- " have hagree := posLexerAgrees s",
- " rw [hp, h] at hagree",
- " simp [Except.toOption] at hagree",
- " · exact hF" ]
+ " exact parser_sound ts k p accepted" ]
let failBlock := match eofCtor with
| none => ""
| some eof => "\n\n" ++ lines [
@@ -1091,6 +1065,7 @@ def emitStreamTransfer (tokenType startTy E l : String) (eofIdx : Nat)
s!" Symbol.T (⟨{eofIdx}, of_decide_eq_true rfl⟩ : Terminal) ∈ prodRhsRev' p := by",
" native_decide",
"",
+ s!"/-- Only the `{eof}` token has the terminal of the end marker `$`. -/",
s!"theorem tokenTerm_eq_end (t : {tokenType})",
s!" (h : tokenTerm' t = (⟨{eofIdx}, of_decide_eq_true rfl⟩ : Terminal)) : t = .{eof} := by",
" cases t <;> first | rfl | exact absurd (congrArg Fin.val h) (Nat.ne_of_beq_eq_false rfl)",
@@ -1107,6 +1082,7 @@ def emitStreamTransfer (tokenType startTy E l : String) (eofIdx : Nat)
s!" startProds_end input ⟨.{eof}, Runtime.Span.dummy⟩ rfl",
" (fun t ht he => hin t ht (tokenTerm_eq_end t.val he)) k hlen r rest",
"",
+ s!"/-- `dependent_ne_parsed_of_no_eof` for the dependent `parse`: it returns `none`. -/",
s!"theorem parse_eq_none_of_no_eof (input : {posToks}) (k : Nat)",
s!" (hin : ∀ t ∈ input, t.val ≠ .{eof}) (hlen : 2 ^ k < input.length) : parse input k = none := by",
" unfold parse",
@@ -1115,7 +1091,8 @@ def emitStreamTransfer (tokenType startTy E l : String) (eofIdx : Nat)
" | Parsed r rest => exact absurd hp (dependent_ne_parsed_of_no_eof input k hin hlen r rest)",
" | _ => rfl",
"",
- s!"/-- A prefix of lexed tokens with no `{eof}`, padded with copies of its first token. -/",
+ s!"/-- A token list `t0 :: ts` with no `{eof}`, padded with `2^k + 1` copies of `t0`, has no",
+ s!" `{eof}` and is longer than `2^k`. -/",
s!"theorem no_eof_pad (t0 : Runtime.Positioned {tokenType}) (ts : {posToks})",
s!" (hts : ∀ t ∈ t0 :: ts, t.val ≠ .{eof}) (k : Nat) :",
s!" (∀ t ∈ t0 :: ts ++ List.replicate (2 ^ k + 1) t0, t.val ≠ .{eof}) ∧",
@@ -1201,7 +1178,8 @@ def emitStreamTransfer (tokenType startTy E l : String) (eofIdx : Nat)
" exact dependent_ne_parsed_of_no_eof _ k hin hlen value stream hdep",
"",
"/-- **End to end.** If `parseStr` accepts `s` with value `p`, then `tokenize` lexes `s` to",
- " `ts`, and `ts` starts with the word of a parse tree whose value is `p`. -/",
+ " `ts`, and the EOF-padded stream of `ts` (`toStream ts`) starts with the word of a parse",
+ " tree whose value is `p`. -/",
s!"theorem parseStr_sound_tokenize (s : String) (k : Nat) (p : {startTy})",
s!" (accepted : {E}.parseStr s k = some p) :",
s!" ∃ ts, {l}.tokenize s = .ok ts ∧",
@@ -1217,8 +1195,8 @@ def emitStreamTransfer (tokenType startTy E l : String) (eofIdx : Nat)
(if !tokSound then "" else "\n\n" ++ lines [
"/-- **End to end, with the lexer specification.** If `parseStr` accepts `s` with value `p`,",
" then `s` has a maximal-munch tokenization (`Lexer.Tokenization`), the spec tokenizer",
- " returns the token values of `ts = tokenize s`, and `ts` starts with the word of a parse",
- " tree whose value is `p`. -/",
+ " returns the token values of `ts = tokenize s`, and the EOF-padded stream of `ts`",
+ " (`toStream ts`) starts with the word of a parse tree whose value is `p`. -/",
s!"theorem parseStr_sound_tokenization (s : String) (k : Nat) (p : {startTy})",
s!" (accepted : {E}.parseStr s k = some p) :",
s!" ∃ ts, {l}.tokenize s = .ok ts ∧ Lexer.Tokenization {l}.rules0 s.toList ∧",
@@ -1233,7 +1211,8 @@ def emitStreamTransfer (tokenType startTy E l : String) (eofIdx : Nat)
let tokParse := if !tokSound then "" else "\n\n" ++ lines [
"/-- **`tokenize` then `parse`.** If `tokenize` lexes `s` to `ts` and `parse` accepts `ts` with",
" value `p`, then `s` has a maximal-munch tokenization, the spec tokenizer returns the token",
- " values of `ts`, and `ts` starts with the word of a parse tree whose value is `p`. -/",
+ " values of `ts`, and the EOF-padded stream of `ts` (`toStream ts`) starts with the word of",
+ " a parse tree whose value is `p`. -/",
s!"theorem tokenize_parse_sound (s : String) (k : Nat) (ts : {posToks}) (p : {startTy})",
s!" (h : {l}.tokenize s = .ok ts) (accepted : {E}.parse ts k = some p) :",
s!" Lexer.Tokenization {l}.rules0 s.toList ∧ Lexer.tokenize {l}.lexer s = .ok (ts.map (·.val)) ∧",
@@ -1244,8 +1223,8 @@ def emitStreamTransfer (tokenType startTy E l : String) (eofIdx : Nat)
s!" obtain ⟨htok, hspec⟩ := {l}.tokenize_sound h",
" exact ⟨htok, hspec, parser_sound ts k p accepted⟩",
"",
- "/-- **Completeness.** If `tokenize` lexes `s` to `ts` and a parse tree of the start symbol",
- " spans exactly `ts`, within the fuel, `parseStr` returns the tree's value. -/",
+ "/-- **Completeness.** If `tokenize` lexes `s` to `ts` and a start parse tree has word",
+ " exactly `ts`, within the fuel, `parseStr` returns the tree's value. -/",
s!"theorem parseStr_complete (s : String) (k : Nat) (ts : {posToks})",
s!" (h : {l}.tokenize s = .ok ts) (tree : ParserStartTree ts)",
" (fuel : Grammar.ptSize tree ≤ 2 ^ k) :",
@@ -1276,8 +1255,8 @@ def emitStreamTransfer (tokenType startTy E l : String) (eofIdx : Nat)
" exact ⟨rfl, (parser_unambiguous tree₁ tree₂).2⟩",
"",
"/-- **Completeness over positioned tokens.** If `ts` is the positioned tokenization of `s`",
- s!" (`{l}.Lexes`) and a parse tree of the start symbol spans exactly `ts`, within the fuel,",
- " `parseStr` returns the tree's value. -/",
+ s!" (`{l}.Lexes`) and a start parse tree has word exactly `ts`, within the fuel, `parseStr`",
+ " returns the tree's value. -/",
s!"theorem parseStr_complete_lexes (s : String) (k : Nat) (ts : {posToks})",
s!" (h : {l}.Lexes s ts) (tree : ParserStartTree ts) (fuel : Grammar.ptSize tree ≤ 2 ^ k) :",
s!" {E}.parseStr s k = some (SpanGrammar.ptSem ⟨0⟩ tree) :=",
@@ -1299,9 +1278,9 @@ def emitStreamTransfer (tokenType startTy E l : String) (eofIdx : Nat)
s!" `s` (`{l}.Lexes`), every leaf's span is `[a, b)` for positions `a ≤ b` of `s`, and a rule's",
" action emits the leaf's token from the lexeme `s.extract a b` (or the leaf is the",
" end-of-input token at the end of `s`). Every inner node's span is `[a, b)` for positions",
- " `a ≤ b` of `s`; `b` is the end of the lexeme of the node's last token, and `a` is the start",
- " of the lexeme of its first token or, when its word is empty or its leftmost children",
- " derive the empty word, the end of the token before it (`Lexer.AllNodeText`). -/",
+ " `a ≤ b` of `s`, where `b` is the end of the node's word (the end `pe` of the token before",
+ " the node when the word is empty) and `a` is `pe` or the start of the first token of the",
+ " word (`Lexer.AllNodeText`). The theorem does not state which of the two `a` is. -/",
s!"theorem parseStr_node_spans (s : String) (ts : {posToks}) (h : {l}.Lexes s ts)",
" (tree : ParserStartTree ts) :",
s!" Lexer.AllNodeText (Lexer.modeAct {l}.lexer {l}.lexer.start) {l}.lexer.eofToken s ⟨0⟩ tree :=",
@@ -1309,8 +1288,8 @@ def emitStreamTransfer (tokenType startTy E l : String) (eofIdx : Nat)
let eofC := eofCtor.getD "EOF"
let lexesSound := if tokSound && eofCtor.isSome then "\n\n" ++ lines [
"/-- **End to end over positioned tokens.** If `parseStr` accepts `s` with value `p`, then",
- s!" `s` has a positioned tokenization `ts` (`{l}.Lexes`), and `ts` starts with the word of a",
- " parse tree whose value is `p`. -/",
+ s!" `s` has a positioned tokenization `ts` (`{l}.Lexes`), and the EOF-padded stream of `ts`",
+ " (`toStream ts`) starts with the word of a parse tree whose value is `p`. -/",
s!"theorem parseStr_sound_lexes (s : String) (k : Nat) (p : {startTy})",
s!" (accepted : {E}.parseStr s k = some p) :",
s!" ∃ ts, {l}.Lexes s ts ∧",
diff --git a/LeanParserGenerator/Frontend/File.lean b/LeanParserGenerator/Frontend/File.lean
index 65e7305..c8329d8 100644
--- a/LeanParserGenerator/Frontend/File.lean
+++ b/LeanParserGenerator/Frontend/File.lean
@@ -708,7 +708,7 @@ def scanEscape : ScanM (Except String Char) := do
| '"' => return .ok '"'
| '\'' => return .ok '\''
| 'u' =>
- -- \uXXXX : exactly four hex digits
+ -- \u followed by one to four hex digits
let mut cur ← get
let mut n := 0
let mut count := 0
diff --git a/LeanParserGenerator/Frontend/Generated/LigVerified.lean b/LeanParserGenerator/Frontend/Generated/LigVerified.lean
index 595e4a4..f7d110b 100644
--- a/LeanParserGenerator/Frontend/Generated/LigVerified.lean
+++ b/LeanParserGenerator/Frontend/Generated/LigVerified.lean
@@ -1293,8 +1293,9 @@ abbrev ParserStartTree (word : List grammarInst.Token) :=
Grammar.ParseTree (G := grammarInst)
(.NT (startNt' (⟨0, of_decide_eq_true rfl⟩ : InitState))) word
-/-- **Soundness.** An accepted token list starts with the word of a parse tree whose value,
- at the start of the input, is the result. -/
+/-- **Soundness.** If `parse` accepts `input`, the EOF-padded stream of `input`
+ (`toStream input`) starts with the word of a parse tree whose value, at the start of the
+ input, is the result. -/
theorem parser_sound (input : List grammarInst.Token) (logNSteps : Nat)
(semantic : Frontend.LigResult)
(accepted : LigParser.parse input logNSteps = some semantic) :
@@ -1319,6 +1320,8 @@ theorem parser_sound (input : List grammarInst.Token) (logNSteps : Nat)
refine ⟨word, tree, rest, inputEq, ?_⟩
rw [← valueEq, semanticEq]
+/-- **Error freedom.** The executable parser's `run` never returns `.err` (the result of
+ inconsistent tables), on every token list and fuel. -/
theorem parser_err_free (input : List grammarInst.Token) (logNSteps : Nat) :
Runtime.Exec.ResultErrFree (LigParser.run input logNSteps) := by
have related := parserRunRefines input logNSteps
@@ -1337,6 +1340,7 @@ theorem parser_err_free (input : List grammarInst.Token) (logNSteps : Nat) :
| timeout => trivial
| error message => exact dependentFree
+/-- `parser_err_free` as an inequality: `run` is not `.err message` for any `message`. -/
theorem parser_ne_err (input : List grammarInst.Token) (logNSteps : Nat)
(message : String) :
LigParser.run input logNSteps ≠ .err message := by
@@ -1345,6 +1349,7 @@ theorem parser_ne_err (input : List grammarInst.Token) (logNSteps : Nat)
rw [isError] at errorFree
exact errorFree
+/-- The EOF-padded stream of `input` is `input` followed by the stream of `[]`. -/
theorem toStream_eq_appList (input : List grammarInst.Token) :
toStream input = Runtime.AppStream.appList input (toStream []) := by
funext index
diff --git a/LeanParserGenerator/Frontend/LigLexer.lean b/LeanParserGenerator/Frontend/LigLexer.lean
index 3b6b317..bfac7d5 100644
--- a/LeanParserGenerator/Frontend/LigLexer.lean
+++ b/LeanParserGenerator/Frontend/LigLexer.lean
@@ -18,7 +18,7 @@ module
public import LeanParserGenerator.Frontend.File
/-
Hand-written lexer for the `.lig` structural language, the escape hatch half of
-the bootstrap (DESIGN §15.4).
+the bootstrap (DESIGN §15).
The `.lig` grammar-file language is context-free in its *structure* (the sequence
of `%`-directives, the rule/alternative/element shape), but its leaves are
diff --git a/LeanParserGenerator/Frontend/LigParse.lean b/LeanParserGenerator/Frontend/LigParse.lean
index a09dda4..08edc0d 100644
--- a/LeanParserGenerator/Frontend/LigParse.lean
+++ b/LeanParserGenerator/Frontend/LigParse.lean
@@ -18,7 +18,8 @@ module
public import LeanParserGenerator.Frontend.LigLexer
public import LeanParserGenerator.Frontend.Generated.LigParser
/-
-The verified `.lig` parser: its main entry point.
+The `.lig` parser generated from `lig.lig`: its main entry point. Its `LigParser` has the
+generated proofs; the lexer is hand-written.
`parseLigGen` is the generated-parser counterpart of the hand-written
`Frontend.parseLig`: it tokenizes `.lig` source with the hand-written
diff --git a/LeanParserGenerator/LSP/Server.lean b/LeanParserGenerator/LSP/Server.lean
index 0381d6e..d04eb1d 100644
--- a/LeanParserGenerator/LSP/Server.lean
+++ b/LeanParserGenerator/LSP/Server.lean
@@ -108,7 +108,7 @@ def initializeResult : Json :=
]),
("serverInfo", Json.mkObj [
("name", Json.str "lig-language-server"),
- ("version", Json.str "0.1.0")
+ ("version", Json.str "0.1.0-alpha.1")
])
]
diff --git a/LeanParserGenerator/Lexer/SpanText.lean b/LeanParserGenerator/Lexer/SpanText.lean
index 78819f1..c1b84d9 100644
--- a/LeanParserGenerator/Lexer/SpanText.lean
+++ b/LeanParserGenerator/Lexer/SpanText.lean
@@ -17,16 +17,17 @@
module
/-
The spans of a parse tree over a positioned tokenization, as text of the input
-(docs/DESIGN.md §6.2).
+(docs/DESIGN.md §4.4, §6.1).
`SpanGrammar.allSpanFacts` relates each node's span to the tokens of its word, and
`PosLexing` relates each token to its lexeme in the input `s`. This file combines the two.
`AllNodeText act eof s pe t`: every leaf of `t` is a token with its lexeme in `s`
(`TokenLexeme`), and every inner node's span delimits a substring of `s` (`SpanIn`) and
-satisfies `SpanFacts`. So the substring ends at the end of the lexeme of the node's last
-token, and starts at the start of the lexeme of its first token or, under the Rust
-convention, at the end `pe` of the token before the node (an empty word, or leftmost
-children that derive the empty word).
+satisfies `SpanFacts`. So the substring ends at the end of the node's word (at the end `pe`
+of the token before the node when the word is empty), and starts at `pe` or at the start of
+the lexeme of its first token. `SpanFacts` does not state which of the two applies; the
+parser takes `pe` for an empty word or leftmost children that derive the empty word (the
+Rust convention).
`PosLexing.allNodeText`: every tree over a `PosLexing` of `s` from `p` has
`AllNodeText … p.offset`.
diff --git a/LeanParserGenerator/Runtime/Alphabet.lean b/LeanParserGenerator/Runtime/Alphabet.lean
index e5e833a..bd2d30b 100644
--- a/LeanParserGenerator/Runtime/Alphabet.lean
+++ b/LeanParserGenerator/Runtime/Alphabet.lean
@@ -20,7 +20,7 @@ Finite, comparable index types: the foundation of the runtime core. Terminals,
non-terminals, states and productions are all `Alphabet`s. The classes here are
Mathlib-free and built on Lean's native `Ordering`/`DecidableEq`.
-Design decisions (see docs/DESIGN.md §5.1):
+Design decisions:
* `Comparable` gives a `cmp` with antisymmetry and transitivity laws.
* `Finite` provides an enumeration `all` with a completeness proof.
* `Numbered` is the cheap way to build all of the above: a bijection with
diff --git a/LeanParserGenerator/Runtime/Automaton.lean b/LeanParserGenerator/Runtime/Automaton.lean
index 116e844..1068b69 100644
--- a/LeanParserGenerator/Runtime/Automaton.lean
+++ b/LeanParserGenerator/Runtime/Automaton.lean
@@ -44,7 +44,7 @@ inductive State (InitState NonInitState : Type) where
| Init : InitState → State InitState NonInitState
| Ninit : NonInitState → State InitState NonInitState
-/-! `State I N` is an alphabet whenever `I` and `N` are (it is essentially `I ⊕ N`).
+/-! `State I N` is an alphabet whenever `I` and `N` are (it is isomorphic to `I ⊕ N`).
The safety validator quantifies over all states (`Finite`), compares them
(`singletonStatePred` uses `DecidableEq`), so we derive the full `Alphabet`
stack here from the component alphabets. -/
diff --git a/LeanParserGenerator/Runtime/Buffer.lean b/LeanParserGenerator/Runtime/Buffer.lean
index 3f89fea..aad55e4 100644
--- a/LeanParserGenerator/Runtime/Buffer.lean
+++ b/LeanParserGenerator/Runtime/Buffer.lean
@@ -18,7 +18,7 @@ module
/-
The input token stream, abstracted behind a type class so the interpreter
observes the input only through sequential `head`/`tail` (see docs/DESIGN.md
-§5.4). This is the `buffer` of §2.4 in Validating LR(1) Parsers, generalized
+§4.3). This is the `buffer` of §2.4 in Validating LR(1) Parsers, generalized
from a concrete coinductive stream to any instance of the class.
* The interpreter and all correctness theorems are stated over an arbitrary
diff --git a/LeanParserGenerator/Runtime/Diagnostic.lean b/LeanParserGenerator/Runtime/Diagnostic.lean
index 1a34312..b82d00c 100644
--- a/LeanParserGenerator/Runtime/Diagnostic.lean
+++ b/LeanParserGenerator/Runtime/Diagnostic.lean
@@ -39,9 +39,11 @@ offending lookahead terminal. This module builds the Menhir-style layer on top:
Like `Runtime.Exec` itself, this layer is **unverified** in the sense that it is
not part of the trusted specification. It is, however, proved *consistent* with
-the verified engine: `diagnose_run_agrees` shows the accept/reject/timeout
-classification of `diagnose` is exactly that of the verified `Runtime.Exec.run`,
-so an error is only ever reported when `run` genuinely rejects.
+the executable engine: `diagnose_run_agrees` shows the accept/reject/timeout
+classification of `diagnose` is exactly that of the executable `Runtime.Exec.run`,
+which each `*Verified` module relates to the dependent parser (`parserRunRefines`;
+for `parse`, `parse_eq_dependent`), so an error is only ever reported when `run`
+rejects.
-/
public import LeanParserGenerator.Runtime.Exec
public import LeanParserGenerator.Runtime.Span
@@ -196,12 +198,12 @@ def ParseError.format (e : ParseError) (terminalName : Nat → String)
else "; expected one of: " ++ ", ".intercalate expected
s!"syntax error at token {e.position}: unexpected {terminalName e.lookahead}{expectedStr} (in parser state {e.state})"
-/-! ### Consistency with the verified engine
+/-! ### Consistency with the executable engine
The diagnostic runner reuses `step`, so its result agrees with `Runtime.Exec.run`
by construction. We make that precise: erasing the extra remaining-input payload
turns `parseFixD` back into `parseFix`, hence `runD` agrees with `run`. This
-guarantees a syntax error is reported exactly when the verified parser rejects. -/
+guarantees a syntax error is reported exactly when `run` rejects. -/
theorem parseFixD_toResult (tbl : ExecTable V) :
∀ (stk : Stack V) (input : List (Nat × V)) (logN : Nat),
@@ -239,7 +241,7 @@ theorem runD_fst_eq_run (tbl : ExecTable V) (input : List (Nat × V)) (logN : Na
have : parseFix tbl [] input logN = .inr p := by rw [← h, hD]; rfl
rw [this]
-/-- `diagnose` classifies accept/reject/timeout exactly as the verified `run`:
+/-- `diagnose` classifies accept/reject/timeout exactly as the executable `run`:
it yields `.ok`/`.error`/`.timeout`/`.internal` iff `run` yields
`.ok`/`.reject`/`.timeout`/`.err`. In particular a `ParseError` is produced
precisely when `run` rejects. -/
diff --git a/LeanParserGenerator/Runtime/SpanGrammar.lean b/LeanParserGenerator/Runtime/SpanGrammar.lean
index 685f4b1..fcf142c 100644
--- a/LeanParserGenerator/Runtime/SpanGrammar.lean
+++ b/LeanParserGenerator/Runtime/SpanGrammar.lean
@@ -301,9 +301,10 @@ theorem ptlSpans_listEnd (pe : Pos) : {heads : List Sym} → {word : List (Posit
end
mutual
-/-- **A node's span starts at its first token or at `pe`.** When its word is empty the
- span starts at `pe`. Otherwise it starts at the start of the first token of its word,
- or, when the leftmost children of the node derive the empty word, at `pe`. -/
+/-- **A node's span starts at its first token or at `pe`.** The span starts at `pe`, or the
+ word is nonempty and the span starts at the start of its first token. (`ptSpan` takes
+ `pe` when the word is empty or the leftmost children derive the empty word; the theorem
+ does not state which case applies.) -/
theorem ptSpan_startPos (pe : Pos) : {head : Sym} → {word : List (Positioned SG.Tok)} →
(t : ParseTree head word) →
(ptSpan pe t).startPos = pe ∨ (∃ tok rest, word = tok :: rest ∧ (ptSpan pe t).startPos = tok.span.startPos)
@@ -375,8 +376,9 @@ end
mutual
/-- **Every node's span is the span of its word.** In every tree, each node's span ends at
the end of its last token (at the end `pe` of the token before it, when its word is
- empty), and starts at the start of its first token, or at `pe` when its word is empty or
- its leftmost children derive the empty word (the Rust convention). -/
+ empty), and starts at `pe` or at the start of its first token (`SpanFacts`). The parser
+ takes `pe` when the word is empty or the leftmost children derive the empty word (the
+ Rust convention); `SpanFacts` does not state which case applies. -/
theorem allSpanFacts (pe : Pos) : {head : Sym} → {word : List (Positioned SG.Tok)} →
(t : ParseTree head word) → AllSpanFacts pe t
| _, _, .terminal tok => by
diff --git a/Main.lean b/Main.lean
index 4310c26..904e874 100644
--- a/Main.lean
+++ b/Main.lean
@@ -25,7 +25,7 @@ leanparsergenerator [options]
One invocation generates every module for the grammar from one parse and one Pager
construction. Output names come from the `.lig` stem, and the `.lig`'s `%option`s
decide which optional modules are written. The flags below adjust the defaults.
-`--print-grammar` and `--rust-report` inspect a grammar without writing files.
+`--print-grammar`, `--list-errors` and `--rust-report` inspect a grammar without writing files.
Exit codes: 0 on success, 1 on any error (bad arguments, unreadable input, `.lig`
parse or generation error), 2 when Pager reports LR(1) conflicts. With exit code 2
@@ -36,6 +36,7 @@ public import LeanParserGenerator.Emit.CodegenVerified
public import LeanParserGenerator.Emit.CodegenLexer
public import LeanParserGenerator.Emit.CodegenRust
public import LeanParserGenerator.Emit.Rust.Report
+public import LeanParserGenerator.Emit.ErrorList
public import LeanParserGenerator.Emit.CodegenLexerRoundtrip
public import LeanParserGenerator.Emit.CodegenParserRoundtrip
public import LeanParserGenerator.Frontend.File
@@ -251,16 +252,16 @@ def generate (cfg : GenConfig) : IO UInt32 := do
match Emit.generateLexerFrom surface lexerModule with
| .error e => return ← fail s!"{ligPath}: lexer generation failed: {e}"
| .ok lexSource =>
- writeOutput (dir ++ lexerModule ++ ".lean") lexSource s!"module {lexerModule}"
+ writeOutput (dir ++ lexerModule ++ ".lean") lexSource s!"module {qualify prefix_ lexerModule}"
if wants .verified then
- writeOutput (dir ++ verifiedModule ++ ".lean") verifiedSource s!"module {verifiedModule}"
+ writeOutput (dir ++ verifiedModule ++ ".lean") verifiedSource s!"module {qualify prefix_ verifiedModule}"
if wants .parser then
- writeOutput (dir ++ executableModule ++ ".lean") executableSource s!"module {executableModule}"
+ writeOutput (dir ++ executableModule ++ ".lean") executableSource s!"module {qualify prefix_ executableModule}"
else if genLexer && wants .lexer then
match Emit.generateLexerFrom surface lexerModule with
| .error e => return ← fail s!"{ligPath}: lexer generation failed: {e}"
| .ok lexSource =>
- writeOutput (dir ++ lexerModule ++ ".lean") lexSource s!"module {lexerModule}"
+ writeOutput (dir ++ lexerModule ++ ".lean") lexSource s!"module {qualify prefix_ lexerModule}"
-- Rust.
if wants .rust then
if let some rp := rustPath then
@@ -275,7 +276,7 @@ def generate (cfg : GenConfig) : IO UInt32 := do
match Emit.generateRoundtripFrom surface lexerImport lexerModule rtModule with
| .error e => return ← fail s!"{ligPath}: roundtrip generation failed: {e}"
| .ok rtSource =>
- writeOutput (dir ++ rtModule ++ ".lean") rtSource s!"module {rtModule}"
+ writeOutput (dir ++ rtModule ++ ".lean") rtSource s!"module {qualify prefix_ rtModule}"
-- The handwritten `Unparse` module defines `unparse`; a generated lexer
-- is needed only for `%option roundtrip_format`.
if surface.options.roundtripParser.isSome then
@@ -285,7 +286,7 @@ def generate (cfg : GenConfig) : IO UInt32 := do
executableImport executableModule unparseImport prtModule with
| .error e => return ← fail s!"{ligPath}: parser roundtrip generation failed: {e}"
| .ok prtSource =>
- writeOutput (dir ++ prtModule ++ ".lean") prtSource s!"module {prtModule}"
+ writeOutput (dir ++ prtModule ++ ".lean") prtSource s!"module {qualify prefix_ prtModule}"
conflictExitCode ligPath prepared.tables
/-- Print an inspectable view built from the same augmented grammar data emitted
@@ -302,6 +303,15 @@ def printGrammarView (format : GrammarViewFormat) (ligPath : String) : IO UInt32
IO.println rendered
conflictExitCode ligPath prepared.tables
+/-- Print the parser states that can reject a token, as a Menhir `.messages`-style template
+ to fill with per-state messages for `errorMessage` (docs/ERROR_MESSAGES.md). -/
+def listErrors (ligPath : String) : IO UInt32 := do
+ match ← prepareFile ligPath with
+ | .error error => fail error
+ | .ok (surface, prepared) =>
+ IO.println (Emit.renderErrorList surface prepared)
+ conflictExitCode ligPath prepared.tables
+
/-- Report which semantic actions the Rust backend could emit (docs/RUST_PARSER.md). The
resolver imports the header's modules, so run this under `lake env` with those
modules built. -/
@@ -319,6 +329,7 @@ def rustReport (verbose : Bool) (ligPath : String) : IO UInt32 := do
private def usageText : String :=
"usage: leanparsergenerator [options]
leanparsergenerator --print-grammar bnf|markdown
+ leanparsergenerator --list-errors
leanparsergenerator --rust-report [-v]
leanparsergenerator --help | --version
@@ -335,6 +346,8 @@ options:
--only