diff options
author | 2023-10-16 00:18:08 +0200 | |
---|---|---|
committer | 2023-10-16 00:18:08 +0200 | |
commit | 6e76d732c5be554d1a24a2f19e550281153f07c2 (patch) | |
tree | 1155be610d5ff72e53ff8593d80a74717c756d11 /subprojects/frontend/src | |
parent | Merge pull request #45 from kris7t/interpreter-communication-tracker (diff) | |
download | refinery-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/frontend/src')
-rw-r--r-- | subprojects/frontend/src/language/problem.grammar | 16 |
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 | ||
67 | FeatureDeclaration { | 67 | FeatureDeclaration { |
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)? |