Repository navigation
Added support for binary int literals - #550
Merged
Merged
Conversation
Collaborator
|
Thanks for implementing this! Looks good. The issue with invalid literals can be fixed as a separate task, since it's not directly related to binary int literals. |
JukkaL
added a commit
that referenced
this pull request
Jan 4, 2015
Added support for binary int literals
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This should fix #534.
As part of this change, I changed the parsing of int expressions to use
int(token, base=0). As noted in the Python docs, "base 0 means to interpret exactly as a code literal, so that the actual base is 2, 8, 10, or 16". This means all four cases are handled in one, andparse_int_exprnow looks more likeparse_float_exprandparse_complex_expr.Also, I was going to add a test similar to
test_invalid_hex_int_literalsfor octal and binary literals, but I discovered the lexer currently allows invalid octal literals like0oA. The same is true for binary literals after this change. Is it worth updating the regular expression to only allow valid literals? I think something like0[xX][0-9a-fA-F]+|0[oO][0-7]+|0[bB][01]+|[0-9]+should work.This is my first contribution to the project, so please let me know if I have missed anything or if you have any questions.