-
Notifications
You must be signed in to change notification settings - Fork 0
/
EmptyVisitor.go
170 lines (127 loc) · 4.06 KB
/
EmptyVisitor.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
package dLola
/*import (
"fmt"
"strings"
)*/
/*Empty Visitor that traverses recursively the AST, CODE MAY NEED TO BE ADDED IN THEIR SPECIFIC PLACES*/
type EmptyVisitor struct { //implements ExprVisitor, BoolExprVisitor, NumExprVisitor, NumComparisonVisitor and StreamExprVisitor
//fields, may be stateful
}
/*ExprVisitor methods*/
func (v *EmptyVisitor) VisitConstExpr(c ConstExpr) {
}
func (v *EmptyVisitor) VisitLetExpr(l LetExpr) {
emptyLet(v, l)
}
func (v *EmptyVisitor) VisitIfThenElseExpr(ite IfThenElseExpr) {
emptyIf(v, ite)
}
func (v *EmptyVisitor) VisitStringExpr(s StringExpr) {
s.StExpr.AcceptStr(v)
}
func (v *EmptyVisitor) VisitStreamOffsetExpr(s StreamOffsetExpr) {
s.SExpr.AcceptStream(v)
}
func (v *EmptyVisitor) VisitBooleanExpr(b BooleanExpr) {
b.BExpr.AcceptBool(v)
}
func (v *EmptyVisitor) VisitNumericExpr(n NumericExpr) {
n.NExpr.AcceptNum(v)
}
/*END ExprVisitor methods*/
/*BoolExprVisitor methods*/
func (v *EmptyVisitor) VisitTruePredicate(t TruePredicate) {
}
func (v *EmptyVisitor) VisitFalsePredicate(f FalsePredicate) {
}
func (v *EmptyVisitor) VisitNotPredicate(n NotPredicate) {
n.Inner.AcceptBool(v)
}
func (v *EmptyVisitor) VisitAndPredicate(a AndPredicate) {
emptyBoolOp(v, a.Left, a.Right)
}
func (v *EmptyVisitor) VisitOrPredicate(o OrPredicate) {
emptyBoolOp(v, o.Left, o.Right)
}
func (v *EmptyVisitor) VisitNumComparisonPredicate(n NumComparisonPredicate) {
n.Comp.AcceptNumComp(v)
}
func (v *EmptyVisitor) VisitStrComparisonPredicate(s StrComparisonPredicate) {
s.Comp.AcceptStrComp(v)
}
/*END BoolExprVisitor methods*/
/*NumComparisonVisitor methods*/
func (v *EmptyVisitor) VisitNumLess(e NumLess) {
emptyNumOp(v, e.Left, e.Right)
}
func (v *EmptyVisitor) VisitNumLessEq(e NumLessEq) {
emptyNumOp(v, e.Left, e.Right)
}
func (v *EmptyVisitor) VisitNumEq(e NumEq) {
emptyNumOp(v, e.Left, e.Right)
}
func (v *EmptyVisitor) VisitNumGreater(e NumGreater) {
emptyNumOp(v, e.Left, e.Right)
}
func (v *EmptyVisitor) VisitNumGreaterEq(e NumGreaterEq) {
emptyNumOp(v, e.Left, e.Right)
}
func (v *EmptyVisitor) VisitNumNotEq(e NumNotEq) {
emptyNumOp(v, e.Left, e.Right)
}
/*END NumComparisonVisitor methods*/
/*NumExprVisitor methods*/
func (v *EmptyVisitor) VisitIntLiteralExpr(i IntLiteralExpr) {
}
func (v *EmptyVisitor) VisitFloatLiteralExpr(f FloatLiteralExpr) {
}
func (v *EmptyVisitor) VisitNumMulExpr(e NumMulExpr) {
emptyNumOp(v, e.Left, e.Right)
}
func (v *EmptyVisitor) VisitNumDivExpr(e NumDivExpr) {
emptyNumOp(v, e.Left, e.Right)
}
func (v *EmptyVisitor) VisitNumPlusExpr(e NumPlusExpr) {
emptyNumOp(v, e.Left, e.Right)
}
func (v *EmptyVisitor) VisitNumMinusExpr(e NumMinusExpr) {
emptyNumOp(v, e.Left, e.Right)
}
/*END NumExprVisitor methods*/
/*StreamExprVisitor methods*/
func (v *EmptyVisitor) VisitStreamFetchExpr(s StreamFetchExpr) {
}
/*END StreamExprVisitor methods*/
/*StrExprVisitor methods: strings*/
func (v *EmptyVisitor) VisitStringLiteralExpr(s StringLiteralExpr) {
}
func (v *EmptyVisitor) VisitStrConcatExpr(s StrConcatExpr) {
emptyStrOp(v, s.Left, s.Right)
}
func (v *EmptyVisitor) VisitStrEqExpr(s StrEqExpr) {
emptyStrOp(v, s.Left, s.Right)
}
/*END StrExprVisitor methods*/
/*Not exported functions*/
func emptyNumOp(v *EmptyVisitor, left NumExpr, right NumExpr) {
left.AcceptNum(v) //will treat the left expression
right.AcceptNum(v) //will treat the right expression
}
func emptyBoolOp(v *EmptyVisitor, left BoolExpr, right BoolExpr) {
left.AcceptBool(v) //will treat the left expression
right.AcceptBool(v) //will treat the right expression
}
func emptyIf(v *EmptyVisitor, ite IfThenElseExpr) {
ite.If.Accept(v) //will treat the left expression
ite.Then.Accept(v) //will treat the right expression
ite.Else.Accept(v) //will treat the right expression
}
func emptyLet(v *EmptyVisitor, l LetExpr) {
l.Bind.Accept(v) //will treat the right expression
l.Body.Accept(v) //will treat the right expression
}
func emptyStrOp(v *EmptyVisitor, left StrExpr, right StrExpr) {
left.AcceptStr(v) //will treat the right expression
right.AcceptStr(v) //will treat the right expression
}
/*END Not exported functions*/