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