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

[Leo] Add hexadecimal, octal, binary numerals. #70

Merged
merged 7 commits into from
Nov 1, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 27 additions & 8 deletions leo.abnf
bendyarm marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -150,17 +150,36 @@ lowercase-letter = %x61-7A ; a-z

letter = uppercase-letter / lowercase-letter

binary-digit = %x30-31 ; 0-1

octal-digit = %x30-37 ; 0-7

decimal-digit = %x30-39 ; 0-9

nonzero-decimal-digit = %x31-39 ; 1-9

hexadecimal-digit = decimal-digit
/ %x41-46 ; A-F (uppercase)
; no a-f (lowercase)

identifier = letter *( letter / decimal-digit / "_" )
; but not a keyword or a boolean literal or aleo1...

numeral = 1*( decimal-digit *"_" )
binary-numeral = 1*( binary-digit *"_" )
acoglio marked this conversation as resolved.
Show resolved Hide resolved

octal-numeral = 1*( octal-digit *"_" )
acoglio marked this conversation as resolved.
Show resolved Hide resolved

decimal-numeral = 1*( decimal-digit *"_" )

hexadecimal-numeral = 1*( hexadecimal-digit *"_" )
acoglio marked this conversation as resolved.
Show resolved Hide resolved

numeral = binary-numeral
/ octal-numeral
/ decimal-numeral
/ hexadecimal-numeral

tuple-index = "0" / nonzero-decimal-digit *( decimal-digit )
; i.e. numeral without extra leading zeros
; i.e. decimal-numeral without extra leading zeros

unsigned-literal = numeral ( %s"u8" / %s"u16" / %s"u32" / %s"u64" / %s"u128" )

Expand All @@ -169,11 +188,11 @@ signed-literal = numeral ( %s"i8" / %s"i16" / %s"i32" / %s"i64" / %s"i128" )
integer-literal = unsigned-literal
/ signed-literal

field-literal = numeral %s"field"
field-literal = decimal-numeral %s"field"

product-group-literal = numeral %s"group"
product-group-literal = decimal-numeral %s"group"

scalar-literal = numeral %s"scalar"
scalar-literal = decimal-numeral %s"scalar"

numeric-literal = integer-literal
/ field-literal
Expand Down Expand Up @@ -227,7 +246,7 @@ symbol = "!"
token = keyword
/ identifier
/ atomic-literal
/ numeral
/ decimal-numeral
/ annotation
/ symbol

Expand Down Expand Up @@ -285,7 +304,7 @@ future-type = untyped-future-type / typed-future-type

tuple-type = "(" type 1*( "," type ) [ "," ] ")"

array-type = "[" type ";" numeral "]"
array-type = "[" type ";" decimal-numeral "]"

type = primitive-type
/ future-type
Expand All @@ -296,7 +315,7 @@ named-type = named-primitive-type
/ untyped-future-type
/ identifier

group-coordinate = ( [ "-" ] numeral ) / "+" / "-" / "_"
group-coordinate = ( [ "-" ] decimal-numeral ) / "+" / "-" / "_"

affine-group-literal = "(" group-coordinate "," group-coordinate %s")group"

Expand Down