lcompilers / lpython

Python compiler
https://lpython.org/
Other
1.5k stars 158 forks source link

Handling leading zeros in integer literals #2568

Closed hankluo6 closed 7 months ago

hankluo6 commented 7 months ago

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.

mrdaybird commented 7 months ago

tokenizer.cpp file is an auto-generated file, created by re2c when you run the build0.sh script using the tokenizer.re file. Any changes needed, will have to be made to the tokenizer.re file.

kmr-srbh commented 7 months ago

Oh! I am sorry. @mrdaybird is right. I had tested your changes through the tokenizer.cpp file and built using build1.sh. I had completely missed the comment on top of the file. I am sorry for the mistake.

Thanks for the correction @mrdaybird !

Thirumalai-Shaktivel commented 7 months ago

Please mark this PR ready for review once it is ready.

hankluo6 commented 7 months ago

@hankluo6 This looks good to me! Thanks for this! Please add an error reference test (for example as in cbb79b6) and we can merge this.

After adding a test, you need to update the reference tests using ./run_tests.py -u and commit the changes/updations.

@Shaikh-Ubaid @Thirumalai-Shaktivel I added a new test, could you review it? Thanks!