From d9a283acefae11c2cc094ed1c7b74759f8166f17 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Hannu=20Niemist=C3=B6?= Date: Fri, 21 Jul 2017 14:06:25 +0300 Subject: [PATCH] (refs #7377) Refactoring CHR query parsing Change-Id: Ia0e2e4589180505c02fabeb5b1dd2267825e3255 --- .../scl/compiler/elaboration/chr/CHRRule.java | 4 + .../elaboration/chr/ast/CHRAstAtom.java | 143 ++++++++++++++++++ .../elaboration/chr/ast/CHRAstBinds.java | 29 ++++ .../chr/ast/CHRAstConjunction.java | 40 +++++ .../elaboration/chr/ast/CHRAstEquals.java | 29 ++++ .../elaboration/chr/ast/CHRAstNegation.java | 24 +++ .../elaboration/chr/ast/CHRAstQuery.java | 28 ++++ .../chr/ast/CHRAstQueryVisitor.java | 9 ++ .../chr/translation/CHRTranslation.java | 6 +- .../elaboration/expressions/EBlock.java | 7 +- .../expressions/EPreCHRSelect.java | 11 +- .../elaboration/expressions/Expression.java | 2 +- .../StandardExpressionTransformer.java | 43 +++++- .../StandardExpressionVisitor.java | 44 +++++- .../expressions/block/CHRStatement.java | 15 +- .../internal/parsing/parser/SCL.grammar | 13 +- .../internal/parsing/parser/SCLParser.dat | Bin 24560 -> 25414 bytes .../internal/parsing/parser/SCLParser.java | 71 +++++---- .../parsing/parser/SCLParserImpl.java | 74 +++++---- .../generator/table/ParseTableBuilder.java | 4 +- .../simantics/scl/compiler/tests/scl/CHR3.scl | 3 +- 21 files changed, 504 insertions(+), 95 deletions(-) create mode 100644 bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/ast/CHRAstAtom.java create mode 100644 bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/ast/CHRAstBinds.java create mode 100644 bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/ast/CHRAstConjunction.java create mode 100644 bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/ast/CHRAstEquals.java create mode 100644 bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/ast/CHRAstNegation.java create mode 100644 bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/ast/CHRAstQuery.java create mode 100644 bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/ast/CHRAstQueryVisitor.java diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/CHRRule.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/CHRRule.java index f714497c4..c668005d7 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/CHRRule.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/CHRRule.java @@ -45,6 +45,10 @@ public class CHRRule extends Symbol { this.body = body; this.existentialVariables = existentialVariables; } + + public CHRRule(long location, CHRQuery head, CHRQuery body) { + this(location, head, body, null); + } public void resolve(TranslationContext context) { context.pushExistentialFrame(); diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/ast/CHRAstAtom.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/ast/CHRAstAtom.java new file mode 100644 index 000000000..031d8edd8 --- /dev/null +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/ast/CHRAstAtom.java @@ -0,0 +1,143 @@ +package org.simantics.scl.compiler.elaboration.chr.ast; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; + +import org.simantics.scl.compiler.common.names.Name; +import org.simantics.scl.compiler.elaboration.chr.CHRLiteral; +import org.simantics.scl.compiler.elaboration.chr.relations.SpecialCHRRelation; +import org.simantics.scl.compiler.elaboration.chr.relations.UnresolvedCHRRelation; +import org.simantics.scl.compiler.elaboration.contexts.TranslationContext; +import org.simantics.scl.compiler.elaboration.expressions.EApply; +import org.simantics.scl.compiler.elaboration.expressions.EBinary; +import org.simantics.scl.compiler.elaboration.expressions.EConstant; +import org.simantics.scl.compiler.elaboration.expressions.ERecord; +import org.simantics.scl.compiler.elaboration.expressions.EVar; +import org.simantics.scl.compiler.elaboration.expressions.Expression; +import org.simantics.scl.compiler.elaboration.expressions.records.FieldAssignment; +import org.simantics.scl.compiler.environment.AmbiguousNameException; +import org.simantics.scl.compiler.environment.Environments; +import org.simantics.scl.compiler.errors.Locations; +import org.simantics.scl.compiler.types.Types; + +public class CHRAstAtom extends CHRAstQuery { + public Expression expression; + public boolean remove; + + public CHRAstAtom(Expression expression, boolean remove) { + this.expression = expression; + this.remove = remove; + } + + @Override + public void accept(CHRAstQueryVisitor visitor) { + visitor.visit(this); + } + + public static CHRAstQuery atom(Expression expression) { + boolean remove = false; + if(expression instanceof EVar) { + EVar var = (EVar)expression; + if(var.name.equals("True")) { + CHRAstConjunction query = new CHRAstConjunction(Collections.emptyList()); + query.location = expression.location; + return query; + } + } + else if(expression instanceof EBinary) { + EBinary binary = (EBinary)expression; + if(binary.negation != null && binary.rights.isEmpty()) { + remove = true; + expression = binary.left; + } + // If query is marked for removal, it must be an atom + } + else if(expression instanceof EApply) { + EApply apply = (EApply)expression; + if(apply.function instanceof EVar && ((EVar)apply.function).name.equals("not")) { + Expression subExpression; + if(apply.parameters.length == 1) + subExpression = apply.parameters[0]; + else + subExpression = new EApply( + Locations.combine(apply.parameters[0].location, apply.parameters[apply.parameters.length-1].location), + apply.parameters[0], + Arrays.copyOfRange(apply.parameters, 1, apply.parameters.length)); + CHRAstNegation query = new CHRAstNegation(atom(subExpression)); + query.location = expression.location; + return query; + } + else if(apply.function instanceof EConstant) { + Name valueName = ((EConstant)apply.function).getValue().getName(); + if(valueName.module.equals(Types.BUILTIN) && valueName.name.startsWith("(")) { + CHRAstQuery[] conjuncts = new CHRAstQuery[apply.parameters.length]; + for(int i=0;i literals) { + literals.add( + isConstraint(context, expression) ? + convertConstraint(remove, expression) : + convertExpression(isHead, expression)); + } + + private static boolean isConstraint(TranslationContext context, Expression expression) { + if(expression instanceof EApply) + expression = ((EApply)expression).function; + else if(expression instanceof ERecord) + expression = ((ERecord)expression).constructor; + if(!(expression instanceof EVar)) + return false; + String name = ((EVar)expression).name; + if(TranslationContext.isConstructorName(name)) + return true; + try { + return Environments.getRelation(context.getEnvironment(), name) != null; + } catch (AmbiguousNameException e) { + return true; + } + } + + private static CHRLiteral convertExpression(boolean isHead, Expression expression) { + if(isHead) + return new CHRLiteral(expression.location, SpecialCHRRelation.CHECK, new Expression[] {expression}, false, false); + else + return new CHRLiteral(expression.location, SpecialCHRRelation.EXECUTE, new Expression[] {expression}, false, false); + } + + private static CHRLiteral convertConstraint(boolean remove, Expression expression) { + long location = expression.location; + Expression[] parameters; + FieldAssignment[] fields = null; + if(expression instanceof EApply) { + EApply apply = (EApply)expression; + parameters = apply.parameters; + expression = apply.function; + } + else if(expression instanceof ERecord) { + ERecord record = (ERecord)expression; + parameters = null; + fields = record.fields; + expression = record.constructor; + } + else // if(expression instanceof EVar) + parameters = Expression.EMPTY_ARRAY; + EVar var = (EVar)expression; // this should succeed because of isConstraint test + CHRLiteral literal = new CHRLiteral(location, new UnresolvedCHRRelation(var.location, var.name), + parameters, remove, false); + literal.fields = fields; + return literal; + } +} diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/ast/CHRAstBinds.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/ast/CHRAstBinds.java new file mode 100644 index 000000000..aa78f4e98 --- /dev/null +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/ast/CHRAstBinds.java @@ -0,0 +1,29 @@ +package org.simantics.scl.compiler.elaboration.chr.ast; + +import java.util.ArrayList; + +import org.simantics.scl.compiler.elaboration.chr.CHRLiteral; +import org.simantics.scl.compiler.elaboration.chr.relations.SpecialCHRRelation; +import org.simantics.scl.compiler.elaboration.contexts.TranslationContext; +import org.simantics.scl.compiler.elaboration.expressions.Expression; + +public class CHRAstBinds extends CHRAstQuery { + public Expression left; + public Expression right; + + public CHRAstBinds(Expression left, Expression right) { + this.left = left; + this.right = right; + } + + @Override + public void accept(CHRAstQueryVisitor visitor) { + visitor.visit(this); + } + + @Override + protected void translate(TranslationContext context, boolean isHead, ArrayList literals) { + literals.add(new CHRLiteral(location, SpecialCHRRelation.MEMBER, + new Expression[] { left, right }, false, false)); + } +} diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/ast/CHRAstConjunction.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/ast/CHRAstConjunction.java new file mode 100644 index 000000000..48f8ae71f --- /dev/null +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/ast/CHRAstConjunction.java @@ -0,0 +1,40 @@ +package org.simantics.scl.compiler.elaboration.chr.ast; + +import java.util.ArrayList; +import java.util.List; + +import org.simantics.scl.compiler.elaboration.chr.CHRLiteral; +import org.simantics.scl.compiler.elaboration.contexts.TranslationContext; + +public class CHRAstConjunction extends CHRAstQuery { + public List conjuncts; + + public CHRAstConjunction(List conjuncts) { + this.conjuncts = conjuncts; + } + + @Override + public void accept(CHRAstQueryVisitor visitor) { + visitor.visit(this); + } + + public static CHRAstQuery conjunction(CHRAstQuery[] conjuncts) { + ArrayList result = new ArrayList(conjuncts.length); + for(CHRAstQuery conjunct : conjuncts) { + if(conjunct instanceof CHRAstConjunction) + result.addAll(((CHRAstConjunction)conjunct).conjuncts); + else + result.add(conjunct); + } + if(result.size() == 1) + return result.get(0); + else + return new CHRAstConjunction(result); + } + + @Override + protected void translate(TranslationContext context, boolean isHead, ArrayList literals) { + for(CHRAstQuery conjunct : conjuncts) + conjunct.translate(context, isHead, literals); + } +} diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/ast/CHRAstEquals.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/ast/CHRAstEquals.java new file mode 100644 index 000000000..d2828934f --- /dev/null +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/ast/CHRAstEquals.java @@ -0,0 +1,29 @@ +package org.simantics.scl.compiler.elaboration.chr.ast; + +import java.util.ArrayList; + +import org.simantics.scl.compiler.elaboration.chr.CHRLiteral; +import org.simantics.scl.compiler.elaboration.chr.relations.SpecialCHRRelation; +import org.simantics.scl.compiler.elaboration.contexts.TranslationContext; +import org.simantics.scl.compiler.elaboration.expressions.Expression; + +public class CHRAstEquals extends CHRAstQuery { + public Expression left; + public Expression right; + + public CHRAstEquals(Expression left, Expression right) { + this.left = left; + this.right = right; + } + + @Override + public void accept(CHRAstQueryVisitor visitor) { + visitor.visit(this); + } + + @Override + protected void translate(TranslationContext context, boolean isHead, ArrayList literals) { + literals.add(new CHRLiteral(location, SpecialCHRRelation.EQUALS, + new Expression[] { left, right }, false, false)); + } +} diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/ast/CHRAstNegation.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/ast/CHRAstNegation.java new file mode 100644 index 000000000..b97f1e7f7 --- /dev/null +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/ast/CHRAstNegation.java @@ -0,0 +1,24 @@ +package org.simantics.scl.compiler.elaboration.chr.ast; + +import java.util.ArrayList; + +import org.simantics.scl.compiler.elaboration.chr.CHRLiteral; +import org.simantics.scl.compiler.elaboration.contexts.TranslationContext; + +public class CHRAstNegation extends CHRAstQuery { + public CHRAstQuery subquery; + + public CHRAstNegation(CHRAstQuery subquery) { + this.subquery = subquery; + } + + @Override + public void accept(CHRAstQueryVisitor visitor) { + visitor.visit(this); + } + + @Override + protected void translate(TranslationContext context, boolean isHead, ArrayList literals) { + context.getCompilationContext().errorLog.log(location, "CHR negation is not yet supported."); + } +} diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/ast/CHRAstQuery.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/ast/CHRAstQuery.java new file mode 100644 index 000000000..bd708e690 --- /dev/null +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/ast/CHRAstQuery.java @@ -0,0 +1,28 @@ +package org.simantics.scl.compiler.elaboration.chr.ast; + +import java.util.ArrayList; + +import org.simantics.scl.compiler.elaboration.chr.CHRLiteral; +import org.simantics.scl.compiler.elaboration.chr.CHRQuery; +import org.simantics.scl.compiler.elaboration.contexts.TranslationContext; +import org.simantics.scl.compiler.internal.parsing.Symbol; + +public abstract class CHRAstQuery extends Symbol { + public CHRQuery translateAsHead(TranslationContext context) { + return translate(context, true); + } + + public CHRQuery translateAsBody(TranslationContext context) { + return translate(context, false); + } + + private CHRQuery translate(TranslationContext context, boolean isHead) { + ArrayList literals = new ArrayList(); + translate(context, isHead, literals); + return new CHRQuery(literals.toArray(new CHRLiteral[literals.size()])); + } + + protected abstract void translate(TranslationContext context, boolean isHead, ArrayList literals); + + public abstract void accept(CHRAstQueryVisitor visitor); +} diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/ast/CHRAstQueryVisitor.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/ast/CHRAstQueryVisitor.java new file mode 100644 index 000000000..3c7b42525 --- /dev/null +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/ast/CHRAstQueryVisitor.java @@ -0,0 +1,9 @@ +package org.simantics.scl.compiler.elaboration.chr.ast; + +public interface CHRAstQueryVisitor { + void visit(CHRAstAtom query); + void visit(CHRAstBinds query); + void visit(CHRAstConjunction query); + void visit(CHRAstEquals query); + void visit(CHRAstNegation query); +} diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/translation/CHRTranslation.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/translation/CHRTranslation.java index d4f21a726..260927b74 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/translation/CHRTranslation.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/translation/CHRTranslation.java @@ -5,7 +5,6 @@ import java.util.Arrays; import org.simantics.scl.compiler.elaboration.chr.CHRLiteral; import org.simantics.scl.compiler.elaboration.chr.CHRQuery; -import org.simantics.scl.compiler.elaboration.chr.CHRRule; import org.simantics.scl.compiler.elaboration.chr.relations.CHRConstraint; import org.simantics.scl.compiler.elaboration.chr.relations.SpecialCHRRelation; import org.simantics.scl.compiler.elaboration.chr.relations.UnresolvedCHRRelation; @@ -15,7 +14,6 @@ import org.simantics.scl.compiler.elaboration.expressions.EBinary; import org.simantics.scl.compiler.elaboration.expressions.ERecord; import org.simantics.scl.compiler.elaboration.expressions.EVar; import org.simantics.scl.compiler.elaboration.expressions.Expression; -import org.simantics.scl.compiler.elaboration.expressions.block.CHRStatement; import org.simantics.scl.compiler.elaboration.expressions.block.ConstraintStatement; import org.simantics.scl.compiler.elaboration.expressions.list.ListAssignment; import org.simantics.scl.compiler.elaboration.expressions.list.ListGenerator; @@ -140,12 +138,12 @@ public class CHRTranslation { return new CHRQuery(query.toArray(new CHRLiteral[query.size()])); } - public static CHRRule convertCHRStatement(TranslationContext context, CHRStatement statement) { + /*public static CHRRule convertCHRStatement(TranslationContext context, CHRStatement statement) { return new CHRRule(statement.location, convertCHRQuery(context, true, statement.head), convertCHRQuery(context, false, statement.body), null); - } + }*/ public static CHRConstraint convertConstraintStatement(TranslationContext context, ConstraintStatement statement) { CHRConstraint constraint = new CHRConstraint(statement.location, statement.name.text, TypeAst.toTypes(context, statement.parameterTypes)); diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EBlock.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EBlock.java index 2c70bd907..e184b1397 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EBlock.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EBlock.java @@ -3,6 +3,7 @@ package org.simantics.scl.compiler.elaboration.expressions; import java.util.ArrayList; import java.util.List; +import org.simantics.scl.compiler.elaboration.chr.CHRRule; import org.simantics.scl.compiler.elaboration.chr.CHRRuleset; import org.simantics.scl.compiler.elaboration.chr.translation.CHRTranslation; import org.simantics.scl.compiler.elaboration.contexts.TranslationContext; @@ -92,8 +93,10 @@ public class EBlock extends ASTExpression { ruleset.location = Locations.combine(statements.get(begin).location, statements.get(end-1).location); for(int i=begin;i result = new THashSet(); collectFreeVariables(result); return result; - } + } public static Expression[] concat(Expression[] a, Expression[] b) { if(a.length == 0) diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/StandardExpressionTransformer.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/StandardExpressionTransformer.java index 948f7c645..c489422a5 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/StandardExpressionTransformer.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/StandardExpressionTransformer.java @@ -4,6 +4,13 @@ import org.simantics.scl.compiler.elaboration.chr.CHRLiteral; import org.simantics.scl.compiler.elaboration.chr.CHRQuery; import org.simantics.scl.compiler.elaboration.chr.CHRRule; import org.simantics.scl.compiler.elaboration.chr.CHRRuleset; +import org.simantics.scl.compiler.elaboration.chr.ast.CHRAstAtom; +import org.simantics.scl.compiler.elaboration.chr.ast.CHRAstBinds; +import org.simantics.scl.compiler.elaboration.chr.ast.CHRAstConjunction; +import org.simantics.scl.compiler.elaboration.chr.ast.CHRAstEquals; +import org.simantics.scl.compiler.elaboration.chr.ast.CHRAstNegation; +import org.simantics.scl.compiler.elaboration.chr.ast.CHRAstQuery; +import org.simantics.scl.compiler.elaboration.chr.ast.CHRAstQueryVisitor; import org.simantics.scl.compiler.elaboration.equation.EqBasic; import org.simantics.scl.compiler.elaboration.equation.EqGuard; import org.simantics.scl.compiler.elaboration.equation.Equation; @@ -41,7 +48,7 @@ import org.simantics.scl.compiler.elaboration.query.pre.QPreGuard; public class StandardExpressionTransformer implements ExpressionTransformer, QueryTransformer, ListQualifierTransformer, StatementVisitor, -EquationVisitor { +EquationVisitor, CHRAstQueryVisitor { @Override public Expression transform(EAmbiguous expression) { @@ -532,10 +539,36 @@ EquationVisitor { @Override public void visit(CHRStatement statement) { - for(int i=0;iw@snM-UjeS_;vFMusxowk^p{G63wolNo zL#gp?(Cv3ESWC3s5|FGGe*EJ~jnGcN-?h%pjt465$K2%Ejz56$B1UpIum?D(RKp_4 z*|164_Ia?~2K^2J$JM@GK)wNEX4^=t1dQ}GVoW?9+jl_O<7+~!Ciphp2keDzi&D+4 zXhF>#N{u@x3m}BBvSx5GqplixL8Smt~B|rBbj*;hxai+n~o;T`A`*B z$=w*k-he4PlqJr;r7hCO<7l6UI0pcO9*ogmQ(|S~d;6%R&;T?7O+Yg+0%!q70;7O2 zz<6LHFb$XvoCM4UP6HMI3o|$!{29O^V6g+^o&~f4=K$vc=K`aFCBWGL7bx?P&IB+A zHs=Ji91q7gAHZ>{Q-Qg_9N-j(S!fG@24(^?fRh0p&xyd)45ome4DclKSeT<7;IVOx z;{c9_<0Ci^lurOSt^}ZtGUv}zlC-B4eMK_9aHaYm_4UH#>YM6WZPcBJJWsuVF|R3H ztbSeHTv)D8(kJVg`o!c+Jzk$)I7gqU7wI|rYJI7`Os~>Y^*i*(^^N*HdW)J?SW;N5 zw-*-b*@d}<#=>lMoqktA>qIA}(KPCB16$2}Ghg4XKawm{|5`Xnjn&`NP3od#hMAwH z`onr#>L^jkxtN>QmIK`T_M7{SEz~{<3~i8|h0^ zH5d4xp09W4Kk&z=`Vi-IAU?i3!|^2x3Zv1#9hmL1+^^r2riJx5zHw%pdN1nD$(S@X zo6Y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X7~TZK+aTZU_=eYreDfPAPpd{gCHb{hHZW&WBo5b{@x*(o&ObHKxZhXdyffc%bf8s|Zt?{NX>LXZ5V WEZ`#Wi-AjkM*^1umjRCg9{vB&xSp*5 diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/parsing/parser/SCLParser.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/parsing/parser/SCLParser.java index 612b118ad..3e857b7f1 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/parsing/parser/SCLParser.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/parsing/parser/SCLParser.java @@ -13,18 +13,18 @@ public abstract class SCLParser { public static final boolean TRACE = false; private static final int INITIAL_CAPACITY = 16; - private static final int STATE_COUNT = 357; + private static final int STATE_COUNT = 362; private static final int TERMINAL_COUNT = 85; - private static final int NONTERMINAL_COUNT = 51; - private static final int PRODUCT_COUNT = 135; + private static final int NONTERMINAL_COUNT = 52; + private static final int PRODUCT_COUNT = 138; private static final int[] ACTION_ROW_ID = new int[STATE_COUNT]; private static final int[] ACTION_COLUMN_ID = new int[TERMINAL_COUNT]; - private static final short[] ACTION_TABLE = new short[6765]; - private static final int[] ERROR_TABLE = new int[949]; + private static final short[] ACTION_TABLE = new short[6832]; + private static final int[] ERROR_TABLE = new int[962]; private static final int[] GOTO_ROW_ID = new int[STATE_COUNT]; private static final int[] GOTO_COLUMN_ID = new int[NONTERMINAL_COUNT]; - private static final short[] GOTO_TABLE = new short[1647]; + private static final short[] GOTO_TABLE = new short[1953]; private static final int[] PRODUCT_LHS = new int[PRODUCT_COUNT]; private static final short STATE_MASK = (short)0x0fff; @@ -162,6 +162,7 @@ public abstract class SCLParser { "symbolWithoutMinus", "listQualifier", "chrQuery", + "chrQueryPart", "caseRhs", "guardedExpArrow", "equation", @@ -395,19 +396,19 @@ public abstract class SCLParser { return parse(0); } public Object parseCommands() { - return parse(341); + return parse(346); } public Object parseImport() { - return parse(349); + return parse(354); } public Object parseType() { - return parse(351); + return parse(356); } public Object parseExp() { - return parse(353); + return parse(358); } public Object parseEquationBlock() { - return parse(355); + return parse(360); } @@ -629,7 +630,7 @@ public abstract class SCLParser { case 106: return reduceQueryBlock(); case 107: - return reduceVerboseCHRQuery(); + return reduceVerboseCHRConjunction(); case 108: return reduceStringLiteral(); case 109: @@ -651,26 +652,32 @@ public abstract class SCLParser { case 117: return reduceThenQualifier(); case 118: - return reduceCHRQuery(); + return reduceCHRConjunction(); case 119: - return reduceSimpleCaseRhs(); + return reduceCHRAtom(); case 120: - return reduceGuardedCaseRhs(); + return reduceCHREquals(); case 121: - return reduceGuardedExpArrow(); + return reduceCHRBinds(); case 122: - return reduceGuardEquation(); + return reduceSimpleCaseRhs(); case 123: - return reduceBasicEquation(); + return reduceGuardedCaseRhs(); case 124: - return reduceEffect(); + return reduceGuardedExpArrow(); case 125: - return reduceJustEtype(); + return reduceGuardEquation(); case 126: - return reduceForAll(); + return reduceBasicEquation(); case 127: - return reduceApplyType(); + return reduceEffect(); case 128: + return reduceJustEtype(); + case 129: + return reduceForAll(); + case 130: + return reduceApplyType(); + case 131: return reduceDummy(); default: @@ -1116,9 +1123,9 @@ public abstract class SCLParser { */ protected abstract Object reduceQueryBlock(); /** - * verboseChrQuery ::= LBRACE listQualifier (SEMICOLON listQualifier)* RBRACE + * verboseChrQuery ::= LBRACE chrQuery (SEMICOLON chrQuery)* RBRACE */ - protected abstract Object reduceVerboseCHRQuery(); + protected abstract Object reduceVerboseCHRConjunction(); /** * stringLiteral ::= BEGIN_STRING (SUSPEND_STRING exp CONTINUE_STRING)* END_STRING */ @@ -1140,9 +1147,21 @@ public abstract class SCLParser { */ protected abstract Object reduceThenQualifier(); /** - * chrQuery ::= (listQualifier COMMA)* listQualifier + * chrQuery ::= (chrQueryPart COMMA)* chrQueryPart + */ + protected abstract Object reduceCHRConjunction(); + /** + * chrQueryPart ::= exp + */ + protected abstract Object reduceCHRAtom(); + /** + * chrQueryPart ::= exp EQUALS exp + */ + protected abstract Object reduceCHREquals(); + /** + * chrQueryPart ::= exp BINDS exp */ - protected abstract Object reduceCHRQuery(); + protected abstract Object reduceCHRBinds(); /** * caseRhs ::= ARROW exp (WHERE statements)? */ diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/parsing/parser/SCLParserImpl.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/parsing/parser/SCLParserImpl.java index dd614f964..bda298bd6 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/parsing/parser/SCLParserImpl.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/parsing/parser/SCLParserImpl.java @@ -11,6 +11,11 @@ import org.simantics.scl.compiler.common.precedence.Precedence; import org.simantics.scl.compiler.compilation.CompilationContext; import org.simantics.scl.compiler.constants.CharacterConstant; import org.simantics.scl.compiler.constants.StringConstant; +import org.simantics.scl.compiler.elaboration.chr.ast.CHRAstAtom; +import org.simantics.scl.compiler.elaboration.chr.ast.CHRAstBinds; +import org.simantics.scl.compiler.elaboration.chr.ast.CHRAstConjunction; +import org.simantics.scl.compiler.elaboration.chr.ast.CHRAstEquals; +import org.simantics.scl.compiler.elaboration.chr.ast.CHRAstQuery; import org.simantics.scl.compiler.elaboration.equation.EqBasic; import org.simantics.scl.compiler.elaboration.equation.EqGuard; import org.simantics.scl.compiler.elaboration.equation.Equation; @@ -1247,25 +1252,12 @@ public class SCLParserImpl extends SCLParser { return new EViewPattern((Expression)get(1), (Expression)get(3)); } - @Override - protected Object reduceCHRStatement() { - return new CHRStatement((ListQualifier[])get(0), (ListQualifier[])get(2)); - } - @Override protected Object reduceConstraintStatement() { ConstructorAst constructor = (ConstructorAst)get(1); return new ConstraintStatement(constructor.name, constructor.parameters, constructor.fieldNames, constructor.annotations); } - @Override - protected Object reduceCHRQuery() { - ListQualifier[] query = new ListQualifier[(length()+1)/2]; - for(int i=0;i A (?x-1) True => A 0 -- -0 -() \ No newline at end of file +6:11-6:23: CHR negation is not yet supported. \ No newline at end of file -- 2.47.1