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 = { Project: peg$parseProject },
|
142 | peg$startRuleFunction = peg$parseProject,
|
143 |
|
144 | peg$c0 = function(headComment, obj) {
|
145 | var proj = Object.create(null)
|
146 | proj.project = obj
|
147 |
|
148 | if (headComment) {
|
149 | proj.headComment = headComment
|
150 | }
|
151 |
|
152 | return proj;
|
153 | },
|
154 | peg$c1 = "{",
|
155 | peg$c2 = peg$literalExpectation("{", false),
|
156 | peg$c3 = "}",
|
157 | peg$c4 = peg$literalExpectation("}", false),
|
158 | peg$c5 = function(obj) { return obj },
|
159 | peg$c6 = function() { return Object.create(null) },
|
160 | peg$c7 = function(list) {
|
161 | var returnObject = list[0][0];
|
162 | for(var i = 1; i < list.length; i++){
|
163 | var another = list[i][0];
|
164 | returnObject = merge_obj(returnObject, another);
|
165 | }
|
166 | return returnObject;
|
167 | },
|
168 | peg$c8 = "=",
|
169 | peg$c9 = peg$literalExpectation("=", false),
|
170 | peg$c10 = ";",
|
171 | peg$c11 = peg$literalExpectation(";", false),
|
172 | peg$c12 = function(id, val) {
|
173 | var result = Object.create(null);
|
174 | result[id] = val
|
175 | return result
|
176 | },
|
177 | peg$c13 = function(commentedId, val) {
|
178 | var result = Object.create(null),
|
179 | commentKey = commentedId.id + '_comment';
|
180 |
|
181 | result[commentedId.id] = val;
|
182 | result[commentKey] = commentedId[commentKey];
|
183 | return result;
|
184 |
|
185 | },
|
186 | peg$c14 = function(id, commentedVal) {
|
187 | var result = Object.create(null);
|
188 | result[id] = commentedVal.value;
|
189 | result[id + "_comment"] = commentedVal.comment;
|
190 | return result;
|
191 | },
|
192 | peg$c15 = function(id, comment) {
|
193 | var result = Object.create(null);
|
194 | result.id = id;
|
195 | result[id + "_comment"] = comment.trim();
|
196 | return result
|
197 | },
|
198 | peg$c16 = function(literal, comment) {
|
199 | var result = Object.create(null)
|
200 | result.comment = comment.trim();
|
201 | result.value = literal.trim();
|
202 | return result;
|
203 | },
|
204 | peg$c17 = /^[^*]/,
|
205 | peg$c18 = peg$classExpectation(["*"], true, false),
|
206 | peg$c19 = function(body) { return body.join('') },
|
207 | peg$c20 = "/*",
|
208 | peg$c21 = peg$literalExpectation("/*", false),
|
209 | peg$c22 = "*/",
|
210 | peg$c23 = peg$literalExpectation("*/", false),
|
211 | peg$c24 = function(begin, fields) {
|
212 | var section = Object.create(null);
|
213 | section[begin.name] = fields
|
214 |
|
215 | return section
|
216 | },
|
217 | peg$c25 = "/* Begin ",
|
218 | peg$c26 = peg$literalExpectation("/* Begin ", false),
|
219 | peg$c27 = " section */",
|
220 | peg$c28 = peg$literalExpectation(" section */", false),
|
221 | peg$c29 = function(sectionName) { return { name: sectionName } },
|
222 | peg$c30 = "/* End ",
|
223 | peg$c31 = peg$literalExpectation("/* End ", false),
|
224 | peg$c32 = "(",
|
225 | peg$c33 = peg$literalExpectation("(", false),
|
226 | peg$c34 = ")",
|
227 | peg$c35 = peg$literalExpectation(")", false),
|
228 | peg$c36 = function(arr) { return arr },
|
229 | peg$c37 = function() { return [] },
|
230 | peg$c38 = function(head, tail) {
|
231 | if (tail) {
|
232 | tail.unshift(head);
|
233 | return tail;
|
234 | } else {
|
235 | return [head];
|
236 | }
|
237 | },
|
238 | peg$c39 = function(val) { return val },
|
239 | peg$c40 = function(val, comment) {
|
240 | var result = Object.create(null);
|
241 | result.value = val.trim();
|
242 | result.comment = comment.trim();
|
243 | return result;
|
244 | },
|
245 | peg$c41 = ",",
|
246 | peg$c42 = peg$literalExpectation(",", false),
|
247 | peg$c43 = /^[A-Za-z0-9_.]/,
|
248 | peg$c44 = peg$classExpectation([["A", "Z"], ["a", "z"], ["0", "9"], "_", "."], false, false),
|
249 | peg$c45 = function(id) { return id.join('') },
|
250 | peg$c46 = ".",
|
251 | peg$c47 = peg$literalExpectation(".", false),
|
252 | peg$c48 = function(decimal) {
|
253 |
|
254 |
|
255 | return decimal.join('')
|
256 | },
|
257 | peg$c49 = function(number) { return parseInt(number.join(''), 10) },
|
258 | peg$c50 = function(str) { return '"' + str + '"' },
|
259 | peg$c51 = function(str) { return str.join('') },
|
260 | peg$c52 = peg$anyExpectation(),
|
261 | peg$c53 = function(char) { return char },
|
262 | peg$c54 = "\\",
|
263 | peg$c55 = peg$literalExpectation("\\", false),
|
264 | peg$c56 = function() { return '\\"' },
|
265 | peg$c57 = function(literal) { return literal.join('') },
|
266 | peg$c58 = /^[^;,\n]/,
|
267 | peg$c59 = peg$classExpectation([";", ",", "\n"], true, false),
|
268 | peg$c60 = "//",
|
269 | peg$c61 = peg$literalExpectation("//", false),
|
270 | peg$c62 = function(contents) { return contents },
|
271 | peg$c63 = function(contents) { return contents.join('') },
|
272 | peg$c64 = /^[0-9]/,
|
273 | peg$c65 = peg$classExpectation([["0", "9"]], false, false),
|
274 | peg$c66 = /^[A-Za-z]/,
|
275 | peg$c67 = peg$classExpectation([["A", "Z"], ["a", "z"]], false, false),
|
276 | peg$c68 = "\"",
|
277 | peg$c69 = peg$literalExpectation("\"", false),
|
278 | peg$c70 = peg$otherExpectation("whitespace"),
|
279 | peg$c71 = /^[\t ]/,
|
280 | peg$c72 = peg$classExpectation(["\t", " "], false, false),
|
281 | peg$c73 = /^[\n\r]/,
|
282 | peg$c74 = peg$classExpectation(["\n", "\r"], false, false),
|
283 |
|
284 | peg$currPos = 0,
|
285 | peg$savedPos = 0,
|
286 | peg$posDetailsCache = [{ line: 1, column: 1 }],
|
287 | peg$maxFailPos = 0,
|
288 | peg$maxFailExpected = [],
|
289 | peg$silentFails = 0,
|
290 |
|
291 | peg$result;
|
292 |
|
293 | if ("startRule" in options) {
|
294 | if (!(options.startRule in peg$startRuleFunctions)) {
|
295 | throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
|
296 | }
|
297 |
|
298 | peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
|
299 | }
|
300 |
|
301 | function text() {
|
302 | return input.substring(peg$savedPos, peg$currPos);
|
303 | }
|
304 |
|
305 | function location() {
|
306 | return peg$computeLocation(peg$savedPos, peg$currPos);
|
307 | }
|
308 |
|
309 | function expected(description, location) {
|
310 | location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos)
|
311 |
|
312 | throw peg$buildStructuredError(
|
313 | [peg$otherExpectation(description)],
|
314 | input.substring(peg$savedPos, peg$currPos),
|
315 | location
|
316 | );
|
317 | }
|
318 |
|
319 | function error(message, location) {
|
320 | location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos)
|
321 |
|
322 | throw peg$buildSimpleError(message, location);
|
323 | }
|
324 |
|
325 | function peg$literalExpectation(text, ignoreCase) {
|
326 | return { type: "literal", text: text, ignoreCase: ignoreCase };
|
327 | }
|
328 |
|
329 | function peg$classExpectation(parts, inverted, ignoreCase) {
|
330 | return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase };
|
331 | }
|
332 |
|
333 | function peg$anyExpectation() {
|
334 | return { type: "any" };
|
335 | }
|
336 |
|
337 | function peg$endExpectation() {
|
338 | return { type: "end" };
|
339 | }
|
340 |
|
341 | function peg$otherExpectation(description) {
|
342 | return { type: "other", description: description };
|
343 | }
|
344 |
|
345 | function peg$computePosDetails(pos) {
|
346 | var details = peg$posDetailsCache[pos], p;
|
347 |
|
348 | if (details) {
|
349 | return details;
|
350 | } else {
|
351 | p = pos - 1;
|
352 | while (!peg$posDetailsCache[p]) {
|
353 | p--;
|
354 | }
|
355 |
|
356 | details = peg$posDetailsCache[p];
|
357 | details = {
|
358 | line: details.line,
|
359 | column: details.column
|
360 | };
|
361 |
|
362 | while (p < pos) {
|
363 | if (input.charCodeAt(p) === 10) {
|
364 | details.line++;
|
365 | details.column = 1;
|
366 | } else {
|
367 | details.column++;
|
368 | }
|
369 |
|
370 | p++;
|
371 | }
|
372 |
|
373 | peg$posDetailsCache[pos] = details;
|
374 | return details;
|
375 | }
|
376 | }
|
377 |
|
378 | function peg$computeLocation(startPos, endPos) {
|
379 | var startPosDetails = peg$computePosDetails(startPos),
|
380 | endPosDetails = peg$computePosDetails(endPos);
|
381 |
|
382 | return {
|
383 | start: {
|
384 | offset: startPos,
|
385 | line: startPosDetails.line,
|
386 | column: startPosDetails.column
|
387 | },
|
388 | end: {
|
389 | offset: endPos,
|
390 | line: endPosDetails.line,
|
391 | column: endPosDetails.column
|
392 | }
|
393 | };
|
394 | }
|
395 |
|
396 | function peg$fail(expected) {
|
397 | if (peg$currPos < peg$maxFailPos) { return; }
|
398 |
|
399 | if (peg$currPos > peg$maxFailPos) {
|
400 | peg$maxFailPos = peg$currPos;
|
401 | peg$maxFailExpected = [];
|
402 | }
|
403 |
|
404 | peg$maxFailExpected.push(expected);
|
405 | }
|
406 |
|
407 | function peg$buildSimpleError(message, location) {
|
408 | return new peg$SyntaxError(message, null, null, location);
|
409 | }
|
410 |
|
411 | function peg$buildStructuredError(expected, found, location) {
|
412 | return new peg$SyntaxError(
|
413 | peg$SyntaxError.buildMessage(expected, found),
|
414 | expected,
|
415 | found,
|
416 | location
|
417 | );
|
418 | }
|
419 |
|
420 | function peg$parseProject() {
|
421 | var s0, s1, s2, s3, s4, s5, s6;
|
422 |
|
423 | s0 = peg$currPos;
|
424 | s1 = peg$parseSingleLineComment();
|
425 | if (s1 === peg$FAILED) {
|
426 | s1 = null;
|
427 | }
|
428 | if (s1 !== peg$FAILED) {
|
429 | s2 = peg$parseInlineComment();
|
430 | if (s2 === peg$FAILED) {
|
431 | s2 = null;
|
432 | }
|
433 | if (s2 !== peg$FAILED) {
|
434 | s3 = peg$parse_();
|
435 | if (s3 !== peg$FAILED) {
|
436 | s4 = peg$parseObject();
|
437 | if (s4 !== peg$FAILED) {
|
438 | s5 = peg$parseNewLine();
|
439 | if (s5 !== peg$FAILED) {
|
440 | s6 = peg$parse_();
|
441 | if (s6 !== peg$FAILED) {
|
442 | peg$savedPos = s0;
|
443 | s1 = peg$c0(s1, s4);
|
444 | s0 = s1;
|
445 | } else {
|
446 | peg$currPos = s0;
|
447 | s0 = peg$FAILED;
|
448 | }
|
449 | } else {
|
450 | peg$currPos = s0;
|
451 | s0 = peg$FAILED;
|
452 | }
|
453 | } else {
|
454 | peg$currPos = s0;
|
455 | s0 = peg$FAILED;
|
456 | }
|
457 | } else {
|
458 | peg$currPos = s0;
|
459 | s0 = peg$FAILED;
|
460 | }
|
461 | } else {
|
462 | peg$currPos = s0;
|
463 | s0 = peg$FAILED;
|
464 | }
|
465 | } else {
|
466 | peg$currPos = s0;
|
467 | s0 = peg$FAILED;
|
468 | }
|
469 |
|
470 | return s0;
|
471 | }
|
472 |
|
473 | function peg$parseObject() {
|
474 | var s0, s1, s2, s3;
|
475 |
|
476 | s0 = peg$currPos;
|
477 | if (input.charCodeAt(peg$currPos) === 123) {
|
478 | s1 = peg$c1;
|
479 | peg$currPos++;
|
480 | } else {
|
481 | s1 = peg$FAILED;
|
482 | if (peg$silentFails === 0) { peg$fail(peg$c2); }
|
483 | }
|
484 | if (s1 !== peg$FAILED) {
|
485 | s2 = peg$parseAssignmentList();
|
486 | if (s2 === peg$FAILED) {
|
487 | s2 = peg$parseEmptyBody();
|
488 | }
|
489 | if (s2 !== peg$FAILED) {
|
490 | if (input.charCodeAt(peg$currPos) === 125) {
|
491 | s3 = peg$c3;
|
492 | peg$currPos++;
|
493 | } else {
|
494 | s3 = peg$FAILED;
|
495 | if (peg$silentFails === 0) { peg$fail(peg$c4); }
|
496 | }
|
497 | if (s3 !== peg$FAILED) {
|
498 | peg$savedPos = s0;
|
499 | s1 = peg$c5(s2);
|
500 | s0 = s1;
|
501 | } else {
|
502 | peg$currPos = s0;
|
503 | s0 = peg$FAILED;
|
504 | }
|
505 | } else {
|
506 | peg$currPos = s0;
|
507 | s0 = peg$FAILED;
|
508 | }
|
509 | } else {
|
510 | peg$currPos = s0;
|
511 | s0 = peg$FAILED;
|
512 | }
|
513 |
|
514 | return s0;
|
515 | }
|
516 |
|
517 | function peg$parseEmptyBody() {
|
518 | var s0, s1;
|
519 |
|
520 | s0 = peg$currPos;
|
521 | s1 = peg$parse_();
|
522 | if (s1 !== peg$FAILED) {
|
523 | peg$savedPos = s0;
|
524 | s1 = peg$c6();
|
525 | }
|
526 | s0 = s1;
|
527 |
|
528 | return s0;
|
529 | }
|
530 |
|
531 | function peg$parseAssignmentList() {
|
532 | var s0, s1, s2, s3, s4, s5;
|
533 |
|
534 | s0 = peg$currPos;
|
535 | s1 = peg$parse_();
|
536 | if (s1 !== peg$FAILED) {
|
537 | s2 = [];
|
538 | s3 = peg$currPos;
|
539 | s4 = peg$parseAssignment();
|
540 | if (s4 === peg$FAILED) {
|
541 | s4 = peg$parseDelimitedSection();
|
542 | }
|
543 | if (s4 !== peg$FAILED) {
|
544 | s5 = peg$parse_();
|
545 | if (s5 !== peg$FAILED) {
|
546 | s4 = [s4, s5];
|
547 | s3 = s4;
|
548 | } else {
|
549 | peg$currPos = s3;
|
550 | s3 = peg$FAILED;
|
551 | }
|
552 | } else {
|
553 | peg$currPos = s3;
|
554 | s3 = peg$FAILED;
|
555 | }
|
556 | if (s3 !== peg$FAILED) {
|
557 | while (s3 !== peg$FAILED) {
|
558 | s2.push(s3);
|
559 | s3 = peg$currPos;
|
560 | s4 = peg$parseAssignment();
|
561 | if (s4 === peg$FAILED) {
|
562 | s4 = peg$parseDelimitedSection();
|
563 | }
|
564 | if (s4 !== peg$FAILED) {
|
565 | s5 = peg$parse_();
|
566 | if (s5 !== peg$FAILED) {
|
567 | s4 = [s4, s5];
|
568 | s3 = s4;
|
569 | } else {
|
570 | peg$currPos = s3;
|
571 | s3 = peg$FAILED;
|
572 | }
|
573 | } else {
|
574 | peg$currPos = s3;
|
575 | s3 = peg$FAILED;
|
576 | }
|
577 | }
|
578 | } else {
|
579 | s2 = peg$FAILED;
|
580 | }
|
581 | if (s2 !== peg$FAILED) {
|
582 | peg$savedPos = s0;
|
583 | s1 = peg$c7(s2);
|
584 | s0 = s1;
|
585 | } else {
|
586 | peg$currPos = s0;
|
587 | s0 = peg$FAILED;
|
588 | }
|
589 | } else {
|
590 | peg$currPos = s0;
|
591 | s0 = peg$FAILED;
|
592 | }
|
593 |
|
594 | return s0;
|
595 | }
|
596 |
|
597 | function peg$parseAssignment() {
|
598 | var s0;
|
599 |
|
600 | s0 = peg$parseSimpleAssignment();
|
601 | if (s0 === peg$FAILED) {
|
602 | s0 = peg$parseCommentedAssignment();
|
603 | }
|
604 |
|
605 | return s0;
|
606 | }
|
607 |
|
608 | function peg$parseSimpleAssignment() {
|
609 | var s0, s1, s2, s3, s4, s5, s6;
|
610 |
|
611 | s0 = peg$currPos;
|
612 | s1 = peg$parseIdentifier();
|
613 | if (s1 !== peg$FAILED) {
|
614 | s2 = peg$parse_();
|
615 | if (s2 !== peg$FAILED) {
|
616 | if (input.charCodeAt(peg$currPos) === 61) {
|
617 | s3 = peg$c8;
|
618 | peg$currPos++;
|
619 | } else {
|
620 | s3 = peg$FAILED;
|
621 | if (peg$silentFails === 0) { peg$fail(peg$c9); }
|
622 | }
|
623 | if (s3 !== peg$FAILED) {
|
624 | s4 = peg$parse_();
|
625 | if (s4 !== peg$FAILED) {
|
626 | s5 = peg$parseValue();
|
627 | if (s5 !== peg$FAILED) {
|
628 | if (input.charCodeAt(peg$currPos) === 59) {
|
629 | s6 = peg$c10;
|
630 | peg$currPos++;
|
631 | } else {
|
632 | s6 = peg$FAILED;
|
633 | if (peg$silentFails === 0) { peg$fail(peg$c11); }
|
634 | }
|
635 | if (s6 !== peg$FAILED) {
|
636 | peg$savedPos = s0;
|
637 | s1 = peg$c12(s1, s5);
|
638 | s0 = s1;
|
639 | } else {
|
640 | peg$currPos = s0;
|
641 | s0 = peg$FAILED;
|
642 | }
|
643 | } else {
|
644 | peg$currPos = s0;
|
645 | s0 = peg$FAILED;
|
646 | }
|
647 | } else {
|
648 | peg$currPos = s0;
|
649 | s0 = peg$FAILED;
|
650 | }
|
651 | } else {
|
652 | peg$currPos = s0;
|
653 | s0 = peg$FAILED;
|
654 | }
|
655 | } else {
|
656 | peg$currPos = s0;
|
657 | s0 = peg$FAILED;
|
658 | }
|
659 | } else {
|
660 | peg$currPos = s0;
|
661 | s0 = peg$FAILED;
|
662 | }
|
663 |
|
664 | return s0;
|
665 | }
|
666 |
|
667 | function peg$parseCommentedAssignment() {
|
668 | var s0, s1, s2, s3, s4, s5, s6;
|
669 |
|
670 | s0 = peg$currPos;
|
671 | s1 = peg$parseCommentedIdentifier();
|
672 | if (s1 !== peg$FAILED) {
|
673 | s2 = peg$parse_();
|
674 | if (s2 !== peg$FAILED) {
|
675 | if (input.charCodeAt(peg$currPos) === 61) {
|
676 | s3 = peg$c8;
|
677 | peg$currPos++;
|
678 | } else {
|
679 | s3 = peg$FAILED;
|
680 | if (peg$silentFails === 0) { peg$fail(peg$c9); }
|
681 | }
|
682 | if (s3 !== peg$FAILED) {
|
683 | s4 = peg$parse_();
|
684 | if (s4 !== peg$FAILED) {
|
685 | s5 = peg$parseValue();
|
686 | if (s5 !== peg$FAILED) {
|
687 | if (input.charCodeAt(peg$currPos) === 59) {
|
688 | s6 = peg$c10;
|
689 | peg$currPos++;
|
690 | } else {
|
691 | s6 = peg$FAILED;
|
692 | if (peg$silentFails === 0) { peg$fail(peg$c11); }
|
693 | }
|
694 | if (s6 !== peg$FAILED) {
|
695 | peg$savedPos = s0;
|
696 | s1 = peg$c13(s1, s5);
|
697 | s0 = s1;
|
698 | } else {
|
699 | peg$currPos = s0;
|
700 | s0 = peg$FAILED;
|
701 | }
|
702 | } else {
|
703 | peg$currPos = s0;
|
704 | s0 = peg$FAILED;
|
705 | }
|
706 | } else {
|
707 | peg$currPos = s0;
|
708 | s0 = peg$FAILED;
|
709 | }
|
710 | } else {
|
711 | peg$currPos = s0;
|
712 | s0 = peg$FAILED;
|
713 | }
|
714 | } else {
|
715 | peg$currPos = s0;
|
716 | s0 = peg$FAILED;
|
717 | }
|
718 | } else {
|
719 | peg$currPos = s0;
|
720 | s0 = peg$FAILED;
|
721 | }
|
722 | if (s0 === peg$FAILED) {
|
723 | s0 = peg$currPos;
|
724 | s1 = peg$parseIdentifier();
|
725 | if (s1 !== peg$FAILED) {
|
726 | s2 = peg$parse_();
|
727 | if (s2 !== peg$FAILED) {
|
728 | if (input.charCodeAt(peg$currPos) === 61) {
|
729 | s3 = peg$c8;
|
730 | peg$currPos++;
|
731 | } else {
|
732 | s3 = peg$FAILED;
|
733 | if (peg$silentFails === 0) { peg$fail(peg$c9); }
|
734 | }
|
735 | if (s3 !== peg$FAILED) {
|
736 | s4 = peg$parse_();
|
737 | if (s4 !== peg$FAILED) {
|
738 | s5 = peg$parseCommentedValue();
|
739 | if (s5 !== peg$FAILED) {
|
740 | if (input.charCodeAt(peg$currPos) === 59) {
|
741 | s6 = peg$c10;
|
742 | peg$currPos++;
|
743 | } else {
|
744 | s6 = peg$FAILED;
|
745 | if (peg$silentFails === 0) { peg$fail(peg$c11); }
|
746 | }
|
747 | if (s6 !== peg$FAILED) {
|
748 | peg$savedPos = s0;
|
749 | s1 = peg$c14(s1, s5);
|
750 | s0 = s1;
|
751 | } else {
|
752 | peg$currPos = s0;
|
753 | s0 = peg$FAILED;
|
754 | }
|
755 | } else {
|
756 | peg$currPos = s0;
|
757 | s0 = peg$FAILED;
|
758 | }
|
759 | } else {
|
760 | peg$currPos = s0;
|
761 | s0 = peg$FAILED;
|
762 | }
|
763 | } else {
|
764 | peg$currPos = s0;
|
765 | s0 = peg$FAILED;
|
766 | }
|
767 | } else {
|
768 | peg$currPos = s0;
|
769 | s0 = peg$FAILED;
|
770 | }
|
771 | } else {
|
772 | peg$currPos = s0;
|
773 | s0 = peg$FAILED;
|
774 | }
|
775 | }
|
776 |
|
777 | return s0;
|
778 | }
|
779 |
|
780 | function peg$parseCommentedIdentifier() {
|
781 | var s0, s1, s2, s3;
|
782 |
|
783 | s0 = peg$currPos;
|
784 | s1 = peg$parseIdentifier();
|
785 | if (s1 !== peg$FAILED) {
|
786 | s2 = peg$parse_();
|
787 | if (s2 !== peg$FAILED) {
|
788 | s3 = peg$parseInlineComment();
|
789 | if (s3 !== peg$FAILED) {
|
790 | peg$savedPos = s0;
|
791 | s1 = peg$c15(s1, s3);
|
792 | s0 = s1;
|
793 | } else {
|
794 | peg$currPos = s0;
|
795 | s0 = peg$FAILED;
|
796 | }
|
797 | } else {
|
798 | peg$currPos = s0;
|
799 | s0 = peg$FAILED;
|
800 | }
|
801 | } else {
|
802 | peg$currPos = s0;
|
803 | s0 = peg$FAILED;
|
804 | }
|
805 |
|
806 | return s0;
|
807 | }
|
808 |
|
809 | function peg$parseCommentedValue() {
|
810 | var s0, s1, s2, s3;
|
811 |
|
812 | s0 = peg$currPos;
|
813 | s1 = peg$parseValue();
|
814 | if (s1 !== peg$FAILED) {
|
815 | s2 = peg$parse_();
|
816 | if (s2 !== peg$FAILED) {
|
817 | s3 = peg$parseInlineComment();
|
818 | if (s3 !== peg$FAILED) {
|
819 | peg$savedPos = s0;
|
820 | s1 = peg$c16(s1, s3);
|
821 | s0 = s1;
|
822 | } else {
|
823 | peg$currPos = s0;
|
824 | s0 = peg$FAILED;
|
825 | }
|
826 | } else {
|
827 | peg$currPos = s0;
|
828 | s0 = peg$FAILED;
|
829 | }
|
830 | } else {
|
831 | peg$currPos = s0;
|
832 | s0 = peg$FAILED;
|
833 | }
|
834 |
|
835 | return s0;
|
836 | }
|
837 |
|
838 | function peg$parseInlineComment() {
|
839 | var s0, s1, s2, s3;
|
840 |
|
841 | s0 = peg$currPos;
|
842 | s1 = peg$parseInlineCommentOpen();
|
843 | if (s1 !== peg$FAILED) {
|
844 | s2 = [];
|
845 | if (peg$c17.test(input.charAt(peg$currPos))) {
|
846 | s3 = input.charAt(peg$currPos);
|
847 | peg$currPos++;
|
848 | } else {
|
849 | s3 = peg$FAILED;
|
850 | if (peg$silentFails === 0) { peg$fail(peg$c18); }
|
851 | }
|
852 | if (s3 !== peg$FAILED) {
|
853 | while (s3 !== peg$FAILED) {
|
854 | s2.push(s3);
|
855 | if (peg$c17.test(input.charAt(peg$currPos))) {
|
856 | s3 = input.charAt(peg$currPos);
|
857 | peg$currPos++;
|
858 | } else {
|
859 | s3 = peg$FAILED;
|
860 | if (peg$silentFails === 0) { peg$fail(peg$c18); }
|
861 | }
|
862 | }
|
863 | } else {
|
864 | s2 = peg$FAILED;
|
865 | }
|
866 | if (s2 !== peg$FAILED) {
|
867 | s3 = peg$parseInlineCommentClose();
|
868 | if (s3 !== peg$FAILED) {
|
869 | peg$savedPos = s0;
|
870 | s1 = peg$c19(s2);
|
871 | s0 = s1;
|
872 | } else {
|
873 | peg$currPos = s0;
|
874 | s0 = peg$FAILED;
|
875 | }
|
876 | } else {
|
877 | peg$currPos = s0;
|
878 | s0 = peg$FAILED;
|
879 | }
|
880 | } else {
|
881 | peg$currPos = s0;
|
882 | s0 = peg$FAILED;
|
883 | }
|
884 |
|
885 | return s0;
|
886 | }
|
887 |
|
888 | function peg$parseInlineCommentOpen() {
|
889 | var s0;
|
890 |
|
891 | if (input.substr(peg$currPos, 2) === peg$c20) {
|
892 | s0 = peg$c20;
|
893 | peg$currPos += 2;
|
894 | } else {
|
895 | s0 = peg$FAILED;
|
896 | if (peg$silentFails === 0) { peg$fail(peg$c21); }
|
897 | }
|
898 |
|
899 | return s0;
|
900 | }
|
901 |
|
902 | function peg$parseInlineCommentClose() {
|
903 | var s0;
|
904 |
|
905 | if (input.substr(peg$currPos, 2) === peg$c22) {
|
906 | s0 = peg$c22;
|
907 | peg$currPos += 2;
|
908 | } else {
|
909 | s0 = peg$FAILED;
|
910 | if (peg$silentFails === 0) { peg$fail(peg$c23); }
|
911 | }
|
912 |
|
913 | return s0;
|
914 | }
|
915 |
|
916 | function peg$parseDelimitedSection() {
|
917 | var s0, s1, s2, s3, s4, s5;
|
918 |
|
919 | s0 = peg$currPos;
|
920 | s1 = peg$parseDelimitedSectionBegin();
|
921 | if (s1 !== peg$FAILED) {
|
922 | s2 = peg$parse_();
|
923 | if (s2 !== peg$FAILED) {
|
924 | s3 = peg$parseAssignmentList();
|
925 | if (s3 === peg$FAILED) {
|
926 | s3 = peg$parseEmptyBody();
|
927 | }
|
928 | if (s3 !== peg$FAILED) {
|
929 | s4 = peg$parse_();
|
930 | if (s4 !== peg$FAILED) {
|
931 | s5 = peg$parseDelimitedSectionEnd();
|
932 | if (s5 !== peg$FAILED) {
|
933 | peg$savedPos = s0;
|
934 | s1 = peg$c24(s1, s3);
|
935 | s0 = s1;
|
936 | } else {
|
937 | peg$currPos = s0;
|
938 | s0 = peg$FAILED;
|
939 | }
|
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 |
|
957 | return s0;
|
958 | }
|
959 |
|
960 | function peg$parseDelimitedSectionBegin() {
|
961 | var s0, s1, s2, s3, s4;
|
962 |
|
963 | s0 = peg$currPos;
|
964 | if (input.substr(peg$currPos, 9) === peg$c25) {
|
965 | s1 = peg$c25;
|
966 | peg$currPos += 9;
|
967 | } else {
|
968 | s1 = peg$FAILED;
|
969 | if (peg$silentFails === 0) { peg$fail(peg$c26); }
|
970 | }
|
971 | if (s1 !== peg$FAILED) {
|
972 | s2 = peg$parseIdentifier();
|
973 | if (s2 !== peg$FAILED) {
|
974 | if (input.substr(peg$currPos, 11) === peg$c27) {
|
975 | s3 = peg$c27;
|
976 | peg$currPos += 11;
|
977 | } else {
|
978 | s3 = peg$FAILED;
|
979 | if (peg$silentFails === 0) { peg$fail(peg$c28); }
|
980 | }
|
981 | if (s3 !== peg$FAILED) {
|
982 | s4 = peg$parseNewLine();
|
983 | if (s4 !== peg$FAILED) {
|
984 | peg$savedPos = s0;
|
985 | s1 = peg$c29(s2);
|
986 | s0 = s1;
|
987 | } else {
|
988 | peg$currPos = s0;
|
989 | s0 = peg$FAILED;
|
990 | }
|
991 | } else {
|
992 | peg$currPos = s0;
|
993 | s0 = peg$FAILED;
|
994 | }
|
995 | } else {
|
996 | peg$currPos = s0;
|
997 | s0 = peg$FAILED;
|
998 | }
|
999 | } else {
|
1000 | peg$currPos = s0;
|
1001 | s0 = peg$FAILED;
|
1002 | }
|
1003 |
|
1004 | return s0;
|
1005 | }
|
1006 |
|
1007 | function peg$parseDelimitedSectionEnd() {
|
1008 | var s0, s1, s2, s3, s4;
|
1009 |
|
1010 | s0 = peg$currPos;
|
1011 | if (input.substr(peg$currPos, 7) === peg$c30) {
|
1012 | s1 = peg$c30;
|
1013 | peg$currPos += 7;
|
1014 | } else {
|
1015 | s1 = peg$FAILED;
|
1016 | if (peg$silentFails === 0) { peg$fail(peg$c31); }
|
1017 | }
|
1018 | if (s1 !== peg$FAILED) {
|
1019 | s2 = peg$parseIdentifier();
|
1020 | if (s2 !== peg$FAILED) {
|
1021 | if (input.substr(peg$currPos, 11) === peg$c27) {
|
1022 | s3 = peg$c27;
|
1023 | peg$currPos += 11;
|
1024 | } else {
|
1025 | s3 = peg$FAILED;
|
1026 | if (peg$silentFails === 0) { peg$fail(peg$c28); }
|
1027 | }
|
1028 | if (s3 !== peg$FAILED) {
|
1029 | s4 = peg$parseNewLine();
|
1030 | if (s4 !== peg$FAILED) {
|
1031 | peg$savedPos = s0;
|
1032 | s1 = peg$c29(s2);
|
1033 | s0 = s1;
|
1034 | } else {
|
1035 | peg$currPos = s0;
|
1036 | s0 = peg$FAILED;
|
1037 | }
|
1038 | } else {
|
1039 | peg$currPos = s0;
|
1040 | s0 = peg$FAILED;
|
1041 | }
|
1042 | } else {
|
1043 | peg$currPos = s0;
|
1044 | s0 = peg$FAILED;
|
1045 | }
|
1046 | } else {
|
1047 | peg$currPos = s0;
|
1048 | s0 = peg$FAILED;
|
1049 | }
|
1050 |
|
1051 | return s0;
|
1052 | }
|
1053 |
|
1054 | function peg$parseArray() {
|
1055 | var s0, s1, s2, s3;
|
1056 |
|
1057 | s0 = peg$currPos;
|
1058 | if (input.charCodeAt(peg$currPos) === 40) {
|
1059 | s1 = peg$c32;
|
1060 | peg$currPos++;
|
1061 | } else {
|
1062 | s1 = peg$FAILED;
|
1063 | if (peg$silentFails === 0) { peg$fail(peg$c33); }
|
1064 | }
|
1065 | if (s1 !== peg$FAILED) {
|
1066 | s2 = peg$parseArrayBody();
|
1067 | if (s2 === peg$FAILED) {
|
1068 | s2 = peg$parseEmptyArray();
|
1069 | }
|
1070 | if (s2 !== peg$FAILED) {
|
1071 | if (input.charCodeAt(peg$currPos) === 41) {
|
1072 | s3 = peg$c34;
|
1073 | peg$currPos++;
|
1074 | } else {
|
1075 | s3 = peg$FAILED;
|
1076 | if (peg$silentFails === 0) { peg$fail(peg$c35); }
|
1077 | }
|
1078 | if (s3 !== peg$FAILED) {
|
1079 | peg$savedPos = s0;
|
1080 | s1 = peg$c36(s2);
|
1081 | s0 = s1;
|
1082 | } else {
|
1083 | peg$currPos = s0;
|
1084 | s0 = peg$FAILED;
|
1085 | }
|
1086 | } else {
|
1087 | peg$currPos = s0;
|
1088 | s0 = peg$FAILED;
|
1089 | }
|
1090 | } else {
|
1091 | peg$currPos = s0;
|
1092 | s0 = peg$FAILED;
|
1093 | }
|
1094 |
|
1095 | return s0;
|
1096 | }
|
1097 |
|
1098 | function peg$parseEmptyArray() {
|
1099 | var s0, s1;
|
1100 |
|
1101 | s0 = peg$currPos;
|
1102 | s1 = peg$parse_();
|
1103 | if (s1 !== peg$FAILED) {
|
1104 | peg$savedPos = s0;
|
1105 | s1 = peg$c37();
|
1106 | }
|
1107 | s0 = s1;
|
1108 |
|
1109 | return s0;
|
1110 | }
|
1111 |
|
1112 | function peg$parseArrayBody() {
|
1113 | var s0, s1, s2, s3, s4, s5;
|
1114 |
|
1115 | s0 = peg$currPos;
|
1116 | s1 = peg$parse_();
|
1117 | if (s1 !== peg$FAILED) {
|
1118 | s2 = peg$parseArrayEntry();
|
1119 | if (s2 !== peg$FAILED) {
|
1120 | s3 = peg$parse_();
|
1121 | if (s3 !== peg$FAILED) {
|
1122 | s4 = peg$parseArrayBody();
|
1123 | if (s4 === peg$FAILED) {
|
1124 | s4 = null;
|
1125 | }
|
1126 | if (s4 !== peg$FAILED) {
|
1127 | s5 = peg$parse_();
|
1128 | if (s5 !== peg$FAILED) {
|
1129 | peg$savedPos = s0;
|
1130 | s1 = peg$c38(s2, s4);
|
1131 | s0 = s1;
|
1132 | } else {
|
1133 | peg$currPos = s0;
|
1134 | s0 = peg$FAILED;
|
1135 | }
|
1136 | } else {
|
1137 | peg$currPos = s0;
|
1138 | s0 = peg$FAILED;
|
1139 | }
|
1140 | } else {
|
1141 | peg$currPos = s0;
|
1142 | s0 = peg$FAILED;
|
1143 | }
|
1144 | } else {
|
1145 | peg$currPos = s0;
|
1146 | s0 = peg$FAILED;
|
1147 | }
|
1148 | } else {
|
1149 | peg$currPos = s0;
|
1150 | s0 = peg$FAILED;
|
1151 | }
|
1152 |
|
1153 | return s0;
|
1154 | }
|
1155 |
|
1156 | function peg$parseArrayEntry() {
|
1157 | var s0;
|
1158 |
|
1159 | s0 = peg$parseSimpleArrayEntry();
|
1160 | if (s0 === peg$FAILED) {
|
1161 | s0 = peg$parseCommentedArrayEntry();
|
1162 | }
|
1163 |
|
1164 | return s0;
|
1165 | }
|
1166 |
|
1167 | function peg$parseSimpleArrayEntry() {
|
1168 | var s0, s1, s2;
|
1169 |
|
1170 | s0 = peg$currPos;
|
1171 | s1 = peg$parseValue();
|
1172 | if (s1 !== peg$FAILED) {
|
1173 | s2 = peg$parseEndArrayEntry();
|
1174 | if (s2 !== peg$FAILED) {
|
1175 | peg$savedPos = s0;
|
1176 | s1 = peg$c39(s1);
|
1177 | s0 = s1;
|
1178 | } else {
|
1179 | peg$currPos = s0;
|
1180 | s0 = peg$FAILED;
|
1181 | }
|
1182 | } else {
|
1183 | peg$currPos = s0;
|
1184 | s0 = peg$FAILED;
|
1185 | }
|
1186 |
|
1187 | return s0;
|
1188 | }
|
1189 |
|
1190 | function peg$parseCommentedArrayEntry() {
|
1191 | var s0, s1, s2, s3, s4;
|
1192 |
|
1193 | s0 = peg$currPos;
|
1194 | s1 = peg$parseValue();
|
1195 | if (s1 !== peg$FAILED) {
|
1196 | s2 = peg$parse_();
|
1197 | if (s2 !== peg$FAILED) {
|
1198 | s3 = peg$parseInlineComment();
|
1199 | if (s3 !== peg$FAILED) {
|
1200 | s4 = peg$parseEndArrayEntry();
|
1201 | if (s4 !== peg$FAILED) {
|
1202 | peg$savedPos = s0;
|
1203 | s1 = peg$c40(s1, s3);
|
1204 | s0 = s1;
|
1205 | } else {
|
1206 | peg$currPos = s0;
|
1207 | s0 = peg$FAILED;
|
1208 | }
|
1209 | } else {
|
1210 | peg$currPos = s0;
|
1211 | s0 = peg$FAILED;
|
1212 | }
|
1213 | } else {
|
1214 | peg$currPos = s0;
|
1215 | s0 = peg$FAILED;
|
1216 | }
|
1217 | } else {
|
1218 | peg$currPos = s0;
|
1219 | s0 = peg$FAILED;
|
1220 | }
|
1221 |
|
1222 | return s0;
|
1223 | }
|
1224 |
|
1225 | function peg$parseEndArrayEntry() {
|
1226 | var s0, s1, s2, s3;
|
1227 |
|
1228 | if (input.charCodeAt(peg$currPos) === 44) {
|
1229 | s0 = peg$c41;
|
1230 | peg$currPos++;
|
1231 | } else {
|
1232 | s0 = peg$FAILED;
|
1233 | if (peg$silentFails === 0) { peg$fail(peg$c42); }
|
1234 | }
|
1235 | if (s0 === peg$FAILED) {
|
1236 | s0 = peg$currPos;
|
1237 | s1 = peg$parse_();
|
1238 | if (s1 !== peg$FAILED) {
|
1239 | s2 = peg$currPos;
|
1240 | peg$silentFails++;
|
1241 | if (input.charCodeAt(peg$currPos) === 41) {
|
1242 | s3 = peg$c34;
|
1243 | peg$currPos++;
|
1244 | } else {
|
1245 | s3 = peg$FAILED;
|
1246 | if (peg$silentFails === 0) { peg$fail(peg$c35); }
|
1247 | }
|
1248 | peg$silentFails--;
|
1249 | if (s3 !== peg$FAILED) {
|
1250 | peg$currPos = s2;
|
1251 | s2 = void 0;
|
1252 | } else {
|
1253 | s2 = peg$FAILED;
|
1254 | }
|
1255 | if (s2 !== peg$FAILED) {
|
1256 | s1 = [s1, s2];
|
1257 | s0 = s1;
|
1258 | } else {
|
1259 | peg$currPos = s0;
|
1260 | s0 = peg$FAILED;
|
1261 | }
|
1262 | } else {
|
1263 | peg$currPos = s0;
|
1264 | s0 = peg$FAILED;
|
1265 | }
|
1266 | }
|
1267 |
|
1268 | return s0;
|
1269 | }
|
1270 |
|
1271 | function peg$parseIdentifier() {
|
1272 | var s0, s1, s2;
|
1273 |
|
1274 | s0 = peg$currPos;
|
1275 | s1 = [];
|
1276 | if (peg$c43.test(input.charAt(peg$currPos))) {
|
1277 | s2 = input.charAt(peg$currPos);
|
1278 | peg$currPos++;
|
1279 | } else {
|
1280 | s2 = peg$FAILED;
|
1281 | if (peg$silentFails === 0) { peg$fail(peg$c44); }
|
1282 | }
|
1283 | if (s2 !== peg$FAILED) {
|
1284 | while (s2 !== peg$FAILED) {
|
1285 | s1.push(s2);
|
1286 | if (peg$c43.test(input.charAt(peg$currPos))) {
|
1287 | s2 = input.charAt(peg$currPos);
|
1288 | peg$currPos++;
|
1289 | } else {
|
1290 | s2 = peg$FAILED;
|
1291 | if (peg$silentFails === 0) { peg$fail(peg$c44); }
|
1292 | }
|
1293 | }
|
1294 | } else {
|
1295 | s1 = peg$FAILED;
|
1296 | }
|
1297 | if (s1 !== peg$FAILED) {
|
1298 | peg$savedPos = s0;
|
1299 | s1 = peg$c45(s1);
|
1300 | }
|
1301 | s0 = s1;
|
1302 | if (s0 === peg$FAILED) {
|
1303 | s0 = peg$parseQuotedString();
|
1304 | }
|
1305 |
|
1306 | return s0;
|
1307 | }
|
1308 |
|
1309 | function peg$parseValue() {
|
1310 | var s0;
|
1311 |
|
1312 | s0 = peg$parseObject();
|
1313 | if (s0 === peg$FAILED) {
|
1314 | s0 = peg$parseArray();
|
1315 | if (s0 === peg$FAILED) {
|
1316 | s0 = peg$parseNumberValue();
|
1317 | if (s0 === peg$FAILED) {
|
1318 | s0 = peg$parseStringValue();
|
1319 | }
|
1320 | }
|
1321 | }
|
1322 |
|
1323 | return s0;
|
1324 | }
|
1325 |
|
1326 | function peg$parseNumberValue() {
|
1327 | var s0;
|
1328 |
|
1329 | s0 = peg$parseDecimalValue();
|
1330 | if (s0 === peg$FAILED) {
|
1331 | s0 = peg$parseIntegerValue();
|
1332 | }
|
1333 |
|
1334 | return s0;
|
1335 | }
|
1336 |
|
1337 | function peg$parseDecimalValue() {
|
1338 | var s0, s1, s2, s3, s4;
|
1339 |
|
1340 | s0 = peg$currPos;
|
1341 | s1 = peg$currPos;
|
1342 | s2 = peg$parseIntegerValue();
|
1343 | if (s2 !== peg$FAILED) {
|
1344 | if (input.charCodeAt(peg$currPos) === 46) {
|
1345 | s3 = peg$c46;
|
1346 | peg$currPos++;
|
1347 | } else {
|
1348 | s3 = peg$FAILED;
|
1349 | if (peg$silentFails === 0) { peg$fail(peg$c47); }
|
1350 | }
|
1351 | if (s3 !== peg$FAILED) {
|
1352 | s4 = peg$parseIntegerValue();
|
1353 | if (s4 !== peg$FAILED) {
|
1354 | s2 = [s2, s3, s4];
|
1355 | s1 = s2;
|
1356 | } else {
|
1357 | peg$currPos = s1;
|
1358 | s1 = peg$FAILED;
|
1359 | }
|
1360 | } else {
|
1361 | peg$currPos = s1;
|
1362 | s1 = peg$FAILED;
|
1363 | }
|
1364 | } else {
|
1365 | peg$currPos = s1;
|
1366 | s1 = peg$FAILED;
|
1367 | }
|
1368 | if (s1 !== peg$FAILED) {
|
1369 | peg$savedPos = s0;
|
1370 | s1 = peg$c48(s1);
|
1371 | }
|
1372 | s0 = s1;
|
1373 |
|
1374 | return s0;
|
1375 | }
|
1376 |
|
1377 | function peg$parseIntegerValue() {
|
1378 | var s0, s1, s2, s3, s4;
|
1379 |
|
1380 | s0 = peg$currPos;
|
1381 | s1 = peg$currPos;
|
1382 | peg$silentFails++;
|
1383 | s2 = peg$parseAlpha();
|
1384 | peg$silentFails--;
|
1385 | if (s2 === peg$FAILED) {
|
1386 | s1 = void 0;
|
1387 | } else {
|
1388 | peg$currPos = s1;
|
1389 | s1 = peg$FAILED;
|
1390 | }
|
1391 | if (s1 !== peg$FAILED) {
|
1392 | s2 = [];
|
1393 | s3 = peg$parseDigit();
|
1394 | if (s3 !== peg$FAILED) {
|
1395 | while (s3 !== peg$FAILED) {
|
1396 | s2.push(s3);
|
1397 | s3 = peg$parseDigit();
|
1398 | }
|
1399 | } else {
|
1400 | s2 = peg$FAILED;
|
1401 | }
|
1402 | if (s2 !== peg$FAILED) {
|
1403 | s3 = peg$currPos;
|
1404 | peg$silentFails++;
|
1405 | s4 = peg$parseNonTerminator();
|
1406 | peg$silentFails--;
|
1407 | if (s4 === peg$FAILED) {
|
1408 | s3 = void 0;
|
1409 | } else {
|
1410 | peg$currPos = s3;
|
1411 | s3 = peg$FAILED;
|
1412 | }
|
1413 | if (s3 !== peg$FAILED) {
|
1414 | peg$savedPos = s0;
|
1415 | s1 = peg$c49(s2);
|
1416 | s0 = s1;
|
1417 | } else {
|
1418 | peg$currPos = s0;
|
1419 | s0 = peg$FAILED;
|
1420 | }
|
1421 | } else {
|
1422 | peg$currPos = s0;
|
1423 | s0 = peg$FAILED;
|
1424 | }
|
1425 | } else {
|
1426 | peg$currPos = s0;
|
1427 | s0 = peg$FAILED;
|
1428 | }
|
1429 |
|
1430 | return s0;
|
1431 | }
|
1432 |
|
1433 | function peg$parseStringValue() {
|
1434 | var s0;
|
1435 |
|
1436 | s0 = peg$parseQuotedString();
|
1437 | if (s0 === peg$FAILED) {
|
1438 | s0 = peg$parseLiteralString();
|
1439 | }
|
1440 |
|
1441 | return s0;
|
1442 | }
|
1443 |
|
1444 | function peg$parseQuotedString() {
|
1445 | var s0, s1, s2, s3;
|
1446 |
|
1447 | s0 = peg$currPos;
|
1448 | s1 = peg$parseDoubleQuote();
|
1449 | if (s1 !== peg$FAILED) {
|
1450 | s2 = peg$parseQuotedBody();
|
1451 | if (s2 !== peg$FAILED) {
|
1452 | s3 = peg$parseDoubleQuote();
|
1453 | if (s3 !== peg$FAILED) {
|
1454 | peg$savedPos = s0;
|
1455 | s1 = peg$c50(s2);
|
1456 | s0 = s1;
|
1457 | } else {
|
1458 | peg$currPos = s0;
|
1459 | s0 = peg$FAILED;
|
1460 | }
|
1461 | } else {
|
1462 | peg$currPos = s0;
|
1463 | s0 = peg$FAILED;
|
1464 | }
|
1465 | } else {
|
1466 | peg$currPos = s0;
|
1467 | s0 = peg$FAILED;
|
1468 | }
|
1469 |
|
1470 | return s0;
|
1471 | }
|
1472 |
|
1473 | function peg$parseQuotedBody() {
|
1474 | var s0, s1, s2;
|
1475 |
|
1476 | s0 = peg$currPos;
|
1477 | s1 = [];
|
1478 | s2 = peg$parseNonQuote();
|
1479 | if (s2 !== peg$FAILED) {
|
1480 | while (s2 !== peg$FAILED) {
|
1481 | s1.push(s2);
|
1482 | s2 = peg$parseNonQuote();
|
1483 | }
|
1484 | } else {
|
1485 | s1 = peg$FAILED;
|
1486 | }
|
1487 | if (s1 !== peg$FAILED) {
|
1488 | peg$savedPos = s0;
|
1489 | s1 = peg$c51(s1);
|
1490 | }
|
1491 | s0 = s1;
|
1492 |
|
1493 | return s0;
|
1494 | }
|
1495 |
|
1496 | function peg$parseNonQuote() {
|
1497 | var s0, s1, s2;
|
1498 |
|
1499 | s0 = peg$parseEscapedQuote();
|
1500 | if (s0 === peg$FAILED) {
|
1501 | s0 = peg$currPos;
|
1502 | s1 = peg$currPos;
|
1503 | peg$silentFails++;
|
1504 | s2 = peg$parseDoubleQuote();
|
1505 | peg$silentFails--;
|
1506 | if (s2 === peg$FAILED) {
|
1507 | s1 = void 0;
|
1508 | } else {
|
1509 | peg$currPos = s1;
|
1510 | s1 = peg$FAILED;
|
1511 | }
|
1512 | if (s1 !== peg$FAILED) {
|
1513 | if (input.length > peg$currPos) {
|
1514 | s2 = input.charAt(peg$currPos);
|
1515 | peg$currPos++;
|
1516 | } else {
|
1517 | s2 = peg$FAILED;
|
1518 | if (peg$silentFails === 0) { peg$fail(peg$c52); }
|
1519 | }
|
1520 | if (s2 !== peg$FAILED) {
|
1521 | peg$savedPos = s0;
|
1522 | s1 = peg$c53(s2);
|
1523 | s0 = s1;
|
1524 | } else {
|
1525 | peg$currPos = s0;
|
1526 | s0 = peg$FAILED;
|
1527 | }
|
1528 | } else {
|
1529 | peg$currPos = s0;
|
1530 | s0 = peg$FAILED;
|
1531 | }
|
1532 | }
|
1533 |
|
1534 | return s0;
|
1535 | }
|
1536 |
|
1537 | function peg$parseEscapedQuote() {
|
1538 | var s0, s1, s2;
|
1539 |
|
1540 | s0 = peg$currPos;
|
1541 | if (input.charCodeAt(peg$currPos) === 92) {
|
1542 | s1 = peg$c54;
|
1543 | peg$currPos++;
|
1544 | } else {
|
1545 | s1 = peg$FAILED;
|
1546 | if (peg$silentFails === 0) { peg$fail(peg$c55); }
|
1547 | }
|
1548 | if (s1 !== peg$FAILED) {
|
1549 | s2 = peg$parseDoubleQuote();
|
1550 | if (s2 !== peg$FAILED) {
|
1551 | peg$savedPos = s0;
|
1552 | s1 = peg$c56();
|
1553 | s0 = s1;
|
1554 | } else {
|
1555 | peg$currPos = s0;
|
1556 | s0 = peg$FAILED;
|
1557 | }
|
1558 | } else {
|
1559 | peg$currPos = s0;
|
1560 | s0 = peg$FAILED;
|
1561 | }
|
1562 |
|
1563 | return s0;
|
1564 | }
|
1565 |
|
1566 | function peg$parseLiteralString() {
|
1567 | var s0, s1, s2;
|
1568 |
|
1569 | s0 = peg$currPos;
|
1570 | s1 = [];
|
1571 | s2 = peg$parseLiteralChar();
|
1572 | if (s2 !== peg$FAILED) {
|
1573 | while (s2 !== peg$FAILED) {
|
1574 | s1.push(s2);
|
1575 | s2 = peg$parseLiteralChar();
|
1576 | }
|
1577 | } else {
|
1578 | s1 = peg$FAILED;
|
1579 | }
|
1580 | if (s1 !== peg$FAILED) {
|
1581 | peg$savedPos = s0;
|
1582 | s1 = peg$c57(s1);
|
1583 | }
|
1584 | s0 = s1;
|
1585 |
|
1586 | return s0;
|
1587 | }
|
1588 |
|
1589 | function peg$parseLiteralChar() {
|
1590 | var s0, s1, s2, s3;
|
1591 |
|
1592 | s0 = peg$currPos;
|
1593 | s1 = peg$currPos;
|
1594 | peg$silentFails++;
|
1595 | s2 = peg$parseInlineCommentOpen();
|
1596 | peg$silentFails--;
|
1597 | if (s2 === peg$FAILED) {
|
1598 | s1 = void 0;
|
1599 | } else {
|
1600 | peg$currPos = s1;
|
1601 | s1 = peg$FAILED;
|
1602 | }
|
1603 | if (s1 !== peg$FAILED) {
|
1604 | s2 = peg$currPos;
|
1605 | peg$silentFails++;
|
1606 | s3 = peg$parseLineTerminator();
|
1607 | peg$silentFails--;
|
1608 | if (s3 === peg$FAILED) {
|
1609 | s2 = void 0;
|
1610 | } else {
|
1611 | peg$currPos = s2;
|
1612 | s2 = peg$FAILED;
|
1613 | }
|
1614 | if (s2 !== peg$FAILED) {
|
1615 | s3 = peg$parseNonTerminator();
|
1616 | if (s3 !== peg$FAILED) {
|
1617 | peg$savedPos = s0;
|
1618 | s1 = peg$c53(s3);
|
1619 | s0 = s1;
|
1620 | } else {
|
1621 | peg$currPos = s0;
|
1622 | s0 = peg$FAILED;
|
1623 | }
|
1624 | } else {
|
1625 | peg$currPos = s0;
|
1626 | s0 = peg$FAILED;
|
1627 | }
|
1628 | } else {
|
1629 | peg$currPos = s0;
|
1630 | s0 = peg$FAILED;
|
1631 | }
|
1632 |
|
1633 | return s0;
|
1634 | }
|
1635 |
|
1636 | function peg$parseNonTerminator() {
|
1637 | var s0;
|
1638 |
|
1639 | if (peg$c58.test(input.charAt(peg$currPos))) {
|
1640 | s0 = input.charAt(peg$currPos);
|
1641 | peg$currPos++;
|
1642 | } else {
|
1643 | s0 = peg$FAILED;
|
1644 | if (peg$silentFails === 0) { peg$fail(peg$c59); }
|
1645 | }
|
1646 |
|
1647 | return s0;
|
1648 | }
|
1649 |
|
1650 | function peg$parseSingleLineComment() {
|
1651 | var s0, s1, s2, s3, s4;
|
1652 |
|
1653 | s0 = peg$currPos;
|
1654 | if (input.substr(peg$currPos, 2) === peg$c60) {
|
1655 | s1 = peg$c60;
|
1656 | peg$currPos += 2;
|
1657 | } else {
|
1658 | s1 = peg$FAILED;
|
1659 | if (peg$silentFails === 0) { peg$fail(peg$c61); }
|
1660 | }
|
1661 | if (s1 !== peg$FAILED) {
|
1662 | s2 = peg$parse_();
|
1663 | if (s2 !== peg$FAILED) {
|
1664 | s3 = peg$parseOneLineString();
|
1665 | if (s3 !== peg$FAILED) {
|
1666 | s4 = peg$parseNewLine();
|
1667 | if (s4 !== peg$FAILED) {
|
1668 | peg$savedPos = s0;
|
1669 | s1 = peg$c62(s3);
|
1670 | s0 = s1;
|
1671 | } else {
|
1672 | peg$currPos = s0;
|
1673 | s0 = peg$FAILED;
|
1674 | }
|
1675 | } else {
|
1676 | peg$currPos = s0;
|
1677 | s0 = peg$FAILED;
|
1678 | }
|
1679 | } else {
|
1680 | peg$currPos = s0;
|
1681 | s0 = peg$FAILED;
|
1682 | }
|
1683 | } else {
|
1684 | peg$currPos = s0;
|
1685 | s0 = peg$FAILED;
|
1686 | }
|
1687 |
|
1688 | return s0;
|
1689 | }
|
1690 |
|
1691 | function peg$parseOneLineString() {
|
1692 | var s0, s1, s2;
|
1693 |
|
1694 | s0 = peg$currPos;
|
1695 | s1 = [];
|
1696 | s2 = peg$parseNonLine();
|
1697 | while (s2 !== peg$FAILED) {
|
1698 | s1.push(s2);
|
1699 | s2 = peg$parseNonLine();
|
1700 | }
|
1701 | if (s1 !== peg$FAILED) {
|
1702 | peg$savedPos = s0;
|
1703 | s1 = peg$c63(s1);
|
1704 | }
|
1705 | s0 = s1;
|
1706 |
|
1707 | return s0;
|
1708 | }
|
1709 |
|
1710 | function peg$parseDigit() {
|
1711 | var s0;
|
1712 |
|
1713 | if (peg$c64.test(input.charAt(peg$currPos))) {
|
1714 | s0 = input.charAt(peg$currPos);
|
1715 | peg$currPos++;
|
1716 | } else {
|
1717 | s0 = peg$FAILED;
|
1718 | if (peg$silentFails === 0) { peg$fail(peg$c65); }
|
1719 | }
|
1720 |
|
1721 | return s0;
|
1722 | }
|
1723 |
|
1724 | function peg$parseAlpha() {
|
1725 | var s0;
|
1726 |
|
1727 | if (peg$c66.test(input.charAt(peg$currPos))) {
|
1728 | s0 = input.charAt(peg$currPos);
|
1729 | peg$currPos++;
|
1730 | } else {
|
1731 | s0 = peg$FAILED;
|
1732 | if (peg$silentFails === 0) { peg$fail(peg$c67); }
|
1733 | }
|
1734 |
|
1735 | return s0;
|
1736 | }
|
1737 |
|
1738 | function peg$parseDoubleQuote() {
|
1739 | var s0;
|
1740 |
|
1741 | if (input.charCodeAt(peg$currPos) === 34) {
|
1742 | s0 = peg$c68;
|
1743 | peg$currPos++;
|
1744 | } else {
|
1745 | s0 = peg$FAILED;
|
1746 | if (peg$silentFails === 0) { peg$fail(peg$c69); }
|
1747 | }
|
1748 |
|
1749 | return s0;
|
1750 | }
|
1751 |
|
1752 | function peg$parse_() {
|
1753 | var s0, s1;
|
1754 |
|
1755 | peg$silentFails++;
|
1756 | s0 = [];
|
1757 | s1 = peg$parsewhitespace();
|
1758 | while (s1 !== peg$FAILED) {
|
1759 | s0.push(s1);
|
1760 | s1 = peg$parsewhitespace();
|
1761 | }
|
1762 | peg$silentFails--;
|
1763 | if (s0 === peg$FAILED) {
|
1764 | s1 = peg$FAILED;
|
1765 | if (peg$silentFails === 0) { peg$fail(peg$c70); }
|
1766 | }
|
1767 |
|
1768 | return s0;
|
1769 | }
|
1770 |
|
1771 | function peg$parsewhitespace() {
|
1772 | var s0;
|
1773 |
|
1774 | s0 = peg$parseNewLine();
|
1775 | if (s0 === peg$FAILED) {
|
1776 | if (peg$c71.test(input.charAt(peg$currPos))) {
|
1777 | s0 = input.charAt(peg$currPos);
|
1778 | peg$currPos++;
|
1779 | } else {
|
1780 | s0 = peg$FAILED;
|
1781 | if (peg$silentFails === 0) { peg$fail(peg$c72); }
|
1782 | }
|
1783 | }
|
1784 |
|
1785 | return s0;
|
1786 | }
|
1787 |
|
1788 | function peg$parseNonLine() {
|
1789 | var s0, s1, s2;
|
1790 |
|
1791 | s0 = peg$currPos;
|
1792 | s1 = peg$currPos;
|
1793 | peg$silentFails++;
|
1794 | s2 = peg$parseNewLine();
|
1795 | peg$silentFails--;
|
1796 | if (s2 === peg$FAILED) {
|
1797 | s1 = void 0;
|
1798 | } else {
|
1799 | peg$currPos = s1;
|
1800 | s1 = peg$FAILED;
|
1801 | }
|
1802 | if (s1 !== peg$FAILED) {
|
1803 | s2 = peg$parseChar();
|
1804 | if (s2 !== peg$FAILED) {
|
1805 | peg$savedPos = s0;
|
1806 | s1 = peg$c53(s2);
|
1807 | s0 = s1;
|
1808 | } else {
|
1809 | peg$currPos = s0;
|
1810 | s0 = peg$FAILED;
|
1811 | }
|
1812 | } else {
|
1813 | peg$currPos = s0;
|
1814 | s0 = peg$FAILED;
|
1815 | }
|
1816 |
|
1817 | return s0;
|
1818 | }
|
1819 |
|
1820 | function peg$parseLineTerminator() {
|
1821 | var s0;
|
1822 |
|
1823 | s0 = peg$parseNewLine();
|
1824 | if (s0 === peg$FAILED) {
|
1825 | if (input.charCodeAt(peg$currPos) === 59) {
|
1826 | s0 = peg$c10;
|
1827 | peg$currPos++;
|
1828 | } else {
|
1829 | s0 = peg$FAILED;
|
1830 | if (peg$silentFails === 0) { peg$fail(peg$c11); }
|
1831 | }
|
1832 | }
|
1833 |
|
1834 | return s0;
|
1835 | }
|
1836 |
|
1837 | function peg$parseNewLine() {
|
1838 | var s0;
|
1839 |
|
1840 | if (peg$c73.test(input.charAt(peg$currPos))) {
|
1841 | s0 = input.charAt(peg$currPos);
|
1842 | peg$currPos++;
|
1843 | } else {
|
1844 | s0 = peg$FAILED;
|
1845 | if (peg$silentFails === 0) { peg$fail(peg$c74); }
|
1846 | }
|
1847 |
|
1848 | return s0;
|
1849 | }
|
1850 |
|
1851 | function peg$parseChar() {
|
1852 | var s0;
|
1853 |
|
1854 | if (input.length > peg$currPos) {
|
1855 | s0 = input.charAt(peg$currPos);
|
1856 | peg$currPos++;
|
1857 | } else {
|
1858 | s0 = peg$FAILED;
|
1859 | if (peg$silentFails === 0) { peg$fail(peg$c52); }
|
1860 | }
|
1861 |
|
1862 | return s0;
|
1863 | }
|
1864 |
|
1865 |
|
1866 | function merge_obj(obj, secondObj) {
|
1867 | if (!obj)
|
1868 | return secondObj;
|
1869 |
|
1870 | for(var i in secondObj)
|
1871 | obj[i] = merge_obj(obj[i], secondObj[i]);
|
1872 |
|
1873 | return obj;
|
1874 | }
|
1875 |
|
1876 |
|
1877 | peg$result = peg$startRuleFunction();
|
1878 |
|
1879 | if (peg$result !== peg$FAILED && peg$currPos === input.length) {
|
1880 | return peg$result;
|
1881 | } else {
|
1882 | if (peg$result !== peg$FAILED && peg$currPos < input.length) {
|
1883 | peg$fail(peg$endExpectation());
|
1884 | }
|
1885 |
|
1886 | throw peg$buildStructuredError(
|
1887 | peg$maxFailExpected,
|
1888 | peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,
|
1889 | peg$maxFailPos < input.length
|
1890 | ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)
|
1891 | : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)
|
1892 | );
|
1893 | }
|
1894 | }
|
1895 |
|
1896 | module.exports = {
|
1897 | SyntaxError: peg$SyntaxError,
|
1898 | parse: peg$parse
|
1899 | };
|