1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | "use strict";
|
8 |
|
9 | function peg$subclass(child, parent) {
|
10 | function ctor() { this.constructor = child; }
|
11 | ctor.prototype = parent.prototype;
|
12 | child.prototype = new ctor();
|
13 | }
|
14 |
|
15 | function peg$SyntaxError(message, expected, found, location) {
|
16 | this.message = message;
|
17 | this.expected = expected;
|
18 | this.found = found;
|
19 | this.location = location;
|
20 | this.name = "SyntaxError";
|
21 |
|
22 | if (typeof Error.captureStackTrace === "function") {
|
23 | Error.captureStackTrace(this, peg$SyntaxError);
|
24 | }
|
25 | }
|
26 |
|
27 | peg$subclass(peg$SyntaxError, Error);
|
28 |
|
29 | peg$SyntaxError.buildMessage = function(expected, found) {
|
30 | var DESCRIBE_EXPECTATION_FNS = {
|
31 | literal: function(expectation) {
|
32 | return "\"" + literalEscape(expectation.text) + "\"";
|
33 | },
|
34 |
|
35 | "class": function(expectation) {
|
36 | var escapedParts = "",
|
37 | i;
|
38 |
|
39 | for (i = 0; i < expectation.parts.length; i++) {
|
40 | escapedParts += expectation.parts[i] instanceof Array
|
41 | ? classEscape(expectation.parts[i][0]) + "-" + classEscape(expectation.parts[i][1])
|
42 | : classEscape(expectation.parts[i]);
|
43 | }
|
44 |
|
45 | return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]";
|
46 | },
|
47 |
|
48 | any: function(expectation) {
|
49 | return "any character";
|
50 | },
|
51 |
|
52 | end: function(expectation) {
|
53 | return "end of input";
|
54 | },
|
55 |
|
56 | other: function(expectation) {
|
57 | return expectation.description;
|
58 | }
|
59 | };
|
60 |
|
61 | function hex(ch) {
|
62 | return ch.charCodeAt(0).toString(16).toUpperCase();
|
63 | }
|
64 |
|
65 | function literalEscape(s) {
|
66 | return s
|
67 | .replace(/\\/g, '\\\\')
|
68 | .replace(/"/g, '\\"')
|
69 | .replace(/\0/g, '\\0')
|
70 | .replace(/\t/g, '\\t')
|
71 | .replace(/\n/g, '\\n')
|
72 | .replace(/\r/g, '\\r')
|
73 | .replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); })
|
74 | .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); });
|
75 | }
|
76 |
|
77 | function classEscape(s) {
|
78 | return s
|
79 | .replace(/\\/g, '\\\\')
|
80 | .replace(/\]/g, '\\]')
|
81 | .replace(/\^/g, '\\^')
|
82 | .replace(/-/g, '\\-')
|
83 | .replace(/\0/g, '\\0')
|
84 | .replace(/\t/g, '\\t')
|
85 | .replace(/\n/g, '\\n')
|
86 | .replace(/\r/g, '\\r')
|
87 | .replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); })
|
88 | .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); });
|
89 | }
|
90 |
|
91 | function describeExpectation(expectation) {
|
92 | return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
|
93 | }
|
94 |
|
95 | function describeExpected(expected) {
|
96 | var descriptions = new Array(expected.length),
|
97 | i, j;
|
98 |
|
99 | for (i = 0; i < expected.length; i++) {
|
100 | descriptions[i] = describeExpectation(expected[i]);
|
101 | }
|
102 |
|
103 | descriptions.sort();
|
104 |
|
105 | if (descriptions.length > 0) {
|
106 | for (i = 1, j = 1; i < descriptions.length; i++) {
|
107 | if (descriptions[i - 1] !== descriptions[i]) {
|
108 | descriptions[j] = descriptions[i];
|
109 | j++;
|
110 | }
|
111 | }
|
112 | descriptions.length = j;
|
113 | }
|
114 |
|
115 | switch (descriptions.length) {
|
116 | case 1:
|
117 | return descriptions[0];
|
118 |
|
119 | case 2:
|
120 | return descriptions[0] + " or " + descriptions[1];
|
121 |
|
122 | default:
|
123 | return descriptions.slice(0, -1).join(", ")
|
124 | + ", or "
|
125 | + descriptions[descriptions.length - 1];
|
126 | }
|
127 | }
|
128 |
|
129 | function describeFound(found) {
|
130 | return found ? "\"" + literalEscape(found) + "\"" : "end of input";
|
131 | }
|
132 |
|
133 | return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
|
134 | };
|
135 |
|
136 | function peg$parse(input, options) {
|
137 | options = options !== void 0 ? options : {};
|
138 |
|
139 | var peg$FAILED = {},
|
140 |
|
141 | peg$startRuleFunctions = { Start: peg$parseStart },
|
142 | peg$startRuleFunction = peg$parseStart,
|
143 |
|
144 | peg$c0 = function(expr) {
|
145 | checkMisusedSize(expr)
|
146 | return checkErrors() || {expression: expr, nestedPaths: nestedPaths, pathHeads: pathHeads}
|
147 | },
|
148 | peg$c1 = function(x, token, y) {
|
149 | [x, y].forEach(checkMisusedSize)
|
150 | return {type: 'or', args: [x, y]}
|
151 | },
|
152 | peg$c2 = function(x, y) {
|
153 | [x, y].forEach(checkMisusedSize)
|
154 | return {type: 'and', args: [x, y]}
|
155 | },
|
156 | peg$c3 = function(token, expr) {
|
157 | checkMisusedSize(expr)
|
158 | return {type: 'not', args: [expr]}
|
159 | },
|
160 | peg$c4 = "(",
|
161 | peg$c5 = peg$literalExpectation("(", false),
|
162 | peg$c6 = ")",
|
163 | peg$c7 = peg$literalExpectation(")", false),
|
164 | peg$c8 = function(expr) {
|
165 | redundantParensError()
|
166 | return expr
|
167 | },
|
168 | peg$c9 = function(expr) {
|
169 | redundantParensError()
|
170 | checkConditionErrors()
|
171 | return expr
|
172 | },
|
173 | peg$c10 = function(expr) {
|
174 | checkConditionErrors()
|
175 | return expr
|
176 | },
|
177 | peg$c11 = function(expr) {
|
178 | return expr
|
179 | },
|
180 | peg$c12 = function(x, comp, y) {
|
181 | checkMisusedFunction([x, y])
|
182 | checkDistinct(comp, [x, y])
|
183 | return {type: comp, args: [x, y]}
|
184 | },
|
185 | peg$c13 = function(x, y, z) {
|
186 | checkMisusedFunction([x, y, z])
|
187 | checkBetweenArgs(y, z)
|
188 | return {type: 'between', args: [x, y, z]}
|
189 | },
|
190 | peg$c14 = function(x, token, args) {
|
191 | checkMisusedFunction([x].concat(args))
|
192 | return {type: 'in', args: [x].concat(args)}
|
193 | },
|
194 | peg$c15 = ">=",
|
195 | peg$c16 = peg$literalExpectation(">=", false),
|
196 | peg$c17 = "<=",
|
197 | peg$c18 = peg$literalExpectation("<=", false),
|
198 | peg$c19 = "<>",
|
199 | peg$c20 = peg$literalExpectation("<>", false),
|
200 | peg$c21 = "=",
|
201 | peg$c22 = peg$literalExpectation("=", false),
|
202 | peg$c23 = "<",
|
203 | peg$c24 = peg$literalExpectation("<", false),
|
204 | peg$c25 = ">",
|
205 | peg$c26 = peg$literalExpectation(">", false),
|
206 | peg$c27 = function(op) {
|
207 | redundantParensError()
|
208 | return op
|
209 | },
|
210 | peg$c28 = function(op) {
|
211 | return op
|
212 | },
|
213 | peg$c29 = function(path) {
|
214 | for (var i = 0; i < path.length; i++) {
|
215 | if (typeof path[i] === 'string') {
|
216 | checkReserved(path[i])
|
217 | } else if (path[i] && path[i].type == 'attrName') {
|
218 | path[i] = resolveAttrName(path[i].name)
|
219 | }
|
220 | }
|
221 | if (path.length > 1) {
|
222 | nestedPaths[path[0]] = true
|
223 | }
|
224 | pathHeads[path[0]] = true
|
225 | return path
|
226 | },
|
227 | peg$c30 = function(head, tail, args) {
|
228 | checkMisusedFunction(args)
|
229 | var name = head + tail.join('')
|
230 | var attrType = checkFunction(name, args)
|
231 | return {type: 'function', name: name, args: args, attrType: attrType}
|
232 | },
|
233 | peg$c31 = ",",
|
234 | peg$c32 = peg$literalExpectation(",", false),
|
235 | peg$c33 = function(head, expr) { return expr },
|
236 | peg$c34 = function(head, tail) {
|
237 | return [head].concat(tail)
|
238 | },
|
239 | peg$c35 = "#",
|
240 | peg$c36 = peg$literalExpectation("#", false),
|
241 | peg$c37 = function(head, tail) {
|
242 | return {type: 'attrName', name: head + tail.join('')}
|
243 | },
|
244 | peg$c38 = ":",
|
245 | peg$c39 = peg$literalExpectation(":", false),
|
246 | peg$c40 = function(head, tail) {
|
247 | return resolveAttrVal(head + tail.join(''))
|
248 | },
|
249 | peg$c41 = "[",
|
250 | peg$c42 = peg$literalExpectation("[", false),
|
251 | peg$c43 = /^[0-9]/,
|
252 | peg$c44 = peg$classExpectation([["0", "9"]], false, false),
|
253 | peg$c45 = "]",
|
254 | peg$c46 = peg$literalExpectation("]", false),
|
255 | peg$c47 = function(head, ix) {
|
256 | return +(ix.join(''))
|
257 | },
|
258 | peg$c48 = ".",
|
259 | peg$c49 = peg$literalExpectation(".", false),
|
260 | peg$c50 = function(head, prop) {
|
261 | return prop
|
262 | },
|
263 | peg$c51 = function(head, tail) {
|
264 | return (Array.isArray(head) ? head : [head]).concat(tail)
|
265 | },
|
266 | peg$c52 = function(path) {
|
267 | redundantParensError()
|
268 | return path
|
269 | },
|
270 | peg$c53 = function(path) {
|
271 | return path
|
272 | },
|
273 | peg$c54 = function(head, tail) {
|
274 | return head + tail.join('')
|
275 | },
|
276 | peg$c55 = /^[a-zA-Z]/,
|
277 | peg$c56 = peg$classExpectation([["a", "z"], ["A", "Z"]], false, false),
|
278 | peg$c57 = "_",
|
279 | peg$c58 = peg$literalExpectation("_", false),
|
280 | peg$c59 = "between",
|
281 | peg$c60 = peg$literalExpectation("BETWEEN", true),
|
282 | peg$c61 = "in",
|
283 | peg$c62 = peg$literalExpectation("IN", true),
|
284 | peg$c63 = "and",
|
285 | peg$c64 = peg$literalExpectation("AND", true),
|
286 | peg$c65 = "or",
|
287 | peg$c66 = peg$literalExpectation("OR", true),
|
288 | peg$c67 = "not",
|
289 | peg$c68 = peg$literalExpectation("NOT", true),
|
290 | peg$c69 = peg$otherExpectation("whitespace"),
|
291 | peg$c70 = /^[ \t\r\n]/,
|
292 | peg$c71 = peg$classExpectation([" ", "\t", "\r", "\n"], false, false),
|
293 |
|
294 | peg$currPos = 0,
|
295 | peg$savedPos = 0,
|
296 | peg$posDetailsCache = [{ line: 1, column: 1 }],
|
297 | peg$maxFailPos = 0,
|
298 | peg$maxFailExpected = [],
|
299 | peg$silentFails = 0,
|
300 |
|
301 | peg$result;
|
302 |
|
303 | if ("startRule" in options) {
|
304 | if (!(options.startRule in peg$startRuleFunctions)) {
|
305 | throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
|
306 | }
|
307 |
|
308 | peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
|
309 | }
|
310 |
|
311 | function text() {
|
312 | return input.substring(peg$savedPos, peg$currPos);
|
313 | }
|
314 |
|
315 | function location() {
|
316 | return peg$computeLocation(peg$savedPos, peg$currPos);
|
317 | }
|
318 |
|
319 | function expected(description, location) {
|
320 | location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos)
|
321 |
|
322 | throw peg$buildStructuredError(
|
323 | [peg$otherExpectation(description)],
|
324 | input.substring(peg$savedPos, peg$currPos),
|
325 | location
|
326 | );
|
327 | }
|
328 |
|
329 | function error(message, location) {
|
330 | location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos)
|
331 |
|
332 | throw peg$buildSimpleError(message, location);
|
333 | }
|
334 |
|
335 | function peg$literalExpectation(text, ignoreCase) {
|
336 | return { type: "literal", text: text, ignoreCase: ignoreCase };
|
337 | }
|
338 |
|
339 | function peg$classExpectation(parts, inverted, ignoreCase) {
|
340 | return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase };
|
341 | }
|
342 |
|
343 | function peg$anyExpectation() {
|
344 | return { type: "any" };
|
345 | }
|
346 |
|
347 | function peg$endExpectation() {
|
348 | return { type: "end" };
|
349 | }
|
350 |
|
351 | function peg$otherExpectation(description) {
|
352 | return { type: "other", description: description };
|
353 | }
|
354 |
|
355 | function peg$computePosDetails(pos) {
|
356 | var details = peg$posDetailsCache[pos], p;
|
357 |
|
358 | if (details) {
|
359 | return details;
|
360 | } else {
|
361 | p = pos - 1;
|
362 | while (!peg$posDetailsCache[p]) {
|
363 | p--;
|
364 | }
|
365 |
|
366 | details = peg$posDetailsCache[p];
|
367 | details = {
|
368 | line: details.line,
|
369 | column: details.column
|
370 | };
|
371 |
|
372 | while (p < pos) {
|
373 | if (input.charCodeAt(p) === 10) {
|
374 | details.line++;
|
375 | details.column = 1;
|
376 | } else {
|
377 | details.column++;
|
378 | }
|
379 |
|
380 | p++;
|
381 | }
|
382 |
|
383 | peg$posDetailsCache[pos] = details;
|
384 | return details;
|
385 | }
|
386 | }
|
387 |
|
388 | function peg$computeLocation(startPos, endPos) {
|
389 | var startPosDetails = peg$computePosDetails(startPos),
|
390 | endPosDetails = peg$computePosDetails(endPos);
|
391 |
|
392 | return {
|
393 | start: {
|
394 | offset: startPos,
|
395 | line: startPosDetails.line,
|
396 | column: startPosDetails.column
|
397 | },
|
398 | end: {
|
399 | offset: endPos,
|
400 | line: endPosDetails.line,
|
401 | column: endPosDetails.column
|
402 | }
|
403 | };
|
404 | }
|
405 |
|
406 | function peg$fail(expected) {
|
407 | if (peg$currPos < peg$maxFailPos) { return; }
|
408 |
|
409 | if (peg$currPos > peg$maxFailPos) {
|
410 | peg$maxFailPos = peg$currPos;
|
411 | peg$maxFailExpected = [];
|
412 | }
|
413 |
|
414 | peg$maxFailExpected.push(expected);
|
415 | }
|
416 |
|
417 | function peg$buildSimpleError(message, location) {
|
418 | return new peg$SyntaxError(message, null, null, location);
|
419 | }
|
420 |
|
421 | function peg$buildStructuredError(expected, found, location) {
|
422 | return new peg$SyntaxError(
|
423 | peg$SyntaxError.buildMessage(expected, found),
|
424 | expected,
|
425 | found,
|
426 | location
|
427 | );
|
428 | }
|
429 |
|
430 | function peg$parseStart() {
|
431 | var s0, s1, s2, s3;
|
432 |
|
433 | s0 = peg$currPos;
|
434 | s1 = peg$parse_();
|
435 | if (s1 !== peg$FAILED) {
|
436 | s2 = peg$parseOrConditionExpression();
|
437 | if (s2 !== peg$FAILED) {
|
438 | s3 = peg$parse_();
|
439 | if (s3 !== peg$FAILED) {
|
440 | peg$savedPos = s0;
|
441 | s1 = peg$c0(s2);
|
442 | s0 = s1;
|
443 | } else {
|
444 | peg$currPos = s0;
|
445 | s0 = peg$FAILED;
|
446 | }
|
447 | } else {
|
448 | peg$currPos = s0;
|
449 | s0 = peg$FAILED;
|
450 | }
|
451 | } else {
|
452 | peg$currPos = s0;
|
453 | s0 = peg$FAILED;
|
454 | }
|
455 |
|
456 | return s0;
|
457 | }
|
458 |
|
459 | function peg$parseOrConditionExpression() {
|
460 | var s0, s1, s2, s3, s4, s5;
|
461 |
|
462 | s0 = peg$currPos;
|
463 | s1 = peg$parseAndConditionExpression();
|
464 | if (s1 !== peg$FAILED) {
|
465 | s2 = peg$parse_();
|
466 | if (s2 !== peg$FAILED) {
|
467 | s3 = peg$parseOrToken();
|
468 | if (s3 !== peg$FAILED) {
|
469 | s4 = peg$parse_();
|
470 | if (s4 !== peg$FAILED) {
|
471 | s5 = peg$parseOrConditionExpression();
|
472 | if (s5 !== peg$FAILED) {
|
473 | peg$savedPos = s0;
|
474 | s1 = peg$c1(s1, s3, s5);
|
475 | s0 = s1;
|
476 | } else {
|
477 | peg$currPos = s0;
|
478 | s0 = peg$FAILED;
|
479 | }
|
480 | } else {
|
481 | peg$currPos = s0;
|
482 | s0 = peg$FAILED;
|
483 | }
|
484 | } else {
|
485 | peg$currPos = s0;
|
486 | s0 = peg$FAILED;
|
487 | }
|
488 | } else {
|
489 | peg$currPos = s0;
|
490 | s0 = peg$FAILED;
|
491 | }
|
492 | } else {
|
493 | peg$currPos = s0;
|
494 | s0 = peg$FAILED;
|
495 | }
|
496 | if (s0 === peg$FAILED) {
|
497 | s0 = peg$parseAndConditionExpression();
|
498 | }
|
499 |
|
500 | return s0;
|
501 | }
|
502 |
|
503 | function peg$parseAndConditionExpression() {
|
504 | var s0, s1, s2, s3, s4, s5;
|
505 |
|
506 | s0 = peg$currPos;
|
507 | s1 = peg$parseNotConditionExpression();
|
508 | if (s1 !== peg$FAILED) {
|
509 | s2 = peg$parse_();
|
510 | if (s2 !== peg$FAILED) {
|
511 | s3 = peg$parseAndToken();
|
512 | if (s3 !== peg$FAILED) {
|
513 | s4 = peg$parse_();
|
514 | if (s4 !== peg$FAILED) {
|
515 | s5 = peg$parseAndConditionExpression();
|
516 | if (s5 !== peg$FAILED) {
|
517 | peg$savedPos = s0;
|
518 | s1 = peg$c2(s1, s5);
|
519 | s0 = s1;
|
520 | } else {
|
521 | peg$currPos = s0;
|
522 | s0 = peg$FAILED;
|
523 | }
|
524 | } else {
|
525 | peg$currPos = s0;
|
526 | s0 = peg$FAILED;
|
527 | }
|
528 | } else {
|
529 | peg$currPos = s0;
|
530 | s0 = peg$FAILED;
|
531 | }
|
532 | } else {
|
533 | peg$currPos = s0;
|
534 | s0 = peg$FAILED;
|
535 | }
|
536 | } else {
|
537 | peg$currPos = s0;
|
538 | s0 = peg$FAILED;
|
539 | }
|
540 | if (s0 === peg$FAILED) {
|
541 | s0 = peg$parseNotConditionExpression();
|
542 | }
|
543 |
|
544 | return s0;
|
545 | }
|
546 |
|
547 | function peg$parseNotConditionExpression() {
|
548 | var s0, s1, s2, s3;
|
549 |
|
550 | s0 = peg$currPos;
|
551 | s1 = peg$parseNotToken();
|
552 | if (s1 !== peg$FAILED) {
|
553 | s2 = peg$parse_();
|
554 | if (s2 !== peg$FAILED) {
|
555 | s3 = peg$parseParensConditionExpression();
|
556 | if (s3 !== peg$FAILED) {
|
557 | peg$savedPos = s0;
|
558 | s1 = peg$c3(s1, s3);
|
559 | s0 = s1;
|
560 | } else {
|
561 | peg$currPos = s0;
|
562 | s0 = peg$FAILED;
|
563 | }
|
564 | } else {
|
565 | peg$currPos = s0;
|
566 | s0 = peg$FAILED;
|
567 | }
|
568 | } else {
|
569 | peg$currPos = s0;
|
570 | s0 = peg$FAILED;
|
571 | }
|
572 | if (s0 === peg$FAILED) {
|
573 | s0 = peg$parseParensConditionExpression();
|
574 | }
|
575 |
|
576 | return s0;
|
577 | }
|
578 |
|
579 | function peg$parseParensConditionExpression() {
|
580 | var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9;
|
581 |
|
582 | s0 = peg$currPos;
|
583 | if (input.charCodeAt(peg$currPos) === 40) {
|
584 | s1 = peg$c4;
|
585 | peg$currPos++;
|
586 | } else {
|
587 | s1 = peg$FAILED;
|
588 | if (peg$silentFails === 0) { peg$fail(peg$c5); }
|
589 | }
|
590 | if (s1 !== peg$FAILED) {
|
591 | s2 = peg$parse_();
|
592 | if (s2 !== peg$FAILED) {
|
593 | if (input.charCodeAt(peg$currPos) === 40) {
|
594 | s3 = peg$c4;
|
595 | peg$currPos++;
|
596 | } else {
|
597 | s3 = peg$FAILED;
|
598 | if (peg$silentFails === 0) { peg$fail(peg$c5); }
|
599 | }
|
600 | if (s3 !== peg$FAILED) {
|
601 | s4 = peg$parse_();
|
602 | if (s4 !== peg$FAILED) {
|
603 | s5 = peg$parseOrConditionExpression();
|
604 | if (s5 !== peg$FAILED) {
|
605 | s6 = peg$parse_();
|
606 | if (s6 !== peg$FAILED) {
|
607 | if (input.charCodeAt(peg$currPos) === 41) {
|
608 | s7 = peg$c6;
|
609 | peg$currPos++;
|
610 | } else {
|
611 | s7 = peg$FAILED;
|
612 | if (peg$silentFails === 0) { peg$fail(peg$c7); }
|
613 | }
|
614 | if (s7 !== peg$FAILED) {
|
615 | s8 = peg$parse_();
|
616 | if (s8 !== peg$FAILED) {
|
617 | if (input.charCodeAt(peg$currPos) === 41) {
|
618 | s9 = peg$c6;
|
619 | peg$currPos++;
|
620 | } else {
|
621 | s9 = peg$FAILED;
|
622 | if (peg$silentFails === 0) { peg$fail(peg$c7); }
|
623 | }
|
624 | if (s9 !== peg$FAILED) {
|
625 | peg$savedPos = s0;
|
626 | s1 = peg$c8(s5);
|
627 | s0 = s1;
|
628 | } else {
|
629 | peg$currPos = s0;
|
630 | s0 = peg$FAILED;
|
631 | }
|
632 | } else {
|
633 | peg$currPos = s0;
|
634 | s0 = peg$FAILED;
|
635 | }
|
636 | } else {
|
637 | peg$currPos = s0;
|
638 | s0 = peg$FAILED;
|
639 | }
|
640 | } else {
|
641 | peg$currPos = s0;
|
642 | s0 = peg$FAILED;
|
643 | }
|
644 | } else {
|
645 | peg$currPos = s0;
|
646 | s0 = peg$FAILED;
|
647 | }
|
648 | } else {
|
649 | peg$currPos = s0;
|
650 | s0 = peg$FAILED;
|
651 | }
|
652 | } else {
|
653 | peg$currPos = s0;
|
654 | s0 = peg$FAILED;
|
655 | }
|
656 | } else {
|
657 | peg$currPos = s0;
|
658 | s0 = peg$FAILED;
|
659 | }
|
660 | } else {
|
661 | peg$currPos = s0;
|
662 | s0 = peg$FAILED;
|
663 | }
|
664 | if (s0 === peg$FAILED) {
|
665 | s0 = peg$currPos;
|
666 | if (input.charCodeAt(peg$currPos) === 40) {
|
667 | s1 = peg$c4;
|
668 | peg$currPos++;
|
669 | } else {
|
670 | s1 = peg$FAILED;
|
671 | if (peg$silentFails === 0) { peg$fail(peg$c5); }
|
672 | }
|
673 | if (s1 !== peg$FAILED) {
|
674 | s2 = peg$parse_();
|
675 | if (s2 !== peg$FAILED) {
|
676 | if (input.charCodeAt(peg$currPos) === 40) {
|
677 | s3 = peg$c4;
|
678 | peg$currPos++;
|
679 | } else {
|
680 | s3 = peg$FAILED;
|
681 | if (peg$silentFails === 0) { peg$fail(peg$c5); }
|
682 | }
|
683 | if (s3 !== peg$FAILED) {
|
684 | s4 = peg$parse_();
|
685 | if (s4 !== peg$FAILED) {
|
686 | s5 = peg$parseConditionExpression();
|
687 | if (s5 !== peg$FAILED) {
|
688 | s6 = peg$parse_();
|
689 | if (s6 !== peg$FAILED) {
|
690 | if (input.charCodeAt(peg$currPos) === 41) {
|
691 | s7 = peg$c6;
|
692 | peg$currPos++;
|
693 | } else {
|
694 | s7 = peg$FAILED;
|
695 | if (peg$silentFails === 0) { peg$fail(peg$c7); }
|
696 | }
|
697 | if (s7 !== peg$FAILED) {
|
698 | s8 = peg$parse_();
|
699 | if (s8 !== peg$FAILED) {
|
700 | if (input.charCodeAt(peg$currPos) === 41) {
|
701 | s9 = peg$c6;
|
702 | peg$currPos++;
|
703 | } else {
|
704 | s9 = peg$FAILED;
|
705 | if (peg$silentFails === 0) { peg$fail(peg$c7); }
|
706 | }
|
707 | if (s9 !== peg$FAILED) {
|
708 | peg$savedPos = s0;
|
709 | s1 = peg$c9(s5);
|
710 | s0 = s1;
|
711 | } else {
|
712 | peg$currPos = s0;
|
713 | s0 = peg$FAILED;
|
714 | }
|
715 | } else {
|
716 | peg$currPos = s0;
|
717 | s0 = peg$FAILED;
|
718 | }
|
719 | } else {
|
720 | peg$currPos = s0;
|
721 | s0 = peg$FAILED;
|
722 | }
|
723 | } else {
|
724 | peg$currPos = s0;
|
725 | s0 = peg$FAILED;
|
726 | }
|
727 | } else {
|
728 | peg$currPos = s0;
|
729 | s0 = peg$FAILED;
|
730 | }
|
731 | } else {
|
732 | peg$currPos = s0;
|
733 | s0 = peg$FAILED;
|
734 | }
|
735 | } else {
|
736 | peg$currPos = s0;
|
737 | s0 = peg$FAILED;
|
738 | }
|
739 | } else {
|
740 | peg$currPos = s0;
|
741 | s0 = peg$FAILED;
|
742 | }
|
743 | } else {
|
744 | peg$currPos = s0;
|
745 | s0 = peg$FAILED;
|
746 | }
|
747 | if (s0 === peg$FAILED) {
|
748 | s0 = peg$currPos;
|
749 | s1 = peg$parseConditionExpression();
|
750 | if (s1 !== peg$FAILED) {
|
751 | peg$savedPos = s0;
|
752 | s1 = peg$c10(s1);
|
753 | }
|
754 | s0 = s1;
|
755 | if (s0 === peg$FAILED) {
|
756 | s0 = peg$currPos;
|
757 | if (input.charCodeAt(peg$currPos) === 40) {
|
758 | s1 = peg$c4;
|
759 | peg$currPos++;
|
760 | } else {
|
761 | s1 = peg$FAILED;
|
762 | if (peg$silentFails === 0) { peg$fail(peg$c5); }
|
763 | }
|
764 | if (s1 !== peg$FAILED) {
|
765 | s2 = peg$parse_();
|
766 | if (s2 !== peg$FAILED) {
|
767 | s3 = peg$parseOrConditionExpression();
|
768 | if (s3 !== peg$FAILED) {
|
769 | s4 = peg$parse_();
|
770 | if (s4 !== peg$FAILED) {
|
771 | if (input.charCodeAt(peg$currPos) === 41) {
|
772 | s5 = peg$c6;
|
773 | peg$currPos++;
|
774 | } else {
|
775 | s5 = peg$FAILED;
|
776 | if (peg$silentFails === 0) { peg$fail(peg$c7); }
|
777 | }
|
778 | if (s5 !== peg$FAILED) {
|
779 | peg$savedPos = s0;
|
780 | s1 = peg$c11(s3);
|
781 | s0 = s1;
|
782 | } else {
|
783 | peg$currPos = s0;
|
784 | s0 = peg$FAILED;
|
785 | }
|
786 | } else {
|
787 | peg$currPos = s0;
|
788 | s0 = peg$FAILED;
|
789 | }
|
790 | } else {
|
791 | peg$currPos = s0;
|
792 | s0 = peg$FAILED;
|
793 | }
|
794 | } else {
|
795 | peg$currPos = s0;
|
796 | s0 = peg$FAILED;
|
797 | }
|
798 | } else {
|
799 | peg$currPos = s0;
|
800 | s0 = peg$FAILED;
|
801 | }
|
802 | }
|
803 | }
|
804 | }
|
805 |
|
806 | return s0;
|
807 | }
|
808 |
|
809 | function peg$parseConditionExpression() {
|
810 | var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9;
|
811 |
|
812 | s0 = peg$currPos;
|
813 | s1 = peg$parseOperandParens();
|
814 | if (s1 !== peg$FAILED) {
|
815 | s2 = peg$parse_();
|
816 | if (s2 !== peg$FAILED) {
|
817 | s3 = peg$parseComparator();
|
818 | if (s3 !== peg$FAILED) {
|
819 | s4 = peg$parse_();
|
820 | if (s4 !== peg$FAILED) {
|
821 | s5 = peg$parseOperandParens();
|
822 | if (s5 !== peg$FAILED) {
|
823 | peg$savedPos = s0;
|
824 | s1 = peg$c12(s1, s3, s5);
|
825 | s0 = s1;
|
826 | } else {
|
827 | peg$currPos = s0;
|
828 | s0 = peg$FAILED;
|
829 | }
|
830 | } else {
|
831 | peg$currPos = s0;
|
832 | s0 = peg$FAILED;
|
833 | }
|
834 | } else {
|
835 | peg$currPos = s0;
|
836 | s0 = peg$FAILED;
|
837 | }
|
838 | } else {
|
839 | peg$currPos = s0;
|
840 | s0 = peg$FAILED;
|
841 | }
|
842 | } else {
|
843 | peg$currPos = s0;
|
844 | s0 = peg$FAILED;
|
845 | }
|
846 | if (s0 === peg$FAILED) {
|
847 | s0 = peg$currPos;
|
848 | s1 = peg$parseOperandParens();
|
849 | if (s1 !== peg$FAILED) {
|
850 | s2 = peg$parse_();
|
851 | if (s2 !== peg$FAILED) {
|
852 | s3 = peg$parseBetweenToken();
|
853 | if (s3 !== peg$FAILED) {
|
854 | s4 = peg$parse_();
|
855 | if (s4 !== peg$FAILED) {
|
856 | s5 = peg$parseOperandParens();
|
857 | if (s5 !== peg$FAILED) {
|
858 | s6 = peg$parse_();
|
859 | if (s6 !== peg$FAILED) {
|
860 | s7 = peg$parseAndToken();
|
861 | if (s7 !== peg$FAILED) {
|
862 | s8 = peg$parse_();
|
863 | if (s8 !== peg$FAILED) {
|
864 | s9 = peg$parseOperandParens();
|
865 | if (s9 !== peg$FAILED) {
|
866 | peg$savedPos = s0;
|
867 | s1 = peg$c13(s1, s5, s9);
|
868 | s0 = s1;
|
869 | } else {
|
870 | peg$currPos = s0;
|
871 | s0 = peg$FAILED;
|
872 | }
|
873 | } else {
|
874 | peg$currPos = s0;
|
875 | s0 = peg$FAILED;
|
876 | }
|
877 | } else {
|
878 | peg$currPos = s0;
|
879 | s0 = peg$FAILED;
|
880 | }
|
881 | } else {
|
882 | peg$currPos = s0;
|
883 | s0 = peg$FAILED;
|
884 | }
|
885 | } else {
|
886 | peg$currPos = s0;
|
887 | s0 = peg$FAILED;
|
888 | }
|
889 | } else {
|
890 | peg$currPos = s0;
|
891 | s0 = peg$FAILED;
|
892 | }
|
893 | } else {
|
894 | peg$currPos = s0;
|
895 | s0 = peg$FAILED;
|
896 | }
|
897 | } else {
|
898 | peg$currPos = s0;
|
899 | s0 = peg$FAILED;
|
900 | }
|
901 | } else {
|
902 | peg$currPos = s0;
|
903 | s0 = peg$FAILED;
|
904 | }
|
905 | if (s0 === peg$FAILED) {
|
906 | s0 = peg$currPos;
|
907 | s1 = peg$parseOperandParens();
|
908 | if (s1 !== peg$FAILED) {
|
909 | s2 = peg$parse_();
|
910 | if (s2 !== peg$FAILED) {
|
911 | s3 = peg$parseInToken();
|
912 | if (s3 !== peg$FAILED) {
|
913 | s4 = peg$parse_();
|
914 | if (s4 !== peg$FAILED) {
|
915 | if (input.charCodeAt(peg$currPos) === 40) {
|
916 | s5 = peg$c4;
|
917 | peg$currPos++;
|
918 | } else {
|
919 | s5 = peg$FAILED;
|
920 | if (peg$silentFails === 0) { peg$fail(peg$c5); }
|
921 | }
|
922 | if (s5 !== peg$FAILED) {
|
923 | s6 = peg$parse_();
|
924 | if (s6 !== peg$FAILED) {
|
925 | s7 = peg$parseFunctionArgumentList();
|
926 | if (s7 !== peg$FAILED) {
|
927 | s8 = peg$parse_();
|
928 | if (s8 !== peg$FAILED) {
|
929 | if (input.charCodeAt(peg$currPos) === 41) {
|
930 | s9 = peg$c6;
|
931 | peg$currPos++;
|
932 | } else {
|
933 | s9 = peg$FAILED;
|
934 | if (peg$silentFails === 0) { peg$fail(peg$c7); }
|
935 | }
|
936 | if (s9 !== peg$FAILED) {
|
937 | peg$savedPos = s0;
|
938 | s1 = peg$c14(s1, s3, s7);
|
939 | s0 = s1;
|
940 | } else {
|
941 | peg$currPos = s0;
|
942 | s0 = peg$FAILED;
|
943 | }
|
944 | } else {
|
945 | peg$currPos = s0;
|
946 | s0 = peg$FAILED;
|
947 | }
|
948 | } else {
|
949 | peg$currPos = s0;
|
950 | s0 = peg$FAILED;
|
951 | }
|
952 | } else {
|
953 | peg$currPos = s0;
|
954 | s0 = peg$FAILED;
|
955 | }
|
956 | } else {
|
957 | peg$currPos = s0;
|
958 | s0 = peg$FAILED;
|
959 | }
|
960 | } else {
|
961 | peg$currPos = s0;
|
962 | s0 = peg$FAILED;
|
963 | }
|
964 | } else {
|
965 | peg$currPos = s0;
|
966 | s0 = peg$FAILED;
|
967 | }
|
968 | } else {
|
969 | peg$currPos = s0;
|
970 | s0 = peg$FAILED;
|
971 | }
|
972 | } else {
|
973 | peg$currPos = s0;
|
974 | s0 = peg$FAILED;
|
975 | }
|
976 | if (s0 === peg$FAILED) {
|
977 | s0 = peg$parseFunction();
|
978 | }
|
979 | }
|
980 | }
|
981 |
|
982 | return s0;
|
983 | }
|
984 |
|
985 | function peg$parseComparator() {
|
986 | var s0;
|
987 |
|
988 | if (input.substr(peg$currPos, 2) === peg$c15) {
|
989 | s0 = peg$c15;
|
990 | peg$currPos += 2;
|
991 | } else {
|
992 | s0 = peg$FAILED;
|
993 | if (peg$silentFails === 0) { peg$fail(peg$c16); }
|
994 | }
|
995 | if (s0 === peg$FAILED) {
|
996 | if (input.substr(peg$currPos, 2) === peg$c17) {
|
997 | s0 = peg$c17;
|
998 | peg$currPos += 2;
|
999 | } else {
|
1000 | s0 = peg$FAILED;
|
1001 | if (peg$silentFails === 0) { peg$fail(peg$c18); }
|
1002 | }
|
1003 | if (s0 === peg$FAILED) {
|
1004 | if (input.substr(peg$currPos, 2) === peg$c19) {
|
1005 | s0 = peg$c19;
|
1006 | peg$currPos += 2;
|
1007 | } else {
|
1008 | s0 = peg$FAILED;
|
1009 | if (peg$silentFails === 0) { peg$fail(peg$c20); }
|
1010 | }
|
1011 | if (s0 === peg$FAILED) {
|
1012 | if (input.charCodeAt(peg$currPos) === 61) {
|
1013 | s0 = peg$c21;
|
1014 | peg$currPos++;
|
1015 | } else {
|
1016 | s0 = peg$FAILED;
|
1017 | if (peg$silentFails === 0) { peg$fail(peg$c22); }
|
1018 | }
|
1019 | if (s0 === peg$FAILED) {
|
1020 | if (input.charCodeAt(peg$currPos) === 60) {
|
1021 | s0 = peg$c23;
|
1022 | peg$currPos++;
|
1023 | } else {
|
1024 | s0 = peg$FAILED;
|
1025 | if (peg$silentFails === 0) { peg$fail(peg$c24); }
|
1026 | }
|
1027 | if (s0 === peg$FAILED) {
|
1028 | if (input.charCodeAt(peg$currPos) === 62) {
|
1029 | s0 = peg$c25;
|
1030 | peg$currPos++;
|
1031 | } else {
|
1032 | s0 = peg$FAILED;
|
1033 | if (peg$silentFails === 0) { peg$fail(peg$c26); }
|
1034 | }
|
1035 | }
|
1036 | }
|
1037 | }
|
1038 | }
|
1039 | }
|
1040 |
|
1041 | return s0;
|
1042 | }
|
1043 |
|
1044 | function peg$parseOperandParens() {
|
1045 | var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9;
|
1046 |
|
1047 | s0 = peg$currPos;
|
1048 | if (input.charCodeAt(peg$currPos) === 40) {
|
1049 | s1 = peg$c4;
|
1050 | peg$currPos++;
|
1051 | } else {
|
1052 | s1 = peg$FAILED;
|
1053 | if (peg$silentFails === 0) { peg$fail(peg$c5); }
|
1054 | }
|
1055 | if (s1 !== peg$FAILED) {
|
1056 | s2 = peg$parse_();
|
1057 | if (s2 !== peg$FAILED) {
|
1058 | if (input.charCodeAt(peg$currPos) === 40) {
|
1059 | s3 = peg$c4;
|
1060 | peg$currPos++;
|
1061 | } else {
|
1062 | s3 = peg$FAILED;
|
1063 | if (peg$silentFails === 0) { peg$fail(peg$c5); }
|
1064 | }
|
1065 | if (s3 !== peg$FAILED) {
|
1066 | s4 = peg$parse_();
|
1067 | if (s4 !== peg$FAILED) {
|
1068 | s5 = peg$parseOperand();
|
1069 | if (s5 !== peg$FAILED) {
|
1070 | s6 = peg$parse_();
|
1071 | if (s6 !== peg$FAILED) {
|
1072 | if (input.charCodeAt(peg$currPos) === 41) {
|
1073 | s7 = peg$c6;
|
1074 | peg$currPos++;
|
1075 | } else {
|
1076 | s7 = peg$FAILED;
|
1077 | if (peg$silentFails === 0) { peg$fail(peg$c7); }
|
1078 | }
|
1079 | if (s7 !== peg$FAILED) {
|
1080 | s8 = peg$parse_();
|
1081 | if (s8 !== peg$FAILED) {
|
1082 | if (input.charCodeAt(peg$currPos) === 41) {
|
1083 | s9 = peg$c6;
|
1084 | peg$currPos++;
|
1085 | } else {
|
1086 | s9 = peg$FAILED;
|
1087 | if (peg$silentFails === 0) { peg$fail(peg$c7); }
|
1088 | }
|
1089 | if (s9 !== peg$FAILED) {
|
1090 | peg$savedPos = s0;
|
1091 | s1 = peg$c27(s5);
|
1092 | s0 = s1;
|
1093 | } else {
|
1094 | peg$currPos = s0;
|
1095 | s0 = peg$FAILED;
|
1096 | }
|
1097 | } else {
|
1098 | peg$currPos = s0;
|
1099 | s0 = peg$FAILED;
|
1100 | }
|
1101 | } else {
|
1102 | peg$currPos = s0;
|
1103 | s0 = peg$FAILED;
|
1104 | }
|
1105 | } else {
|
1106 | peg$currPos = s0;
|
1107 | s0 = peg$FAILED;
|
1108 | }
|
1109 | } else {
|
1110 | peg$currPos = s0;
|
1111 | s0 = peg$FAILED;
|
1112 | }
|
1113 | } else {
|
1114 | peg$currPos = s0;
|
1115 | s0 = peg$FAILED;
|
1116 | }
|
1117 | } else {
|
1118 | peg$currPos = s0;
|
1119 | s0 = peg$FAILED;
|
1120 | }
|
1121 | } else {
|
1122 | peg$currPos = s0;
|
1123 | s0 = peg$FAILED;
|
1124 | }
|
1125 | } else {
|
1126 | peg$currPos = s0;
|
1127 | s0 = peg$FAILED;
|
1128 | }
|
1129 | if (s0 === peg$FAILED) {
|
1130 | s0 = peg$currPos;
|
1131 | if (input.charCodeAt(peg$currPos) === 40) {
|
1132 | s1 = peg$c4;
|
1133 | peg$currPos++;
|
1134 | } else {
|
1135 | s1 = peg$FAILED;
|
1136 | if (peg$silentFails === 0) { peg$fail(peg$c5); }
|
1137 | }
|
1138 | if (s1 !== peg$FAILED) {
|
1139 | s2 = peg$parse_();
|
1140 | if (s2 !== peg$FAILED) {
|
1141 | s3 = peg$parseOperand();
|
1142 | if (s3 !== peg$FAILED) {
|
1143 | s4 = peg$parse_();
|
1144 | if (s4 !== peg$FAILED) {
|
1145 | if (input.charCodeAt(peg$currPos) === 41) {
|
1146 | s5 = peg$c6;
|
1147 | peg$currPos++;
|
1148 | } else {
|
1149 | s5 = peg$FAILED;
|
1150 | if (peg$silentFails === 0) { peg$fail(peg$c7); }
|
1151 | }
|
1152 | if (s5 !== peg$FAILED) {
|
1153 | peg$savedPos = s0;
|
1154 | s1 = peg$c28(s3);
|
1155 | s0 = s1;
|
1156 | } else {
|
1157 | peg$currPos = s0;
|
1158 | s0 = peg$FAILED;
|
1159 | }
|
1160 | } else {
|
1161 | peg$currPos = s0;
|
1162 | s0 = peg$FAILED;
|
1163 | }
|
1164 | } else {
|
1165 | peg$currPos = s0;
|
1166 | s0 = peg$FAILED;
|
1167 | }
|
1168 | } else {
|
1169 | peg$currPos = s0;
|
1170 | s0 = peg$FAILED;
|
1171 | }
|
1172 | } else {
|
1173 | peg$currPos = s0;
|
1174 | s0 = peg$FAILED;
|
1175 | }
|
1176 | if (s0 === peg$FAILED) {
|
1177 | s0 = peg$parseOperand();
|
1178 | }
|
1179 | }
|
1180 |
|
1181 | return s0;
|
1182 | }
|
1183 |
|
1184 | function peg$parseOperand() {
|
1185 | var s0, s1;
|
1186 |
|
1187 | s0 = peg$parseFunction();
|
1188 | if (s0 === peg$FAILED) {
|
1189 | s0 = peg$parseExpressionAttributeValue();
|
1190 | if (s0 === peg$FAILED) {
|
1191 | s0 = peg$currPos;
|
1192 | s1 = peg$parsePathExpression();
|
1193 | if (s1 !== peg$FAILED) {
|
1194 | peg$savedPos = s0;
|
1195 | s1 = peg$c29(s1);
|
1196 | }
|
1197 | s0 = s1;
|
1198 | }
|
1199 | }
|
1200 |
|
1201 | return s0;
|
1202 | }
|
1203 |
|
1204 | function peg$parseFunction() {
|
1205 | var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9;
|
1206 |
|
1207 | s0 = peg$currPos;
|
1208 | s1 = peg$currPos;
|
1209 | peg$silentFails++;
|
1210 | s2 = peg$parseReservedWord();
|
1211 | peg$silentFails--;
|
1212 | if (s2 === peg$FAILED) {
|
1213 | s1 = void 0;
|
1214 | } else {
|
1215 | peg$currPos = s1;
|
1216 | s1 = peg$FAILED;
|
1217 | }
|
1218 | if (s1 !== peg$FAILED) {
|
1219 | s2 = peg$parseIdentifierStart();
|
1220 | if (s2 !== peg$FAILED) {
|
1221 | s3 = [];
|
1222 | s4 = peg$parseIdentifierPart();
|
1223 | while (s4 !== peg$FAILED) {
|
1224 | s3.push(s4);
|
1225 | s4 = peg$parseIdentifierPart();
|
1226 | }
|
1227 | if (s3 !== peg$FAILED) {
|
1228 | s4 = peg$parse_();
|
1229 | if (s4 !== peg$FAILED) {
|
1230 | if (input.charCodeAt(peg$currPos) === 40) {
|
1231 | s5 = peg$c4;
|
1232 | peg$currPos++;
|
1233 | } else {
|
1234 | s5 = peg$FAILED;
|
1235 | if (peg$silentFails === 0) { peg$fail(peg$c5); }
|
1236 | }
|
1237 | if (s5 !== peg$FAILED) {
|
1238 | s6 = peg$parse_();
|
1239 | if (s6 !== peg$FAILED) {
|
1240 | s7 = peg$parseFunctionArgumentList();
|
1241 | if (s7 !== peg$FAILED) {
|
1242 | s8 = peg$parse_();
|
1243 | if (s8 !== peg$FAILED) {
|
1244 | if (input.charCodeAt(peg$currPos) === 41) {
|
1245 | s9 = peg$c6;
|
1246 | peg$currPos++;
|
1247 | } else {
|
1248 | s9 = peg$FAILED;
|
1249 | if (peg$silentFails === 0) { peg$fail(peg$c7); }
|
1250 | }
|
1251 | if (s9 !== peg$FAILED) {
|
1252 | peg$savedPos = s0;
|
1253 | s1 = peg$c30(s2, s3, s7);
|
1254 | s0 = s1;
|
1255 | } else {
|
1256 | peg$currPos = s0;
|
1257 | s0 = peg$FAILED;
|
1258 | }
|
1259 | } else {
|
1260 | peg$currPos = s0;
|
1261 | s0 = peg$FAILED;
|
1262 | }
|
1263 | } else {
|
1264 | peg$currPos = s0;
|
1265 | s0 = peg$FAILED;
|
1266 | }
|
1267 | } else {
|
1268 | peg$currPos = s0;
|
1269 | s0 = peg$FAILED;
|
1270 | }
|
1271 | } else {
|
1272 | peg$currPos = s0;
|
1273 | s0 = peg$FAILED;
|
1274 | }
|
1275 | } else {
|
1276 | peg$currPos = s0;
|
1277 | s0 = peg$FAILED;
|
1278 | }
|
1279 | } else {
|
1280 | peg$currPos = s0;
|
1281 | s0 = peg$FAILED;
|
1282 | }
|
1283 | } else {
|
1284 | peg$currPos = s0;
|
1285 | s0 = peg$FAILED;
|
1286 | }
|
1287 | } else {
|
1288 | peg$currPos = s0;
|
1289 | s0 = peg$FAILED;
|
1290 | }
|
1291 |
|
1292 | return s0;
|
1293 | }
|
1294 |
|
1295 | function peg$parseFunctionArgumentList() {
|
1296 | var s0, s1, s2, s3, s4, s5, s6, s7;
|
1297 |
|
1298 | s0 = peg$currPos;
|
1299 | s1 = peg$parseOperandParens();
|
1300 | if (s1 !== peg$FAILED) {
|
1301 | s2 = [];
|
1302 | s3 = peg$currPos;
|
1303 | s4 = peg$parse_();
|
1304 | if (s4 !== peg$FAILED) {
|
1305 | if (input.charCodeAt(peg$currPos) === 44) {
|
1306 | s5 = peg$c31;
|
1307 | peg$currPos++;
|
1308 | } else {
|
1309 | s5 = peg$FAILED;
|
1310 | if (peg$silentFails === 0) { peg$fail(peg$c32); }
|
1311 | }
|
1312 | if (s5 !== peg$FAILED) {
|
1313 | s6 = peg$parse_();
|
1314 | if (s6 !== peg$FAILED) {
|
1315 | s7 = peg$parseOperandParens();
|
1316 | if (s7 !== peg$FAILED) {
|
1317 | peg$savedPos = s3;
|
1318 | s4 = peg$c33(s1, s7);
|
1319 | s3 = s4;
|
1320 | } else {
|
1321 | peg$currPos = s3;
|
1322 | s3 = peg$FAILED;
|
1323 | }
|
1324 | } else {
|
1325 | peg$currPos = s3;
|
1326 | s3 = peg$FAILED;
|
1327 | }
|
1328 | } else {
|
1329 | peg$currPos = s3;
|
1330 | s3 = peg$FAILED;
|
1331 | }
|
1332 | } else {
|
1333 | peg$currPos = s3;
|
1334 | s3 = peg$FAILED;
|
1335 | }
|
1336 | while (s3 !== peg$FAILED) {
|
1337 | s2.push(s3);
|
1338 | s3 = peg$currPos;
|
1339 | s4 = peg$parse_();
|
1340 | if (s4 !== peg$FAILED) {
|
1341 | if (input.charCodeAt(peg$currPos) === 44) {
|
1342 | s5 = peg$c31;
|
1343 | peg$currPos++;
|
1344 | } else {
|
1345 | s5 = peg$FAILED;
|
1346 | if (peg$silentFails === 0) { peg$fail(peg$c32); }
|
1347 | }
|
1348 | if (s5 !== peg$FAILED) {
|
1349 | s6 = peg$parse_();
|
1350 | if (s6 !== peg$FAILED) {
|
1351 | s7 = peg$parseOperandParens();
|
1352 | if (s7 !== peg$FAILED) {
|
1353 | peg$savedPos = s3;
|
1354 | s4 = peg$c33(s1, s7);
|
1355 | s3 = s4;
|
1356 | } else {
|
1357 | peg$currPos = s3;
|
1358 | s3 = peg$FAILED;
|
1359 | }
|
1360 | } else {
|
1361 | peg$currPos = s3;
|
1362 | s3 = peg$FAILED;
|
1363 | }
|
1364 | } else {
|
1365 | peg$currPos = s3;
|
1366 | s3 = peg$FAILED;
|
1367 | }
|
1368 | } else {
|
1369 | peg$currPos = s3;
|
1370 | s3 = peg$FAILED;
|
1371 | }
|
1372 | }
|
1373 | if (s2 !== peg$FAILED) {
|
1374 | peg$savedPos = s0;
|
1375 | s1 = peg$c34(s1, s2);
|
1376 | s0 = s1;
|
1377 | } else {
|
1378 | peg$currPos = s0;
|
1379 | s0 = peg$FAILED;
|
1380 | }
|
1381 | } else {
|
1382 | peg$currPos = s0;
|
1383 | s0 = peg$FAILED;
|
1384 | }
|
1385 |
|
1386 | return s0;
|
1387 | }
|
1388 |
|
1389 | function peg$parseExpressionAttributeName() {
|
1390 | var s0, s1, s2, s3, s4;
|
1391 |
|
1392 | s0 = peg$currPos;
|
1393 | s1 = peg$currPos;
|
1394 | peg$silentFails++;
|
1395 | s2 = peg$parseReservedWord();
|
1396 | peg$silentFails--;
|
1397 | if (s2 === peg$FAILED) {
|
1398 | s1 = void 0;
|
1399 | } else {
|
1400 | peg$currPos = s1;
|
1401 | s1 = peg$FAILED;
|
1402 | }
|
1403 | if (s1 !== peg$FAILED) {
|
1404 | if (input.charCodeAt(peg$currPos) === 35) {
|
1405 | s2 = peg$c35;
|
1406 | peg$currPos++;
|
1407 | } else {
|
1408 | s2 = peg$FAILED;
|
1409 | if (peg$silentFails === 0) { peg$fail(peg$c36); }
|
1410 | }
|
1411 | if (s2 !== peg$FAILED) {
|
1412 | s3 = [];
|
1413 | s4 = peg$parseIdentifierPart();
|
1414 | while (s4 !== peg$FAILED) {
|
1415 | s3.push(s4);
|
1416 | s4 = peg$parseIdentifierPart();
|
1417 | }
|
1418 | if (s3 !== peg$FAILED) {
|
1419 | peg$savedPos = s0;
|
1420 | s1 = peg$c37(s2, s3);
|
1421 | s0 = s1;
|
1422 | } else {
|
1423 | peg$currPos = s0;
|
1424 | s0 = peg$FAILED;
|
1425 | }
|
1426 | } else {
|
1427 | peg$currPos = s0;
|
1428 | s0 = peg$FAILED;
|
1429 | }
|
1430 | } else {
|
1431 | peg$currPos = s0;
|
1432 | s0 = peg$FAILED;
|
1433 | }
|
1434 |
|
1435 | return s0;
|
1436 | }
|
1437 |
|
1438 | function peg$parseExpressionAttributeValue() {
|
1439 | var s0, s1, s2, s3, s4;
|
1440 |
|
1441 | s0 = peg$currPos;
|
1442 | s1 = peg$currPos;
|
1443 | peg$silentFails++;
|
1444 | s2 = peg$parseReservedWord();
|
1445 | peg$silentFails--;
|
1446 | if (s2 === peg$FAILED) {
|
1447 | s1 = void 0;
|
1448 | } else {
|
1449 | peg$currPos = s1;
|
1450 | s1 = peg$FAILED;
|
1451 | }
|
1452 | if (s1 !== peg$FAILED) {
|
1453 | if (input.charCodeAt(peg$currPos) === 58) {
|
1454 | s2 = peg$c38;
|
1455 | peg$currPos++;
|
1456 | } else {
|
1457 | s2 = peg$FAILED;
|
1458 | if (peg$silentFails === 0) { peg$fail(peg$c39); }
|
1459 | }
|
1460 | if (s2 !== peg$FAILED) {
|
1461 | s3 = [];
|
1462 | s4 = peg$parseIdentifierPart();
|
1463 | while (s4 !== peg$FAILED) {
|
1464 | s3.push(s4);
|
1465 | s4 = peg$parseIdentifierPart();
|
1466 | }
|
1467 | if (s3 !== peg$FAILED) {
|
1468 | peg$savedPos = s0;
|
1469 | s1 = peg$c40(s2, s3);
|
1470 | s0 = s1;
|
1471 | } else {
|
1472 | peg$currPos = s0;
|
1473 | s0 = peg$FAILED;
|
1474 | }
|
1475 | } else {
|
1476 | peg$currPos = s0;
|
1477 | s0 = peg$FAILED;
|
1478 | }
|
1479 | } else {
|
1480 | peg$currPos = s0;
|
1481 | s0 = peg$FAILED;
|
1482 | }
|
1483 |
|
1484 | return s0;
|
1485 | }
|
1486 |
|
1487 | function peg$parsePathExpression() {
|
1488 | var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9;
|
1489 |
|
1490 | s0 = peg$currPos;
|
1491 | s1 = peg$parseGroupedPathExpression();
|
1492 | if (s1 !== peg$FAILED) {
|
1493 | s2 = [];
|
1494 | s3 = peg$currPos;
|
1495 | s4 = peg$parse_();
|
1496 | if (s4 !== peg$FAILED) {
|
1497 | if (input.charCodeAt(peg$currPos) === 91) {
|
1498 | s5 = peg$c41;
|
1499 | peg$currPos++;
|
1500 | } else {
|
1501 | s5 = peg$FAILED;
|
1502 | if (peg$silentFails === 0) { peg$fail(peg$c42); }
|
1503 | }
|
1504 | if (s5 !== peg$FAILED) {
|
1505 | s6 = peg$parse_();
|
1506 | if (s6 !== peg$FAILED) {
|
1507 | s7 = [];
|
1508 | if (peg$c43.test(input.charAt(peg$currPos))) {
|
1509 | s8 = input.charAt(peg$currPos);
|
1510 | peg$currPos++;
|
1511 | } else {
|
1512 | s8 = peg$FAILED;
|
1513 | if (peg$silentFails === 0) { peg$fail(peg$c44); }
|
1514 | }
|
1515 | if (s8 !== peg$FAILED) {
|
1516 | while (s8 !== peg$FAILED) {
|
1517 | s7.push(s8);
|
1518 | if (peg$c43.test(input.charAt(peg$currPos))) {
|
1519 | s8 = input.charAt(peg$currPos);
|
1520 | peg$currPos++;
|
1521 | } else {
|
1522 | s8 = peg$FAILED;
|
1523 | if (peg$silentFails === 0) { peg$fail(peg$c44); }
|
1524 | }
|
1525 | }
|
1526 | } else {
|
1527 | s7 = peg$FAILED;
|
1528 | }
|
1529 | if (s7 !== peg$FAILED) {
|
1530 | s8 = peg$parse_();
|
1531 | if (s8 !== peg$FAILED) {
|
1532 | if (input.charCodeAt(peg$currPos) === 93) {
|
1533 | s9 = peg$c45;
|
1534 | peg$currPos++;
|
1535 | } else {
|
1536 | s9 = peg$FAILED;
|
1537 | if (peg$silentFails === 0) { peg$fail(peg$c46); }
|
1538 | }
|
1539 | if (s9 !== peg$FAILED) {
|
1540 | peg$savedPos = s3;
|
1541 | s4 = peg$c47(s1, s7);
|
1542 | s3 = s4;
|
1543 | } else {
|
1544 | peg$currPos = s3;
|
1545 | s3 = peg$FAILED;
|
1546 | }
|
1547 | } else {
|
1548 | peg$currPos = s3;
|
1549 | s3 = peg$FAILED;
|
1550 | }
|
1551 | } else {
|
1552 | peg$currPos = s3;
|
1553 | s3 = peg$FAILED;
|
1554 | }
|
1555 | } else {
|
1556 | peg$currPos = s3;
|
1557 | s3 = peg$FAILED;
|
1558 | }
|
1559 | } else {
|
1560 | peg$currPos = s3;
|
1561 | s3 = peg$FAILED;
|
1562 | }
|
1563 | } else {
|
1564 | peg$currPos = s3;
|
1565 | s3 = peg$FAILED;
|
1566 | }
|
1567 | if (s3 === peg$FAILED) {
|
1568 | s3 = peg$currPos;
|
1569 | s4 = peg$parse_();
|
1570 | if (s4 !== peg$FAILED) {
|
1571 | if (input.charCodeAt(peg$currPos) === 46) {
|
1572 | s5 = peg$c48;
|
1573 | peg$currPos++;
|
1574 | } else {
|
1575 | s5 = peg$FAILED;
|
1576 | if (peg$silentFails === 0) { peg$fail(peg$c49); }
|
1577 | }
|
1578 | if (s5 !== peg$FAILED) {
|
1579 | s6 = peg$parse_();
|
1580 | if (s6 !== peg$FAILED) {
|
1581 | s7 = peg$parseIdentifier();
|
1582 | if (s7 !== peg$FAILED) {
|
1583 | peg$savedPos = s3;
|
1584 | s4 = peg$c50(s1, s7);
|
1585 | s3 = s4;
|
1586 | } else {
|
1587 | peg$currPos = s3;
|
1588 | s3 = peg$FAILED;
|
1589 | }
|
1590 | } else {
|
1591 | peg$currPos = s3;
|
1592 | s3 = peg$FAILED;
|
1593 | }
|
1594 | } else {
|
1595 | peg$currPos = s3;
|
1596 | s3 = peg$FAILED;
|
1597 | }
|
1598 | } else {
|
1599 | peg$currPos = s3;
|
1600 | s3 = peg$FAILED;
|
1601 | }
|
1602 | }
|
1603 | while (s3 !== peg$FAILED) {
|
1604 | s2.push(s3);
|
1605 | s3 = peg$currPos;
|
1606 | s4 = peg$parse_();
|
1607 | if (s4 !== peg$FAILED) {
|
1608 | if (input.charCodeAt(peg$currPos) === 91) {
|
1609 | s5 = peg$c41;
|
1610 | peg$currPos++;
|
1611 | } else {
|
1612 | s5 = peg$FAILED;
|
1613 | if (peg$silentFails === 0) { peg$fail(peg$c42); }
|
1614 | }
|
1615 | if (s5 !== peg$FAILED) {
|
1616 | s6 = peg$parse_();
|
1617 | if (s6 !== peg$FAILED) {
|
1618 | s7 = [];
|
1619 | if (peg$c43.test(input.charAt(peg$currPos))) {
|
1620 | s8 = input.charAt(peg$currPos);
|
1621 | peg$currPos++;
|
1622 | } else {
|
1623 | s8 = peg$FAILED;
|
1624 | if (peg$silentFails === 0) { peg$fail(peg$c44); }
|
1625 | }
|
1626 | if (s8 !== peg$FAILED) {
|
1627 | while (s8 !== peg$FAILED) {
|
1628 | s7.push(s8);
|
1629 | if (peg$c43.test(input.charAt(peg$currPos))) {
|
1630 | s8 = input.charAt(peg$currPos);
|
1631 | peg$currPos++;
|
1632 | } else {
|
1633 | s8 = peg$FAILED;
|
1634 | if (peg$silentFails === 0) { peg$fail(peg$c44); }
|
1635 | }
|
1636 | }
|
1637 | } else {
|
1638 | s7 = peg$FAILED;
|
1639 | }
|
1640 | if (s7 !== peg$FAILED) {
|
1641 | s8 = peg$parse_();
|
1642 | if (s8 !== peg$FAILED) {
|
1643 | if (input.charCodeAt(peg$currPos) === 93) {
|
1644 | s9 = peg$c45;
|
1645 | peg$currPos++;
|
1646 | } else {
|
1647 | s9 = peg$FAILED;
|
1648 | if (peg$silentFails === 0) { peg$fail(peg$c46); }
|
1649 | }
|
1650 | if (s9 !== peg$FAILED) {
|
1651 | peg$savedPos = s3;
|
1652 | s4 = peg$c47(s1, s7);
|
1653 | s3 = s4;
|
1654 | } else {
|
1655 | peg$currPos = s3;
|
1656 | s3 = peg$FAILED;
|
1657 | }
|
1658 | } else {
|
1659 | peg$currPos = s3;
|
1660 | s3 = peg$FAILED;
|
1661 | }
|
1662 | } else {
|
1663 | peg$currPos = s3;
|
1664 | s3 = peg$FAILED;
|
1665 | }
|
1666 | } else {
|
1667 | peg$currPos = s3;
|
1668 | s3 = peg$FAILED;
|
1669 | }
|
1670 | } else {
|
1671 | peg$currPos = s3;
|
1672 | s3 = peg$FAILED;
|
1673 | }
|
1674 | } else {
|
1675 | peg$currPos = s3;
|
1676 | s3 = peg$FAILED;
|
1677 | }
|
1678 | if (s3 === peg$FAILED) {
|
1679 | s3 = peg$currPos;
|
1680 | s4 = peg$parse_();
|
1681 | if (s4 !== peg$FAILED) {
|
1682 | if (input.charCodeAt(peg$currPos) === 46) {
|
1683 | s5 = peg$c48;
|
1684 | peg$currPos++;
|
1685 | } else {
|
1686 | s5 = peg$FAILED;
|
1687 | if (peg$silentFails === 0) { peg$fail(peg$c49); }
|
1688 | }
|
1689 | if (s5 !== peg$FAILED) {
|
1690 | s6 = peg$parse_();
|
1691 | if (s6 !== peg$FAILED) {
|
1692 | s7 = peg$parseIdentifier();
|
1693 | if (s7 !== peg$FAILED) {
|
1694 | peg$savedPos = s3;
|
1695 | s4 = peg$c50(s1, s7);
|
1696 | s3 = s4;
|
1697 | } else {
|
1698 | peg$currPos = s3;
|
1699 | s3 = peg$FAILED;
|
1700 | }
|
1701 | } else {
|
1702 | peg$currPos = s3;
|
1703 | s3 = peg$FAILED;
|
1704 | }
|
1705 | } else {
|
1706 | peg$currPos = s3;
|
1707 | s3 = peg$FAILED;
|
1708 | }
|
1709 | } else {
|
1710 | peg$currPos = s3;
|
1711 | s3 = peg$FAILED;
|
1712 | }
|
1713 | }
|
1714 | }
|
1715 | if (s2 !== peg$FAILED) {
|
1716 | peg$savedPos = s0;
|
1717 | s1 = peg$c51(s1, s2);
|
1718 | s0 = s1;
|
1719 | } else {
|
1720 | peg$currPos = s0;
|
1721 | s0 = peg$FAILED;
|
1722 | }
|
1723 | } else {
|
1724 | peg$currPos = s0;
|
1725 | s0 = peg$FAILED;
|
1726 | }
|
1727 |
|
1728 | return s0;
|
1729 | }
|
1730 |
|
1731 | function peg$parseGroupedPathExpression() {
|
1732 | var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9;
|
1733 |
|
1734 | s0 = peg$parseIdentifier();
|
1735 | if (s0 === peg$FAILED) {
|
1736 | s0 = peg$currPos;
|
1737 | if (input.charCodeAt(peg$currPos) === 40) {
|
1738 | s1 = peg$c4;
|
1739 | peg$currPos++;
|
1740 | } else {
|
1741 | s1 = peg$FAILED;
|
1742 | if (peg$silentFails === 0) { peg$fail(peg$c5); }
|
1743 | }
|
1744 | if (s1 !== peg$FAILED) {
|
1745 | s2 = peg$parse_();
|
1746 | if (s2 !== peg$FAILED) {
|
1747 | if (input.charCodeAt(peg$currPos) === 40) {
|
1748 | s3 = peg$c4;
|
1749 | peg$currPos++;
|
1750 | } else {
|
1751 | s3 = peg$FAILED;
|
1752 | if (peg$silentFails === 0) { peg$fail(peg$c5); }
|
1753 | }
|
1754 | if (s3 !== peg$FAILED) {
|
1755 | s4 = peg$parse_();
|
1756 | if (s4 !== peg$FAILED) {
|
1757 | s5 = peg$parsePathExpression();
|
1758 | if (s5 !== peg$FAILED) {
|
1759 | s6 = peg$parse_();
|
1760 | if (s6 !== peg$FAILED) {
|
1761 | if (input.charCodeAt(peg$currPos) === 41) {
|
1762 | s7 = peg$c6;
|
1763 | peg$currPos++;
|
1764 | } else {
|
1765 | s7 = peg$FAILED;
|
1766 | if (peg$silentFails === 0) { peg$fail(peg$c7); }
|
1767 | }
|
1768 | if (s7 !== peg$FAILED) {
|
1769 | s8 = peg$parse_();
|
1770 | if (s8 !== peg$FAILED) {
|
1771 | if (input.charCodeAt(peg$currPos) === 41) {
|
1772 | s9 = peg$c6;
|
1773 | peg$currPos++;
|
1774 | } else {
|
1775 | s9 = peg$FAILED;
|
1776 | if (peg$silentFails === 0) { peg$fail(peg$c7); }
|
1777 | }
|
1778 | if (s9 !== peg$FAILED) {
|
1779 | peg$savedPos = s0;
|
1780 | s1 = peg$c52(s5);
|
1781 | s0 = s1;
|
1782 | } else {
|
1783 | peg$currPos = s0;
|
1784 | s0 = peg$FAILED;
|
1785 | }
|
1786 | } else {
|
1787 | peg$currPos = s0;
|
1788 | s0 = peg$FAILED;
|
1789 | }
|
1790 | } else {
|
1791 | peg$currPos = s0;
|
1792 | s0 = peg$FAILED;
|
1793 | }
|
1794 | } else {
|
1795 | peg$currPos = s0;
|
1796 | s0 = peg$FAILED;
|
1797 | }
|
1798 | } else {
|
1799 | peg$currPos = s0;
|
1800 | s0 = peg$FAILED;
|
1801 | }
|
1802 | } else {
|
1803 | peg$currPos = s0;
|
1804 | s0 = peg$FAILED;
|
1805 | }
|
1806 | } else {
|
1807 | peg$currPos = s0;
|
1808 | s0 = peg$FAILED;
|
1809 | }
|
1810 | } else {
|
1811 | peg$currPos = s0;
|
1812 | s0 = peg$FAILED;
|
1813 | }
|
1814 | } else {
|
1815 | peg$currPos = s0;
|
1816 | s0 = peg$FAILED;
|
1817 | }
|
1818 | if (s0 === peg$FAILED) {
|
1819 | s0 = peg$currPos;
|
1820 | if (input.charCodeAt(peg$currPos) === 40) {
|
1821 | s1 = peg$c4;
|
1822 | peg$currPos++;
|
1823 | } else {
|
1824 | s1 = peg$FAILED;
|
1825 | if (peg$silentFails === 0) { peg$fail(peg$c5); }
|
1826 | }
|
1827 | if (s1 !== peg$FAILED) {
|
1828 | s2 = peg$parse_();
|
1829 | if (s2 !== peg$FAILED) {
|
1830 | s3 = peg$parsePathExpression();
|
1831 | if (s3 !== peg$FAILED) {
|
1832 | s4 = peg$parse_();
|
1833 | if (s4 !== peg$FAILED) {
|
1834 | if (input.charCodeAt(peg$currPos) === 41) {
|
1835 | s5 = peg$c6;
|
1836 | peg$currPos++;
|
1837 | } else {
|
1838 | s5 = peg$FAILED;
|
1839 | if (peg$silentFails === 0) { peg$fail(peg$c7); }
|
1840 | }
|
1841 | if (s5 !== peg$FAILED) {
|
1842 | peg$savedPos = s0;
|
1843 | s1 = peg$c53(s3);
|
1844 | s0 = s1;
|
1845 | } else {
|
1846 | peg$currPos = s0;
|
1847 | s0 = peg$FAILED;
|
1848 | }
|
1849 | } else {
|
1850 | peg$currPos = s0;
|
1851 | s0 = peg$FAILED;
|
1852 | }
|
1853 | } else {
|
1854 | peg$currPos = s0;
|
1855 | s0 = peg$FAILED;
|
1856 | }
|
1857 | } else {
|
1858 | peg$currPos = s0;
|
1859 | s0 = peg$FAILED;
|
1860 | }
|
1861 | } else {
|
1862 | peg$currPos = s0;
|
1863 | s0 = peg$FAILED;
|
1864 | }
|
1865 | }
|
1866 | }
|
1867 |
|
1868 | return s0;
|
1869 | }
|
1870 |
|
1871 | function peg$parseIdentifier() {
|
1872 | var s0, s1, s2, s3, s4;
|
1873 |
|
1874 | s0 = peg$currPos;
|
1875 | s1 = peg$currPos;
|
1876 | peg$silentFails++;
|
1877 | s2 = peg$parseReservedWord();
|
1878 | peg$silentFails--;
|
1879 | if (s2 === peg$FAILED) {
|
1880 | s1 = void 0;
|
1881 | } else {
|
1882 | peg$currPos = s1;
|
1883 | s1 = peg$FAILED;
|
1884 | }
|
1885 | if (s1 !== peg$FAILED) {
|
1886 | s2 = peg$parseIdentifierStart();
|
1887 | if (s2 !== peg$FAILED) {
|
1888 | s3 = [];
|
1889 | s4 = peg$parseIdentifierPart();
|
1890 | while (s4 !== peg$FAILED) {
|
1891 | s3.push(s4);
|
1892 | s4 = peg$parseIdentifierPart();
|
1893 | }
|
1894 | if (s3 !== peg$FAILED) {
|
1895 | peg$savedPos = s0;
|
1896 | s1 = peg$c54(s2, s3);
|
1897 | s0 = s1;
|
1898 | } else {
|
1899 | peg$currPos = s0;
|
1900 | s0 = peg$FAILED;
|
1901 | }
|
1902 | } else {
|
1903 | peg$currPos = s0;
|
1904 | s0 = peg$FAILED;
|
1905 | }
|
1906 | } else {
|
1907 | peg$currPos = s0;
|
1908 | s0 = peg$FAILED;
|
1909 | }
|
1910 | if (s0 === peg$FAILED) {
|
1911 | s0 = peg$parseExpressionAttributeName();
|
1912 | }
|
1913 |
|
1914 | return s0;
|
1915 | }
|
1916 |
|
1917 | function peg$parseIdentifierStart() {
|
1918 | var s0;
|
1919 |
|
1920 | if (peg$c55.test(input.charAt(peg$currPos))) {
|
1921 | s0 = input.charAt(peg$currPos);
|
1922 | peg$currPos++;
|
1923 | } else {
|
1924 | s0 = peg$FAILED;
|
1925 | if (peg$silentFails === 0) { peg$fail(peg$c56); }
|
1926 | }
|
1927 | if (s0 === peg$FAILED) {
|
1928 | if (input.charCodeAt(peg$currPos) === 95) {
|
1929 | s0 = peg$c57;
|
1930 | peg$currPos++;
|
1931 | } else {
|
1932 | s0 = peg$FAILED;
|
1933 | if (peg$silentFails === 0) { peg$fail(peg$c58); }
|
1934 | }
|
1935 | }
|
1936 |
|
1937 | return s0;
|
1938 | }
|
1939 |
|
1940 | function peg$parseIdentifierPart() {
|
1941 | var s0;
|
1942 |
|
1943 | s0 = peg$parseIdentifierStart();
|
1944 | if (s0 === peg$FAILED) {
|
1945 | if (peg$c43.test(input.charAt(peg$currPos))) {
|
1946 | s0 = input.charAt(peg$currPos);
|
1947 | peg$currPos++;
|
1948 | } else {
|
1949 | s0 = peg$FAILED;
|
1950 | if (peg$silentFails === 0) { peg$fail(peg$c44); }
|
1951 | }
|
1952 | }
|
1953 |
|
1954 | return s0;
|
1955 | }
|
1956 |
|
1957 | function peg$parseAttributePart() {
|
1958 | var s0;
|
1959 |
|
1960 | s0 = peg$parseIdentifierPart();
|
1961 | if (s0 === peg$FAILED) {
|
1962 | if (input.charCodeAt(peg$currPos) === 35) {
|
1963 | s0 = peg$c35;
|
1964 | peg$currPos++;
|
1965 | } else {
|
1966 | s0 = peg$FAILED;
|
1967 | if (peg$silentFails === 0) { peg$fail(peg$c36); }
|
1968 | }
|
1969 | if (s0 === peg$FAILED) {
|
1970 | if (input.charCodeAt(peg$currPos) === 58) {
|
1971 | s0 = peg$c38;
|
1972 | peg$currPos++;
|
1973 | } else {
|
1974 | s0 = peg$FAILED;
|
1975 | if (peg$silentFails === 0) { peg$fail(peg$c39); }
|
1976 | }
|
1977 | }
|
1978 | }
|
1979 |
|
1980 | return s0;
|
1981 | }
|
1982 |
|
1983 | function peg$parseReservedWord() {
|
1984 | var s0;
|
1985 |
|
1986 | s0 = peg$parseBetweenToken();
|
1987 | if (s0 === peg$FAILED) {
|
1988 | s0 = peg$parseInToken();
|
1989 | if (s0 === peg$FAILED) {
|
1990 | s0 = peg$parseAndToken();
|
1991 | if (s0 === peg$FAILED) {
|
1992 | s0 = peg$parseOrToken();
|
1993 | if (s0 === peg$FAILED) {
|
1994 | s0 = peg$parseNotToken();
|
1995 | }
|
1996 | }
|
1997 | }
|
1998 | }
|
1999 |
|
2000 | return s0;
|
2001 | }
|
2002 |
|
2003 | function peg$parseBetweenToken() {
|
2004 | var s0, s1, s2, s3;
|
2005 |
|
2006 | s0 = peg$currPos;
|
2007 | if (input.substr(peg$currPos, 7).toLowerCase() === peg$c59) {
|
2008 | s1 = input.substr(peg$currPos, 7);
|
2009 | peg$currPos += 7;
|
2010 | } else {
|
2011 | s1 = peg$FAILED;
|
2012 | if (peg$silentFails === 0) { peg$fail(peg$c60); }
|
2013 | }
|
2014 | if (s1 !== peg$FAILED) {
|
2015 | s2 = peg$currPos;
|
2016 | peg$silentFails++;
|
2017 | s3 = peg$parseAttributePart();
|
2018 | peg$silentFails--;
|
2019 | if (s3 === peg$FAILED) {
|
2020 | s2 = void 0;
|
2021 | } else {
|
2022 | peg$currPos = s2;
|
2023 | s2 = peg$FAILED;
|
2024 | }
|
2025 | if (s2 !== peg$FAILED) {
|
2026 | s1 = [s1, s2];
|
2027 | s0 = s1;
|
2028 | } else {
|
2029 | peg$currPos = s0;
|
2030 | s0 = peg$FAILED;
|
2031 | }
|
2032 | } else {
|
2033 | peg$currPos = s0;
|
2034 | s0 = peg$FAILED;
|
2035 | }
|
2036 |
|
2037 | return s0;
|
2038 | }
|
2039 |
|
2040 | function peg$parseInToken() {
|
2041 | var s0, s1, s2, s3;
|
2042 |
|
2043 | s0 = peg$currPos;
|
2044 | if (input.substr(peg$currPos, 2).toLowerCase() === peg$c61) {
|
2045 | s1 = input.substr(peg$currPos, 2);
|
2046 | peg$currPos += 2;
|
2047 | } else {
|
2048 | s1 = peg$FAILED;
|
2049 | if (peg$silentFails === 0) { peg$fail(peg$c62); }
|
2050 | }
|
2051 | if (s1 !== peg$FAILED) {
|
2052 | s2 = peg$currPos;
|
2053 | peg$silentFails++;
|
2054 | s3 = peg$parseAttributePart();
|
2055 | peg$silentFails--;
|
2056 | if (s3 === peg$FAILED) {
|
2057 | s2 = void 0;
|
2058 | } else {
|
2059 | peg$currPos = s2;
|
2060 | s2 = peg$FAILED;
|
2061 | }
|
2062 | if (s2 !== peg$FAILED) {
|
2063 | s1 = [s1, s2];
|
2064 | s0 = s1;
|
2065 | } else {
|
2066 | peg$currPos = s0;
|
2067 | s0 = peg$FAILED;
|
2068 | }
|
2069 | } else {
|
2070 | peg$currPos = s0;
|
2071 | s0 = peg$FAILED;
|
2072 | }
|
2073 |
|
2074 | return s0;
|
2075 | }
|
2076 |
|
2077 | function peg$parseAndToken() {
|
2078 | var s0, s1, s2, s3;
|
2079 |
|
2080 | s0 = peg$currPos;
|
2081 | if (input.substr(peg$currPos, 3).toLowerCase() === peg$c63) {
|
2082 | s1 = input.substr(peg$currPos, 3);
|
2083 | peg$currPos += 3;
|
2084 | } else {
|
2085 | s1 = peg$FAILED;
|
2086 | if (peg$silentFails === 0) { peg$fail(peg$c64); }
|
2087 | }
|
2088 | if (s1 !== peg$FAILED) {
|
2089 | s2 = peg$currPos;
|
2090 | peg$silentFails++;
|
2091 | s3 = peg$parseAttributePart();
|
2092 | peg$silentFails--;
|
2093 | if (s3 === peg$FAILED) {
|
2094 | s2 = void 0;
|
2095 | } else {
|
2096 | peg$currPos = s2;
|
2097 | s2 = peg$FAILED;
|
2098 | }
|
2099 | if (s2 !== peg$FAILED) {
|
2100 | s1 = [s1, s2];
|
2101 | s0 = s1;
|
2102 | } else {
|
2103 | peg$currPos = s0;
|
2104 | s0 = peg$FAILED;
|
2105 | }
|
2106 | } else {
|
2107 | peg$currPos = s0;
|
2108 | s0 = peg$FAILED;
|
2109 | }
|
2110 |
|
2111 | return s0;
|
2112 | }
|
2113 |
|
2114 | function peg$parseOrToken() {
|
2115 | var s0, s1, s2, s3;
|
2116 |
|
2117 | s0 = peg$currPos;
|
2118 | if (input.substr(peg$currPos, 2).toLowerCase() === peg$c65) {
|
2119 | s1 = input.substr(peg$currPos, 2);
|
2120 | peg$currPos += 2;
|
2121 | } else {
|
2122 | s1 = peg$FAILED;
|
2123 | if (peg$silentFails === 0) { peg$fail(peg$c66); }
|
2124 | }
|
2125 | if (s1 !== peg$FAILED) {
|
2126 | s2 = peg$currPos;
|
2127 | peg$silentFails++;
|
2128 | s3 = peg$parseAttributePart();
|
2129 | peg$silentFails--;
|
2130 | if (s3 === peg$FAILED) {
|
2131 | s2 = void 0;
|
2132 | } else {
|
2133 | peg$currPos = s2;
|
2134 | s2 = peg$FAILED;
|
2135 | }
|
2136 | if (s2 !== peg$FAILED) {
|
2137 | s1 = [s1, s2];
|
2138 | s0 = s1;
|
2139 | } else {
|
2140 | peg$currPos = s0;
|
2141 | s0 = peg$FAILED;
|
2142 | }
|
2143 | } else {
|
2144 | peg$currPos = s0;
|
2145 | s0 = peg$FAILED;
|
2146 | }
|
2147 |
|
2148 | return s0;
|
2149 | }
|
2150 |
|
2151 | function peg$parseNotToken() {
|
2152 | var s0, s1, s2, s3;
|
2153 |
|
2154 | s0 = peg$currPos;
|
2155 | if (input.substr(peg$currPos, 3).toLowerCase() === peg$c67) {
|
2156 | s1 = input.substr(peg$currPos, 3);
|
2157 | peg$currPos += 3;
|
2158 | } else {
|
2159 | s1 = peg$FAILED;
|
2160 | if (peg$silentFails === 0) { peg$fail(peg$c68); }
|
2161 | }
|
2162 | if (s1 !== peg$FAILED) {
|
2163 | s2 = peg$currPos;
|
2164 | peg$silentFails++;
|
2165 | s3 = peg$parseAttributePart();
|
2166 | peg$silentFails--;
|
2167 | if (s3 === peg$FAILED) {
|
2168 | s2 = void 0;
|
2169 | } else {
|
2170 | peg$currPos = s2;
|
2171 | s2 = peg$FAILED;
|
2172 | }
|
2173 | if (s2 !== peg$FAILED) {
|
2174 | s1 = [s1, s2];
|
2175 | s0 = s1;
|
2176 | } else {
|
2177 | peg$currPos = s0;
|
2178 | s0 = peg$FAILED;
|
2179 | }
|
2180 | } else {
|
2181 | peg$currPos = s0;
|
2182 | s0 = peg$FAILED;
|
2183 | }
|
2184 |
|
2185 | return s0;
|
2186 | }
|
2187 |
|
2188 | function peg$parse_() {
|
2189 | var s0, s1;
|
2190 |
|
2191 | peg$silentFails++;
|
2192 | s0 = [];
|
2193 | if (peg$c70.test(input.charAt(peg$currPos))) {
|
2194 | s1 = input.charAt(peg$currPos);
|
2195 | peg$currPos++;
|
2196 | } else {
|
2197 | s1 = peg$FAILED;
|
2198 | if (peg$silentFails === 0) { peg$fail(peg$c71); }
|
2199 | }
|
2200 | while (s1 !== peg$FAILED) {
|
2201 | s0.push(s1);
|
2202 | if (peg$c70.test(input.charAt(peg$currPos))) {
|
2203 | s1 = input.charAt(peg$currPos);
|
2204 | peg$currPos++;
|
2205 | } else {
|
2206 | s1 = peg$FAILED;
|
2207 | if (peg$silentFails === 0) { peg$fail(peg$c71); }
|
2208 | }
|
2209 | }
|
2210 | peg$silentFails--;
|
2211 | if (s0 === peg$FAILED) {
|
2212 | s1 = peg$FAILED;
|
2213 | if (peg$silentFails === 0) { peg$fail(peg$c69); }
|
2214 | }
|
2215 |
|
2216 | return s0;
|
2217 | }
|
2218 |
|
2219 |
|
2220 |
|
2221 |
|
2222 | var context = options.context
|
2223 | var attrNames = context.attrNames || {}
|
2224 | var attrVals = context.attrVals || {}
|
2225 | var unusedAttrNames = context.unusedAttrNames || {}
|
2226 | var unusedAttrVals = context.unusedAttrVals || {}
|
2227 | var isReserved = context.isReserved
|
2228 | var errors = Object.create(null)
|
2229 | var nestedPaths = Object.create(null)
|
2230 | var pathHeads = Object.create(null)
|
2231 |
|
2232 | function checkReserved(name) {
|
2233 | if (isReserved(name) && !errors.reserved) {
|
2234 | errors.reserved = 'Attribute name is a reserved keyword; reserved keyword: ' + name
|
2235 | }
|
2236 | }
|
2237 |
|
2238 | function resolveAttrName(name) {
|
2239 | if (errors.attrNameVal) {
|
2240 | return
|
2241 | }
|
2242 | if (!attrNames[name]) {
|
2243 | errors.attrNameVal = 'An expression attribute name used in the document path is not defined; attribute name: ' + name
|
2244 | return
|
2245 | }
|
2246 | delete unusedAttrNames[name]
|
2247 | return attrNames[name]
|
2248 | }
|
2249 |
|
2250 | function resolveAttrVal(name) {
|
2251 | if (errors.attrNameVal) {
|
2252 | return
|
2253 | }
|
2254 | if (!attrVals[name]) {
|
2255 | errors.attrNameVal = 'An expression attribute value used in expression is not defined; attribute value: ' + name
|
2256 | return
|
2257 | }
|
2258 | delete unusedAttrVals[name]
|
2259 | return attrVals[name]
|
2260 | }
|
2261 |
|
2262 | function checkFunction(name, args) {
|
2263 | if (errors.unknownFunction) {
|
2264 | return
|
2265 | }
|
2266 | var functions = {
|
2267 | attribute_exists: 1,
|
2268 | attribute_not_exists: 1,
|
2269 | attribute_type: 2,
|
2270 | begins_with: 2,
|
2271 | contains: 2,
|
2272 | size: 1,
|
2273 | }
|
2274 | var numOperands = functions[name]
|
2275 | if (numOperands == null) {
|
2276 | errors.unknownFunction = 'Invalid function name; function: ' + name
|
2277 | return
|
2278 | }
|
2279 |
|
2280 | if (errors.operand) {
|
2281 | return
|
2282 | }
|
2283 | if (numOperands != args.length) {
|
2284 | errors.operand = 'Incorrect number of operands for operator or function; ' +
|
2285 | 'operator or function: ' + name + ', number of operands: ' + args.length
|
2286 | return
|
2287 | }
|
2288 |
|
2289 | checkDistinct(name, args)
|
2290 |
|
2291 | if (errors.function) {
|
2292 | return
|
2293 | }
|
2294 | switch (name) {
|
2295 | case 'attribute_exists':
|
2296 | case 'attribute_not_exists':
|
2297 | if (!Array.isArray(args[0])) {
|
2298 | errors.function = 'Operator or function requires a document path; ' +
|
2299 | 'operator or function: ' + name
|
2300 | return
|
2301 | }
|
2302 | return getType(args[1])
|
2303 | case 'begins_with':
|
2304 | for (var i = 0; i < args.length; i++) {
|
2305 | var type = getType(args[i])
|
2306 | if (type && type != 'S' && type != 'B') {
|
2307 | errors.function = 'Incorrect operand type for operator or function; ' +
|
2308 | 'operator or function: ' + name + ', operand type: ' + type
|
2309 | return
|
2310 | }
|
2311 | }
|
2312 | return 'BOOL'
|
2313 | case 'attribute_type':
|
2314 | var type = getType(args[1])
|
2315 | if (type != 'S') {
|
2316 | if (type == null) type = '{NS,SS,L,BS,N,M,B,BOOL,NULL,S}'
|
2317 | errors.function = 'Incorrect operand type for operator or function; ' +
|
2318 | 'operator or function: ' + name + ', operand type: ' + type
|
2319 | return
|
2320 | }
|
2321 | if (!~['S', 'N', 'B', 'NULL', 'SS', 'BOOL', 'L', 'BS', 'NS', 'M'].indexOf(args[1].S)) {
|
2322 | errors.function = 'Invalid attribute type name found; type: ' +
|
2323 | args[1].S + ', valid types: {B,NULL,SS,BOOL,L,BS,N,NS,S,M}'
|
2324 | return
|
2325 | }
|
2326 | return 'BOOL'
|
2327 | case 'size':
|
2328 | var type = getType(args[0])
|
2329 | if (~['N', 'BOOL', 'NULL'].indexOf(type)) {
|
2330 | errors.function = 'Incorrect operand type for operator or function; ' +
|
2331 | 'operator or function: ' + name + ', operand type: ' + type
|
2332 | return
|
2333 | }
|
2334 | return 'N'
|
2335 | case 'contains':
|
2336 | return 'BOOL'
|
2337 | }
|
2338 | }
|
2339 |
|
2340 | function redundantParensError() {
|
2341 | if (!errors.parens) {
|
2342 | errors.parens = 'The expression has redundant parentheses;'
|
2343 | }
|
2344 | }
|
2345 |
|
2346 | function checkMisusedFunction(args) {
|
2347 | if (errors.misusedFunction) {
|
2348 | return
|
2349 | }
|
2350 | for (var i = 0; i < args.length; i++) {
|
2351 | if (args[i] && args[i].type == 'function' && args[i].name != 'size') {
|
2352 | errors.misusedFunction = 'The function is not allowed to be used this way in an expression; function: ' +
|
2353 | args[i].name
|
2354 | return
|
2355 | }
|
2356 | }
|
2357 | }
|
2358 |
|
2359 | function checkMisusedSize(expr) {
|
2360 | if (expr.type == 'function' && expr.name == 'size' && !errors.misusedFunction) {
|
2361 | errors.misusedFunction = 'The function is not allowed to be used this way in an expression; function: ' + expr.name
|
2362 | }
|
2363 | }
|
2364 |
|
2365 | function checkDistinct(name, args) {
|
2366 | if (errors.distinct || args.length != 2 || !Array.isArray(args[0]) || !Array.isArray(args[1]) || args[0].length != args[1].length) {
|
2367 | return
|
2368 | }
|
2369 | for (var i = 0; i < args[0].length; i++) {
|
2370 | if (args[0][i] !== args[1][i]) {
|
2371 | return
|
2372 | }
|
2373 | }
|
2374 | errors.distinct = 'The first operand must be distinct from the remaining operands for this operator or function; operator: ' +
|
2375 | name + ', first operand: ' + pathStr(args[0])
|
2376 | }
|
2377 |
|
2378 | function checkBetweenArgs(x, y) {
|
2379 | if (errors.function) {
|
2380 | return
|
2381 | }
|
2382 | var type1 = getImmediateType(x)
|
2383 | var type2 = getImmediateType(y)
|
2384 | if (type1 && type2) {
|
2385 | if (type1 != type2) {
|
2386 | errors.function = 'The BETWEEN operator requires same data type for lower and upper bounds; ' +
|
2387 | 'lower bound operand: AttributeValue: {' + type1 + ':' + x[type1] + '}, ' +
|
2388 | 'upper bound operand: AttributeValue: {' + type2 + ':' + y[type2] + '}'
|
2389 | } else if (context.compare('GT', x, y)) {
|
2390 | errors.function = 'The BETWEEN operator requires upper bound to be greater than or equal to lower bound; ' +
|
2391 | 'lower bound operand: AttributeValue: {' + type1 + ':' + x[type1] + '}, ' +
|
2392 | 'upper bound operand: AttributeValue: {' + type2 + ':' + y[type2] + '}'
|
2393 | }
|
2394 | }
|
2395 | }
|
2396 |
|
2397 | function pathStr(path) {
|
2398 | return '[' + path.map(function(piece) {
|
2399 | return typeof piece == 'number' ? '[' + piece + ']' : piece
|
2400 | }).join(', ') + ']'
|
2401 | }
|
2402 |
|
2403 | function getType(val) {
|
2404 | if (!val || typeof val != 'object' || Array.isArray(val)) return null
|
2405 | if (val.attrType) return val.attrType
|
2406 | return getImmediateType(val)
|
2407 | }
|
2408 |
|
2409 | function getImmediateType(val) {
|
2410 | if (!val || typeof val != 'object' || Array.isArray(val) || val.attrType) return null
|
2411 | var types = ['S', 'N', 'B', 'NULL', 'BOOL', 'SS', 'NS', 'BS', 'L', 'M']
|
2412 | for (var i = 0; i < types.length; i++) {
|
2413 | if (val[types[i]] != null) return types[i]
|
2414 | }
|
2415 | return null
|
2416 | }
|
2417 |
|
2418 | function checkConditionErrors() {
|
2419 | if (errors.condition) {
|
2420 | return
|
2421 | }
|
2422 | var errorOrder = ['attrNameVal', 'operand', 'distinct', 'function']
|
2423 | for (var i = 0; i < errorOrder.length; i++) {
|
2424 | if (errors[errorOrder[i]]) {
|
2425 | errors.condition = errors[errorOrder[i]]
|
2426 | return
|
2427 | }
|
2428 | }
|
2429 | }
|
2430 |
|
2431 | function checkErrors() {
|
2432 | var errorOrder = ['parens', 'unknownFunction', 'misusedFunction', 'reserved', 'condition']
|
2433 | for (var i = 0; i < errorOrder.length; i++) {
|
2434 | if (errors[errorOrder[i]]) return errors[errorOrder[i]]
|
2435 | }
|
2436 | return null
|
2437 | }
|
2438 |
|
2439 |
|
2440 | peg$result = peg$startRuleFunction();
|
2441 |
|
2442 | if (peg$result !== peg$FAILED && peg$currPos === input.length) {
|
2443 | return peg$result;
|
2444 | } else {
|
2445 | if (peg$result !== peg$FAILED && peg$currPos < input.length) {
|
2446 | peg$fail(peg$endExpectation());
|
2447 | }
|
2448 |
|
2449 | throw peg$buildStructuredError(
|
2450 | peg$maxFailExpected,
|
2451 | peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,
|
2452 | peg$maxFailPos < input.length
|
2453 | ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)
|
2454 | : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)
|
2455 | );
|
2456 | }
|
2457 | }
|
2458 |
|
2459 | module.exports = {
|
2460 | SyntaxError: peg$SyntaxError,
|
2461 | parse: peg$parse
|
2462 | };
|