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
The parser is line-oriented: it scans the source line by line with a bufio.Scanner, matches patterns per trimmed line, and returns on the first
syntax error with no recovery. Spans are line-wide approximations and the
formatter is whitespace-only string manipulation. Most of the work deferred to #250 — parser error recovery, an AST-backed formatter, exact token spans, and
granular per-construct diagnostic codes — is downstream of this single
foundation. Right now the line-oriented parser is effectively deferred by
omission rather than by an explicit decision.
Relevant code:
internal/parser/syntax.go: bufio.Scanner line loop, first-error return
This is a decision/ADR issue, not an implementation task. Decide whether M2
commits to a real tokenizer + recursive-descent parser with error recovery, or
explicitly keeps the line-oriented parser with documented limits for now.
If committing: outline the token-stream layer, the recovery strategy
(continue-after-error so one syntax error does not hide the rest of the file),
and the span model — which depends on byte offsets in SourcePosition.
If deferring: document the limitation explicitly and link the dependent issues so
it is a conscious choice rather than an omission.
Acceptance Criteria
An ADR (docs/engineering/decisions/) records the chosen direction and
rationale.
Problem
The parser is line-oriented: it scans the source line by line with a
bufio.Scanner, matches patterns per trimmed line, and returns on the firstsyntax error with no recovery. Spans are line-wide approximations and the
formatter is whitespace-only string manipulation. Most of the work deferred to
#250 — parser error recovery, an AST-backed formatter, exact token spans, and
granular per-construct diagnostic codes — is downstream of this single
foundation. Right now the line-oriented parser is effectively deferred by
omission rather than by an explicit decision.
Relevant code:
internal/parser/syntax.go:bufio.Scannerline loop, first-error returninternal/parser/patterns.go: per-linelexLinetokenizerinternal/parser/braces.go: stateful brace scanner (accepted JS-regex limit)internal/lang/format.go: line-oriented formatterScope
This is a decision/ADR issue, not an implementation task. Decide whether M2
commits to a real tokenizer + recursive-descent parser with error recovery, or
explicitly keeps the line-oriented parser with documented limits for now.
If committing: outline the token-stream layer, the recovery strategy
(continue-after-error so one syntax error does not hide the rest of the file),
and the span model — which depends on byte offsets in
SourcePosition.If deferring: document the limitation explicitly and link the dependent issues so
it is a conscious choice rather than an omission.
Acceptance Criteria
docs/engineering/decisions/) records the chosen direction andrationale.
omission) and the dependent deferral ([Language] Track remaining parser/spec hardening follow-ups #250) references the decision.
and formatter, with byte-offset spans as a dependency.
Verification
docs/engineering/decisions/.docs/compiler/pipeline.mdanddocs/engineering/architecture.mdupdated tomatch the decision.