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
{{ message }}
Repository navigation
Add byte spans to SourceLocation and populate them in the parser #132
SourceLocation (src/lexer/token.hxx:107) carries file, line, and column. That is enough to point at a declaration in an error message, and not enough for anything that has to edit or reproduce source: a text edit is a range plus replacement text, and a losslessness check needs to know exactly which bytes a node spans.
Tokens already carry what is needed — Token::startOffset / Token::endOffset (src/lexer/token.hxx:117) are byte offsets into the original UTF-8 source. The information exists and is discarded at the parser boundary.
What lands
SourceLocation gains startOffset and endOffset (exclusive), defaulting to -1 as Token does.
The parser fills them from the tokens it consumes: a node's span runs from the first token of the construct to the last, inclusive of closing end/)/].
ast::TaggedLiteral::bodyStartOffset / bodyEndOffset (src/ast/ast.
8156
hxx) already do this by hand for one node; that is the pattern, generalised.
Why it is separate
It is a pure core change with no user-visible effect, and every later stage depends on it. Landing it alone keeps the diff reviewable and the blame legible.
Verification
make test-all — no behavioural change expected. (Bare ctest misses the spec/*.kex suite.)
A new test asserting that for a representative parse, every node has startOffset >= 0, endOffset > startOffset, and a span nested within its parent's. The nesting assertion is what catches a node whose span was filled from the wrong token.
Done. SourceLocation carries startOffset/endOffset (src/lexer/token.hxx:114), the parser fills them from the tokens it consumes, and tests/parser_test.cxx:43 asserts both the offsets and the parent/child span nesting the ticket asked for.
Activity
akoskovacs commentedon Aug 21, 2026
Done.
SourceLocationcarriesstartOffset/endOffset(src/lexer/token.hxx:114), the parser fills them from the tokens it consumes, andtests/parser_test.cxx:43asserts both the offsets and the parent/child span nesting the ticket asked for.