@weborigami/language 0.0.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/index.ts +30 -0
  2. package/main.js +21 -0
  3. package/package.json +24 -0
  4. package/src/compiler/code.d.ts +3 -0
  5. package/src/compiler/compile.js +55 -0
  6. package/src/compiler/origami.pegjs +277 -0
  7. package/src/compiler/parse.js +2292 -0
  8. package/src/compiler/parserHelpers.js +26 -0
  9. package/src/runtime/EventTargetMixin.d.ts +9 -0
  10. package/src/runtime/EventTargetMixin.js +117 -0
  11. package/src/runtime/ExpressionTree.js +20 -0
  12. package/src/runtime/FileLoadersTransform.d.ts +5 -0
  13. package/src/runtime/FileLoadersTransform.js +43 -0
  14. package/src/runtime/ImportModulesMixin.d.ts +5 -0
  15. package/src/runtime/ImportModulesMixin.js +48 -0
  16. package/src/runtime/InheritScopeMixin.js +34 -0
  17. package/src/runtime/InheritScopeMixin.ts +9 -0
  18. package/src/runtime/InvokeFunctionsTransform.d.ts +5 -0
  19. package/src/runtime/InvokeFunctionsTransform.js +27 -0
  20. package/src/runtime/OrigamiFiles.d.ts +11 -0
  21. package/src/runtime/OrigamiFiles.js +9 -0
  22. package/src/runtime/OrigamiTransform.d.ts +11 -0
  23. package/src/runtime/OrigamiTransform.js +11 -0
  24. package/src/runtime/OrigamiTree.js +4 -0
  25. package/src/runtime/ReadMe.md +1 -0
  26. package/src/runtime/Scope.js +89 -0
  27. package/src/runtime/TreeEvent.js +6 -0
  28. package/src/runtime/WatchFilesMixin.d.ts +5 -0
  29. package/src/runtime/WatchFilesMixin.js +58 -0
  30. package/src/runtime/concatTreeValues.js +46 -0
  31. package/src/runtime/evaluate.js +90 -0
  32. package/src/runtime/expressionFunction.js +33 -0
  33. package/src/runtime/extname.js +20 -0
  34. package/src/runtime/format.js +126 -0
  35. package/src/runtime/functionResultsMap.js +28 -0
  36. package/src/runtime/internal.js +20 -0
  37. package/src/runtime/ops.js +222 -0
  38. package/test/compiler/compile.test.js +64 -0
  39. package/test/compiler/parse.test.js +389 -0
  40. package/test/runtime/EventTargetMixin.test.js +68 -0
  41. package/test/runtime/ExpressionTree.test.js +27 -0
  42. package/test/runtime/FileLoadersTransform.test.js +41 -0
  43. package/test/runtime/InheritScopeMixin.test.js +29 -0
  44. package/test/runtime/OrigamiFiles.test.js +37 -0
  45. package/test/runtime/Scope.test.js +37 -0
  46. package/test/runtime/concatTreeValues.js +20 -0
  47. package/test/runtime/evaluate.test.js +55 -0
  48. package/test/runtime/fixtures/foo.js +1 -0
  49. package/test/runtime/fixtures/makeTest/a +1 -0
  50. package/test/runtime/fixtures/makeTest/b = a +0 -0
  51. package/test/runtime/fixtures/metagraphs/foo.txt +1 -0
  52. package/test/runtime/fixtures/metagraphs/greeting = this('world').js +3 -0
  53. package/test/runtime/fixtures/metagraphs/obj = this.json +5 -0
  54. package/test/runtime/fixtures/metagraphs/sample.txt = this().js +3 -0
  55. package/test/runtime/fixtures/metagraphs/string = this.json +1 -0
  56. package/test/runtime/fixtures/metagraphs/value = fn() +0 -0
  57. package/test/runtime/fixtures/programs/context.yaml +4 -0
  58. package/test/runtime/fixtures/programs/files.yaml +2 -0
  59. package/test/runtime/fixtures/programs/obj.yaml +3 -0
  60. package/test/runtime/fixtures/programs/simple.yaml +2 -0
  61. package/test/runtime/fixtures/subgraph = this.js +5 -0
  62. package/test/runtime/fixtures/templates/greet.orit +4 -0
  63. package/test/runtime/fixtures/templates/index.orit +15 -0
  64. package/test/runtime/fixtures/templates/names.yaml +3 -0
  65. package/test/runtime/fixtures/templates/plain.txt +1 -0
  66. package/test/runtime/fixtures/virtualKeys/.keys.json +1 -0
  67. package/test/runtime/format.test.js +66 -0
  68. package/test/runtime/functionResultsMap.test.js +27 -0
  69. package/test/runtime/ops.test.js +111 -0
