From 19d38b03de9af68e6234a2a07ac54c36d73edaa7 Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Sun, 20 Nov 2022 20:52:17 +0100 Subject: refactor(language): simplify syntax --- subprojects/frontend/src/language/problem.grammar | 17 +++++++++++------ .../frontend/src/language/problemLanguageSupport.ts | 4 ++-- 2 files changed, 13 insertions(+), 8 deletions(-) (limited to 'subprojects/frontend/src/language') 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 @@ @external prop implicitCompletion from './props' @precedence { + reference @cut, prefix, exponential @right, multiplicative @left, @@ -47,10 +48,10 @@ statement { Assertion { kw<"default">? (NotOp | UnknownOp)? RelationName ParameterList - (":" LogicValue | ("=" | kw<"in">) Expr)? "." + (":" Expr)? "." } | IndividualDeclaration { - kw<"individual"> sep<",", IndividualNodeName> "." + kw<"indiv"> sep<",", IndividualNodeName> "." } | ScopeDeclaration { kw<"scope"> sep<",", ScopeElement> "." @@ -58,7 +59,8 @@ statement { } FeatureDeclaration { - (ReferenceKind | PrimitiveType | kw<"bool">) RelationName + // The @cut helps disambiguate silly cases like `contains contains` + (ReferenceKind !reference | PrimitiveType | kw<"bool">)? RelationName ("[" Multiplicity? "]")? RelationName (kw<"opposite"> RelationName)? @@ -90,7 +92,7 @@ BinaryExpr { } UnaryExpr { - !prefix ("+" | "-" | "!" | "#" | Modality) Expr + !prefix ("+" | "-" | "!" | kw<"count"> | Modality) Expr } Aggregation { @@ -109,7 +111,7 @@ Atom { RelationName "+"? ParameterList } AssertionArgument { NodeName | StarArgument } -Constant { Real | String | StarMult } +Constant { Real | String | StarMult | LogicValue } ReferenceKind { kw<"refers"> | ckw<"contains"> | kw<"container"> @@ -199,7 +201,10 @@ sep1 { content (separator content)* } "\"" (![\\"\n] | "\\" (![\n] | "\n"))* "\"" } - SymbolicComparisonOp { ">" | ">=" | "<" | "<=" | "==" | "!=" } + SymbolicComparisonOp { + ">" | ">=" | "<" | "<=" | "==" | "!=" | + "<:" | ":>" | "===" | "!==" + } NotOp { "!" } 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({ styleTags({ LineComment: t.lineComment, BlockComment: t.blockComment, - 'problem class enum pred individual scope': t.definitionKeyword, + 'problem class enum pred indiv scope': t.definitionKeyword, 'abstract extends refers contains container opposite': t.modifier, 'default error contained containment': t.modifier, 'true false unknown error': t.keyword, 'int real string bool': t.keyword, - 'may must current': t.operatorKeyword, + 'may must current count': t.operatorKeyword, 'sum prod min max in': t.operatorKeyword, // 'new delete': t.keyword, NotOp: t.operator, -- cgit v1.2.3-54-g00ecf