aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2022-10-04 01:12:01 +0200
committerLibravatar Kristóf Marussy <kristof@marussy.com>2022-10-04 01:12:01 +0200
commit4a3cdd67cd1b5c6d407c5702a1c50a19bc17fc20 (patch)
tree8cdac92902a75c5d1808a2a876382f0c987298c0 /subprojects
parentfeat(frontend): enable cross-origin isolation (diff)
downloadrefinery-4a3cdd67cd1b5c6d407c5702a1c50a19bc17fc20.tar.gz
refinery-4a3cdd67cd1b5c6d407c5702a1c50a19bc17fc20.tar.zst
refinery-4a3cdd67cd1b5c6d407c5702a1c50a19bc17fc20.zip
refactor(language): disable rule parsing
Rules have too complex semantics to implement in the first prototype.
Diffstat (limited to 'subprojects')
-rw-r--r--subprojects/frontend/src/index.tsx8
-rw-r--r--subprojects/frontend/src/language/folding.ts2
-rw-r--r--subprojects/frontend/src/language/problem.grammar24
-rw-r--r--subprojects/frontend/src/language/problemLanguageSupport.ts21
-rw-r--r--subprojects/language/src/main/java/tools/refinery/language/Problem.xtext52
-rw-r--r--subprojects/language/src/main/java/tools/refinery/language/utils/SymbolCollector.java29
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
39rule 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
47indiv family. 39indiv family.
48Family(family). 40Family(family).
49members(family, anne). 41members(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
106export function foldWholeNode(node: SyntaxNode): FoldRange { 106function 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
74Atom { RelationName "+"? ParameterList<Argument> } 74Atom { RelationName "+"? ParameterList<Argument> }
75 75
76Consequent { ("," | Action)+ } 76//Consequent { ("," | Action)+ }
77 77
78Action { 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
84Argument { VariableName | Constant } 84Argument { VariableName | Constant }
85 85
@@ -101,7 +101,7 @@ Multiplicity { (IntMult "..")? (IntMult | StarMult)}
101 101
102RelationName { QualifiedName } 102RelationName { QualifiedName }
103 103
104RuleName { QualifiedName } 104//RuleName { QualifiedName }
105 105
106IndividualNodeName { QualifiedName } 106IndividualNodeName { 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';
9import { styleTags, tags as t } from '@lezer/highlight'; 9import { styleTags, tags as t } from '@lezer/highlight';
10 10
11import { 11import { foldBlockComment, foldConjunction, foldDeclaration } from './folding';
12 foldBlockComment,
13 foldConjunction,
14 foldDeclaration,
15 foldWholeNode,
16} from './folding';
17import { 12import {
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
10Statement: 10Statement:
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
51RuleDefinition: 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
59Parameter: 59Parameter:
60 (modality=Modality? parameterType=[Relation|QualifiedName])? name=Identifier; 60 (modality=Modality? parameterType=[Relation|QualifiedName])? name=Identifier;
@@ -62,8 +62,8 @@ Parameter:
62Conjunction: 62Conjunction:
63 literals+=Literal ("," literals+=Literal)*; 63 literals+=Literal ("," literals+=Literal)*;
64 64
65Consequent: 65//Consequent:
66 actions+=Action ("," actions+=Action)*; 66// actions+=Action ("," actions+=Action)*;
67 67
68Literal: 68Literal:
69 Atom | NegativeLiteral | CountLiteral; 69 Atom | NegativeLiteral | CountLiteral;
@@ -77,21 +77,21 @@ enum ComparisonOp:
77CountLiteral: 77CountLiteral:
78 modality=Modality? "count" atom=Atom op=ComparisonOp threshold=INT; 78 modality=Modality? "count" atom=Atom op=ComparisonOp threshold=INT;
79 79
80Action: 80//Action:
81 AssertionAction | DeleteAction | NewAction; 81// AssertionAction | DeleteAction | NewAction;
82 82//
83AssertionAction: 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//
87DeleteAction: 87//DeleteAction:
88 "delete" variableOrNode=[VariableOrNode|QualifiedName]; 88// "delete" variableOrNode=[VariableOrNode|QualifiedName];
89 89//
90NewAction: 90//NewAction:
91 "new" variable=NewVariable ("<:" parent=[VariableOrNode|QualifiedName])?; 91// "new" variable=NewVariable ("<:" parent=[VariableOrNode|QualifiedName])?;
92 92//
93NewVariable: 93//NewVariable:
94 name=Identifier; 94// name=Identifier;
95 95
96enum Modality: 96enum Modality:
97 MAY="may" | MUST="must" | CURRENT="current"; 97 MAY="may" | MUST="must" | CURRENT="current";
@@ -191,7 +191,7 @@ QualifiedName hidden():
191 191
192NonRelationKindIdentifier: 192NonRelationKindIdentifier:
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
197Identifier: 197Identifier:
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 @@
1package tools.refinery.language.utils; 1package tools.refinery.language.utils;
2 2
3import java.util.LinkedHashMap; 3import com.google.inject.Inject;
4import java.util.List;
5import java.util.Map;
6
7import org.eclipse.emf.ecore.EObject; 4import org.eclipse.emf.ecore.EObject;
8import org.eclipse.emf.ecore.util.EcoreUtil; 5import org.eclipse.emf.ecore.util.EcoreUtil;
9import org.eclipse.xtext.naming.IQualifiedNameConverter; 6import org.eclipse.xtext.naming.IQualifiedNameConverter;
10import org.eclipse.xtext.naming.IQualifiedNameProvider; 7import org.eclipse.xtext.naming.IQualifiedNameProvider;
8import tools.refinery.language.model.problem.*;
11 9
12import com.google.inject.Inject; 10import java.util.LinkedHashMap;
13 11import java.util.List;
14import tools.refinery.language.model.problem.Assertion; 12import java.util.Map;
15import tools.refinery.language.model.problem.ClassDeclaration;
16import tools.refinery.language.model.problem.ConstantAssertionArgument;
17import tools.refinery.language.model.problem.EnumDeclaration;
18import tools.refinery.language.model.problem.IndividualDeclaration;
19import tools.refinery.language.model.problem.IntConstant;
20import tools.refinery.language.model.problem.LogicValue;
21import tools.refinery.language.model.problem.Node;
22import tools.refinery.language.model.problem.NodeValueAssertion;
23import tools.refinery.language.model.problem.PredicateDefinition;
24import tools.refinery.language.model.problem.PredicateKind;
25import tools.refinery.language.model.problem.Problem;
26import tools.refinery.language.model.problem.ProblemFactory;
27import tools.refinery.language.model.problem.RealConstant;
28import tools.refinery.language.model.problem.Relation;
29import tools.refinery.language.model.problem.StringConstant;
30 13
31class SymbolCollector { 14class 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 }