[Lexer] YAML integer-looking value like 1.0-beta or 2 val misparses
#1328
Replies: 1 comment
|
The proposed direction addresses the root cause: the old trailing word boundary can accept the numeric prefix of a larger plain scalar such as 1.0-beta or 2 val. I would keep the fix, but define the boundary in terms of a complete YAML scalar rather than only copying the TextMate expression. The regression matrix should include:
The proposed lookahead contains // as a delimiter, but // is not a YAML comment marker, so I would verify that this is intentional for the lexer context rather than inherited from a different grammar. If the regex engine supports the lookahead, the key invariant should be: classify as LiteralNumber only when the numeric pattern consumes the complete plain scalar; otherwise emit one Literal token for the whole value. Adding the cases to yaml.actual and yaml.expected is the right validation. I would also keep the benchmark because the extra boundary check is cheap, but it is worth checking long non-numeric scalars and flow collections as well as the two examples. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Request type
Lexer highlighting bug
Language
YAML
Sample input
https://swapoff.org/chroma/playground/#eyJsYW5ndWFnZSI6IllBTUwiLCJzdHlsZSI6ImdpdGh1YiIsInRleHQiOiJhOiAxLjAtYmV0YVxuYjogMiB2YWwiLCJjbGFzc2VzIjpmYWxzZX0
Syntax references
I'm not a regex expert myself, so I asked Claude to look at the TextMate implementation, and it found a reference version:
https://github.com/textmate/yaml.tmbundle/blob/master/Syntaxes/YAML.tmLanguage
Diff below, combined by Claude from that reference implementation, tested and passing:
Claude AI: perf check
Only strings starting with a digit but not fully numeric (e.g.
1.0-beta) get slower; ~0.9µs → ~1.7µs per value. Everything else (non-numeric values, valid numbers) is unaffected or slightly faster.All reactions