aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/frontend/src
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2022-11-20 20:52:17 +0100
committerLibravatar Kristóf Marussy <kristof@marussy.com>2022-11-22 16:40:03 +0100
commit19d38b03de9af68e6234a2a07ac54c36d73edaa7 (patch)
treef6c402aa3610bdf66fb842e3b6206622eed8a2fd /subprojects/frontend/src
parentrefactor(test): WebSocket integ test robustness (diff)
downloadrefinery-19d38b03de9af68e6234a2a07ac54c36d73edaa7.tar.gz
refinery-19d38b03de9af68e6234a2a07ac54c36d73edaa7.tar.zst
refinery-19d38b03de9af68e6234a2a07ac54c36d73edaa7.zip
refactor(language): simplify syntax
Diffstat (limited to 'subprojects/frontend/src')
-rw-r--r--subprojects/frontend/src/index.tsx22
-rw-r--r--subprojects/frontend/src/language/problem.grammar17
-rw-r--r--subprojects/frontend/src/language/problemLanguageSupport.ts4
3 files changed, 24 insertions, 19 deletions
diff --git a/subprojects/frontend/src/index.tsx b/subprojects/frontend/src/index.tsx
index 0165d7c1..a40f1762 100644
--- a/subprojects/frontend/src/index.tsx
+++ b/subprojects/frontend/src/index.tsx
@@ -10,29 +10,29 @@ const initialValue = `class Family {
10} 10}
11 11
12class Person { 12class Person {
13 refers Person[] children opposite parent 13 Person[] children opposite parent
14 refers Person[0..1] parent opposite children 14 Person[0..1] parent opposite children
15 int age 15 int age
16 refers TaxStatus taxStatus 16 TaxStatus taxStatus
17} 17}
18 18
19enum TaxStatus { 19enum TaxStatus {
20 child, student, adult, retired 20 CHILD, STUDENT, ADULT, RETIRED
21} 21}
22 22
23% A child cannot have any dependents. 23% A child cannot have any dependents.
24pred invalidTaxStatus(Person p) <-> 24pred invalidTaxStatus(Person p) <->
25 taxStatus(p, child), 25 taxStatus(p, CHILD),
26 children(p, _q) 26 children(p, _q)
27; 27;
28 parent(p, q), 28 parent(p, q),
29 age(q) < age(p) 29 age(q) < age(p)
30; 30;
31 taxStatus(p, retired), 31 taxStatus(p, RETIRED),
32 parent(p, q), 32 parent(p, q),
33 !taxStatus(q, retired). 33 !taxStatus(q, RETIRED).
34 34
35individual family. 35indiv family.
36Family(family). 36Family(family).
37members(family, anne). 37members(family, anne).
38members(family, bob). 38members(family, bob).
@@ -40,9 +40,9 @@ members(family, ciri).
40children(anne, ciri). 40children(anne, ciri).
41?children(bob, ciri). 41?children(bob, ciri).
42default children(ciri, *): false. 42default children(ciri, *): false.
43taxStatus(anne, adult). 43taxStatus(anne, ADULT).
44age(bob) in 21..35. 44age(bob): 21..35.
45age(ciri) = 10. 45age(ciri): 10.
46 46
47scope Family = 1, Person += 5..10. 47scope Family = 1, Person += 5..10.
48`; 48`;
diff --git a/subprojects/frontend/src/language/problem.grammar b/subprojects/frontend/src/language/problem.grammar
index 7c4098d5..c2410913 100644
--- a/subprojects/frontend/src/language/problem.grammar
+++ b/subprojects/frontend/src/language/problem.grammar
@@ -3,6 +3,7 @@
3@external prop implicitCompletion from './props' 3@external prop implicitCompletion from './props'
4 4
5@precedence { 5@precedence {
6 reference @cut,
6 prefix, 7 prefix,
7 exponential @right, 8 exponential @right,
8 multiplicative @left, 9 multiplicative @left,
@@ -47,10 +48,10 @@ statement {
47 Assertion { 48 Assertion {
48 kw<"default">? (NotOp | UnknownOp)? RelationName 49 kw<"default">? (NotOp | UnknownOp)? RelationName
49 ParameterList<AssertionArgument> 50 ParameterList<AssertionArgument>
50 (":" LogicValue | ("=" | kw<"in">) Expr)? "." 51 (":" Expr)? "."
51 } | 52 } |
52 IndividualDeclaration { 53 IndividualDeclaration {
53 kw<"individual"> sep<",", IndividualNodeName> "." 54 kw<"indiv"> sep<",", IndividualNodeName> "."
54 } | 55 } |
55 ScopeDeclaration { 56 ScopeDeclaration {
56 kw<"scope"> sep<",", ScopeElement> "." 57 kw<"scope"> sep<",", ScopeElement> "."
@@ -58,7 +59,8 @@ statement {
58} 59}
59 60
60FeatureDeclaration { 61FeatureDeclaration {
61 (ReferenceKind | PrimitiveType | kw<"bool">) RelationName 62 // The @cut helps disambiguate silly cases like `contains contains`
63 (ReferenceKind !reference | PrimitiveType | kw<"bool">)? RelationName
62 ("[" Multiplicity? "]")? 64 ("[" Multiplicity? "]")?
63 RelationName 65 RelationName
64 (kw<"opposite"> RelationName)? 66 (kw<"opposite"> RelationName)?
@@ -90,7 +92,7 @@ BinaryExpr {
90} 92}
91 93
92UnaryExpr { 94UnaryExpr {
93 !prefix ("+" | "-" | "!" | "#" | Modality) Expr 95 !prefix ("+" | "-" | "!" | kw<"count"> | Modality) Expr
94} 96}
95 97
96Aggregation { 98Aggregation {
@@ -109,7 +111,7 @@ Atom { RelationName "+"? ParameterList<Expr> }
109 111
110AssertionArgument { NodeName | StarArgument } 112AssertionArgument { NodeName | StarArgument }
111 113
112Constant { Real | String | StarMult } 114Constant { Real | String | StarMult | LogicValue }
113 115
114ReferenceKind { 116ReferenceKind {
115 kw<"refers"> | ckw<"contains"> | kw<"container"> 117 kw<"refers"> | ckw<"contains"> | kw<"container">
@@ -199,7 +201,10 @@ sep1<separator, content> { content (separator content)* }
199 "\"" (![\\"\n] | "\\" (![\n] | "\n"))* "\"" 201 "\"" (![\\"\n] | "\\" (![\n] | "\n"))* "\""
200 } 202 }
201 203
202 SymbolicComparisonOp { ">" | ">=" | "<" | "<=" | "==" | "!=" } 204 SymbolicComparisonOp {
205 ">" | ">=" | "<" | "<=" | "==" | "!=" |
206 "<:" | ":>" | "===" | "!=="
207 }
203 208
204 NotOp { "!" } 209 NotOp { "!" }
205 210
diff --git a/subprojects/frontend/src/language/problemLanguageSupport.ts b/subprojects/frontend/src/language/problemLanguageSupport.ts
index 2a973c93..497030e2 100644
--- a/subprojects/frontend/src/language/problemLanguageSupport.ts
+++ b/subprojects/frontend/src/language/problemLanguageSupport.ts
@@ -21,12 +21,12 @@ const parserWithMetadata = parser.configure({
21 styleTags({ 21 styleTags({
22 LineComment: t.lineComment, 22 LineComment: t.lineComment,
23 BlockComment: t.blockComment, 23 BlockComment: t.blockComment,
24 'problem class enum pred individual scope': t.definitionKeyword, 24 'problem class enum pred indiv scope': t.definitionKeyword,
25 'abstract extends refers contains container opposite': t.modifier, 25 'abstract extends refers contains container opposite': t.modifier,
26 'default error contained containment': t.modifier, 26 'default error contained containment': t.modifier,
27 'true false unknown error': t.keyword, 27 'true false unknown error': t.keyword,
28 'int real string bool': t.keyword, 28 'int real string bool': t.keyword,
29 'may must current': t.operatorKeyword, 29 'may must current count': t.operatorKeyword,
30 'sum prod min max in': t.operatorKeyword, 30 'sum prod min max in': t.operatorKeyword,
31 // 'new delete': t.keyword, 31 // 'new delete': t.keyword,
32 NotOp: t.operator, 32 NotOp: t.operator,