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.CHRQuery;
5 import org.simantics.scl.compiler.elaboration.chr.CHRRule;
6 import org.simantics.scl.compiler.elaboration.chr.CHRRuleset;
7 import org.simantics.scl.compiler.elaboration.equation.EqBasic;
8 import org.simantics.scl.compiler.elaboration.equation.EqGuard;
9 import org.simantics.scl.compiler.elaboration.equation.Equation;
10 import org.simantics.scl.compiler.elaboration.equation.EquationVisitor;
11 import org.simantics.scl.compiler.elaboration.expressions.ERuleset.DatalogRule;
12 import org.simantics.scl.compiler.elaboration.expressions.accessor.ExpressionAccessor;
13 import org.simantics.scl.compiler.elaboration.expressions.accessor.FieldAccessorVisitor;
14 import org.simantics.scl.compiler.elaboration.expressions.accessor.IdAccessor;
15 import org.simantics.scl.compiler.elaboration.expressions.accessor.StringAccessor;
16 import org.simantics.scl.compiler.elaboration.expressions.block.BindStatement;
17 import org.simantics.scl.compiler.elaboration.expressions.block.CHRStatement;
18 import org.simantics.scl.compiler.elaboration.expressions.block.GuardStatement;
19 import org.simantics.scl.compiler.elaboration.expressions.block.IncludeStatement;
20 import org.simantics.scl.compiler.elaboration.expressions.block.LetStatement;
21 import org.simantics.scl.compiler.elaboration.expressions.block.RuleStatement;
22 import org.simantics.scl.compiler.elaboration.expressions.block.Statement;
23 import org.simantics.scl.compiler.elaboration.expressions.block.StatementVisitor;
24 import org.simantics.scl.compiler.elaboration.expressions.list.ListAssignment;
25 import org.simantics.scl.compiler.elaboration.expressions.list.ListGenerator;
26 import org.simantics.scl.compiler.elaboration.expressions.list.ListGuard;
27 import org.simantics.scl.compiler.elaboration.expressions.list.ListQualifier;
28 import org.simantics.scl.compiler.elaboration.expressions.list.ListQualifierVisitor;
29 import org.simantics.scl.compiler.elaboration.expressions.list.ListSeq;
30 import org.simantics.scl.compiler.elaboration.expressions.list.ListThen;
31 import org.simantics.scl.compiler.elaboration.expressions.records.FieldAssignment;
32 import org.simantics.scl.compiler.elaboration.query.QAlternative;
33 import org.simantics.scl.compiler.elaboration.query.QAtom;
34 import org.simantics.scl.compiler.elaboration.query.QConjunction;
35 import org.simantics.scl.compiler.elaboration.query.QDisjunction;
36 import org.simantics.scl.compiler.elaboration.query.QExists;
37 import org.simantics.scl.compiler.elaboration.query.QIf;
38 import org.simantics.scl.compiler.elaboration.query.QMapping;
39 import org.simantics.scl.compiler.elaboration.query.QNegation;
40 import org.simantics.scl.compiler.elaboration.query.Query;
41 import org.simantics.scl.compiler.elaboration.query.QueryVisitor;
44 public class StandardExpressionVisitor implements
45 ExpressionVisitor, QueryVisitor, FieldAccessorVisitor, ListQualifierVisitor,
46 EquationVisitor, StatementVisitor {
49 public void visit(EApply expression) {
50 expression.function.accept(this);
51 for(Expression parameter : expression.parameters)
52 parameter.accept(this);
56 public void visit(EApplyType expression) {
57 expression.expression.accept(this);
61 public void visit(EAsPattern expression) {
62 expression.pattern.accept(this);
66 public void visit(EBind expression) {
67 expression.pattern.accept(this);
68 expression.value.accept(this);
69 expression.in.accept(this);
73 public void visit(EConstant expression) {
77 public void visit(EEnforce expression) {
78 expression.query.accept(this);
82 public void visit(EError expression) {
86 public void visit(EExternalConstant expression) {
90 public void visit(EFieldAccess expression) {
91 expression.parent.accept(this);
92 expression.accessor.accept(this);
96 public void visit(EGetConstraint expression) {
97 if(expression.evidence != null)
98 expression.evidence.accept(this);
102 public void visit(EIf expression) {
103 expression.condition.accept(this);
104 expression.then_.accept(this);
105 if(expression.else_ != null)
106 expression.else_.accept(this);
110 public void visit(EIntegerLiteral expression) {
111 if(expression.constraint != null)
112 expression.constraint.accept(this);
116 public void visit(ELambda expression) {
117 for(Case case_ : expression.cases)
122 public void visit(EViewPattern expression) {
123 expression.expression.accept(this);
124 expression.pattern.accept(this);
127 public void visit(Case case_) {
128 for(Expression pattern : case_.patterns)
129 pattern.accept(this);
130 case_.value.accept(this);
134 public void visit(ELambdaType expression) {
135 expression.value.accept(this);
139 public void visit(ELet expression) {
140 for(Assignment assignment : expression.assignments)
144 public void visit(Assignment assignment) {
145 assignment.pattern.accept(this);
146 assignment.value.accept(this);
150 public void visit(EListComprehension expression) {
151 expression.head.accept(this);
152 expression.qualifier.accept(this);
156 public void visit(EListLiteral expression) {
157 for(Expression component : expression.components)
158 component.accept(this);
162 public void visit(ELiteral expression) {
166 public void visit(EMatch expression) {
167 for(Expression s : expression.scrutinee)
169 for(Case case_ : expression.cases)
174 public void visit(EPlaceholder expression) {
175 expression.expression.accept(this);
179 public void visit(ERealLiteral expression) {
180 if(expression.constraint != null)
181 expression.constraint.accept(this);
185 public void visit(ERuleset expression) {
186 for(DatalogRule rule : expression.rules)
188 expression.in.accept(this);
191 public void visit(DatalogRule rule) {
192 for(Expression parameter : rule.headParameters)
193 parameter.accept(this);
194 rule.body.accept(this);
198 public void visit(ESelect expression) {
199 expression.query.accept(this);
200 expression.expression.accept(this);
204 public void visit(ECHRSelect expression) {
205 visit(expression.query);
206 expression.expression.accept(this);
210 public void visit(ESimpleLambda expression) {
211 expression.value.accept(this);
215 public void visit(ESimpleLet expression) {
216 expression.value.accept(this);
217 expression.in.accept(this);
221 public void visit(ETransformation expression) {
222 expression.seed.accept(this);
226 public void visit(ETypeAnnotation expression) {
227 expression.value.accept(this);
231 public void visit(EVar expression) {
235 public void visit(EVariable expression) {
239 public void visit(EWhen expression) {
240 expression.query.accept(this);
241 expression.action.accept(this);
245 public void visit(GuardedExpressionGroup expression) {
246 for(GuardedExpression gexp : expression.expressions) {
247 for(Expression guard : gexp.guards)
249 gexp.value.accept(this);
254 public void visit(QAlternative query) {
255 for(Query q : query.queries)
260 public void visit(QAtom query) {
261 for(Expression parameter : query.parameters)
262 parameter.accept(this);
266 public void visit(QMapping query) {
267 for(Expression parameter : query.parameters)
268 parameter.accept(this);
272 public void visit(QConjunction query) {
273 for(Query q : query.queries)
278 public void visit(QDisjunction query) {
279 for(Query q : query.queries)
284 public void visit(QExists query) {
285 query.query.accept(this);
289 public void visit(QNegation query) {
290 query.query.accept(this);
294 public void visit(ExpressionAccessor accessor) {
295 accessor.fieldName.accept(this);
299 public void visit(IdAccessor accessor) {
303 public void visit(StringAccessor accessor) {
307 public void visit(ListAssignment qualifier) {
308 qualifier.pattern.accept(this);
309 qualifier.value.accept(this);
313 public void visit(ListGenerator qualifier) {
314 qualifier.pattern.accept(this);
315 qualifier.value.accept(this);
319 public void visit(ListGuard qualifier) {
320 qualifier.condition.accept(this);
324 public void visit(ListSeq qualifier) {
325 qualifier.a.accept(this);
326 qualifier.b.accept(this);
330 public void visit(ListThen qualifier) {
331 qualifier.left.accept(this);
332 qualifier.transformer.accept(this);
333 if(qualifier.by != null)
334 qualifier.by.accept(this);
338 public void visit(QIf query) {
339 query.condition.accept(this);
340 query.thenQuery.accept(this);
341 query.elseQuery.accept(this);
345 public void visit(ECoveringBranchPoint expression) {
346 expression.expression.accept(this);
350 public void visit(EqBasic equation) {
351 equation.left.accept(this);
352 equation.right.accept(this);
356 public void visit(EqGuard equation) {
357 equation.guard.accept(this);
361 public void visit(EEquations expression) {
362 for(Equation equation : expression.equations)
363 equation.accept(this);
366 public void visit(CHRQuery query) {
367 for(CHRLiteral literal : query.literals)
368 for(Expression parameter : literal.parameters)
369 parameter.accept(this);
372 public void visit(CHRRuleset ruleset) {
373 for(CHRRule rule : ruleset.rules) {
380 public void visit(ECHRRuleset expression) {
381 visit(expression.ruleset);
382 expression.in.accept(this);
386 public void visit(ECHRRulesetConstructor expression) {
387 visit(expression.ruleset);
391 public void visit(EBinary expression) {
392 expression.left.accept(this);
393 for(EBinaryRightSide right : expression.rights)
394 right.right.accept(this);
398 public void visit(EBlock expression) {
399 for(Statement stat : expression.statements)
404 public void visit(EPreLet expression) {
405 for(LetStatement stat : expression.assignments) {
406 stat.pattern.accept(this);
407 stat.value.accept(this);
409 expression.in.accept(this);
413 public void visit(ERange expression) {
414 expression.from.accept(this);
415 expression.to.accept(this);
419 public void visit(ERecord expression) {
420 for(FieldAssignment assignment : expression.fields)
421 assignment.value.accept(this);
426 public void visit(EStringLiteral expression) {
427 for(Expression exp : expression.expressions)
432 public void visit(BindStatement statement) {
433 statement.pattern.accept(this);
434 statement.value.accept(this);
438 public void visit(GuardStatement statement) {
439 statement.value.accept(this);
443 public void visit(LetStatement statement) {
444 statement.value.accept(this);
448 public void visit(RuleStatement statement) {
449 statement.head.accept(this);
450 statement.body.accept(this);
454 public void visit(IncludeStatement statement) {
455 statement.value.accept(this);
459 public void visit(CHRStatement statement) {
460 for(ListQualifier q : statement.body)
462 for(ListQualifier q : statement.head)