@letsrunit/gherkin 0.1.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/README.md +44 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.js +1638 -0
- package/dist/index.js.map +1 -0
- package/package.json +56 -0
- package/src/date.ts +0 -0
- package/src/feature.ts +127 -0
- package/src/index.ts +4 -0
- package/src/keys/parse-key-combo.ts +94 -0
- package/src/locator/compile.ts +172 -0
- package/src/locator/index.ts +2 -0
- package/src/locator/parser.js +1419 -0
- package/src/locator/parser.peggy +101 -0
- package/src/locator/regexp.ts +2 -0
- package/src/parameters.ts +80 -0
- package/src/sanitize.ts +7 -0
- package/src/value.ts +24 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1638 @@
|
|
|
1
|
+
import { parseDateString } from '@letsrunit/utils';
|
|
2
|
+
import { generateMessages } from '@cucumber/gherkin';
|
|
3
|
+
import { IdGenerator, SourceMediaType } from '@cucumber/messages';
|
|
4
|
+
|
|
5
|
+
// src/keys/parse-key-combo.ts
|
|
6
|
+
var SYNONYMS = {
|
|
7
|
+
// modifiers
|
|
8
|
+
"ctrl": "Control",
|
|
9
|
+
"control": "Control",
|
|
10
|
+
"cmd": "Meta",
|
|
11
|
+
"command": "Meta",
|
|
12
|
+
"meta": "Meta",
|
|
13
|
+
"opt": "Alt",
|
|
14
|
+
"option": "Alt",
|
|
15
|
+
"alt": "Alt",
|
|
16
|
+
"shift": "Shift",
|
|
17
|
+
// common keys
|
|
18
|
+
"enter": "Enter",
|
|
19
|
+
"return": "Enter",
|
|
20
|
+
"esc": "Escape",
|
|
21
|
+
"escape": "Escape",
|
|
22
|
+
"tab": "Tab",
|
|
23
|
+
"backspace": "Backspace",
|
|
24
|
+
"del": "Delete",
|
|
25
|
+
"delete": "Delete",
|
|
26
|
+
"space": "Space",
|
|
27
|
+
"home": "Home",
|
|
28
|
+
"end": "End",
|
|
29
|
+
"pageup": "PageUp",
|
|
30
|
+
"page up": "PageUp",
|
|
31
|
+
"pagedown": "PageDown",
|
|
32
|
+
"page down": "PageDown",
|
|
33
|
+
// arrows
|
|
34
|
+
"arrowup": "ArrowUp",
|
|
35
|
+
"arrow up": "ArrowUp",
|
|
36
|
+
"up": "ArrowUp",
|
|
37
|
+
"arrowdown": "ArrowDown",
|
|
38
|
+
"arrow down": "ArrowDown",
|
|
39
|
+
"down": "ArrowDown",
|
|
40
|
+
"arrowleft": "ArrowLeft",
|
|
41
|
+
"arrow left": "ArrowLeft",
|
|
42
|
+
"left": "ArrowLeft",
|
|
43
|
+
"arrowright": "ArrowRight",
|
|
44
|
+
"arrow right": "ArrowRight",
|
|
45
|
+
"right": "ArrowRight"
|
|
46
|
+
};
|
|
47
|
+
function normalizeToken(raw) {
|
|
48
|
+
const t = raw.trim().toLowerCase();
|
|
49
|
+
const fMatch = /^f([1-9]|1[0-2])$/.exec(t);
|
|
50
|
+
if (fMatch) return `F${fMatch[1]}`;
|
|
51
|
+
if (!(t in SYNONYMS)) {
|
|
52
|
+
if (t.length === 1) return raw.trim().length === 1 ? raw.trim().toUpperCase() : raw.trim();
|
|
53
|
+
return raw.trim();
|
|
54
|
+
}
|
|
55
|
+
return SYNONYMS[t];
|
|
56
|
+
}
|
|
57
|
+
var isModifier = (k) => k === "Control" || k === "Shift" || k === "Alt" || k === "Meta";
|
|
58
|
+
function parseKeyCombo(text) {
|
|
59
|
+
const parts = text.split("+").map((p) => p.trim()).filter(Boolean);
|
|
60
|
+
if (parts.length === 0) throw new Error(`Invalid key combo: "${text}"`);
|
|
61
|
+
const tokens = parts.map(normalizeToken);
|
|
62
|
+
const modifiers = [];
|
|
63
|
+
let key;
|
|
64
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
65
|
+
const tok = tokens[i];
|
|
66
|
+
const isLast = i === tokens.length - 1;
|
|
67
|
+
if (!isLast && isModifier(tok)) {
|
|
68
|
+
modifiers.push(tok);
|
|
69
|
+
} else if (isLast) {
|
|
70
|
+
key = tok;
|
|
71
|
+
} else {
|
|
72
|
+
if (!isModifier(tok)) {
|
|
73
|
+
throw new Error(`Only modifiers may precede the final key: "${text}"`);
|
|
74
|
+
}
|
|
75
|
+
modifiers.push(tok);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (!key) throw new Error(`Missing final key in combo: "${text}"`);
|
|
79
|
+
return { modifiers, key };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// src/locator/parser.js
|
|
83
|
+
var peg$SyntaxError = class extends SyntaxError {
|
|
84
|
+
constructor(message, expected, found, location) {
|
|
85
|
+
super(message);
|
|
86
|
+
this.expected = expected;
|
|
87
|
+
this.found = found;
|
|
88
|
+
this.location = location;
|
|
89
|
+
this.name = "SyntaxError";
|
|
90
|
+
}
|
|
91
|
+
format(sources) {
|
|
92
|
+
let str = "Error: " + this.message;
|
|
93
|
+
if (this.location) {
|
|
94
|
+
let src = null;
|
|
95
|
+
const st = sources.find((s2) => s2.source === this.location.source);
|
|
96
|
+
if (st) {
|
|
97
|
+
src = st.text.split(/\r\n|\n|\r/g);
|
|
98
|
+
}
|
|
99
|
+
const s = this.location.start;
|
|
100
|
+
const offset_s = this.location.source && typeof this.location.source.offset === "function" ? this.location.source.offset(s) : s;
|
|
101
|
+
const loc = this.location.source + ":" + offset_s.line + ":" + offset_s.column;
|
|
102
|
+
if (src) {
|
|
103
|
+
const e = this.location.end;
|
|
104
|
+
const filler = "".padEnd(offset_s.line.toString().length, " ");
|
|
105
|
+
const line = src[s.line - 1];
|
|
106
|
+
const last = s.line === e.line ? e.column : line.length + 1;
|
|
107
|
+
const hatLen = last - s.column || 1;
|
|
108
|
+
str += "\n --> " + loc + "\n" + filler + " |\n" + offset_s.line + " | " + line + "\n" + filler + " | " + "".padEnd(s.column - 1, " ") + "".padEnd(hatLen, "^");
|
|
109
|
+
} else {
|
|
110
|
+
str += "\n at " + loc;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return str;
|
|
114
|
+
}
|
|
115
|
+
static buildMessage(expected, found) {
|
|
116
|
+
function hex(ch) {
|
|
117
|
+
return ch.codePointAt(0).toString(16).toUpperCase();
|
|
118
|
+
}
|
|
119
|
+
const nonPrintable = Object.prototype.hasOwnProperty.call(RegExp.prototype, "unicode") ? new RegExp("[\\p{C}\\p{Mn}\\p{Mc}]", "gu") : null;
|
|
120
|
+
function unicodeEscape(s) {
|
|
121
|
+
if (nonPrintable) {
|
|
122
|
+
return s.replace(nonPrintable, (ch) => "\\u{" + hex(ch) + "}");
|
|
123
|
+
}
|
|
124
|
+
return s;
|
|
125
|
+
}
|
|
126
|
+
function literalEscape(s) {
|
|
127
|
+
return unicodeEscape(s.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\0/g, "\\0").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/[\x00-\x0F]/g, (ch) => "\\x0" + hex(ch)).replace(/[\x10-\x1F\x7F-\x9F]/g, (ch) => "\\x" + hex(ch)));
|
|
128
|
+
}
|
|
129
|
+
function classEscape(s) {
|
|
130
|
+
return unicodeEscape(s.replace(/\\/g, "\\\\").replace(/\]/g, "\\]").replace(/\^/g, "\\^").replace(/-/g, "\\-").replace(/\0/g, "\\0").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/[\x00-\x0F]/g, (ch) => "\\x0" + hex(ch)).replace(/[\x10-\x1F\x7F-\x9F]/g, (ch) => "\\x" + hex(ch)));
|
|
131
|
+
}
|
|
132
|
+
const DESCRIBE_EXPECTATION_FNS = {
|
|
133
|
+
literal(expectation) {
|
|
134
|
+
return '"' + literalEscape(expectation.text) + '"';
|
|
135
|
+
},
|
|
136
|
+
class(expectation) {
|
|
137
|
+
const escapedParts = expectation.parts.map(
|
|
138
|
+
(part) => Array.isArray(part) ? classEscape(part[0]) + "-" + classEscape(part[1]) : classEscape(part)
|
|
139
|
+
);
|
|
140
|
+
return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]" + (expectation.unicode ? "u" : "");
|
|
141
|
+
},
|
|
142
|
+
any() {
|
|
143
|
+
return "any character";
|
|
144
|
+
},
|
|
145
|
+
end() {
|
|
146
|
+
return "end of input";
|
|
147
|
+
},
|
|
148
|
+
other(expectation) {
|
|
149
|
+
return expectation.description;
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
function describeExpectation(expectation) {
|
|
153
|
+
return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
|
|
154
|
+
}
|
|
155
|
+
function describeExpected(expected2) {
|
|
156
|
+
const descriptions = expected2.map(describeExpectation);
|
|
157
|
+
descriptions.sort();
|
|
158
|
+
if (descriptions.length > 0) {
|
|
159
|
+
let j = 1;
|
|
160
|
+
for (let i = 1; i < descriptions.length; i++) {
|
|
161
|
+
if (descriptions[i - 1] !== descriptions[i]) {
|
|
162
|
+
descriptions[j] = descriptions[i];
|
|
163
|
+
j++;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
descriptions.length = j;
|
|
167
|
+
}
|
|
168
|
+
switch (descriptions.length) {
|
|
169
|
+
case 1:
|
|
170
|
+
return descriptions[0];
|
|
171
|
+
case 2:
|
|
172
|
+
return descriptions[0] + " or " + descriptions[1];
|
|
173
|
+
default:
|
|
174
|
+
return descriptions.slice(0, -1).join(", ") + ", or " + descriptions[descriptions.length - 1];
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
function describeFound(found2) {
|
|
178
|
+
return found2 ? '"' + literalEscape(found2) + '"' : "end of input";
|
|
179
|
+
}
|
|
180
|
+
return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
function peg$parse(input, options) {
|
|
184
|
+
options = options !== void 0 ? options : {};
|
|
185
|
+
const peg$FAILED = {};
|
|
186
|
+
const peg$source = options.grammarSource;
|
|
187
|
+
const peg$startRuleFunctions = {
|
|
188
|
+
Start: peg$parseStart
|
|
189
|
+
};
|
|
190
|
+
let peg$startRuleFunction = peg$parseStart;
|
|
191
|
+
const peg$c0 = "within";
|
|
192
|
+
const peg$c1 = "with";
|
|
193
|
+
const peg$c2 = "without";
|
|
194
|
+
const peg$c3 = "`";
|
|
195
|
+
const peg$c4 = "date";
|
|
196
|
+
const peg$c5 = "of";
|
|
197
|
+
const peg$c6 = "button";
|
|
198
|
+
const peg$c7 = "link";
|
|
199
|
+
const peg$c8 = "field";
|
|
200
|
+
const peg$c9 = "image";
|
|
201
|
+
const peg$c10 = "text";
|
|
202
|
+
const peg$c11 = "the";
|
|
203
|
+
const peg$c12 = '"';
|
|
204
|
+
const peg$c13 = '\\"';
|
|
205
|
+
const peg$r0 = /^[a-zA-Z]/;
|
|
206
|
+
const peg$r1 = /^[^`]/;
|
|
207
|
+
const peg$r2 = /^[a-zA-Z_]/;
|
|
208
|
+
const peg$r3 = /^[a-zA-Z0-9_\-]/;
|
|
209
|
+
const peg$r4 = /^[ \t\r\n]/;
|
|
210
|
+
const peg$e0 = peg$literalExpectation("within", true);
|
|
211
|
+
const peg$e1 = peg$classExpectation([["a", "z"], ["A", "Z"]], false, false, false);
|
|
212
|
+
const peg$e2 = peg$literalExpectation("with", true);
|
|
213
|
+
const peg$e3 = peg$literalExpectation("without", true);
|
|
214
|
+
const peg$e4 = peg$literalExpectation("`", false);
|
|
215
|
+
const peg$e5 = peg$classExpectation(["`"], true, false, false);
|
|
216
|
+
const peg$e6 = peg$literalExpectation("date", true);
|
|
217
|
+
const peg$e7 = peg$literalExpectation("of", true);
|
|
218
|
+
const peg$e8 = peg$anyExpectation();
|
|
219
|
+
const peg$e9 = peg$literalExpectation("button", true);
|
|
220
|
+
const peg$e10 = peg$literalExpectation("link", true);
|
|
221
|
+
const peg$e11 = peg$literalExpectation("field", true);
|
|
222
|
+
const peg$e12 = peg$literalExpectation("image", true);
|
|
223
|
+
const peg$e13 = peg$literalExpectation("text", true);
|
|
224
|
+
const peg$e14 = peg$literalExpectation("the", true);
|
|
225
|
+
const peg$e15 = peg$classExpectation([["a", "z"], ["A", "Z"], "_"], false, false, false);
|
|
226
|
+
const peg$e16 = peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"], "_", "-"], false, false, false);
|
|
227
|
+
const peg$e17 = peg$literalExpectation('"', false);
|
|
228
|
+
const peg$e18 = peg$literalExpectation('\\"', false);
|
|
229
|
+
const peg$e19 = peg$classExpectation([" ", " ", "\r", "\n"], false, false, false);
|
|
230
|
+
function peg$f0(e) {
|
|
231
|
+
return e;
|
|
232
|
+
}
|
|
233
|
+
function peg$f1(base, s) {
|
|
234
|
+
return s;
|
|
235
|
+
}
|
|
236
|
+
function peg$f2(base, rest) {
|
|
237
|
+
return { type: "Within", base, ancestors: rest ?? [] };
|
|
238
|
+
}
|
|
239
|
+
function peg$f3(sel, wp) {
|
|
240
|
+
return wp;
|
|
241
|
+
}
|
|
242
|
+
function peg$f4(sel, parts) {
|
|
243
|
+
const include = [], exclude = [];
|
|
244
|
+
for (const x of parts) {
|
|
245
|
+
(x.incl ? include : exclude).push(x.p);
|
|
246
|
+
}
|
|
247
|
+
return { type: "With", selector: sel, include, exclude };
|
|
248
|
+
}
|
|
249
|
+
function peg$f5(p) {
|
|
250
|
+
return { incl: true, p };
|
|
251
|
+
}
|
|
252
|
+
function peg$f6(p) {
|
|
253
|
+
return { incl: false, p };
|
|
254
|
+
}
|
|
255
|
+
function peg$f7(s) {
|
|
256
|
+
return { type: "Selector", mode: "raw", raw: s.trim() };
|
|
257
|
+
}
|
|
258
|
+
function peg$f8(base) {
|
|
259
|
+
return { type: "Selector", mode: "role", role: base.role, name: base.name };
|
|
260
|
+
}
|
|
261
|
+
function peg$f9(n) {
|
|
262
|
+
return { type: "Selector", mode: "date", name: n };
|
|
263
|
+
}
|
|
264
|
+
function peg$f10(s) {
|
|
265
|
+
return `"${s}"`;
|
|
266
|
+
}
|
|
267
|
+
function peg$f11(r, n) {
|
|
268
|
+
return { role: r, name: n ?? null };
|
|
269
|
+
}
|
|
270
|
+
function peg$f12(r, n) {
|
|
271
|
+
return { role: r, name: n };
|
|
272
|
+
}
|
|
273
|
+
function peg$f13(t) {
|
|
274
|
+
return { type: "Selector", mode: "tag", tag: t };
|
|
275
|
+
}
|
|
276
|
+
function peg$f14(sel) {
|
|
277
|
+
return { type: "HasDescendant", selector: sel };
|
|
278
|
+
}
|
|
279
|
+
function peg$f15(chars) {
|
|
280
|
+
return chars;
|
|
281
|
+
}
|
|
282
|
+
let peg$currPos = options.peg$currPos | 0;
|
|
283
|
+
const peg$posDetailsCache = [{ line: 1, column: 1 }];
|
|
284
|
+
let peg$maxFailPos = peg$currPos;
|
|
285
|
+
let peg$maxFailExpected = options.peg$maxFailExpected || [];
|
|
286
|
+
let peg$silentFails = options.peg$silentFails | 0;
|
|
287
|
+
let peg$result;
|
|
288
|
+
if (options.startRule) {
|
|
289
|
+
if (!(options.startRule in peg$startRuleFunctions)) {
|
|
290
|
+
throw new Error(`Can't start parsing from rule "` + options.startRule + '".');
|
|
291
|
+
}
|
|
292
|
+
peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
|
|
293
|
+
}
|
|
294
|
+
function peg$getUnicode(pos = peg$currPos) {
|
|
295
|
+
const cp = input.codePointAt(pos);
|
|
296
|
+
if (cp === void 0) {
|
|
297
|
+
return "";
|
|
298
|
+
}
|
|
299
|
+
return String.fromCodePoint(cp);
|
|
300
|
+
}
|
|
301
|
+
function peg$literalExpectation(text2, ignoreCase) {
|
|
302
|
+
return { type: "literal", text: text2, ignoreCase };
|
|
303
|
+
}
|
|
304
|
+
function peg$classExpectation(parts, inverted, ignoreCase, unicode) {
|
|
305
|
+
return { type: "class", parts, inverted, ignoreCase, unicode };
|
|
306
|
+
}
|
|
307
|
+
function peg$anyExpectation() {
|
|
308
|
+
return { type: "any" };
|
|
309
|
+
}
|
|
310
|
+
function peg$endExpectation() {
|
|
311
|
+
return { type: "end" };
|
|
312
|
+
}
|
|
313
|
+
function peg$computePosDetails(pos) {
|
|
314
|
+
let details = peg$posDetailsCache[pos];
|
|
315
|
+
let p;
|
|
316
|
+
if (details) {
|
|
317
|
+
return details;
|
|
318
|
+
} else {
|
|
319
|
+
if (pos >= peg$posDetailsCache.length) {
|
|
320
|
+
p = peg$posDetailsCache.length - 1;
|
|
321
|
+
} else {
|
|
322
|
+
p = pos;
|
|
323
|
+
while (!peg$posDetailsCache[--p]) {
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
details = peg$posDetailsCache[p];
|
|
327
|
+
details = {
|
|
328
|
+
line: details.line,
|
|
329
|
+
column: details.column
|
|
330
|
+
};
|
|
331
|
+
while (p < pos) {
|
|
332
|
+
if (input.charCodeAt(p) === 10) {
|
|
333
|
+
details.line++;
|
|
334
|
+
details.column = 1;
|
|
335
|
+
} else {
|
|
336
|
+
details.column++;
|
|
337
|
+
}
|
|
338
|
+
p++;
|
|
339
|
+
}
|
|
340
|
+
peg$posDetailsCache[pos] = details;
|
|
341
|
+
return details;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
function peg$computeLocation(startPos, endPos, offset2) {
|
|
345
|
+
const startPosDetails = peg$computePosDetails(startPos);
|
|
346
|
+
const endPosDetails = peg$computePosDetails(endPos);
|
|
347
|
+
const res = {
|
|
348
|
+
source: peg$source,
|
|
349
|
+
start: {
|
|
350
|
+
offset: startPos,
|
|
351
|
+
line: startPosDetails.line,
|
|
352
|
+
column: startPosDetails.column
|
|
353
|
+
},
|
|
354
|
+
end: {
|
|
355
|
+
offset: endPos,
|
|
356
|
+
line: endPosDetails.line,
|
|
357
|
+
column: endPosDetails.column
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
return res;
|
|
361
|
+
}
|
|
362
|
+
function peg$fail(expected2) {
|
|
363
|
+
if (peg$currPos < peg$maxFailPos) {
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
if (peg$currPos > peg$maxFailPos) {
|
|
367
|
+
peg$maxFailPos = peg$currPos;
|
|
368
|
+
peg$maxFailExpected = [];
|
|
369
|
+
}
|
|
370
|
+
peg$maxFailExpected.push(expected2);
|
|
371
|
+
}
|
|
372
|
+
function peg$buildStructuredError(expected2, found, location2) {
|
|
373
|
+
return new peg$SyntaxError(
|
|
374
|
+
peg$SyntaxError.buildMessage(expected2, found),
|
|
375
|
+
expected2,
|
|
376
|
+
found,
|
|
377
|
+
location2
|
|
378
|
+
);
|
|
379
|
+
}
|
|
380
|
+
function peg$parseStart() {
|
|
381
|
+
let s0, s2;
|
|
382
|
+
s0 = peg$currPos;
|
|
383
|
+
peg$parse_();
|
|
384
|
+
s2 = peg$parseExpr();
|
|
385
|
+
if (s2 !== peg$FAILED) {
|
|
386
|
+
peg$parse_();
|
|
387
|
+
s0 = peg$f0(s2);
|
|
388
|
+
} else {
|
|
389
|
+
peg$currPos = s0;
|
|
390
|
+
s0 = peg$FAILED;
|
|
391
|
+
}
|
|
392
|
+
return s0;
|
|
393
|
+
}
|
|
394
|
+
function peg$parseExpr() {
|
|
395
|
+
let s0, s1, s2, s3, s5, s6, s7, s8;
|
|
396
|
+
s0 = peg$currPos;
|
|
397
|
+
s1 = peg$parseWithExpr();
|
|
398
|
+
if (s1 !== peg$FAILED) {
|
|
399
|
+
s2 = [];
|
|
400
|
+
s3 = peg$currPos;
|
|
401
|
+
peg$parse_();
|
|
402
|
+
s5 = input.substr(peg$currPos, 6);
|
|
403
|
+
if (s5.toLowerCase() === peg$c0) {
|
|
404
|
+
peg$currPos += 6;
|
|
405
|
+
} else {
|
|
406
|
+
s5 = peg$FAILED;
|
|
407
|
+
if (peg$silentFails === 0) {
|
|
408
|
+
peg$fail(peg$e0);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
if (s5 !== peg$FAILED) {
|
|
412
|
+
s6 = peg$currPos;
|
|
413
|
+
peg$silentFails++;
|
|
414
|
+
s7 = input.charAt(peg$currPos);
|
|
415
|
+
if (peg$r0.test(s7)) {
|
|
416
|
+
peg$currPos++;
|
|
417
|
+
} else {
|
|
418
|
+
s7 = peg$FAILED;
|
|
419
|
+
if (peg$silentFails === 0) {
|
|
420
|
+
peg$fail(peg$e1);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
peg$silentFails--;
|
|
424
|
+
if (s7 === peg$FAILED) {
|
|
425
|
+
s6 = void 0;
|
|
426
|
+
} else {
|
|
427
|
+
peg$currPos = s6;
|
|
428
|
+
s6 = peg$FAILED;
|
|
429
|
+
}
|
|
430
|
+
if (s6 !== peg$FAILED) {
|
|
431
|
+
s7 = peg$parse_();
|
|
432
|
+
s8 = peg$parseSelector();
|
|
433
|
+
if (s8 !== peg$FAILED) {
|
|
434
|
+
s3 = peg$f1(s1, s8);
|
|
435
|
+
} else {
|
|
436
|
+
peg$currPos = s3;
|
|
437
|
+
s3 = peg$FAILED;
|
|
438
|
+
}
|
|
439
|
+
} else {
|
|
440
|
+
peg$currPos = s3;
|
|
441
|
+
s3 = peg$FAILED;
|
|
442
|
+
}
|
|
443
|
+
} else {
|
|
444
|
+
peg$currPos = s3;
|
|
445
|
+
s3 = peg$FAILED;
|
|
446
|
+
}
|
|
447
|
+
while (s3 !== peg$FAILED) {
|
|
448
|
+
s2.push(s3);
|
|
449
|
+
s3 = peg$currPos;
|
|
450
|
+
peg$parse_();
|
|
451
|
+
s5 = input.substr(peg$currPos, 6);
|
|
452
|
+
if (s5.toLowerCase() === peg$c0) {
|
|
453
|
+
peg$currPos += 6;
|
|
454
|
+
} else {
|
|
455
|
+
s5 = peg$FAILED;
|
|
456
|
+
if (peg$silentFails === 0) {
|
|
457
|
+
peg$fail(peg$e0);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
if (s5 !== peg$FAILED) {
|
|
461
|
+
s6 = peg$currPos;
|
|
462
|
+
peg$silentFails++;
|
|
463
|
+
s7 = input.charAt(peg$currPos);
|
|
464
|
+
if (peg$r0.test(s7)) {
|
|
465
|
+
peg$currPos++;
|
|
466
|
+
} else {
|
|
467
|
+
s7 = peg$FAILED;
|
|
468
|
+
if (peg$silentFails === 0) {
|
|
469
|
+
peg$fail(peg$e1);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
peg$silentFails--;
|
|
473
|
+
if (s7 === peg$FAILED) {
|
|
474
|
+
s6 = void 0;
|
|
475
|
+
} else {
|
|
476
|
+
peg$currPos = s6;
|
|
477
|
+
s6 = peg$FAILED;
|
|
478
|
+
}
|
|
479
|
+
if (s6 !== peg$FAILED) {
|
|
480
|
+
s7 = peg$parse_();
|
|
481
|
+
s8 = peg$parseSelector();
|
|
482
|
+
if (s8 !== peg$FAILED) {
|
|
483
|
+
s3 = peg$f1(s1, s8);
|
|
484
|
+
} else {
|
|
485
|
+
peg$currPos = s3;
|
|
486
|
+
s3 = peg$FAILED;
|
|
487
|
+
}
|
|
488
|
+
} else {
|
|
489
|
+
peg$currPos = s3;
|
|
490
|
+
s3 = peg$FAILED;
|
|
491
|
+
}
|
|
492
|
+
} else {
|
|
493
|
+
peg$currPos = s3;
|
|
494
|
+
s3 = peg$FAILED;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
s0 = peg$f2(s1, s2);
|
|
498
|
+
} else {
|
|
499
|
+
peg$currPos = s0;
|
|
500
|
+
s0 = peg$FAILED;
|
|
501
|
+
}
|
|
502
|
+
return s0;
|
|
503
|
+
}
|
|
504
|
+
function peg$parseWithExpr() {
|
|
505
|
+
let s0, s1, s2, s3, s5;
|
|
506
|
+
s0 = peg$currPos;
|
|
507
|
+
s1 = peg$parseSelector();
|
|
508
|
+
if (s1 !== peg$FAILED) {
|
|
509
|
+
s2 = [];
|
|
510
|
+
s3 = peg$currPos;
|
|
511
|
+
peg$parse_();
|
|
512
|
+
s5 = peg$parseWithPart();
|
|
513
|
+
if (s5 !== peg$FAILED) {
|
|
514
|
+
s3 = peg$f3(s1, s5);
|
|
515
|
+
} else {
|
|
516
|
+
peg$currPos = s3;
|
|
517
|
+
s3 = peg$FAILED;
|
|
518
|
+
}
|
|
519
|
+
while (s3 !== peg$FAILED) {
|
|
520
|
+
s2.push(s3);
|
|
521
|
+
s3 = peg$currPos;
|
|
522
|
+
peg$parse_();
|
|
523
|
+
s5 = peg$parseWithPart();
|
|
524
|
+
if (s5 !== peg$FAILED) {
|
|
525
|
+
s3 = peg$f3(s1, s5);
|
|
526
|
+
} else {
|
|
527
|
+
peg$currPos = s3;
|
|
528
|
+
s3 = peg$FAILED;
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
s0 = peg$f4(s1, s2);
|
|
532
|
+
} else {
|
|
533
|
+
peg$currPos = s0;
|
|
534
|
+
s0 = peg$FAILED;
|
|
535
|
+
}
|
|
536
|
+
return s0;
|
|
537
|
+
}
|
|
538
|
+
function peg$parseWithPart() {
|
|
539
|
+
let s0, s1, s2, s3, s4;
|
|
540
|
+
s0 = peg$currPos;
|
|
541
|
+
s1 = input.substr(peg$currPos, 4);
|
|
542
|
+
if (s1.toLowerCase() === peg$c1) {
|
|
543
|
+
peg$currPos += 4;
|
|
544
|
+
} else {
|
|
545
|
+
s1 = peg$FAILED;
|
|
546
|
+
if (peg$silentFails === 0) {
|
|
547
|
+
peg$fail(peg$e2);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
if (s1 !== peg$FAILED) {
|
|
551
|
+
s2 = peg$currPos;
|
|
552
|
+
peg$silentFails++;
|
|
553
|
+
s3 = input.charAt(peg$currPos);
|
|
554
|
+
if (peg$r0.test(s3)) {
|
|
555
|
+
peg$currPos++;
|
|
556
|
+
} else {
|
|
557
|
+
s3 = peg$FAILED;
|
|
558
|
+
if (peg$silentFails === 0) {
|
|
559
|
+
peg$fail(peg$e1);
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
peg$silentFails--;
|
|
563
|
+
if (s3 === peg$FAILED) {
|
|
564
|
+
s2 = void 0;
|
|
565
|
+
} else {
|
|
566
|
+
peg$currPos = s2;
|
|
567
|
+
s2 = peg$FAILED;
|
|
568
|
+
}
|
|
569
|
+
if (s2 !== peg$FAILED) {
|
|
570
|
+
s3 = peg$parse_();
|
|
571
|
+
s4 = peg$parsePredicate();
|
|
572
|
+
if (s4 !== peg$FAILED) {
|
|
573
|
+
s0 = peg$f5(s4);
|
|
574
|
+
} else {
|
|
575
|
+
peg$currPos = s0;
|
|
576
|
+
s0 = peg$FAILED;
|
|
577
|
+
}
|
|
578
|
+
} else {
|
|
579
|
+
peg$currPos = s0;
|
|
580
|
+
s0 = peg$FAILED;
|
|
581
|
+
}
|
|
582
|
+
} else {
|
|
583
|
+
peg$currPos = s0;
|
|
584
|
+
s0 = peg$FAILED;
|
|
585
|
+
}
|
|
586
|
+
if (s0 === peg$FAILED) {
|
|
587
|
+
s0 = peg$currPos;
|
|
588
|
+
s1 = input.substr(peg$currPos, 7);
|
|
589
|
+
if (s1.toLowerCase() === peg$c2) {
|
|
590
|
+
peg$currPos += 7;
|
|
591
|
+
} else {
|
|
592
|
+
s1 = peg$FAILED;
|
|
593
|
+
if (peg$silentFails === 0) {
|
|
594
|
+
peg$fail(peg$e3);
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
if (s1 !== peg$FAILED) {
|
|
598
|
+
s2 = peg$currPos;
|
|
599
|
+
peg$silentFails++;
|
|
600
|
+
s3 = input.charAt(peg$currPos);
|
|
601
|
+
if (peg$r0.test(s3)) {
|
|
602
|
+
peg$currPos++;
|
|
603
|
+
} else {
|
|
604
|
+
s3 = peg$FAILED;
|
|
605
|
+
if (peg$silentFails === 0) {
|
|
606
|
+
peg$fail(peg$e1);
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
peg$silentFails--;
|
|
610
|
+
if (s3 === peg$FAILED) {
|
|
611
|
+
s2 = void 0;
|
|
612
|
+
} else {
|
|
613
|
+
peg$currPos = s2;
|
|
614
|
+
s2 = peg$FAILED;
|
|
615
|
+
}
|
|
616
|
+
if (s2 !== peg$FAILED) {
|
|
617
|
+
s3 = peg$parse_();
|
|
618
|
+
s4 = peg$parsePredicate();
|
|
619
|
+
if (s4 !== peg$FAILED) {
|
|
620
|
+
s0 = peg$f6(s4);
|
|
621
|
+
} else {
|
|
622
|
+
peg$currPos = s0;
|
|
623
|
+
s0 = peg$FAILED;
|
|
624
|
+
}
|
|
625
|
+
} else {
|
|
626
|
+
peg$currPos = s0;
|
|
627
|
+
s0 = peg$FAILED;
|
|
628
|
+
}
|
|
629
|
+
} else {
|
|
630
|
+
peg$currPos = s0;
|
|
631
|
+
s0 = peg$FAILED;
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
return s0;
|
|
635
|
+
}
|
|
636
|
+
function peg$parseSelector() {
|
|
637
|
+
let s0;
|
|
638
|
+
s0 = peg$parseRawSel();
|
|
639
|
+
if (s0 === peg$FAILED) {
|
|
640
|
+
s0 = peg$parseDateSel();
|
|
641
|
+
if (s0 === peg$FAILED) {
|
|
642
|
+
s0 = peg$parseRoleSelFull();
|
|
643
|
+
if (s0 === peg$FAILED) {
|
|
644
|
+
s0 = peg$parseTagSelFull();
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
return s0;
|
|
649
|
+
}
|
|
650
|
+
function peg$parseRawSel() {
|
|
651
|
+
let s0, s1, s2, s3;
|
|
652
|
+
s0 = peg$currPos;
|
|
653
|
+
if (input.charCodeAt(peg$currPos) === 96) {
|
|
654
|
+
s1 = peg$c3;
|
|
655
|
+
peg$currPos++;
|
|
656
|
+
} else {
|
|
657
|
+
s1 = peg$FAILED;
|
|
658
|
+
if (peg$silentFails === 0) {
|
|
659
|
+
peg$fail(peg$e4);
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
if (s1 !== peg$FAILED) {
|
|
663
|
+
s2 = peg$parseRawChars();
|
|
664
|
+
if (input.charCodeAt(peg$currPos) === 96) {
|
|
665
|
+
s3 = peg$c3;
|
|
666
|
+
peg$currPos++;
|
|
667
|
+
} else {
|
|
668
|
+
s3 = peg$FAILED;
|
|
669
|
+
if (peg$silentFails === 0) {
|
|
670
|
+
peg$fail(peg$e4);
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
if (s3 !== peg$FAILED) {
|
|
674
|
+
s0 = peg$f7(s2);
|
|
675
|
+
} else {
|
|
676
|
+
peg$currPos = s0;
|
|
677
|
+
s0 = peg$FAILED;
|
|
678
|
+
}
|
|
679
|
+
} else {
|
|
680
|
+
peg$currPos = s0;
|
|
681
|
+
s0 = peg$FAILED;
|
|
682
|
+
}
|
|
683
|
+
return s0;
|
|
684
|
+
}
|
|
685
|
+
function peg$parseRawChars() {
|
|
686
|
+
let s0, s1, s2;
|
|
687
|
+
s0 = peg$currPos;
|
|
688
|
+
s1 = [];
|
|
689
|
+
s2 = input.charAt(peg$currPos);
|
|
690
|
+
if (peg$r1.test(s2)) {
|
|
691
|
+
peg$currPos++;
|
|
692
|
+
} else {
|
|
693
|
+
s2 = peg$FAILED;
|
|
694
|
+
if (peg$silentFails === 0) {
|
|
695
|
+
peg$fail(peg$e5);
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
while (s2 !== peg$FAILED) {
|
|
699
|
+
s1.push(s2);
|
|
700
|
+
s2 = input.charAt(peg$currPos);
|
|
701
|
+
if (peg$r1.test(s2)) {
|
|
702
|
+
peg$currPos++;
|
|
703
|
+
} else {
|
|
704
|
+
s2 = peg$FAILED;
|
|
705
|
+
if (peg$silentFails === 0) {
|
|
706
|
+
peg$fail(peg$e5);
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
s0 = input.substring(s0, peg$currPos);
|
|
711
|
+
return s0;
|
|
712
|
+
}
|
|
713
|
+
function peg$parseRoleSelFull() {
|
|
714
|
+
let s0, s2;
|
|
715
|
+
s0 = peg$currPos;
|
|
716
|
+
peg$parseTheOpt();
|
|
717
|
+
s2 = peg$parseRoleSel();
|
|
718
|
+
if (s2 !== peg$FAILED) {
|
|
719
|
+
s0 = peg$f8(s2);
|
|
720
|
+
} else {
|
|
721
|
+
peg$currPos = s0;
|
|
722
|
+
s0 = peg$FAILED;
|
|
723
|
+
}
|
|
724
|
+
return s0;
|
|
725
|
+
}
|
|
726
|
+
function peg$parseDateSel() {
|
|
727
|
+
let s0, s1, s4;
|
|
728
|
+
s0 = peg$currPos;
|
|
729
|
+
s1 = input.substr(peg$currPos, 4);
|
|
730
|
+
if (s1.toLowerCase() === peg$c4) {
|
|
731
|
+
peg$currPos += 4;
|
|
732
|
+
} else {
|
|
733
|
+
s1 = peg$FAILED;
|
|
734
|
+
if (peg$silentFails === 0) {
|
|
735
|
+
peg$fail(peg$e6);
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
if (s1 !== peg$FAILED) {
|
|
739
|
+
peg$parse_();
|
|
740
|
+
peg$parseOfOpt();
|
|
741
|
+
s4 = peg$parseDateValue();
|
|
742
|
+
if (s4 !== peg$FAILED) {
|
|
743
|
+
s0 = peg$f9(s4);
|
|
744
|
+
} else {
|
|
745
|
+
peg$currPos = s0;
|
|
746
|
+
s0 = peg$FAILED;
|
|
747
|
+
}
|
|
748
|
+
} else {
|
|
749
|
+
peg$currPos = s0;
|
|
750
|
+
s0 = peg$FAILED;
|
|
751
|
+
}
|
|
752
|
+
return s0;
|
|
753
|
+
}
|
|
754
|
+
function peg$parseOfOpt() {
|
|
755
|
+
let s0, s1, s2, s3;
|
|
756
|
+
s0 = peg$currPos;
|
|
757
|
+
s1 = input.substr(peg$currPos, 2);
|
|
758
|
+
if (s1.toLowerCase() === peg$c5) {
|
|
759
|
+
peg$currPos += 2;
|
|
760
|
+
} else {
|
|
761
|
+
s1 = peg$FAILED;
|
|
762
|
+
if (peg$silentFails === 0) {
|
|
763
|
+
peg$fail(peg$e7);
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
if (s1 !== peg$FAILED) {
|
|
767
|
+
s2 = peg$currPos;
|
|
768
|
+
peg$silentFails++;
|
|
769
|
+
s3 = input.charAt(peg$currPos);
|
|
770
|
+
if (peg$r0.test(s3)) {
|
|
771
|
+
peg$currPos++;
|
|
772
|
+
} else {
|
|
773
|
+
s3 = peg$FAILED;
|
|
774
|
+
if (peg$silentFails === 0) {
|
|
775
|
+
peg$fail(peg$e1);
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
peg$silentFails--;
|
|
779
|
+
if (s3 === peg$FAILED) {
|
|
780
|
+
s2 = void 0;
|
|
781
|
+
} else {
|
|
782
|
+
peg$currPos = s2;
|
|
783
|
+
s2 = peg$FAILED;
|
|
784
|
+
}
|
|
785
|
+
if (s2 !== peg$FAILED) {
|
|
786
|
+
s3 = peg$parse_();
|
|
787
|
+
s1 = [s1, s2, s3];
|
|
788
|
+
s0 = s1;
|
|
789
|
+
} else {
|
|
790
|
+
peg$currPos = s0;
|
|
791
|
+
s0 = peg$FAILED;
|
|
792
|
+
}
|
|
793
|
+
} else {
|
|
794
|
+
peg$currPos = s0;
|
|
795
|
+
s0 = peg$FAILED;
|
|
796
|
+
}
|
|
797
|
+
return s0;
|
|
798
|
+
}
|
|
799
|
+
function peg$parseDateValue() {
|
|
800
|
+
let s0, s1, s2, s3, s4, s5, s6, s7, s8;
|
|
801
|
+
s0 = peg$currPos;
|
|
802
|
+
s1 = peg$parseStringLit();
|
|
803
|
+
if (s1 !== peg$FAILED) {
|
|
804
|
+
s1 = peg$f10(s1);
|
|
805
|
+
}
|
|
806
|
+
s0 = s1;
|
|
807
|
+
if (s0 === peg$FAILED) {
|
|
808
|
+
s0 = peg$currPos;
|
|
809
|
+
s1 = [];
|
|
810
|
+
s2 = peg$currPos;
|
|
811
|
+
s3 = peg$currPos;
|
|
812
|
+
peg$silentFails++;
|
|
813
|
+
s4 = peg$currPos;
|
|
814
|
+
s5 = peg$parse_();
|
|
815
|
+
s6 = input.substr(peg$currPos, 6);
|
|
816
|
+
if (s6.toLowerCase() === peg$c0) {
|
|
817
|
+
peg$currPos += 6;
|
|
818
|
+
} else {
|
|
819
|
+
s6 = peg$FAILED;
|
|
820
|
+
if (peg$silentFails === 0) {
|
|
821
|
+
peg$fail(peg$e0);
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
if (s6 !== peg$FAILED) {
|
|
825
|
+
s7 = peg$currPos;
|
|
826
|
+
peg$silentFails++;
|
|
827
|
+
s8 = input.charAt(peg$currPos);
|
|
828
|
+
if (peg$r0.test(s8)) {
|
|
829
|
+
peg$currPos++;
|
|
830
|
+
} else {
|
|
831
|
+
s8 = peg$FAILED;
|
|
832
|
+
if (peg$silentFails === 0) {
|
|
833
|
+
peg$fail(peg$e1);
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
peg$silentFails--;
|
|
837
|
+
if (s8 === peg$FAILED) {
|
|
838
|
+
s7 = void 0;
|
|
839
|
+
} else {
|
|
840
|
+
peg$currPos = s7;
|
|
841
|
+
s7 = peg$FAILED;
|
|
842
|
+
}
|
|
843
|
+
if (s7 !== peg$FAILED) {
|
|
844
|
+
s5 = [s5, s6, s7];
|
|
845
|
+
s4 = s5;
|
|
846
|
+
} else {
|
|
847
|
+
peg$currPos = s4;
|
|
848
|
+
s4 = peg$FAILED;
|
|
849
|
+
}
|
|
850
|
+
} else {
|
|
851
|
+
peg$currPos = s4;
|
|
852
|
+
s4 = peg$FAILED;
|
|
853
|
+
}
|
|
854
|
+
peg$silentFails--;
|
|
855
|
+
if (s4 === peg$FAILED) {
|
|
856
|
+
s3 = void 0;
|
|
857
|
+
} else {
|
|
858
|
+
peg$currPos = s3;
|
|
859
|
+
s3 = peg$FAILED;
|
|
860
|
+
}
|
|
861
|
+
if (s3 !== peg$FAILED) {
|
|
862
|
+
if (input.length > peg$currPos) {
|
|
863
|
+
s4 = input.charAt(peg$currPos);
|
|
864
|
+
peg$currPos++;
|
|
865
|
+
} else {
|
|
866
|
+
s4 = peg$FAILED;
|
|
867
|
+
if (peg$silentFails === 0) {
|
|
868
|
+
peg$fail(peg$e8);
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
if (s4 !== peg$FAILED) {
|
|
872
|
+
s3 = [s3, s4];
|
|
873
|
+
s2 = s3;
|
|
874
|
+
} else {
|
|
875
|
+
peg$currPos = s2;
|
|
876
|
+
s2 = peg$FAILED;
|
|
877
|
+
}
|
|
878
|
+
} else {
|
|
879
|
+
peg$currPos = s2;
|
|
880
|
+
s2 = peg$FAILED;
|
|
881
|
+
}
|
|
882
|
+
if (s2 !== peg$FAILED) {
|
|
883
|
+
while (s2 !== peg$FAILED) {
|
|
884
|
+
s1.push(s2);
|
|
885
|
+
s2 = peg$currPos;
|
|
886
|
+
s3 = peg$currPos;
|
|
887
|
+
peg$silentFails++;
|
|
888
|
+
s4 = peg$currPos;
|
|
889
|
+
s5 = peg$parse_();
|
|
890
|
+
s6 = input.substr(peg$currPos, 6);
|
|
891
|
+
if (s6.toLowerCase() === peg$c0) {
|
|
892
|
+
peg$currPos += 6;
|
|
893
|
+
} else {
|
|
894
|
+
s6 = peg$FAILED;
|
|
895
|
+
if (peg$silentFails === 0) {
|
|
896
|
+
peg$fail(peg$e0);
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
if (s6 !== peg$FAILED) {
|
|
900
|
+
s7 = peg$currPos;
|
|
901
|
+
peg$silentFails++;
|
|
902
|
+
s8 = input.charAt(peg$currPos);
|
|
903
|
+
if (peg$r0.test(s8)) {
|
|
904
|
+
peg$currPos++;
|
|
905
|
+
} else {
|
|
906
|
+
s8 = peg$FAILED;
|
|
907
|
+
if (peg$silentFails === 0) {
|
|
908
|
+
peg$fail(peg$e1);
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
peg$silentFails--;
|
|
912
|
+
if (s8 === peg$FAILED) {
|
|
913
|
+
s7 = void 0;
|
|
914
|
+
} else {
|
|
915
|
+
peg$currPos = s7;
|
|
916
|
+
s7 = peg$FAILED;
|
|
917
|
+
}
|
|
918
|
+
if (s7 !== peg$FAILED) {
|
|
919
|
+
s5 = [s5, s6, s7];
|
|
920
|
+
s4 = s5;
|
|
921
|
+
} else {
|
|
922
|
+
peg$currPos = s4;
|
|
923
|
+
s4 = peg$FAILED;
|
|
924
|
+
}
|
|
925
|
+
} else {
|
|
926
|
+
peg$currPos = s4;
|
|
927
|
+
s4 = peg$FAILED;
|
|
928
|
+
}
|
|
929
|
+
peg$silentFails--;
|
|
930
|
+
if (s4 === peg$FAILED) {
|
|
931
|
+
s3 = void 0;
|
|
932
|
+
} else {
|
|
933
|
+
peg$currPos = s3;
|
|
934
|
+
s3 = peg$FAILED;
|
|
935
|
+
}
|
|
936
|
+
if (s3 !== peg$FAILED) {
|
|
937
|
+
if (input.length > peg$currPos) {
|
|
938
|
+
s4 = input.charAt(peg$currPos);
|
|
939
|
+
peg$currPos++;
|
|
940
|
+
} else {
|
|
941
|
+
s4 = peg$FAILED;
|
|
942
|
+
if (peg$silentFails === 0) {
|
|
943
|
+
peg$fail(peg$e8);
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
if (s4 !== peg$FAILED) {
|
|
947
|
+
s3 = [s3, s4];
|
|
948
|
+
s2 = s3;
|
|
949
|
+
} else {
|
|
950
|
+
peg$currPos = s2;
|
|
951
|
+
s2 = peg$FAILED;
|
|
952
|
+
}
|
|
953
|
+
} else {
|
|
954
|
+
peg$currPos = s2;
|
|
955
|
+
s2 = peg$FAILED;
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
} else {
|
|
959
|
+
s1 = peg$FAILED;
|
|
960
|
+
}
|
|
961
|
+
if (s1 !== peg$FAILED) {
|
|
962
|
+
s0 = input.substring(s0, peg$currPos);
|
|
963
|
+
} else {
|
|
964
|
+
s0 = s1;
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
return s0;
|
|
968
|
+
}
|
|
969
|
+
function peg$parseRoleSel() {
|
|
970
|
+
let s0, s1, s3;
|
|
971
|
+
s0 = peg$currPos;
|
|
972
|
+
s1 = peg$parseKnownRole();
|
|
973
|
+
if (s1 !== peg$FAILED) {
|
|
974
|
+
peg$parse_();
|
|
975
|
+
s3 = peg$parseStringLit();
|
|
976
|
+
if (s3 === peg$FAILED) {
|
|
977
|
+
s3 = null;
|
|
978
|
+
}
|
|
979
|
+
s0 = peg$f11(s1, s3);
|
|
980
|
+
} else {
|
|
981
|
+
peg$currPos = s0;
|
|
982
|
+
s0 = peg$FAILED;
|
|
983
|
+
}
|
|
984
|
+
if (s0 === peg$FAILED) {
|
|
985
|
+
s0 = peg$currPos;
|
|
986
|
+
s1 = peg$parseIdent();
|
|
987
|
+
if (s1 !== peg$FAILED) {
|
|
988
|
+
peg$parse_();
|
|
989
|
+
s3 = peg$parseStringLit();
|
|
990
|
+
if (s3 !== peg$FAILED) {
|
|
991
|
+
s0 = peg$f12(s1, s3);
|
|
992
|
+
} else {
|
|
993
|
+
peg$currPos = s0;
|
|
994
|
+
s0 = peg$FAILED;
|
|
995
|
+
}
|
|
996
|
+
} else {
|
|
997
|
+
peg$currPos = s0;
|
|
998
|
+
s0 = peg$FAILED;
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
return s0;
|
|
1002
|
+
}
|
|
1003
|
+
function peg$parseKnownRole() {
|
|
1004
|
+
let s0;
|
|
1005
|
+
s0 = input.substr(peg$currPos, 6);
|
|
1006
|
+
if (s0.toLowerCase() === peg$c6) {
|
|
1007
|
+
peg$currPos += 6;
|
|
1008
|
+
} else {
|
|
1009
|
+
s0 = peg$FAILED;
|
|
1010
|
+
if (peg$silentFails === 0) {
|
|
1011
|
+
peg$fail(peg$e9);
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
if (s0 === peg$FAILED) {
|
|
1015
|
+
s0 = input.substr(peg$currPos, 4);
|
|
1016
|
+
if (s0.toLowerCase() === peg$c7) {
|
|
1017
|
+
peg$currPos += 4;
|
|
1018
|
+
} else {
|
|
1019
|
+
s0 = peg$FAILED;
|
|
1020
|
+
if (peg$silentFails === 0) {
|
|
1021
|
+
peg$fail(peg$e10);
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
if (s0 === peg$FAILED) {
|
|
1025
|
+
s0 = input.substr(peg$currPos, 5);
|
|
1026
|
+
if (s0.toLowerCase() === peg$c8) {
|
|
1027
|
+
peg$currPos += 5;
|
|
1028
|
+
} else {
|
|
1029
|
+
s0 = peg$FAILED;
|
|
1030
|
+
if (peg$silentFails === 0) {
|
|
1031
|
+
peg$fail(peg$e11);
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
if (s0 === peg$FAILED) {
|
|
1035
|
+
s0 = input.substr(peg$currPos, 5);
|
|
1036
|
+
if (s0.toLowerCase() === peg$c9) {
|
|
1037
|
+
peg$currPos += 5;
|
|
1038
|
+
} else {
|
|
1039
|
+
s0 = peg$FAILED;
|
|
1040
|
+
if (peg$silentFails === 0) {
|
|
1041
|
+
peg$fail(peg$e12);
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
if (s0 === peg$FAILED) {
|
|
1045
|
+
s0 = input.substr(peg$currPos, 4);
|
|
1046
|
+
if (s0.toLowerCase() === peg$c10) {
|
|
1047
|
+
peg$currPos += 4;
|
|
1048
|
+
} else {
|
|
1049
|
+
s0 = peg$FAILED;
|
|
1050
|
+
if (peg$silentFails === 0) {
|
|
1051
|
+
peg$fail(peg$e13);
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
if (s0 === peg$FAILED) {
|
|
1055
|
+
s0 = input.substr(peg$currPos, 4);
|
|
1056
|
+
if (s0.toLowerCase() === peg$c4) {
|
|
1057
|
+
peg$currPos += 4;
|
|
1058
|
+
} else {
|
|
1059
|
+
s0 = peg$FAILED;
|
|
1060
|
+
if (peg$silentFails === 0) {
|
|
1061
|
+
peg$fail(peg$e6);
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
return s0;
|
|
1070
|
+
}
|
|
1071
|
+
function peg$parseTagSelFull() {
|
|
1072
|
+
let s0, s2;
|
|
1073
|
+
s0 = peg$currPos;
|
|
1074
|
+
peg$parseTheOpt();
|
|
1075
|
+
s2 = peg$parseIdent();
|
|
1076
|
+
if (s2 !== peg$FAILED) {
|
|
1077
|
+
s0 = peg$f13(s2);
|
|
1078
|
+
} else {
|
|
1079
|
+
peg$currPos = s0;
|
|
1080
|
+
s0 = peg$FAILED;
|
|
1081
|
+
}
|
|
1082
|
+
return s0;
|
|
1083
|
+
}
|
|
1084
|
+
function peg$parsePredicate() {
|
|
1085
|
+
let s0, s1;
|
|
1086
|
+
s0 = peg$currPos;
|
|
1087
|
+
s1 = peg$parseSelector();
|
|
1088
|
+
if (s1 !== peg$FAILED) {
|
|
1089
|
+
s1 = peg$f14(s1);
|
|
1090
|
+
}
|
|
1091
|
+
s0 = s1;
|
|
1092
|
+
return s0;
|
|
1093
|
+
}
|
|
1094
|
+
function peg$parseTheOpt() {
|
|
1095
|
+
let s0, s1, s2, s3;
|
|
1096
|
+
s0 = peg$currPos;
|
|
1097
|
+
s1 = input.substr(peg$currPos, 3);
|
|
1098
|
+
if (s1.toLowerCase() === peg$c11) {
|
|
1099
|
+
peg$currPos += 3;
|
|
1100
|
+
} else {
|
|
1101
|
+
s1 = peg$FAILED;
|
|
1102
|
+
if (peg$silentFails === 0) {
|
|
1103
|
+
peg$fail(peg$e14);
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
if (s1 !== peg$FAILED) {
|
|
1107
|
+
s2 = peg$currPos;
|
|
1108
|
+
peg$silentFails++;
|
|
1109
|
+
s3 = input.charAt(peg$currPos);
|
|
1110
|
+
if (peg$r0.test(s3)) {
|
|
1111
|
+
peg$currPos++;
|
|
1112
|
+
} else {
|
|
1113
|
+
s3 = peg$FAILED;
|
|
1114
|
+
if (peg$silentFails === 0) {
|
|
1115
|
+
peg$fail(peg$e1);
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
peg$silentFails--;
|
|
1119
|
+
if (s3 === peg$FAILED) {
|
|
1120
|
+
s2 = void 0;
|
|
1121
|
+
} else {
|
|
1122
|
+
peg$currPos = s2;
|
|
1123
|
+
s2 = peg$FAILED;
|
|
1124
|
+
}
|
|
1125
|
+
if (s2 !== peg$FAILED) {
|
|
1126
|
+
s3 = peg$parse_();
|
|
1127
|
+
s1 = [s1, s2, s3];
|
|
1128
|
+
s0 = s1;
|
|
1129
|
+
} else {
|
|
1130
|
+
peg$currPos = s0;
|
|
1131
|
+
s0 = peg$FAILED;
|
|
1132
|
+
}
|
|
1133
|
+
} else {
|
|
1134
|
+
peg$currPos = s0;
|
|
1135
|
+
s0 = peg$FAILED;
|
|
1136
|
+
}
|
|
1137
|
+
return s0;
|
|
1138
|
+
}
|
|
1139
|
+
function peg$parseIdent() {
|
|
1140
|
+
let s0, s1, s2, s3, s4;
|
|
1141
|
+
s0 = peg$currPos;
|
|
1142
|
+
s1 = peg$currPos;
|
|
1143
|
+
s2 = input.charAt(peg$currPos);
|
|
1144
|
+
if (peg$r2.test(s2)) {
|
|
1145
|
+
peg$currPos++;
|
|
1146
|
+
} else {
|
|
1147
|
+
s2 = peg$FAILED;
|
|
1148
|
+
if (peg$silentFails === 0) {
|
|
1149
|
+
peg$fail(peg$e15);
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
if (s2 !== peg$FAILED) {
|
|
1153
|
+
s3 = [];
|
|
1154
|
+
s4 = input.charAt(peg$currPos);
|
|
1155
|
+
if (peg$r3.test(s4)) {
|
|
1156
|
+
peg$currPos++;
|
|
1157
|
+
} else {
|
|
1158
|
+
s4 = peg$FAILED;
|
|
1159
|
+
if (peg$silentFails === 0) {
|
|
1160
|
+
peg$fail(peg$e16);
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
while (s4 !== peg$FAILED) {
|
|
1164
|
+
s3.push(s4);
|
|
1165
|
+
s4 = input.charAt(peg$currPos);
|
|
1166
|
+
if (peg$r3.test(s4)) {
|
|
1167
|
+
peg$currPos++;
|
|
1168
|
+
} else {
|
|
1169
|
+
s4 = peg$FAILED;
|
|
1170
|
+
if (peg$silentFails === 0) {
|
|
1171
|
+
peg$fail(peg$e16);
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
s2 = [s2, s3];
|
|
1176
|
+
s1 = s2;
|
|
1177
|
+
} else {
|
|
1178
|
+
peg$currPos = s1;
|
|
1179
|
+
s1 = peg$FAILED;
|
|
1180
|
+
}
|
|
1181
|
+
if (s1 !== peg$FAILED) {
|
|
1182
|
+
s0 = input.substring(s0, peg$currPos);
|
|
1183
|
+
} else {
|
|
1184
|
+
s0 = s1;
|
|
1185
|
+
}
|
|
1186
|
+
return s0;
|
|
1187
|
+
}
|
|
1188
|
+
function peg$parseStringLit() {
|
|
1189
|
+
let s0, s1, s2, s3, s4, s5, s6;
|
|
1190
|
+
s0 = peg$currPos;
|
|
1191
|
+
if (input.charCodeAt(peg$currPos) === 34) {
|
|
1192
|
+
s1 = peg$c12;
|
|
1193
|
+
peg$currPos++;
|
|
1194
|
+
} else {
|
|
1195
|
+
s1 = peg$FAILED;
|
|
1196
|
+
if (peg$silentFails === 0) {
|
|
1197
|
+
peg$fail(peg$e17);
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
if (s1 !== peg$FAILED) {
|
|
1201
|
+
s2 = peg$currPos;
|
|
1202
|
+
s3 = [];
|
|
1203
|
+
if (input.substr(peg$currPos, 2) === peg$c13) {
|
|
1204
|
+
s4 = peg$c13;
|
|
1205
|
+
peg$currPos += 2;
|
|
1206
|
+
} else {
|
|
1207
|
+
s4 = peg$FAILED;
|
|
1208
|
+
if (peg$silentFails === 0) {
|
|
1209
|
+
peg$fail(peg$e18);
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
if (s4 === peg$FAILED) {
|
|
1213
|
+
s4 = peg$currPos;
|
|
1214
|
+
s5 = peg$currPos;
|
|
1215
|
+
peg$silentFails++;
|
|
1216
|
+
if (input.charCodeAt(peg$currPos) === 34) {
|
|
1217
|
+
s6 = peg$c12;
|
|
1218
|
+
peg$currPos++;
|
|
1219
|
+
} else {
|
|
1220
|
+
s6 = peg$FAILED;
|
|
1221
|
+
if (peg$silentFails === 0) {
|
|
1222
|
+
peg$fail(peg$e17);
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
peg$silentFails--;
|
|
1226
|
+
if (s6 === peg$FAILED) {
|
|
1227
|
+
s5 = void 0;
|
|
1228
|
+
} else {
|
|
1229
|
+
peg$currPos = s5;
|
|
1230
|
+
s5 = peg$FAILED;
|
|
1231
|
+
}
|
|
1232
|
+
if (s5 !== peg$FAILED) {
|
|
1233
|
+
if (input.length > peg$currPos) {
|
|
1234
|
+
s6 = input.charAt(peg$currPos);
|
|
1235
|
+
peg$currPos++;
|
|
1236
|
+
} else {
|
|
1237
|
+
s6 = peg$FAILED;
|
|
1238
|
+
if (peg$silentFails === 0) {
|
|
1239
|
+
peg$fail(peg$e8);
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
if (s6 !== peg$FAILED) {
|
|
1243
|
+
s5 = [s5, s6];
|
|
1244
|
+
s4 = s5;
|
|
1245
|
+
} else {
|
|
1246
|
+
peg$currPos = s4;
|
|
1247
|
+
s4 = peg$FAILED;
|
|
1248
|
+
}
|
|
1249
|
+
} else {
|
|
1250
|
+
peg$currPos = s4;
|
|
1251
|
+
s4 = peg$FAILED;
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
while (s4 !== peg$FAILED) {
|
|
1255
|
+
s3.push(s4);
|
|
1256
|
+
if (input.substr(peg$currPos, 2) === peg$c13) {
|
|
1257
|
+
s4 = peg$c13;
|
|
1258
|
+
peg$currPos += 2;
|
|
1259
|
+
} else {
|
|
1260
|
+
s4 = peg$FAILED;
|
|
1261
|
+
if (peg$silentFails === 0) {
|
|
1262
|
+
peg$fail(peg$e18);
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
if (s4 === peg$FAILED) {
|
|
1266
|
+
s4 = peg$currPos;
|
|
1267
|
+
s5 = peg$currPos;
|
|
1268
|
+
peg$silentFails++;
|
|
1269
|
+
if (input.charCodeAt(peg$currPos) === 34) {
|
|
1270
|
+
s6 = peg$c12;
|
|
1271
|
+
peg$currPos++;
|
|
1272
|
+
} else {
|
|
1273
|
+
s6 = peg$FAILED;
|
|
1274
|
+
if (peg$silentFails === 0) {
|
|
1275
|
+
peg$fail(peg$e17);
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
peg$silentFails--;
|
|
1279
|
+
if (s6 === peg$FAILED) {
|
|
1280
|
+
s5 = void 0;
|
|
1281
|
+
} else {
|
|
1282
|
+
peg$currPos = s5;
|
|
1283
|
+
s5 = peg$FAILED;
|
|
1284
|
+
}
|
|
1285
|
+
if (s5 !== peg$FAILED) {
|
|
1286
|
+
if (input.length > peg$currPos) {
|
|
1287
|
+
s6 = input.charAt(peg$currPos);
|
|
1288
|
+
peg$currPos++;
|
|
1289
|
+
} else {
|
|
1290
|
+
s6 = peg$FAILED;
|
|
1291
|
+
if (peg$silentFails === 0) {
|
|
1292
|
+
peg$fail(peg$e8);
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
if (s6 !== peg$FAILED) {
|
|
1296
|
+
s5 = [s5, s6];
|
|
1297
|
+
s4 = s5;
|
|
1298
|
+
} else {
|
|
1299
|
+
peg$currPos = s4;
|
|
1300
|
+
s4 = peg$FAILED;
|
|
1301
|
+
}
|
|
1302
|
+
} else {
|
|
1303
|
+
peg$currPos = s4;
|
|
1304
|
+
s4 = peg$FAILED;
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
s2 = input.substring(s2, peg$currPos);
|
|
1309
|
+
if (input.charCodeAt(peg$currPos) === 34) {
|
|
1310
|
+
s3 = peg$c12;
|
|
1311
|
+
peg$currPos++;
|
|
1312
|
+
} else {
|
|
1313
|
+
s3 = peg$FAILED;
|
|
1314
|
+
if (peg$silentFails === 0) {
|
|
1315
|
+
peg$fail(peg$e17);
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
if (s3 !== peg$FAILED) {
|
|
1319
|
+
s0 = peg$f15(s2);
|
|
1320
|
+
} else {
|
|
1321
|
+
peg$currPos = s0;
|
|
1322
|
+
s0 = peg$FAILED;
|
|
1323
|
+
}
|
|
1324
|
+
} else {
|
|
1325
|
+
peg$currPos = s0;
|
|
1326
|
+
s0 = peg$FAILED;
|
|
1327
|
+
}
|
|
1328
|
+
return s0;
|
|
1329
|
+
}
|
|
1330
|
+
function peg$parse_() {
|
|
1331
|
+
let s0, s1;
|
|
1332
|
+
s0 = [];
|
|
1333
|
+
s1 = input.charAt(peg$currPos);
|
|
1334
|
+
if (peg$r4.test(s1)) {
|
|
1335
|
+
peg$currPos++;
|
|
1336
|
+
} else {
|
|
1337
|
+
s1 = peg$FAILED;
|
|
1338
|
+
if (peg$silentFails === 0) {
|
|
1339
|
+
peg$fail(peg$e19);
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
while (s1 !== peg$FAILED) {
|
|
1343
|
+
s0.push(s1);
|
|
1344
|
+
s1 = input.charAt(peg$currPos);
|
|
1345
|
+
if (peg$r4.test(s1)) {
|
|
1346
|
+
peg$currPos++;
|
|
1347
|
+
} else {
|
|
1348
|
+
s1 = peg$FAILED;
|
|
1349
|
+
if (peg$silentFails === 0) {
|
|
1350
|
+
peg$fail(peg$e19);
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
return s0;
|
|
1355
|
+
}
|
|
1356
|
+
peg$result = peg$startRuleFunction();
|
|
1357
|
+
const peg$success = peg$result !== peg$FAILED && peg$currPos === input.length;
|
|
1358
|
+
function peg$throw() {
|
|
1359
|
+
if (peg$result !== peg$FAILED && peg$currPos < input.length) {
|
|
1360
|
+
peg$fail(peg$endExpectation());
|
|
1361
|
+
}
|
|
1362
|
+
throw peg$buildStructuredError(
|
|
1363
|
+
peg$maxFailExpected,
|
|
1364
|
+
peg$maxFailPos < input.length ? peg$getUnicode(peg$maxFailPos) : null,
|
|
1365
|
+
peg$maxFailPos < input.length ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1) : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)
|
|
1366
|
+
);
|
|
1367
|
+
}
|
|
1368
|
+
if (options.peg$library) {
|
|
1369
|
+
return (
|
|
1370
|
+
/** @type {any} */
|
|
1371
|
+
{
|
|
1372
|
+
peg$result,
|
|
1373
|
+
peg$currPos,
|
|
1374
|
+
peg$FAILED,
|
|
1375
|
+
peg$maxFailExpected,
|
|
1376
|
+
peg$maxFailPos,
|
|
1377
|
+
peg$success,
|
|
1378
|
+
peg$throw: peg$success ? void 0 : peg$throw
|
|
1379
|
+
}
|
|
1380
|
+
);
|
|
1381
|
+
}
|
|
1382
|
+
if (peg$success) {
|
|
1383
|
+
return peg$result;
|
|
1384
|
+
} else {
|
|
1385
|
+
peg$throw();
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1389
|
+
// src/locator/compile.ts
|
|
1390
|
+
function escapeRegexForSelector(re) {
|
|
1391
|
+
if (re.unicode || re.unicodeSets) return String(re);
|
|
1392
|
+
return String(re).replace(/(^|[^\\])(\\\\)*(["'`])/g, "$1$2\\$3").replace(/>>/g, "\\>\\>");
|
|
1393
|
+
}
|
|
1394
|
+
function escapeForTextSelector(text, exact = false) {
|
|
1395
|
+
if (typeof text !== "string") return escapeRegexForSelector(text);
|
|
1396
|
+
return `${JSON.stringify(text)}${exact ? "s" : "i"}`;
|
|
1397
|
+
}
|
|
1398
|
+
function escapeForAttributeSelector(value, exact = false) {
|
|
1399
|
+
if (typeof value !== "string") return escapeRegexForSelector(value);
|
|
1400
|
+
return `"${value.trim().replace(/\\/g, "\\\\").replace(/["]/g, '\\"')}"${exact ? "s" : "i"}`;
|
|
1401
|
+
}
|
|
1402
|
+
function getByAttributeTextSelector(attrName, text, props = "") {
|
|
1403
|
+
return `[${attrName}=${escapeForAttributeSelector(text)}]` + (props ? ` ${props}` : "");
|
|
1404
|
+
}
|
|
1405
|
+
function getByAltTextSelector(text, props = "") {
|
|
1406
|
+
return getByAttributeTextSelector("alt", text, props);
|
|
1407
|
+
}
|
|
1408
|
+
function getByFieldSelector(text, props = "") {
|
|
1409
|
+
const q = escapeForTextSelector(text);
|
|
1410
|
+
return `field=${q}${props ? ` ${props}` : ""}`;
|
|
1411
|
+
}
|
|
1412
|
+
function getByTextSelector(text, props = "") {
|
|
1413
|
+
return "text=" + escapeForTextSelector(text) + (props ? ` ${props}` : "");
|
|
1414
|
+
}
|
|
1415
|
+
function getByDateSelector(text, props = "") {
|
|
1416
|
+
return "date=" + text.trim() + (props ? ` ${props}` : "");
|
|
1417
|
+
}
|
|
1418
|
+
function getByRoleSelector(role, name = "", props = "") {
|
|
1419
|
+
return `role=${role}` + (name ? ` [name=${escapeForAttributeSelector(name)}]` : "") + (props ? ` ${props}` : "");
|
|
1420
|
+
}
|
|
1421
|
+
function compileBaseSelector(sel) {
|
|
1422
|
+
switch (sel.mode) {
|
|
1423
|
+
case "raw":
|
|
1424
|
+
return sel.raw;
|
|
1425
|
+
case "tag":
|
|
1426
|
+
return sel.tag;
|
|
1427
|
+
case "date":
|
|
1428
|
+
return getByDateSelector(sel.name);
|
|
1429
|
+
case "role": {
|
|
1430
|
+
const r = sel.role.toLowerCase();
|
|
1431
|
+
if (r === "field") {
|
|
1432
|
+
if (!sel.name) throw new Error('`field` requires a label string: field "Name"');
|
|
1433
|
+
return getByFieldSelector(sel.name);
|
|
1434
|
+
}
|
|
1435
|
+
if (r === "image") {
|
|
1436
|
+
if (!sel.name) throw new Error('`image` requires an alt string: image "Logo"');
|
|
1437
|
+
return getByAltTextSelector(sel.name);
|
|
1438
|
+
}
|
|
1439
|
+
if (r === "text") {
|
|
1440
|
+
if (!sel.name) throw new Error('`text` requires a string: text "Hello"');
|
|
1441
|
+
return getByTextSelector(sel.name);
|
|
1442
|
+
}
|
|
1443
|
+
return getByRoleSelector(r, sel.name ?? "");
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
}
|
|
1447
|
+
function compilePredicates(include, exclude) {
|
|
1448
|
+
const parts = [];
|
|
1449
|
+
for (const p of include) {
|
|
1450
|
+
const inner = compileBaseSelector(p.selector);
|
|
1451
|
+
parts.push(`>> has="${inner}"`);
|
|
1452
|
+
}
|
|
1453
|
+
for (const p of exclude) {
|
|
1454
|
+
const inner = compileBaseSelector(p.selector);
|
|
1455
|
+
parts.push(`>> has-not="${inner}"`);
|
|
1456
|
+
}
|
|
1457
|
+
return parts.length ? " " + parts.join(" ") : "";
|
|
1458
|
+
}
|
|
1459
|
+
function joinChain(parts) {
|
|
1460
|
+
return parts.filter(Boolean).join(" >> ");
|
|
1461
|
+
}
|
|
1462
|
+
function compileLocator(input) {
|
|
1463
|
+
const ast = peg$parse(input);
|
|
1464
|
+
const chain = ast.ancestors.map(compileBaseSelector);
|
|
1465
|
+
const base = compileBaseSelector(ast.base.selector);
|
|
1466
|
+
const pred = compilePredicates(ast.base.include, ast.base.exclude);
|
|
1467
|
+
let selector = joinChain([...chain, base]);
|
|
1468
|
+
if (pred) selector += " " + pred.trim();
|
|
1469
|
+
return selector;
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1472
|
+
// src/locator/regexp.ts
|
|
1473
|
+
var SELECTOR = /(?:the )?\w+(?: "[^"]*")?|`([^`]+|\\.)*`/;
|
|
1474
|
+
var locatorRegexp = new RegExp(String.raw`((?:${SELECTOR.source})(?: with(?:in|out)? (?:${SELECTOR.source}))*)`);
|
|
1475
|
+
var scalarRegexp = /"((?:[^"\\]+|\\.)*)"|(-?\d+(?:\.\d+)?)|date (?:of )?((?:today|tomorrow|yesterday|\d+ \w+ (?:ago|from now))(?: (?:at )?\d{2}:\d{2}?(?::\d{2})?)?|"\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}(?::\d{2})?(?:.\d{3})?Z?)?")/;
|
|
1476
|
+
var arrayRegexp = new RegExp(String.raw`\[(.*?)\]`);
|
|
1477
|
+
function transformScalar(str, num, date) {
|
|
1478
|
+
if (str != null) return str;
|
|
1479
|
+
if (num != null) return Number(num);
|
|
1480
|
+
if (date) return parseDateString(date);
|
|
1481
|
+
throw new Error("Unexpected value");
|
|
1482
|
+
}
|
|
1483
|
+
var valueTransformer = (str, num, date, arr) => {
|
|
1484
|
+
return arr ? Array.from(arr.matchAll(new RegExp(scalarRegexp, "g")), (m) => transformScalar(m[1], m[2], m[3])) : transformScalar(str, num, date);
|
|
1485
|
+
};
|
|
1486
|
+
|
|
1487
|
+
// src/parameters.ts
|
|
1488
|
+
function enumToRegexp(values) {
|
|
1489
|
+
const satinized = values.map((v) => v.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
|
|
1490
|
+
return new RegExp(`(${satinized.join("|")})`);
|
|
1491
|
+
}
|
|
1492
|
+
function booleanParameter(trueValue, falseValue, regexp) {
|
|
1493
|
+
return {
|
|
1494
|
+
name: trueValue.replace(/\W/, "_"),
|
|
1495
|
+
placeholder: `${trueValue}|${falseValue}`,
|
|
1496
|
+
regexp: regexp ?? enumToRegexp([trueValue, falseValue]),
|
|
1497
|
+
transformer: (value) => value === trueValue
|
|
1498
|
+
};
|
|
1499
|
+
}
|
|
1500
|
+
function enumParameter(values, regexp) {
|
|
1501
|
+
return {
|
|
1502
|
+
name: values[0].replace(/\W/, "_"),
|
|
1503
|
+
placeholder: values.join("|"),
|
|
1504
|
+
regexp: regexp ?? enumToRegexp(values),
|
|
1505
|
+
transformer: (value) => value
|
|
1506
|
+
};
|
|
1507
|
+
}
|
|
1508
|
+
function valueParameter(name = "value") {
|
|
1509
|
+
return {
|
|
1510
|
+
name,
|
|
1511
|
+
placeholder: name,
|
|
1512
|
+
regexp: [scalarRegexp, arrayRegexp],
|
|
1513
|
+
transformer: valueTransformer
|
|
1514
|
+
};
|
|
1515
|
+
}
|
|
1516
|
+
function locatorParameter(name = "locator") {
|
|
1517
|
+
return {
|
|
1518
|
+
name,
|
|
1519
|
+
placeholder: name,
|
|
1520
|
+
regexp: locatorRegexp,
|
|
1521
|
+
transformer: (locator) => {
|
|
1522
|
+
try {
|
|
1523
|
+
return compileLocator(locator);
|
|
1524
|
+
} catch (e) {
|
|
1525
|
+
console.error(e);
|
|
1526
|
+
return locator;
|
|
1527
|
+
}
|
|
1528
|
+
}
|
|
1529
|
+
};
|
|
1530
|
+
}
|
|
1531
|
+
function keysParameter(name = "keys") {
|
|
1532
|
+
return {
|
|
1533
|
+
name,
|
|
1534
|
+
placeholder: name,
|
|
1535
|
+
regexp: /"([^"]+)"|'([^']+)'/,
|
|
1536
|
+
transformer: (doubleQuoted, singleQuoted) => {
|
|
1537
|
+
const raw = (doubleQuoted ?? singleQuoted ?? "").trim();
|
|
1538
|
+
return parseKeyCombo(raw);
|
|
1539
|
+
}
|
|
1540
|
+
};
|
|
1541
|
+
}
|
|
1542
|
+
var newId = IdGenerator.uuid();
|
|
1543
|
+
function makeFeature({ name, description, comments, background, steps }) {
|
|
1544
|
+
const lines = [`Feature: ${name ?? ""}`.trim(), ""];
|
|
1545
|
+
if (description) {
|
|
1546
|
+
lines.push(
|
|
1547
|
+
...description.split("\n").map((s) => ` ${s.trim()}`),
|
|
1548
|
+
""
|
|
1549
|
+
);
|
|
1550
|
+
}
|
|
1551
|
+
if (background && background.length > 0) {
|
|
1552
|
+
lines.push(
|
|
1553
|
+
" Background:",
|
|
1554
|
+
...background.map((s) => ` ${s}`),
|
|
1555
|
+
""
|
|
1556
|
+
);
|
|
1557
|
+
}
|
|
1558
|
+
lines.push(
|
|
1559
|
+
" Scenario:",
|
|
1560
|
+
...steps.map((s) => ` ${s}`)
|
|
1561
|
+
);
|
|
1562
|
+
if (comments) {
|
|
1563
|
+
lines.push(
|
|
1564
|
+
"",
|
|
1565
|
+
...comments.split("\n").map((s) => ` # ${s.trim()}`)
|
|
1566
|
+
);
|
|
1567
|
+
}
|
|
1568
|
+
return lines.join("\n") + "\n";
|
|
1569
|
+
}
|
|
1570
|
+
function wrapIfNeeded(input) {
|
|
1571
|
+
if (/^\s*Feature:/im.test(input)) return input;
|
|
1572
|
+
const lines = input.split("\n");
|
|
1573
|
+
const scenario = lines[0].trim().startsWith("Scenario:") ? lines.shift().trim() : "Scenario:";
|
|
1574
|
+
const indented = lines.map((l) => l.trim() ? " " + l : l);
|
|
1575
|
+
return ["Feature:", ` ${scenario}`, ...indented].join("\n");
|
|
1576
|
+
}
|
|
1577
|
+
function parseFeature(input) {
|
|
1578
|
+
const source = wrapIfNeeded(input);
|
|
1579
|
+
const envelopes = generateMessages(source, "inline.feature", SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN, {
|
|
1580
|
+
newId: () => newId(),
|
|
1581
|
+
includeGherkinDocument: true,
|
|
1582
|
+
includePickles: false,
|
|
1583
|
+
includeSource: false
|
|
1584
|
+
});
|
|
1585
|
+
const gherkinDoc = envelopes.find((e) => e.gherkinDocument)?.gherkinDocument;
|
|
1586
|
+
const feature = gherkinDoc?.feature;
|
|
1587
|
+
const comments = (gherkinDoc?.comments ?? []).map((c) => (c.text ?? "").trim()).filter(Boolean).join("\n") || void 0;
|
|
1588
|
+
if (!feature) return { name: "", description: "", steps: [], comments };
|
|
1589
|
+
const firstScenarioChild = feature.children?.find((c) => c.scenario && !c.scenario?.examples?.length);
|
|
1590
|
+
const scenario = firstScenarioChild?.scenario;
|
|
1591
|
+
if (!scenario) return { name: "", description: feature.description, steps: [], comments };
|
|
1592
|
+
let currentKeyword = "Given";
|
|
1593
|
+
const steps = (scenario.steps ?? []).map((s) => {
|
|
1594
|
+
let keyword = (s.keyword || "").trim();
|
|
1595
|
+
if (keyword.toLowerCase() === "and" || keyword === "*") {
|
|
1596
|
+
keyword = currentKeyword;
|
|
1597
|
+
} else {
|
|
1598
|
+
currentKeyword = keyword;
|
|
1599
|
+
}
|
|
1600
|
+
const text = s.text?.trim() || "";
|
|
1601
|
+
let result = `${keyword} ${text}`.trim();
|
|
1602
|
+
if (s.docString?.content) {
|
|
1603
|
+
result += `
|
|
1604
|
+
"""
|
|
1605
|
+
${s.docString.content.trim()}
|
|
1606
|
+
"""`;
|
|
1607
|
+
}
|
|
1608
|
+
if (s.dataTable?.rows?.length) {
|
|
1609
|
+
const table = s.dataTable.rows.map((r) => `| ${r.cells.map((c) => c.value.trim()).join(" | ")} |`).join("\n");
|
|
1610
|
+
result += `
|
|
1611
|
+
${table}`;
|
|
1612
|
+
}
|
|
1613
|
+
return result;
|
|
1614
|
+
});
|
|
1615
|
+
return { name: feature.name, description: feature.description, steps, comments };
|
|
1616
|
+
}
|
|
1617
|
+
function deltaSteps(steps, newSteps) {
|
|
1618
|
+
let overlap = 0;
|
|
1619
|
+
for (let i = Math.min(steps.length, newSteps.length); i > 0; i--) {
|
|
1620
|
+
if (steps.slice(-i).join("\n") === newSteps.slice(0, i).join("\n")) {
|
|
1621
|
+
overlap = i;
|
|
1622
|
+
break;
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1625
|
+
return newSteps.slice(overlap);
|
|
1626
|
+
}
|
|
1627
|
+
|
|
1628
|
+
// src/sanitize.ts
|
|
1629
|
+
function sanitizeStepDefinition(step) {
|
|
1630
|
+
if (typeof step !== "string") {
|
|
1631
|
+
return step;
|
|
1632
|
+
}
|
|
1633
|
+
return step.replace(/\{([^|}]+)\|[^}]+}/g, "{$1}");
|
|
1634
|
+
}
|
|
1635
|
+
|
|
1636
|
+
export { booleanParameter, deltaSteps, enumParameter, keysParameter, locatorParameter, makeFeature, parseFeature, sanitizeStepDefinition, valueParameter };
|
|
1637
|
+
//# sourceMappingURL=index.js.map
|
|
1638
|
+
//# sourceMappingURL=index.js.map
|