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
|
@@ -2,28 +2,28 @@ import * as antlr from "antlr4ng";
|
|
|
2
2
|
export class TagSetLexer extends antlr.Lexer {
|
|
3
3
|
static SET = 1;
|
|
4
4
|
static ITEM = 2;
|
|
5
|
-
static
|
|
6
|
-
static
|
|
7
|
-
static
|
|
8
|
-
static
|
|
9
|
-
static
|
|
5
|
+
static COMMA = 3;
|
|
6
|
+
static COLON = 4;
|
|
7
|
+
static QUOTED_STRING = 5;
|
|
8
|
+
static WORD = 6;
|
|
9
|
+
static COMMENT = 7;
|
|
10
10
|
static NL = 8;
|
|
11
11
|
static WS = 9;
|
|
12
12
|
static channelNames = [
|
|
13
13
|
"DEFAULT_TOKEN_CHANNEL", "HIDDEN"
|
|
14
14
|
];
|
|
15
15
|
static literalNames = [
|
|
16
|
-
null, "'set'", "'item'", "'
|
|
16
|
+
null, "'set'", "'item'", "','", "':'"
|
|
17
17
|
];
|
|
18
18
|
static symbolicNames = [
|
|
19
|
-
null, "SET", "ITEM", "
|
|
20
|
-
"NL", "WS"
|
|
19
|
+
null, "SET", "ITEM", "COMMA", "COLON", "QUOTED_STRING", "WORD",
|
|
20
|
+
"COMMENT", "NL", "WS"
|
|
21
21
|
];
|
|
22
22
|
static modeNames = [
|
|
23
23
|
"DEFAULT_MODE",
|
|
24
24
|
];
|
|
25
25
|
static ruleNames = [
|
|
26
|
-
"SET", "ITEM", "
|
|
26
|
+
"SET", "ITEM", "COMMA", "COLON", "QUOTED_STRING", "WORD", "COMMENT",
|
|
27
27
|
"NL", "WS",
|
|
28
28
|
];
|
|
29
29
|
constructor(input) {
|
|
@@ -38,27 +38,29 @@ export class TagSetLexer extends antlr.Lexer {
|
|
|
38
38
|
get channelNames() { return TagSetLexer.channelNames; }
|
|
39
39
|
get modeNames() { return TagSetLexer.modeNames; }
|
|
40
40
|
static _serializedATN = [
|
|
41
|
-
4, 0, 9,
|
|
41
|
+
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,
|
|
42
42
|
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,
|
|
43
|
-
2, 1, 3, 1, 3, 1, 4, 1, 4,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
0, 0, 0, 0,
|
|
50
|
-
0, 0, 0,
|
|
51
|
-
1, 0, 0, 0,
|
|
52
|
-
0,
|
|
53
|
-
|
|
54
|
-
44, 0, 0,
|
|
55
|
-
|
|
56
|
-
0, 0, 0,
|
|
57
|
-
|
|
58
|
-
0,
|
|
59
|
-
1, 0, 0, 0,
|
|
60
|
-
|
|
61
|
-
|
|
43
|
+
2, 1, 3, 1, 3, 1, 4, 1, 4, 5, 4, 35, 8, 4, 10, 4, 12, 4, 38, 9, 4, 1, 4, 1, 4, 1, 5, 4, 5, 43,
|
|
44
|
+
8, 5, 11, 5, 12, 5, 44, 1, 6, 1, 6, 5, 6, 49, 8, 6, 10, 6, 12, 6, 52, 9, 6, 1, 6, 1, 6, 1, 7,
|
|
45
|
+
4, 7, 57, 8, 7, 11, 7, 12, 7, 58, 1, 8, 4, 8, 62, 8, 8, 11, 8, 12, 8, 63, 1, 8, 1, 8, 0, 0,
|
|
46
|
+
9, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 1, 0, 4, 3, 0, 10, 10, 13, 13,
|
|
47
|
+
34, 34, 6, 0, 9, 10, 13, 13, 32, 32, 34, 34, 44, 44, 58, 58, 2, 0, 10, 10, 13, 13, 2, 0,
|
|
48
|
+
9, 9, 32, 32, 71, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9,
|
|
49
|
+
1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 1, 19,
|
|
50
|
+
1, 0, 0, 0, 3, 23, 1, 0, 0, 0, 5, 28, 1, 0, 0, 0, 7, 30, 1, 0, 0, 0, 9, 32, 1, 0, 0, 0, 11, 42,
|
|
51
|
+
1, 0, 0, 0, 13, 46, 1, 0, 0, 0, 15, 56, 1, 0, 0, 0, 17, 61, 1, 0, 0, 0, 19, 20, 5, 115, 0,
|
|
52
|
+
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,
|
|
53
|
+
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,
|
|
54
|
+
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,
|
|
55
|
+
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,
|
|
56
|
+
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,
|
|
57
|
+
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,
|
|
58
|
+
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,
|
|
59
|
+
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,
|
|
60
|
+
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,
|
|
61
|
+
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,
|
|
62
|
+
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,
|
|
63
|
+
0, 65, 66, 6, 8, 0, 0, 66, 18, 1, 0, 0, 0, 6, 0, 36, 44, 50, 58, 63, 1, 6, 0, 0
|
|
62
64
|
];
|
|
63
65
|
static __ATN;
|
|
64
66
|
static get _ATN() {
|
|
@@ -63,16 +63,6 @@ export class TagSetListener {
|
|
|
63
63
|
* @param ctx the parse tree
|
|
64
64
|
*/
|
|
65
65
|
exitSugarDecl;
|
|
66
|
-
/**
|
|
67
|
-
* Enter a parse tree produced by `TagSetParser.pattern`.
|
|
68
|
-
* @param ctx the parse tree
|
|
69
|
-
*/
|
|
70
|
-
enterPattern;
|
|
71
|
-
/**
|
|
72
|
-
* Exit a parse tree produced by `TagSetParser.pattern`.
|
|
73
|
-
* @param ctx the parse tree
|
|
74
|
-
*/
|
|
75
|
-
exitPattern;
|
|
76
66
|
/**
|
|
77
67
|
* Enter a parse tree produced by `TagSetParser.valueList`.
|
|
78
68
|
* @param ctx the parse tree
|
|
@@ -2,11 +2,11 @@ import * as antlr from "antlr4ng";
|
|
|
2
2
|
export class TagSetParser extends antlr.Parser {
|
|
3
3
|
static SET = 1;
|
|
4
4
|
static ITEM = 2;
|
|
5
|
-
static
|
|
6
|
-
static
|
|
7
|
-
static
|
|
8
|
-
static
|
|
9
|
-
static
|
|
5
|
+
static COMMA = 3;
|
|
6
|
+
static COLON = 4;
|
|
7
|
+
static QUOTED_STRING = 5;
|
|
8
|
+
static WORD = 6;
|
|
9
|
+
static COMMENT = 7;
|
|
10
10
|
static NL = 8;
|
|
11
11
|
static WS = 9;
|
|
12
12
|
static RULE_program = 0;
|
|
@@ -15,19 +15,18 @@ export class TagSetParser extends antlr.Parser {
|
|
|
15
15
|
static RULE_labelPart = 3;
|
|
16
16
|
static RULE_itemDecl = 4;
|
|
17
17
|
static RULE_sugarDecl = 5;
|
|
18
|
-
static
|
|
19
|
-
static
|
|
20
|
-
static RULE_valueItem = 8;
|
|
18
|
+
static RULE_valueList = 6;
|
|
19
|
+
static RULE_valueItem = 7;
|
|
21
20
|
static literalNames = [
|
|
22
|
-
null, "'set'", "'item'", "'
|
|
21
|
+
null, "'set'", "'item'", "','", "':'"
|
|
23
22
|
];
|
|
24
23
|
static symbolicNames = [
|
|
25
|
-
null, "SET", "ITEM", "
|
|
26
|
-
"NL", "WS"
|
|
24
|
+
null, "SET", "ITEM", "COMMA", "COLON", "QUOTED_STRING", "WORD",
|
|
25
|
+
"COMMENT", "NL", "WS"
|
|
27
26
|
];
|
|
28
27
|
static ruleNames = [
|
|
29
28
|
"program", "line", "setDecl", "labelPart", "itemDecl", "sugarDecl",
|
|
30
|
-
"
|
|
29
|
+
"valueList", "valueItem",
|
|
31
30
|
];
|
|
32
31
|
get grammarFileName() { return "TagSet.g4"; }
|
|
33
32
|
get literalNames() { return TagSetParser.literalNames; }
|
|
@@ -48,17 +47,17 @@ export class TagSetParser extends antlr.Parser {
|
|
|
48
47
|
try {
|
|
49
48
|
this.enterOuterAlt(localContext, 1);
|
|
50
49
|
{
|
|
51
|
-
this.state =
|
|
50
|
+
this.state = 20;
|
|
52
51
|
this.errorHandler.sync(this);
|
|
53
52
|
_la = this.tokenStream.LA(1);
|
|
54
|
-
while ((((_la) & ~0x1F) === 0 && ((1 << _la) &
|
|
53
|
+
while ((((_la) & ~0x1F) === 0 && ((1 << _la) & 326) !== 0)) {
|
|
55
54
|
{
|
|
56
|
-
this.state =
|
|
55
|
+
this.state = 18;
|
|
57
56
|
this.errorHandler.sync(this);
|
|
58
57
|
switch (this.tokenStream.LA(1)) {
|
|
59
58
|
case TagSetParser.NL:
|
|
60
59
|
{
|
|
61
|
-
this.state =
|
|
60
|
+
this.state = 16;
|
|
62
61
|
this.match(TagSetParser.NL);
|
|
63
62
|
}
|
|
64
63
|
break;
|
|
@@ -66,7 +65,7 @@ export class TagSetParser extends antlr.Parser {
|
|
|
66
65
|
case TagSetParser.ITEM:
|
|
67
66
|
case TagSetParser.WORD:
|
|
68
67
|
{
|
|
69
|
-
this.state =
|
|
68
|
+
this.state = 17;
|
|
70
69
|
this.line();
|
|
71
70
|
}
|
|
72
71
|
break;
|
|
@@ -74,11 +73,11 @@ export class TagSetParser extends antlr.Parser {
|
|
|
74
73
|
throw new antlr.NoViableAltException(this);
|
|
75
74
|
}
|
|
76
75
|
}
|
|
77
|
-
this.state =
|
|
76
|
+
this.state = 22;
|
|
78
77
|
this.errorHandler.sync(this);
|
|
79
78
|
_la = this.tokenStream.LA(1);
|
|
80
79
|
}
|
|
81
|
-
this.state =
|
|
80
|
+
this.state = 23;
|
|
82
81
|
this.match(TagSetParser.EOF);
|
|
83
82
|
}
|
|
84
83
|
}
|
|
@@ -102,36 +101,36 @@ export class TagSetParser extends antlr.Parser {
|
|
|
102
101
|
try {
|
|
103
102
|
this.enterOuterAlt(localContext, 1);
|
|
104
103
|
{
|
|
105
|
-
this.state =
|
|
104
|
+
this.state = 28;
|
|
106
105
|
this.errorHandler.sync(this);
|
|
107
106
|
switch (this.tokenStream.LA(1)) {
|
|
108
107
|
case TagSetParser.SET:
|
|
109
108
|
{
|
|
110
|
-
this.state =
|
|
109
|
+
this.state = 25;
|
|
111
110
|
this.setDecl();
|
|
112
111
|
}
|
|
113
112
|
break;
|
|
114
113
|
case TagSetParser.ITEM:
|
|
115
114
|
{
|
|
116
|
-
this.state =
|
|
115
|
+
this.state = 26;
|
|
117
116
|
this.itemDecl();
|
|
118
117
|
}
|
|
119
118
|
break;
|
|
120
119
|
case TagSetParser.WORD:
|
|
121
120
|
{
|
|
122
|
-
this.state =
|
|
121
|
+
this.state = 27;
|
|
123
122
|
this.sugarDecl();
|
|
124
123
|
}
|
|
125
124
|
break;
|
|
126
125
|
default:
|
|
127
126
|
throw new antlr.NoViableAltException(this);
|
|
128
127
|
}
|
|
129
|
-
this.state =
|
|
128
|
+
this.state = 31;
|
|
130
129
|
this.errorHandler.sync(this);
|
|
131
130
|
switch (this.interpreter.adaptivePredict(this.tokenStream, 3, this.context)) {
|
|
132
131
|
case 1:
|
|
133
132
|
{
|
|
134
|
-
this.state =
|
|
133
|
+
this.state = 30;
|
|
135
134
|
this.match(TagSetParser.NL);
|
|
136
135
|
}
|
|
137
136
|
break;
|
|
@@ -159,11 +158,11 @@ export class TagSetParser extends antlr.Parser {
|
|
|
159
158
|
let alternative;
|
|
160
159
|
this.enterOuterAlt(localContext, 1);
|
|
161
160
|
{
|
|
162
|
-
this.state =
|
|
161
|
+
this.state = 33;
|
|
163
162
|
this.match(TagSetParser.SET);
|
|
164
|
-
this.state =
|
|
163
|
+
this.state = 34;
|
|
165
164
|
this.match(TagSetParser.WORD);
|
|
166
|
-
this.state =
|
|
165
|
+
this.state = 36;
|
|
167
166
|
this.errorHandler.sync(this);
|
|
168
167
|
alternative = 1;
|
|
169
168
|
do {
|
|
@@ -171,7 +170,7 @@ export class TagSetParser extends antlr.Parser {
|
|
|
171
170
|
case 1:
|
|
172
171
|
{
|
|
173
172
|
{
|
|
174
|
-
this.state =
|
|
173
|
+
this.state = 35;
|
|
175
174
|
this.labelPart();
|
|
176
175
|
}
|
|
177
176
|
}
|
|
@@ -179,7 +178,7 @@ export class TagSetParser extends antlr.Parser {
|
|
|
179
178
|
default:
|
|
180
179
|
throw new antlr.NoViableAltException(this);
|
|
181
180
|
}
|
|
182
|
-
this.state =
|
|
181
|
+
this.state = 38;
|
|
183
182
|
this.errorHandler.sync(this);
|
|
184
183
|
alternative = this.interpreter.adaptivePredict(this.tokenStream, 4, this.context);
|
|
185
184
|
} while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER);
|
|
@@ -206,9 +205,9 @@ export class TagSetParser extends antlr.Parser {
|
|
|
206
205
|
try {
|
|
207
206
|
this.enterOuterAlt(localContext, 1);
|
|
208
207
|
{
|
|
209
|
-
this.state =
|
|
208
|
+
this.state = 40;
|
|
210
209
|
_la = this.tokenStream.LA(1);
|
|
211
|
-
if (!(_la ===
|
|
210
|
+
if (!(_la === 5 || _la === 6)) {
|
|
212
211
|
this.errorHandler.recoverInline(this);
|
|
213
212
|
}
|
|
214
213
|
else {
|
|
@@ -237,11 +236,11 @@ export class TagSetParser extends antlr.Parser {
|
|
|
237
236
|
try {
|
|
238
237
|
this.enterOuterAlt(localContext, 1);
|
|
239
238
|
{
|
|
240
|
-
this.state =
|
|
239
|
+
this.state = 42;
|
|
241
240
|
this.match(TagSetParser.ITEM);
|
|
242
|
-
this.state =
|
|
243
|
-
this.
|
|
244
|
-
this.state =
|
|
241
|
+
this.state = 43;
|
|
242
|
+
this.match(TagSetParser.WORD);
|
|
243
|
+
this.state = 44;
|
|
245
244
|
this.valueList();
|
|
246
245
|
}
|
|
247
246
|
}
|
|
@@ -266,27 +265,27 @@ export class TagSetParser extends antlr.Parser {
|
|
|
266
265
|
try {
|
|
267
266
|
this.enterOuterAlt(localContext, 1);
|
|
268
267
|
{
|
|
269
|
-
this.state =
|
|
268
|
+
this.state = 46;
|
|
270
269
|
this.match(TagSetParser.WORD);
|
|
271
|
-
this.state =
|
|
270
|
+
this.state = 51;
|
|
272
271
|
this.errorHandler.sync(this);
|
|
273
272
|
_la = this.tokenStream.LA(1);
|
|
274
|
-
while (_la ===
|
|
273
|
+
while (_la === 3) {
|
|
275
274
|
{
|
|
276
275
|
{
|
|
277
|
-
this.state =
|
|
276
|
+
this.state = 47;
|
|
278
277
|
this.match(TagSetParser.COMMA);
|
|
279
|
-
this.state =
|
|
278
|
+
this.state = 48;
|
|
280
279
|
this.match(TagSetParser.WORD);
|
|
281
280
|
}
|
|
282
281
|
}
|
|
283
|
-
this.state =
|
|
282
|
+
this.state = 53;
|
|
284
283
|
this.errorHandler.sync(this);
|
|
285
284
|
_la = this.tokenStream.LA(1);
|
|
286
285
|
}
|
|
287
|
-
this.state =
|
|
286
|
+
this.state = 54;
|
|
288
287
|
this.match(TagSetParser.COLON);
|
|
289
|
-
this.state =
|
|
288
|
+
this.state = 55;
|
|
290
289
|
this.valueList();
|
|
291
290
|
}
|
|
292
291
|
}
|
|
@@ -304,69 +303,28 @@ export class TagSetParser extends antlr.Parser {
|
|
|
304
303
|
}
|
|
305
304
|
return localContext;
|
|
306
305
|
}
|
|
307
|
-
pattern() {
|
|
308
|
-
let localContext = new PatternContext(this.context, this.state);
|
|
309
|
-
this.enterRule(localContext, 12, TagSetParser.RULE_pattern);
|
|
310
|
-
let _la;
|
|
311
|
-
try {
|
|
312
|
-
this.enterOuterAlt(localContext, 1);
|
|
313
|
-
{
|
|
314
|
-
this.state = 59;
|
|
315
|
-
this.match(TagSetParser.WORD);
|
|
316
|
-
this.state = 64;
|
|
317
|
-
this.errorHandler.sync(this);
|
|
318
|
-
_la = this.tokenStream.LA(1);
|
|
319
|
-
while (_la === 3) {
|
|
320
|
-
{
|
|
321
|
-
{
|
|
322
|
-
this.state = 60;
|
|
323
|
-
this.match(TagSetParser.AMP);
|
|
324
|
-
this.state = 61;
|
|
325
|
-
this.match(TagSetParser.WORD);
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
this.state = 66;
|
|
329
|
-
this.errorHandler.sync(this);
|
|
330
|
-
_la = this.tokenStream.LA(1);
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
catch (re) {
|
|
335
|
-
if (re instanceof antlr.RecognitionException) {
|
|
336
|
-
this.errorHandler.reportError(this, re);
|
|
337
|
-
this.errorHandler.recover(this, re);
|
|
338
|
-
}
|
|
339
|
-
else {
|
|
340
|
-
throw re;
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
finally {
|
|
344
|
-
this.exitRule();
|
|
345
|
-
}
|
|
346
|
-
return localContext;
|
|
347
|
-
}
|
|
348
306
|
valueList() {
|
|
349
307
|
let localContext = new ValueListContext(this.context, this.state);
|
|
350
|
-
this.enterRule(localContext,
|
|
308
|
+
this.enterRule(localContext, 12, TagSetParser.RULE_valueList);
|
|
351
309
|
let _la;
|
|
352
310
|
try {
|
|
353
311
|
this.enterOuterAlt(localContext, 1);
|
|
354
312
|
{
|
|
355
|
-
this.state =
|
|
313
|
+
this.state = 57;
|
|
356
314
|
this.valueItem();
|
|
357
|
-
this.state =
|
|
315
|
+
this.state = 62;
|
|
358
316
|
this.errorHandler.sync(this);
|
|
359
317
|
_la = this.tokenStream.LA(1);
|
|
360
|
-
while (_la ===
|
|
318
|
+
while (_la === 3) {
|
|
361
319
|
{
|
|
362
320
|
{
|
|
363
|
-
this.state =
|
|
321
|
+
this.state = 58;
|
|
364
322
|
this.match(TagSetParser.COMMA);
|
|
365
|
-
this.state =
|
|
323
|
+
this.state = 59;
|
|
366
324
|
this.valueItem();
|
|
367
325
|
}
|
|
368
326
|
}
|
|
369
|
-
this.state =
|
|
327
|
+
this.state = 64;
|
|
370
328
|
this.errorHandler.sync(this);
|
|
371
329
|
_la = this.tokenStream.LA(1);
|
|
372
330
|
}
|
|
@@ -388,13 +346,13 @@ export class TagSetParser extends antlr.Parser {
|
|
|
388
346
|
}
|
|
389
347
|
valueItem() {
|
|
390
348
|
let localContext = new ValueItemContext(this.context, this.state);
|
|
391
|
-
this.enterRule(localContext,
|
|
349
|
+
this.enterRule(localContext, 14, TagSetParser.RULE_valueItem);
|
|
392
350
|
let _la;
|
|
393
351
|
try {
|
|
394
352
|
let alternative;
|
|
395
353
|
this.enterOuterAlt(localContext, 1);
|
|
396
354
|
{
|
|
397
|
-
this.state =
|
|
355
|
+
this.state = 66;
|
|
398
356
|
this.errorHandler.sync(this);
|
|
399
357
|
alternative = 1;
|
|
400
358
|
do {
|
|
@@ -402,9 +360,9 @@ export class TagSetParser extends antlr.Parser {
|
|
|
402
360
|
case 1:
|
|
403
361
|
{
|
|
404
362
|
{
|
|
405
|
-
this.state =
|
|
363
|
+
this.state = 65;
|
|
406
364
|
_la = this.tokenStream.LA(1);
|
|
407
|
-
if (!(_la ===
|
|
365
|
+
if (!(_la === 5 || _la === 6)) {
|
|
408
366
|
this.errorHandler.recoverInline(this);
|
|
409
367
|
}
|
|
410
368
|
else {
|
|
@@ -417,9 +375,9 @@ export class TagSetParser extends antlr.Parser {
|
|
|
417
375
|
default:
|
|
418
376
|
throw new antlr.NoViableAltException(this);
|
|
419
377
|
}
|
|
420
|
-
this.state =
|
|
378
|
+
this.state = 68;
|
|
421
379
|
this.errorHandler.sync(this);
|
|
422
|
-
alternative = this.interpreter.adaptivePredict(this.tokenStream,
|
|
380
|
+
alternative = this.interpreter.adaptivePredict(this.tokenStream, 7, this.context);
|
|
423
381
|
} while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER);
|
|
424
382
|
}
|
|
425
383
|
}
|
|
@@ -438,31 +396,28 @@ export class TagSetParser extends antlr.Parser {
|
|
|
438
396
|
return localContext;
|
|
439
397
|
}
|
|
440
398
|
static _serializedATN = [
|
|
441
|
-
4, 1, 9,
|
|
442
|
-
2, 7, 7, 7,
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
0, 0,
|
|
448
|
-
0, 0,
|
|
449
|
-
0, 0, 0,
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
0,
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
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,
|
|
464
|
-
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,
|
|
465
|
-
1, 0, 0, 0, 9, 20, 22, 30, 33, 40, 53, 64, 72, 78
|
|
399
|
+
4, 1, 9, 71, 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, 6, 7, 6,
|
|
400
|
+
2, 7, 7, 7, 1, 0, 1, 0, 5, 0, 19, 8, 0, 10, 0, 12, 0, 22, 9, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1,
|
|
401
|
+
3, 1, 29, 8, 1, 1, 1, 3, 1, 32, 8, 1, 1, 2, 1, 2, 1, 2, 4, 2, 37, 8, 2, 11, 2, 12, 2, 38, 1,
|
|
402
|
+
3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 5, 5, 50, 8, 5, 10, 5, 12, 5, 53, 9, 5, 1,
|
|
403
|
+
5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 5, 6, 61, 8, 6, 10, 6, 12, 6, 64, 9, 6, 1, 7, 4, 7, 67, 8, 7,
|
|
404
|
+
11, 7, 12, 7, 68, 1, 7, 0, 0, 8, 0, 2, 4, 6, 8, 10, 12, 14, 0, 1, 1, 0, 5, 6, 71, 0, 20, 1,
|
|
405
|
+
0, 0, 0, 2, 28, 1, 0, 0, 0, 4, 33, 1, 0, 0, 0, 6, 40, 1, 0, 0, 0, 8, 42, 1, 0, 0, 0, 10, 46,
|
|
406
|
+
1, 0, 0, 0, 12, 57, 1, 0, 0, 0, 14, 66, 1, 0, 0, 0, 16, 19, 5, 8, 0, 0, 17, 19, 3, 2, 1, 0,
|
|
407
|
+
18, 16, 1, 0, 0, 0, 18, 17, 1, 0, 0, 0, 19, 22, 1, 0, 0, 0, 20, 18, 1, 0, 0, 0, 20, 21, 1,
|
|
408
|
+
0, 0, 0, 21, 23, 1, 0, 0, 0, 22, 20, 1, 0, 0, 0, 23, 24, 5, 0, 0, 1, 24, 1, 1, 0, 0, 0, 25,
|
|
409
|
+
29, 3, 4, 2, 0, 26, 29, 3, 8, 4, 0, 27, 29, 3, 10, 5, 0, 28, 25, 1, 0, 0, 0, 28, 26, 1, 0,
|
|
410
|
+
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,
|
|
411
|
+
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,
|
|
412
|
+
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,
|
|
413
|
+
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,
|
|
414
|
+
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,
|
|
415
|
+
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,
|
|
416
|
+
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,
|
|
417
|
+
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,
|
|
418
|
+
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,
|
|
419
|
+
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,
|
|
420
|
+
69, 15, 1, 0, 0, 0, 8, 18, 20, 28, 31, 38, 51, 62, 68
|
|
466
421
|
];
|
|
467
422
|
static __ATN;
|
|
468
423
|
static get _ATN() {
|
|
@@ -635,8 +590,8 @@ export class ItemDeclContext extends antlr.ParserRuleContext {
|
|
|
635
590
|
ITEM() {
|
|
636
591
|
return this.getToken(TagSetParser.ITEM, 0);
|
|
637
592
|
}
|
|
638
|
-
|
|
639
|
-
return this.
|
|
593
|
+
WORD() {
|
|
594
|
+
return this.getToken(TagSetParser.WORD, 0);
|
|
640
595
|
}
|
|
641
596
|
valueList() {
|
|
642
597
|
return this.getRuleContext(0, ValueListContext);
|
|
@@ -711,48 +666,6 @@ export class SugarDeclContext extends antlr.ParserRuleContext {
|
|
|
711
666
|
}
|
|
712
667
|
}
|
|
713
668
|
}
|
|
714
|
-
export class PatternContext extends antlr.ParserRuleContext {
|
|
715
|
-
constructor(parent, invokingState) {
|
|
716
|
-
super(parent, invokingState);
|
|
717
|
-
}
|
|
718
|
-
WORD(i) {
|
|
719
|
-
if (i === undefined) {
|
|
720
|
-
return this.getTokens(TagSetParser.WORD);
|
|
721
|
-
}
|
|
722
|
-
else {
|
|
723
|
-
return this.getToken(TagSetParser.WORD, i);
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
AMP(i) {
|
|
727
|
-
if (i === undefined) {
|
|
728
|
-
return this.getTokens(TagSetParser.AMP);
|
|
729
|
-
}
|
|
730
|
-
else {
|
|
731
|
-
return this.getToken(TagSetParser.AMP, i);
|
|
732
|
-
}
|
|
733
|
-
}
|
|
734
|
-
get ruleIndex() {
|
|
735
|
-
return TagSetParser.RULE_pattern;
|
|
736
|
-
}
|
|
737
|
-
enterRule(listener) {
|
|
738
|
-
if (listener.enterPattern) {
|
|
739
|
-
listener.enterPattern(this);
|
|
740
|
-
}
|
|
741
|
-
}
|
|
742
|
-
exitRule(listener) {
|
|
743
|
-
if (listener.exitPattern) {
|
|
744
|
-
listener.exitPattern(this);
|
|
745
|
-
}
|
|
746
|
-
}
|
|
747
|
-
accept(visitor) {
|
|
748
|
-
if (visitor.visitPattern) {
|
|
749
|
-
return visitor.visitPattern(this);
|
|
750
|
-
}
|
|
751
|
-
else {
|
|
752
|
-
return visitor.visitChildren(this);
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
}
|
|
756
669
|
export class ValueListContext extends antlr.ParserRuleContext {
|
|
757
670
|
constructor(parent, invokingState) {
|
|
758
671
|
super(parent, invokingState);
|
|
@@ -43,12 +43,6 @@ export class TagSetVisitor extends AbstractParseTreeVisitor {
|
|
|
43
43
|
* @return the visitor result
|
|
44
44
|
*/
|
|
45
45
|
visitSugarDecl;
|
|
46
|
-
/**
|
|
47
|
-
* Visit a parse tree produced by `TagSetParser.pattern`.
|
|
48
|
-
* @param ctx the parse tree
|
|
49
|
-
* @return the visitor result
|
|
50
|
-
*/
|
|
51
|
-
visitPattern;
|
|
52
46
|
/**
|
|
53
47
|
* Visit a parse tree produced by `TagSetParser.valueList`.
|
|
54
48
|
* @param ctx the parse tree
|
package/lib/esm/visitor.js
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { TagSetVisitor } from './generated/TagSetVisitor.js';
|
|
2
2
|
import { calcBitmask } from './bitmask.js';
|
|
3
|
-
function extractPatternIds(ctx) {
|
|
4
|
-
return ctx
|
|
5
|
-
.WORD()
|
|
6
|
-
.map((w) => w.getText())
|
|
7
|
-
.filter((t) => t !== '_');
|
|
8
|
-
}
|
|
9
3
|
function extractValues(ctx) {
|
|
10
4
|
return ctx.valueItem().map((vi) => {
|
|
11
5
|
const parts = [
|
|
@@ -56,8 +50,8 @@ export class TagSetASTVisitor extends TagSetVisitor {
|
|
|
56
50
|
this.explicitSets.push({ id, label, index: this.setIndex++ });
|
|
57
51
|
};
|
|
58
52
|
visitItemDecl = (ctx) => {
|
|
59
|
-
const
|
|
60
|
-
const patternIds =
|
|
53
|
+
const id = ctx.WORD().getText();
|
|
54
|
+
const patternIds = id === '_' ? [] : [id];
|
|
61
55
|
const values = extractValues(ctx.valueList());
|
|
62
56
|
this.rawItems.push({ patternIds, values });
|
|
63
57
|
};
|
|
@@ -72,7 +66,7 @@ export class TagSetASTVisitor extends TagSetVisitor {
|
|
|
72
66
|
buildAST() {
|
|
73
67
|
const sets = autoDetectSets(this.explicitSets, this.rawItems);
|
|
74
68
|
const items = this.rawItems.map((raw) => {
|
|
75
|
-
const pattern = raw.patternIds.join('
|
|
69
|
+
const pattern = raw.patternIds.join(',');
|
|
76
70
|
const bitmask = calcBitmask(pattern, sets);
|
|
77
71
|
return { pattern, bitmask, values: raw.values };
|
|
78
72
|
});
|
|
@@ -2,11 +2,11 @@ import * as antlr from "antlr4ng";
|
|
|
2
2
|
export declare class TagSetLexer extends antlr.Lexer {
|
|
3
3
|
static readonly SET = 1;
|
|
4
4
|
static readonly ITEM = 2;
|
|
5
|
-
static readonly
|
|
6
|
-
static readonly
|
|
7
|
-
static readonly
|
|
8
|
-
static readonly
|
|
9
|
-
static readonly
|
|
5
|
+
static readonly COMMA = 3;
|
|
6
|
+
static readonly COLON = 4;
|
|
7
|
+
static readonly QUOTED_STRING = 5;
|
|
8
|
+
static readonly WORD = 6;
|
|
9
|
+
static readonly COMMENT = 7;
|
|
10
10
|
static readonly NL = 8;
|
|
11
11
|
static readonly WS = 9;
|
|
12
12
|
static readonly channelNames: string[];
|