1 package org.simantics.scl.compiler.elaboration.expressions;
\r
3 import org.simantics.scl.compiler.elaboration.equation.EqBasic;
\r
4 import org.simantics.scl.compiler.elaboration.equation.EqGuard;
\r
5 import org.simantics.scl.compiler.elaboration.equation.Equation;
\r
6 import org.simantics.scl.compiler.elaboration.equation.EquationVisitor;
\r
7 import org.simantics.scl.compiler.elaboration.expressions.ERuleset.DatalogRule;
\r
8 import org.simantics.scl.compiler.elaboration.expressions.accessor.ExpressionAccessor;
\r
9 import org.simantics.scl.compiler.elaboration.expressions.accessor.FieldAccessor;
\r
10 import org.simantics.scl.compiler.elaboration.expressions.accessor.FieldAccessorVisitor;
\r
11 import org.simantics.scl.compiler.elaboration.expressions.accessor.IdAccessor;
\r
12 import org.simantics.scl.compiler.elaboration.expressions.accessor.StringAccessor;
\r
13 import org.simantics.scl.compiler.elaboration.expressions.list.ListAssignment;
\r
14 import org.simantics.scl.compiler.elaboration.expressions.list.ListGenerator;
\r
15 import org.simantics.scl.compiler.elaboration.expressions.list.ListGuard;
\r
16 import org.simantics.scl.compiler.elaboration.expressions.list.ListQualifierVisitor;
\r
17 import org.simantics.scl.compiler.elaboration.expressions.list.ListSeq;
\r
18 import org.simantics.scl.compiler.elaboration.expressions.list.ListThen;
\r
19 import org.simantics.scl.compiler.elaboration.query.QAlternative;
\r
20 import org.simantics.scl.compiler.elaboration.query.QAtom;
\r
21 import org.simantics.scl.compiler.elaboration.query.QConjunction;
\r
22 import org.simantics.scl.compiler.elaboration.query.QDisjunction;
\r
23 import org.simantics.scl.compiler.elaboration.query.QExists;
\r
24 import org.simantics.scl.compiler.elaboration.query.QIf;
\r
25 import org.simantics.scl.compiler.elaboration.query.QMapping;
\r
26 import org.simantics.scl.compiler.elaboration.query.QNegation;
\r
27 import org.simantics.scl.compiler.elaboration.query.Query;
\r
28 import org.simantics.scl.compiler.elaboration.query.QueryVisitor;
\r
31 public class StandardExpressionVisitor implements
\r
32 ExpressionVisitor, QueryVisitor, FieldAccessorVisitor, ListQualifierVisitor,
\r
36 public void visit(EApply expression) {
\r
37 expression.function.accept(this);
\r
38 for(Expression parameter : expression.parameters)
\r
39 parameter.accept(this);
\r
43 public void visit(EApplyType expression) {
\r
44 expression.expression.accept(this);
\r
48 public void visit(EAsPattern expression) {
\r
49 expression.pattern.accept(this);
\r
53 public void visit(EBind expression) {
\r
54 expression.pattern.accept(this);
\r
55 expression.value.accept(this);
\r
56 expression.in.accept(this);
\r
60 public void visit(EConstant expression) {
\r
64 public void visit(EEnforce expression) {
\r
65 expression.query.accept(this);
\r
69 public void visit(EError expression) {
\r
73 public void visit(EExternalConstant expression) {
\r
77 public void visit(EFieldAccess expression) {
\r
78 expression.parent.accept(this);
\r
79 for(FieldAccessor accessor : expression.accessors)
\r
80 accessor.accept(this);
\r
84 public void visit(EGetConstraint expression) {
\r
85 if(expression.evidence != null)
\r
86 expression.evidence.accept(this);
\r
90 public void visit(EIf expression) {
\r
91 expression.condition.accept(this);
\r
92 expression.then_.accept(this);
\r
93 expression.else_.accept(this);
\r
97 public void visit(EIntegerLiteral expression) {
\r
98 if(expression.constraint != null)
\r
99 expression.constraint.accept(this);
\r
103 public void visit(ELambda expression) {
\r
104 for(Case case_ : expression.cases)
\r
108 public void visit(Case case_) {
\r
109 for(Expression pattern : case_.patterns)
\r
110 pattern.accept(this);
\r
111 case_.value.accept(this);
\r
115 public void visit(ELambdaType expression) {
\r
116 expression.value.accept(this);
\r
120 public void visit(ELet expression) {
\r
121 for(Assignment assignment : expression.assignments)
\r
125 public void visit(Assignment assignment) {
\r
126 assignment.pattern.accept(this);
\r
127 assignment.value.accept(this);
\r
131 public void visit(EListComprehension expression) {
\r
132 expression.head.accept(this);
\r
133 expression.qualifier.accept(this);
\r
137 public void visit(EListLiteral expression) {
\r
138 for(Expression component : expression.components)
\r
139 component.accept(this);
\r
143 public void visit(ELiteral expression) {
\r
147 public void visit(EMatch expression) {
\r
148 for(Expression s : expression.scrutinee)
\r
150 for(Case case_ : expression.cases)
\r
155 public void visit(EPlaceholder expression) {
\r
156 expression.expression.accept(this);
\r
160 public void visit(ERealLiteral expression) {
\r
161 if(expression.constraint != null)
\r
162 expression.constraint.accept(this);
\r
166 public void visit(ERuleset expression) {
\r
167 for(DatalogRule rule : expression.rules)
\r
169 expression.in.accept(this);
\r
172 public void visit(DatalogRule rule) {
\r
173 for(Expression parameter : rule.headParameters)
\r
174 parameter.accept(this);
\r
175 rule.body.accept(this);
\r
179 public void visit(ESelect expression) {
\r
180 expression.query.accept(this);
\r
181 expression.expression.accept(this);
\r
185 public void visit(ESimpleLambda expression) {
\r
186 expression.value.accept(this);
\r
190 public void visit(ESimpleLet expression) {
\r
191 expression.value.accept(this);
\r
192 expression.in.accept(this);
\r
196 public void visit(ETransformation expression) {
\r
197 expression.seed.accept(this);
\r
201 public void visit(ETypeAnnotation expression) {
\r
202 expression.value.accept(this);
\r
206 public void visit(EVariable expression) {
\r
210 public void visit(EWhen expression) {
\r
211 expression.query.accept(this);
\r
212 expression.action.accept(this);
\r
216 public void visit(GuardedExpressionGroup expression) {
\r
217 for(GuardedExpression gexp : expression.expressions) {
\r
218 for(Expression guard : gexp.guards)
\r
219 guard.accept(this);
\r
220 gexp.value.accept(this);
\r
225 public void visit(QAlternative query) {
\r
226 for(Query q : query.queries)
\r
231 public void visit(QAtom query) {
\r
232 for(Expression parameter : query.parameters)
\r
233 parameter.accept(this);
\r
237 public void visit(QMapping query) {
\r
238 for(Expression parameter : query.parameters)
\r
239 parameter.accept(this);
\r
243 public void visit(QConjunction query) {
\r
244 for(Query q : query.queries)
\r
249 public void visit(QDisjunction query) {
\r
250 for(Query q : query.queries)
\r
255 public void visit(QExists query) {
\r
256 query.query.accept(this);
\r
260 public void visit(QNegation query) {
\r
261 query.query.accept(this);
\r
265 public void visit(ExpressionAccessor accessor) {
\r
266 accessor.fieldName.accept(this);
\r
270 public void visit(IdAccessor accessor) {
\r
274 public void visit(StringAccessor accessor) {
\r
278 public void visit(ListAssignment qualifier) {
\r
279 qualifier.pattern.accept(this);
\r
280 qualifier.value.accept(this);
\r
284 public void visit(ListGenerator qualifier) {
\r
285 qualifier.pattern.accept(this);
\r
286 qualifier.value.accept(this);
\r
290 public void visit(ListGuard qualifier) {
\r
291 qualifier.condition.accept(this);
\r
295 public void visit(ListSeq qualifier) {
\r
296 qualifier.a.accept(this);
\r
297 qualifier.b.accept(this);
\r
301 public void visit(ListThen qualifier) {
\r
302 qualifier.left.accept(this);
\r
303 qualifier.transformer.accept(this);
\r
304 if(qualifier.by != null)
\r
305 qualifier.by.accept(this);
\r
309 public void visit(QIf query) {
\r
310 query.condition.accept(this);
\r
311 query.thenQuery.accept(this);
\r
312 query.elseQuery.accept(this);
\r
316 public void visit(ECoveringBranchPoint expression) {
\r
317 expression.expression.accept(this);
\r
321 public void visit(EqBasic equation) {
\r
322 equation.left.accept(this);
\r
323 equation.right.accept(this);
\r
327 public void visit(EqGuard equation) {
\r
328 equation.guard.accept(this);
\r
332 public void visit(EEquations expression) {
\r
333 for(Equation equation : expression.equations)
\r
334 equation.accept(this);
\r