diff options
Diffstat (limited to 'subprojects/frontend')
-rw-r--r-- | subprojects/frontend/src/index.tsx | 22 | ||||
-rw-r--r-- | subprojects/frontend/src/language/problem.grammar | 17 | ||||
-rw-r--r-- | subprojects/frontend/src/language/problemLanguageSupport.ts | 4 |
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 | ||
12 | class Person { | 12 | class 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 | ||
19 | enum TaxStatus { | 19 | enum 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. |
24 | pred invalidTaxStatus(Person p) <-> | 24 | pred 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 | ||
35 | individual family. | 35 | indiv family. |
36 | Family(family). | 36 | Family(family). |
37 | members(family, anne). | 37 | members(family, anne). |
38 | members(family, bob). | 38 | members(family, bob). |
@@ -40,9 +40,9 @@ members(family, ciri). | |||
40 | children(anne, ciri). | 40 | children(anne, ciri). |
41 | ?children(bob, ciri). | 41 | ?children(bob, ciri). |
42 | default children(ciri, *): false. | 42 | default children(ciri, *): false. |
43 | taxStatus(anne, adult). | 43 | taxStatus(anne, ADULT). |
44 | age(bob) in 21..35. | 44 | age(bob): 21..35. |
45 | age(ciri) = 10. | 45 | age(ciri): 10. |
46 | 46 | ||
47 | scope Family = 1, Person += 5..10. | 47 | scope 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 | ||
60 | FeatureDeclaration { | 61 | FeatureDeclaration { |
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 | ||
92 | UnaryExpr { | 94 | UnaryExpr { |
93 | !prefix ("+" | "-" | "!" | "#" | Modality) Expr | 95 | !prefix ("+" | "-" | "!" | kw<"count"> | Modality) Expr |
94 | } | 96 | } |
95 | 97 | ||
96 | Aggregation { | 98 | Aggregation { |
@@ -109,7 +111,7 @@ Atom { RelationName "+"? ParameterList<Expr> } | |||
109 | 111 | ||
110 | AssertionArgument { NodeName | StarArgument } | 112 | AssertionArgument { NodeName | StarArgument } |
111 | 113 | ||
112 | Constant { Real | String | StarMult } | 114 | Constant { Real | String | StarMult | LogicValue } |
113 | 115 | ||
114 | ReferenceKind { | 116 | ReferenceKind { |
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, |