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.block.BindStatement;
16 import org.simantics.scl.compiler.elaboration.expressions.block.GuardStatement;
17 import org.simantics.scl.compiler.elaboration.expressions.block.LetStatement;
18 import org.simantics.scl.compiler.elaboration.expressions.block.RuleStatement;
19 import org.simantics.scl.compiler.elaboration.expressions.block.Statement;
20 import org.simantics.scl.compiler.elaboration.expressions.block.StatementVisitor;
21 import org.simantics.scl.compiler.elaboration.expressions.list.ListAssignment;
22 import org.simantics.scl.compiler.elaboration.expressions.list.ListGenerator;
23 import org.simantics.scl.compiler.elaboration.expressions.list.ListGuard;
24 import org.simantics.scl.compiler.elaboration.expressions.list.ListQualifierVisitor;
25 import org.simantics.scl.compiler.elaboration.expressions.list.ListSeq;
26 import org.simantics.scl.compiler.elaboration.expressions.list.ListThen;
27 import org.simantics.scl.compiler.elaboration.expressions.records.FieldAssignment;
28 import org.simantics.scl.compiler.elaboration.query.QAlternative;
29 import org.simantics.scl.compiler.elaboration.query.QAtom;
30 import org.simantics.scl.compiler.elaboration.query.QConjunction;
31 import org.simantics.scl.compiler.elaboration.query.QDisjunction;
32 import org.simantics.scl.compiler.elaboration.query.QExists;
33 import org.simantics.scl.compiler.elaboration.query.QIf;
34 import org.simantics.scl.compiler.elaboration.query.QMapping;
35 import org.simantics.scl.compiler.elaboration.query.QNegation;
36 import org.simantics.scl.compiler.elaboration.query.Query;
37 import org.simantics.scl.compiler.elaboration.query.QueryVisitor;
40 public class StandardExpressionVisitor implements
41 ExpressionVisitor, QueryVisitor, FieldAccessorVisitor, ListQualifierVisitor,
42 EquationVisitor, StatementVisitor {
45 public void visit(EApply expression) {
46 expression.function.accept(this);
47 for(Expression parameter : expression.parameters)
48 parameter.accept(this);
52 public void visit(EApplyType expression) {
53 expression.expression.accept(this);
57 public void visit(EAsPattern expression) {
58 expression.pattern.accept(this);
62 public void visit(EBind expression) {
63 expression.pattern.accept(this);
64 expression.value.accept(this);
65 expression.in.accept(this);
69 public void visit(EConstant expression) {
73 public void visit(EEnforce expression) {
74 expression.query.accept(this);
78 public void visit(EError expression) {
82 public void visit(EExternalConstant expression) {
86 public void visit(EFieldAccess expression) {
87 expression.parent.accept(this);
88 for(FieldAccessor accessor : expression.accessors)
89 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);
358 public void visit(ECHRRuleset ruleset) {
359 for(CHRRule rule : ruleset.ruleset.rules) {
360 for(CHRLiteral literal : rule.head.literals)
361 for(Expression parameter : literal.parameters)
362 parameter.accept(this);
363 for(CHRLiteral literal : rule.body.literals)
364 for(Expression parameter : literal.parameters)
365 parameter.accept(this);
367 ruleset.in.accept(this);
371 public void visit(EBinary expression) {
372 expression.left.accept(this);
373 for(EBinaryRightSide right : expression.rights)
374 right.right.accept(this);
378 public void visit(EBlock expression) {
379 for(Statement stat : expression.statements)
384 public void visit(EPreLet expression) {
385 for(LetStatement stat : expression.assignments) {
386 stat.pattern.accept(this);
387 stat.value.accept(this);
389 expression.in.accept(this);
393 public void visit(ERange expression) {
394 expression.from.accept(this);
395 expression.to.accept(this);
399 public void visit(ERecord expression) {
400 for(FieldAssignment assignment : expression.fields)
401 assignment.value.accept(this);
406 public void visit(EStringLiteral expression) {
407 for(Expression exp : expression.expressions)
412 public void visit(BindStatement statement) {
413 statement.pattern.accept(this);
414 statement.value.accept(this);
418 public void visit(GuardStatement statement) {
419 statement.value.accept(this);
423 public void visit(LetStatement statement) {
424 statement.value.accept(this);
428 public void visit(RuleStatement statement) {
429 statement.head.accept(this);
430 statement.body.accept(this);