Work on expressions.
This commit is contained in:
parent
3f534bf7fd
commit
3f3df59761
@ -440,4 +440,162 @@ ForStatement:
|
|||||||
vec: true
|
vec: true
|
||||||
- end_kw:
|
- end_kw:
|
||||||
rule: End
|
rule: End
|
||||||
|
vec: true
|
||||||
|
|
||||||
|
# Expressions
|
||||||
|
Expression:
|
||||||
|
children:
|
||||||
|
- ternary_expression
|
||||||
|
TernaryExpression:
|
||||||
|
children:
|
||||||
|
- or_expression
|
||||||
|
- ternary_alternatives:
|
||||||
|
optional: true
|
||||||
|
TernaryAlternatives:
|
||||||
|
children:
|
||||||
|
- ternary_true_alternative
|
||||||
|
- ternary_false_alternative
|
||||||
|
TernaryTrueAlternative:
|
||||||
|
children:
|
||||||
|
- expression
|
||||||
|
TernaryFalseAlternative:
|
||||||
|
children:
|
||||||
|
- expression
|
||||||
|
OrExpression:
|
||||||
|
children:
|
||||||
|
- left:
|
||||||
|
rule: AndExpression
|
||||||
|
- or_sym:
|
||||||
|
rule: Or
|
||||||
|
skip: true
|
||||||
|
- right:
|
||||||
|
rule: Expression
|
||||||
|
optional: true
|
||||||
|
AndExpression:
|
||||||
|
children:
|
||||||
|
- left:
|
||||||
|
rule: ComparisonExpression
|
||||||
|
- and_sym:
|
||||||
|
rule: And
|
||||||
|
skip: true
|
||||||
|
- right:
|
||||||
|
rule: Expression
|
||||||
|
optional: true
|
||||||
|
ComparisonExpression:
|
||||||
|
children:
|
||||||
|
- left:
|
||||||
|
rule: ShiftExpression
|
||||||
|
- operator:
|
||||||
|
rule: ComparisonOperator
|
||||||
|
optional: true
|
||||||
|
- right:
|
||||||
|
rule: Expression
|
||||||
|
optional: true
|
||||||
|
ComparisonOperator:
|
||||||
|
rules:
|
||||||
|
- Greater
|
||||||
|
- Less
|
||||||
|
- GreaterEqual
|
||||||
|
- LessEqual
|
||||||
|
- EqualTo
|
||||||
|
- NotEqualTo
|
||||||
|
ShiftExpression:
|
||||||
|
children:
|
||||||
|
- left:
|
||||||
|
rule: AdditiveExpression
|
||||||
|
- operator:
|
||||||
|
rule: ShiftOperator
|
||||||
|
optional: true
|
||||||
|
- right:
|
||||||
|
rule: Expression
|
||||||
|
ShiftOperator:
|
||||||
|
rules:
|
||||||
|
- LeftShift
|
||||||
|
- RightShift
|
||||||
|
AdditiveExpression:
|
||||||
|
children:
|
||||||
|
- left:
|
||||||
|
rule: MultiplicativeExpression
|
||||||
|
- operator:
|
||||||
|
rule: AdditiveOperator
|
||||||
|
optional: true
|
||||||
|
- right:
|
||||||
|
rule: Expression
|
||||||
|
optional: true
|
||||||
|
MultiplicativeExpression:
|
||||||
|
children:
|
||||||
|
- left:
|
||||||
|
rule: PrefixExpression
|
||||||
|
- operator:
|
||||||
|
rule: MultiplicativeOperator
|
||||||
|
optional: true
|
||||||
|
- right:
|
||||||
|
rule: Expression
|
||||||
|
MultiplicativeOperator:
|
||||||
|
type: leaf_enum
|
||||||
|
rules:
|
||||||
|
- Multiply
|
||||||
|
- Divide
|
||||||
|
- Modulo
|
||||||
|
PrefixExpression:
|
||||||
|
children:
|
||||||
|
- operators:
|
||||||
|
rule: PrefixOperator
|
||||||
|
vec: true
|
||||||
|
PrefixOperator:
|
||||||
|
type: leaf_enum
|
||||||
|
rules:
|
||||||
|
- Spread
|
||||||
|
- Not
|
||||||
|
- Negative
|
||||||
|
SuffixExpression:
|
||||||
|
children:
|
||||||
|
- left:
|
||||||
|
rule: PrimaryExpression
|
||||||
|
- operators:
|
||||||
|
rule: SuffixOperator
|
||||||
|
vec: true
|
||||||
|
SuffixOperator:
|
||||||
|
type: leaf_enum
|
||||||
|
rules:
|
||||||
|
- PlusPlus
|
||||||
|
- MinusMinus
|
||||||
|
- ObjectProperty:
|
||||||
|
child: true
|
||||||
|
- ObjectIndex:
|
||||||
|
child: true
|
||||||
|
- Call:
|
||||||
|
child: true
|
||||||
|
ObjectProperty:
|
||||||
|
children:
|
||||||
|
- identifier
|
||||||
|
ObjectIndex:
|
||||||
|
children:
|
||||||
|
- expression
|
||||||
|
PrimaryExpression:
|
||||||
|
rules:
|
||||||
|
- Literal
|
||||||
|
- FullyQualifiedName
|
||||||
|
- Closure
|
||||||
|
- ParenthesizedExpression
|
||||||
|
ParenthesizedExpression:
|
||||||
|
children:
|
||||||
|
- expression
|
||||||
|
|
||||||
|
# Calls
|
||||||
|
Call:
|
||||||
|
children:
|
||||||
|
- turbo_fish:
|
||||||
|
optional: true
|
||||||
|
- expression_list:
|
||||||
|
optional: true
|
||||||
|
- closure:
|
||||||
|
optional: true
|
||||||
|
TurboFish:
|
||||||
|
children:
|
||||||
|
- generic_arguments
|
||||||
|
ExpressionList:
|
||||||
|
children:
|
||||||
|
- expressions:
|
||||||
|
rule: Expression
|
||||||
vec: true
|
vec: true
|
@ -81,6 +81,10 @@ Keyword = {
|
|||||||
| True
|
| True
|
||||||
| False
|
| False
|
||||||
| Use
|
| Use
|
||||||
|
| Then
|
||||||
|
| Do
|
||||||
|
| End
|
||||||
|
| Companion
|
||||||
| Byte
|
| Byte
|
||||||
| Short
|
| Short
|
||||||
| Char
|
| Char
|
||||||
@ -627,12 +631,22 @@ Expression = {
|
|||||||
|
|
||||||
TernaryExpression = {
|
TernaryExpression = {
|
||||||
OrExpression
|
OrExpression
|
||||||
~ (
|
~ ( TernaryAlternatives )?
|
||||||
"?"
|
}
|
||||||
~ Expression
|
|
||||||
~ ":"
|
TernaryAlternatives = {
|
||||||
~ Expression
|
TernaryTrueAlternative
|
||||||
)?
|
~ TernaryFalseAlternative
|
||||||
|
}
|
||||||
|
|
||||||
|
TernaryTrueAlternative = {
|
||||||
|
"?"
|
||||||
|
~ Expression
|
||||||
|
}
|
||||||
|
|
||||||
|
TernaryFalseAlternative = {
|
||||||
|
":"
|
||||||
|
~ Expression
|
||||||
}
|
}
|
||||||
|
|
||||||
OrExpression = {
|
OrExpression = {
|
||||||
@ -648,52 +662,93 @@ AndExpression = {
|
|||||||
ComparisonExpression = {
|
ComparisonExpression = {
|
||||||
ShiftExpression
|
ShiftExpression
|
||||||
~ (
|
~ (
|
||||||
( Greater | Less | GreaterEqual | LessEqual | EqualTo | NotEqualTo )
|
ComparisonOperator
|
||||||
~ Expression
|
~ Expression
|
||||||
)?
|
)?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ComparisonOperator = {
|
||||||
|
Greater
|
||||||
|
| Less
|
||||||
|
| GreaterEqual
|
||||||
|
| LessEqual
|
||||||
|
| EqualTo
|
||||||
|
| NotEqualTo
|
||||||
|
}
|
||||||
|
|
||||||
ShiftExpression = {
|
ShiftExpression = {
|
||||||
AdditiveExpression
|
AdditiveExpression
|
||||||
~ ( ( LeftShift | RightShift ) ~ Expression )?
|
~ (
|
||||||
|
ShiftOperator
|
||||||
|
~ Expression
|
||||||
|
)?
|
||||||
|
}
|
||||||
|
|
||||||
|
ShiftOperator = {
|
||||||
|
LeftShift
|
||||||
|
| RightShift
|
||||||
}
|
}
|
||||||
|
|
||||||
AdditiveExpression = {
|
AdditiveExpression = {
|
||||||
MultiplicativeExpression
|
MultiplicativeExpression
|
||||||
~ (
|
~ (
|
||||||
( Add | Subtract )
|
AdditiveOperator
|
||||||
~ Expression
|
~ Expression
|
||||||
)?
|
)?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AdditiveOperator = {
|
||||||
|
Add
|
||||||
|
| Subtract
|
||||||
|
}
|
||||||
|
|
||||||
MultiplicativeExpression = {
|
MultiplicativeExpression = {
|
||||||
PrefixExpression
|
PrefixExpression
|
||||||
~ (
|
~ (
|
||||||
( Multiply | Divide | Modulo )
|
MultiplicativeOperator
|
||||||
~ Expression
|
~ Expression
|
||||||
)?
|
)?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MultiplicativeOperator = {
|
||||||
|
Multiply
|
||||||
|
| Divide
|
||||||
|
| Modulo
|
||||||
|
}
|
||||||
|
|
||||||
PrefixExpression = {
|
PrefixExpression = {
|
||||||
(
|
PrefixOperator*
|
||||||
Spread
|
|
||||||
| BorrowMut
|
|
||||||
| Borrow
|
|
||||||
| Mut
|
|
||||||
| Not
|
|
||||||
| Negative
|
|
||||||
)*
|
|
||||||
~ SuffixExpression
|
~ SuffixExpression
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PrefixOperator = {
|
||||||
|
Spread
|
||||||
|
| Not
|
||||||
|
| Negative
|
||||||
|
}
|
||||||
|
|
||||||
SuffixExpression = {
|
SuffixExpression = {
|
||||||
PrimaryExpression
|
PrimaryExpression
|
||||||
~ (
|
~ SuffixOperator*
|
||||||
ObjectAccess
|
}
|
||||||
| ParenthesesCall
|
|
||||||
| PlusPlus
|
SuffixOperator = {
|
||||||
| MinusMinus
|
PlusPlus
|
||||||
)*
|
| MinusMinus
|
||||||
|
| ObjectProperty
|
||||||
|
| ObjectIndex
|
||||||
|
| Call
|
||||||
|
}
|
||||||
|
|
||||||
|
ObjectProperty = {
|
||||||
|
"."
|
||||||
|
~ Identifier
|
||||||
|
}
|
||||||
|
|
||||||
|
ObjectIndex = {
|
||||||
|
"["
|
||||||
|
~ Expression
|
||||||
|
~ "]"
|
||||||
}
|
}
|
||||||
|
|
||||||
PrimaryExpression = {
|
PrimaryExpression = {
|
||||||
@ -709,36 +764,9 @@ ParenthesizedExpression = {
|
|||||||
~ ")"
|
~ ")"
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectAccess = {
|
|
||||||
( ObjectProperty | ObjectIndex )+
|
|
||||||
}
|
|
||||||
|
|
||||||
ObjectProperty = {
|
|
||||||
"."
|
|
||||||
~ Identifier
|
|
||||||
}
|
|
||||||
|
|
||||||
ObjectIndex = {
|
|
||||||
"["
|
|
||||||
~ Expression
|
|
||||||
~ "]"
|
|
||||||
}
|
|
||||||
|
|
||||||
// Calls
|
// Calls
|
||||||
|
|
||||||
CallExpression = {
|
Call = {
|
||||||
PrimaryExpression
|
|
||||||
~ ObjectAccess?
|
|
||||||
~ ParenthesesCall
|
|
||||||
~ (
|
|
||||||
ObjectAccess
|
|
||||||
| ParenthesesCall
|
|
||||||
| PlusPlus
|
|
||||||
| MinusMinus
|
|
||||||
)*
|
|
||||||
}
|
|
||||||
|
|
||||||
ParenthesesCall = {
|
|
||||||
TurboFish?
|
TurboFish?
|
||||||
~ "("
|
~ "("
|
||||||
~ ExpressionList?
|
~ ExpressionList?
|
||||||
|
Loading…
Reference in New Issue
Block a user