From 4a3cdd67cd1b5c6d407c5702a1c50a19bc17fc20 Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Tue, 4 Oct 2022 01:12:01 +0200 Subject: refactor(language): disable rule parsing Rules have too complex semantics to implement in the first prototype. --- .../java/tools/refinery/language/Problem.xtext | 52 +++++++++++----------- .../refinery/language/utils/SymbolCollector.java | 29 +++--------- 2 files changed, 33 insertions(+), 48 deletions(-) (limited to 'subprojects/language/src/main/java') diff --git a/subprojects/language/src/main/java/tools/refinery/language/Problem.xtext b/subprojects/language/src/main/java/tools/refinery/language/Problem.xtext index 2a5af628..f514e96c 100644 --- a/subprojects/language/src/main/java/tools/refinery/language/Problem.xtext +++ b/subprojects/language/src/main/java/tools/refinery/language/Problem.xtext @@ -8,7 +8,7 @@ Problem: statements+=Statement*; Statement: - ClassDeclaration | EnumDeclaration | PredicateDefinition | RuleDefinition | Assertion | NodeValueAssertion | + ClassDeclaration | EnumDeclaration | PredicateDefinition | /* RuleDefinition | */ Assertion | NodeValueAssertion | ScopeDeclaration | IndividualDeclaration; @@ -48,13 +48,13 @@ PredicateDefinition: ("<->" bodies+=Conjunction (";" bodies+=Conjunction)*)? "."; -RuleDefinition: - "rule" - name=Identifier - "(" (parameters+=Parameter ("," parameters+=Parameter)*)? ")" - (":" bodies+=Conjunction (";" bodies+=Conjunction)* - "==>" consequents+=Consequent (";" consequents+=Consequent)*)? - "."; +//RuleDefinition: +// "rule" +// name=Identifier +// "(" (parameters+=Parameter ("," parameters+=Parameter)*)? ")" +// (":" bodies+=Conjunction (";" bodies+=Conjunction)* +// "==>" consequents+=Consequent (";" consequents+=Consequent)*)? +// "."; Parameter: (modality=Modality? parameterType=[Relation|QualifiedName])? name=Identifier; @@ -62,8 +62,8 @@ Parameter: Conjunction: literals+=Literal ("," literals+=Literal)*; -Consequent: - actions+=Action ("," actions+=Action)*; +//Consequent: +// actions+=Action ("," actions+=Action)*; Literal: Atom | NegativeLiteral | CountLiteral; @@ -77,21 +77,21 @@ enum ComparisonOp: CountLiteral: modality=Modality? "count" atom=Atom op=ComparisonOp threshold=INT; -Action: - AssertionAction | DeleteAction | NewAction; - -AssertionAction: - value=ShortLogicValue? atom=Atom | - atom=Atom (overwrite?=":=" | "<:") value=LogicValue; - -DeleteAction: - "delete" variableOrNode=[VariableOrNode|QualifiedName]; - -NewAction: - "new" variable=NewVariable ("<:" parent=[VariableOrNode|QualifiedName])?; - -NewVariable: - name=Identifier; +//Action: +// AssertionAction | DeleteAction | NewAction; +// +//AssertionAction: +// value=ShortLogicValue? atom=Atom | +// atom=Atom (overwrite?=":=" | "<:") value=LogicValue; +// +//DeleteAction: +// "delete" variableOrNode=[VariableOrNode|QualifiedName]; +// +//NewAction: +// "new" variable=NewVariable ("<:" parent=[VariableOrNode|QualifiedName])?; +// +//NewVariable: +// name=Identifier; enum Modality: MAY="may" | MUST="must" | CURRENT="current"; @@ -191,7 +191,7 @@ QualifiedName hidden(): NonRelationKindIdentifier: ID | "true" | "false" | "unknown" | "error" | "class" | "abstract" | "extends" | "enum" | - "pred" | "indiv" | "problem" | "new" | "delete" | "rule" | "may" | "must" | "current" | + "pred" | "indiv" | "problem" | /* "new" | "delete" | "rule" | */ "may" | "must" | "current" | "count" | "default" | "scope" | "contained" | "containment"; Identifier: diff --git a/subprojects/language/src/main/java/tools/refinery/language/utils/SymbolCollector.java b/subprojects/language/src/main/java/tools/refinery/language/utils/SymbolCollector.java index 87cce1f3..a386db7f 100644 --- a/subprojects/language/src/main/java/tools/refinery/language/utils/SymbolCollector.java +++ b/subprojects/language/src/main/java/tools/refinery/language/utils/SymbolCollector.java @@ -1,32 +1,15 @@ package tools.refinery.language.utils; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - +import com.google.inject.Inject; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.xtext.naming.IQualifiedNameConverter; import org.eclipse.xtext.naming.IQualifiedNameProvider; +import tools.refinery.language.model.problem.*; -import com.google.inject.Inject; - -import tools.refinery.language.model.problem.Assertion; -import tools.refinery.language.model.problem.ClassDeclaration; -import tools.refinery.language.model.problem.ConstantAssertionArgument; -import tools.refinery.language.model.problem.EnumDeclaration; -import tools.refinery.language.model.problem.IndividualDeclaration; -import tools.refinery.language.model.problem.IntConstant; -import tools.refinery.language.model.problem.LogicValue; -import tools.refinery.language.model.problem.Node; -import tools.refinery.language.model.problem.NodeValueAssertion; -import tools.refinery.language.model.problem.PredicateDefinition; -import tools.refinery.language.model.problem.PredicateKind; -import tools.refinery.language.model.problem.Problem; -import tools.refinery.language.model.problem.ProblemFactory; -import tools.refinery.language.model.problem.RealConstant; -import tools.refinery.language.model.problem.Relation; -import tools.refinery.language.model.problem.StringConstant; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; class SymbolCollector { @Inject @@ -64,6 +47,8 @@ class SymbolCollector { collectClass(classDeclaration); } else if (statement instanceof EnumDeclaration enumDeclaration) { collectEnum(enumDeclaration); + } else if (statement instanceof RuleDefinition) { + throw new UnsupportedOperationException("Rules are not currently supported"); } } } -- cgit v1.2.3-54-g00ecf