Refine and add statements.
This commit is contained in:
parent
17f5d2d62d
commit
3f534bf7fd
@ -311,3 +311,133 @@ Member:
|
|||||||
on: rule_present
|
on: rule_present
|
||||||
- identifier
|
- identifier
|
||||||
- type_use
|
- type_use
|
||||||
|
|
||||||
|
# Statements
|
||||||
|
Statement:
|
||||||
|
rules:
|
||||||
|
- VariableDeclaration
|
||||||
|
- AssignmentStatement
|
||||||
|
- ExpressionStatement
|
||||||
|
- UseStatement
|
||||||
|
- IfElseStatement
|
||||||
|
- IfStatementStatement
|
||||||
|
- WhileStatement
|
||||||
|
- ForStatement
|
||||||
|
VariableDeclaration:
|
||||||
|
children:
|
||||||
|
- let_kw:
|
||||||
|
rule: Let
|
||||||
|
skip: true
|
||||||
|
- is_mut:
|
||||||
|
rule: Mut
|
||||||
|
build:
|
||||||
|
type: boolean
|
||||||
|
on: rule_present
|
||||||
|
- identifier
|
||||||
|
- type_use:
|
||||||
|
optional: true
|
||||||
|
- expression:
|
||||||
|
optional: true
|
||||||
|
AssignmentStatement:
|
||||||
|
children:
|
||||||
|
- left:
|
||||||
|
rule: Expression
|
||||||
|
- right:
|
||||||
|
rule: Expression
|
||||||
|
ExpressionStatement:
|
||||||
|
children:
|
||||||
|
- expression
|
||||||
|
IfStatement:
|
||||||
|
children:
|
||||||
|
- if_kw:
|
||||||
|
rule: If
|
||||||
|
skip: true
|
||||||
|
- expression
|
||||||
|
- then_kw:
|
||||||
|
rule: Then
|
||||||
|
skip: true
|
||||||
|
- statements:
|
||||||
|
rule: Statement
|
||||||
|
vec: true
|
||||||
|
- end_kw:
|
||||||
|
rule: End
|
||||||
|
skip: true
|
||||||
|
IfElseStatement:
|
||||||
|
children:
|
||||||
|
- if_else_first
|
||||||
|
- if_else_ifs:
|
||||||
|
rule: IfElseIf
|
||||||
|
vec: true
|
||||||
|
- if_else_else
|
||||||
|
IfElseFirst:
|
||||||
|
children:
|
||||||
|
- if_kw:
|
||||||
|
rule: If
|
||||||
|
skip: true
|
||||||
|
- expression
|
||||||
|
- then_kw:
|
||||||
|
rule: Then
|
||||||
|
skip: true
|
||||||
|
- statements:
|
||||||
|
rule: Statement
|
||||||
|
vec: true
|
||||||
|
IfElseIf:
|
||||||
|
children:
|
||||||
|
- else_kw:
|
||||||
|
rule: Else
|
||||||
|
skip: true
|
||||||
|
- if_kw:
|
||||||
|
rule: If
|
||||||
|
skip: true
|
||||||
|
- expression
|
||||||
|
- then_kw:
|
||||||
|
rule: Then
|
||||||
|
skip: true
|
||||||
|
- statements:
|
||||||
|
rule: Statement
|
||||||
|
vec: true
|
||||||
|
IfElseElse:
|
||||||
|
children:
|
||||||
|
- else_kw:
|
||||||
|
rule: Else
|
||||||
|
skip: true
|
||||||
|
- statements:
|
||||||
|
rule: Statement
|
||||||
|
vec: true
|
||||||
|
- end_kw:
|
||||||
|
rule: End
|
||||||
|
skip: true
|
||||||
|
WhileStatement:
|
||||||
|
children:
|
||||||
|
- while_kw:
|
||||||
|
rule: While
|
||||||
|
skip: true
|
||||||
|
- expression
|
||||||
|
- do_kw:
|
||||||
|
rule: Do
|
||||||
|
skip: true
|
||||||
|
- statements:
|
||||||
|
rule: Statement
|
||||||
|
vec: true
|
||||||
|
- end_kw:
|
||||||
|
rule: End
|
||||||
|
skip: true
|
||||||
|
ForStatement:
|
||||||
|
children:
|
||||||
|
- for_kw:
|
||||||
|
rule: For
|
||||||
|
skip: true
|
||||||
|
- identifier
|
||||||
|
- in_kw:
|
||||||
|
rule: In
|
||||||
|
skip: true
|
||||||
|
- expression
|
||||||
|
- do_kw:
|
||||||
|
rule: Do
|
||||||
|
skip: true
|
||||||
|
- statement:
|
||||||
|
rule: Statement
|
||||||
|
vec: true
|
||||||
|
- end_kw:
|
||||||
|
rule: End
|
||||||
|
vec: true
|
@ -30,6 +30,8 @@ Alias = { "alias" }
|
|||||||
True = { "true" }
|
True = { "true" }
|
||||||
False = { "false" }
|
False = { "false" }
|
||||||
Use = { "use" }
|
Use = { "use" }
|
||||||
|
Then = { "then" }
|
||||||
|
Do = { "do" }
|
||||||
End = { "end" }
|
End = { "end" }
|
||||||
Companion = { "comp" }
|
Companion = { "comp" }
|
||||||
|
|
||||||
@ -535,29 +537,15 @@ Member = {
|
|||||||
|
|
||||||
// Statements
|
// Statements
|
||||||
|
|
||||||
BlockStatement = {
|
|
||||||
"{"
|
|
||||||
~ Statement*
|
|
||||||
~ Expression?
|
|
||||||
~ "}"
|
|
||||||
}
|
|
||||||
|
|
||||||
Statement = {
|
Statement = {
|
||||||
(
|
VariableDeclaration
|
||||||
VariableDeclaration
|
| AssignmentStatement
|
||||||
| AssignmentStatement
|
| ExpressionStatement
|
||||||
| CallStatement
|
| UseStatement
|
||||||
| ReturnStatement
|
| IfElseStatement
|
||||||
| UseStatement
|
| IfStatement
|
||||||
)
|
| WhileStatement
|
||||||
~ Semicolon
|
| ForStatement
|
||||||
| (
|
|
||||||
BlockStatement
|
|
||||||
| IfElseStatement
|
|
||||||
| IfStatement
|
|
||||||
| WhileStatement
|
|
||||||
| ForStatement
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VariableDeclaration = {
|
VariableDeclaration = {
|
||||||
@ -574,63 +562,61 @@ AssignmentStatement = {
|
|||||||
~ Expression
|
~ Expression
|
||||||
}
|
}
|
||||||
|
|
||||||
CallStatement = {
|
ExpressionStatement = {
|
||||||
PrimaryExpression
|
Expression
|
||||||
~ ObjectAccess?
|
|
||||||
~ ParenthesesCall
|
|
||||||
~ (
|
|
||||||
ObjectAccess
|
|
||||||
| ParenthesesCall
|
|
||||||
| PlusPlus
|
|
||||||
| MinusMinus
|
|
||||||
)*
|
|
||||||
}
|
|
||||||
|
|
||||||
ReturnStatement = {
|
|
||||||
Return
|
|
||||||
~ Expression?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IfStatement = {
|
IfStatement = {
|
||||||
If
|
If
|
||||||
~ "("
|
|
||||||
~ Expression
|
~ Expression
|
||||||
~ ")"
|
~ Then
|
||||||
~ BlockStatement
|
~ Statement*
|
||||||
|
~ End
|
||||||
}
|
}
|
||||||
|
|
||||||
IfElseStatement = {
|
IfElseStatement = {
|
||||||
IfStatement
|
IfElseFirst
|
||||||
~ ElseIf*
|
~ IfElseIf*
|
||||||
~ ElseBlock?
|
~ IfElseElse
|
||||||
}
|
}
|
||||||
|
|
||||||
ElseIf = {
|
IfElseFirst = {
|
||||||
Else
|
If
|
||||||
~ IfStatement
|
~ Expression
|
||||||
|
~ Then
|
||||||
|
~ Statement*
|
||||||
}
|
}
|
||||||
|
|
||||||
ElseBlock = {
|
IfElseIf = {
|
||||||
Else
|
Else
|
||||||
~ BlockStatement
|
~ If
|
||||||
|
~ Expression
|
||||||
|
~ Then
|
||||||
|
~ Statement*
|
||||||
|
}
|
||||||
|
|
||||||
|
IfElseElse = {
|
||||||
|
Else
|
||||||
|
~ Statement*
|
||||||
|
~ End
|
||||||
}
|
}
|
||||||
|
|
||||||
WhileStatement = {
|
WhileStatement = {
|
||||||
While
|
While
|
||||||
~ "("
|
|
||||||
~ Expression
|
~ Expression
|
||||||
~ ")"
|
~ Do
|
||||||
~ BlockStatement
|
~ Statement*
|
||||||
|
~ End
|
||||||
}
|
}
|
||||||
|
|
||||||
ForStatement = {
|
ForStatement = {
|
||||||
For
|
For
|
||||||
~ "("
|
|
||||||
~ Identifier
|
~ Identifier
|
||||||
~ In
|
~ In
|
||||||
~ Expression
|
~ Expression
|
||||||
~ ")"
|
~ Do
|
||||||
~ BlockStatement
|
~ Statement*
|
||||||
|
~ End
|
||||||
}
|
}
|
||||||
|
|
||||||
// Expressions
|
// Expressions
|
||||||
@ -740,6 +726,18 @@ ObjectIndex = {
|
|||||||
|
|
||||||
// Calls
|
// Calls
|
||||||
|
|
||||||
|
CallExpression = {
|
||||||
|
PrimaryExpression
|
||||||
|
~ ObjectAccess?
|
||||||
|
~ ParenthesesCall
|
||||||
|
~ (
|
||||||
|
ObjectAccess
|
||||||
|
| ParenthesesCall
|
||||||
|
| PlusPlus
|
||||||
|
| MinusMinus
|
||||||
|
)*
|
||||||
|
}
|
||||||
|
|
||||||
ParenthesesCall = {
|
ParenthesesCall = {
|
||||||
TurboFish?
|
TurboFish?
|
||||||
~ "("
|
~ "("
|
||||||
|
Loading…
Reference in New Issue
Block a user