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.FieldAccessorVisitor;
12 import org.simantics.scl.compiler.elaboration.expressions.accessor.IdAccessor;
13 import org.simantics.scl.compiler.elaboration.expressions.accessor.StringAccessor;
14 import org.simantics.scl.compiler.elaboration.expressions.block.BindStatement;
15 import org.simantics.scl.compiler.elaboration.expressions.block.GuardStatement;
16 import org.simantics.scl.compiler.elaboration.expressions.block.LetStatement;
17 import org.simantics.scl.compiler.elaboration.expressions.block.RuleStatement;
18 import org.simantics.scl.compiler.elaboration.expressions.block.Statement;
19 import org.simantics.scl.compiler.elaboration.expressions.block.StatementVisitor;
20 import org.simantics.scl.compiler.elaboration.expressions.list.ListAssignment;
21 import org.simantics.scl.compiler.elaboration.expressions.list.ListGenerator;
22 import org.simantics.scl.compiler.elaboration.expressions.list.ListGuard;
23 import org.simantics.scl.compiler.elaboration.expressions.list.ListQualifierVisitor;
24 import org.simantics.scl.compiler.elaboration.expressions.list.ListSeq;
25 import org.simantics.scl.compiler.elaboration.expressions.list.ListThen;
26 import org.simantics.scl.compiler.elaboration.expressions.records.FieldAssignment;
27 import org.simantics.scl.compiler.elaboration.query.QAlternative;
28 import org.simantics.scl.compiler.elaboration.query.QAtom;
29 import org.simantics.scl.compiler.elaboration.query.QConjunction;
30 import org.simantics.scl.compiler.elaboration.query.QDisjunction;
31 import org.simantics.scl.compiler.elaboration.query.QExists;
32 import org.simantics.scl.compiler.elaboration.query.QIf;
33 import org.simantics.scl.compiler.elaboration.query.QMapping;
34 import org.simantics.scl.compiler.elaboration.query.QNegation;
35 import org.simantics.scl.compiler.elaboration.query.Query;
36 import org.simantics.scl.compiler.elaboration.query.QueryVisitor;
39 public class StandardExpressionVisitor implements
40 ExpressionVisitor, QueryVisitor, FieldAccessorVisitor, ListQualifierVisitor,
41 EquationVisitor, StatementVisitor {
44 public void visit(EApply expression) {
45 expression.function.accept(this);
46 for(Expression parameter : expression.parameters)
47 parameter.accept(this);
51 public void visit(EApplyType expression) {
52 expression.expression.accept(this);
56 public void visit(EAsPattern expression) {
57 expression.pattern.accept(this);
61 public void visit(EBind expression) {
62 expression.pattern.accept(this);
63 expression.value.accept(this);
64 expression.in.accept(this);
68 public void visit(EConstant expression) {
72 public void visit(EEnforce expression) {
73 expression.query.accept(this);
77 public void visit(EError expression) {
81 public void visit(EExternalConstant expression) {
85 public void visit(EFieldAccess expression) {
86 expression.parent.accept(this);
87 expression.accessor.accept(this);
91 public void visit(EGetConstraint expression) {
92 if(expression.evidence != null)
93 expression.evidence.accept(this);
97 public void visit(EIf expression) {
98 expression.condition.accept(this);
99 expression.then_.accept(this);
100 if(expression.else_ != null)
101 expression.else_.accept(this);
105 public void visit(EIntegerLiteral expression) {
106 if(expression.constraint != null)
107 expression.constraint.accept(this);
111 public void visit(ELambda expression) {
112 for(Case case_ : expression.cases)
117 public void visit(EViewPattern expression) {
118 expression.expression.accept(this);
119 expression.pattern.accept(this);
122 public void visit(Case case_) {
123 for(Expression pattern : case_.patterns)
124 pattern.accept(this);
125 case_.value.accept(this);
129 public void visit(ELambdaType expression) {
130 expression.value.accept(this);
134 public void visit(ELet expression) {
135 for(Assignment assignment : expression.assignments)
139 public void visit(Assignment assignment) {
140 assignment.pattern.accept(this);
141 assignment.value.accept(this);
145 public void visit(EListComprehension expression) {
146 expression.head.accept(this);
147 expression.qualifier.accept(this);
151 public void visit(EListLiteral expression) {
152 for(Expression component : expression.components)
153 component.accept(this);
157 public void visit(ELiteral expression) {
161 public void visit(EMatch expression) {
162 for(Expression s : expression.scrutinee)
164 for(Case case_ : expression.cases)
169 public void visit(EPlaceholder expression) {
170 expression.expression.accept(this);
174 public void visit(ERealLiteral expression) {
175 if(expression.constraint != null)
176 expression.constraint.accept(this);
180 public void visit(ERuleset expression) {
181 for(DatalogRule rule : expression.rules)
183 expression.in.accept(this);
186 public void visit(DatalogRule rule) {
187 for(Expression parameter : rule.headParameters)
188 parameter.accept(this);
189 rule.body.accept(this);
193 public void visit(ESelect expression) {
194 expression.query.accept(this);
195 expression.expression.accept(this);
199 public void visit(ESimpleLambda expression) {
200 expression.value.accept(this);
204 public void visit(ESimpleLet expression) {
205 expression.value.accept(this);
206 expression.in.accept(this);
210 public void visit(ETransformation expression) {
211 expression.seed.accept(this);
215 public void visit(ETypeAnnotation expression) {
216 expression.value.accept(this);
220 public void visit(EVar expression) {
224 public void visit(EVariable expression) {
228 public void visit(EWhen expression) {
229 expression.query.accept(this);
230 expression.action.accept(this);
234 public void visit(GuardedExpressionGroup expression) {
235 for(GuardedExpression gexp : expression.expressions) {
236 for(Expression guard : gexp.guards)
238 gexp.value.accept(this);
243 public void visit(QAlternative query) {
244 for(Query q : query.queries)
249 public void visit(QAtom query) {
250 for(Expression parameter : query.parameters)
251 parameter.accept(this);
255 public void visit(QMapping query) {
256 for(Expression parameter : query.parameters)
257 parameter.accept(this);
261 public void visit(QConjunction query) {
262 for(Query q : query.queries)
267 public void visit(QDisjunction query) {
268 for(Query q : query.queries)
273 public void visit(QExists query) {
274 query.query.accept(this);
278 public void visit(QNegation query) {
279 query.query.accept(this);
283 public void visit(ExpressionAccessor accessor) {
284 accessor.fieldName.accept(this);
288 public void visit(IdAccessor accessor) {
292 public void visit(StringAccessor accessor) {
296 public void visit(ListAssignment qualifier) {
297 qualifier.pattern.accept(this);
298 qualifier.value.accept(this);
302 public void visit(ListGenerator qualifier) {
303 qualifier.pattern.accept(this);
304 qualifier.value.accept(this);
308 public void visit(ListGuard qualifier) {
309 qualifier.condition.accept(this);
313 public void visit(ListSeq qualifier) {
314 qualifier.a.accept(this);
315 qualifier.b.accept(this);
319 public void visit(ListThen qualifier) {
320 qualifier.left.accept(this);
321 qualifier.transformer.accept(this);
322 if(qualifier.by != null)
323 qualifier.by.accept(this);
327 public void visit(QIf query) {
328 query.condition.accept(this);
329 query.thenQuery.accept(this);
330 query.elseQuery.accept(this);
334 public void visit(ECoveringBranchPoint expression) {
335 expression.expression.accept(this);
339 public void visit(EqBasic equation) {
340 equation.left.accept(this);
341 equation.right.accept(this);
345 public void visit(EqGuard equation) {
346 equation.guard.accept(this);
350 public void visit(EEquations expression) {
351 for(Equation equation : expression.equations)
352 equation.accept(this);
356 public void visit(ECHRRuleset ruleset) {
357 for(CHRRule rule : ruleset.ruleset.rules) {
358 for(CHRLiteral literal : rule.head.literals)
359 for(Expression parameter : literal.parameters)
360 parameter.accept(this);
361 for(CHRLiteral literal : rule.body.literals)
362 for(Expression parameter : literal.parameters)
363 parameter.accept(this);
365 ruleset.in.accept(this);
369 public void visit(EBinary expression) {
370 expression.left.accept(this);
371 for(EBinaryRightSide right : expression.rights)
372 right.right.accept(this);
376 public void visit(EBlock expression) {
377 for(Statement stat : expression.statements)
382 public void visit(EPreLet expression) {
383 for(LetStatement stat : expression.assignments) {
384 stat.pattern.accept(this);
385 stat.value.accept(this);
387 expression.in.accept(this);
391 public void visit(ERange expression) {
392 expression.from.accept(this);
393 expression.to.accept(this);
397 public void visit(ERecord expression) {
398 for(FieldAssignment assignment : expression.fields)
399 assignment.value.accept(this);
404 public void visit(EStringLiteral expression) {
405 for(Expression exp : expression.expressions)
410 public void visit(BindStatement statement) {
411 statement.pattern.accept(this);
412 statement.value.accept(this);
416 public void visit(GuardStatement statement) {
417 statement.value.accept(this);
421 public void visit(LetStatement statement) {
422 statement.value.accept(this);
426 public void visit(RuleStatement statement) {
427 statement.head.accept(this);
428 statement.body.accept(this);