Work on literals and numbers.
This commit is contained in:
parent
6652b9fc63
commit
5c01589ca3
@ -607,3 +607,112 @@ ClosureParameter:
|
||||
- identifier
|
||||
- type_use:
|
||||
optional: true
|
||||
|
||||
# Literals
|
||||
Literal:
|
||||
rules:
|
||||
- NumberLiteral
|
||||
- StringLiteral
|
||||
- BooleanLiteral
|
||||
NumberLiteral:
|
||||
rules:
|
||||
- DoubleLiteral
|
||||
- LongLiteral
|
||||
- IntLiteral
|
||||
IntLiteral:
|
||||
children:
|
||||
- number_base
|
||||
LongLiteral:
|
||||
children:
|
||||
- number_base
|
||||
DoubleLiteral:
|
||||
children:
|
||||
- double_whole
|
||||
- double_fractional
|
||||
DoubleWhole:
|
||||
children:
|
||||
- decimal_base
|
||||
DoubleFractional:
|
||||
children:
|
||||
- decimal_base
|
||||
NumberBase:
|
||||
rules:
|
||||
- BinaryBase
|
||||
- HexadecimalBase
|
||||
- DecimalBase
|
||||
DecimalBase:
|
||||
children:
|
||||
- literal:
|
||||
build:
|
||||
type: string
|
||||
from: whole_pair
|
||||
BinaryBase:
|
||||
children:
|
||||
- binary_digits
|
||||
BinaryDigits:
|
||||
children:
|
||||
- literal:
|
||||
build:
|
||||
type: string
|
||||
from: whole_pair
|
||||
HexadecimalBase:
|
||||
children:
|
||||
- hexadecimal_digits
|
||||
HexadecimalDigits:
|
||||
children:
|
||||
- literal:
|
||||
build:
|
||||
type: string
|
||||
from: whole_pair
|
||||
StringLiteral:
|
||||
rules:
|
||||
- SingleQuoteString
|
||||
- DoubleQuoteString
|
||||
- BacktickString
|
||||
SingleQuoteString:
|
||||
children:
|
||||
- string_inner:
|
||||
optional: true
|
||||
DoubleQuoteString:
|
||||
children:
|
||||
- inners:
|
||||
rule: DStringInner
|
||||
vec: true
|
||||
- expressions:
|
||||
rule: DStringExpression
|
||||
vec: true
|
||||
StringInner:
|
||||
children:
|
||||
- literal:
|
||||
build:
|
||||
type: string
|
||||
from: whole_pair
|
||||
DStringInner:
|
||||
children:
|
||||
- literal:
|
||||
build:
|
||||
type: string
|
||||
from: whole_pair
|
||||
DStringExpression:
|
||||
children:
|
||||
- expression
|
||||
BacktickString:
|
||||
children:
|
||||
- inners:
|
||||
rule: BacktickInner
|
||||
vec: true
|
||||
- expressions:
|
||||
rule: DStringExpression
|
||||
vec: true
|
||||
BacktickInner:
|
||||
children:
|
||||
- literal:
|
||||
build:
|
||||
type: string
|
||||
from: whole_pair
|
||||
BooleanLiteral:
|
||||
children:
|
||||
- literal:
|
||||
build:
|
||||
type: boolean
|
||||
from: parse_whole_pair
|
@ -823,7 +823,11 @@ IntLiteral = { NumberBase }
|
||||
|
||||
LongLiteral = ${ NumberBase ~ "L" }
|
||||
|
||||
DoubleLiteral = ${ DecimalBase ~ "." ~ Digit+ }
|
||||
DoubleLiteral = ${ DoubleWhole ~ "." ~ DoubleFractional }
|
||||
|
||||
DoubleWhole = { DecimalBase }
|
||||
|
||||
DoubleFractional = { DecimalBase }
|
||||
|
||||
NumberBase = {
|
||||
BinaryBase
|
||||
@ -831,18 +835,17 @@ NumberBase = {
|
||||
| DecimalBase
|
||||
}
|
||||
|
||||
DecimalBase = @{
|
||||
"0"
|
||||
| DecimalStartDigit ~ Digit*
|
||||
}
|
||||
DecimalBase = @{ '0'..'9'+ }
|
||||
|
||||
BinaryBase = @{ "0b" ~ Digit+ }
|
||||
BinaryBase = { "0b" ~ BinaryDigits }
|
||||
|
||||
DecimalStartDigit = { '1'..'9' }
|
||||
BinaryDigits = @{ BinaryDigit+ }
|
||||
|
||||
Digit = @{ '0'..'9'+ }
|
||||
BinaryDigit = { "0" | "1" }
|
||||
|
||||
HexadecimalBase = @{ "0x" ~ HexadecimalDigit+ }
|
||||
HexadecimalBase = { "0x" ~ HexadecimalDigits }
|
||||
|
||||
HexadecimalDigits = @{ HexadecimalDigit+ }
|
||||
|
||||
HexadecimalDigit = { '0'..'9' | 'a'..'f' }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user