tagset-parser 0.0.0 → 1.0.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/lib/cjs/bitmask.js +1 -1
- package/lib/cjs/generated/TagSetLexer.js +31 -29
- package/lib/cjs/generated/TagSetListener.js +0 -10
- package/lib/cjs/generated/TagSetParser.js +81 -169
- package/lib/cjs/generated/TagSetVisitor.js +0 -6
- package/lib/cjs/visitor.js +3 -9
- package/lib/esm/bitmask.js +1 -1
- package/lib/esm/generated/TagSetLexer.js +31 -29
- package/lib/esm/generated/TagSetListener.js +0 -10
- package/lib/esm/generated/TagSetParser.js +80 -167
- package/lib/esm/generated/TagSetVisitor.js +0 -6
- package/lib/esm/visitor.js +3 -9
- package/lib/types/generated/TagSetLexer.d.ts +5 -5
- package/lib/types/generated/TagSetListener.d.ts +0 -11
- package/lib/types/generated/TagSetParser.d.ts +8 -21
- package/lib/types/generated/TagSetVisitor.d.ts +0 -7
- package/package.json +19 -17
- package/readme.md +67 -19
package/lib/cjs/bitmask.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.calcBitmask = calcBitmask;
|
|
4
4
|
function calcBitmask(pattern, sets) {
|
|
5
|
-
const tokens = pattern.split('
|
|
5
|
+
const tokens = pattern.split(',');
|
|
6
6
|
let mask = 0;
|
|
7
7
|
for (const token of tokens) {
|
|
8
8
|
const t = token.trim();
|
|
@@ -5,28 +5,28 @@ const antlr = require("antlr4ng");
|
|
|
5
5
|
class TagSetLexer extends antlr.Lexer {
|
|
6
6
|
static SET = 1;
|
|
7
7
|
static ITEM = 2;
|
|
8
|
-
static
|
|
9
|
-
static
|
|
10
|
-
static
|
|
11
|
-
static
|
|
12
|
-
static
|
|
8
|
+
static COMMA = 3;
|
|
9
|
+
static COLON = 4;
|
|
10
|
+
static QUOTED_STRING = 5;
|
|
11
|
+
static WORD = 6;
|
|
12
|
+
static COMMENT = 7;
|
|
13
13
|
static NL = 8;
|
|
14
14
|
static WS = 9;
|
|
15
15
|
static channelNames = [
|
|
16
16
|
"DEFAULT_TOKEN_CHANNEL", "HIDDEN"
|
|
17
17
|
];
|
|
18
18
|
static literalNames = [
|
|
19
|
-
null, "'set'", "'item'", "'
|
|
19
|
+
null, "'set'", "'item'", "','", "':'"
|
|
20
20
|
];
|
|
21
21
|
static symbolicNames = [
|
|
22
|
-
null, "SET", "ITEM", "
|
|
23
|
-
"NL", "WS"
|
|
22
|
+
null, "SET", "ITEM", "COMMA", "COLON", "QUOTED_STRING", "WORD",
|
|
23
|
+
"COMMENT", "NL", "WS"
|
|
24
24
|
];
|
|
25
25
|
static modeNames = [
|
|
26
26
|
"DEFAULT_MODE",
|
|
27
27
|
];
|
|
28
28
|
static ruleNames = [
|
|
29
|
-
"SET", "ITEM", "
|
|
29
|
+
"SET", "ITEM", "COMMA", "COLON", "QUOTED_STRING", "WORD", "COMMENT",
|
|
30
30
|
"NL", "WS",
|
|
31
31
|
];
|
|
32
32
|
constructor(input) {
|
|
@@ -41,27 +41,29 @@ class TagSetLexer extends antlr.Lexer {
|
|
|
41
41
|
get channelNames() { return TagSetLexer.channelNames; }
|
|
42
42
|
get modeNames() { return TagSetLexer.modeNames; }
|
|
43
43
|
static _serializedATN = [
|
|
44
|
-
4, 0, 9,
|
|
44
|
+
4, 0, 9, 67, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2,
|
|
45
45
|
6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1,
|
|
46
|
-
2, 1, 3, 1, 3, 1, 4, 1, 4,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
0, 0, 0, 0,
|
|
53
|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 115, 0,
|
|
55
|
+
0, 20, 21, 5, 101, 0, 0, 21, 22, 5, 116, 0, 0, 22, 2, 1, 0, 0, 0, 23, 24, 5, 105, 0, 0, 24,
|
|
56
|
+
25, 5, 116, 0, 0, 25, 26, 5, 101, 0, 0, 26, 27, 5, 109, 0, 0, 27, 4, 1, 0, 0, 0, 28, 29,
|
|
57
|
+
5, 44, 0, 0, 29, 6, 1, 0, 0, 0, 30, 31, 5, 58, 0, 0, 31, 8, 1, 0, 0, 0, 32, 36, 5, 34, 0, 0,
|
|
58
|
+
33, 35, 8, 0, 0, 0, 34, 33, 1, 0, 0, 0, 35, 38, 1, 0, 0, 0, 36, 34, 1, 0, 0, 0, 36, 37, 1,
|
|
59
|
+
0, 0, 0, 37, 39, 1, 0, 0, 0, 38, 36, 1, 0, 0, 0, 39, 40, 5, 34, 0, 0, 40, 10, 1, 0, 0, 0, 41,
|
|
60
|
+
43, 8, 1, 0, 0, 42, 41, 1, 0, 0, 0, 43, 44, 1, 0, 0, 0, 44, 42, 1, 0, 0, 0, 44, 45, 1, 0, 0,
|
|
61
|
+
0, 45, 12, 1, 0, 0, 0, 46, 50, 5, 35, 0, 0, 47, 49, 8, 2, 0, 0, 48, 47, 1, 0, 0, 0, 49, 52,
|
|
62
|
+
1, 0, 0, 0, 50, 48, 1, 0, 0, 0, 50, 51, 1, 0, 0, 0, 51, 53, 1, 0, 0, 0, 52, 50, 1, 0, 0, 0,
|
|
63
|
+
53, 54, 6, 6, 0, 0, 54, 14, 1, 0, 0, 0, 55, 57, 7, 2, 0, 0, 56, 55, 1, 0, 0, 0, 57, 58, 1,
|
|
64
|
+
0, 0, 0, 58, 56, 1, 0, 0, 0, 58, 59, 1, 0, 0, 0, 59, 16, 1, 0, 0, 0, 60, 62, 7, 3, 0, 0, 61,
|
|
65
|
+
60, 1, 0, 0, 0, 62, 63, 1, 0, 0, 0, 63, 61, 1, 0, 0, 0, 63, 64, 1, 0, 0, 0, 64, 65, 1, 0, 0,
|
|
66
|
+
0, 65, 66, 6, 8, 0, 0, 66, 18, 1, 0, 0, 0, 6, 0, 36, 44, 50, 58, 63, 1, 6, 0, 0
|
|
65
67
|
];
|
|
66
68
|
static __ATN;
|
|
67
69
|
static get _ATN() {
|
|
@@ -66,16 +66,6 @@ class TagSetListener {
|
|
|
66
66
|
* @param ctx the parse tree
|
|
67
67
|
*/
|
|
68
68
|
exitSugarDecl;
|
|
69
|
-
/**
|
|
70
|
-
* Enter a parse tree produced by `TagSetParser.pattern`.
|
|
71
|
-
* @param ctx the parse tree
|
|
72
|
-
*/
|
|
73
|
-
enterPattern;
|
|
74
|
-
/**
|
|
75
|
-
* Exit a parse tree produced by `TagSetParser.pattern`.
|
|
76
|
-
* @param ctx the parse tree
|
|
77
|
-
*/
|
|
78
|
-
exitPattern;
|
|
79
69
|
/**
|
|
80
70
|
* Enter a parse tree produced by `TagSetParser.valueList`.
|
|
81
71
|
* @param ctx the parse tree
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ValueItemContext = exports.ValueListContext = exports.
|
|
3
|
+
exports.ValueItemContext = exports.ValueListContext = exports.SugarDeclContext = exports.ItemDeclContext = exports.LabelPartContext = exports.SetDeclContext = exports.LineContext = exports.ProgramContext = exports.TagSetParser = void 0;
|
|
4
4
|
const antlr = require("antlr4ng");
|
|
5
5
|
class TagSetParser extends antlr.Parser {
|
|
6
6
|
static SET = 1;
|
|
7
7
|
static ITEM = 2;
|
|
8
|
-
static
|
|
9
|
-
static
|
|
10
|
-
static
|
|
11
|
-
static
|
|
12
|
-
static
|
|
8
|
+
static COMMA = 3;
|
|
9
|
+
static COLON = 4;
|
|
10
|
+
static QUOTED_STRING = 5;
|
|
11
|
+
static WORD = 6;
|
|
12
|
+
static COMMENT = 7;
|
|
13
13
|
static NL = 8;
|
|
14
14
|
static WS = 9;
|
|
15
15
|
static RULE_program = 0;
|
|
@@ -18,19 +18,18 @@ class TagSetParser extends antlr.Parser {
|
|
|
18
18
|
static RULE_labelPart = 3;
|
|
19
19
|
static RULE_itemDecl = 4;
|
|
20
20
|
static RULE_sugarDecl = 5;
|
|
21
|
-
static
|
|
22
|
-
static
|
|
23
|
-
static RULE_valueItem = 8;
|
|
21
|
+
static RULE_valueList = 6;
|
|
22
|
+
static RULE_valueItem = 7;
|
|
24
23
|
static literalNames = [
|
|
25
|
-
null, "'set'", "'item'", "'
|
|
24
|
+
null, "'set'", "'item'", "','", "':'"
|
|
26
25
|
];
|
|
27
26
|
static symbolicNames = [
|
|
28
|
-
null, "SET", "ITEM", "
|
|
29
|
-
"NL", "WS"
|
|
27
|
+
null, "SET", "ITEM", "COMMA", "COLON", "QUOTED_STRING", "WORD",
|
|
28
|
+
"COMMENT", "NL", "WS"
|
|
30
29
|
];
|
|
31
30
|
static ruleNames = [
|
|
32
31
|
"program", "line", "setDecl", "labelPart", "itemDecl", "sugarDecl",
|
|
33
|
-
"
|
|
32
|
+
"valueList", "valueItem",
|
|
34
33
|
];
|
|
35
34
|
get grammarFileName() { return "TagSet.g4"; }
|
|
36
35
|
get literalNames() { return TagSetParser.literalNames; }
|
|
@@ -51,17 +50,17 @@ class TagSetParser extends antlr.Parser {
|
|
|
51
50
|
try {
|
|
52
51
|
this.enterOuterAlt(localContext, 1);
|
|
53
52
|
{
|
|
54
|
-
this.state =
|
|
53
|
+
this.state = 20;
|
|
55
54
|
this.errorHandler.sync(this);
|
|
56
55
|
_la = this.tokenStream.LA(1);
|
|
57
|
-
while ((((_la) & ~0x1F) === 0 && ((1 << _la) &
|
|
56
|
+
while ((((_la) & ~0x1F) === 0 && ((1 << _la) & 326) !== 0)) {
|
|
58
57
|
{
|
|
59
|
-
this.state =
|
|
58
|
+
this.state = 18;
|
|
60
59
|
this.errorHandler.sync(this);
|
|
61
60
|
switch (this.tokenStream.LA(1)) {
|
|
62
61
|
case TagSetParser.NL:
|
|
63
62
|
{
|
|
64
|
-
this.state =
|
|
63
|
+
this.state = 16;
|
|
65
64
|
this.match(TagSetParser.NL);
|
|
66
65
|
}
|
|
67
66
|
break;
|
|
@@ -69,7 +68,7 @@ class TagSetParser extends antlr.Parser {
|
|
|
69
68
|
case TagSetParser.ITEM:
|
|
70
69
|
case TagSetParser.WORD:
|
|
71
70
|
{
|
|
72
|
-
this.state =
|
|
71
|
+
this.state = 17;
|
|
73
72
|
this.line();
|
|
74
73
|
}
|
|
75
74
|
break;
|
|
@@ -77,11 +76,11 @@ class TagSetParser extends antlr.Parser {
|
|
|
77
76
|
throw new antlr.NoViableAltException(this);
|
|
78
77
|
}
|
|
79
78
|
}
|
|
80
|
-
this.state =
|
|
79
|
+
this.state = 22;
|
|
81
80
|
this.errorHandler.sync(this);
|
|
82
81
|
_la = this.tokenStream.LA(1);
|
|
83
82
|
}
|
|
84
|
-
this.state =
|
|
83
|
+
this.state = 23;
|
|
85
84
|
this.match(TagSetParser.EOF);
|
|
86
85
|
}
|
|
87
86
|
}
|
|
@@ -105,36 +104,36 @@ class TagSetParser extends antlr.Parser {
|
|
|
105
104
|
try {
|
|
106
105
|
this.enterOuterAlt(localContext, 1);
|
|
107
106
|
{
|
|
108
|
-
this.state =
|
|
107
|
+
this.state = 28;
|
|
109
108
|
this.errorHandler.sync(this);
|
|
110
109
|
switch (this.tokenStream.LA(1)) {
|
|
111
110
|
case TagSetParser.SET:
|
|
112
111
|
{
|
|
113
|
-
this.state =
|
|
112
|
+
this.state = 25;
|
|
114
113
|
this.setDecl();
|
|
115
114
|
}
|
|
116
115
|
break;
|
|
117
116
|
case TagSetParser.ITEM:
|
|
118
117
|
{
|
|
119
|
-
this.state =
|
|
118
|
+
this.state = 26;
|
|
120
119
|
this.itemDecl();
|
|
121
120
|
}
|
|
122
121
|
break;
|
|
123
122
|
case TagSetParser.WORD:
|
|
124
123
|
{
|
|
125
|
-
this.state =
|
|
124
|
+
this.state = 27;
|
|
126
125
|
this.sugarDecl();
|
|
127
126
|
}
|
|
128
127
|
break;
|
|
129
128
|
default:
|
|
130
129
|
throw new antlr.NoViableAltException(this);
|
|
131
130
|
}
|
|
132
|
-
this.state =
|
|
131
|
+
this.state = 31;
|
|
133
132
|
this.errorHandler.sync(this);
|
|
134
133
|
switch (this.interpreter.adaptivePredict(this.tokenStream, 3, this.context)) {
|
|
135
134
|
case 1:
|
|
136
135
|
{
|
|
137
|
-
this.state =
|
|
136
|
+
this.state = 30;
|
|
138
137
|
this.match(TagSetParser.NL);
|
|
139
138
|
}
|
|
140
139
|
break;
|
|
@@ -162,11 +161,11 @@ class TagSetParser extends antlr.Parser {
|
|
|
162
161
|
let alternative;
|
|
163
162
|
this.enterOuterAlt(localContext, 1);
|
|
164
163
|
{
|
|
165
|
-
this.state =
|
|
164
|
+
this.state = 33;
|
|
166
165
|
this.match(TagSetParser.SET);
|
|
167
|
-
this.state =
|
|
166
|
+
this.state = 34;
|
|
168
167
|
this.match(TagSetParser.WORD);
|
|
169
|
-
this.state =
|
|
168
|
+
this.state = 36;
|
|
170
169
|
this.errorHandler.sync(this);
|
|
171
170
|
alternative = 1;
|
|
172
171
|
do {
|
|
@@ -174,7 +173,7 @@ class TagSetParser extends antlr.Parser {
|
|
|
174
173
|
case 1:
|
|
175
174
|
{
|
|
176
175
|
{
|
|
177
|
-
this.state =
|
|
176
|
+
this.state = 35;
|
|
178
177
|
this.labelPart();
|
|
179
178
|
}
|
|
180
179
|
}
|
|
@@ -182,7 +181,7 @@ class TagSetParser extends antlr.Parser {
|
|
|
182
181
|
default:
|
|
183
182
|
throw new antlr.NoViableAltException(this);
|
|
184
183
|
}
|
|
185
|
-
this.state =
|
|
184
|
+
this.state = 38;
|
|
186
185
|
this.errorHandler.sync(this);
|
|
187
186
|
alternative = this.interpreter.adaptivePredict(this.tokenStream, 4, this.context);
|
|
188
187
|
} while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER);
|
|
@@ -209,9 +208,9 @@ class TagSetParser extends antlr.Parser {
|
|
|
209
208
|
try {
|
|
210
209
|
this.enterOuterAlt(localContext, 1);
|
|
211
210
|
{
|
|
212
|
-
this.state =
|
|
211
|
+
this.state = 40;
|
|
213
212
|
_la = this.tokenStream.LA(1);
|
|
214
|
-
if (!(_la ===
|
|
213
|
+
if (!(_la === 5 || _la === 6)) {
|
|
215
214
|
this.errorHandler.recoverInline(this);
|
|
216
215
|
}
|
|
217
216
|
else {
|
|
@@ -240,11 +239,11 @@ class TagSetParser extends antlr.Parser {
|
|
|
240
239
|
try {
|
|
241
240
|
this.enterOuterAlt(localContext, 1);
|
|
242
241
|
{
|
|
243
|
-
this.state =
|
|
242
|
+
this.state = 42;
|
|
244
243
|
this.match(TagSetParser.ITEM);
|
|
245
|
-
this.state =
|
|
246
|
-
this.
|
|
247
|
-
this.state =
|
|
244
|
+
this.state = 43;
|
|
245
|
+
this.match(TagSetParser.WORD);
|
|
246
|
+
this.state = 44;
|
|
248
247
|
this.valueList();
|
|
249
248
|
}
|
|
250
249
|
}
|
|
@@ -269,27 +268,27 @@ class TagSetParser extends antlr.Parser {
|
|
|
269
268
|
try {
|
|
270
269
|
this.enterOuterAlt(localContext, 1);
|
|
271
270
|
{
|
|
272
|
-
this.state =
|
|
271
|
+
this.state = 46;
|
|
273
272
|
this.match(TagSetParser.WORD);
|
|
274
|
-
this.state =
|
|
273
|
+
this.state = 51;
|
|
275
274
|
this.errorHandler.sync(this);
|
|
276
275
|
_la = this.tokenStream.LA(1);
|
|
277
|
-
while (_la ===
|
|
276
|
+
while (_la === 3) {
|
|
278
277
|
{
|
|
279
278
|
{
|
|
280
|
-
this.state =
|
|
279
|
+
this.state = 47;
|
|
281
280
|
this.match(TagSetParser.COMMA);
|
|
282
|
-
this.state =
|
|
281
|
+
this.state = 48;
|
|
283
282
|
this.match(TagSetParser.WORD);
|
|
284
283
|
}
|
|
285
284
|
}
|
|
286
|
-
this.state =
|
|
285
|
+
this.state = 53;
|
|
287
286
|
this.errorHandler.sync(this);
|
|
288
287
|
_la = this.tokenStream.LA(1);
|
|
289
288
|
}
|
|
290
|
-
this.state =
|
|
289
|
+
this.state = 54;
|
|
291
290
|
this.match(TagSetParser.COLON);
|
|
292
|
-
this.state =
|
|
291
|
+
this.state = 55;
|
|
293
292
|
this.valueList();
|
|
294
293
|
}
|
|
295
294
|
}
|
|
@@ -307,69 +306,28 @@ class TagSetParser extends antlr.Parser {
|
|
|
307
306
|
}
|
|
308
307
|
return localContext;
|
|
309
308
|
}
|
|
310
|
-
pattern() {
|
|
311
|
-
let localContext = new PatternContext(this.context, this.state);
|
|
312
|
-
this.enterRule(localContext, 12, TagSetParser.RULE_pattern);
|
|
313
|
-
let _la;
|
|
314
|
-
try {
|
|
315
|
-
this.enterOuterAlt(localContext, 1);
|
|
316
|
-
{
|
|
317
|
-
this.state = 59;
|
|
318
|
-
this.match(TagSetParser.WORD);
|
|
319
|
-
this.state = 64;
|
|
320
|
-
this.errorHandler.sync(this);
|
|
321
|
-
_la = this.tokenStream.LA(1);
|
|
322
|
-
while (_la === 3) {
|
|
323
|
-
{
|
|
324
|
-
{
|
|
325
|
-
this.state = 60;
|
|
326
|
-
this.match(TagSetParser.AMP);
|
|
327
|
-
this.state = 61;
|
|
328
|
-
this.match(TagSetParser.WORD);
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
this.state = 66;
|
|
332
|
-
this.errorHandler.sync(this);
|
|
333
|
-
_la = this.tokenStream.LA(1);
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
catch (re) {
|
|
338
|
-
if (re instanceof antlr.RecognitionException) {
|
|
339
|
-
this.errorHandler.reportError(this, re);
|
|
340
|
-
this.errorHandler.recover(this, re);
|
|
341
|
-
}
|
|
342
|
-
else {
|
|
343
|
-
throw re;
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
finally {
|
|
347
|
-
this.exitRule();
|
|
348
|
-
}
|
|
349
|
-
return localContext;
|
|
350
|
-
}
|
|
351
309
|
valueList() {
|
|
352
310
|
let localContext = new ValueListContext(this.context, this.state);
|
|
353
|
-
this.enterRule(localContext,
|
|
311
|
+
this.enterRule(localContext, 12, TagSetParser.RULE_valueList);
|
|
354
312
|
let _la;
|
|
355
313
|
try {
|
|
356
314
|
this.enterOuterAlt(localContext, 1);
|
|
357
315
|
{
|
|
358
|
-
this.state =
|
|
316
|
+
this.state = 57;
|
|
359
317
|
this.valueItem();
|
|
360
|
-
this.state =
|
|
318
|
+
this.state = 62;
|
|
361
319
|
this.errorHandler.sync(this);
|
|
362
320
|
_la = this.tokenStream.LA(1);
|
|
363
|
-
while (_la ===
|
|
321
|
+
while (_la === 3) {
|
|
364
322
|
{
|
|
365
323
|
{
|
|
366
|
-
this.state =
|
|
324
|
+
this.state = 58;
|
|
367
325
|
this.match(TagSetParser.COMMA);
|
|
368
|
-
this.state =
|
|
326
|
+
this.state = 59;
|
|
369
327
|
this.valueItem();
|
|
370
328
|
}
|
|
371
329
|
}
|
|
372
|
-
this.state =
|
|
330
|
+
this.state = 64;
|
|
373
331
|
this.errorHandler.sync(this);
|
|
374
332
|
_la = this.tokenStream.LA(1);
|
|
375
333
|
}
|
|
@@ -391,13 +349,13 @@ class TagSetParser extends antlr.Parser {
|
|
|
391
349
|
}
|
|
392
350
|
valueItem() {
|
|
393
351
|
let localContext = new ValueItemContext(this.context, this.state);
|
|
394
|
-
this.enterRule(localContext,
|
|
352
|
+
this.enterRule(localContext, 14, TagSetParser.RULE_valueItem);
|
|
395
353
|
let _la;
|
|
396
354
|
try {
|
|
397
355
|
let alternative;
|
|
398
356
|
this.enterOuterAlt(localContext, 1);
|
|
399
357
|
{
|
|
400
|
-
this.state =
|
|
358
|
+
this.state = 66;
|
|
401
359
|
this.errorHandler.sync(this);
|
|
402
360
|
alternative = 1;
|
|
403
361
|
do {
|
|
@@ -405,9 +363,9 @@ class TagSetParser extends antlr.Parser {
|
|
|
405
363
|
case 1:
|
|
406
364
|
{
|
|
407
365
|
{
|
|
408
|
-
this.state =
|
|
366
|
+
this.state = 65;
|
|
409
367
|
_la = this.tokenStream.LA(1);
|
|
410
|
-
if (!(_la ===
|
|
368
|
+
if (!(_la === 5 || _la === 6)) {
|
|
411
369
|
this.errorHandler.recoverInline(this);
|
|
412
370
|
}
|
|
413
371
|
else {
|
|
@@ -420,9 +378,9 @@ class TagSetParser extends antlr.Parser {
|
|
|
420
378
|
default:
|
|
421
379
|
throw new antlr.NoViableAltException(this);
|
|
422
380
|
}
|
|
423
|
-
this.state =
|
|
381
|
+
this.state = 68;
|
|
424
382
|
this.errorHandler.sync(this);
|
|
425
|
-
alternative = this.interpreter.adaptivePredict(this.tokenStream,
|
|
383
|
+
alternative = this.interpreter.adaptivePredict(this.tokenStream, 7, this.context);
|
|
426
384
|
} while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER);
|
|
427
385
|
}
|
|
428
386
|
}
|
|
@@ -441,31 +399,28 @@ class TagSetParser extends antlr.Parser {
|
|
|
441
399
|
return localContext;
|
|
442
400
|
}
|
|
443
401
|
static _serializedATN = [
|
|
444
|
-
4, 1, 9,
|
|
445
|
-
2, 7, 7, 7,
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
0, 0,
|
|
451
|
-
0, 0,
|
|
452
|
-
0, 0, 0,
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
0,
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
70, 1, 0, 0, 0, 72, 73, 1, 0, 0, 0, 73, 15, 1, 0, 0, 0, 74, 72, 1, 0, 0, 0, 75, 77, 7, 0, 0,
|
|
467
|
-
0, 76, 75, 1, 0, 0, 0, 77, 78, 1, 0, 0, 0, 78, 76, 1, 0, 0, 0, 78, 79, 1, 0, 0, 0, 79, 17,
|
|
468
|
-
1, 0, 0, 0, 9, 20, 22, 30, 33, 40, 53, 64, 72, 78
|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10, 5, 0, 28, 25, 1, 0, 0, 0, 28, 26, 1, 0,
|
|
413
|
+
0, 0, 28, 27, 1, 0, 0, 0, 29, 31, 1, 0, 0, 0, 30, 32, 5, 8, 0, 0, 31, 30, 1, 0, 0, 0, 31, 32,
|
|
414
|
+
1, 0, 0, 0, 32, 3, 1, 0, 0, 0, 33, 34, 5, 1, 0, 0, 34, 36, 5, 6, 0, 0, 35, 37, 3, 6, 3, 0, 36,
|
|
415
|
+
35, 1, 0, 0, 0, 37, 38, 1, 0, 0, 0, 38, 36, 1, 0, 0, 0, 38, 39, 1, 0, 0, 0, 39, 5, 1, 0, 0,
|
|
416
|
+
0, 40, 41, 7, 0, 0, 0, 41, 7, 1, 0, 0, 0, 42, 43, 5, 2, 0, 0, 43, 44, 5, 6, 0, 0, 44, 45, 3,
|
|
417
|
+
12, 6, 0, 45, 9, 1, 0, 0, 0, 46, 51, 5, 6, 0, 0, 47, 48, 5, 3, 0, 0, 48, 50, 5, 6, 0, 0, 49,
|
|
418
|
+
47, 1, 0, 0, 0, 50, 53, 1, 0, 0, 0, 51, 49, 1, 0, 0, 0, 51, 52, 1, 0, 0, 0, 52, 54, 1, 0, 0,
|
|
419
|
+
0, 53, 51, 1, 0, 0, 0, 54, 55, 5, 4, 0, 0, 55, 56, 3, 12, 6, 0, 56, 11, 1, 0, 0, 0, 57, 62,
|
|
420
|
+
3, 14, 7, 0, 58, 59, 5, 3, 0, 0, 59, 61, 3, 14, 7, 0, 60, 58, 1, 0, 0, 0, 61, 64, 1, 0, 0,
|
|
421
|
+
0, 62, 60, 1, 0, 0, 0, 62, 63, 1, 0, 0, 0, 63, 13, 1, 0, 0, 0, 64, 62, 1, 0, 0, 0, 65, 67,
|
|
422
|
+
7, 0, 0, 0, 66, 65, 1, 0, 0, 0, 67, 68, 1, 0, 0, 0, 68, 66, 1, 0, 0, 0, 68, 69, 1, 0, 0, 0,
|
|
423
|
+
69, 15, 1, 0, 0, 0, 8, 18, 20, 28, 31, 38, 51, 62, 68
|
|
469
424
|
];
|
|
470
425
|
static __ATN;
|
|
471
426
|
static get _ATN() {
|
|
@@ -643,8 +598,8 @@ class ItemDeclContext extends antlr.ParserRuleContext {
|
|
|
643
598
|
ITEM() {
|
|
644
599
|
return this.getToken(TagSetParser.ITEM, 0);
|
|
645
600
|
}
|
|
646
|
-
|
|
647
|
-
return this.
|
|
601
|
+
WORD() {
|
|
602
|
+
return this.getToken(TagSetParser.WORD, 0);
|
|
648
603
|
}
|
|
649
604
|
valueList() {
|
|
650
605
|
return this.getRuleContext(0, ValueListContext);
|
|
@@ -721,49 +676,6 @@ class SugarDeclContext extends antlr.ParserRuleContext {
|
|
|
721
676
|
}
|
|
722
677
|
}
|
|
723
678
|
exports.SugarDeclContext = SugarDeclContext;
|
|
724
|
-
class PatternContext extends antlr.ParserRuleContext {
|
|
725
|
-
constructor(parent, invokingState) {
|
|
726
|
-
super(parent, invokingState);
|
|
727
|
-
}
|
|
728
|
-
WORD(i) {
|
|
729
|
-
if (i === undefined) {
|
|
730
|
-
return this.getTokens(TagSetParser.WORD);
|
|
731
|
-
}
|
|
732
|
-
else {
|
|
733
|
-
return this.getToken(TagSetParser.WORD, i);
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
AMP(i) {
|
|
737
|
-
if (i === undefined) {
|
|
738
|
-
return this.getTokens(TagSetParser.AMP);
|
|
739
|
-
}
|
|
740
|
-
else {
|
|
741
|
-
return this.getToken(TagSetParser.AMP, i);
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
get ruleIndex() {
|
|
745
|
-
return TagSetParser.RULE_pattern;
|
|
746
|
-
}
|
|
747
|
-
enterRule(listener) {
|
|
748
|
-
if (listener.enterPattern) {
|
|
749
|
-
listener.enterPattern(this);
|
|
750
|
-
}
|
|
751
|
-
}
|
|
752
|
-
exitRule(listener) {
|
|
753
|
-
if (listener.exitPattern) {
|
|
754
|
-
listener.exitPattern(this);
|
|
755
|
-
}
|
|
756
|
-
}
|
|
757
|
-
accept(visitor) {
|
|
758
|
-
if (visitor.visitPattern) {
|
|
759
|
-
return visitor.visitPattern(this);
|
|
760
|
-
}
|
|
761
|
-
else {
|
|
762
|
-
return visitor.visitChildren(this);
|
|
763
|
-
}
|
|
764
|
-
}
|
|
765
|
-
}
|
|
766
|
-
exports.PatternContext = PatternContext;
|
|
767
679
|
class ValueListContext extends antlr.ParserRuleContext {
|
|
768
680
|
constructor(parent, invokingState) {
|
|
769
681
|
super(parent, invokingState);
|
|
@@ -46,12 +46,6 @@ class TagSetVisitor extends antlr4ng_1.AbstractParseTreeVisitor {
|
|
|
46
46
|
* @return the visitor result
|
|
47
47
|
*/
|
|
48
48
|
visitSugarDecl;
|
|
49
|
-
/**
|
|
50
|
-
* Visit a parse tree produced by `TagSetParser.pattern`.
|
|
51
|
-
* @param ctx the parse tree
|
|
52
|
-
* @return the visitor result
|
|
53
|
-
*/
|
|
54
|
-
visitPattern;
|
|
55
49
|
/**
|
|
56
50
|
* Visit a parse tree produced by `TagSetParser.valueList`.
|
|
57
51
|
* @param ctx the parse tree
|
package/lib/cjs/visitor.js
CHANGED
|
@@ -3,12 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.TagSetASTVisitor = void 0;
|
|
4
4
|
const TagSetVisitor_js_1 = require("./generated/TagSetVisitor.js");
|
|
5
5
|
const bitmask_js_1 = require("./bitmask.js");
|
|
6
|
-
function extractPatternIds(ctx) {
|
|
7
|
-
return ctx
|
|
8
|
-
.WORD()
|
|
9
|
-
.map((w) => w.getText())
|
|
10
|
-
.filter((t) => t !== '_');
|
|
11
|
-
}
|
|
12
6
|
function extractValues(ctx) {
|
|
13
7
|
return ctx.valueItem().map((vi) => {
|
|
14
8
|
const parts = [
|
|
@@ -59,8 +53,8 @@ class TagSetASTVisitor extends TagSetVisitor_js_1.TagSetVisitor {
|
|
|
59
53
|
this.explicitSets.push({ id, label, index: this.setIndex++ });
|
|
60
54
|
};
|
|
61
55
|
visitItemDecl = (ctx) => {
|
|
62
|
-
const
|
|
63
|
-
const patternIds =
|
|
56
|
+
const id = ctx.WORD().getText();
|
|
57
|
+
const patternIds = id === '_' ? [] : [id];
|
|
64
58
|
const values = extractValues(ctx.valueList());
|
|
65
59
|
this.rawItems.push({ patternIds, values });
|
|
66
60
|
};
|
|
@@ -75,7 +69,7 @@ class TagSetASTVisitor extends TagSetVisitor_js_1.TagSetVisitor {
|
|
|
75
69
|
buildAST() {
|
|
76
70
|
const sets = autoDetectSets(this.explicitSets, this.rawItems);
|
|
77
71
|
const items = this.rawItems.map((raw) => {
|
|
78
|
-
const pattern = raw.patternIds.join('
|
|
72
|
+
const pattern = raw.patternIds.join(',');
|
|
79
73
|
const bitmask = (0, bitmask_js_1.calcBitmask)(pattern, sets);
|
|
80
74
|
return { pattern, bitmask, values: raw.values };
|
|
81
75
|
});
|
package/lib/esm/bitmask.js
CHANGED