From 6e76d732c5be554d1a24a2f19e550281153f07c2 Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Mon, 16 Oct 2023 00:18:08 +0200 Subject: 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. --- subprojects/frontend/src/language/problem.grammar | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'subprojects/frontend/src') 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 @@ @external prop implicitCompletion from './props' @precedence { - reference @cut, prefix, exponential @right, multiplicative @left, additive @left, range @left, lattice @left, - comparison @left + comparison @left, + feature @cut } @top Problem { statement* } @@ -65,8 +65,16 @@ statement { } FeatureDeclaration { - // The @cut helps disambiguate silly cases like `contains contains` - (ReferenceKind !reference | PrimitiveType | kw<"bool">)? RelationName + // Prefer parsing `contains` as a contextual keyword. + ( + FeatureDeclarationHeadWithKind[@dynamicPrecedence=1] { + ReferenceKind !feature ~featureHead + } | + FeatureDeclarationHeadWithoutKind { + (PrimitiveType | kw<"bool">)? ~featureHead + } + ) + RelationName ("[" Multiplicity? "]")? RelationName (kw<"opposite"> RelationName)? -- cgit v1.2.3-54-g00ecf