Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Carbon lexer doesn't handle multi-character integers correctly #2454

Closed
davidben opened this issue Jun 14, 2023 · 1 comment
Closed

Carbon lexer doesn't handle multi-character integers correctly #2454

davidben opened this issue Jun 14, 2023 · 1 comment

Comments

@davidben
Copy link
Contributor

I was looking at the Carbon lexer as a template for another one (it was very small and C-like), and noticed an issue.

#2370 (CC @AmrDeveloper) switched the integer regexes to +?, which is non-greedy. As a result, multi-character integers such as 1234 or 0x1234abcd get lexed funny. They're not covered by tests, but the lex ends up being:

'   '         Text.Whitespace
'1'           Literal.Number.Integer
'2'           Literal.Number.Integer
'3'           Literal.Number.Integer
'4'           Literal.Number.Integer
'\n'          Text.Whitespace

'   '         Text.Whitespace
'0x1'         Literal.Number.Hex
'2'           Literal.Number.Integer
'3'           Literal.Number.Integer
'4'           Literal.Number.Integer
'abcd'        Name.Other
'\n'          Text.Whitespace
@AmrDeveloper
Copy link
Contributor

Thank you @davidben for reporting,
I will fix it and cover it on the test cases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants