aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/frontend
diff options
context:
space:
mode:
Diffstat (limited to 'subprojects/frontend')
-rw-r--r--subprojects/frontend/src/language/folding.ts2
-rw-r--r--subprojects/frontend/src/language/problem.grammar44
-rw-r--r--subprojects/frontend/src/language/problemLanguageSupport.ts21
3 files changed, 45 insertions, 22 deletions
diff --git a/subprojects/frontend/src/language/folding.ts b/subprojects/frontend/src/language/folding.ts
index b4d4ca22..0afabfa0 100644
--- a/subprojects/frontend/src/language/folding.ts
+++ b/subprojects/frontend/src/language/folding.ts
@@ -109,7 +109,7 @@ function foldWithSibling(node: SyntaxNode): FoldRange | null {
109 return null; 109 return null;
110} 110}
111 111
112function foldWholeNode(node: SyntaxNode): FoldRange { 112export function foldWholeNode(node: SyntaxNode): FoldRange {
113 return { 113 return {
114 from: node.from, 114 from: node.from,
115 to: node.to, 115 to: node.to,
diff --git a/subprojects/frontend/src/language/problem.grammar b/subprojects/frontend/src/language/problem.grammar
index 7949f90c..0d3f0e3a 100644
--- a/subprojects/frontend/src/language/problem.grammar
+++ b/subprojects/frontend/src/language/problem.grammar
@@ -63,11 +63,11 @@ statement {
63 // kw<"fn"> RelationName RelationName ParameterList<Parameter>? 63 // kw<"fn"> RelationName RelationName ParameterList<Parameter>?
64 // FunctionBody { ("=" sep<OrOp, Case>)? "." } 64 // FunctionBody { ("=" sep<OrOp, Case>)? "." }
65 // } | 65 // } |
66 //RuleDefinition { 66 RuleDefinition {
67 // kw<"rule"> 67 (ckw<"decision"> | ckw<"propagation">)? kw<"rule">
68 // RuleName ParameterList<Parameter>? 68 RuleName ParameterList<Parameter>?
69 // RuleBody { ":" sep<OrOp, Conjunction> "==>" sep<OrOp, Consequent> "." } 69 RuleBody { ":" sep<OrOp, Conjunction> "==>" sep<OrOp, Consequent> "." }
70 //} | 70 } |
71 AtomDeclaration { 71 AtomDeclaration {
72 kw<"declare">? ckw<"atom"> sep<",", AtomNodeName> "." 72 kw<"declare">? ckw<"atom"> sep<",", AtomNodeName> "."
73 } | 73 } |
@@ -96,7 +96,12 @@ FeatureDeclaration {
96 ";"? 96 ";"?
97} 97}
98 98
99Parameter { RelationName? VariableName } 99Parameter {
100 kw<"candidate">? (kw<"may"> | kw<"must">)?
101 RelationName?
102 (AndBinding | StarBinding)?
103 VariableName
104}
100 105
101// Use @dynamicPrecedence to prevent a(b) from being parsed as Expr { a } Expr { b } 106// Use @dynamicPrecedence to prevent a(b) from being parsed as Expr { a } Expr { b }
102// instead of Atom { a(b) } 107// instead of Atom { a(b) }
@@ -125,7 +130,12 @@ BinaryExpr {
125} 130}
126 131
127UnaryExpr { 132UnaryExpr {
128 !prefix ("+" | "-" | "!" | kw<"count">) Expr 133 !prefix
134 (
135 "+" | "-" | "!" | kw<"count"> |
136 kw<"candidate"> | kw<"may"> | kw<"must">
137 )
138 Expr
129} 139}
130 140
131CastExpr { !cast Expr kw<"as"> DatatypeName } 141CastExpr { !cast Expr kw<"as"> DatatypeName }
@@ -136,16 +146,18 @@ Aggregation {
136 146
137Atom { RelationName "+"? ParameterList<Expr> } 147Atom { RelationName "+"? ParameterList<Expr> }
138 148
139//Consequent { ("," | Action)+ } 149Consequent { ("," | Action)+ }
140 150
141//Action { 151Action {
142// ckw<"new"> VariableName ("<:" VariableName)? | 152 (NotOp | UnknownOp)? RelationName
143// kw<"delete"> VariableName | 153 ParameterList<AssertionActionArgument>
144// Literal 154 (":" Expr)?
145//} 155}
146 156
147AssertionArgument { NodeName | StarArgument } 157AssertionArgument { NodeName | StarArgument }
148 158
159AssertionActionArgument { VariableName | StarArgument }
160
149Constant { Real | String | StarMult | LogicValue } 161Constant { Real | String | StarMult | LogicValue }
150 162
151ReferenceKind { 163ReferenceKind {
@@ -170,7 +182,7 @@ RelationName { QualifiedName ~name }
170 182
171DatatypeName { QualifiedName } 183DatatypeName { QualifiedName }
172 184
173//RuleName { QualifiedName } 185RuleName { QualifiedName }
174 186
175AtomNodeName { QualifiedName } 187AtomNodeName { QualifiedName }
176 188
@@ -247,5 +259,9 @@ sep1<separator, content> { content (separator content)* }
247 259
248 StarArgument { "*" } 260 StarArgument { "*" }
249 261
262 StarBinding { "*" }
263
264 AndBinding { "&" }
265
250 "{" "}" "(" ")" "[" "]" "." ".." "," ":" "->" "<->" "+" "-" "**" "=" "+=" 266 "{" "}" "(" ")" "[" "]" "." ".." "," ":" "->" "<->" "+" "-" "**" "=" "+="
251} 267}
diff --git a/subprojects/frontend/src/language/problemLanguageSupport.ts b/subprojects/frontend/src/language/problemLanguageSupport.ts
index dd5d6347..ae998d20 100644
--- a/subprojects/frontend/src/language/problemLanguageSupport.ts
+++ b/subprojects/frontend/src/language/problemLanguageSupport.ts
@@ -14,7 +14,12 @@ import {
14} from '@codemirror/language'; 14} from '@codemirror/language';
15import { styleTags, tags as t } from '@lezer/highlight'; 15import { styleTags, tags as t } from '@lezer/highlight';
16 16
17import { foldBlockComment, foldConjunction, foldDeclaration } from './folding'; 17import {
18 foldBlockComment,
19 foldConjunction,
20 foldDeclaration,
21 foldWholeNode,
22} from './folding';
18import { 23import {
19 indentBlockComment, 24 indentBlockComment,
20 indentDeclaration, 25 indentDeclaration,
@@ -30,11 +35,13 @@ const parserWithMetadata = parser.configure({
30 'module problem class enum pred fn scope': t.definitionKeyword, 35 'module problem class enum pred fn scope': t.definitionKeyword,
31 'import as declare atom multi': t.definitionKeyword, 36 'import as declare atom multi': t.definitionKeyword,
32 'extern datatype aggregator': t.definitionKeyword, 37 'extern datatype aggregator': t.definitionKeyword,
38 rule: t.definitionKeyword,
33 'abstract extends refers contains container opposite': t.modifier, 39 'abstract extends refers contains container opposite': t.modifier,
34 default: t.modifier, 40 default: t.modifier,
41 'propagation decision': t.modifier,
35 'true false unknown error': t.keyword, 42 'true false unknown error': t.keyword,
43 'candidate may must': t.operatorKeyword,
36 'count in is': t.operatorKeyword, 44 'count in is': t.operatorKeyword,
37 // 'new delete': t.keyword,
38 NotOp: t.operator, 45 NotOp: t.operator,
39 UnknownOp: t.operator, 46 UnknownOp: t.operator,
40 OrOp: t.separator, 47 OrOp: t.separator,
@@ -45,7 +52,7 @@ const parserWithMetadata = parser.configure({
45 'RelationName/QualifiedName': t.typeName, 52 'RelationName/QualifiedName': t.typeName,
46 'DatatypeName/QualifiedName': t.keyword, 53 'DatatypeName/QualifiedName': t.keyword,
47 'AggregatorName/QualifiedName': t.operatorKeyword, 54 'AggregatorName/QualifiedName': t.operatorKeyword,
48 // 'RuleName/QualifiedName': t.typeName, 55 'RuleName/QualifiedName': t.typeName,
49 'AtomNodeName/QualifiedName': t.atom, 56 'AtomNodeName/QualifiedName': t.atom,
50 'VariableName/QualifiedName': t.variableName, 57 'VariableName/QualifiedName': t.variableName,
51 'ModuleName/QualifiedName': t.typeName, 58 'ModuleName/QualifiedName': t.typeName,
@@ -62,7 +69,7 @@ const parserWithMetadata = parser.configure({
62 ScopeDeclaration: indentDeclaration, 69 ScopeDeclaration: indentDeclaration,
63 PredicateBody: indentPredicateOrRule, 70 PredicateBody: indentPredicateOrRule,
64 // FunctionBody: indentPredicateOrRule, 71 // FunctionBody: indentPredicateOrRule,
65 // RuleBody: indentPredicateOrRule, 72 RuleBody: indentPredicateOrRule,
66 BlockComment: indentBlockComment, 73 BlockComment: indentBlockComment,
67 }), 74 }),
68 foldNodeProp.add({ 75 foldNodeProp.add({
@@ -71,9 +78,9 @@ const parserWithMetadata = parser.configure({
71 ParameterList: foldInside, 78 ParameterList: foldInside,
72 PredicateBody: foldInside, 79 PredicateBody: foldInside,
73 // FunctionBody: foldInside, 80 // FunctionBody: foldInside,
74 // RuleBody: foldInside, 81 RuleBody: foldInside,
75 Conjunction: foldConjunction, 82 Conjunction: foldConjunction,
76 // Consequent: foldWholeNode, 83 Consequent: foldWholeNode,
77 AtomDeclaration: foldDeclaration, 84 AtomDeclaration: foldDeclaration,
78 NodeDeclaration: foldDeclaration, 85 NodeDeclaration: foldDeclaration,
79 ScopeDeclaration: foldDeclaration, 86 ScopeDeclaration: foldDeclaration,
@@ -92,7 +99,7 @@ const problemLanguage = LRLanguage.define({
92 }, 99 },
93 line: '%', 100 line: '%',
94 }, 101 },
95 indentOnInput: /^\s*(?:\{|\}|\(|\)|->|;|\.)$/, 102 indentOnInput: /^\s*(?:\{|\}|\(|\)|->|==>|;|\.)$/,
96 }, 103 },
97}); 104});
98 105