Add binary literals and underscore separators to number literals - #352
Draft
fmeum wants to merge 1 commit into
Draft
Add binary literals and underscore separators to number literals#352fmeum wants to merge 1 commit into
fmeum wants to merge 1 commit into
Conversation
Adds 0b/0B binary integer literals and PEP 515-style underscore separators between digits to the lexical grammar for int and float literals. Fixes bazelbuild#117 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Member
|
(CLA is false positive due to claude attribution) |
brandjon
requested changes
Jun 15, 2026
| group digits for readability and have no effect on the value of the | ||
| literal. | ||
|
|
||
| It is a static error if the digits of a number literal are immediately |
Member
There was a problem hiding this comment.
I would delete this second paragraph. I believe in all cases it is already a static error regardless of this text, so all the paragraph is doing is specifying that it's a lexical error rather than a parsing one, which is really an implementation detail.
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.
Extends the lexical grammar for number literals in two ways:
0b1011/0B1011): these are documented in the go.starlark.net language description and partially implemented in the Java lexer, but were missing from the spec. Fixes spec: 0b10101 binary literals #117._may appear between two digits of an int or float literal, or between a base prefix and the first digit (e.g.1_000_000,0xFFFF_FFFF,0x_FF,1_000.000_1). Underscores have no effect on the value.Following Python, the spec also states that it is an error if a literal's digits are immediately followed by a decimal digit that is not valid in the literal's base (e.g.
0o12345678is an error rather than the two tokens0o1234567and8).This is the spec counterpart to the Java implementation in bazelbuild/bazel#29784, requested in this review.
🤖 Generated with Claude Code