diff options
author | 2024-01-31 02:00:09 +0100 | |
---|---|---|
committer | 2024-01-31 18:45:13 +0100 | |
commit | c63126d2f1ce5f571c316b37e00fb43d2da7c7d3 (patch) | |
tree | 16e9dd04624565f7c9ccedd17749a9f264e89cb0 /subprojects/frontend | |
parent | fix(build): avoid cyclic dependency (diff) | |
download | refinery-c63126d2f1ce5f571c316b37e00fb43d2da7c7d3.tar.gz refinery-c63126d2f1ce5f571c316b37e00fb43d2da7c7d3.tar.zst refinery-c63126d2f1ce5f571c316b37e00fb43d2da7c7d3.zip |
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.
Diffstat (limited to 'subprojects/frontend')
-rw-r--r-- | subprojects/frontend/src/editor/EditorTheme.ts | 2 | ||||
-rw-r--r-- | subprojects/frontend/src/language/problem.grammar | 13 | ||||
-rw-r--r-- | subprojects/frontend/src/language/problemLanguageSupport.ts | 11 |
3 files changed, 16 insertions, 10 deletions
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', { | |||
126 | color: theme.palette.text.secondary, | 126 | color: theme.palette.text.secondary, |
127 | }, | 127 | }, |
128 | }, | 128 | }, |
129 | '.tok-problem-individual': { | 129 | '.tok-problem-atom': { |
130 | '&, & .tok-variableName': { | 130 | '&, & .tok-variableName': { |
131 | color: theme.palette.text.primary, | 131 | color: theme.palette.text.primary, |
132 | }, | 132 | }, |
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 { | |||
28 | (":" Expr)? "." | 28 | (":" Expr)? "." |
29 | } | | 29 | } | |
30 | ProblemDeclaration { | 30 | ProblemDeclaration { |
31 | kw<"problem"> QualifiedName "." | 31 | (ckw<"module"> | kw<"problem">) QualifiedName "." |
32 | } | | 32 | } | |
33 | ClassDefinition { | 33 | ClassDefinition { |
34 | kw<"abstract">? kw<"class"> RelationName | 34 | kw<"abstract">? kw<"class"> RelationName |
@@ -37,7 +37,7 @@ statement { | |||
37 | } | | 37 | } | |
38 | EnumDefinition { | 38 | EnumDefinition { |
39 | kw<"enum"> RelationName | 39 | kw<"enum"> RelationName |
40 | (EnumBody { "{" sep<",", IndividualNodeName> "}" } | ".") | 40 | (EnumBody { "{" sep<",", AtomNodeName> "}" } | ".") |
41 | } | | 41 | } | |
42 | PredicateDefinition { | 42 | PredicateDefinition { |
43 | ( | 43 | ( |
@@ -56,8 +56,11 @@ statement { | |||
56 | // RuleName ParameterList<Parameter>? | 56 | // RuleName ParameterList<Parameter>? |
57 | // RuleBody { ":" sep<OrOp, Conjunction> "==>" sep<OrOp, Consequent> "." } | 57 | // RuleBody { ":" sep<OrOp, Conjunction> "==>" sep<OrOp, Consequent> "." } |
58 | //} | | 58 | //} | |
59 | IndividualDeclaration { | 59 | AtomDeclaration { |
60 | kw<"indiv"> sep<",", IndividualNodeName> "." | 60 | ckw<"atom"> sep<",", AtomNodeName> "." |
61 | } | | ||
62 | NodeDeclaration { | ||
63 | (ckw<"node"> | ckw<"multi">) sep<",", NodeName> "." | ||
61 | } | | 64 | } | |
62 | ScopeDeclaration { | 65 | ScopeDeclaration { |
63 | kw<"scope"> sep<",", ScopeElement> "." | 66 | kw<"scope"> sep<",", ScopeElement> "." |
@@ -161,7 +164,7 @@ RelationName { QualifiedName ~name } | |||
161 | 164 | ||
162 | //RuleName { QualifiedName } | 165 | //RuleName { QualifiedName } |
163 | 166 | ||
164 | IndividualNodeName { QualifiedName } | 167 | AtomNodeName { QualifiedName } |
165 | 168 | ||
166 | VariableName[@dynamicPrecedence=10] { QualifiedName ~name } | 169 | VariableName[@dynamicPrecedence=10] { QualifiedName ~name } |
167 | 170 | ||
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({ | |||
27 | styleTags({ | 27 | styleTags({ |
28 | LineComment: t.lineComment, | 28 | LineComment: t.lineComment, |
29 | BlockComment: t.blockComment, | 29 | BlockComment: t.blockComment, |
30 | 'problem class enum pred fn indiv scope': t.definitionKeyword, | 30 | 'module problem class enum pred fn scope': t.definitionKeyword, |
31 | 'node atom multi': t.definitionKeyword, | ||
31 | 'abstract extends refers contains container opposite': t.modifier, | 32 | 'abstract extends refers contains container opposite': t.modifier, |
32 | 'default error contained containment': t.modifier, | 33 | 'default error contained containment': t.modifier, |
33 | 'true false unknown error': t.keyword, | 34 | 'true false unknown error': t.keyword, |
@@ -44,7 +45,7 @@ const parserWithMetadata = parser.configure({ | |||
44 | String: t.string, | 45 | String: t.string, |
45 | 'RelationName/QualifiedName': t.typeName, | 46 | 'RelationName/QualifiedName': t.typeName, |
46 | // 'RuleName/QualifiedName': t.typeName, | 47 | // 'RuleName/QualifiedName': t.typeName, |
47 | 'IndividualNodeName/QualifiedName': t.atom, | 48 | 'AtomNodeName/QualifiedName': t.atom, |
48 | 'VariableName/QualifiedName': t.variableName, | 49 | 'VariableName/QualifiedName': t.variableName, |
49 | '{ }': t.brace, | 50 | '{ }': t.brace, |
50 | '( )': t.paren, | 51 | '( )': t.paren, |
@@ -54,7 +55,8 @@ const parserWithMetadata = parser.configure({ | |||
54 | }), | 55 | }), |
55 | indentNodeProp.add({ | 56 | indentNodeProp.add({ |
56 | ProblemDeclaration: indentDeclaration, | 57 | ProblemDeclaration: indentDeclaration, |
57 | UniqueDeclaration: indentDeclaration, | 58 | AtomDeclaration: indentDeclaration, |
59 | NodeDeclaration: indentDeclaration, | ||
58 | ScopeDeclaration: indentDeclaration, | 60 | ScopeDeclaration: indentDeclaration, |
59 | PredicateBody: indentPredicateOrRule, | 61 | PredicateBody: indentPredicateOrRule, |
60 | FunctionBody: indentPredicateOrRule, | 62 | FunctionBody: indentPredicateOrRule, |
@@ -70,7 +72,8 @@ const parserWithMetadata = parser.configure({ | |||
70 | // RuleBody: foldInside, | 72 | // RuleBody: foldInside, |
71 | Conjunction: foldConjunction, | 73 | Conjunction: foldConjunction, |
72 | // Consequent: foldWholeNode, | 74 | // Consequent: foldWholeNode, |
73 | UniqueDeclaration: foldDeclaration, | 75 | AtomDeclaration: foldDeclaration, |
76 | NodeDeclaration: foldDeclaration, | ||
74 | ScopeDeclaration: foldDeclaration, | 77 | ScopeDeclaration: foldDeclaration, |
75 | BlockComment: foldBlockComment, | 78 | BlockComment: foldBlockComment, |
76 | }), | 79 | }), |