aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2023-10-16 00:18:08 +0200
committerLibravatar Kristóf Marussy <kristof@marussy.com>2023-10-16 00:18:08 +0200
commit6e76d732c5be554d1a24a2f19e550281153f07c2 (patch)
tree1155be610d5ff72e53ff8593d80a74717c756d11 /subprojects
parentMerge pull request #45 from kris7t/interpreter-communication-tracker (diff)
downloadrefinery-6e76d732c5be554d1a24a2f19e550281153f07c2.tar.gz
refinery-6e76d732c5be554d1a24a2f19e550281153f07c2.tar.zst
refinery-6e76d732c5be554d1a24a2f19e550281153f07c2.zip
fix(frontend): contains contextual keyword
Make sure contains is parsed as a contextual keyword whenever possible. The existing cut operator wasn't sufficient for this, so we also add dynamic precedence to the grammar rule.
Diffstat (limited to 'subprojects')
-rw-r--r--subprojects/frontend/src/language/problem.grammar16
1 files changed, 12 insertions, 4 deletions
diff --git a/subprojects/frontend/src/language/problem.grammar b/subprojects/frontend/src/language/problem.grammar
index a7b1fb0a..ce3baa02 100644
--- a/subprojects/frontend/src/language/problem.grammar
+++ b/subprojects/frontend/src/language/problem.grammar
@@ -9,14 +9,14 @@
9@external prop implicitCompletion from './props' 9@external prop implicitCompletion from './props'
10 10
11@precedence { 11@precedence {
12 reference @cut,
13 prefix, 12 prefix,
14 exponential @right, 13 exponential @right,
15 multiplicative @left, 14 multiplicative @left,
16 additive @left, 15 additive @left,
17 range @left, 16 range @left,
18 lattice @left, 17 lattice @left,
19 comparison @left 18 comparison @left,
19 feature @cut
20} 20}
21 21
22@top Problem { statement* } 22@top Problem { statement* }
@@ -65,8 +65,16 @@ statement {
65} 65}
66 66
67FeatureDeclaration { 67FeatureDeclaration {
68 // The @cut helps disambiguate silly cases like `contains contains` 68 // Prefer parsing `contains` as a contextual keyword.
69 (ReferenceKind !reference | PrimitiveType | kw<"bool">)? RelationName 69 (
70 FeatureDeclarationHeadWithKind[@dynamicPrecedence=1] {
71 ReferenceKind !feature ~featureHead
72 } |
73 FeatureDeclarationHeadWithoutKind {
74 (PrimitiveType | kw<"bool">)? ~featureHead
75 }
76 )
77 RelationName
70 ("[" Multiplicity? "]")? 78 ("[" Multiplicity? "]")?
71 RelationName 79 RelationName
72 (kw<"opposite"> RelationName)? 80 (kw<"opposite"> RelationName)?