You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ADR 0010 (docs/engineering/decisions/0010-tokenizer-recursive-descent-parser.md)
accepted the direction: replace the line-oriented parser with a single shared
tokenizer and a recursive-descent parser with error recovery, behind the stable gwdkast AST seam. The decision is recorded; the implementation is not started.
This issue tracks building it.
Relevant code:
internal/lang/lexer.go: the rune scanner to promote into the shared lexer
internal/parser/syntax.go, patterns.go: the line-oriented parser and
per-line lexLine to retire
internal/parser/braces.go: brace state that becomes ordinary lexer state
Build a recursive-descent parser to gwdkast.File with error recovery
(synchronize at declaration boundaries and block braces; accumulate
diagnostics instead of returning on the first error).
Gate with golden AST-equivalence tests against the line-oriented parser and
the conformance corpus ([Language] Add a machine-checked .gwdk conformance corpus #295); cut over per declaration kind; remove the
line-oriented path when equivalence holds.
The AST-backed formatter and granular per-construct diagnostic codes deferred in #250 consume this parser and are out of scope here.
Acceptance Criteria
One shared tokenizer feeds both the compiler parser and editor/CLI tooling.
One syntax error no longer hides the rest of the file; diagnostics accumulate.
AST output matches the line-oriented parser for the supported subset until
cutover, verified by golden equivalence tests and the corpus.
The line-oriented parser and lexLine are removed once equivalence holds.
Verification
go test ./internal/parser ./internal/lang ./internal/compiler ./cmd/gowdk
Follow-up from #299 (ADR 0010) and PR #300.
Problem
ADR 0010 (
docs/engineering/decisions/0010-tokenizer-recursive-descent-parser.md)accepted the direction: replace the line-oriented parser with a single shared
tokenizer and a recursive-descent parser with error recovery, behind the stable
gwdkastAST seam. The decision is recorded; the implementation is not started.This issue tracks building it.
Relevant code:
internal/lang/lexer.go: the rune scanner to promote into the shared lexerinternal/parser/syntax.go,patterns.go: the line-oriented parser andper-line
lexLineto retireinternal/parser/braces.go: brace state that becomes ordinary lexer stateinternal/gwdkast: the stable AST output contractScope
Implement the ADR in phases behind the AST seam:
internal/lang's scanner into the shared tokenizer (with byteoffsets, [Compiler] Carry byte offsets in source positions #294 follow-up) and retire
internal/parserlexLine.gwdkast.Filewith error recovery(synchronize at declaration boundaries and block braces; accumulate
diagnostics instead of returning on the first error).
the conformance corpus ([Language] Add a machine-checked .gwdk conformance corpus #295); cut over per declaration kind; remove the
line-oriented path when equivalence holds.
The AST-backed formatter and granular per-construct diagnostic codes deferred in
#250 consume this parser and are out of scope here.
Acceptance Criteria
cutover, verified by golden equivalence tests and the corpus.
lexLineare removed once equivalence holds.Verification
go test ./internal/parser ./internal/lang ./internal/compiler ./cmd/gowdk