From 97b13eee9a8053afa8fd29ecc8887394040332d3 Mon Sep 17 00:00:00 2001 From: Garami Bence <85867500+garamibence@users.noreply.github.com> Date: Tue, 12 Oct 2021 17:09:32 +0200 Subject: Add syntax for direct rules and direct predicates Xtext and Class diagram extended. --- .../java/tools/refinery/language/Problem.xtext | 50 ++++++++++++++++++++-- 1 file changed, 46 insertions(+), 4 deletions(-) (limited to 'language') diff --git a/language/src/main/java/tools/refinery/language/Problem.xtext b/language/src/main/java/tools/refinery/language/Problem.xtext index 6b46ee86..c4c890e3 100644 --- a/language/src/main/java/tools/refinery/language/Problem.xtext +++ b/language/src/main/java/tools/refinery/language/Problem.xtext @@ -8,7 +8,7 @@ Problem: statements+=Statement*; Statement: - ClassDeclaration | EnumDeclaration | PredicateDefinition | Assertion | NodeValueAssertion | ScopeDeclaration | + ClassDeclaration | EnumDeclaration | PredicateDefinition | RuleDefinition | Assertion | NodeValueAssertion | ScopeDeclaration | UniqueDeclaration; ClassDeclaration: @@ -32,30 +32,72 @@ ReferenceDeclaration: name=Identifier ("opposite" opposite=[ReferenceDeclaration|QualifiedName])?; +enum PredicateKind: + DIRECT="direct"; + PredicateDefinition: - (error?="error" "pred"? | "pred") + (error?="error" "pred"? | kind=PredicateKind? "pred") name=Identifier "(" (parameters+=Parameter ("," parameters+=Parameter)*)? ")" ("<->" bodies+=Conjunction (";" bodies+=Conjunction)*)? "."; +enum RuleKind: + DIRECT="direct"; + +RuleDefinition: + kind=RuleKind "rule" + name=Identifier + "(" (parameters+=Parameter ("," parameters+=Parameter)*)? ")" + (":" bodies+=Conjunction (";" bodies+=Conjunction)* + "~>" action=Action)? + "."; + Parameter: parameterType=[Relation|QualifiedName]? name=Identifier; Conjunction: literals+=Literal ("," literals+=Literal)*; +Action: + actionLiterals+=ActionLiteral ("," actionLiterals+=ActionLiteral)*; + Literal: - Atom | NegativeLiteral; + Atom | ValueLiteral | NegativeLiteral; + +ValueLiteral: + atom=Atom + (refinement?=":"|"=") + values+=LogicConstant ("|" values+=LogicConstant)*; NegativeLiteral: "!" atom=Atom; +ActionLiteral: + ValueActionLiteral | DeleteActionLiteral | NewActionLiteral; + +ValueActionLiteral: + atom=Atom + (refinement?=":"|"=") + value=LogicValue; + +DeleteActionLiteral: + "delete" variableOrNode=[VariableOrNode|QualifiedName]; + +NewActionLiteral: + "new" variable=NewVariable; + +NewVariable: + name=Identifier; + Atom: relation=[Relation|QualifiedName] transitiveClosure?="+"? "(" (arguments+=Argument ("," arguments+=Argument)*)? ")"; +LogicConstant: + value=LogicValue; + Argument: VariableOrNodeArgument | ConstantArgument; @@ -142,7 +184,7 @@ QualifiedName hidden(): Identifier: ID | "true" | "false" | "unknown" | "error" | "class" | "abstract" | "extends" | "enum" | "pred" | "scope" | - "unique" | "default" | "problem" | "contains" | "refers"; + "unique" | "default" | "problem" | "contains" | "refers" | "new" | "delete"; Integer returns ecore::EInt hidden(): "-"? INT; -- cgit v1.2.3-54-g00ecf