1 package org.simantics.scl.compiler.elaboration.chr.ast;
3 import java.util.ArrayList;
5 import org.simantics.scl.compiler.elaboration.chr.CHRLiteral;
6 import org.simantics.scl.compiler.elaboration.chr.CHRQuery;
7 import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
8 import org.simantics.scl.compiler.internal.parsing.Symbol;
10 public abstract class CHRAstQuery extends Symbol {
11 public CHRQuery translateAsHead(TranslationContext context) {
12 return translate(context, true);
15 public CHRQuery translateAsBody(TranslationContext context) {
16 return translate(context, false);
19 private CHRQuery translate(TranslationContext context, boolean isHead) {
20 ArrayList<CHRLiteral> literals = new ArrayList<CHRLiteral>();
21 translate(context, isHead, literals);
22 return new CHRQuery(literals.toArray(new CHRLiteral[literals.size()]));
25 protected abstract void translate(TranslationContext context, boolean isHead, ArrayList<CHRLiteral> literals);
27 public abstract void accept(CHRAstQueryVisitor visitor);