grammar-well 1.1.8 → 1.1.10
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/README.md
CHANGED
|
@@ -114,9 +114,9 @@ lexer: {{
|
|
|
114
114
|
|
|
115
115
|
start ->
|
|
116
116
|
- import: string, js, ws, comment, l_scolon, l_star
|
|
117
|
-
- when: /lexer(?![a-zA-Z\d_])/ tag: "T_WORD" goto: lexer
|
|
118
|
-
- when: /grammar(?![a-zA-Z\d_])/ tag: "T_WORD" goto: grammar
|
|
119
|
-
- when: /config(?![a-zA-Z\d_])/ tag: "T_WORD" goto: config
|
|
117
|
+
- when: /lexer(?![a-zA-Z\d_])/ tag: "T_WORD" goto: lexer highlight: "type"
|
|
118
|
+
- when: /grammar(?![a-zA-Z\d_])/ tag: "T_WORD" goto: grammar highlight: "type"
|
|
119
|
+
- when: /config(?![a-zA-Z\d_])/ tag: "T_WORD" goto: config highlight: "type"
|
|
120
120
|
- import: kv
|
|
121
121
|
config ->
|
|
122
122
|
- import: ws, l_colon
|
|
@@ -168,21 +168,21 @@ lexer: {{
|
|
|
168
168
|
- when: /\/\/[^\n]*/ tag: "T_JSBODY"
|
|
169
169
|
- when: /\/\*.*\*\// tag: "T_JSBODY"
|
|
170
170
|
string ->
|
|
171
|
-
- when: /"(?:[^"\\\r\n]|\\.)*"/ tag: "T_STRING"
|
|
171
|
+
- when: /"(?:[^"\\\r\n]|\\.)*"/ tag: "T_STRING" highlight: "string"
|
|
172
172
|
string2 ->
|
|
173
|
-
- when: /'(?:[^'\\\r\n]|\\.)*'/ tag: "T_STRING"
|
|
173
|
+
- when: /'(?:[^'\\\r\n]|\\.)*'/ tag: "T_STRING" highlight: "string"
|
|
174
174
|
string3 ->
|
|
175
|
-
- when: /`(?:[^`\\]|\\.)*`/ tag: "T_STRING"
|
|
175
|
+
- when: /`(?:[^`\\]|\\.)*`/ tag: "T_STRING" highlight: "string"
|
|
176
176
|
regex ->
|
|
177
|
-
- when: /\/(?:[^\/\\\r\n]|\\.)+\// tag: "T_REGEX"
|
|
177
|
+
- when: /\/(?:[^\/\\\r\n]|\\.)+\// tag: "T_REGEX" highlight: "regexp"
|
|
178
178
|
integer ->
|
|
179
|
-
- when: /\d+/ tag: "T_INTEGER"
|
|
179
|
+
- when: /\d+/ tag: "T_INTEGER" highlight: "number"
|
|
180
180
|
word ->
|
|
181
181
|
- when: /[a-zA-Z_][a-zA-Z_\d]*/ tag: "T_WORD"
|
|
182
182
|
ws ->
|
|
183
183
|
- when: /\s+/ tag: "T_WS"
|
|
184
184
|
l_colon ->
|
|
185
|
-
- when: ":" tag: "L_COLON"
|
|
185
|
+
- when: ":" tag: "L_COLON" highlight: "keyword"
|
|
186
186
|
l_scolon ->
|
|
187
187
|
- when: ";" tag: "L_SCOLON"
|
|
188
188
|
l_qmark ->
|
|
@@ -194,7 +194,7 @@ lexer: {{
|
|
|
194
194
|
l_comma ->
|
|
195
195
|
- when: "," tag: "L_COMMA"
|
|
196
196
|
l_pipe ->
|
|
197
|
-
- when: "|" tag: "L_PIPE"
|
|
197
|
+
- when: "|" tag: "L_PIPE" highlight: "keyword"
|
|
198
198
|
l_parenl ->
|
|
199
199
|
- when: "(" tag: "L_PARENL"
|
|
200
200
|
l_parenr ->
|
|
@@ -204,15 +204,15 @@ lexer: {{
|
|
|
204
204
|
l_templater ->
|
|
205
205
|
- when: "}}" tag: "L_TEMPLATER"
|
|
206
206
|
l_arrow ->
|
|
207
|
-
- when: "->" tag: "L_ARROW"
|
|
207
|
+
- when: "->" tag: "L_ARROW" highlight: "keyword"
|
|
208
208
|
l_dsign ->
|
|
209
209
|
- when: "$" tag: "L_DSIGN"
|
|
210
210
|
l_dash ->
|
|
211
211
|
- when: "-" tag: "L_DASH"
|
|
212
212
|
comment ->
|
|
213
|
-
- when: /\/\/[^\n]*/ tag: "T_COMMENT"
|
|
213
|
+
- when: /\/\/[^\n]*/ tag: "T_COMMENT" highlight: "comment"
|
|
214
214
|
commentmulti ->
|
|
215
|
-
- when: /\/\*.*\*\// tag: "T_COMMENT"
|
|
215
|
+
- when: /\/\*.*\*\// tag: "T_COMMENT" highlight: "comment"
|
|
216
216
|
|
|
217
217
|
}}
|
|
218
218
|
|
|
@@ -273,6 +273,7 @@ grammar: {{
|
|
|
273
273
|
| K_POP : {{ { pop: 1 } }}
|
|
274
274
|
| K_POP _ L_COLON _ T_INTEGER : {{ { pop: parseInt($4) } }}
|
|
275
275
|
| K_POP _ L_COLON _ K_ALL : {{ { pop: "all" } }}
|
|
276
|
+
| K_HIGHLIGHT _ L_COLON _ T_STRING : {{ { highlight: $4 } }}
|
|
276
277
|
| K_INSET : {{ { inset: 1 } }}
|
|
277
278
|
| K_INSET _ L_COLON _ T_INTEGER : {{ { inset: parseInt($4) } }}
|
|
278
279
|
| K_SET _ L_COLON _ T_WORD : {{ { set: $4 } }}
|
|
@@ -343,9 +344,10 @@ grammar: {{
|
|
|
343
344
|
| T_WORD _ L_COMMA _ word_list : {{ [$0].concat($4) }}
|
|
344
345
|
|
|
345
346
|
_ ->
|
|
346
|
-
T_WS
|
|
347
|
+
( T_WS | T_COMMENT )* : {{ null }}
|
|
348
|
+
|
|
347
349
|
__ ->
|
|
348
|
-
T_WS+ : {{ null }}
|
|
350
|
+
( T_WS | T_COMMENT )+ : {{ null }}
|
|
349
351
|
|
|
350
352
|
L_COLON -> $L_COLON
|
|
351
353
|
L_SCOLON -> $L_SCOLON
|
|
@@ -368,6 +370,7 @@ grammar: {{
|
|
|
368
370
|
K_TYPE -> "type"
|
|
369
371
|
K_WHEN -> "when"
|
|
370
372
|
K_POP -> "pop"
|
|
373
|
+
K_HIGHLIGHT -> "highlight"
|
|
371
374
|
K_INSET -> "inset"
|
|
372
375
|
K_SET -> "set"
|
|
373
376
|
K_GOTO -> "goto"
|
|
@@ -375,14 +378,14 @@ grammar: {{
|
|
|
375
378
|
K_LEXER -> "lexer"
|
|
376
379
|
K_GRAMMAR -> "grammar"
|
|
377
380
|
K_IMPORT -> "import"
|
|
378
|
-
K_BODY -> "body"
|
|
381
|
+
K_BODY -> "body"
|
|
379
382
|
K_HEAD -> "head"
|
|
380
383
|
|
|
381
384
|
T_JS -> $L_JSL $T_JSBODY* $L_JSR : {{ { js: $1.map(v=>v.value).join('') } }}
|
|
382
385
|
T_GRAMMAR_TEMPLATE -> $L_TEMPLATEL _ $T_JSBODY* _ $L_TEMPLATER : {{ { template: $2.map(v=>v.value).join('').trim() } }}
|
|
383
386
|
T_STRING -> $T_STRING : {{ JSON.parse($0.value) }}
|
|
384
387
|
T_WORD -> $T_WORD : {{ $0.value }}
|
|
385
|
-
T_REGEX -> $T_REGEX /[gmiuy]/* : {{ { regex: $0.value.replace(/\\\\\//g,'/').slice(1,-1), flags: $1.join('') } }}
|
|
388
|
+
T_REGEX -> $T_REGEX /[gmiuy]/* : {{ { regex: $0.value.replace(/\\\\\//g,'/').slice(1,-1), flags: $1.map(v=>v.value).join('').trim() } }}
|
|
386
389
|
T_COMMENT -> $T_COMMENT
|
|
387
390
|
T_INTEGER -> $T_INTEGER : {{ $0.value }}
|
|
388
391
|
T_WS -> $T_WS : {{ null }}
|
|
@@ -11,7 +11,7 @@ class TextFormatter {
|
|
|
11
11
|
lines.push('End of input was expected.');
|
|
12
12
|
}
|
|
13
13
|
else {
|
|
14
|
-
lines.push('
|
|
14
|
+
lines.push('Expected:');
|
|
15
15
|
for (const ex of expected) {
|
|
16
16
|
const nextSymbol = ex.symbols[ex.index];
|
|
17
17
|
const symbolDisplay = TextFormatter.GrammarRuleSymbol(nextSymbol, false, true);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-format.js","sourceRoot":"","sources":["../../src/utility/text-format.ts"],"names":[],"mappings":";;;AAGA,MAAa,aAAa;IAEtB,MAAM,CAAC,eAAe,CAAC,KAAkB,EAAE,QAA8C;QACrF,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC;QAC3B,MAAM,YAAY,GAAG,aAAa,CAAC,eA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ACd,OAAO,uBAAuB,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;aAC3D;SACJ;IACL,CAAC;IAED,MAAM,CAAC,WAAW,CAAC,IAAiB,EAAE,YAAqB;QACvD,IAAI,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC5H,IAAI,OAAO,YAAY,KAAK,WAAW,EAAE;YACrC,cAAc,IAAI,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SACjI;QACD,OAAO,IAAI,CAAC,IAAI,GAAG,KAAK,GAAG,cAAc,CAAC;IAC9C,CAAC;CACJ;AAhFD,sCAgFC"}
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@ export class TextFormatter {
|
|
|
11
11
|
if (expected.length === 0) {
|
|
12
12
|
lines.push('End of input was expected.');
|
|
13
13
|
} else {
|
|
14
|
-
lines.push('
|
|
14
|
+
lines.push('Expected:');
|
|
15
15
|
for (const ex of expected) {
|
|
16
16
|
const nextSymbol = ex.symbols[ex.index];
|
|
17
17
|
const symbolDisplay = TextFormatter.GrammarRuleSymbol(nextSymbol, false, true);
|