@@ -0,0 +1,2292 @@
1
+ // Generated by Peggy 3.0.2.
2
+ //
3
+ // https://peggyjs.org/
4
+
5
+
6
+ //
7
+ // Origami language parser
8
+ //
9
+ // Generate the parser via `npm build`.
10
+ // @ts-nocheck
11
+ //
12
+
13
+ import * as ops from "../runtime/ops.js";
14
+ import { makeFunctionCall, makeTemplate } from "./parserHelpers.js";
15
+
16
+ function peg$subclass(child, parent) {
17
+ function C() { this.constructor = child; }
18
+ C.prototype = parent.prototype;
19
+ child.prototype = new C();
20
+ }
21
+
22
+ function peg$SyntaxError(message, expected, found, location) {
23
+ var self = Error.call(this, message);
24
+ // istanbul ignore next Check is a necessary evil to support older environments
25
+ if (Object.setPrototypeOf) {
26
+ Object.setPrototypeOf(self, peg$SyntaxError.prototype);
27
+ }
28
+ self.expected = expected;
29
+ self.found = found;
30
+ self.location = location;
31
+ self.name = "SyntaxError";
32
+ return self;
33
+ }
34
+
35
+ peg$subclass(peg$SyntaxError, Error);
36
+
37
+ function peg$padEnd(str, targetLength, padString) {
38
+ padString = padString || " ";
39
+ if (str.length > targetLength) { return str; }
40
+ targetLength -= str.length;
41
+ padString += padString.repeat(targetLength);
42
+ return str + padString.slice(0, targetLength);
43
+ }
44
+
45
+ peg$SyntaxError.prototype.format = function(sources) {
46
+ var str = "Error: " + this.message;
47
+ if (this.location) {
48
+ var src = null;
49
+ var k;
50
+ for (k = 0; k < sources.length; k++) {
51
+ if (sources[k].source === this.location.source) {
52
+ src = sources[k].text.split(/\r\n|\n|\r/g);
53
+ break;
54
+ }
55
+ }
56
+ var s = this.location.start;
57
+ var offset_s = (this.location.source && (typeof this.location.source.offset === "function"))
58
+ ? this.location.source.offset(s)
59
+ : s;
60
+ var loc = this.location.source + ":" + offset_s.line + ":" + offset_s.column;
61
+ if (src) {
62
+ var e = this.location.end;
63
+ var filler = peg$padEnd("", offset_s.line.toString().length, ' ');
64
+ var line = src[s.line - 1];
65
+ var last = s.line === e.line ? e.column : line.length + 1;
66
+ var hatLen = (last - s.column) || 1;
67
+ str += "\n --> " + loc + "\n"
68
+ + filler + " |\n"
69
+ + offset_s.line + " | " + line + "\n"
70
+ + filler + " | " + peg$padEnd("", s.column - 1, ' ')
71
+ + peg$padEnd("", hatLen, "^");
72
+ } else {
73
+ str += "\n at " + loc;
74
+ }
75
+ }
76
+ return str;
77
+ };
78
+
79
+ peg$SyntaxError.buildMessage = function(expected, found) {
80
+ var DESCRIBE_EXPECTATION_FNS = {
81
+ literal: function(expectation) {
82
+ return "\"" + literalEscape(expectation.text) + "\"";
83
+ },
84
+
85
+ class: function(expectation) {
86
+ var escapedParts = expectation.parts.map(function(part) {
87
+ return Array.isArray(part)
88
+ ? classEscape(part[0]) + "-" + classEscape(part[1])
89
+ : classEscape(part);
90
+ });
91
+
92
+ return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]";
93
+ },
94
+
95
+ any: function() {
96
+ return "any character";
97
+ },
98
+
99
+ end: function() {
100
+ return "end of input";
101
+ },
102
+
103
+ other: function(expectation) {
104
+ return expectation.description;
105
+ }
106
+ };
107
+
108
+ function hex(ch) {
109
+ return ch.charCodeAt(0).toString(16).toUpperCase();
110
+ }
111
+
112
+ function literalEscape(s) {
113
+ return s
114
+ .replace(/\\/g, "\\\\")
115
+ .replace(/"/g, "\\\"")
116
+ .replace(/\0/g, "\\0")
117
+ .replace(/\t/g, "\\t")
118
+ .replace(/\n/g, "\\n")
119
+ .replace(/\r/g, "\\r")
120
+ .replace(/[\x00-\x0F]/g, function(ch) { return "\\x0" + hex(ch); })
121
+ .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return "\\x" + hex(ch); });
122
+ }
123
+
124
+ function classEscape(s) {
125
+ return s
126
+ .replace(/\\/g, "\\\\")
127
+ .replace(/\]/g, "\\]")
128
+ .replace(/\^/g, "\\^")
129
+ .replace(/-/g, "\\-")
130
+ .replace(/\0/g, "\\0")
131
+ .replace(/\t/g, "\\t")
132
+ .replace(/\n/g, "\\n")
133
+ .replace(/\r/g, "\\r")
134
+ .replace(/[\x00-\x0F]/g, function(ch) { return "\\x0" + hex(ch); })
135
+ .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return "\\x" + hex(ch); });
136
+ }
137
+
138
+ function describeExpectation(expectation) {
139
+ return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
140
+ }
141
+
142
+ function describeExpected(expected) {
143
+ var descriptions = expected.map(describeExpectation);
144
+ var i, j;
145
+
146
+ descriptions.sort();
147
+
148
+ if (descriptions.length > 0) {
149
+ for (i = 1, j = 1; i < descriptions.length; i++) {
150
+ if (descriptions[i - 1] !== descriptions[i]) {
151
+ descriptions[j] = descriptions[i];
152
+ j++;
153
+ }
154
+ }
155
+ descriptions.length = j;
156
+ }
157
+
158
+ switch (descriptions.length) {
159
+ case 1:
160
+ return descriptions[0];
161
+
162
+ case 2:
163
+ return descriptions[0] + " or " + descriptions[1];
164
+
165
+ default:
166
+ return descriptions.slice(0, -1).join(", ")
167
+ + ", or "
168
+ + descriptions[descriptions.length - 1];
169
+ }
170
+ }
171
+
172
+ function describeFound(found) {
173
+ return found ? "\"" + literalEscape(found) + "\"" : "end of input";
174
+ }
175
+
176
+ return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
177
+ };
178
+
179
+ function peg$parse(input, options) {
180
+ options = options !== undefined ? options : {};
181
+
182
+ var peg$FAILED = {};
183
+ var peg$source = options.grammarSource;
184
+
185
+ var peg$startRuleFunctions = { __: peg$parse__, absoluteFilePath: peg$parseabsoluteFilePath, argsChain: peg$parseargsChain, assignment: peg$parseassignment, assignmentOrShorthand: peg$parseassignmentOrShorthand, array: peg$parsearray, callTarget: peg$parsecallTarget, comment: peg$parsecomment, digits: peg$parsedigits, doubleQuoteString: peg$parsedoubleQuoteString, doubleQuoteStringChar: peg$parsedoubleQuoteStringChar, escapedChar: peg$parseescapedChar, expr: peg$parseexpr, expression: peg$parseexpression, float: peg$parsefloat, functionComposition: peg$parsefunctionComposition, group: peg$parsegroup, identifier: peg$parseidentifier, identifierChar: peg$parseidentifierChar, implicitParensCall: peg$parseimplicitParensCall, host: peg$parsehost, inlineSpace: peg$parseinlineSpace, integer: peg$parseinteger, lambda: peg$parselambda, leadingSlashPath: peg$parseleadingSlashPath, list: peg$parselist, newLine: peg$parsenewLine, number: peg$parsenumber, object: peg$parseobject, objectProperties: peg$parseobjectProperties, objectProperty: peg$parseobjectProperty, objectPropertyOrShorthand: peg$parseobjectPropertyOrShorthand, parensArgs: peg$parseparensArgs, separator: peg$parseseparator, sign: peg$parsesign, path: peg$parsepath, pathKey: peg$parsepathKey, protocolCall: peg$parseprotocolCall, protocol: peg$parseprotocol, reservedProtocol: peg$parsereservedProtocol, scopeReference: peg$parsescopeReference, singleQuoteString: peg$parsesingleQuoteString, singleQuoteStringChar: peg$parsesingleQuoteStringChar, start: peg$parsestart, string: peg$parsestring, templateDocument: peg$parsetemplateDocument, templateDocumentChar: peg$parsetemplateDocumentChar, templateDocumentContents: peg$parsetemplateDocumentContents, templateDocumentText: peg$parsetemplateDocumentText, templateLiteral: peg$parsetemplateLiteral, templateLiteralChar: peg$parsetemplateLiteralChar, templateLiteralContents: peg$parsetemplateLiteralContents, templateLiteralText: peg$parsetemplateLiteralText, templateSubstitution: peg$parsetemplateSubstitution, textChar: peg$parsetextChar, tree: peg$parsetree, treeAssignments: peg$parsetreeAssignments, whitespaceWithNewLine: peg$parsewhitespaceWithNewLine };
186
+ var peg$startRuleFunction = peg$parse__;
187
+
188
+ var peg$c0 = "=";
189
+ var peg$c1 = "[";
190
+ var peg$c2 = "]";
191
+ var peg$c3 = "#";
192
+ var peg$c4 = "\"";
193
+ var peg$c5 = "\\";
194
+ var peg$c6 = ".";
195
+ var peg$c7 = "(";
196
+ var peg$c8 = ")";
197
+ var peg$c9 = ":";
198
+ var peg$c10 = "/";
199
+ var peg$c11 = "\n";
200
+ var peg$c12 = "\r\n";
201
+ var peg$c13 = "\r";
202
+ var peg$c14 = "{";
203
+ var peg$c15 = "}";
204
+ var peg$c16 = ",";
205
+ var peg$c17 = "https";
206
+ var peg$c18 = "http";
207
+ var peg$c19 = "treehttps";
208
+ var peg$c20 = "treehttp";
209
+ var peg$c21 = "tree";
210
+ var peg$c22 = "'";
211
+ var peg$c23 = "{{";
212
+ var peg$c24 = "`";
213
+ var peg$c25 = "}}";
214
+
215
+ var peg$r0 = /^[^\n\r]/;
216
+ var peg$r1 = /^[0-9]/;
217
+ var peg$r2 = /^[^(){}[\],\/:=`"'\\# \t\n\r]/;
218
+ var peg$r3 = /^[ \t]/;
219
+ var peg$r4 = /^[+\-]/;
220
+
221
+ var peg$e0 = peg$literalExpectation("=", false);
222
+ var peg$e1 = peg$literalExpectation("[", false);
223
+ var peg$e2 = peg$literalExpectation("]", false);
224
+ var peg$e3 = peg$literalExpectation("#", false);
225
+ var peg$e4 = peg$classExpectation(["\n", "\r"], true, false);
226
+ var peg$e5 = peg$classExpectation([["0", "9"]], false, false);
227
+ var peg$e6 = peg$literalExpectation("\"", false);
228
+ var peg$e7 = peg$literalExpectation("\\", false);
229
+ var peg$e8 = peg$anyExpectation();
230
+ var peg$e9 = peg$otherExpectation("Origami expression");
231
+ var peg$e10 = peg$literalExpectation(".", false);
232
+ var peg$e11 = peg$literalExpectation("(", false);
233
+ var peg$e12 = peg$literalExpectation(")", false);
234
+ var peg$e13 = peg$classExpectation(["(", ")", "{", "}", "[", "]", ",", "/", ":", "=", "`", "\"", "'", "\\", "#", " ", "\t", "\n", "\r"], true, false);
235
+ var peg$e14 = peg$literalExpectation(":", false);
236
+ var peg$e15 = peg$classExpectation([" ", "\t"], false, false);
237
+ var peg$e16 = peg$literalExpectation("/", false);
238
+ var peg$e17 = peg$literalExpectation("\n", false);
239
+ var peg$e18 = peg$literalExpectation("\r\n", false);
240
+ var peg$e19 = peg$literalExpectation("\r", false);
241
+ var peg$e20 = peg$literalExpectation("{", false);
242
+ var peg$e21 = peg$literalExpectation("}", false);
243
+ var peg$e22 = peg$literalExpectation(",", false);
244
+ var peg$e23 = peg$classExpectation(["+", "-"], false, false);
245
+ var peg$e24 = peg$literalExpectation("https", false);
246
+ var peg$e25 = peg$literalExpectation("http", false);
247
+ var peg$e26 = peg$literalExpectation("treehttps", false);
248
+ var peg$e27 = peg$literalExpectation("treehttp", false);
249
+ var peg$e28 = peg$literalExpectation("tree", false);
250
+ var peg$e29 = peg$literalExpectation("'", false);
251
+ var peg$e30 = peg$otherExpectation("Origami template");
252
+ var peg$e31 = peg$literalExpectation("{{", false);
253
+ var peg$e32 = peg$literalExpectation("`", false);
254
+ var peg$e33 = peg$literalExpectation("}}", false);
255
+
256
+ var peg$f0 = function() { return ""; };
257
+ var peg$f1 = function(path) { return [[ops.filesRoot], ...path]; };
258
+ var peg$f2 = function(parts) { return parts; };
259
+ var peg$f3 = function(key) { return [key, [ops.inherited, key]]; };
260
+ var peg$f4 = function(list) { return [ops.array, ...(list ?? [])]; };
261
+ var peg$f5 = function(chars) { return chars.join(""); };
262
+ var peg$f6 = function() {
263
+ return parseFloat(text());
264
+ };
265
+ var peg$f7 = function(target, chain) { return makeFunctionCall(target, chain); };
266
+ var peg$f8 = function(chars) { return chars.join(""); };
267
+ var peg$f9 = function(target, args) {
268
+ return [target, ...args];
269
+ };
270
+ var peg$f10 = function() { return text(); };
271
+ var peg$f11 = function() {
272
+ return parseInt(text());
273
+ };
274
+ var peg$f12 = function(expr) { return [ops.lambda, expr]; };
275
+ var peg$f13 = function() { return [""]; };
276
+ var peg$f14 = function(head, tail) { return [head].concat(tail); };
277
+ var peg$f15 = function(properties) { return [ops.object, ...(properties ?? [])]; };
278
+ var peg$f16 = function(head, tail) {
279
+ return [head].concat(tail);
280
+ };
281
+ var peg$f17 = function(key) { return [key, [ops.inherited, key]]; };
282
+ var peg$f18 = function(list) { return list ?? [undefined]; };
283
+ var peg$f19 = function(head, tail) { return [head].concat(tail); };
284
+ var peg$f20 = function(key) { return [key]; };
285
+ var peg$f21 = function(key) { return key.join(""); };
286
+ var peg$f22 = function(protocol, host, path) {
287
+ return [protocol, host, ...(path ?? [])];
288
+ };
289
+ var peg$f23 = function() { return ops.https; };
290
+ var peg$f24 = function() { return ops.http; };
291
+ var peg$f25 = function() { return ops.treeHttps; };
292
+ var peg$f26 = function() { return ops.treeHttp; };
293
+ var peg$f27 = function() { return ops.treeHttps; };
294
+ var peg$f28 = function(key) { return [ops.scope, key]; };
295
+ var peg$f29 = function(chars) { return chars.join(""); };
296
+ var peg$f30 = function(contents) { return [ops.lambda, contents]; };
297
+ var peg$f31 = function(parts) { return makeTemplate(parts); };
298
+ var peg$f32 = function(chars) { return chars.join(""); };
299
+ var peg$f33 = function(parts) { return makeTemplate(parts); };
300
+ var peg$f34 = function(chars) { return chars.join(""); };
301
+ var peg$f35 = function(assignments) { return [ops.tree, ...(assignments ?? [])]; };
302
+ var peg$f36 = function(head, tail) {
303
+ return [head].concat(tail);
304
+ };
305
+ var peg$currPos = 0;
306
+ var peg$savedPos = 0;
307
+ var peg$posDetailsCache = [{ line: 1, column: 1 }];
308
+ var peg$maxFailPos = 0;
309
+ var peg$maxFailExpected = [];
310
+ var peg$silentFails = 0;
311
+
312
+ var peg$result;
313
+
314
+ if ("startRule" in options) {
315
+ if (!(options.startRule in peg$startRuleFunctions)) {
316
+ throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
317
+ }
318
+
319
+ peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
320
+ }
321
+
322
+ function text() {
323
+ return input.substring(peg$savedPos, peg$currPos);
324
+ }
325
+
326
+ function offset() {
327
+ return peg$savedPos;
328
+ }
329
+
330
+ function range() {
331
+ return {
332
+ source: peg$source,
333
+ start: peg$savedPos,
334
+ end: peg$currPos
335
+ };
336
+ }
337
+
338
+ function location() {
339
+ return peg$computeLocation(peg$savedPos, peg$currPos);
340
+ }
341
+
342
+ function expected(description, location) {
343
+ location = location !== undefined
344
+ ? location
345
+ : peg$computeLocation(peg$savedPos, peg$currPos);
346
+
347
+ throw peg$buildStructuredError(
348
+ [peg$otherExpectation(description)],
349
+ input.substring(peg$savedPos, peg$currPos),
350
+ location
351
+ );
352
+ }
353
+
354
+ function error(message, location) {
355
+ location = location !== undefined
356
+ ? location
357
+ : peg$computeLocation(peg$savedPos, peg$currPos);
358
+
359
+ throw peg$buildSimpleError(message, location);
360
+ }
361
+
362
+ function peg$literalExpectation(text, ignoreCase) {
363
+ return { type: "literal", text: text, ignoreCase: ignoreCase };
364
+ }
365
+
366
+ function peg$classExpectation(parts, inverted, ignoreCase) {
367
+ return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase };
368
+ }
369
+
370
+ function peg$anyExpectation() {
371
+ return { type: "any" };
372
+ }
373
+
374
+ function peg$endExpectation() {
375
+ return { type: "end" };
376
+ }
377
+
378
+ function peg$otherExpectation(description) {
379
+ return { type: "other", description: description };
380
+ }
381
+
382
+ function peg$computePosDetails(pos) {
383
+ var details = peg$posDetailsCache[pos];
384
+ var p;
385
+
386
+ if (details) {
387
+ return details;
388
+ } else {
389
+ p = pos - 1;
390
+ while (!peg$posDetailsCache[p]) {
391
+ p--;
392
+ }
393
+
394
+ details = peg$posDetailsCache[p];
395
+ details = {
396
+ line: details.line,
397
+ column: details.column
398
+ };
399
+
400
+ while (p < pos) {
401
+ if (input.charCodeAt(p) === 10) {
402
+ details.line++;
403
+ details.column = 1;
404
+ } else {
405
+ details.column++;
406
+ }
407
+
408
+ p++;
409
+ }
410
+
411
+ peg$posDetailsCache[pos] = details;
412
+
413
+ return details;
414
+ }
415
+ }
416
+
417
+ function peg$computeLocation(startPos, endPos, offset) {
418
+ var startPosDetails = peg$computePosDetails(startPos);
419
+ var endPosDetails = peg$computePosDetails(endPos);
420
+
421
+ var res = {
422
+ source: peg$source,
423
+ start: {
424
+ offset: startPos,
425
+ line: startPosDetails.line,
426
+ column: startPosDetails.column
427
+ },
428
+ end: {
429
+ offset: endPos,
430
+ line: endPosDetails.line,
431
+ column: endPosDetails.column
432
+ }
433
+ };
434
+ if (offset && peg$source && (typeof peg$source.offset === "function")) {
435
+ res.start = peg$source.offset(res.start);
436
+ res.end = peg$source.offset(res.end);
437
+ }
438
+ return res;
439
+ }
440
+
441
+ function peg$fail(expected) {
442
+ if (peg$currPos < peg$maxFailPos) { return; }
443
+
444
+ if (peg$currPos > peg$maxFailPos) {
445
+ peg$maxFailPos = peg$currPos;
446
+ peg$maxFailExpected = [];
447
+ }
448
+
449
+ peg$maxFailExpected.push(expected);
450
+ }
451
+
452
+ function peg$buildSimpleError(message, location) {
453
+ return new peg$SyntaxError(message, null, null, location);
454
+ }
455
+
456
+ function peg$buildStructuredError(expected, found, location) {
457
+ return new peg$SyntaxError(
458
+ peg$SyntaxError.buildMessage(expected, found),
459
+ expected,
460
+ found,
461
+ location
462
+ );
463
+ }
464
+
465
+ function peg$parse__() {
466
+ var s0, s1, s2;
467
+
468
+ s0 = peg$currPos;
469
+ s1 = [];
470
+ s2 = peg$parseinlineSpace();
471
+ if (s2 === peg$FAILED) {
472
+ s2 = peg$parsenewLine();
473
+ if (s2 === peg$FAILED) {
474
+ s2 = peg$parsecomment();
475
+ }
476
+ }
477
+ while (s2 !== peg$FAILED) {
478
+ s1.push(s2);
479
+ s2 = peg$parseinlineSpace();
480
+ if (s2 === peg$FAILED) {
481
+ s2 = peg$parsenewLine();
482
+ if (s2 === peg$FAILED) {
483
+ s2 = peg$parsecomment();
484
+ }
485
+ }
486
+ }
487
+ peg$savedPos = s0;
488
+ s1 = peg$f0();
489
+ s0 = s1;
490
+
491
+ return s0;
492
+ }
493
+
494
+ function peg$parseabsoluteFilePath() {
495
+ var s0, s1;
496
+
497
+ s0 = peg$currPos;
498
+ s1 = peg$parseleadingSlashPath();
499
+ if (s1 !== peg$FAILED) {
500
+ peg$savedPos = s0;
501
+ s1 = peg$f1(s1);
502
+ }
503
+ s0 = s1;
504
+
505
+ return s0;
506
+ }
507
+
508
+ function peg$parseargsChain() {
509
+ var s0, s1, s2;
510
+
511
+ s0 = peg$currPos;
512
+ s1 = [];
513
+ s2 = peg$parseparensArgs();
514
+ if (s2 === peg$FAILED) {
515
+ s2 = peg$parseleadingSlashPath();
516
+ }
517
+ if (s2 !== peg$FAILED) {
518
+ while (s2 !== peg$FAILED) {
519
+ s1.push(s2);
520
+ s2 = peg$parseparensArgs();
521
+ if (s2 === peg$FAILED) {
522
+ s2 = peg$parseleadingSlashPath();
523
+ }
524
+ }
525
+ } else {
526
+ s1 = peg$FAILED;
527
+ }
528
+ if (s1 !== peg$FAILED) {
529
+ peg$savedPos = s0;
530
+ s1 = peg$f2(s1);
531
+ }
532
+ s0 = s1;
533
+
534
+ return s0;
535
+ }
536
+
537
+ function peg$parseassignment() {
538
+ var s0, s1, s2, s3, s4, s5;
539
+
540
+ s0 = peg$currPos;
541
+ s1 = peg$parseidentifier();
542
+ if (s1 !== peg$FAILED) {
543
+ s2 = peg$parse__();
544
+ if (input.charCodeAt(peg$currPos) === 61) {
545
+ s3 = peg$c0;
546
+ peg$currPos++;
547
+ } else {
548
+ s3 = peg$FAILED;
549
+ if (peg$silentFails === 0) { peg$fail(peg$e0); }
550
+ }
551
+ if (s3 !== peg$FAILED) {
552
+ s4 = peg$parse__();
553
+ s5 = peg$parseexpr();
554
+ if (s5 !== peg$FAILED) {
555
+ s0 = [ s1, s5 ];
556
+ } else {
557
+ peg$currPos = s0;
558
+ s0 = peg$FAILED;
559
+ }
560
+ } else {
561
+ peg$currPos = s0;
562
+ s0 = peg$FAILED;
563
+ }
564
+ } else {
565
+ peg$currPos = s0;
566
+ s0 = peg$FAILED;
567
+ }
568
+
569
+ return s0;
570
+ }
571
+
572
+ function peg$parseassignmentOrShorthand() {
573
+ var s0, s1;
574
+
575
+ s0 = peg$parseassignment();
576
+ if (s0 === peg$FAILED) {
577
+ s0 = peg$currPos;
578
+ s1 = peg$parseidentifier();
579
+ if (s1 !== peg$FAILED) {
580
+ peg$savedPos = s0;
581
+ s1 = peg$f3(s1);
582
+ }
583
+ s0 = s1;
584
+ }
585
+
586
+ return s0;
587
+ }
588
+
589
+ function peg$parsearray() {
590
+ var s0, s1, s2, s3, s4;
591
+
592
+ s0 = peg$currPos;
593
+ if (input.charCodeAt(peg$currPos) === 91) {
594
+ s1 = peg$c1;
595
+ peg$currPos++;
596
+ } else {
597
+ s1 = peg$FAILED;
598
+ if (peg$silentFails === 0) { peg$fail(peg$e1); }
599
+ }
600
+ if (s1 !== peg$FAILED) {
601
+ s2 = peg$parse__();
602
+ s3 = peg$parselist();
603
+ if (s3 === peg$FAILED) {
604
+ s3 = null;
605
+ }
606
+ if (input.charCodeAt(peg$currPos) === 93) {
607
+ s4 = peg$c2;
608
+ peg$currPos++;
609
+ } else {
610
+ s4 = peg$FAILED;
611
+ if (peg$silentFails === 0) { peg$fail(peg$e2); }
612
+ }
613
+ if (s4 !== peg$FAILED) {
614
+ peg$savedPos = s0;
615
+ s0 = peg$f4(s3);
616
+ } else {
617
+ peg$currPos = s0;
618
+ s0 = peg$FAILED;
619
+ }
620
+ } else {
621
+ peg$currPos = s0;
622
+ s0 = peg$FAILED;
623
+ }
624
+
625
+ return s0;
626
+ }
627
+
628
+ function peg$parsecallTarget() {
629
+ var s0;
630
+
631
+ s0 = peg$parseabsoluteFilePath();
632
+ if (s0 === peg$FAILED) {
633
+ s0 = peg$parsearray();
634
+ if (s0 === peg$FAILED) {
635
+ s0 = peg$parseobject();
636
+ if (s0 === peg$FAILED) {
637
+ s0 = peg$parsetree();
638
+ if (s0 === peg$FAILED) {
639
+ s0 = peg$parselambda();
640
+ if (s0 === peg$FAILED) {
641
+ s0 = peg$parseprotocolCall();
642
+ if (s0 === peg$FAILED) {
643
+ s0 = peg$parsegroup();
644
+ if (s0 === peg$FAILED) {
645
+ s0 = peg$parsescopeReference();
646
+ }
647
+ }
648
+ }
649
+ }
650
+ }
651
+ }
652
+ }
653
+
654
+ return s0;
655
+ }
656
+
657
+ function peg$parsecomment() {
658
+ var s0, s1, s2, s3;
659
+
660
+ s0 = peg$currPos;
661
+ if (input.charCodeAt(peg$currPos) === 35) {
662
+ s1 = peg$c3;
663
+ peg$currPos++;
664
+ } else {
665
+ s1 = peg$FAILED;
666
+ if (peg$silentFails === 0) { peg$fail(peg$e3); }
667
+ }
668
+ if (s1 !== peg$FAILED) {
669
+ s2 = [];
670
+ if (peg$r0.test(input.charAt(peg$currPos))) {
671
+ s3 = input.charAt(peg$currPos);
672
+ peg$currPos++;
673
+ } else {
674
+ s3 = peg$FAILED;
675
+ if (peg$silentFails === 0) { peg$fail(peg$e4); }
676
+ }
677
+ while (s3 !== peg$FAILED) {
678
+ s2.push(s3);
679
+ if (peg$r0.test(input.charAt(peg$currPos))) {
680
+ s3 = input.charAt(peg$currPos);
681
+ peg$currPos++;
682
+ } else {
683
+ s3 = peg$FAILED;
684
+ if (peg$silentFails === 0) { peg$fail(peg$e4); }
685
+ }
686
+ }
687
+ s1 = [s1, s2];
688
+ s0 = s1;
689
+ } else {
690
+ peg$currPos = s0;
691
+ s0 = peg$FAILED;
692
+ }
693
+
694
+ return s0;
695
+ }
696
+
697
+ function peg$parsedigits() {
698
+ var s0, s1, s2;
699
+
700
+ s0 = peg$currPos;
701
+ s1 = [];
702
+ if (peg$r1.test(input.charAt(peg$currPos))) {
703
+ s2 = input.charAt(peg$currPos);
704
+ peg$currPos++;
705
+ } else {
706
+ s2 = peg$FAILED;
707
+ if (peg$silentFails === 0) { peg$fail(peg$e5); }
708
+ }
709
+ if (s2 !== peg$FAILED) {
710
+ while (s2 !== peg$FAILED) {
711
+ s1.push(s2);
712
+ if (peg$r1.test(input.charAt(peg$currPos))) {
713
+ s2 = input.charAt(peg$currPos);
714
+ peg$currPos++;
715
+ } else {
716
+ s2 = peg$FAILED;
717
+ if (peg$silentFails === 0) { peg$fail(peg$e5); }
718
+ }
719
+ }
720
+ } else {
721
+ s1 = peg$FAILED;
722
+ }
723
+ if (s1 !== peg$FAILED) {
724
+ s0 = s1;
725
+ } else {
726
+ peg$currPos = s0;
727
+ s0 = peg$FAILED;
728
+ }
729
+
730
+ return s0;
731
+ }
732
+
733
+ function peg$parsedoubleQuoteString() {
734
+ var s0, s1, s2, s3;
735
+
736
+ s0 = peg$currPos;
737
+ if (input.charCodeAt(peg$currPos) === 34) {
738
+ s1 = peg$c4;
739
+ peg$currPos++;
740
+ } else {
741
+ s1 = peg$FAILED;
742
+ if (peg$silentFails === 0) { peg$fail(peg$e6); }
743
+ }
744
+ if (s1 !== peg$FAILED) {
745
+ s2 = [];
746
+ s3 = peg$parsedoubleQuoteStringChar();
747
+ while (s3 !== peg$FAILED) {
748
+ s2.push(s3);
749
+ s3 = peg$parsedoubleQuoteStringChar();
750
+ }
751
+ if (input.charCodeAt(peg$currPos) === 34) {
752
+ s3 = peg$c4;
753
+ peg$currPos++;
754
+ } else {
755
+ s3 = peg$FAILED;
756
+ if (peg$silentFails === 0) { peg$fail(peg$e6); }
757
+ }
758
+ if (s3 !== peg$FAILED) {
759
+ peg$savedPos = s0;
760
+ s0 = peg$f5(s2);
761
+ } else {
762
+ peg$currPos = s0;
763
+ s0 = peg$FAILED;
764
+ }
765
+ } else {
766
+ peg$currPos = s0;
767
+ s0 = peg$FAILED;
768
+ }
769
+
770
+ return s0;
771
+ }
772
+
773
+ function peg$parsedoubleQuoteStringChar() {
774
+ var s0, s1, s2;
775
+
776
+ s0 = peg$currPos;
777
+ s1 = peg$currPos;
778
+ peg$silentFails++;
779
+ if (input.charCodeAt(peg$currPos) === 34) {
780
+ s2 = peg$c4;
781
+ peg$currPos++;
782
+ } else {
783
+ s2 = peg$FAILED;
784
+ if (peg$silentFails === 0) { peg$fail(peg$e6); }
785
+ }
786
+ if (s2 === peg$FAILED) {
787
+ s2 = peg$parsenewLine();
788
+ }
789
+ peg$silentFails--;
790
+ if (s2 === peg$FAILED) {
791
+ s1 = undefined;
792
+ } else {
793
+ peg$currPos = s1;
794
+ s1 = peg$FAILED;
795
+ }
796
+ if (s1 !== peg$FAILED) {
797
+ s2 = peg$parsetextChar();
798
+ if (s2 !== peg$FAILED) {
799
+ s0 = s2;
800
+ } else {
801
+ peg$currPos = s0;
802
+ s0 = peg$FAILED;
803
+ }
804
+ } else {
805
+ peg$currPos = s0;
806
+ s0 = peg$FAILED;
807
+ }
808
+
809
+ return s0;
810
+ }
811
+
812
+ function peg$parseescapedChar() {
813
+ var s0, s1, s2;
814
+
815
+ s0 = peg$currPos;
816
+ if (input.charCodeAt(peg$currPos) === 92) {
817
+ s1 = peg$c5;
818
+ peg$currPos++;
819
+ } else {
820
+ s1 = peg$FAILED;
821
+ if (peg$silentFails === 0) { peg$fail(peg$e7); }
822
+ }
823
+ if (s1 !== peg$FAILED) {
824
+ if (input.length > peg$currPos) {
825
+ s2 = input.charAt(peg$currPos);
826
+ peg$currPos++;
827
+ } else {
828
+ s2 = peg$FAILED;
829
+ if (peg$silentFails === 0) { peg$fail(peg$e8); }
830
+ }
831
+ if (s2 !== peg$FAILED) {
832
+ s0 = s2;
833
+ } else {
834
+ peg$currPos = s0;
835
+ s0 = peg$FAILED;
836
+ }
837
+ } else {
838
+ peg$currPos = s0;
839
+ s0 = peg$FAILED;
840
+ }
841
+
842
+ return s0;
843
+ }
844
+
845
+ function peg$parseexpr() {
846
+ var s0;
847
+
848
+ s0 = peg$parseimplicitParensCall();
849
+ if (s0 === peg$FAILED) {
850
+ s0 = peg$parsefunctionComposition();
851
+ if (s0 === peg$FAILED) {
852
+ s0 = peg$parseabsoluteFilePath();
853
+ if (s0 === peg$FAILED) {
854
+ s0 = peg$parsearray();
855
+ if (s0 === peg$FAILED) {
856
+ s0 = peg$parseobject();
857
+ if (s0 === peg$FAILED) {
858
+ s0 = peg$parsetree();
859
+ if (s0 === peg$FAILED) {
860
+ s0 = peg$parselambda();
861
+ if (s0 === peg$FAILED) {
862
+ s0 = peg$parsetemplateLiteral();
863
+ if (s0 === peg$FAILED) {
864
+ s0 = peg$parsegroup();
865
+ if (s0 === peg$FAILED) {
866
+ s0 = peg$parsestring();
867
+ if (s0 === peg$FAILED) {
868
+ s0 = peg$parsenumber();
869
+ if (s0 === peg$FAILED) {
870
+ s0 = peg$parseprotocolCall();
871
+ if (s0 === peg$FAILED) {
872
+ s0 = peg$parsescopeReference();
873
+ }
874
+ }
875
+ }
876
+ }
877
+ }
878
+ }
879
+ }
880
+ }
881
+ }
882
+ }
883
+ }
884
+ }
885
+
886
+ return s0;
887
+ }
888
+
889
+ function peg$parseexpression() {
890
+ var s0, s1, s2, s3;
891
+
892
+ peg$silentFails++;
893
+ s0 = peg$currPos;
894
+ s1 = peg$parse__();
895
+ s2 = peg$parseexpr();
896
+ if (s2 !== peg$FAILED) {
897
+ s3 = peg$parse__();
898
+ s0 = s2;
899
+ } else {
900
+ peg$currPos = s0;
901
+ s0 = peg$FAILED;
902
+ }
903
+ peg$silentFails--;
904
+ if (s0 === peg$FAILED) {
905
+ s1 = peg$FAILED;
906
+ if (peg$silentFails === 0) { peg$fail(peg$e9); }
907
+ }
908
+
909
+ return s0;
910
+ }
911
+
912
+ function peg$parsefloat() {
913
+ var s0, s1, s2, s3, s4;
914
+
915
+ s0 = peg$currPos;
916
+ s1 = peg$parsesign();
917
+ if (s1 === peg$FAILED) {
918
+ s1 = null;
919
+ }
920
+ s2 = peg$parsedigits();
921
+ if (s2 === peg$FAILED) {
922
+ s2 = null;
923
+ }
924
+ if (input.charCodeAt(peg$currPos) === 46) {
925
+ s3 = peg$c6;
926
+ peg$currPos++;
927
+ } else {
928
+ s3 = peg$FAILED;
929
+ if (peg$silentFails === 0) { peg$fail(peg$e10); }
930
+ }
931
+ if (s3 !== peg$FAILED) {
932
+ s4 = peg$parsedigits();
933
+ if (s4 !== peg$FAILED) {
934
+ peg$savedPos = s0;
935
+ s0 = peg$f6();
936
+ } else {
937
+ peg$currPos = s0;
938
+ s0 = peg$FAILED;
939
+ }
940
+ } else {
941
+ peg$currPos = s0;
942
+ s0 = peg$FAILED;
943
+ }
944
+
945
+ return s0;
946
+ }
947
+
948
+ function peg$parsefunctionComposition() {
949
+ var s0, s1, s2;
950
+
951
+ s0 = peg$currPos;
952
+ s1 = peg$parsecallTarget();
953
+ if (s1 !== peg$FAILED) {
954
+ s2 = peg$parseargsChain();
955
+ if (s2 !== peg$FAILED) {
956
+ peg$savedPos = s0;
957
+ s0 = peg$f7(s1, s2);
958
+ } else {
959
+ peg$currPos = s0;
960
+ s0 = peg$FAILED;
961
+ }
962
+ } else {
963
+ peg$currPos = s0;
964
+ s0 = peg$FAILED;
965
+ }
966
+
967
+ return s0;
968
+ }
969
+
970
+ function peg$parsegroup() {
971
+ var s0, s1, s2, s3, s4, s5;
972
+
973
+ s0 = peg$currPos;
974
+ if (input.charCodeAt(peg$currPos) === 40) {
975
+ s1 = peg$c7;
976
+ peg$currPos++;
977
+ } else {
978
+ s1 = peg$FAILED;
979
+ if (peg$silentFails === 0) { peg$fail(peg$e11); }
980
+ }
981
+ if (s1 !== peg$FAILED) {
982
+ s2 = peg$parse__();
983
+ s3 = peg$parseexpr();
984
+ if (s3 !== peg$FAILED) {
985
+ s4 = peg$parse__();
986
+ if (input.charCodeAt(peg$currPos) === 41) {
987
+ s5 = peg$c8;
988
+ peg$currPos++;
989
+ } else {
990
+ s5 = peg$FAILED;
991
+ if (peg$silentFails === 0) { peg$fail(peg$e12); }
992
+ }
993
+ if (s5 !== peg$FAILED) {
994
+ s0 = s3;
995
+ } else {
996
+ peg$currPos = s0;
997
+ s0 = peg$FAILED;
998
+ }
999
+ } else {
1000
+ peg$currPos = s0;
1001
+ s0 = peg$FAILED;
1002
+ }
1003
+ } else {
1004
+ peg$currPos = s0;
1005
+ s0 = peg$FAILED;
1006
+ }
1007
+
1008
+ return s0;
1009
+ }
1010
+
1011
+ function peg$parseidentifier() {
1012
+ var s0, s1, s2;
1013
+
1014
+ s0 = peg$currPos;
1015
+ s1 = [];
1016
+ s2 = peg$parseidentifierChar();
1017
+ if (s2 !== peg$FAILED) {
1018
+ while (s2 !== peg$FAILED) {
1019
+ s1.push(s2);
1020
+ s2 = peg$parseidentifierChar();
1021
+ }
1022
+ } else {
1023
+ s1 = peg$FAILED;
1024
+ }
1025
+ if (s1 !== peg$FAILED) {
1026
+ peg$savedPos = s0;
1027
+ s1 = peg$f8(s1);
1028
+ }
1029
+ s0 = s1;
1030
+
1031
+ return s0;
1032
+ }
1033
+
1034
+ function peg$parseidentifierChar() {
1035
+ var s0;
1036
+
1037
+ if (peg$r2.test(input.charAt(peg$currPos))) {
1038
+ s0 = input.charAt(peg$currPos);
1039
+ peg$currPos++;
1040
+ } else {
1041
+ s0 = peg$FAILED;
1042
+ if (peg$silentFails === 0) { peg$fail(peg$e13); }
1043
+ }
1044
+ if (s0 === peg$FAILED) {
1045
+ s0 = peg$parseescapedChar();
1046
+ }
1047
+
1048
+ return s0;
1049
+ }
1050
+
1051
+ function peg$parseimplicitParensCall() {
1052
+ var s0, s1, s2, s3;
1053
+
1054
+ s0 = peg$currPos;
1055
+ s1 = peg$parsefunctionComposition();
1056
+ if (s1 === peg$FAILED) {
1057
+ s1 = peg$parsecallTarget();
1058
+ }
1059
+ if (s1 !== peg$FAILED) {
1060
+ s2 = [];
1061
+ s3 = peg$parseinlineSpace();
1062
+ if (s3 !== peg$FAILED) {
1063
+ while (s3 !== peg$FAILED) {
1064
+ s2.push(s3);
1065
+ s3 = peg$parseinlineSpace();
1066
+ }
1067
+ } else {
1068
+ s2 = peg$FAILED;
1069
+ }
1070
+ if (s2 !== peg$FAILED) {
1071
+ s3 = peg$parselist();
1072
+ if (s3 !== peg$FAILED) {
1073
+ peg$savedPos = s0;
1074
+ s0 = peg$f9(s1, s3);
1075
+ } else {
1076
+ peg$currPos = s0;
1077
+ s0 = peg$FAILED;
1078
+ }
1079
+ } else {
1080
+ peg$currPos = s0;
1081
+ s0 = peg$FAILED;
1082
+ }
1083
+ } else {
1084
+ peg$currPos = s0;
1085
+ s0 = peg$FAILED;
1086
+ }
1087
+
1088
+ return s0;
1089
+ }
1090
+
1091
+ function peg$parsehost() {
1092
+ var s0, s1, s2, s3, s4;
1093
+
1094
+ s0 = peg$currPos;
1095
+ s1 = peg$parseidentifier();
1096
+ if (s1 !== peg$FAILED) {
1097
+ s2 = peg$currPos;
1098
+ if (input.charCodeAt(peg$currPos) === 58) {
1099
+ s3 = peg$c9;
1100
+ peg$currPos++;
1101
+ } else {
1102
+ s3 = peg$FAILED;
1103
+ if (peg$silentFails === 0) { peg$fail(peg$e14); }
1104
+ }
1105
+ if (s3 !== peg$FAILED) {
1106
+ s4 = peg$parsenumber();
1107
+ if (s4 !== peg$FAILED) {
1108
+ s3 = [s3, s4];
1109
+ s2 = s3;
1110
+ } else {
1111
+ peg$currPos = s2;
1112
+ s2 = peg$FAILED;
1113
+ }
1114
+ } else {
1115
+ peg$currPos = s2;
1116
+ s2 = peg$FAILED;
1117
+ }
1118
+ if (s2 === peg$FAILED) {
1119
+ s2 = null;
1120
+ }
1121
+ peg$savedPos = s0;
1122
+ s0 = peg$f10();
1123
+ } else {
1124
+ peg$currPos = s0;
1125
+ s0 = peg$FAILED;
1126
+ }
1127
+
1128
+ return s0;
1129
+ }
1130
+
1131
+ function peg$parseinlineSpace() {
1132
+ var s0;
1133
+
1134
+ if (peg$r3.test(input.charAt(peg$currPos))) {
1135
+ s0 = input.charAt(peg$currPos);
1136
+ peg$currPos++;
1137
+ } else {
1138
+ s0 = peg$FAILED;
1139
+ if (peg$silentFails === 0) { peg$fail(peg$e15); }
1140
+ }
1141
+
1142
+ return s0;
1143
+ }
1144
+
1145
+ function peg$parseinteger() {
1146
+ var s0, s1, s2;
1147
+
1148
+ s0 = peg$currPos;
1149
+ s1 = peg$parsesign();
1150
+ if (s1 === peg$FAILED) {
1151
+ s1 = null;
1152
+ }
1153
+ s2 = peg$parsedigits();
1154
+ if (s2 !== peg$FAILED) {
1155
+ peg$savedPos = s0;
1156
+ s0 = peg$f11();
1157
+ } else {
1158
+ peg$currPos = s0;
1159
+ s0 = peg$FAILED;
1160
+ }
1161
+
1162
+ return s0;
1163
+ }
1164
+
1165
+ function peg$parselambda() {
1166
+ var s0, s1, s2, s3;
1167
+
1168
+ s0 = peg$currPos;
1169
+ if (input.charCodeAt(peg$currPos) === 61) {
1170
+ s1 = peg$c0;
1171
+ peg$currPos++;
1172
+ } else {
1173
+ s1 = peg$FAILED;
1174
+ if (peg$silentFails === 0) { peg$fail(peg$e0); }
1175
+ }
1176
+ if (s1 !== peg$FAILED) {
1177
+ s2 = peg$parse__();
1178
+ s3 = peg$parseexpr();
1179
+ if (s3 !== peg$FAILED) {
1180
+ peg$savedPos = s0;
1181
+ s0 = peg$f12(s3);
1182
+ } else {
1183
+ peg$currPos = s0;
1184
+ s0 = peg$FAILED;
1185
+ }
1186
+ } else {
1187
+ peg$currPos = s0;
1188
+ s0 = peg$FAILED;
1189
+ }
1190
+
1191
+ return s0;
1192
+ }
1193
+
1194
+ function peg$parseleadingSlashPath() {
1195
+ var s0, s1, s2;
1196
+
1197
+ s0 = peg$currPos;
1198
+ if (input.charCodeAt(peg$currPos) === 47) {
1199
+ s1 = peg$c10;
1200
+ peg$currPos++;
1201
+ } else {
1202
+ s1 = peg$FAILED;
1203
+ if (peg$silentFails === 0) { peg$fail(peg$e16); }
1204
+ }
1205
+ if (s1 !== peg$FAILED) {
1206
+ s2 = peg$parsepath();
1207
+ if (s2 !== peg$FAILED) {
1208
+ s0 = s2;
1209
+ } else {
1210
+ peg$currPos = s0;
1211
+ s0 = peg$FAILED;
1212
+ }
1213
+ } else {
1214
+ peg$currPos = s0;
1215
+ s0 = peg$FAILED;
1216
+ }
1217
+ if (s0 === peg$FAILED) {
1218
+ s0 = peg$currPos;
1219
+ if (input.charCodeAt(peg$currPos) === 47) {
1220
+ s1 = peg$c10;
1221
+ peg$currPos++;
1222
+ } else {
1223
+ s1 = peg$FAILED;
1224
+ if (peg$silentFails === 0) { peg$fail(peg$e16); }
1225
+ }
1226
+ if (s1 !== peg$FAILED) {
1227
+ peg$savedPos = s0;
1228
+ s1 = peg$f13();
1229
+ }
1230
+ s0 = s1;
1231
+ }
1232
+
1233
+ return s0;
1234
+ }
1235
+
1236
+ function peg$parselist() {
1237
+ var s0, s1, s2, s3, s4, s5;
1238
+
1239
+ s0 = peg$currPos;
1240
+ s1 = peg$parseexpr();
1241
+ if (s1 !== peg$FAILED) {
1242
+ s2 = [];
1243
+ s3 = peg$currPos;
1244
+ s4 = peg$parseseparator();
1245
+ if (s4 !== peg$FAILED) {
1246
+ s5 = peg$parseexpr();
1247
+ if (s5 !== peg$FAILED) {
1248
+ s3 = s5;
1249
+ } else {
1250
+ peg$currPos = s3;
1251
+ s3 = peg$FAILED;
1252
+ }
1253
+ } else {
1254
+ peg$currPos = s3;
1255
+ s3 = peg$FAILED;
1256
+ }
1257
+ while (s3 !== peg$FAILED) {
1258
+ s2.push(s3);
1259
+ s3 = peg$currPos;
1260
+ s4 = peg$parseseparator();
1261
+ if (s4 !== peg$FAILED) {
1262
+ s5 = peg$parseexpr();
1263
+ if (s5 !== peg$FAILED) {
1264
+ s3 = s5;
1265
+ } else {
1266
+ peg$currPos = s3;
1267
+ s3 = peg$FAILED;
1268
+ }
1269
+ } else {
1270
+ peg$currPos = s3;
1271
+ s3 = peg$FAILED;
1272
+ }
1273
+ }
1274
+ s3 = peg$parseseparator();
1275
+ if (s3 === peg$FAILED) {
1276
+ s3 = null;
1277
+ }
1278
+ peg$savedPos = s0;
1279
+ s0 = peg$f14(s1, s2);
1280
+ } else {
1281
+ peg$currPos = s0;
1282
+ s0 = peg$FAILED;
1283
+ }
1284
+
1285
+ return s0;
1286
+ }
1287
+
1288
+ function peg$parsenewLine() {
1289
+ var s0;
1290
+
1291
+ if (input.charCodeAt(peg$currPos) === 10) {
1292
+ s0 = peg$c11;
1293
+ peg$currPos++;
1294
+ } else {
1295
+ s0 = peg$FAILED;
1296
+ if (peg$silentFails === 0) { peg$fail(peg$e17); }
1297
+ }
1298
+ if (s0 === peg$FAILED) {
1299
+ if (input.substr(peg$currPos, 2) === peg$c12) {
1300
+ s0 = peg$c12;
1301
+ peg$currPos += 2;
1302
+ } else {
1303
+ s0 = peg$FAILED;
1304
+ if (peg$silentFails === 0) { peg$fail(peg$e18); }
1305
+ }
1306
+ if (s0 === peg$FAILED) {
1307
+ if (input.charCodeAt(peg$currPos) === 13) {
1308
+ s0 = peg$c13;
1309
+ peg$currPos++;
1310
+ } else {
1311
+ s0 = peg$FAILED;
1312
+ if (peg$silentFails === 0) { peg$fail(peg$e19); }
1313
+ }
1314
+ }
1315
+ }
1316
+
1317
+ return s0;
1318
+ }
1319
+
1320
+ function peg$parsenumber() {
1321
+ var s0;
1322
+
1323
+ s0 = peg$parsefloat();
1324
+ if (s0 === peg$FAILED) {
1325
+ s0 = peg$parseinteger();
1326
+ }
1327
+
1328
+ return s0;
1329
+ }
1330
+
1331
+ function peg$parseobject() {
1332
+ var s0, s1, s2, s3, s4;
1333
+
1334
+ s0 = peg$currPos;
1335
+ if (input.charCodeAt(peg$currPos) === 123) {
1336
+ s1 = peg$c14;
1337
+ peg$currPos++;
1338
+ } else {
1339
+ s1 = peg$FAILED;
1340
+ if (peg$silentFails === 0) { peg$fail(peg$e20); }
1341
+ }
1342
+ if (s1 !== peg$FAILED) {
1343
+ s2 = peg$parse__();
1344
+ s3 = peg$parseobjectProperties();
1345
+ if (s3 === peg$FAILED) {
1346
+ s3 = null;
1347
+ }
1348
+ if (input.charCodeAt(peg$currPos) === 125) {
1349
+ s4 = peg$c15;
1350
+ peg$currPos++;
1351
+ } else {
1352
+ s4 = peg$FAILED;
1353
+ if (peg$silentFails === 0) { peg$fail(peg$e21); }
1354
+ }
1355
+ if (s4 !== peg$FAILED) {
1356
+ peg$savedPos = s0;
1357
+ s0 = peg$f15(s3);
1358
+ } else {
1359
+ peg$currPos = s0;
1360
+ s0 = peg$FAILED;
1361
+ }
1362
+ } else {
1363
+ peg$currPos = s0;
1364
+ s0 = peg$FAILED;
1365
+ }
1366
+
1367
+ return s0;
1368
+ }
1369
+
1370
+ function peg$parseobjectProperties() {
1371
+ var s0, s1, s2, s3, s4, s5;
1372
+
1373
+ s0 = peg$currPos;
1374
+ s1 = peg$parseobjectPropertyOrShorthand();
1375
+ if (s1 !== peg$FAILED) {
1376
+ s2 = [];
1377
+ s3 = peg$currPos;
1378
+ s4 = peg$parseseparator();
1379
+ if (s4 !== peg$FAILED) {
1380
+ s5 = peg$parseobjectPropertyOrShorthand();
1381
+ if (s5 !== peg$FAILED) {
1382
+ s3 = s5;
1383
+ } else {
1384
+ peg$currPos = s3;
1385
+ s3 = peg$FAILED;
1386
+ }
1387
+ } else {
1388
+ peg$currPos = s3;
1389
+ s3 = peg$FAILED;
1390
+ }
1391
+ while (s3 !== peg$FAILED) {
1392
+ s2.push(s3);
1393
+ s3 = peg$currPos;
1394
+ s4 = peg$parseseparator();
1395
+ if (s4 !== peg$FAILED) {
1396
+ s5 = peg$parseobjectPropertyOrShorthand();
1397
+ if (s5 !== peg$FAILED) {
1398
+ s3 = s5;
1399
+ } else {
1400
+ peg$currPos = s3;
1401
+ s3 = peg$FAILED;
1402
+ }
1403
+ } else {
1404
+ peg$currPos = s3;
1405
+ s3 = peg$FAILED;
1406
+ }
1407
+ }
1408
+ s3 = peg$parseseparator();
1409
+ if (s3 === peg$FAILED) {
1410
+ s3 = null;
1411
+ }
1412
+ s4 = peg$parse__();
1413
+ peg$savedPos = s0;
1414
+ s0 = peg$f16(s1, s2);
1415
+ } else {
1416
+ peg$currPos = s0;
1417
+ s0 = peg$FAILED;
1418
+ }
1419
+
1420
+ return s0;
1421
+ }
1422
+
1423
+ function peg$parseobjectProperty() {
1424
+ var s0, s1, s2, s3, s4, s5;
1425
+
1426
+ s0 = peg$currPos;
1427
+ s1 = peg$parseidentifier();
1428
+ if (s1 !== peg$FAILED) {
1429
+ s2 = peg$parse__();
1430
+ if (input.charCodeAt(peg$currPos) === 58) {
1431
+ s3 = peg$c9;
1432
+ peg$currPos++;
1433
+ } else {
1434
+ s3 = peg$FAILED;
1435
+ if (peg$silentFails === 0) { peg$fail(peg$e14); }
1436
+ }
1437
+ if (s3 !== peg$FAILED) {
1438
+ s4 = peg$parse__();
1439
+ s5 = peg$parseexpr();
1440
+ if (s5 !== peg$FAILED) {
1441
+ s0 = [ s1, s5 ];
1442
+ } else {
1443
+ peg$currPos = s0;
1444
+ s0 = peg$FAILED;
1445
+ }
1446
+ } else {
1447
+ peg$currPos = s0;
1448
+ s0 = peg$FAILED;
1449
+ }
1450
+ } else {
1451
+ peg$currPos = s0;
1452
+ s0 = peg$FAILED;
1453
+ }
1454
+
1455
+ return s0;
1456
+ }
1457
+
1458
+ function peg$parseobjectPropertyOrShorthand() {
1459
+ var s0, s1;
1460
+
1461
+ s0 = peg$parseobjectProperty();
1462
+ if (s0 === peg$FAILED) {
1463
+ s0 = peg$currPos;
1464
+ s1 = peg$parseidentifier();
1465
+ if (s1 !== peg$FAILED) {
1466
+ peg$savedPos = s0;
1467
+ s1 = peg$f17(s1);
1468
+ }
1469
+ s0 = s1;
1470
+ }
1471
+
1472
+ return s0;
1473
+ }
1474
+
1475
+ function peg$parseparensArgs() {
1476
+ var s0, s1, s2, s3, s4;
1477
+
1478
+ s0 = peg$currPos;
1479
+ if (input.charCodeAt(peg$currPos) === 40) {
1480
+ s1 = peg$c7;
1481
+ peg$currPos++;
1482
+ } else {
1483
+ s1 = peg$FAILED;
1484
+ if (peg$silentFails === 0) { peg$fail(peg$e11); }
1485
+ }
1486
+ if (s1 !== peg$FAILED) {
1487
+ s2 = peg$parse__();
1488
+ s3 = peg$parselist();
1489
+ if (s3 === peg$FAILED) {
1490
+ s3 = null;
1491
+ }
1492
+ if (input.charCodeAt(peg$currPos) === 41) {
1493
+ s4 = peg$c8;
1494
+ peg$currPos++;
1495
+ } else {
1496
+ s4 = peg$FAILED;
1497
+ if (peg$silentFails === 0) { peg$fail(peg$e12); }
1498
+ }
1499
+ if (s4 !== peg$FAILED) {
1500
+ peg$savedPos = s0;
1501
+ s0 = peg$f18(s3);
1502
+ } else {
1503
+ peg$currPos = s0;
1504
+ s0 = peg$FAILED;
1505
+ }
1506
+ } else {
1507
+ peg$currPos = s0;
1508
+ s0 = peg$FAILED;
1509
+ }
1510
+
1511
+ return s0;
1512
+ }
1513
+
1514
+ function peg$parseseparator() {
1515
+ var s0, s1, s2, s3;
1516
+
1517
+ s0 = peg$currPos;
1518
+ s1 = peg$parse__();
1519
+ if (input.charCodeAt(peg$currPos) === 44) {
1520
+ s2 = peg$c16;
1521
+ peg$currPos++;
1522
+ } else {
1523
+ s2 = peg$FAILED;
1524
+ if (peg$silentFails === 0) { peg$fail(peg$e22); }
1525
+ }
1526
+ if (s2 !== peg$FAILED) {
1527
+ s3 = peg$parse__();
1528
+ s1 = [s1, s2, s3];
1529
+ s0 = s1;
1530
+ } else {
1531
+ peg$currPos = s0;
1532
+ s0 = peg$FAILED;
1533
+ }
1534
+ if (s0 === peg$FAILED) {
1535
+ s0 = peg$parsewhitespaceWithNewLine();
1536
+ }
1537
+
1538
+ return s0;
1539
+ }
1540
+
1541
+ function peg$parsesign() {
1542
+ var s0;
1543
+
1544
+ if (peg$r4.test(input.charAt(peg$currPos))) {
1545
+ s0 = input.charAt(peg$currPos);
1546
+ peg$currPos++;
1547
+ } else {
1548
+ s0 = peg$FAILED;
1549
+ if (peg$silentFails === 0) { peg$fail(peg$e23); }
1550
+ }
1551
+
1552
+ return s0;
1553
+ }
1554
+
1555
+ function peg$parsepath() {
1556
+ var s0, s1, s2, s3;
1557
+
1558
+ s0 = peg$currPos;
1559
+ s1 = peg$parsepathKey();
1560
+ if (input.charCodeAt(peg$currPos) === 47) {
1561
+ s2 = peg$c10;
1562
+ peg$currPos++;
1563
+ } else {
1564
+ s2 = peg$FAILED;
1565
+ if (peg$silentFails === 0) { peg$fail(peg$e16); }
1566
+ }
1567
+ if (s2 !== peg$FAILED) {
1568
+ s3 = peg$parsepath();
1569
+ if (s3 !== peg$FAILED) {
1570
+ peg$savedPos = s0;
1571
+ s0 = peg$f19(s1, s3);
1572
+ } else {
1573
+ peg$currPos = s0;
1574
+ s0 = peg$FAILED;
1575
+ }
1576
+ } else {
1577
+ peg$currPos = s0;
1578
+ s0 = peg$FAILED;
1579
+ }
1580
+ if (s0 === peg$FAILED) {
1581
+ s0 = peg$currPos;
1582
+ s1 = peg$parsepathKey();
1583
+ peg$savedPos = s0;
1584
+ s1 = peg$f20(s1);
1585
+ s0 = s1;
1586
+ }
1587
+
1588
+ return s0;
1589
+ }
1590
+
1591
+ function peg$parsepathKey() {
1592
+ var s0, s1, s2;
1593
+
1594
+ s0 = peg$currPos;
1595
+ s1 = [];
1596
+ s2 = peg$parseidentifierChar();
1597
+ while (s2 !== peg$FAILED) {
1598
+ s1.push(s2);
1599
+ s2 = peg$parseidentifierChar();
1600
+ }
1601
+ peg$savedPos = s0;
1602
+ s1 = peg$f21(s1);
1603
+ s0 = s1;
1604
+
1605
+ return s0;
1606
+ }
1607
+
1608
+ function peg$parseprotocolCall() {
1609
+ var s0, s1, s2, s3, s4, s5;
1610
+
1611
+ s0 = peg$currPos;
1612
+ s1 = peg$parseprotocol();
1613
+ if (s1 !== peg$FAILED) {
1614
+ if (input.charCodeAt(peg$currPos) === 58) {
1615
+ s2 = peg$c9;
1616
+ peg$currPos++;
1617
+ } else {
1618
+ s2 = peg$FAILED;
1619
+ if (peg$silentFails === 0) { peg$fail(peg$e14); }
1620
+ }
1621
+ if (s2 !== peg$FAILED) {
1622
+ s3 = [];
1623
+ if (input.charCodeAt(peg$currPos) === 47) {
1624
+ s4 = peg$c10;
1625
+ peg$currPos++;
1626
+ } else {
1627
+ s4 = peg$FAILED;
1628
+ if (peg$silentFails === 0) { peg$fail(peg$e16); }
1629
+ }
1630
+ while (s4 !== peg$FAILED) {
1631
+ s3.push(s4);
1632
+ if (s3.length >= 2) {
1633
+ s4 = peg$FAILED;
1634
+ } else {
1635
+ if (input.charCodeAt(peg$currPos) === 47) {
1636
+ s4 = peg$c10;
1637
+ peg$currPos++;
1638
+ } else {
1639
+ s4 = peg$FAILED;
1640
+ if (peg$silentFails === 0) { peg$fail(peg$e16); }
1641
+ }
1642
+ }
1643
+ }
1644
+ s4 = peg$parsehost();
1645
+ if (s4 !== peg$FAILED) {
1646
+ s5 = peg$parseleadingSlashPath();
1647
+ if (s5 === peg$FAILED) {
1648
+ s5 = null;
1649
+ }
1650
+ peg$savedPos = s0;
1651
+ s0 = peg$f22(s1, s4, s5);
1652
+ } else {
1653
+ peg$currPos = s0;
1654
+ s0 = peg$FAILED;
1655
+ }
1656
+ } else {
1657
+ peg$currPos = s0;
1658
+ s0 = peg$FAILED;
1659
+ }
1660
+ } else {
1661
+ peg$currPos = s0;
1662
+ s0 = peg$FAILED;
1663
+ }
1664
+
1665
+ return s0;
1666
+ }
1667
+
1668
+ function peg$parseprotocol() {
1669
+ var s0;
1670
+
1671
+ s0 = peg$parsereservedProtocol();
1672
+ if (s0 === peg$FAILED) {
1673
+ s0 = peg$parsescopeReference();
1674
+ }
1675
+
1676
+ return s0;
1677
+ }
1678
+
1679
+ function peg$parsereservedProtocol() {
1680
+ var s0, s1;
1681
+
1682
+ s0 = peg$currPos;
1683
+ if (input.substr(peg$currPos, 5) === peg$c17) {
1684
+ s1 = peg$c17;
1685
+ peg$currPos += 5;
1686
+ } else {
1687
+ s1 = peg$FAILED;
1688
+ if (peg$silentFails === 0) { peg$fail(peg$e24); }
1689
+ }
1690
+ if (s1 !== peg$FAILED) {
1691
+ peg$savedPos = s0;
1692
+ s1 = peg$f23();
1693
+ }
1694
+ s0 = s1;
1695
+ if (s0 === peg$FAILED) {
1696
+ s0 = peg$currPos;
1697
+ if (input.substr(peg$currPos, 4) === peg$c18) {
1698
+ s1 = peg$c18;
1699
+ peg$currPos += 4;
1700
+ } else {
1701
+ s1 = peg$FAILED;
1702
+ if (peg$silentFails === 0) { peg$fail(peg$e25); }
1703
+ }
1704
+ if (s1 !== peg$FAILED) {
1705
+ peg$savedPos = s0;
1706
+ s1 = peg$f24();
1707
+ }
1708
+ s0 = s1;
1709
+ if (s0 === peg$FAILED) {
1710
+ s0 = peg$currPos;
1711
+ if (input.substr(peg$currPos, 9) === peg$c19) {
1712
+ s1 = peg$c19;
1713
+ peg$currPos += 9;
1714
+ } else {
1715
+ s1 = peg$FAILED;
1716
+ if (peg$silentFails === 0) { peg$fail(peg$e26); }
1717
+ }
1718
+ if (s1 !== peg$FAILED) {
1719
+ peg$savedPos = s0;
1720
+ s1 = peg$f25();
1721
+ }
1722
+ s0 = s1;
1723
+ if (s0 === peg$FAILED) {
1724
+ s0 = peg$currPos;
1725
+ if (input.substr(peg$currPos, 8) === peg$c20) {
1726
+ s1 = peg$c20;
1727
+ peg$currPos += 8;
1728
+ } else {
1729
+ s1 = peg$FAILED;
1730
+ if (peg$silentFails === 0) { peg$fail(peg$e27); }
1731
+ }
1732
+ if (s1 !== peg$FAILED) {
1733
+ peg$savedPos = s0;
1734
+ s1 = peg$f26();
1735
+ }
1736
+ s0 = s1;
1737
+ if (s0 === peg$FAILED) {
1738
+ s0 = peg$currPos;
1739
+ if (input.substr(peg$currPos, 4) === peg$c21) {
1740
+ s1 = peg$c21;
1741
+ peg$currPos += 4;
1742
+ } else {
1743
+ s1 = peg$FAILED;
1744
+ if (peg$silentFails === 0) { peg$fail(peg$e28); }
1745
+ }
1746
+ if (s1 !== peg$FAILED) {
1747
+ peg$savedPos = s0;
1748
+ s1 = peg$f27();
1749
+ }
1750
+ s0 = s1;
1751
+ }
1752
+ }
1753
+ }
1754
+ }
1755
+
1756
+ return s0;
1757
+ }
1758
+
1759
+ function peg$parsescopeReference() {
1760
+ var s0, s1;
1761
+
1762
+ s0 = peg$currPos;
1763
+ s1 = peg$parseidentifier();
1764
+ if (s1 !== peg$FAILED) {
1765
+ peg$savedPos = s0;
1766
+ s1 = peg$f28(s1);
1767
+ }
1768
+ s0 = s1;
1769
+
1770
+ return s0;
1771
+ }
1772
+
1773
+ function peg$parsesingleQuoteString() {
1774
+ var s0, s1, s2, s3;
1775
+
1776
+ s0 = peg$currPos;
1777
+ if (input.charCodeAt(peg$currPos) === 39) {
1778
+ s1 = peg$c22;
1779
+ peg$currPos++;
1780
+ } else {
1781
+ s1 = peg$FAILED;
1782
+ if (peg$silentFails === 0) { peg$fail(peg$e29); }
1783
+ }
1784
+ if (s1 !== peg$FAILED) {
1785
+ s2 = [];
1786
+ s3 = peg$parsesingleQuoteStringChar();
1787
+ while (s3 !== peg$FAILED) {
1788
+ s2.push(s3);
1789
+ s3 = peg$parsesingleQuoteStringChar();
1790
+ }
1791
+ if (input.charCodeAt(peg$currPos) === 39) {
1792
+ s3 = peg$c22;
1793
+ peg$currPos++;
1794
+ } else {
1795
+ s3 = peg$FAILED;
1796
+ if (peg$silentFails === 0) { peg$fail(peg$e29); }
1797
+ }
1798
+ if (s3 !== peg$FAILED) {
1799
+ peg$savedPos = s0;
1800
+ s0 = peg$f29(s2);
1801
+ } else {
1802
+ peg$currPos = s0;
1803
+ s0 = peg$FAILED;
1804
+ }
1805
+ } else {
1806
+ peg$currPos = s0;
1807
+ s0 = peg$FAILED;
1808
+ }
1809
+
1810
+ return s0;
1811
+ }
1812
+
1813
+ function peg$parsesingleQuoteStringChar() {
1814
+ var s0, s1, s2;
1815
+
1816
+ s0 = peg$currPos;
1817
+ s1 = peg$currPos;
1818
+ peg$silentFails++;
1819
+ if (input.charCodeAt(peg$currPos) === 39) {
1820
+ s2 = peg$c22;
1821
+ peg$currPos++;
1822
+ } else {
1823
+ s2 = peg$FAILED;
1824
+ if (peg$silentFails === 0) { peg$fail(peg$e29); }
1825
+ }
1826
+ if (s2 === peg$FAILED) {
1827
+ s2 = peg$parsenewLine();
1828
+ }
1829
+ peg$silentFails--;
1830
+ if (s2 === peg$FAILED) {
1831
+ s1 = undefined;
1832
+ } else {
1833
+ peg$currPos = s1;
1834
+ s1 = peg$FAILED;
1835
+ }
1836
+ if (s1 !== peg$FAILED) {
1837
+ s2 = peg$parsetextChar();
1838
+ if (s2 !== peg$FAILED) {
1839
+ s0 = s2;
1840
+ } else {
1841
+ peg$currPos = s0;
1842
+ s0 = peg$FAILED;
1843
+ }
1844
+ } else {
1845
+ peg$currPos = s0;
1846
+ s0 = peg$FAILED;
1847
+ }
1848
+
1849
+ return s0;
1850
+ }
1851
+
1852
+ function peg$parsestart() {
1853
+ var s0;
1854
+
1855
+ s0 = peg$parsenumber();
1856
+
1857
+ return s0;
1858
+ }
1859
+
1860
+ function peg$parsestring() {
1861
+ var s0;
1862
+
1863
+ s0 = peg$parsedoubleQuoteString();
1864
+ if (s0 === peg$FAILED) {
1865
+ s0 = peg$parsesingleQuoteString();
1866
+ }
1867
+
1868
+ return s0;
1869
+ }
1870
+
1871
+ function peg$parsetemplateDocument() {
1872
+ var s0, s1;
1873
+
1874
+ peg$silentFails++;
1875
+ s0 = peg$currPos;
1876
+ s1 = peg$parsetemplateDocumentContents();
1877
+ peg$savedPos = s0;
1878
+ s1 = peg$f30(s1);
1879
+ s0 = s1;
1880
+ peg$silentFails--;
1881
+ s1 = peg$FAILED;
1882
+ if (peg$silentFails === 0) { peg$fail(peg$e30); }
1883
+
1884
+ return s0;
1885
+ }
1886
+
1887
+ function peg$parsetemplateDocumentChar() {
1888
+ var s0, s1, s2;
1889
+
1890
+ s0 = peg$currPos;
1891
+ s1 = peg$currPos;
1892
+ peg$silentFails++;
1893
+ if (input.substr(peg$currPos, 2) === peg$c23) {
1894
+ s2 = peg$c23;
1895
+ peg$currPos += 2;
1896
+ } else {
1897
+ s2 = peg$FAILED;
1898
+ if (peg$silentFails === 0) { peg$fail(peg$e31); }
1899
+ }
1900
+ peg$silentFails--;
1901
+ if (s2 === peg$FAILED) {
1902
+ s1 = undefined;
1903
+ } else {
1904
+ peg$currPos = s1;
1905
+ s1 = peg$FAILED;
1906
+ }
1907
+ if (s1 !== peg$FAILED) {
1908
+ s2 = peg$parsetextChar();
1909
+ if (s2 !== peg$FAILED) {
1910
+ s0 = s2;
1911
+ } else {
1912
+ peg$currPos = s0;
1913
+ s0 = peg$FAILED;
1914
+ }
1915
+ } else {
1916
+ peg$currPos = s0;
1917
+ s0 = peg$FAILED;
1918
+ }
1919
+
1920
+ return s0;
1921
+ }
1922
+
1923
+ function peg$parsetemplateDocumentContents() {
1924
+ var s0, s1, s2;
1925
+
1926
+ s0 = peg$currPos;
1927
+ s1 = [];
1928
+ s2 = peg$parsetemplateDocumentText();
1929
+ if (s2 === peg$FAILED) {
1930
+ s2 = peg$parsetemplateSubstitution();
1931
+ }
1932
+ while (s2 !== peg$FAILED) {
1933
+ s1.push(s2);
1934
+ s2 = peg$parsetemplateDocumentText();
1935
+ if (s2 === peg$FAILED) {
1936
+ s2 = peg$parsetemplateSubstitution();
1937
+ }
1938
+ }
1939
+ peg$savedPos = s0;
1940
+ s1 = peg$f31(s1);
1941
+ s0 = s1;
1942
+
1943
+ return s0;
1944
+ }
1945
+
1946
+ function peg$parsetemplateDocumentText() {
1947
+ var s0, s1, s2;
1948
+
1949
+ s0 = peg$currPos;
1950
+ s1 = [];
1951
+ s2 = peg$parsetemplateDocumentChar();
1952
+ if (s2 !== peg$FAILED) {
1953
+ while (s2 !== peg$FAILED) {
1954
+ s1.push(s2);
1955
+ s2 = peg$parsetemplateDocumentChar();
1956
+ }
1957
+ } else {
1958
+ s1 = peg$FAILED;
1959
+ }
1960
+ if (s1 !== peg$FAILED) {
1961
+ peg$savedPos = s0;
1962
+ s1 = peg$f32(s1);
1963
+ }
1964
+ s0 = s1;
1965
+
1966
+ return s0;
1967
+ }
1968
+
1969
+ function peg$parsetemplateLiteral() {
1970
+ var s0, s1, s2, s3;
1971
+
1972
+ s0 = peg$currPos;
1973
+ if (input.charCodeAt(peg$currPos) === 96) {
1974
+ s1 = peg$c24;
1975
+ peg$currPos++;
1976
+ } else {
1977
+ s1 = peg$FAILED;
1978
+ if (peg$silentFails === 0) { peg$fail(peg$e32); }
1979
+ }
1980
+ if (s1 !== peg$FAILED) {
1981
+ s2 = peg$parsetemplateLiteralContents();
1982
+ if (input.charCodeAt(peg$currPos) === 96) {
1983
+ s3 = peg$c24;
1984
+ peg$currPos++;
1985
+ } else {
1986
+ s3 = peg$FAILED;
1987
+ if (peg$silentFails === 0) { peg$fail(peg$e32); }
1988
+ }
1989
+ if (s3 !== peg$FAILED) {
1990
+ s0 = s2;
1991
+ } else {
1992
+ peg$currPos = s0;
1993
+ s0 = peg$FAILED;
1994
+ }
1995
+ } else {
1996
+ peg$currPos = s0;
1997
+ s0 = peg$FAILED;
1998
+ }
1999
+
2000
+ return s0;
2001
+ }
2002
+
2003
+ function peg$parsetemplateLiteralChar() {
2004
+ var s0, s1, s2;
2005
+
2006
+ s0 = peg$currPos;
2007
+ s1 = peg$currPos;
2008
+ peg$silentFails++;
2009
+ if (input.charCodeAt(peg$currPos) === 96) {
2010
+ s2 = peg$c24;
2011
+ peg$currPos++;
2012
+ } else {
2013
+ s2 = peg$FAILED;
2014
+ if (peg$silentFails === 0) { peg$fail(peg$e32); }
2015
+ }
2016
+ if (s2 === peg$FAILED) {
2017
+ if (input.substr(peg$currPos, 2) === peg$c23) {
2018
+ s2 = peg$c23;
2019
+ peg$currPos += 2;
2020
+ } else {
2021
+ s2 = peg$FAILED;
2022
+ if (peg$silentFails === 0) { peg$fail(peg$e31); }
2023
+ }
2024
+ }
2025
+ peg$silentFails--;
2026
+ if (s2 === peg$FAILED) {
2027
+ s1 = undefined;
2028
+ } else {
2029
+ peg$currPos = s1;
2030
+ s1 = peg$FAILED;
2031
+ }
2032
+ if (s1 !== peg$FAILED) {
2033
+ s2 = peg$parsetextChar();
2034
+ if (s2 !== peg$FAILED) {
2035
+ s0 = s2;
2036
+ } else {
2037
+ peg$currPos = s0;
2038
+ s0 = peg$FAILED;
2039
+ }
2040
+ } else {
2041
+ peg$currPos = s0;
2042
+ s0 = peg$FAILED;
2043
+ }
2044
+
2045
+ return s0;
2046
+ }
2047
+
2048
+ function peg$parsetemplateLiteralContents() {
2049
+ var s0, s1, s2;
2050
+
2051
+ s0 = peg$currPos;
2052
+ s1 = [];
2053
+ s2 = peg$parsetemplateLiteralText();
2054
+ if (s2 === peg$FAILED) {
2055
+ s2 = peg$parsetemplateSubstitution();
2056
+ }
2057
+ while (s2 !== peg$FAILED) {
2058
+ s1.push(s2);
2059
+ s2 = peg$parsetemplateLiteralText();
2060
+ if (s2 === peg$FAILED) {
2061
+ s2 = peg$parsetemplateSubstitution();
2062
+ }
2063
+ }
2064
+ peg$savedPos = s0;
2065
+ s1 = peg$f33(s1);
2066
+ s0 = s1;
2067
+
2068
+ return s0;
2069
+ }
2070
+
2071
+ function peg$parsetemplateLiteralText() {
2072
+ var s0, s1, s2;
2073
+
2074
+ s0 = peg$currPos;
2075
+ s1 = [];
2076
+ s2 = peg$parsetemplateLiteralChar();
2077
+ if (s2 !== peg$FAILED) {
2078
+ while (s2 !== peg$FAILED) {
2079
+ s1.push(s2);
2080
+ s2 = peg$parsetemplateLiteralChar();
2081
+ }
2082
+ } else {
2083
+ s1 = peg$FAILED;
2084
+ }
2085
+ if (s1 !== peg$FAILED) {
2086
+ peg$savedPos = s0;
2087
+ s1 = peg$f34(s1);
2088
+ }
2089
+ s0 = s1;
2090
+
2091
+ return s0;
2092
+ }
2093
+
2094
+ function peg$parsetemplateSubstitution() {
2095
+ var s0, s1, s2, s3;
2096
+
2097
+ s0 = peg$currPos;
2098
+ if (input.substr(peg$currPos, 2) === peg$c23) {
2099
+ s1 = peg$c23;
2100
+ peg$currPos += 2;
2101
+ } else {
2102
+ s1 = peg$FAILED;
2103
+ if (peg$silentFails === 0) { peg$fail(peg$e31); }
2104
+ }
2105
+ if (s1 !== peg$FAILED) {
2106
+ s2 = peg$parseexpression();
2107
+ if (s2 !== peg$FAILED) {
2108
+ if (input.substr(peg$currPos, 2) === peg$c25) {
2109
+ s3 = peg$c25;
2110
+ peg$currPos += 2;
2111
+ } else {
2112
+ s3 = peg$FAILED;
2113
+ if (peg$silentFails === 0) { peg$fail(peg$e33); }
2114
+ }
2115
+ if (s3 !== peg$FAILED) {
2116
+ s0 = s2;
2117
+ } else {
2118
+ peg$currPos = s0;
2119
+ s0 = peg$FAILED;
2120
+ }
2121
+ } else {
2122
+ peg$currPos = s0;
2123
+ s0 = peg$FAILED;
2124
+ }
2125
+ } else {
2126
+ peg$currPos = s0;
2127
+ s0 = peg$FAILED;
2128
+ }
2129
+
2130
+ return s0;
2131
+ }
2132
+
2133
+ function peg$parsetextChar() {
2134
+ var s0;
2135
+
2136
+ s0 = peg$parseescapedChar();
2137
+ if (s0 === peg$FAILED) {
2138
+ if (input.length > peg$currPos) {
2139
+ s0 = input.charAt(peg$currPos);
2140
+ peg$currPos++;
2141
+ } else {
2142
+ s0 = peg$FAILED;
2143
+ if (peg$silentFails === 0) { peg$fail(peg$e8); }
2144
+ }
2145
+ }
2146
+
2147
+ return s0;
2148
+ }
2149
+
2150
+ function peg$parsetree() {
2151
+ var s0, s1, s2, s3, s4;
2152
+
2153
+ s0 = peg$currPos;
2154
+ if (input.charCodeAt(peg$currPos) === 123) {
2155
+ s1 = peg$c14;
2156
+ peg$currPos++;
2157
+ } else {
2158
+ s1 = peg$FAILED;
2159
+ if (peg$silentFails === 0) { peg$fail(peg$e20); }
2160
+ }
2161
+ if (s1 !== peg$FAILED) {
2162
+ s2 = peg$parse__();
2163
+ s3 = peg$parsetreeAssignments();
2164
+ if (s3 === peg$FAILED) {
2165
+ s3 = null;
2166
+ }
2167
+ if (input.charCodeAt(peg$currPos) === 125) {
2168
+ s4 = peg$c15;
2169
+ peg$currPos++;
2170
+ } else {
2171
+ s4 = peg$FAILED;
2172
+ if (peg$silentFails === 0) { peg$fail(peg$e21); }
2173
+ }
2174
+ if (s4 !== peg$FAILED) {
2175
+ peg$savedPos = s0;
2176
+ s0 = peg$f35(s3);
2177
+ } else {
2178
+ peg$currPos = s0;
2179
+ s0 = peg$FAILED;
2180
+ }
2181
+ } else {
2182
+ peg$currPos = s0;
2183
+ s0 = peg$FAILED;
2184
+ }
2185
+
2186
+ return s0;
2187
+ }
2188
+
2189
+ function peg$parsetreeAssignments() {
2190
+ var s0, s1, s2, s3, s4, s5;
2191
+
2192
+ s0 = peg$currPos;
2193
+ s1 = peg$parseassignmentOrShorthand();
2194
+ if (s1 !== peg$FAILED) {
2195
+ s2 = [];
2196
+ s3 = peg$currPos;
2197
+ s4 = peg$parseseparator();
2198
+ if (s4 !== peg$FAILED) {
2199
+ s5 = peg$parseassignmentOrShorthand();
2200
+ if (s5 !== peg$FAILED) {
2201
+ s3 = s5;
2202
+ } else {
2203
+ peg$currPos = s3;
2204
+ s3 = peg$FAILED;
2205
+ }
2206
+ } else {
2207
+ peg$currPos = s3;
2208
+ s3 = peg$FAILED;
2209
+ }
2210
+ while (s3 !== peg$FAILED) {
2211
+ s2.push(s3);
2212
+ s3 = peg$currPos;
2213
+ s4 = peg$parseseparator();
2214
+ if (s4 !== peg$FAILED) {
2215
+ s5 = peg$parseassignmentOrShorthand();
2216
+ if (s5 !== peg$FAILED) {
2217
+ s3 = s5;
2218
+ } else {
2219
+ peg$currPos = s3;
2220
+ s3 = peg$FAILED;
2221
+ }
2222
+ } else {
2223
+ peg$currPos = s3;
2224
+ s3 = peg$FAILED;
2225
+ }
2226
+ }
2227
+ s3 = peg$parseseparator();
2228
+ if (s3 === peg$FAILED) {
2229
+ s3 = null;
2230
+ }
2231
+ s4 = peg$parse__();
2232
+ peg$savedPos = s0;
2233
+ s0 = peg$f36(s1, s2);
2234
+ } else {
2235
+ peg$currPos = s0;
2236
+ s0 = peg$FAILED;
2237
+ }
2238
+
2239
+ return s0;
2240
+ }
2241
+
2242
+ function peg$parsewhitespaceWithNewLine() {
2243
+ var s0, s1, s2, s3, s4;
2244
+
2245
+ s0 = peg$currPos;
2246
+ s1 = [];
2247
+ s2 = peg$parseinlineSpace();
2248
+ while (s2 !== peg$FAILED) {
2249
+ s1.push(s2);
2250
+ s2 = peg$parseinlineSpace();
2251
+ }
2252
+ s2 = peg$parsecomment();
2253
+ if (s2 === peg$FAILED) {
2254
+ s2 = null;
2255
+ }
2256
+ s3 = peg$parsenewLine();
2257
+ if (s3 !== peg$FAILED) {
2258
+ s4 = peg$parse__();
2259
+ s1 = [s1, s2, s3, s4];
2260
+ s0 = s1;
2261
+ } else {
2262
+ peg$currPos = s0;
2263
+ s0 = peg$FAILED;
2264
+ }
2265
+
2266
+ return s0;
2267
+ }
2268
+
2269
+ peg$result = peg$startRuleFunction();
2270
+
2271
+ if (peg$result !== peg$FAILED && peg$currPos === input.length) {
2272
+ return peg$result;
2273
+ } else {
2274
+ if (peg$result !== peg$FAILED && peg$currPos < input.length) {
2275
+ peg$fail(peg$endExpectation());
2276
+ }
2277
+
2278
+ throw peg$buildStructuredError(
2279
+ peg$maxFailExpected,
2280
+ peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,
2281
+ peg$maxFailPos < input.length
2282
+ ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)
2283
+ : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)
2284
+ );
2285
+ }
2286
+ }
2287
+
2288
+ export {
2289
+ peg$SyntaxError as SyntaxError,
2290
+
2291
+ peg$parse as parse
2292
+ };