-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstatements.go
More file actions
56 lines (48 loc) · 1.09 KB
/
statements.go
File metadata and controls
56 lines (48 loc) · 1.09 KB
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
package glox
type Stmt interface {
Accept(*StmtVisitor) interface{}
}
type StmtVisitor interface {
VisitBlockStmt(Block) interface{}
VisitExpressionStmt(Expression) interface{}
VisitPrintStmt(Print) interface{}
VisitVarStmt(Var) interface{}
VisitWhileStmt(While) interface{}
}
type Block struct {
Statements []Stmt
}
func (me Block) Accept(visitor *StmtVisitor) interface{} {
v := *visitor
return v.VisitBlockStmt(me)
}
type Expression struct {
Expression Expr
}
func (me Expression) Accept(visitor *StmtVisitor) interface{} {
v := *visitor
return v.VisitExpressionStmt(me)
}
type Print struct {
Expression Expr
}
func (me Print) Accept(visitor *StmtVisitor) interface{} {
v := *visitor
return v.VisitPrintStmt(me)
}
type Var struct {
Name Token
Initializer Expr
}
func (me Var) Accept(visitor *StmtVisitor) interface{} {
v := *visitor
return v.VisitVarStmt(me)
}
type While struct {
Condition Expr
Body Stmt
}
func (me While) Accept(visitor *StmtVisitor) interface{} {
v := *visitor
return v.VisitWhileStmt(me)
}