Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: _ separators in numeric literals #6204

Merged
merged 1 commit into from
Dec 8, 2024
Merged

Conversation

kmill
Copy link
Collaborator

@kmill kmill commented Nov 25, 2024

This PR lets _ be used in numeric literals as a separator. For example, 1_000_000, 0xff_ff or 0b_10_11_01_00. New lexical syntax:

numeral10 : [0-9]+ ("_"+ [0-9]+)*
numeral2  : "0" [bB] ("_"* [0-1]+)+
numeral8  : "0" [oO] ("_"* [0-7]+)+
numeral16 : "0" [xX] ("_"* hex_char+)+
float     : numeral10 "." numeral10? [eE[+-]numeral10]

Closes #6199

This PR allows `_` in numeric literals as a separator. For example, `1_000_000`, `0xff_ff` or `0b_10_11_01_00`.

Closes leanprover#6199
@kmill kmill requested a review from Kha as a code owner November 25, 2024 00:22
@kmill kmill added the changelog-language Language features, tactics, and metaprograms label Nov 25, 2024
@github-actions github-actions bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Nov 25, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Nov 25, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Nov 25, 2024
@leanprover-community-bot leanprover-community-bot added the builds-mathlib CI has verified that Mathlib builds against this PR label Nov 25, 2024
@leanprover-community-bot
Copy link
Collaborator

Mathlib CI status (docs):

@Kha Kha added the awaiting-review Waiting for someone to review the PR label Nov 27, 2024
@Kha Kha removed the awaiting-review Waiting for someone to review the PR label Dec 6, 2024
@kmill kmill enabled auto-merge December 8, 2024 22:18
@kmill kmill added this pull request to the merge queue Dec 8, 2024
@kmill kmill removed this pull request from the merge queue due to a manual request Dec 8, 2024
@kmill kmill enabled auto-merge December 8, 2024 22:23
@kmill kmill added this pull request to the merge queue Dec 8, 2024
Merged via the queue into leanprover:master with commit 63791f0 Dec 8, 2024
28 of 29 checks passed
kuotsanhsu added a commit to kuotsanhsu/lean4-dump that referenced this pull request Jan 20, 2025
JovanGerb pushed a commit to JovanGerb/lean4 that referenced this pull request Jan 21, 2025
This PR lets `_` be used in numeric literals as a separator. For
example, `1_000_000`, `0xff_ff` or `0b_10_11_01_00`. New lexical syntax:
```text
numeral10 : [0-9]+ ("_"+ [0-9]+)*
numeral2  : "0" [bB] ("_"* [0-1]+)+
numeral8  : "0" [oO] ("_"* [0-7]+)+
numeral16 : "0" [xX] ("_"* hex_char+)+
float     : numeral10 "." numeral10? [eE[+-]numeral10]
```

Closes leanprover#6199
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
builds-mathlib CI has verified that Mathlib builds against this PR changelog-language Language features, tactics, and metaprograms toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RFC: Visual Separators in Number Literals
3 participants