diff options
author | Kristóf Marussy <kristof@marussy.com> | 2024-02-29 02:24:06 +0100 |
---|---|---|
committer | Kristóf Marussy <kristof@marussy.com> | 2024-04-07 14:55:46 +0200 |
commit | 71fc54a96bf33dde7895ade0bd280887553125b0 (patch) | |
tree | 5b475f117ba9e999d9df8699d0bea77555e45bb5 /subprojects/frontend/src/language | |
parent | feat(query): left join for data variables (diff) | |
download | refinery-71fc54a96bf33dde7895ade0bd280887553125b0.tar.gz refinery-71fc54a96bf33dde7895ade0bd280887553125b0.tar.zst refinery-71fc54a96bf33dde7895ade0bd280887553125b0.zip |
refactor(language): assignment and cast expression
Also reorganizes operator names for easier future extension.
Diffstat (limited to 'subprojects/frontend/src/language')
-rw-r--r-- | subprojects/frontend/src/language/problem.grammar | 11 | ||||
-rw-r--r-- | subprojects/frontend/src/language/problemLanguageSupport.ts | 2 |
2 files changed, 10 insertions, 3 deletions
diff --git a/subprojects/frontend/src/language/problem.grammar b/subprojects/frontend/src/language/problem.grammar index 32f76f6a..0f6ea3e1 100644 --- a/subprojects/frontend/src/language/problem.grammar +++ b/subprojects/frontend/src/language/problem.grammar | |||
@@ -9,6 +9,7 @@ | |||
9 | @external prop implicitCompletion from './props' | 9 | @external prop implicitCompletion from './props' |
10 | 10 | ||
11 | @precedence { | 11 | @precedence { |
12 | cast, | ||
12 | prefix, | 13 | prefix, |
13 | exponential @right, | 14 | exponential @right, |
14 | multiplicative @left, | 15 | multiplicative @left, |
@@ -16,6 +17,7 @@ | |||
16 | range @left, | 17 | range @left, |
17 | lattice @left, | 18 | lattice @left, |
18 | comparison @left, | 19 | comparison @left, |
20 | assignment, | ||
19 | feature @cut | 21 | feature @cut |
20 | } | 22 | } |
21 | 23 | ||
@@ -97,14 +99,17 @@ Parameter { Modality? RelationName? VariableName } | |||
97 | // Being looser with token sequencing enables more consistent syntactic highlighting. | 99 | // Being looser with token sequencing enables more consistent syntactic highlighting. |
98 | Conjunction { ("," | NextConjunction[@dynamicPrecedence=-10] { Expr })+ } | 100 | Conjunction { ("," | NextConjunction[@dynamicPrecedence=-10] { Expr })+ } |
99 | 101 | ||
100 | Case { Conjunction ("->" Expr)? } | 102 | // Case { Conjunction ("->" Expr)? } |
101 | 103 | ||
102 | OrOp { ";" } | 104 | OrOp { ";" } |
103 | 105 | ||
104 | Expr { | 106 | Expr { |
105 | UnaryExpr | BinaryExpr | Aggregation | VariableName | Atom | Constant | "(" Expr ")" | 107 | AssignmentExpr | UnaryExpr | BinaryExpr | CastExpr | Aggregation | |
108 | VariableName | Atom | Constant | "(" Expr ")" | ||
106 | } | 109 | } |
107 | 110 | ||
111 | AssignmentExpr { !assignment VariableName kw<"is"> Expr } | ||
112 | |||
108 | BinaryExpr { | 113 | BinaryExpr { |
109 | Expr !comparison ComparisonOp Expr | | 114 | Expr !comparison ComparisonOp Expr | |
110 | Expr !lattice (LatticeMeet | "\\/") Expr | | 115 | Expr !lattice (LatticeMeet | "\\/") Expr | |
@@ -118,6 +123,8 @@ UnaryExpr { | |||
118 | !prefix ("+" | "-" | "!" | kw<"count"> | Modality) Expr | 123 | !prefix ("+" | "-" | "!" | kw<"count"> | Modality) Expr |
119 | } | 124 | } |
120 | 125 | ||
126 | CastExpr { !cast Expr kw<"as"> DatatypeName } | ||
127 | |||
121 | Aggregation { | 128 | Aggregation { |
122 | AggregationOp "{" Expr "|" Expr "}" | 129 | AggregationOp "{" Expr "|" Expr "}" |
123 | } | 130 | } |
diff --git a/subprojects/frontend/src/language/problemLanguageSupport.ts b/subprojects/frontend/src/language/problemLanguageSupport.ts index 9500fbf2..3d25d699 100644 --- a/subprojects/frontend/src/language/problemLanguageSupport.ts +++ b/subprojects/frontend/src/language/problemLanguageSupport.ts | |||
@@ -33,7 +33,7 @@ const parserWithMetadata = parser.configure({ | |||
33 | 'default error contained containment': t.modifier, | 33 | 'default error contained containment': t.modifier, |
34 | 'true false unknown error': t.keyword, | 34 | 'true false unknown error': t.keyword, |
35 | 'may must current count': t.operatorKeyword, | 35 | 'may must current count': t.operatorKeyword, |
36 | 'sum prod min max in': t.operatorKeyword, | 36 | 'sum prod min max in is': t.operatorKeyword, |
37 | // 'new delete': t.keyword, | 37 | // 'new delete': t.keyword, |
38 | NotOp: t.operator, | 38 | NotOp: t.operator, |
39 | UnknownOp: t.operator, | 39 | UnknownOp: t.operator, |