Skip to content

Conversation

@lucach
Copy link

@lucach lucach commented Nov 5, 2025

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
Author

lucach commented Nov 5, 2025

@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