@op-ted/efx-syntax-highlighter 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +286 -286
- package/README.md +77 -41
- package/dist/completion/CompletionItems.js +51 -0
- package/dist/completion/EfxCompletions.js +86 -0
- package/dist/completion/ExpectedTokens.js +64 -0
- package/dist/completion/Variables.js +60 -0
- package/dist/efx-parser.js +20 -12
- package/dist/efx-parser.terms.js +317 -45
- package/dist/efxHighlighting.js +82 -0
- package/dist/efxLanguage.js +29 -12
- package/dist/efxSymbols.js +12 -0
- package/dist/efxTheme.js +46 -104
- package/dist/generated/completions.js +2318 -0
- package/dist/generated/words.js +215 -0
- package/dist/index.js +5 -3
- package/dist/lexer/ExpressionMode.js +44 -0
- package/dist/lexer/FormatMode.js +31 -0
- package/dist/lexer/IdentifierMode.js +12 -0
- package/dist/lexer/LabelMode.js +27 -0
- package/dist/lexer/LexerContext.js +76 -0
- package/dist/lexer/LexerInput.js +188 -0
- package/dist/lexer/LexerMode.js +24 -0
- package/dist/lexer/LexerModes.js +50 -0
- package/dist/lexer/LineMode.js +85 -0
- package/dist/lexer/ReservedWords.js +75 -0
- package/dist/lexer/StageHeaderMode.js +12 -0
- package/dist/lexer/TemplateMode.js +77 -0
- package/dist/lexer/TemplateStartMode.js +25 -0
- package/package.json +63 -43
package/dist/efx-parser.terms.js
CHANGED
|
@@ -1,47 +1,319 @@
|
|
|
1
1
|
// This file was generated by lezer-generator. You probably shouldn't edit it.
|
|
2
2
|
export const
|
|
3
|
-
|
|
4
|
-
Comment =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
3
|
+
space = 394,
|
|
4
|
+
Comment = 1,
|
|
5
|
+
FreeText = 2,
|
|
6
|
+
AssetType = 3,
|
|
7
|
+
LabelType = 4,
|
|
8
|
+
OtherAssetId = 5,
|
|
9
|
+
Semicolon = 6,
|
|
10
|
+
FormatShort = 7,
|
|
11
|
+
FormatMedium = 8,
|
|
12
|
+
FormatLong = 9,
|
|
13
|
+
FormatNoUnit = 10,
|
|
14
|
+
FormatNoFormatting = 11,
|
|
15
|
+
With = 12,
|
|
16
|
+
Compute = 13,
|
|
17
|
+
Select = 14,
|
|
18
|
+
Let = 15,
|
|
19
|
+
When = 16,
|
|
20
|
+
Otherwise = 17,
|
|
21
|
+
Display = 18,
|
|
22
|
+
Invoke = 19,
|
|
23
|
+
Index = 20,
|
|
24
|
+
By = 21,
|
|
25
|
+
Template = 22,
|
|
26
|
+
Dynamic = 23,
|
|
27
|
+
And = 24,
|
|
28
|
+
Or = 25,
|
|
29
|
+
Is = 26,
|
|
30
|
+
In = 27,
|
|
31
|
+
Like = 28,
|
|
32
|
+
Present = 29,
|
|
33
|
+
Empty = 30,
|
|
34
|
+
Unique = 31,
|
|
35
|
+
Has = 32,
|
|
36
|
+
No = 33,
|
|
37
|
+
Duplicates = 34,
|
|
38
|
+
Every = 35,
|
|
39
|
+
Some = 36,
|
|
40
|
+
Satisfies = 37,
|
|
41
|
+
If = 38,
|
|
42
|
+
Then = 39,
|
|
43
|
+
Else = 40,
|
|
44
|
+
For = 41,
|
|
45
|
+
Return = 42,
|
|
46
|
+
Distinct = 43,
|
|
47
|
+
Always = 44,
|
|
48
|
+
Never = 45,
|
|
49
|
+
True = 46,
|
|
50
|
+
False = 47,
|
|
51
|
+
At = 48,
|
|
52
|
+
AT = 49,
|
|
53
|
+
EVERY = 50,
|
|
54
|
+
Not = 51,
|
|
55
|
+
Text = 52,
|
|
56
|
+
Number = 53,
|
|
57
|
+
Indicator = 54,
|
|
58
|
+
Date = 55,
|
|
59
|
+
Time = 56,
|
|
60
|
+
Duration = 57,
|
|
61
|
+
ContextType = 58,
|
|
62
|
+
CountFunction = 59,
|
|
63
|
+
SubstringFunction = 60,
|
|
64
|
+
SubstringBeforeFunction = 61,
|
|
65
|
+
SubstringAfterFunction = 62,
|
|
66
|
+
ContainsFunction = 63,
|
|
67
|
+
StartsWithFunction = 64,
|
|
68
|
+
EndsWithFunction = 65,
|
|
69
|
+
StringLengthFunction = 66,
|
|
70
|
+
IndexOfSubstringFunction = 67,
|
|
71
|
+
SumFunction = 68,
|
|
72
|
+
MinFunction = 69,
|
|
73
|
+
MaxFunction = 70,
|
|
74
|
+
AverageFunction = 71,
|
|
75
|
+
AbsoluteFunction = 72,
|
|
76
|
+
RoundFunction = 73,
|
|
77
|
+
RoundDownFunction = 74,
|
|
78
|
+
RoundUpFunction = 75,
|
|
79
|
+
YearFunction = 76,
|
|
80
|
+
MonthFunction = 77,
|
|
81
|
+
DayFunction = 78,
|
|
82
|
+
HoursFunction = 79,
|
|
83
|
+
MinutesFunction = 80,
|
|
84
|
+
SecondsFunction = 81,
|
|
85
|
+
YearsFunction = 82,
|
|
86
|
+
MonthsFunction = 83,
|
|
87
|
+
DaysFunction = 84,
|
|
88
|
+
FormatNumberFunction = 85,
|
|
89
|
+
FormatShortFunction = 86,
|
|
90
|
+
FormatMediumFunction = 87,
|
|
91
|
+
FormatLongFunction = 88,
|
|
92
|
+
UpperCaseFunction = 89,
|
|
93
|
+
LowerCaseFunction = 90,
|
|
94
|
+
NormalizeSpaceFunction = 91,
|
|
95
|
+
TrimFunction = 92,
|
|
96
|
+
TrimLeftFunction = 93,
|
|
97
|
+
TrimRightFunction = 94,
|
|
98
|
+
PadLeftFunction = 95,
|
|
99
|
+
PadRightFunction = 96,
|
|
100
|
+
RepeatFunction = 97,
|
|
101
|
+
ReplaceFunction = 98,
|
|
102
|
+
ReplaceRegexFunction = 99,
|
|
103
|
+
UrlEncodeFunction = 100,
|
|
104
|
+
CapitalizeFirstFunction = 101,
|
|
105
|
+
ConcatFunction = 102,
|
|
106
|
+
StringJoinFunction = 103,
|
|
107
|
+
CurrentDateFunction = 104,
|
|
108
|
+
CurrentTimeFunction = 105,
|
|
109
|
+
DayTimeDurationFunction = 106,
|
|
110
|
+
YearMonthDurationFunction = 107,
|
|
111
|
+
AddDurationFunction = 108,
|
|
112
|
+
SubtractDurationFunction = 109,
|
|
113
|
+
DistinctValuesFunction = 110,
|
|
114
|
+
CountDuplicatesFunction = 111,
|
|
115
|
+
GetDuplicatesFunction = 112,
|
|
116
|
+
ValueUnionFunction = 113,
|
|
117
|
+
ValueIntersectFunction = 114,
|
|
118
|
+
ValueExceptFunction = 115,
|
|
119
|
+
SequenceEqualFunction = 116,
|
|
120
|
+
SortFunction = 117,
|
|
121
|
+
ReverseFunction = 118,
|
|
122
|
+
SubsequenceFunction = 119,
|
|
123
|
+
IndexOfFunction = 120,
|
|
124
|
+
PreferredLanguageFunction = 121,
|
|
125
|
+
PreferredLanguageTextFunction = 122,
|
|
126
|
+
SplitFunction = 123,
|
|
127
|
+
Endpoint = 124,
|
|
128
|
+
Call = 125,
|
|
129
|
+
Api = 126,
|
|
130
|
+
On = 127,
|
|
131
|
+
Warn = 128,
|
|
132
|
+
Reject = 129,
|
|
133
|
+
Error = 130,
|
|
134
|
+
Warning = 131,
|
|
135
|
+
Info = 132,
|
|
136
|
+
Assert = 133,
|
|
137
|
+
Report = 134,
|
|
138
|
+
OtherwiseAssert = 135,
|
|
139
|
+
OtherwiseReport = 136,
|
|
140
|
+
As = 137,
|
|
141
|
+
FOR = 138,
|
|
142
|
+
IN = 139,
|
|
143
|
+
Any = 140,
|
|
144
|
+
Scope = 141,
|
|
145
|
+
IncludeDirective = 142,
|
|
146
|
+
AttributeSlash = 143,
|
|
147
|
+
PublicationDate = 144,
|
|
148
|
+
JustificationCode = 145,
|
|
149
|
+
JustificationDescription = 146,
|
|
150
|
+
PrivacyCode = 147,
|
|
151
|
+
WasWithheld = 148,
|
|
152
|
+
IsWithheld = 149,
|
|
153
|
+
IsWithholdable = 150,
|
|
154
|
+
IsDisclosed = 151,
|
|
155
|
+
IsMasked = 152,
|
|
156
|
+
RawValue = 153,
|
|
157
|
+
PreferredLanguage = 154,
|
|
158
|
+
PreferredLanguageText = 155,
|
|
159
|
+
TemplateFile = 156,
|
|
160
|
+
IncludePath = 157,
|
|
161
|
+
GlobalDeclaration = 158,
|
|
162
|
+
VariableDeclaration = 159,
|
|
163
|
+
TypeDeclaration = 161,
|
|
164
|
+
PrimitiveType = 162,
|
|
165
|
+
Star = 163,
|
|
166
|
+
Colon = 164,
|
|
167
|
+
VariablePrefix = 165,
|
|
168
|
+
UnquotedIdentifier = 166,
|
|
169
|
+
Assignment = 167,
|
|
170
|
+
CloseParenthesis = 168,
|
|
171
|
+
OpenParenthesis = 169,
|
|
172
|
+
CloseBracket = 171,
|
|
173
|
+
OpenBracket = 173,
|
|
174
|
+
AtPrefix = 176,
|
|
175
|
+
ColonColon = 178,
|
|
176
|
+
LinkedFieldReference = 179,
|
|
177
|
+
SimpleFieldReference = 180,
|
|
178
|
+
FieldId = 181,
|
|
179
|
+
Identifier = 182,
|
|
180
|
+
LinkedFieldProperty = 183,
|
|
181
|
+
SimpleNodeReference = 185,
|
|
182
|
+
NodeId = 186,
|
|
183
|
+
Slash = 191,
|
|
184
|
+
Percent = 192,
|
|
185
|
+
Plus = 194,
|
|
186
|
+
Minus = 195,
|
|
187
|
+
StringLiteral = 201,
|
|
188
|
+
Comparison = 204,
|
|
189
|
+
IteratorList = 209,
|
|
190
|
+
AbsoluteFieldReference = 213,
|
|
191
|
+
ContextBracket = 214,
|
|
192
|
+
Predicate = 215,
|
|
193
|
+
AbsoluteNodeReference = 217,
|
|
194
|
+
Comma = 218,
|
|
195
|
+
Literal = 222,
|
|
196
|
+
UuidV4Literal = 223,
|
|
197
|
+
NumericLiteral = 224,
|
|
198
|
+
IntegerLiteral = 225,
|
|
199
|
+
DecimalLiteral = 226,
|
|
200
|
+
BooleanLiteral = 227,
|
|
201
|
+
TrueBooleanLiteral = 228,
|
|
202
|
+
FalseBooleanLiteral = 229,
|
|
203
|
+
DateLiteral = 230,
|
|
204
|
+
TimeLiteral = 231,
|
|
205
|
+
DurationLiteral = 232,
|
|
206
|
+
DayTimeDurationLiteral = 233,
|
|
207
|
+
YearMonthDurationLiteral = 234,
|
|
208
|
+
Reference = 236,
|
|
209
|
+
FieldReference = 237,
|
|
210
|
+
NodeReference = 238,
|
|
211
|
+
VariableReference = 239,
|
|
212
|
+
FunctionPrefix = 240,
|
|
213
|
+
FunctionInvocation = 241,
|
|
214
|
+
ArgumentList = 242,
|
|
215
|
+
Argument = 243,
|
|
216
|
+
FieldMention = 246,
|
|
217
|
+
CodelistReference = 253,
|
|
218
|
+
Ellipsis = 254,
|
|
219
|
+
HashPrefix = 255,
|
|
220
|
+
BuiltInFunction = 257,
|
|
221
|
+
DynamicFunctionInvocation = 259,
|
|
222
|
+
DictionaryDeclaration = 260,
|
|
223
|
+
DictionaryIndexClause = 261,
|
|
224
|
+
DictionaryKeyClause = 262,
|
|
225
|
+
FunctionDeclaration = 263,
|
|
226
|
+
ParameterList = 264,
|
|
227
|
+
ParameterDeclaration = 265,
|
|
228
|
+
TemplateDeclaration = 266,
|
|
229
|
+
Indentation = 267,
|
|
230
|
+
Tabs = 268,
|
|
231
|
+
Spaces = 269,
|
|
232
|
+
MixedIndent = 270,
|
|
233
|
+
TemplateDefinition = 271,
|
|
234
|
+
ChooseTemplate = 272,
|
|
235
|
+
WhenBlock = 273,
|
|
236
|
+
WhenDisplayTemplate = 274,
|
|
237
|
+
DisplayTemplate = 275,
|
|
238
|
+
LineBreak = 277,
|
|
239
|
+
NewLine = 278,
|
|
240
|
+
TextBlock = 280,
|
|
241
|
+
Whitespace = 281,
|
|
242
|
+
OtherEscapeSequence = 282,
|
|
243
|
+
CharacterReference = 283,
|
|
244
|
+
EndBlock = 284,
|
|
245
|
+
LinkBlock = 285,
|
|
246
|
+
StartHyperlinkBlock = 286,
|
|
247
|
+
StartLabelBlock = 288,
|
|
248
|
+
Pipe = 291,
|
|
249
|
+
ExpressionBlock = 292,
|
|
250
|
+
StandardExpressionBlock = 293,
|
|
251
|
+
StartExpressionBlock = 294,
|
|
252
|
+
ShorthandFieldValueReferenceFromContextField = 295,
|
|
253
|
+
AssetId = 296,
|
|
254
|
+
BtId = 297,
|
|
255
|
+
Pluraliser = 302,
|
|
256
|
+
sharpValue = 304,
|
|
257
|
+
FormatOptions = 307,
|
|
258
|
+
FormatDecimals = 308,
|
|
259
|
+
FormatStyle = 309,
|
|
260
|
+
WhenInvokeTemplate = 312,
|
|
261
|
+
InvokeTemplate = 313,
|
|
262
|
+
OtherwiseBlock = 314,
|
|
263
|
+
OtherwiseDisplayTemplate = 315,
|
|
264
|
+
OtherwiseInvokeTemplate = 316,
|
|
265
|
+
TemplateLine = 317,
|
|
266
|
+
OutlineNumber = 318,
|
|
267
|
+
ContextDeclarationBlock = 319,
|
|
268
|
+
VariableList = 320,
|
|
269
|
+
ContextDeclaration = 321,
|
|
270
|
+
ContextVariableInitializer = 322,
|
|
271
|
+
Dot = 323,
|
|
272
|
+
DotDot = 324,
|
|
273
|
+
StartContextBlock = 325,
|
|
274
|
+
CRLF = 326,
|
|
275
|
+
OtherSections = 327,
|
|
276
|
+
NavigationSection = 328,
|
|
277
|
+
NavigationSectionHeader = 329,
|
|
278
|
+
SummarySection = 330,
|
|
279
|
+
SummarySectionHeader = 331,
|
|
280
|
+
RulesFile = 332,
|
|
281
|
+
ApiEndpointDeclaration = 333,
|
|
282
|
+
DynamicFunctionDeclaration = 334,
|
|
283
|
+
OnErrorClause = 335,
|
|
284
|
+
GlobalVariableDeclaration = 336,
|
|
285
|
+
ValidationStage = 337,
|
|
286
|
+
StageHeaderStart = 338,
|
|
287
|
+
StageIdentifier = 339,
|
|
288
|
+
StageHeaderEnd = 340,
|
|
289
|
+
StageVariableDeclaration = 341,
|
|
290
|
+
RuleSet = 342,
|
|
291
|
+
WithClause = 343,
|
|
292
|
+
Rules = 344,
|
|
293
|
+
ConditionalRule = 345,
|
|
294
|
+
WhenClause = 346,
|
|
295
|
+
AssertClause = 347,
|
|
296
|
+
ReportClause = 348,
|
|
297
|
+
AsClause = 349,
|
|
298
|
+
Severity = 350,
|
|
299
|
+
RuleId = 351,
|
|
300
|
+
RuleIdentifier = 352,
|
|
301
|
+
ForClause = 353,
|
|
302
|
+
InClause = 354,
|
|
303
|
+
NoticeTypeRange = 357,
|
|
304
|
+
NoticeType = 358,
|
|
305
|
+
ScopeClause = 359,
|
|
306
|
+
ScopeAnnotation = 360,
|
|
307
|
+
Pre = 361,
|
|
308
|
+
Post = 362,
|
|
309
|
+
Flag = 363,
|
|
310
|
+
SimpleRule = 364,
|
|
311
|
+
ConditionalRules = 365,
|
|
312
|
+
FallbackRule = 366,
|
|
313
|
+
OtherwiseAssertClause = 367,
|
|
314
|
+
OtherwiseReportClause = 368,
|
|
315
|
+
SingleExpression = 369,
|
|
316
|
+
StartSelectorBlock = 370,
|
|
317
|
+
SelectorBlock = 371,
|
|
318
|
+
Selection = 372,
|
|
319
|
+
AttributeReference = 373
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// The highlight tags of the grammar: which tag each kind of node carries, read by the parser
|
|
2
|
+
// (grammar/efx.grammar, @external propSource). The colours of the tags are in efxTheme.js.
|
|
3
|
+
import { styleTags, tags as t } from "@lezer/highlight";
|
|
4
|
+
|
|
5
|
+
// The highlight tag of each kind of node of the grammar (grammar/efx.grammar), named by the node or by
|
|
6
|
+
// the node and its parent (Parent/Node). A node that is not listed is plain text.
|
|
7
|
+
export const EFX_STYLES = {
|
|
8
|
+
// The words that start a line, a part of a line or a clause of a rule, and the headers.
|
|
9
|
+
"Let With EVERY When Otherwise Display Invoke Index By Compute Select": t.keyword,
|
|
10
|
+
"Endpoint AT Call Api On OnErrorClause/Error": t.keyword,
|
|
11
|
+
"Assert Report OtherwiseAssert OtherwiseReport As FOR IN Scope": t.keyword,
|
|
12
|
+
"IncludeDirective SummarySectionHeader NavigationSectionHeader StageHeaderStart StageHeaderEnd": t.keyword,
|
|
13
|
+
|
|
14
|
+
// The words of expressions.
|
|
15
|
+
"And Or Not Is In Like Present Empty Unique Has No Duplicates Every Some Satisfies If Then Else For Return": t.className,
|
|
16
|
+
"Distinct At": t.className,
|
|
17
|
+
// The words chosen from a fixed list: asset and label types, format options, field properties,
|
|
18
|
+
// severities, what a failed call does, any notice type and the scope annotations.
|
|
19
|
+
"AssetType LabelType FormatDecimals FormatShort FormatMedium FormatLong FormatNoUnit FormatNoFormatting": t.className,
|
|
20
|
+
"PublicationDate JustificationCode JustificationDescription WasWithheld IsWithheld IsWithholdable IsDisclosed": t.className,
|
|
21
|
+
"IsMasked PrivacyCode RawValue PreferredLanguage PreferredLanguageText": t.className,
|
|
22
|
+
"Error Warning Info Warn Reject Any AnyNoticeTypes/Star Pre Post": t.className,
|
|
23
|
+
|
|
24
|
+
// Types, with the colon after them in a declaration.
|
|
25
|
+
"Text Number Indicator Date Time Duration ContextType Template Dynamic TypeDeclaration/Star": t.typeName,
|
|
26
|
+
"TypedVariableInitializer/Colon DynamicVariableInitializer/Colon ContextVariableInitializer/Colon": t.typeName,
|
|
27
|
+
"ParameterDeclaration/Colon ValueIterator/Colon ContextIterator/Colon": t.typeName,
|
|
28
|
+
"FunctionDeclaration/Colon DynamicFunctionDeclaration/Colon TemplateDefinition/Colon": t.typeName,
|
|
29
|
+
|
|
30
|
+
// The built-in functions.
|
|
31
|
+
"BuiltInFunction/Not BuiltInFunction/Indicator BuiltInFunction/Empty BuiltInFunction/Number": t.function(t.keyword),
|
|
32
|
+
"BuiltInFunction/Text BuiltInFunction/Date BuiltInFunction/Time": t.function(t.keyword),
|
|
33
|
+
"CountFunction SubstringFunction SubstringBeforeFunction SubstringAfterFunction ContainsFunction": t.function(t.keyword),
|
|
34
|
+
"StartsWithFunction EndsWithFunction StringLengthFunction IndexOfSubstringFunction SumFunction": t.function(t.keyword),
|
|
35
|
+
"MinFunction MaxFunction AverageFunction AbsoluteFunction RoundFunction RoundDownFunction": t.function(t.keyword),
|
|
36
|
+
"RoundUpFunction YearFunction MonthFunction DayFunction HoursFunction MinutesFunction SecondsFunction": t.function(t.keyword),
|
|
37
|
+
"YearsFunction MonthsFunction DaysFunction FormatNumberFunction FormatShortFunction FormatMediumFunction": t.function(t.keyword),
|
|
38
|
+
"FormatLongFunction UpperCaseFunction LowerCaseFunction NormalizeSpaceFunction TrimFunction": t.function(t.keyword),
|
|
39
|
+
"TrimLeftFunction TrimRightFunction PadLeftFunction PadRightFunction RepeatFunction ReplaceFunction": t.function(t.keyword),
|
|
40
|
+
"ReplaceRegexFunction UrlEncodeFunction CapitalizeFirstFunction ConcatFunction StringJoinFunction": t.function(t.keyword),
|
|
41
|
+
"CurrentDateFunction CurrentTimeFunction DayTimeDurationFunction YearMonthDurationFunction": t.function(t.keyword),
|
|
42
|
+
"AddDurationFunction SubtractDurationFunction DistinctValuesFunction CountDuplicatesFunction": t.function(t.keyword),
|
|
43
|
+
"GetDuplicatesFunction ValueUnionFunction ValueIntersectFunction ValueExceptFunction SequenceEqualFunction": t.function(t.keyword),
|
|
44
|
+
"SubsequenceFunction IndexOfFunction PreferredLanguageFunction PreferredLanguageTextFunction": t.function(t.keyword),
|
|
45
|
+
"SortFunction ReverseFunction SplitFunction": t.function(t.keyword),
|
|
46
|
+
|
|
47
|
+
// Literals, and the notice types of a rule and the path of an include.
|
|
48
|
+
"StringLiteral UuidV4Literal IntegerLiteral DecimalLiteral True False Always Never DateLiteral TimeLiteral": t.literal,
|
|
49
|
+
"DayTimeDurationLiteral YearMonthDurationLiteral NumericLiteral/Minus NoticeType/Identifier NoticeTypeRange/Minus": t.literal,
|
|
50
|
+
IncludePath: t.literal,
|
|
51
|
+
|
|
52
|
+
// The data of a notice: fields, nodes and attributes.
|
|
53
|
+
"FieldId NodeId BtId SimpleFieldReference/Identifier FieldMention/Identifier SingleExpression/Identifier": t.propertyName,
|
|
54
|
+
"AttributeReference/AtPrefix AttributeReference/Identifier": t.propertyName,
|
|
55
|
+
"AttributeExpression/AtPrefix AttributeExpression/Identifier": t.propertyName,
|
|
56
|
+
|
|
57
|
+
// Variables, and the field value and label of the context in a template.
|
|
58
|
+
"VariablePrefix VariableReference/Identifier TypedVariableInitializer/Identifier": t.variableName,
|
|
59
|
+
"DynamicVariableInitializer/Identifier ContextVariableInitializer/Identifier ParameterDeclaration/Identifier": t.variableName,
|
|
60
|
+
"ValueIterator/Identifier ContextIterator/Identifier DictionaryDeclaration/Identifier": t.variableName,
|
|
61
|
+
"ShorthandFieldValueReferenceFromContextField ShorthandIndirectLabelReferenceFromContextField": t.variableName,
|
|
62
|
+
|
|
63
|
+
// Functions and templates that a file declares.
|
|
64
|
+
"FunctionPrefix FunctionInvocation/Identifier FunctionDeclaration/Identifier": t.function(t.name),
|
|
65
|
+
"DynamicFunctionDeclaration/Identifier TemplateDefinition/Identifier InvokeTemplate/Identifier": t.function(t.name),
|
|
66
|
+
|
|
67
|
+
// Names of assets: asset ids in a label, codelists, flags, rules and stages.
|
|
68
|
+
"OtherAssetId AssetId/AssetType AssetId/LabelType RuleIdentifier StageIdentifier": t.special(t.name),
|
|
69
|
+
"CodelistReference/HashPrefix CodelistReference/Identifier Flag/HashPrefix Flag/Identifier": t.special(t.name),
|
|
70
|
+
|
|
71
|
+
// Template text.
|
|
72
|
+
"FreeText OtherEscapeSequence CharacterReference NewLine": t.special(t.string),
|
|
73
|
+
|
|
74
|
+
"Assignment Comparison Plus Minus Star Slash Percent ColonColon": t.operator,
|
|
75
|
+
"OpenParenthesis CloseParenthesis OpenBracket CloseBracket Pipe Colon Dot DotDot Ellipsis": t.punctuation,
|
|
76
|
+
"AttributeReference/Slash AttributeExpression/Slash": t.punctuation,
|
|
77
|
+
"StartContextBlock StartExpressionBlock StartLabelBlock StartHyperlinkBlock StartSelectorBlock EndBlock": t.bracket,
|
|
78
|
+
Comment: t.lineComment,
|
|
79
|
+
Identifier: t.name,
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const efxHighlighting = styleTags(EFX_STYLES);
|
package/dist/efxLanguage.js
CHANGED
|
@@ -1,12 +1,29 @@
|
|
|
1
|
-
// CodeMirror 6 language support for
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
1
|
+
// CodeMirror 6 language support for EFX. The grammar reads three kinds of EFX text, each from a top
|
|
2
|
+
// of its own; an editor holds one kind, so there is one language per kind. The parser carries the
|
|
3
|
+
// highlight tags (efxHighlighting.js); the EFX colours are the editor's default colours. The
|
|
4
|
+
// language offers its completions (completion/EfxCompletions.js) to the editor's autocompletion,
|
|
5
|
+
// which the application turns on.
|
|
6
|
+
import { LRLanguage, LanguageSupport, syntaxHighlighting } from "@codemirror/language";
|
|
7
|
+
import { EfxCompletions } from "./completion/EfxCompletions.js";
|
|
8
|
+
import { parser } from "./efx-parser.js";
|
|
9
|
+
import { efxHighlightStyle } from "./efxTheme.js";
|
|
10
|
+
|
|
11
|
+
// The top of the grammar that reads each kind of EFX text.
|
|
12
|
+
const TOPS = { template: "TemplateFile", rules: "RulesFile", expression: "SingleExpression" };
|
|
13
|
+
|
|
14
|
+
const LANGUAGES = new Map(Object.entries(TOPS).map(([kind, top]) =>
|
|
15
|
+
[kind, LRLanguage.define({ name: "efx", parser: parser.configure({ top }) })]));
|
|
16
|
+
|
|
17
|
+
// The EFX colours, used where the application gives the editor no colours of its own.
|
|
18
|
+
const DEFAULT_COLOURS = syntaxHighlighting(efxHighlightStyle, { fallback: true });
|
|
19
|
+
|
|
20
|
+
/** EFX support for an editor that holds one kind of EFX text: "template", "rules" or "expression". */
|
|
21
|
+
export function efx(kind) {
|
|
22
|
+
const language = LANGUAGES.get(kind);
|
|
23
|
+
if (language === undefined) {
|
|
24
|
+
throw new RangeError(`Unknown kind of EFX text: ${kind}. The kinds are ${[...LANGUAGES.keys()].join(", ")}.`);
|
|
25
|
+
}
|
|
26
|
+
const completions = new EfxCompletions(language.parser);
|
|
27
|
+
const autocomplete = language.data.of({ autocomplete: (context) => completions.complete(context) });
|
|
28
|
+
return new LanguageSupport(language, [DEFAULT_COLOURS, autocomplete]);
|
|
29
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// The field and node ids an application gives the editor, which it offers where the grammar takes
|
|
2
|
+
// one: an extension, `efxSymbols.of({ fields, nodes })`, each a list of ids, for example those of
|
|
3
|
+
// the SDK's fields.json. The ids of several such extensions add up.
|
|
4
|
+
|
|
5
|
+
import { Facet } from '@codemirror/state';
|
|
6
|
+
|
|
7
|
+
export const efxSymbols = Facet.define({
|
|
8
|
+
combine: (symbols) => ({
|
|
9
|
+
fields: symbols.flatMap(({ fields = [] }) => fields),
|
|
10
|
+
nodes: symbols.flatMap(({ nodes = [] }) => nodes),
|
|
11
|
+
}),
|
|
12
|
+
});
|
package/dist/efxTheme.js
CHANGED
|
@@ -1,104 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
Identifier: t.name,
|
|
48
|
-
Operator: t.operator,
|
|
49
|
-
Delimiter: t.punctuation,
|
|
50
|
-
Bracket: t.punctuation,
|
|
51
|
-
Brace: t.punctuation,
|
|
52
|
-
Parenthesis: t.punctuation,
|
|
53
|
-
Pipe: t.punctuation,
|
|
54
|
-
Punctuation: t.punctuation,
|
|
55
|
-
Comment: t.lineComment,
|
|
56
|
-
FreeText: t.special(t.string)
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
export const efxColors = syntaxHighlighting(
|
|
60
|
-
HighlightStyle.define([
|
|
61
|
-
{ tag: t.keyword, color: "#7058be", fontWeight: "bold" },
|
|
62
|
-
{ tag: t.typeName, color: "#7058be" },
|
|
63
|
-
{ tag: t.literal, color: "#e14775" },
|
|
64
|
-
{ tag: t.propertyName, color: "#269d69", fontWeight: "bold" },
|
|
65
|
-
{ tag: t.variableName, color: "#cc7a0a", fontWeight: "bold" },
|
|
66
|
-
{ tag: t.function(t.name), color: "#cc7a0a", fontWeight: "bold" },
|
|
67
|
-
{ tag: t.function(t.keyword), color: "#7058be", fontWeight: "bold" },
|
|
68
|
-
{ tag: t.name, color: "#24292e" },
|
|
69
|
-
{ tag: t.className, color: "#7058be" },
|
|
70
|
-
{ tag: t.operator, color: "#6d6d6d", fontWeight: "bold" },
|
|
71
|
-
{ tag: t.punctuation, color: "#cc7a0a" },
|
|
72
|
-
{ tag: t.bracket, color: "#cc7a0a" },
|
|
73
|
-
{ tag: t.lineComment, color: "#999999", fontStyle: "italic" },
|
|
74
|
-
{ tag: t.special(t.name), color: "#e14775" },
|
|
75
|
-
{ tag: t.special(t.string), color: "black" },
|
|
76
|
-
])
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
export const efxTheme = EditorView.theme({
|
|
80
|
-
"&": {
|
|
81
|
-
backgroundColor: "#ffffff",
|
|
82
|
-
color: "#000000"
|
|
83
|
-
},
|
|
84
|
-
".cm-content": {
|
|
85
|
-
backgroundColor: "#ffffff",
|
|
86
|
-
caretColor: "#000000"
|
|
87
|
-
},
|
|
88
|
-
".cm-cursor, .cm-dropCursor": {
|
|
89
|
-
borderLeftColor: "#000000 !important",
|
|
90
|
-
borderLeftWidth: "2px !important",
|
|
91
|
-
borderLeftStyle: "solid !important"
|
|
92
|
-
},
|
|
93
|
-
".cm-selectionMatch": {
|
|
94
|
-
backgroundColor: "#add6ff !important"
|
|
95
|
-
},
|
|
96
|
-
"&.cm-focused .cm-cursor": {
|
|
97
|
-
borderLeftColor: "#000000 !important"
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
export let extensions = [
|
|
102
|
-
efxTheme,
|
|
103
|
-
efxColors,
|
|
104
|
-
];
|
|
1
|
+
// The look of EFX in an editor: the colour of each highlight tag (efxHighlightStyle), which efx()
|
|
2
|
+
// gives the editor as its default colours, and a look for the editor itself (efxTheme), which an
|
|
3
|
+
// application adds if it wants it.
|
|
4
|
+
import { tags as t } from "@lezer/highlight";
|
|
5
|
+
import { HighlightStyle } from "@codemirror/language";
|
|
6
|
+
import { EditorView } from "@codemirror/view";
|
|
7
|
+
|
|
8
|
+
export const efxHighlightStyle = HighlightStyle.define([
|
|
9
|
+
{ tag: t.keyword, color: "#7058be", fontWeight: "bold" },
|
|
10
|
+
{ tag: t.typeName, color: "#7058be" },
|
|
11
|
+
{ tag: t.literal, color: "#e14775" },
|
|
12
|
+
{ tag: t.propertyName, color: "#269d69", fontWeight: "bold" },
|
|
13
|
+
{ tag: t.variableName, color: "#cc7a0a", fontWeight: "bold" },
|
|
14
|
+
{ tag: t.function(t.name), color: "#cc7a0a", fontWeight: "bold" },
|
|
15
|
+
{ tag: t.function(t.keyword), color: "#7058be", fontWeight: "bold" },
|
|
16
|
+
{ tag: t.name, color: "#24292e" },
|
|
17
|
+
{ tag: t.className, color: "#7058be" },
|
|
18
|
+
{ tag: t.operator, color: "#6d6d6d", fontWeight: "bold" },
|
|
19
|
+
{ tag: t.punctuation, color: "#cc7a0a" },
|
|
20
|
+
{ tag: t.bracket, color: "#cc7a0a" },
|
|
21
|
+
{ tag: t.lineComment, color: "#999999", fontStyle: "italic" },
|
|
22
|
+
{ tag: t.special(t.name), color: "#e14775" },
|
|
23
|
+
{ tag: t.special(t.string), color: "black" },
|
|
24
|
+
]);
|
|
25
|
+
|
|
26
|
+
export const efxTheme = EditorView.theme({
|
|
27
|
+
"&": {
|
|
28
|
+
backgroundColor: "#ffffff",
|
|
29
|
+
color: "#000000"
|
|
30
|
+
},
|
|
31
|
+
".cm-content": {
|
|
32
|
+
backgroundColor: "#ffffff",
|
|
33
|
+
caretColor: "#000000"
|
|
34
|
+
},
|
|
35
|
+
".cm-cursor, .cm-dropCursor": {
|
|
36
|
+
borderLeftColor: "#000000 !important",
|
|
37
|
+
borderLeftWidth: "2px !important",
|
|
38
|
+
borderLeftStyle: "solid !important"
|
|
39
|
+
},
|
|
40
|
+
".cm-selectionMatch": {
|
|
41
|
+
backgroundColor: "#add6ff !important"
|
|
42
|
+
},
|
|
43
|
+
"&.cm-focused .cm-cursor": {
|
|
44
|
+
borderLeftColor: "#000000 !important"
|
|
45
|
+
}
|
|
46
|
+
});
|