Skip to content

Improve Python's tokenizer for numeric literals - #5084

Open
Luca Chiodini (lucach) wants to merge 1 commit into
microsoft:mainfrom
lucach:fix_python_numeric_literals
Open

Improve Python's tokenizer for numeric literals#5084
Luca Chiodini (lucach) wants to merge 1 commit into
microsoft:mainfrom
lucach:fix_python_numeric_literals

Conversation

@lucach

Copy link
Copy Markdown

This improves Python's tokenizer for numeric literals with respect to several aspects:

Reference: https://docs.python.org/3/reference/lexical_analysis.html#numeric-literals

Add tests to cover several of the above cases and their combinations.

P.S.: I ran the tests with v0.52.0, as they have been (mistakenly? temporarily?) removed in e56ad4b.

This improves Python's tokenizer for numeric literals with respect to several aspects:
- Support underscores between digits and after prefixes (fixes microsoft#4745)
- Support octal and binary literals
- Support case-insensitive prefixes for hex/octal/binary literals
- Recognize a possible leading minus sign as a separate token, instead of mistakenly treating it as part of the numeric literal

Reference: https://docs.python.org/3/reference/lexical_analysis.html#numeric-literals

Add tests to cover several of the above cases and their combinations.
@lucach

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

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

Successfully merging this pull request may close these issues.

[Bug] Python syntax highlighting does not support underscores in numeric literals

1 participant