From c63126d2f1ce5f571c316b37e00fb43d2da7c7d3 Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Wed, 31 Jan 2024 02:00:09 +0100 Subject: refactor(language): module and node declarations * New default file extension: .refinery (.problem is also supported). * Add module keyword for self-contained modules. * Rename indiv declarations to atom declaration. * Add node and multi declarations for explicitly declared nodes and multi-objects, respectively. --- subprojects/frontend/src/editor/EditorTheme.ts | 2 +- subprojects/frontend/src/language/problem.grammar | 13 ++++++++----- subprojects/frontend/src/language/problemLanguageSupport.ts | 11 +++++++---- 3 files changed, 16 insertions(+), 10 deletions(-) (limited to 'subprojects/frontend/src') diff --git a/subprojects/frontend/src/editor/EditorTheme.ts b/subprojects/frontend/src/editor/EditorTheme.ts index 1cad4a36..f499b0d9 100644 --- a/subprojects/frontend/src/editor/EditorTheme.ts +++ b/subprojects/frontend/src/editor/EditorTheme.ts @@ -126,7 +126,7 @@ export default styled('div', { color: theme.palette.text.secondary, }, }, - '.tok-problem-individual': { + '.tok-problem-atom': { '&, & .tok-variableName': { color: theme.palette.text.primary, }, diff --git a/subprojects/frontend/src/language/problem.grammar b/subprojects/frontend/src/language/problem.grammar index ce3baa02..b08a9c36 100644 --- a/subprojects/frontend/src/language/problem.grammar +++ b/subprojects/frontend/src/language/problem.grammar @@ -28,7 +28,7 @@ statement { (":" Expr)? "." } | ProblemDeclaration { - kw<"problem"> QualifiedName "." + (ckw<"module"> | kw<"problem">) QualifiedName "." } | ClassDefinition { kw<"abstract">? kw<"class"> RelationName @@ -37,7 +37,7 @@ statement { } | EnumDefinition { kw<"enum"> RelationName - (EnumBody { "{" sep<",", IndividualNodeName> "}" } | ".") + (EnumBody { "{" sep<",", AtomNodeName> "}" } | ".") } | PredicateDefinition { ( @@ -56,8 +56,11 @@ statement { // RuleName ParameterList? // RuleBody { ":" sep "==>" sep "." } //} | - IndividualDeclaration { - kw<"indiv"> sep<",", IndividualNodeName> "." + AtomDeclaration { + ckw<"atom"> sep<",", AtomNodeName> "." + } | + NodeDeclaration { + (ckw<"node"> | ckw<"multi">) sep<",", NodeName> "." } | ScopeDeclaration { kw<"scope"> sep<",", ScopeElement> "." @@ -161,7 +164,7 @@ RelationName { QualifiedName ~name } //RuleName { QualifiedName } -IndividualNodeName { QualifiedName } +AtomNodeName { QualifiedName } VariableName[@dynamicPrecedence=10] { QualifiedName ~name } diff --git a/subprojects/frontend/src/language/problemLanguageSupport.ts b/subprojects/frontend/src/language/problemLanguageSupport.ts index 2121e05f..3847fdd8 100644 --- a/subprojects/frontend/src/language/problemLanguageSupport.ts +++ b/subprojects/frontend/src/language/problemLanguageSupport.ts @@ -27,7 +27,8 @@ const parserWithMetadata = parser.configure({ styleTags({ LineComment: t.lineComment, BlockComment: t.blockComment, - 'problem class enum pred fn indiv scope': t.definitionKeyword, + 'module problem class enum pred fn scope': t.definitionKeyword, + 'node atom multi': t.definitionKeyword, 'abstract extends refers contains container opposite': t.modifier, 'default error contained containment': t.modifier, 'true false unknown error': t.keyword, @@ -44,7 +45,7 @@ const parserWithMetadata = parser.configure({ String: t.string, 'RelationName/QualifiedName': t.typeName, // 'RuleName/QualifiedName': t.typeName, - 'IndividualNodeName/QualifiedName': t.atom, + 'AtomNodeName/QualifiedName': t.atom, 'VariableName/QualifiedName': t.variableName, '{ }': t.brace, '( )': t.paren, @@ -54,7 +55,8 @@ const parserWithMetadata = parser.configure({ }), indentNodeProp.add({ ProblemDeclaration: indentDeclaration, - UniqueDeclaration: indentDeclaration, + AtomDeclaration: indentDeclaration, + NodeDeclaration: indentDeclaration, ScopeDeclaration: indentDeclaration, PredicateBody: indentPredicateOrRule, FunctionBody: indentPredicateOrRule, @@ -70,7 +72,8 @@ const parserWithMetadata = parser.configure({ // RuleBody: foldInside, Conjunction: foldConjunction, // Consequent: foldWholeNode, - UniqueDeclaration: foldDeclaration, + AtomDeclaration: foldDeclaration, + NodeDeclaration: foldDeclaration, ScopeDeclaration: foldDeclaration, BlockComment: foldBlockComment, }), -- cgit v1.2.3-54-g00ecf