diff options
6 files changed, 54 insertions, 82 deletions
diff --git a/subprojects/frontend/src/index.tsx b/subprojects/frontend/src/index.tsx index 55e0590f..f7fe61b9 100644 --- a/subprojects/frontend/src/index.tsx +++ b/subprojects/frontend/src/index.tsx | |||
@@ -36,14 +36,6 @@ pred invalidTaxStatus(Person p) <-> | |||
36 | parent(p, q), | 36 | parent(p, q), |
37 | !taxStatus(q, retired). | 37 | !taxStatus(q, retired). |
38 | 38 | ||
39 | rule createChild(may Person p, must Person newPerson): | ||
40 | may children(p, newPerson), | ||
41 | may !equals(newPerson, newPerson) | ||
42 | ==> | ||
43 | new q <: newPerson, | ||
44 | children(p, q), | ||
45 | taxStatus(q, child). | ||
46 | |||
47 | indiv family. | 39 | indiv family. |
48 | Family(family). | 40 | Family(family). |
49 | members(family, anne). | 41 | members(family, anne). |
diff --git a/subprojects/frontend/src/language/folding.ts b/subprojects/frontend/src/language/folding.ts index 9d1c04a3..4dabfa27 100644 --- a/subprojects/frontend/src/language/folding.ts +++ b/subprojects/frontend/src/language/folding.ts | |||
@@ -103,7 +103,7 @@ function foldWithSibling(node: SyntaxNode): FoldRange | null { | |||
103 | return null; | 103 | return null; |
104 | } | 104 | } |
105 | 105 | ||
106 | export function foldWholeNode(node: SyntaxNode): FoldRange { | 106 | function foldWholeNode(node: SyntaxNode): FoldRange { |
107 | return { | 107 | return { |
108 | from: node.from, | 108 | from: node.from, |
109 | to: node.to, | 109 | to: node.to, |
diff --git a/subprojects/frontend/src/language/problem.grammar b/subprojects/frontend/src/language/problem.grammar index 7feb6bfe..1e1ef70f 100644 --- a/subprojects/frontend/src/language/problem.grammar +++ b/subprojects/frontend/src/language/problem.grammar | |||
@@ -25,11 +25,11 @@ statement { | |||
25 | RelationName ParameterList<Parameter>? | 25 | RelationName ParameterList<Parameter>? |
26 | PredicateBody { ("<->" sep<OrOp, Conjunction>)? "." } | 26 | PredicateBody { ("<->" sep<OrOp, Conjunction>)? "." } |
27 | } | | 27 | } | |
28 | RuleDefinition { | 28 | //RuleDefinition { |
29 | ckw<"rule"> | 29 | // ckw<"rule"> |
30 | RuleName ParameterList<Parameter>? | 30 | // RuleName ParameterList<Parameter>? |
31 | RuleBody { ":" sep<OrOp, Conjunction> "==>" sep<OrOp, Consequent> "." } | 31 | // RuleBody { ":" sep<OrOp, Conjunction> "==>" sep<OrOp, Consequent> "." } |
32 | } | | 32 | //} | |
33 | Assertion { | 33 | Assertion { |
34 | ckw<"default">? (NotOp | UnknownOp)? RelationName | 34 | ckw<"default">? (NotOp | UnknownOp)? RelationName |
35 | ParameterList<AssertionArgument> (":" LogicValue)? "." | 35 | ParameterList<AssertionArgument> (":" LogicValue)? "." |
@@ -73,13 +73,13 @@ Literal { | |||
73 | 73 | ||
74 | Atom { RelationName "+"? ParameterList<Argument> } | 74 | Atom { RelationName "+"? ParameterList<Argument> } |
75 | 75 | ||
76 | Consequent { ("," | Action)+ } | 76 | //Consequent { ("," | Action)+ } |
77 | 77 | ||
78 | Action { | 78 | //Action { |
79 | ckw<"new"> VariableName ("<:" VariableName)? | | 79 | // ckw<"new"> VariableName ("<:" VariableName)? | |
80 | ckw<"delete"> VariableName | | 80 | // ckw<"delete"> VariableName | |
81 | Literal | 81 | // Literal |
82 | } | 82 | //} |
83 | 83 | ||
84 | Argument { VariableName | Constant } | 84 | Argument { VariableName | Constant } |
85 | 85 | ||
@@ -101,7 +101,7 @@ Multiplicity { (IntMult "..")? (IntMult | StarMult)} | |||
101 | 101 | ||
102 | RelationName { QualifiedName } | 102 | RelationName { QualifiedName } |
103 | 103 | ||
104 | RuleName { QualifiedName } | 104 | //RuleName { QualifiedName } |
105 | 105 | ||
106 | IndividualNodeName { QualifiedName } | 106 | IndividualNodeName { QualifiedName } |
107 | 107 | ||
diff --git a/subprojects/frontend/src/language/problemLanguageSupport.ts b/subprojects/frontend/src/language/problemLanguageSupport.ts index 03a7c4cc..a96b5402 100644 --- a/subprojects/frontend/src/language/problemLanguageSupport.ts +++ b/subprojects/frontend/src/language/problemLanguageSupport.ts | |||
@@ -8,12 +8,7 @@ import { | |||
8 | } from '@codemirror/language'; | 8 | } from '@codemirror/language'; |
9 | import { styleTags, tags as t } from '@lezer/highlight'; | 9 | import { styleTags, tags as t } from '@lezer/highlight'; |
10 | 10 | ||
11 | import { | 11 | import { foldBlockComment, foldConjunction, foldDeclaration } from './folding'; |
12 | foldBlockComment, | ||
13 | foldConjunction, | ||
14 | foldDeclaration, | ||
15 | foldWholeNode, | ||
16 | } from './folding'; | ||
17 | import { | 12 | import { |
18 | indentBlockComment, | 13 | indentBlockComment, |
19 | indentDeclaration, | 14 | indentDeclaration, |
@@ -26,12 +21,12 @@ const parserWithMetadata = parser.configure({ | |||
26 | styleTags({ | 21 | styleTags({ |
27 | LineComment: t.lineComment, | 22 | LineComment: t.lineComment, |
28 | BlockComment: t.blockComment, | 23 | BlockComment: t.blockComment, |
29 | 'problem class enum pred rule indiv scope': t.definitionKeyword, | 24 | 'problem class enum pred indiv scope': t.definitionKeyword, |
30 | 'abstract extends refers contains container opposite': t.modifier, | 25 | 'abstract extends refers contains container opposite': t.modifier, |
31 | 'default error contained containment': t.modifier, | 26 | 'default error contained containment': t.modifier, |
32 | 'true false unknown error': t.operatorKeyword, | 27 | 'true false unknown error': t.operatorKeyword, |
33 | 'may must current count': t.operatorKeyword, | 28 | 'may must current count': t.operatorKeyword, |
34 | 'new delete': t.keyword, | 29 | // 'new delete': t.keyword, |
35 | NotOp: t.operator, | 30 | NotOp: t.operator, |
36 | UnknownOp: t.operator, | 31 | UnknownOp: t.operator, |
37 | OrOp: t.separator, | 32 | OrOp: t.separator, |
@@ -40,7 +35,7 @@ const parserWithMetadata = parser.configure({ | |||
40 | StarMult: t.number, | 35 | StarMult: t.number, |
41 | String: t.string, | 36 | String: t.string, |
42 | 'RelationName/QualifiedName': t.typeName, | 37 | 'RelationName/QualifiedName': t.typeName, |
43 | 'RuleName/QualifiedName': t.typeName, | 38 | // 'RuleName/QualifiedName': t.typeName, |
44 | 'IndividualNodeName/QualifiedName': t.atom, | 39 | 'IndividualNodeName/QualifiedName': t.atom, |
45 | 'VariableName/QualifiedName': t.variableName, | 40 | 'VariableName/QualifiedName': t.variableName, |
46 | '{ }': t.brace, | 41 | '{ }': t.brace, |
@@ -54,7 +49,7 @@ const parserWithMetadata = parser.configure({ | |||
54 | UniqueDeclaration: indentDeclaration, | 49 | UniqueDeclaration: indentDeclaration, |
55 | ScopeDeclaration: indentDeclaration, | 50 | ScopeDeclaration: indentDeclaration, |
56 | PredicateBody: indentPredicateOrRule, | 51 | PredicateBody: indentPredicateOrRule, |
57 | RuleBody: indentPredicateOrRule, | 52 | // RuleBody: indentPredicateOrRule, |
58 | BlockComment: indentBlockComment, | 53 | BlockComment: indentBlockComment, |
59 | }), | 54 | }), |
60 | foldNodeProp.add({ | 55 | foldNodeProp.add({ |
@@ -62,9 +57,9 @@ const parserWithMetadata = parser.configure({ | |||
62 | EnumBody: foldInside, | 57 | EnumBody: foldInside, |
63 | ParameterList: foldInside, | 58 | ParameterList: foldInside, |
64 | PredicateBody: foldInside, | 59 | PredicateBody: foldInside, |
65 | RuleBody: foldInside, | 60 | // RuleBody: foldInside, |
66 | Conjunction: foldConjunction, | 61 | Conjunction: foldConjunction, |
67 | Consequent: foldWholeNode, | 62 | // Consequent: foldWholeNode, |
68 | UniqueDeclaration: foldDeclaration, | 63 | UniqueDeclaration: foldDeclaration, |
69 | ScopeDeclaration: foldDeclaration, | 64 | ScopeDeclaration: foldDeclaration, |
70 | BlockComment: foldBlockComment, | 65 | BlockComment: foldBlockComment, |
@@ -82,7 +77,7 @@ const problemLanguage = LRLanguage.define({ | |||
82 | }, | 77 | }, |
83 | line: '%', | 78 | line: '%', |
84 | }, | 79 | }, |
85 | indentOnInput: /^\s*(?:\{|\}|\(|\)|;|\.|==>)$/, | 80 | indentOnInput: /^\s*(?:\{|\}|\(|\)|;|\.)$/, |
86 | }, | 81 | }, |
87 | }); | 82 | }); |
88 | 83 | ||
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: | |||
8 | statements+=Statement*; | 8 | statements+=Statement*; |
9 | 9 | ||
10 | Statement: | 10 | Statement: |
11 | ClassDeclaration | EnumDeclaration | PredicateDefinition | RuleDefinition | Assertion | NodeValueAssertion | | 11 | ClassDeclaration | EnumDeclaration | PredicateDefinition | /* RuleDefinition | */ Assertion | NodeValueAssertion | |
12 | ScopeDeclaration | | 12 | ScopeDeclaration | |
13 | IndividualDeclaration; | 13 | IndividualDeclaration; |
14 | 14 | ||
@@ -48,13 +48,13 @@ PredicateDefinition: | |||
48 | ("<->" bodies+=Conjunction (";" bodies+=Conjunction)*)? | 48 | ("<->" bodies+=Conjunction (";" bodies+=Conjunction)*)? |
49 | "."; | 49 | "."; |
50 | 50 | ||
51 | RuleDefinition: | 51 | //RuleDefinition: |
52 | "rule" | 52 | // "rule" |
53 | name=Identifier | 53 | // name=Identifier |
54 | "(" (parameters+=Parameter ("," parameters+=Parameter)*)? ")" | 54 | // "(" (parameters+=Parameter ("," parameters+=Parameter)*)? ")" |
55 | (":" bodies+=Conjunction (";" bodies+=Conjunction)* | 55 | // (":" bodies+=Conjunction (";" bodies+=Conjunction)* |
56 | "==>" consequents+=Consequent (";" consequents+=Consequent)*)? | 56 | // "==>" consequents+=Consequent (";" consequents+=Consequent)*)? |
57 | "."; | 57 | // "."; |
58 | 58 | ||
59 | Parameter: | 59 | Parameter: |
60 | (modality=Modality? parameterType=[Relation|QualifiedName])? name=Identifier; | 60 | (modality=Modality? parameterType=[Relation|QualifiedName])? name=Identifier; |
@@ -62,8 +62,8 @@ Parameter: | |||
62 | Conjunction: | 62 | Conjunction: |
63 | literals+=Literal ("," literals+=Literal)*; | 63 | literals+=Literal ("," literals+=Literal)*; |
64 | 64 | ||
65 | Consequent: | 65 | //Consequent: |
66 | actions+=Action ("," actions+=Action)*; | 66 | // actions+=Action ("," actions+=Action)*; |
67 | 67 | ||
68 | Literal: | 68 | Literal: |
69 | Atom | NegativeLiteral | CountLiteral; | 69 | Atom | NegativeLiteral | CountLiteral; |
@@ -77,21 +77,21 @@ enum ComparisonOp: | |||
77 | CountLiteral: | 77 | CountLiteral: |
78 | modality=Modality? "count" atom=Atom op=ComparisonOp threshold=INT; | 78 | modality=Modality? "count" atom=Atom op=ComparisonOp threshold=INT; |
79 | 79 | ||
80 | Action: | 80 | //Action: |
81 | AssertionAction | DeleteAction | NewAction; | 81 | // AssertionAction | DeleteAction | NewAction; |
82 | 82 | // | |
83 | AssertionAction: | 83 | //AssertionAction: |
84 | value=ShortLogicValue? atom=Atom | | 84 | // value=ShortLogicValue? atom=Atom | |
85 | atom=Atom (overwrite?=":=" | "<:") value=LogicValue; | 85 | // atom=Atom (overwrite?=":=" | "<:") value=LogicValue; |
86 | 86 | // | |
87 | DeleteAction: | 87 | //DeleteAction: |
88 | "delete" variableOrNode=[VariableOrNode|QualifiedName]; | 88 | // "delete" variableOrNode=[VariableOrNode|QualifiedName]; |
89 | 89 | // | |
90 | NewAction: | 90 | //NewAction: |
91 | "new" variable=NewVariable ("<:" parent=[VariableOrNode|QualifiedName])?; | 91 | // "new" variable=NewVariable ("<:" parent=[VariableOrNode|QualifiedName])?; |
92 | 92 | // | |
93 | NewVariable: | 93 | //NewVariable: |
94 | name=Identifier; | 94 | // name=Identifier; |
95 | 95 | ||
96 | enum Modality: | 96 | enum Modality: |
97 | MAY="may" | MUST="must" | CURRENT="current"; | 97 | MAY="may" | MUST="must" | CURRENT="current"; |
@@ -191,7 +191,7 @@ QualifiedName hidden(): | |||
191 | 191 | ||
192 | NonRelationKindIdentifier: | 192 | NonRelationKindIdentifier: |
193 | ID | "true" | "false" | "unknown" | "error" | "class" | "abstract" | "extends" | "enum" | | 193 | ID | "true" | "false" | "unknown" | "error" | "class" | "abstract" | "extends" | "enum" | |
194 | "pred" | "indiv" | "problem" | "new" | "delete" | "rule" | "may" | "must" | "current" | | 194 | "pred" | "indiv" | "problem" | /* "new" | "delete" | "rule" | */ "may" | "must" | "current" | |
195 | "count" | "default" | "scope" | "contained" | "containment"; | 195 | "count" | "default" | "scope" | "contained" | "containment"; |
196 | 196 | ||
197 | Identifier: | 197 | 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 @@ | |||
1 | package tools.refinery.language.utils; | 1 | package tools.refinery.language.utils; |
2 | 2 | ||
3 | import java.util.LinkedHashMap; | 3 | import com.google.inject.Inject; |
4 | import java.util.List; | ||
5 | import java.util.Map; | ||
6 | |||
7 | import org.eclipse.emf.ecore.EObject; | 4 | import org.eclipse.emf.ecore.EObject; |
8 | import org.eclipse.emf.ecore.util.EcoreUtil; | 5 | import org.eclipse.emf.ecore.util.EcoreUtil; |
9 | import org.eclipse.xtext.naming.IQualifiedNameConverter; | 6 | import org.eclipse.xtext.naming.IQualifiedNameConverter; |
10 | import org.eclipse.xtext.naming.IQualifiedNameProvider; | 7 | import org.eclipse.xtext.naming.IQualifiedNameProvider; |
8 | import tools.refinery.language.model.problem.*; | ||
11 | 9 | ||
12 | import com.google.inject.Inject; | 10 | import java.util.LinkedHashMap; |
13 | 11 | import java.util.List; | |
14 | import tools.refinery.language.model.problem.Assertion; | 12 | import java.util.Map; |
15 | import tools.refinery.language.model.problem.ClassDeclaration; | ||
16 | import tools.refinery.language.model.problem.ConstantAssertionArgument; | ||
17 | import tools.refinery.language.model.problem.EnumDeclaration; | ||
18 | import tools.refinery.language.model.problem.IndividualDeclaration; | ||
19 | import tools.refinery.language.model.problem.IntConstant; | ||
20 | import tools.refinery.language.model.problem.LogicValue; | ||
21 | import tools.refinery.language.model.problem.Node; | ||
22 | import tools.refinery.language.model.problem.NodeValueAssertion; | ||
23 | import tools.refinery.language.model.problem.PredicateDefinition; | ||
24 | import tools.refinery.language.model.problem.PredicateKind; | ||
25 | import tools.refinery.language.model.problem.Problem; | ||
26 | import tools.refinery.language.model.problem.ProblemFactory; | ||
27 | import tools.refinery.language.model.problem.RealConstant; | ||
28 | import tools.refinery.language.model.problem.Relation; | ||
29 | import tools.refinery.language.model.problem.StringConstant; | ||
30 | 13 | ||
31 | class SymbolCollector { | 14 | class SymbolCollector { |
32 | @Inject | 15 | @Inject |
@@ -64,6 +47,8 @@ class SymbolCollector { | |||
64 | collectClass(classDeclaration); | 47 | collectClass(classDeclaration); |
65 | } else if (statement instanceof EnumDeclaration enumDeclaration) { | 48 | } else if (statement instanceof EnumDeclaration enumDeclaration) { |
66 | collectEnum(enumDeclaration); | 49 | collectEnum(enumDeclaration); |
50 | } else if (statement instanceof RuleDefinition) { | ||
51 | throw new UnsupportedOperationException("Rules are not currently supported"); | ||
67 | } | 52 | } |
68 | } | 53 | } |
69 | } | 54 | } |