-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexpr_def.go
195 lines (157 loc) · 4.37 KB
/
expr_def.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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
// Code generated by cmd. DO NOT EDIT.
package expr
import "reflect"
type Expr interface {
AcceptStr(visitor ExprVisitorStr) string
AcceptObj(visitor ExprVisitorObj) (interface{}, error)
}
type ExprVisitorStr interface{
VisitExprBinaryStr(binary *ExprBinary) string
VisitExprCallStr(call *ExprCall) string
VisitExprGroupingStr(grouping *ExprGrouping) string
VisitExprLiteralStr(literal *ExprLiteral) string
VisitExprLogicalStr(logical *ExprLogical) string
VisitExprUnaryStr(unary *ExprUnary) string
VisitExprArrayStr(array *ExprArray) string
VisitExprVariableStr(variable *ExprVariable) string
}
type ExprVisitorObj interface{
VisitExprBinaryObj(binary *ExprBinary) (interface{}, error)
VisitExprCallObj(call *ExprCall) (interface{}, error)
VisitExprGroupingObj(grouping *ExprGrouping) (interface{}, error)
VisitExprLiteralObj(literal *ExprLiteral) (interface{}, error)
VisitExprLogicalObj(logical *ExprLogical) (interface{}, error)
VisitExprUnaryObj(unary *ExprUnary) (interface{}, error)
VisitExprArrayObj(array *ExprArray) (interface{}, error)
VisitExprVariableObj(variable *ExprVariable) (interface{}, error)
}
type ExprBinary struct {
left Expr
operator *Token
right Expr
}
func NewExprBinary(left Expr, operator *Token, right Expr) Expr {
t := &ExprBinary{}
t.left = left
t.operator = operator
t.right = right
return t
}
func (e *ExprBinary) AcceptStr(visitor ExprVisitorStr) string {
return visitor.VisitExprBinaryStr(e)
}
func (e *ExprBinary) AcceptObj(visitor ExprVisitorObj) (interface{}, error) {
return visitor.VisitExprBinaryObj(e)
}
type ExprCall struct {
callee Expr
paren *Token
arguments []Expr
}
func NewExprCall(callee Expr, paren *Token, arguments []Expr) Expr {
t := &ExprCall{}
t.callee = callee
t.paren = paren
t.arguments = arguments
return t
}
func (e *ExprCall) AcceptStr(visitor ExprVisitorStr) string {
return visitor.VisitExprCallStr(e)
}
func (e *ExprCall) AcceptObj(visitor ExprVisitorObj) (interface{}, error) {
return visitor.VisitExprCallObj(e)
}
type ExprGrouping struct {
expression Expr
}
func NewExprGrouping(expression Expr) Expr {
t := &ExprGrouping{}
t.expression = expression
return t
}
func (e *ExprGrouping) AcceptStr(visitor ExprVisitorStr) string {
return visitor.VisitExprGroupingStr(e)
}
func (e *ExprGrouping) AcceptObj(visitor ExprVisitorObj) (interface{}, error) {
return visitor.VisitExprGroupingObj(e)
}
type ExprLiteral struct {
value interface{}
rtype reflect.Kind
}
func NewExprLiteral(value interface{}, rtype reflect.Kind) Expr {
t := &ExprLiteral{}
t.value = value
t.rtype = rtype
return t
}
func (e *ExprLiteral) AcceptStr(visitor ExprVisitorStr) string {
return visitor.VisitExprLiteralStr(e)
}
func (e *ExprLiteral) AcceptObj(visitor ExprVisitorObj) (interface{}, error) {
return visitor.VisitExprLiteralObj(e)
}
type ExprLogical struct {
left Expr
operator *Token
right Expr
}
func NewExprLogical(left Expr, operator *Token, right Expr) Expr {
t := &ExprLogical{}
t.left = left
t.operator = operator
t.right = right
return t
}
func (e *ExprLogical) AcceptStr(visitor ExprVisitorStr) string {
return visitor.VisitExprLogicalStr(e)
}
func (e *ExprLogical) AcceptObj(visitor ExprVisitorObj) (interface{}, error) {
return visitor.VisitExprLogicalObj(e)
}
type ExprUnary struct {
operator *Token
right Expr
}
func NewExprUnary(operator *Token, right Expr) Expr {
t := &ExprUnary{}
t.operator = operator
t.right = right
return t
}
func (e *ExprUnary) AcceptStr(visitor ExprVisitorStr) string {
return visitor.VisitExprUnaryStr(e)
}
func (e *ExprUnary) AcceptObj(visitor ExprVisitorObj) (interface{}, error) {
return visitor.VisitExprUnaryObj(e)
}
type ExprArray struct {
bracket *Token
items []Expr
}
func NewExprArray(bracket *Token, items []Expr) Expr {
t := &ExprArray{}
t.bracket = bracket
t.items = items
return t
}
func (e *ExprArray) AcceptStr(visitor ExprVisitorStr) string {
return visitor.VisitExprArrayStr(e)
}
func (e *ExprArray) AcceptObj(visitor ExprVisitorObj) (interface{}, error) {
return visitor.VisitExprArrayObj(e)
}
type ExprVariable struct {
name *Token
}
func NewExprVariable(name *Token) Expr {
t := &ExprVariable{}
t.name = name
return t
}
func (e *ExprVariable) AcceptStr(visitor ExprVisitorStr) string {
return visitor.VisitExprVariableStr(e)
}
func (e *ExprVariable) AcceptObj(visitor ExprVisitorObj) (interface{}, error) {
return visitor.VisitExprVariableObj(e)
}