-
-
Notifications
You must be signed in to change notification settings - Fork 120
/
Copy pathstmt.go
157 lines (134 loc) · 2.52 KB
/
stmt.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
package ast
// Stmt provides all of interfaces for statement.
type Stmt interface {
Pos
}
// StmtImpl provide commonly implementations for Stmt..
type StmtImpl struct {
PosImpl // PosImpl provide Pos() function.
}
// StmtsStmt provides statements.
type StmtsStmt struct {
StmtImpl
Stmts []Stmt
}
// ExprStmt provide expression statement.
type ExprStmt struct {
StmtImpl
Expr Expr
}
// IfStmt provide "if/else" statement.
type IfStmt struct {
StmtImpl
If Expr
Then Stmt
ElseIf []Stmt // This is array of IfStmt
Else Stmt
}
// TryStmt provide "try/catch/finally" statement.
type TryStmt struct {
StmtImpl
Try Stmt
Var string
Catch Stmt
Finally Stmt
}
// ForStmt provide "for in" expression statement.
type ForStmt struct {
StmtImpl
Vars []string
Value Expr
Stmt Stmt
}
// CForStmt provide C-style "for (;;)" expression statement.
type CForStmt struct {
StmtImpl
Stmt1 Stmt
Expr2 Expr
Expr3 Expr
Stmt Stmt
}
// LoopStmt provide "for expr" expression statement.
type LoopStmt struct {
StmtImpl
Expr Expr
Stmt Stmt
}
// BreakStmt provide "break" expression statement.
type BreakStmt struct {
StmtImpl
}
// ContinueStmt provide "continue" expression statement.
type ContinueStmt struct {
StmtImpl
}
// ReturnStmt provide "return" expression statement.
type ReturnStmt struct {
StmtImpl
Exprs []Expr
}
// ThrowStmt provide "throw" expression statement.
type ThrowStmt struct {
StmtImpl
Expr Expr
}
// ModuleStmt provide "module" expression statement.
type ModuleStmt struct {
StmtImpl
Name string
Stmt Stmt
}
// SwitchStmt provide switch statement.
type SwitchStmt struct {
StmtImpl
Expr Expr
Cases []Stmt
Default Stmt
}
// SwitchCaseStmt provide switch case statement.
type SwitchCaseStmt struct {
StmtImpl
Exprs []Expr
Stmt Stmt
}
// VarStmt provide statement to let variables in current scope.
type VarStmt struct {
StmtImpl
Names []string
Exprs []Expr
}
// LetsStmt provide multiple statement of let.
type LetsStmt struct {
StmtImpl
LHSS []Expr
RHSS []Expr
}
// LetMapItemStmt provide statement of let for map item.
type LetMapItemStmt struct {
StmtImpl
LHSS []Expr
RHS Expr
}
// GoroutineStmt provide statement of groutine.
type GoroutineStmt struct {
StmtImpl
Expr Expr
}
// DeleteStmt provides statement of delete.
type DeleteStmt struct {
ExprImpl
Item Expr
Key Expr
}
// CloseStmt provides statement of close.
type CloseStmt struct {
StmtImpl
Expr Expr
}
// ChanStmt provide chan lets statement.
type ChanStmt struct {
ExprImpl
LHS Expr
OkExpr Expr
RHS Expr
}