-
Notifications
You must be signed in to change notification settings - Fork 0
/
statement.go
39 lines (32 loc) · 1.01 KB
/
statement.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package script
import (
"github.com/alecthomas/participle/v2/lexer"
)
type Statements struct {
Pos lexer.Position
Statements []*Statement `parser:"'{' @@* '}'"`
}
type Statement struct {
Pos lexer.Position
Next *Statement // Next statement within Statements block
Break bool `parser:" @'break'"`
Continue bool `parser:"| @'continue'"`
DoWhile *DoWhile `parser:"| @@"`
IfStmt *If `parser:"| @@"`
For *For `parser:"| @@"`
ForRange *ForRange `parser:"| @@"`
Repeat *Repeat `parser:"| @@"`
Return *Return `parser:"| @@"`
Switch *Switch `parser:"| @@"`
While *While `parser:"| @@"`
// Try is after the main block as it's a bit more complex,
// so it's better to place it here after the statements
// when in the railroad diagrams.
//
// Otherwise, this could be in the above block
Try *Try `parser:"| @@"`
// These must be at the end
Block *Statements `parser:"| @@"`
Expression *Expression `parser:"| @@"`
Empty bool `parser:"| @';'"`
}