1 package org.simantics.scl.compiler.elaboration.expressions;
3 import org.simantics.scl.compiler.elaboration.chr.CHRLiteral;
4 import org.simantics.scl.compiler.elaboration.chr.CHRRule;
5 import org.simantics.scl.compiler.elaboration.equation.EqBasic;
6 import org.simantics.scl.compiler.elaboration.equation.EqGuard;
7 import org.simantics.scl.compiler.elaboration.equation.Equation;
8 import org.simantics.scl.compiler.elaboration.equation.EquationVisitor;
9 import org.simantics.scl.compiler.elaboration.expressions.ERuleset.DatalogRule;
10 import org.simantics.scl.compiler.elaboration.expressions.accessor.ExpressionAccessor;
11 import org.simantics.scl.compiler.elaboration.expressions.accessor.FieldAccessor;
12 import org.simantics.scl.compiler.elaboration.expressions.accessor.FieldAccessorVisitor;
13 import org.simantics.scl.compiler.elaboration.expressions.accessor.IdAccessor;
14 import org.simantics.scl.compiler.elaboration.expressions.accessor.StringAccessor;
15 import org.simantics.scl.compiler.elaboration.expressions.list.ListAssignment;
16 import org.simantics.scl.compiler.elaboration.expressions.list.ListGenerator;
17 import org.simantics.scl.compiler.elaboration.expressions.list.ListGuard;
18 import org.simantics.scl.compiler.elaboration.expressions.list.ListQualifierVisitor;
19 import org.simantics.scl.compiler.elaboration.expressions.list.ListSeq;
20 import org.simantics.scl.compiler.elaboration.expressions.list.ListThen;
21 import org.simantics.scl.compiler.elaboration.query.QAlternative;
22 import org.simantics.scl.compiler.elaboration.query.QAtom;
23 import org.simantics.scl.compiler.elaboration.query.QConjunction;
24 import org.simantics.scl.compiler.elaboration.query.QDisjunction;
25 import org.simantics.scl.compiler.elaboration.query.QExists;
26 import org.simantics.scl.compiler.elaboration.query.QIf;
27 import org.simantics.scl.compiler.elaboration.query.QMapping;
28 import org.simantics.scl.compiler.elaboration.query.QNegation;
29 import org.simantics.scl.compiler.elaboration.query.Query;
30 import org.simantics.scl.compiler.elaboration.query.QueryVisitor;
33 public class StandardExpressionVisitor implements
34 ExpressionVisitor, QueryVisitor, FieldAccessorVisitor, ListQualifierVisitor,
38 public void visit(EApply expression) {
39 expression.function.accept(this);
40 for(Expression parameter : expression.parameters)
41 parameter.accept(this);
45 public void visit(EApplyType expression) {
46 expression.expression.accept(this);
50 public void visit(EAsPattern expression) {
51 expression.pattern.accept(this);
55 public void visit(EBind expression) {
56 expression.pattern.accept(this);
57 expression.value.accept(this);
58 expression.in.accept(this);
62 public void visit(EConstant expression) {
66 public void visit(EEnforce expression) {
67 expression.query.accept(this);
71 public void visit(EError expression) {
75 public void visit(EExternalConstant expression) {
79 public void visit(EFieldAccess expression) {
80 expression.parent.accept(this);
81 for(FieldAccessor accessor : expression.accessors)
82 accessor.accept(this);
86 public void visit(EGetConstraint expression) {
87 if(expression.evidence != null)
88 expression.evidence.accept(this);
92 public void visit(EIf expression) {
93 expression.condition.accept(this);
94 expression.then_.accept(this);
95 if(expression.else_ != null)
96 expression.else_.accept(this);
100 public void visit(EIntegerLiteral expression) {
101 if(expression.constraint != null)
102 expression.constraint.accept(this);
106 public void visit(ELambda expression) {
107 for(Case case_ : expression.cases)
112 public void visit(EViewPattern expression) {
113 expression.expression.accept(this);
114 expression.pattern.accept(this);
117 public void visit(Case case_) {
118 for(Expression pattern : case_.patterns)
119 pattern.accept(this);
120 case_.value.accept(this);
124 public void visit(ELambdaType expression) {
125 expression.value.accept(this);
129 public void visit(ELet expression) {
130 for(Assignment assignment : expression.assignments)
134 public void visit(Assignment assignment) {
135 assignment.pattern.accept(this);
136 assignment.value.accept(this);
140 public void visit(EListComprehension expression) {
141 expression.head.accept(this);
142 expression.qualifier.accept(this);
146 public void visit(EListLiteral expression) {
147 for(Expression component : expression.components)
148 component.accept(this);
152 public void visit(ELiteral expression) {
156 public void visit(EMatch expression) {
157 for(Expression s : expression.scrutinee)
159 for(Case case_ : expression.cases)
164 public void visit(EPlaceholder expression) {
165 expression.expression.accept(this);
169 public void visit(ERealLiteral expression) {
170 if(expression.constraint != null)
171 expression.constraint.accept(this);
175 public void visit(ERuleset expression) {
176 for(DatalogRule rule : expression.rules)
178 expression.in.accept(this);
181 public void visit(DatalogRule rule) {
182 for(Expression parameter : rule.headParameters)
183 parameter.accept(this);
184 rule.body.accept(this);
188 public void visit(ESelect expression) {
189 expression.query.accept(this);
190 expression.expression.accept(this);
194 public void visit(ESimpleLambda expression) {
195 expression.value.accept(this);
199 public void visit(ESimpleLet expression) {
200 expression.value.accept(this);
201 expression.in.accept(this);
205 public void visit(ETransformation expression) {
206 expression.seed.accept(this);
210 public void visit(ETypeAnnotation expression) {
211 expression.value.accept(this);
215 public void visit(EVariable expression) {
219 public void visit(EWhen expression) {
220 expression.query.accept(this);
221 expression.action.accept(this);
225 public void visit(GuardedExpressionGroup expression) {
226 for(GuardedExpression gexp : expression.expressions) {
227 for(Expression guard : gexp.guards)
229 gexp.value.accept(this);
234 public void visit(QAlternative query) {
235 for(Query q : query.queries)
240 public void visit(QAtom query) {
241 for(Expression parameter : query.parameters)
242 parameter.accept(this);
246 public void visit(QMapping query) {
247 for(Expression parameter : query.parameters)
248 parameter.accept(this);
252 public void visit(QConjunction query) {
253 for(Query q : query.queries)
258 public void visit(QDisjunction query) {
259 for(Query q : query.queries)
264 public void visit(QExists query) {
265 query.query.accept(this);
269 public void visit(QNegation query) {
270 query.query.accept(this);
274 public void visit(ExpressionAccessor accessor) {
275 accessor.fieldName.accept(this);
279 public void visit(IdAccessor accessor) {
283 public void visit(StringAccessor accessor) {
287 public void visit(ListAssignment qualifier) {
288 qualifier.pattern.accept(this);
289 qualifier.value.accept(this);
293 public void visit(ListGenerator qualifier) {
294 qualifier.pattern.accept(this);
295 qualifier.value.accept(this);
299 public void visit(ListGuard qualifier) {
300 qualifier.condition.accept(this);
304 public void visit(ListSeq qualifier) {
305 qualifier.a.accept(this);
306 qualifier.b.accept(this);
310 public void visit(ListThen qualifier) {
311 qualifier.left.accept(this);
312 qualifier.transformer.accept(this);
313 if(qualifier.by != null)
314 qualifier.by.accept(this);
318 public void visit(QIf query) {
319 query.condition.accept(this);
320 query.thenQuery.accept(this);
321 query.elseQuery.accept(this);
325 public void visit(ECoveringBranchPoint expression) {
326 expression.expression.accept(this);
330 public void visit(EqBasic equation) {
331 equation.left.accept(this);
332 equation.right.accept(this);
336 public void visit(EqGuard equation) {
337 equation.guard.accept(this);
341 public void visit(EEquations expression) {
342 for(Equation equation : expression.equations)
343 equation.accept(this);
347 public void visit(ECHRRuleset ruleset) {
348 for(CHRRule rule : ruleset.ruleset.rules) {
349 for(CHRLiteral literal : rule.head.literals)
350 for(Expression parameter : literal.parameters)
351 parameter.accept(this);
352 for(CHRLiteral literal : rule.body.literals)
353 for(Expression parameter : literal.parameters)
354 parameter.accept(this);
356 ruleset.in.accept(this);