Repository navigation
Spec 035: the grammar and the parser on etalii-lark (T164, T165) - #81
Merged
Merged
Conversation
As research R9 was amended on 2026-10-24, ATD's grammar and parser are built on etalii-lark 0.4.0, the Rust port of Lark, instead of a table builder, lexer and parser of their own. adp-atd-grammar (T164) keeps the notation reader's refusals of what the subset does not admit and hands the modules to etalii-lark in LALR mode with the contextual lexer and strict, so that the tables, the conflicts and the terminal collisions are Lark's own verdict, reported in the table's names; it prints Lark's table as the normalized ParseTables (byte for byte atd.tables.json). Its own LR(0) items, lookaheads, collision DFAs and regex lexer are removed; T032 and T034 pass unchanged. adp-atd-syntax (T165) embeds the grammar's modules at build time and builds the parser once per process. It feeds etalii-lark's interactive parser one token at a time, each lexed for its state, drives T039's error recovery through it (the stack popped with truncate, the construct start fed), keeps the popped and skipped text as skipped tokens and lexes the text between tokens as trivia, so the tree stays lossless, and lowers from Lark's tree. Its own table-driven parser and static tables are removed; T035, T037 and the shell's .atd tests pass unchanged, and the refused corpus gives its findings exactly. The parser is built without strict mode, whose checks take nine tenths of the build and are made where the tables are: about 0.3 s instead of 2 s. etalii-lark and the regex crates it builds with are optimised in debug builds too. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
vrenken
enabled auto-merge
October 24, 2026 14:36
This was referenced Oct 24, 2026
vrenken
added a commit
that referenced
this pull request
Oct 25, 2026
… offset Since the parser moved to etalii-lark (#81), each token the parser reads between its own creates a LexerState with LexerState::new, which counts the lines of all the text before it. Reading a file's trivia became quadratic: on the 5,000-line description of SC-006, diagnostics after a keystroke took 1.4 s and completion 1.2 s natively, and 1.9 s and 1.7 s in VS Code over WebAssembly, against bounds of 1 s and 0.5 s. The lexer's state now starts at the position by its byte offset, as nothing reads its lines and ATD's terminals have no anchors: 0.35 s and 0.19 s. The Build now runs the latency bench, which no job ran, so this is held from here on. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This was referenced Oct 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Peter · project thread
Delivery 2b of etalii.adp spec 035 (
specs/035-adp-tool-language/): tasks T164 and T165, added by the amendment of 2026-10-24 (research R9, etalii.adp #504). ATD's grammar and parser are now built on etalii-lark 0.4.0, which got the accessors this needs in vrenken/EtAlii.Lark#13.What
adp-atd-grammar(T164)"x",$END.tables::to_jsonprints Lark's table, read throughLark::parse_table(), as the normalizedParseTables.atd tablesequalsatd.tables.jsonbyte for byte.Lexeris now a thin wrapper over Lark's lexer.adp-atd-syntax(T165)next_token, each token lexed for its state.}at the end of the file is fed in;truncate.keep_all_tokens, no placeholders).Startup. Lark's strict-mode checks take nine tenths of building the parser, so the run-time parser leaves them out. Its tables are the same, and strictness is checked where the tables are: the T032/T034 tests,
atd tables, and etalii.adp's grammar job. The first parse then costs about 0.3 s instead of 2 s. etalii-lark and the regex crates it builds with are optimised in debug builds as well; unoptimised, building the grammar took 17 s.Unchanged tests as the guard
.atdtests: the editor walk, drawing, and accessibility.atd check --corpus refused: all 22 refused files give exactly their findings, ATD1001's message included.The workspace's
fmt,clippy -D warningsand tests pass. So do the WebAssembly build ofadp-atd-lsp,atd record --check,sync-etalii-adp.py --check, and cargo-deny's licence check ofatdand the language server.🤖 Generated with Claude Code