-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for binary, octal, and underscores in integer notation
At the source level, integer literal can now be written in - binary with a 0b or 0B prefix: 0b10001111 - octal with a 0o or 0O prefix: 0o7722 - decimal without any explicit prefix: 42 - hexadecimal with a 0x or 0X prefix: 0xabcd All these notations may contain underscores (except at the beginning), e.g., 0b1111_0000 or 10_854_736. Caveat _1234 is an indentifier, not a number. Co-authored-by: Vincent Laporte <Vincent.Laporte@inria.fr>
- Loading branch information
Showing
4 changed files
with
42 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
Test for all valid integer syntaxes | ||
*/ | ||
export fn test () -> reg u32 { | ||
reg u32 y; | ||
y = 0b11110000; | ||
y = 0b111_111_11; | ||
y = 0B111_00_11; | ||
|
||
y = 0o01234567; | ||
y = 0o765_4_321; | ||
y = 0O76543210; | ||
|
||
y = 1000000000; | ||
y = 1000_0000_000; | ||
|
||
y = 0x01234567; | ||
y = 0x765_b_32aac; | ||
y = 0X76aab3210; | ||
|
||
return y; | ||
} |