feat: improve expression grammar
This commit is contained in:
parent
71de3bd598
commit
1783097ba9
@ -9,9 +9,10 @@ The expression parser effectively implements a precedence table.
|
|||||||
|
|
||||||
| Operator | Precedence |
|
| Operator | Precedence |
|
||||||
|------------|------------|
|
|------------|------------|
|
||||||
| == != | 4 |
|
| == != | 5 |
|
||||||
| > >= < <= | 3 |
|
| > >= < <= | 4 |
|
||||||
| - + ++ | 2 |
|
| - + ++ | 3 |
|
||||||
|
| . ?. !. | 2 |
|
||||||
| / * % | 1 |
|
| / * % | 1 |
|
||||||
|
|
||||||
|
|
||||||
@ -22,9 +23,23 @@ Expression = Equality
|
|||||||
Equality = Comparison, (("==" | "!="), Comparison)*
|
Equality = Comparison, (("==" | "!="), Comparison)*
|
||||||
Comparison = Term, ((">" | ">=" | "<" | "<="), Term)*
|
Comparison = Term, ((">" | ">=" | "<" | "<="), Term)*
|
||||||
Term = Factor, (("-" | "+" | "++"), Factor)*
|
Term = Factor, (("-" | "+" | "++"), Factor)*
|
||||||
Factor = Unary, (("/" | "*" | "%"), Unary)*
|
Factor = DotAccess, (("/" | "*" | "%"), DotAccess)*
|
||||||
|
DotAccess = Unary, (("."), Unary)*
|
||||||
Unary = ("!" | "-"), Expression
|
Unary = ("!" | "-"), Expression
|
||||||
| FunctionCallExpression
|
| CallExpression
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## CallExpression
|
||||||
|
|
||||||
|
It's so hard to properly name these constructions.
|
||||||
|
This one groups a function call or an array access.
|
||||||
|
|
||||||
|
```ebnf
|
||||||
|
CallExpression = primary, "(", (arguments list)?, ")"
|
||||||
|
| primary, "[", (expression, (comma, expression)*, comma?)? "]"
|
||||||
|
| primary
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user