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.chr.CHRRuleset;
6 import org.simantics.scl.compiler.elaboration.equation.EqBasic;
7 import org.simantics.scl.compiler.elaboration.equation.EqGuard;
8 import org.simantics.scl.compiler.elaboration.equation.Equation;
9 import org.simantics.scl.compiler.elaboration.equation.EquationVisitor;
10 import org.simantics.scl.compiler.elaboration.expressions.ERuleset.DatalogRule;
11 import org.simantics.scl.compiler.elaboration.expressions.accessor.ExpressionAccessor;
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.block.BindStatement;
16 import org.simantics.scl.compiler.elaboration.expressions.block.GuardStatement;
17 import org.simantics.scl.compiler.elaboration.expressions.block.IncludeStatement;
18 import org.simantics.scl.compiler.elaboration.expressions.block.LetStatement;
19 import org.simantics.scl.compiler.elaboration.expressions.block.RuleStatement;
20 import org.simantics.scl.compiler.elaboration.expressions.block.Statement;
21 import org.simantics.scl.compiler.elaboration.expressions.block.StatementVisitor;
22 import org.simantics.scl.compiler.elaboration.expressions.list.ListAssignment;
23 import org.simantics.scl.compiler.elaboration.expressions.list.ListGenerator;
24 import org.simantics.scl.compiler.elaboration.expressions.list.ListGuard;
25 import org.simantics.scl.compiler.elaboration.expressions.list.ListQualifierVisitor;
26 import org.simantics.scl.compiler.elaboration.expressions.list.ListSeq;
27 import org.simantics.scl.compiler.elaboration.expressions.list.ListThen;
28 import org.simantics.scl.compiler.elaboration.expressions.records.FieldAssignment;
29 import org.simantics.scl.compiler.elaboration.query.QAlternative;
30 import org.simantics.scl.compiler.elaboration.query.QAtom;
31 import org.simantics.scl.compiler.elaboration.query.QConjunction;
32 import org.simantics.scl.compiler.elaboration.query.QDisjunction;
33 import org.simantics.scl.compiler.elaboration.query.QExists;
34 import org.simantics.scl.compiler.elaboration.query.QIf;
35 import org.simantics.scl.compiler.elaboration.query.QMapping;
36 import org.simantics.scl.compiler.elaboration.query.QNegation;
37 import org.simantics.scl.compiler.elaboration.query.Query;
38 import org.simantics.scl.compiler.elaboration.query.QueryVisitor;
41 public class StandardExpressionVisitor implements
42 ExpressionVisitor, QueryVisitor, FieldAccessorVisitor, ListQualifierVisitor,
43 EquationVisitor, StatementVisitor {
46 public void visit(EApply expression) {
47 expression.function.accept(this);
48 for(Expression parameter : expression.parameters)
49 parameter.accept(this);
53 public void visit(EApplyType expression) {
54 expression.expression.accept(this);
58 public void visit(EAsPattern expression) {
59 expression.pattern.accept(this);
63 public void visit(EBind expression) {
64 expression.pattern.accept(this);
65 expression.value.accept(this);
66 expression.in.accept(this);
70 public void visit(EConstant expression) {
74 public void visit(EEnforce expression) {
75 expression.query.accept(this);
79 public void visit(EError expression) {
83 public void visit(EExternalConstant expression) {
87 public void visit(EFieldAccess expression) {
88 expression.parent.accept(this);
89 expression.accessor.accept(this);
93 public void visit(EGetConstraint expression) {
94 if(expression.evidence != null)
95 expression.evidence.accept(this);
99 public void visit(EIf expression) {
100 expression.condition.accept(this);
101 expression.then_.accept(this);
102 if(expression.else_ != null)
103 expression.else_.accept(this);
107 public void visit(EIntegerLiteral expression) {
108 if(expression.constraint != null)
109 expression.constraint.accept(this);
113 public void visit(ELambda expression) {
114 for(Case case_ : expression.cases)
119 public void visit(EViewPattern expression) {
120 expression.expression.accept(this);
121 expression.pattern.accept(this);
124 public void visit(Case case_) {
125 for(Expression pattern : case_.patterns)
126 pattern.accept(this);
127 case_.value.accept(this);
131 public void visit(ELambdaType expression) {
132 expression.value.accept(this);
136 public void visit(ELet expression) {
137 for(Assignment assignment : expression.assignments)
141 public void visit(Assignment assignment) {
142 assignment.pattern.accept(this);
143 assignment.value.accept(this);
147 public void visit(EListComprehension expression) {
148 expression.head.accept(this);
149 expression.qualifier.accept(this);
153 public void visit(EListLiteral expression) {
154 for(Expression component : expression.components)
155 component.accept(this);
159 public void visit(ELiteral expression) {
163 public void visit(EMatch expression) {
164 for(Expression s : expression.scrutinee)
166 for(Case case_ : expression.cases)
171 public void visit(EPlaceholder expression) {
172 expression.expression.accept(this);
176 public void visit(ERealLiteral expression) {
177 if(expression.constraint != null)
178 expression.constraint.accept(this);
182 public void visit(ERuleset expression) {
183 for(DatalogRule rule : expression.rules)
185 expression.in.accept(this);
188 public void visit(DatalogRule rule) {
189 for(Expression parameter : rule.headParameters)
190 parameter.accept(this);
191 rule.body.accept(this);
195 public void visit(ESelect expression) {
196 expression.query.accept(this);
197 expression.expression.accept(this);
201 public void visit(ESimpleLambda expression) {
202 expression.value.accept(this);
206 public void visit(ESimpleLet expression) {
207 expression.value.accept(this);
208 expression.in.accept(this);
212 public void visit(ETransformation expression) {
213 expression.seed.accept(this);
217 public void visit(ETypeAnnotation expression) {
218 expression.value.accept(this);
222 public void visit(EVar expression) {
226 public void visit(EVariable expression) {
230 public void visit(EWhen expression) {
231 expression.query.accept(this);
232 expression.action.accept(this);
236 public void visit(GuardedExpressionGroup expression) {
237 for(GuardedExpression gexp : expression.expressions) {
238 for(Expression guard : gexp.guards)
240 gexp.value.accept(this);
245 public void visit(QAlternative query) {
246 for(Query q : query.queries)
251 public void visit(QAtom query) {
252 for(Expression parameter : query.parameters)
253 parameter.accept(this);
257 public void visit(QMapping query) {
258 for(Expression parameter : query.parameters)
259 parameter.accept(this);
263 public void visit(QConjunction query) {
264 for(Query q : query.queries)
269 public void visit(QDisjunction query) {
270 for(Query q : query.queries)
275 public void visit(QExists query) {
276 query.query.accept(this);
280 public void visit(QNegation query) {
281 query.query.accept(this);
285 public void visit(ExpressionAccessor accessor) {
286 accessor.fieldName.accept(this);
290 public void visit(IdAccessor accessor) {
294 public void visit(StringAccessor accessor) {
298 public void visit(ListAssignment qualifier) {
299 qualifier.pattern.accept(this);
300 qualifier.value.accept(this);
304 public void visit(ListGenerator qualifier) {
305 qualifier.pattern.accept(this);
306 qualifier.value.accept(this);
310 public void visit(ListGuard qualifier) {
311 qualifier.condition.accept(this);
315 public void visit(ListSeq qualifier) {
316 qualifier.a.accept(this);
317 qualifier.b.accept(this);
321 public void visit(ListThen qualifier) {
322 qualifier.left.accept(this);
323 qualifier.transformer.accept(this);
324 if(qualifier.by != null)
325 qualifier.by.accept(this);
329 public void visit(QIf query) {
330 query.condition.accept(this);
331 query.thenQuery.accept(this);
332 query.elseQuery.accept(this);
336 public void visit(ECoveringBranchPoint expression) {
337 expression.expression.accept(this);
341 public void visit(EqBasic equation) {
342 equation.left.accept(this);
343 equation.right.accept(this);
347 public void visit(EqGuard equation) {
348 equation.guard.accept(this);
352 public void visit(EEquations expression) {
353 for(Equation equation : expression.equations)
354 equation.accept(this);
357 public void visit(CHRRuleset ruleset) {
358 for(CHRRule rule : ruleset.rules) {
359 for(CHRLiteral literal : rule.head.literals)
360 for(Expression parameter : literal.parameters)
361 parameter.accept(this);
362 for(CHRLiteral literal : rule.body.literals)
363 for(Expression parameter : literal.parameters)
364 parameter.accept(this);
369 public void visit(ECHRRuleset expression) {
370 visit(expression.ruleset);
371 expression.in.accept(this);
375 public void visit(ECHRRulesetConstructor expression) {
376 visit(expression.ruleset);
380 public void visit(EBinary expression) {
381 expression.left.accept(this);
382 for(EBinaryRightSide right : expression.rights)
383 right.right.accept(this);
387 public void visit(EBlock expression) {
388 for(Statement stat : expression.statements)
393 public void visit(EPreLet expression) {
394 for(LetStatement stat : expression.assignments) {
395 stat.pattern.accept(this);
396 stat.value.accept(this);
398 expression.in.accept(this);
402 public void visit(ERange expression) {
403 expression.from.accept(this);
404 expression.to.accept(this);
408 public void visit(ERecord expression) {
409 for(FieldAssignment assignment : expression.fields)
410 assignment.value.accept(this);
415 public void visit(EStringLiteral expression) {
416 for(Expression exp : expression.expressions)
421 public void visit(BindStatement statement) {
422 statement.pattern.accept(this);
423 statement.value.accept(this);
427 public void visit(GuardStatement statement) {
428 statement.value.accept(this);
432 public void visit(LetStatement statement) {
433 statement.value.accept(this);
437 public void visit(RuleStatement statement) {
438 statement.head.accept(this);
439 statement.body.accept(this);
443 public void visit(IncludeStatement statement) {
444 statement.value.accept(this);