-
Notifications
You must be signed in to change notification settings - Fork 1
/
nodes.go
108 lines (85 loc) · 2.41 KB
/
nodes.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
package goexp
/*
Expr interface for all types expression nodes
*/
type Expr interface {
exprNode()
Accept(v Visitor, context VisitorContext) (res interface{}, err error)
}
/*
StringLiteralExpr represents a string literal
*/
type StringLiteralExpr struct {
Value string
}
type IntegerLiteralExpr struct {
Value int64
}
type FloatLiteralExpr struct {
Value float64
}
type BooleanLiteralExpr struct {
Value bool
}
type NilLiteralExpr struct {
}
type GroupingExpr struct {
Expr Expr
}
type BinaryExpr struct {
Left Expr
Right Expr
Operator Token
}
type UnaryExpr struct {
Value Expr
Operator Token
}
type CallExpr struct {
Name Expr
Args []Expr
}
type IdentifierExpr struct {
Name string
Expr Expr
}
func (StringLiteralExpr) exprNode() {}
func (IntegerLiteralExpr) exprNode() {}
func (FloatLiteralExpr) exprNode() {}
func (BooleanLiteralExpr) exprNode() {}
func (NilLiteralExpr) exprNode() {}
func (UnaryExpr) exprNode() {}
func (BinaryExpr) exprNode() {}
func (CallExpr) exprNode() {}
func (IdentifierExpr) exprNode() {}
func (GroupingExpr) exprNode() {}
func (s StringLiteralExpr) Accept(v Visitor, context VisitorContext) (interface{}, error) {
return v.VisitStringLiteralExpr(s, context)
}
func (e IntegerLiteralExpr) Accept(v Visitor, context VisitorContext) (interface{}, error) {
return v.VisitIntegerLiteralExpr(e, context)
}
func (e FloatLiteralExpr) Accept(v Visitor, context VisitorContext) (interface{}, error) {
return v.VisitFloatLiteralExpr(e, context)
}
func (e BooleanLiteralExpr) Accept(v Visitor, context VisitorContext) (interface{}, error) {
return v.VisitBooleanLiteralExpr(e, context)
}
func (e NilLiteralExpr) Accept(v Visitor, context VisitorContext) (interface{}, error) {
return v.VisitNilLiteralExpr(e, context)
}
func (e BinaryExpr) Accept(v Visitor, context VisitorContext) (interface{}, error) {
return v.VisitBinaryExpr(e, context)
}
func (e UnaryExpr) Accept(v Visitor, context VisitorContext) (interface{}, error) {
return v.VisitUnaryExpr(e, context)
}
func (e IdentifierExpr) Accept(v Visitor, context VisitorContext) (interface{}, error) {
return v.VisitIdentifierExpr(e, context)
}
func (e CallExpr) Accept(v Visitor, context VisitorContext) (interface{}, error) {
return v.VisitCallExpr(e, context)
}
func (e GroupingExpr) Accept(v Visitor, context VisitorContext) (interface{}, error) {
return v.VisitGroupingExpr(e, context)
}