-
Notifications
You must be signed in to change notification settings - Fork 0
/
stmt.go
108 lines (86 loc) · 1.99 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
// Code generated by "make codegen"; DO NOT EDIT.
package main
type StmtVisitor interface {
visitBlockStmt(*Block) interface{}
visitClassStmt(*Class) interface{}
visitExpressionStmt(*Expression) interface{}
visitFunctionStmt(*Function) interface{}
visitIfStmt(*If) interface{}
visitWhileStmt(*While) interface{}
visitPrintStmt(*Print) interface{}
visitReturnStmt(*Return) interface{}
visitBreakStmt(*Break) interface{}
visitVarStmt(*Var) interface{}
}
type Stmt interface {
accept(StmtVisitor) interface{}
}
type Block struct {
statements []Stmt
}
func (b *Block) accept(visitor StmtVisitor) interface{} {
return visitor.visitBlockStmt(b)
}
type Class struct {
name Token
superclass Variable
methods []Function
}
func (c *Class) accept(visitor StmtVisitor) interface{} {
return visitor.visitClassStmt(c)
}
type Expression struct {
expression Expr
}
func (e *Expression) accept(visitor StmtVisitor) interface{} {
return visitor.visitExpressionStmt(e)
}
type Function struct {
name Token
params []Token
body []Stmt
}
func (f *Function) accept(visitor StmtVisitor) interface{} {
return visitor.visitFunctionStmt(f)
}
type If struct {
condition Expr
thenBranch Stmt
elseBranch Stmt
}
func (i *If) accept(visitor StmtVisitor) interface{} {
return visitor.visitIfStmt(i)
}
type While struct {
condition Expr
body Stmt
}
func (w *While) accept(visitor StmtVisitor) interface{} {
return visitor.visitWhileStmt(w)
}
type Print struct {
expression Expr
}
func (p *Print) accept(visitor StmtVisitor) interface{} {
return visitor.visitPrintStmt(p)
}
type Return struct {
keyword Token
value Expr
}
func (r *Return) accept(visitor StmtVisitor) interface{} {
return visitor.visitReturnStmt(r)
}
type Break struct {
keyword Token
}
func (b *Break) accept(visitor StmtVisitor) interface{} {
return visitor.visitBreakStmt(b)
}
type Var struct {
name Token
initializer Expr
}
func (v *Var) accept(visitor StmtVisitor) interface{} {
return visitor.visitVarStmt(v)
}