-
Notifications
You must be signed in to change notification settings - Fork 171
Handling leading zeros in integer literals #2568
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
Conversation
src/lpython/parser/tokenizer.re
Outdated
// Oct | ||
s = s + 2; | ||
uint64_t n = get_value((char*)s, 8, loc); | ||
u.from_smallint(n); | ||
} else { | ||
lex_dec_int_large(al, s, e, u); | ||
if (s[0] == '0' && u.n != 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @hankluo6 ! Thanks for this!
I think this is not the right file to make the changes. Your idea is correct. Please make the same changes in tokenizer.cpp
. 👍
Welcome to LPython!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @kmr-srbh
Thanks for your feedback! I'm excited to be part of LPython! I think tokenizer.cpp
is generated from tokenizer.re
using re2c
so I made change on this file. Please let me know if I'm mistaken.
|
Oh! I am sorry. @mrdaybird is right. I had tested your changes through the Thanks for the correction @mrdaybird ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please mark this PR ready for review once it is ready. |
@Shaikh-Ubaid @Thirumalai-Shaktivel I added a new test, could you review it? Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect! Thanks! Great work @hankluo6!
Fixed #2002
I catch this error in the tokenizer because it removes trailing zeros in
lex_int
. Also, to handle the case of all zeros, we must allow the tokenizer to process the number first.