@malloydata/malloy-sql 0.0.439 → 0.0.440

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.
@@ -1,223 +1,200 @@
1
- // @generated by Peggy 4.2.0.
1
+ // @generated by Peggy 5.1.1.
2
2
  //
3
3
  // https://peggyjs.org/
4
4
  "use strict";
5
- function peg$subclass(child, parent) {
6
- function C() { this.constructor = child; }
7
- C.prototype = parent.prototype;
8
- child.prototype = new C();
9
- }
10
- function peg$SyntaxError(message, expected, found, location) {
11
- var self = Error.call(this, message);
12
- // istanbul ignore next Check is a necessary evil to support older environments
13
- if (Object.setPrototypeOf) {
14
- Object.setPrototypeOf(self, peg$SyntaxError.prototype);
15
- }
16
- self.expected = expected;
17
- self.found = found;
18
- self.location = location;
19
- self.name = "SyntaxError";
20
- return self;
21
- }
22
- peg$subclass(peg$SyntaxError, Error);
23
- function peg$padEnd(str, targetLength, padString) {
24
- padString = padString || " ";
25
- if (str.length > targetLength) {
26
- return str;
27
- }
28
- targetLength -= str.length;
29
- padString += padString.repeat(targetLength);
30
- return str + padString.slice(0, targetLength);
31
- }
32
- peg$SyntaxError.prototype.format = function (sources) {
33
- var str = "Error: " + this.message;
34
- if (this.location) {
35
- var src = null;
36
- var k;
37
- for (k = 0; k < sources.length; k++) {
38
- if (sources[k].source === this.location.source) {
39
- src = sources[k].text.split(/\r\n|\n|\r/g);
40
- break;
5
+ class peg$SyntaxError extends SyntaxError {
6
+ constructor(message, expected, found, location) {
7
+ super(message);
8
+ this.expected = expected;
9
+ this.found = found;
10
+ this.location = location;
11
+ this.name = "SyntaxError";
12
+ }
13
+ format(sources) {
14
+ let str = "Error: " + this.message;
15
+ if (this.location) {
16
+ let src = null;
17
+ const st = sources.find(s => s.source === this.location.source);
18
+ if (st) {
19
+ src = st.text.split(/\r\n|\n|\r/g);
20
+ }
21
+ const s = this.location.start;
22
+ const offset_s = (this.location.source && (typeof this.location.source.offset === "function"))
23
+ ? this.location.source.offset(s)
24
+ : s;
25
+ const loc = this.location.source + ":" + offset_s.line + ":" + offset_s.column;
26
+ if (src) {
27
+ const e = this.location.end;
28
+ const filler = "".padEnd(offset_s.line.toString().length, " ");
29
+ const line = src[s.line - 1];
30
+ const last = s.line === e.line ? e.column : line.length + 1;
31
+ const hatLen = (last - s.column) || 1;
32
+ str += "\n --> " + loc + "\n"
33
+ + filler + " |\n"
34
+ + offset_s.line + " | " + line + "\n"
35
+ + filler + " | " + "".padEnd(s.column - 1, " ")
36
+ + "".padEnd(hatLen, "^");
37
+ }
38
+ else {
39
+ str += "\n at " + loc;
41
40
  }
42
41
  }
43
- var s = this.location.start;
44
- var offset_s = (this.location.source && (typeof this.location.source.offset === "function"))
45
- ? this.location.source.offset(s)
46
- : s;
47
- var loc = this.location.source + ":" + offset_s.line + ":" + offset_s.column;
48
- if (src) {
49
- var e = this.location.end;
50
- var filler = peg$padEnd("", offset_s.line.toString().length, ' ');
51
- var line = src[s.line - 1];
52
- var last = s.line === e.line ? e.column : line.length + 1;
53
- var hatLen = (last - s.column) || 1;
54
- str += "\n --> " + loc + "\n"
55
- + filler + " |\n"
56
- + offset_s.line + " | " + line + "\n"
57
- + filler + " | " + peg$padEnd("", s.column - 1, ' ')
58
- + peg$padEnd("", hatLen, "^");
59
- }
60
- else {
61
- str += "\n at " + loc;
62
- }
42
+ return str;
63
43
  }
64
- return str;
65
- };
66
- peg$SyntaxError.buildMessage = function (expected, found) {
67
- var DESCRIBE_EXPECTATION_FNS = {
68
- literal: function (expectation) {
69
- return "\"" + literalEscape(expectation.text) + "\"";
70
- },
71
- class: function (expectation) {
72
- var escapedParts = expectation.parts.map(function (part) {
73
- return Array.isArray(part)
44
+ static buildMessage(expected, found) {
45
+ function hex(ch) {
46
+ return ch.codePointAt(0).toString(16).toUpperCase();
47
+ }
48
+ const nonPrintable = Object.prototype.hasOwnProperty.call(RegExp.prototype, "unicode")
49
+ ? new RegExp("[\\p{C}\\p{Mn}\\p{Mc}]", "gu")
50
+ : null;
51
+ function unicodeEscape(s) {
52
+ if (nonPrintable) {
53
+ return s.replace(nonPrintable, ch => "\\u{" + hex(ch) + "}");
54
+ }
55
+ return s;
56
+ }
57
+ function escape(s, special) {
58
+ return unicodeEscape(s
59
+ .replace(special, "\\$&")
60
+ .replace(/\0/g, "\\0")
61
+ .replace(/\t/g, "\\t")
62
+ .replace(/\n/g, "\\n")
63
+ .replace(/\r/g, "\\r")
64
+ .replace(/[\x00-\x0F]/g, ch => "\\x0" + hex(ch))
65
+ .replace(/[\x10-\x1F\x7F-\x9F]/g, ch => "\\x" + hex(ch)));
66
+ }
67
+ function literalEscape(s) {
68
+ return escape(s, /[\\"]/g);
69
+ }
70
+ function classEscape(s) {
71
+ return escape(s, /[\\\]^-]/g);
72
+ }
73
+ const DESCRIBE_EXPECTATION_FNS = {
74
+ literal(expectation) {
75
+ return "\"" + literalEscape(expectation.text) + "\"";
76
+ },
77
+ class(expectation) {
78
+ const escapedParts = expectation.parts.map(part => (Array.isArray(part)
74
79
  ? classEscape(part[0]) + "-" + classEscape(part[1])
75
- : classEscape(part);
76
- });
77
- return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]";
78
- },
79
- any: function () {
80
- return "any character";
81
- },
82
- end: function () {
83
- return "end of input";
84
- },
85
- other: function (expectation) {
86
- return expectation.description;
87
- }
88
- };
89
- function hex(ch) {
90
- return ch.charCodeAt(0).toString(16).toUpperCase();
91
- }
92
- function literalEscape(s) {
93
- return s
94
- .replace(/\\/g, "\\\\")
95
- .replace(/"/g, "\\\"")
96
- .replace(/\0/g, "\\0")
97
- .replace(/\t/g, "\\t")
98
- .replace(/\n/g, "\\n")
99
- .replace(/\r/g, "\\r")
100
- .replace(/[\x00-\x0F]/g, function (ch) { return "\\x0" + hex(ch); })
101
- .replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) { return "\\x" + hex(ch); });
102
- }
103
- function classEscape(s) {
104
- return s
105
- .replace(/\\/g, "\\\\")
106
- .replace(/\]/g, "\\]")
107
- .replace(/\^/g, "\\^")
108
- .replace(/-/g, "\\-")
109
- .replace(/\0/g, "\\0")
110
- .replace(/\t/g, "\\t")
111
- .replace(/\n/g, "\\n")
112
- .replace(/\r/g, "\\r")
113
- .replace(/[\x00-\x0F]/g, function (ch) { return "\\x0" + hex(ch); })
114
- .replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) { return "\\x" + hex(ch); });
115
- }
116
- function describeExpectation(expectation) {
117
- return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
118
- }
119
- function describeExpected(expected) {
120
- var descriptions = expected.map(describeExpectation);
121
- var i, j;
122
- descriptions.sort();
123
- if (descriptions.length > 0) {
124
- for (i = 1, j = 1; i < descriptions.length; i++) {
125
- if (descriptions[i - 1] !== descriptions[i]) {
126
- descriptions[j] = descriptions[i];
127
- j++;
80
+ : classEscape(part)));
81
+ return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]" + (expectation.unicode ? "u" : "");
82
+ },
83
+ any() {
84
+ return "any character";
85
+ },
86
+ end() {
87
+ return "end of input";
88
+ },
89
+ other(expectation) {
90
+ return expectation.description;
91
+ },
92
+ };
93
+ function describeExpectation(expectation) {
94
+ return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
95
+ }
96
+ function describeExpected(expected) {
97
+ const descriptions = expected.map(describeExpectation);
98
+ descriptions.sort();
99
+ if (descriptions.length > 0) {
100
+ let j = 1;
101
+ for (let i = 1; i < descriptions.length; i++) {
102
+ if (descriptions[i - 1] !== descriptions[i]) {
103
+ descriptions[j] = descriptions[i];
104
+ j++;
105
+ }
128
106
  }
107
+ descriptions.length = j;
108
+ }
109
+ switch (descriptions.length) {
110
+ case 1:
111
+ return descriptions[0];
112
+ case 2:
113
+ return descriptions[0] + " or " + descriptions[1];
114
+ default:
115
+ return descriptions.slice(0, -1).join(", ")
116
+ + ", or "
117
+ + descriptions[descriptions.length - 1];
129
118
  }
130
- descriptions.length = j;
131
119
  }
132
- switch (descriptions.length) {
133
- case 1:
134
- return descriptions[0];
135
- case 2:
136
- return descriptions[0] + " or " + descriptions[1];
137
- default:
138
- return descriptions.slice(0, -1).join(", ")
139
- + ", or "
140
- + descriptions[descriptions.length - 1];
120
+ function describeFound(found) {
121
+ return found ? "\"" + literalEscape(found) + "\"" : "end of input";
141
122
  }
123
+ return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
142
124
  }
143
- function describeFound(found) {
144
- return found ? "\"" + literalEscape(found) + "\"" : "end of input";
145
- }
146
- return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
147
- };
125
+ }
148
126
  function peg$parse(input, options) {
149
127
  options = options !== undefined ? options : {};
150
- var peg$FAILED = {};
151
- var peg$source = options.grammarSource;
152
- var peg$startRuleFunctions = { start: peg$parsestart };
153
- var peg$startRuleFunction = peg$parsestart;
154
- var peg$c0 = ">>>";
155
- var peg$c1 = "sql";
156
- var peg$c2 = "malloy";
157
- var peg$c3 = "markdown";
158
- var peg$c4 = "//";
159
- var peg$c5 = "--";
160
- var peg$c6 = "/*";
161
- var peg$c7 = "*/";
162
- var peg$r0 = /^[ \t]/;
163
- var peg$r1 = /^[\n\r]/;
164
- var peg$e0 = peg$otherExpectation("cell");
165
- var peg$e1 = peg$anyExpectation();
166
- var peg$e2 = peg$literalExpectation(">>>", false);
167
- var peg$e3 = peg$literalExpectation("sql", false);
168
- var peg$e4 = peg$literalExpectation("malloy", false);
169
- var peg$e5 = peg$literalExpectation("markdown", false);
170
- var peg$e6 = peg$otherExpectation("initial comments");
171
- var peg$e7 = peg$otherExpectation("comment");
172
- var peg$e8 = peg$literalExpectation("//", false);
173
- var peg$e9 = peg$literalExpectation("--", false);
174
- var peg$e10 = peg$literalExpectation("/*", false);
175
- var peg$e11 = peg$literalExpectation("*/", false);
176
- var peg$e12 = peg$classExpectation([" ", "\t"], false, false);
177
- var peg$e13 = peg$otherExpectation("end of line");
178
- var peg$e14 = peg$classExpectation(["\n", "\r"], false, false);
179
- var peg$f0 = function (c, s) {
128
+ const peg$FAILED = {};
129
+ const peg$source = options.grammarSource;
130
+ const peg$startRuleFunctions = {
131
+ start: peg$parsestart,
132
+ };
133
+ let peg$startRuleFunction = peg$parsestart;
134
+ const peg$c0 = ">>>";
135
+ const peg$c1 = "sql";
136
+ const peg$c2 = "malloy";
137
+ const peg$c3 = "markdown";
138
+ const peg$c4 = "//";
139
+ const peg$c5 = "--";
140
+ const peg$c6 = "/*";
141
+ const peg$c7 = "*/";
142
+ const peg$e0 = peg$anyExpectation();
143
+ const peg$e1 = peg$literalExpectation(">>>", false);
144
+ const peg$e2 = peg$literalExpectation("sql", false);
145
+ const peg$e3 = peg$literalExpectation("malloy", false);
146
+ const peg$e4 = peg$literalExpectation("markdown", false);
147
+ const peg$e5 = peg$otherExpectation("comment");
148
+ const peg$e6 = peg$literalExpectation("//", false);
149
+ const peg$e7 = peg$literalExpectation("--", false);
150
+ const peg$e8 = peg$literalExpectation("/*", false);
151
+ const peg$e9 = peg$literalExpectation("*/", false);
152
+ const peg$e10 = peg$classExpectation([" ", "\t"], false, false, false);
153
+ const peg$e11 = peg$otherExpectation("end of line");
154
+ const peg$e12 = peg$classExpectation(["\n", "\r"], false, false, false);
155
+ function peg$f0(c, s) {
180
156
  s["statementType"] = c.type;
181
157
  s["config"] = c.config;
182
158
  s["delimiterRange"] = c.range;
183
159
  return s;
184
- };
185
- var peg$f1 = function (p) {
160
+ }
161
+ function peg$f1(p) {
186
162
  return {
187
163
  parts: p,
188
164
  range: location(),
189
165
  statementText: p.text
190
166
  };
191
- };
192
- var peg$f2 = function (s) {
167
+ }
168
+ function peg$f2(s) {
193
169
  return {
194
170
  type: "other",
195
171
  text: s,
196
172
  range: location()
197
173
  };
198
- };
199
- var peg$f3 = function (t, oc) { return oc; };
200
- var peg$f4 = function (t, c) {
174
+ }
175
+ function peg$f3(t, oc) { return oc; }
176
+ function peg$f4(t, c) {
201
177
  return {
202
178
  type: t,
203
179
  config: c ? c.trim() : '',
204
180
  range: location()
205
181
  };
206
- };
207
- var peg$f5 = function (c) {
182
+ }
183
+ function peg$f5(c) {
208
184
  return {
209
185
  type: "comment",
210
186
  text: c,
211
187
  range: location()
212
188
  };
213
- };
214
- var peg$currPos = options.peg$currPos | 0;
215
- var peg$savedPos = peg$currPos;
216
- var peg$posDetailsCache = [{ line: 1, column: 1 }];
217
- var peg$maxFailPos = peg$currPos;
218
- var peg$maxFailExpected = options.peg$maxFailExpected || [];
219
- var peg$silentFails = options.peg$silentFails | 0;
220
- var peg$result;
189
+ }
190
+ let peg$currPos = options.peg$currPos | 0;
191
+ let peg$savedPos = peg$currPos;
192
+ const peg$posDetailsCache = [{ line: 1, column: 1 }];
193
+ let peg$maxFailPos = peg$currPos;
194
+ let peg$maxFailExpected = options.peg$maxFailExpected || [];
195
+ let peg$silentFails = options.peg$silentFails | 0;
196
+ let peg$result;
197
+ let peg$charCode;
221
198
  if (options.startRule) {
222
199
  if (!(options.startRule in peg$startRuleFunctions)) {
223
200
  throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
@@ -234,7 +211,7 @@ function peg$parse(input, options) {
234
211
  return {
235
212
  source: peg$source,
236
213
  start: peg$savedPos,
237
- end: peg$currPos
214
+ end: peg$currPos,
238
215
  };
239
216
  }
240
217
  function location() {
@@ -252,11 +229,18 @@ function peg$parse(input, options) {
252
229
  : peg$computeLocation(peg$savedPos, peg$currPos);
253
230
  throw peg$buildSimpleError(message, location);
254
231
  }
232
+ function peg$getUnicode(pos = peg$currPos) {
233
+ const cp = input.codePointAt(pos);
234
+ if (cp === undefined) {
235
+ return "";
236
+ }
237
+ return String.fromCodePoint(cp);
238
+ }
255
239
  function peg$literalExpectation(text, ignoreCase) {
256
- return { type: "literal", text: text, ignoreCase: ignoreCase };
240
+ return { type: "literal", text, ignoreCase };
257
241
  }
258
- function peg$classExpectation(parts, inverted, ignoreCase) {
259
- return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase };
242
+ function peg$classExpectation(parts, inverted, ignoreCase, unicode) {
243
+ return { type: "class", parts, inverted, ignoreCase, unicode };
260
244
  }
261
245
  function peg$anyExpectation() {
262
246
  return { type: "any" };
@@ -265,11 +249,11 @@ function peg$parse(input, options) {
265
249
  return { type: "end" };
266
250
  }
267
251
  function peg$otherExpectation(description) {
268
- return { type: "other", description: description };
252
+ return { type: "other", description };
269
253
  }
270
254
  function peg$computePosDetails(pos) {
271
- var details = peg$posDetailsCache[pos];
272
- var p;
255
+ let details = peg$posDetailsCache[pos];
256
+ let p;
273
257
  if (details) {
274
258
  return details;
275
259
  }
@@ -284,7 +268,7 @@ function peg$parse(input, options) {
284
268
  details = peg$posDetailsCache[p];
285
269
  details = {
286
270
  line: details.line,
287
- column: details.column
271
+ column: details.column,
288
272
  };
289
273
  while (p < pos) {
290
274
  if (input.charCodeAt(p) === 10) {
@@ -301,20 +285,20 @@ function peg$parse(input, options) {
301
285
  }
302
286
  }
303
287
  function peg$computeLocation(startPos, endPos, offset) {
304
- var startPosDetails = peg$computePosDetails(startPos);
305
- var endPosDetails = peg$computePosDetails(endPos);
306
- var res = {
288
+ const startPosDetails = peg$computePosDetails(startPos);
289
+ const endPosDetails = peg$computePosDetails(endPos);
290
+ const res = {
307
291
  source: peg$source,
308
292
  start: {
309
293
  offset: startPos,
310
294
  line: startPosDetails.line,
311
- column: startPosDetails.column
295
+ column: startPosDetails.column,
312
296
  },
313
297
  end: {
314
298
  offset: endPos,
315
299
  line: endPosDetails.line,
316
- column: endPosDetails.column
317
- }
300
+ column: endPosDetails.column,
301
+ },
318
302
  };
319
303
  if (offset && peg$source && (typeof peg$source.offset === "function")) {
320
304
  res.start = peg$source.offset(res.start);
@@ -339,7 +323,7 @@ function peg$parse(input, options) {
339
323
  return new peg$SyntaxError(peg$SyntaxError.buildMessage(expected, found), expected, found, location);
340
324
  }
341
325
  function peg$parsestart() {
342
- var s0, s1, s2, s3, s4;
326
+ let s0, s1, s2, s3, s4;
343
327
  s0 = peg$currPos;
344
328
  s1 = peg$parseinitial_comments();
345
329
  s2 = [];
@@ -367,7 +351,7 @@ function peg$parse(input, options) {
367
351
  return s0;
368
352
  }
369
353
  function peg$parsedelimiter_and_statement() {
370
- var s0, s1, s2;
354
+ let s0, s1, s2;
371
355
  s0 = peg$currPos;
372
356
  s1 = peg$parsedelimiter();
373
357
  if (s1 !== peg$FAILED) {
@@ -382,7 +366,7 @@ function peg$parse(input, options) {
382
366
  return s0;
383
367
  }
384
368
  function peg$parsestatement() {
385
- var s0, s1;
369
+ let s0, s1;
386
370
  s0 = peg$currPos;
387
371
  s1 = peg$parsecell();
388
372
  peg$savedPos = s0;
@@ -391,65 +375,12 @@ function peg$parse(input, options) {
391
375
  return s0;
392
376
  }
393
377
  function peg$parsecell() {
394
- var s0, s1, s2, s3, s4, s5, s6, s7;
378
+ let s0, s1, s2, s3, s4, s5, s6, s7;
395
379
  peg$silentFails++;
396
380
  s0 = peg$currPos;
397
381
  s1 = peg$currPos;
398
382
  s2 = [];
399
- s3 = peg$currPos;
400
- s4 = peg$currPos;
401
- peg$silentFails++;
402
- s5 = peg$currPos;
403
- s6 = peg$parseEOL();
404
- if (s6 !== peg$FAILED) {
405
- s7 = peg$parsedelimiter_start();
406
- if (s7 !== peg$FAILED) {
407
- s6 = [s6, s7];
408
- s5 = s6;
409
- }
410
- else {
411
- peg$currPos = s5;
412
- s5 = peg$FAILED;
413
- }
414
- }
415
- else {
416
- peg$currPos = s5;
417
- s5 = peg$FAILED;
418
- }
419
- peg$silentFails--;
420
- if (s5 === peg$FAILED) {
421
- s4 = undefined;
422
- }
423
- else {
424
- peg$currPos = s4;
425
- s4 = peg$FAILED;
426
- }
427
- if (s4 !== peg$FAILED) {
428
- if (input.length > peg$currPos) {
429
- s5 = input.charAt(peg$currPos);
430
- peg$currPos++;
431
- }
432
- else {
433
- s5 = peg$FAILED;
434
- if (peg$silentFails === 0) {
435
- peg$fail(peg$e1);
436
- }
437
- }
438
- if (s5 !== peg$FAILED) {
439
- s4 = [s4, s5];
440
- s3 = s4;
441
- }
442
- else {
443
- peg$currPos = s3;
444
- s3 = peg$FAILED;
445
- }
446
- }
447
- else {
448
- peg$currPos = s3;
449
- s3 = peg$FAILED;
450
- }
451
- while (s3 !== peg$FAILED) {
452
- s2.push(s3);
383
+ for (;;) {
453
384
  s3 = peg$currPos;
454
385
  s4 = peg$currPos;
455
386
  peg$silentFails++;
@@ -486,7 +417,7 @@ function peg$parse(input, options) {
486
417
  else {
487
418
  s5 = peg$FAILED;
488
419
  if (peg$silentFails === 0) {
489
- peg$fail(peg$e1);
420
+ peg$fail(peg$e0);
490
421
  }
491
422
  }
492
423
  if (s5 !== peg$FAILED) {
@@ -502,20 +433,20 @@ function peg$parse(input, options) {
502
433
  peg$currPos = s3;
503
434
  s3 = peg$FAILED;
504
435
  }
436
+ if (s3 === peg$FAILED) {
437
+ break;
438
+ }
439
+ s2.push(s3);
505
440
  }
506
441
  s1 = input.substring(s1, peg$currPos);
507
442
  peg$savedPos = s0;
508
443
  s1 = peg$f2(s1);
509
444
  s0 = s1;
510
445
  peg$silentFails--;
511
- s1 = peg$FAILED;
512
- if (peg$silentFails === 0) {
513
- peg$fail(peg$e0);
514
- }
515
446
  return s0;
516
447
  }
517
448
  function peg$parsedelimiter() {
518
- var s0, s1, s2, s3, s4, s5;
449
+ let s0, s1, s2, s3, s4, s5;
519
450
  s0 = peg$currPos;
520
451
  s1 = peg$parsedelimiter_start();
521
452
  if (s1 !== peg$FAILED) {
@@ -564,7 +495,7 @@ function peg$parse(input, options) {
564
495
  return s0;
565
496
  }
566
497
  function peg$parsedelimiter_start() {
567
- var s0;
498
+ let s0;
568
499
  if (input.substr(peg$currPos, 3) === peg$c0) {
569
500
  s0 = peg$c0;
570
501
  peg$currPos += 3;
@@ -572,13 +503,13 @@ function peg$parse(input, options) {
572
503
  else {
573
504
  s0 = peg$FAILED;
574
505
  if (peg$silentFails === 0) {
575
- peg$fail(peg$e2);
506
+ peg$fail(peg$e1);
576
507
  }
577
508
  }
578
509
  return s0;
579
510
  }
580
511
  function peg$parsestatement_type() {
581
- var s0;
512
+ let s0;
582
513
  if (input.substr(peg$currPos, 3) === peg$c1) {
583
514
  s0 = peg$c1;
584
515
  peg$currPos += 3;
@@ -586,7 +517,7 @@ function peg$parse(input, options) {
586
517
  else {
587
518
  s0 = peg$FAILED;
588
519
  if (peg$silentFails === 0) {
589
- peg$fail(peg$e3);
520
+ peg$fail(peg$e2);
590
521
  }
591
522
  }
592
523
  if (s0 === peg$FAILED) {
@@ -597,7 +528,7 @@ function peg$parse(input, options) {
597
528
  else {
598
529
  s0 = peg$FAILED;
599
530
  if (peg$silentFails === 0) {
600
- peg$fail(peg$e4);
531
+ peg$fail(peg$e3);
601
532
  }
602
533
  }
603
534
  if (s0 === peg$FAILED) {
@@ -608,7 +539,7 @@ function peg$parse(input, options) {
608
539
  else {
609
540
  s0 = peg$FAILED;
610
541
  if (peg$silentFails === 0) {
611
- peg$fail(peg$e5);
542
+ peg$fail(peg$e4);
612
543
  }
613
544
  }
614
545
  }
@@ -616,64 +547,10 @@ function peg$parse(input, options) {
616
547
  return s0;
617
548
  }
618
549
  function peg$parseoptional_config() {
619
- var s0, s1, s2, s3, s4, s5;
550
+ let s0, s1, s2, s3, s4, s5;
620
551
  s0 = peg$currPos;
621
552
  s1 = [];
622
- s2 = peg$currPos;
623
- s3 = peg$currPos;
624
- peg$silentFails++;
625
- s4 = peg$parsecomment();
626
- peg$silentFails--;
627
- if (s4 === peg$FAILED) {
628
- s3 = undefined;
629
- }
630
- else {
631
- peg$currPos = s3;
632
- s3 = peg$FAILED;
633
- }
634
- if (s3 !== peg$FAILED) {
635
- s4 = peg$currPos;
636
- peg$silentFails++;
637
- s5 = peg$parseEOL();
638
- peg$silentFails--;
639
- if (s5 === peg$FAILED) {
640
- s4 = undefined;
641
- }
642
- else {
643
- peg$currPos = s4;
644
- s4 = peg$FAILED;
645
- }
646
- if (s4 !== peg$FAILED) {
647
- if (input.length > peg$currPos) {
648
- s5 = input.charAt(peg$currPos);
649
- peg$currPos++;
650
- }
651
- else {
652
- s5 = peg$FAILED;
653
- if (peg$silentFails === 0) {
654
- peg$fail(peg$e1);
655
- }
656
- }
657
- if (s5 !== peg$FAILED) {
658
- s3 = [s3, s4, s5];
659
- s2 = s3;
660
- }
661
- else {
662
- peg$currPos = s2;
663
- s2 = peg$FAILED;
664
- }
665
- }
666
- else {
667
- peg$currPos = s2;
668
- s2 = peg$FAILED;
669
- }
670
- }
671
- else {
672
- peg$currPos = s2;
673
- s2 = peg$FAILED;
674
- }
675
- while (s2 !== peg$FAILED) {
676
- s1.push(s2);
553
+ for (;;) {
677
554
  s2 = peg$currPos;
678
555
  s3 = peg$currPos;
679
556
  peg$silentFails++;
@@ -706,7 +583,7 @@ function peg$parse(input, options) {
706
583
  else {
707
584
  s5 = peg$FAILED;
708
585
  if (peg$silentFails === 0) {
709
- peg$fail(peg$e1);
586
+ peg$fail(peg$e0);
710
587
  }
711
588
  }
712
589
  if (s5 !== peg$FAILED) {
@@ -727,24 +604,20 @@ function peg$parse(input, options) {
727
604
  peg$currPos = s2;
728
605
  s2 = peg$FAILED;
729
606
  }
607
+ if (s2 === peg$FAILED) {
608
+ break;
609
+ }
610
+ s1.push(s2);
730
611
  }
731
612
  s0 = input.substring(s0, peg$currPos);
732
613
  return s0;
733
614
  }
734
615
  function peg$parseinitial_comments() {
735
- var s0, s1, s2;
616
+ let s0, s1, s2;
736
617
  peg$silentFails++;
737
618
  s0 = peg$currPos;
738
619
  s1 = [];
739
- s2 = peg$parse_();
740
- if (s2 === peg$FAILED) {
741
- s2 = peg$parseEOL();
742
- if (s2 === peg$FAILED) {
743
- s2 = peg$parsecomment();
744
- }
745
- }
746
- while (s2 !== peg$FAILED) {
747
- s1.push(s2);
620
+ for (;;) {
748
621
  s2 = peg$parse_();
749
622
  if (s2 === peg$FAILED) {
750
623
  s2 = peg$parseEOL();
@@ -752,17 +625,17 @@ function peg$parse(input, options) {
752
625
  s2 = peg$parsecomment();
753
626
  }
754
627
  }
628
+ if (s2 === peg$FAILED) {
629
+ break;
630
+ }
631
+ s1.push(s2);
755
632
  }
756
633
  s0 = input.substring(s0, peg$currPos);
757
634
  peg$silentFails--;
758
- s1 = peg$FAILED;
759
- if (peg$silentFails === 0) {
760
- peg$fail(peg$e6);
761
- }
762
635
  return s0;
763
636
  }
764
637
  function peg$parsecomment() {
765
- var s0, s1;
638
+ let s0, s1;
766
639
  peg$silentFails++;
767
640
  s0 = peg$currPos;
768
641
  s1 = peg$parsesingle_comment();
@@ -778,13 +651,13 @@ function peg$parse(input, options) {
778
651
  if (s0 === peg$FAILED) {
779
652
  s1 = peg$FAILED;
780
653
  if (peg$silentFails === 0) {
781
- peg$fail(peg$e7);
654
+ peg$fail(peg$e5);
782
655
  }
783
656
  }
784
657
  return s0;
785
658
  }
786
659
  function peg$parsesingle_comment() {
787
- var s0, s1, s2, s3, s4, s5, s6;
660
+ let s0, s1, s2, s3, s4, s5, s6;
788
661
  s0 = peg$currPos;
789
662
  s1 = peg$currPos;
790
663
  if (input.substr(peg$currPos, 2) === peg$c4) {
@@ -794,7 +667,7 @@ function peg$parse(input, options) {
794
667
  else {
795
668
  s2 = peg$FAILED;
796
669
  if (peg$silentFails === 0) {
797
- peg$fail(peg$e8);
670
+ peg$fail(peg$e6);
798
671
  }
799
672
  }
800
673
  if (s2 === peg$FAILED) {
@@ -805,50 +678,13 @@ function peg$parse(input, options) {
805
678
  else {
806
679
  s2 = peg$FAILED;
807
680
  if (peg$silentFails === 0) {
808
- peg$fail(peg$e9);
681
+ peg$fail(peg$e7);
809
682
  }
810
683
  }
811
684
  }
812
685
  if (s2 !== peg$FAILED) {
813
686
  s3 = [];
814
- s4 = peg$currPos;
815
- s5 = peg$currPos;
816
- peg$silentFails++;
817
- s6 = peg$parseEOL();
818
- peg$silentFails--;
819
- if (s6 === peg$FAILED) {
820
- s5 = undefined;
821
- }
822
- else {
823
- peg$currPos = s5;
824
- s5 = peg$FAILED;
825
- }
826
- if (s5 !== peg$FAILED) {
827
- if (input.length > peg$currPos) {
828
- s6 = input.charAt(peg$currPos);
829
- peg$currPos++;
830
- }
831
- else {
832
- s6 = peg$FAILED;
833
- if (peg$silentFails === 0) {
834
- peg$fail(peg$e1);
835
- }
836
- }
837
- if (s6 !== peg$FAILED) {
838
- s5 = [s5, s6];
839
- s4 = s5;
840
- }
841
- else {
842
- peg$currPos = s4;
843
- s4 = peg$FAILED;
844
- }
845
- }
846
- else {
847
- peg$currPos = s4;
848
- s4 = peg$FAILED;
849
- }
850
- while (s4 !== peg$FAILED) {
851
- s3.push(s4);
687
+ for (;;) {
852
688
  s4 = peg$currPos;
853
689
  s5 = peg$currPos;
854
690
  peg$silentFails++;
@@ -869,7 +705,7 @@ function peg$parse(input, options) {
869
705
  else {
870
706
  s6 = peg$FAILED;
871
707
  if (peg$silentFails === 0) {
872
- peg$fail(peg$e1);
708
+ peg$fail(peg$e0);
873
709
  }
874
710
  }
875
711
  if (s6 !== peg$FAILED) {
@@ -885,6 +721,10 @@ function peg$parse(input, options) {
885
721
  peg$currPos = s4;
886
722
  s4 = peg$FAILED;
887
723
  }
724
+ if (s4 === peg$FAILED) {
725
+ break;
726
+ }
727
+ s3.push(s4);
888
728
  }
889
729
  s4 = peg$parse__();
890
730
  s5 = peg$parseEOL();
@@ -913,7 +753,7 @@ function peg$parse(input, options) {
913
753
  return s0;
914
754
  }
915
755
  function peg$parsemulti_comment() {
916
- var s0, s1, s2, s3, s4, s5, s6;
756
+ let s0, s1, s2, s3, s4, s5, s6;
917
757
  s0 = peg$currPos;
918
758
  s1 = peg$currPos;
919
759
  if (input.substr(peg$currPos, 2) === peg$c6) {
@@ -923,58 +763,12 @@ function peg$parse(input, options) {
923
763
  else {
924
764
  s2 = peg$FAILED;
925
765
  if (peg$silentFails === 0) {
926
- peg$fail(peg$e10);
766
+ peg$fail(peg$e8);
927
767
  }
928
768
  }
929
769
  if (s2 !== peg$FAILED) {
930
770
  s3 = [];
931
- s4 = peg$currPos;
932
- s5 = peg$currPos;
933
- peg$silentFails++;
934
- if (input.substr(peg$currPos, 2) === peg$c7) {
935
- s6 = peg$c7;
936
- peg$currPos += 2;
937
- }
938
- else {
939
- s6 = peg$FAILED;
940
- if (peg$silentFails === 0) {
941
- peg$fail(peg$e11);
942
- }
943
- }
944
- peg$silentFails--;
945
- if (s6 === peg$FAILED) {
946
- s5 = undefined;
947
- }
948
- else {
949
- peg$currPos = s5;
950
- s5 = peg$FAILED;
951
- }
952
- if (s5 !== peg$FAILED) {
953
- if (input.length > peg$currPos) {
954
- s6 = input.charAt(peg$currPos);
955
- peg$currPos++;
956
- }
957
- else {
958
- s6 = peg$FAILED;
959
- if (peg$silentFails === 0) {
960
- peg$fail(peg$e1);
961
- }
962
- }
963
- if (s6 !== peg$FAILED) {
964
- s5 = [s5, s6];
965
- s4 = s5;
966
- }
967
- else {
968
- peg$currPos = s4;
969
- s4 = peg$FAILED;
970
- }
971
- }
972
- else {
973
- peg$currPos = s4;
974
- s4 = peg$FAILED;
975
- }
976
- while (s4 !== peg$FAILED) {
977
- s3.push(s4);
771
+ for (;;) {
978
772
  s4 = peg$currPos;
979
773
  s5 = peg$currPos;
980
774
  peg$silentFails++;
@@ -985,7 +779,7 @@ function peg$parse(input, options) {
985
779
  else {
986
780
  s6 = peg$FAILED;
987
781
  if (peg$silentFails === 0) {
988
- peg$fail(peg$e11);
782
+ peg$fail(peg$e9);
989
783
  }
990
784
  }
991
785
  peg$silentFails--;
@@ -1004,7 +798,7 @@ function peg$parse(input, options) {
1004
798
  else {
1005
799
  s6 = peg$FAILED;
1006
800
  if (peg$silentFails === 0) {
1007
- peg$fail(peg$e1);
801
+ peg$fail(peg$e0);
1008
802
  }
1009
803
  }
1010
804
  if (s6 !== peg$FAILED) {
@@ -1020,6 +814,10 @@ function peg$parse(input, options) {
1020
814
  peg$currPos = s4;
1021
815
  s4 = peg$FAILED;
1022
816
  }
817
+ if (s4 === peg$FAILED) {
818
+ break;
819
+ }
820
+ s3.push(s4);
1023
821
  }
1024
822
  if (input.substr(peg$currPos, 2) === peg$c7) {
1025
823
  s4 = peg$c7;
@@ -1028,7 +826,7 @@ function peg$parse(input, options) {
1028
826
  else {
1029
827
  s4 = peg$FAILED;
1030
828
  if (peg$silentFails === 0) {
1031
- peg$fail(peg$e11);
829
+ peg$fail(peg$e9);
1032
830
  }
1033
831
  }
1034
832
  if (s4 !== peg$FAILED) {
@@ -1053,53 +851,55 @@ function peg$parse(input, options) {
1053
851
  return s0;
1054
852
  }
1055
853
  function peg$parse__() {
1056
- var s0, s1;
854
+ let s0, s1;
1057
855
  s0 = [];
1058
- s1 = peg$parse_();
1059
- while (s1 !== peg$FAILED) {
1060
- s0.push(s1);
856
+ for (;;) {
1061
857
  s1 = peg$parse_();
858
+ if (s1 === peg$FAILED) {
859
+ break;
860
+ }
861
+ s0.push(s1);
1062
862
  }
1063
863
  return s0;
1064
864
  }
1065
865
  function peg$parse_() {
1066
- var s0;
866
+ let s0;
1067
867
  s0 = input.charAt(peg$currPos);
1068
- if (peg$r0.test(s0)) {
868
+ if ((peg$charCode = s0.charCodeAt(0), peg$charCode === 32 || peg$charCode === 9)) {
1069
869
  peg$currPos++;
1070
870
  }
1071
871
  else {
1072
872
  s0 = peg$FAILED;
1073
873
  if (peg$silentFails === 0) {
1074
- peg$fail(peg$e12);
874
+ peg$fail(peg$e10);
1075
875
  }
1076
876
  }
1077
877
  return s0;
1078
878
  }
1079
879
  function peg$parseEOL() {
1080
- var s0, s1;
880
+ let s0, s1;
1081
881
  peg$silentFails++;
1082
882
  s0 = input.charAt(peg$currPos);
1083
- if (peg$r1.test(s0)) {
883
+ if ((peg$charCode = s0.charCodeAt(0), peg$charCode === 10 || peg$charCode === 13)) {
1084
884
  peg$currPos++;
1085
885
  }
1086
886
  else {
1087
887
  s0 = peg$FAILED;
1088
888
  if (peg$silentFails === 0) {
1089
- peg$fail(peg$e14);
889
+ peg$fail(peg$e12);
1090
890
  }
1091
891
  }
1092
892
  peg$silentFails--;
1093
893
  if (s0 === peg$FAILED) {
1094
894
  s1 = peg$FAILED;
1095
895
  if (peg$silentFails === 0) {
1096
- peg$fail(peg$e13);
896
+ peg$fail(peg$e11);
1097
897
  }
1098
898
  }
1099
899
  return s0;
1100
900
  }
1101
901
  function peg$parseEOF() {
1102
- var s0, s1;
902
+ let s0, s1;
1103
903
  s0 = peg$currPos;
1104
904
  peg$silentFails++;
1105
905
  if (input.length > peg$currPos) {
@@ -1109,7 +909,7 @@ function peg$parse(input, options) {
1109
909
  else {
1110
910
  s1 = peg$FAILED;
1111
911
  if (peg$silentFails === 0) {
1112
- peg$fail(peg$e1);
912
+ peg$fail(peg$e0);
1113
913
  }
1114
914
  }
1115
915
  peg$silentFails--;
@@ -1123,30 +923,36 @@ function peg$parse(input, options) {
1123
923
  return s0;
1124
924
  }
1125
925
  peg$result = peg$startRuleFunction();
926
+ const peg$success = (peg$result !== peg$FAILED && peg$currPos === input.length);
927
+ function peg$throw() {
928
+ if (peg$result !== peg$FAILED && peg$currPos < input.length) {
929
+ peg$fail(peg$endExpectation());
930
+ }
931
+ throw peg$buildStructuredError(peg$maxFailExpected, peg$maxFailPos < input.length ? peg$getUnicode(peg$maxFailPos) : null, peg$maxFailPos < input.length
932
+ ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)
933
+ : peg$computeLocation(peg$maxFailPos, peg$maxFailPos));
934
+ }
1126
935
  if (options.peg$library) {
1127
936
  return /** @type {any} */ ({
1128
937
  peg$result,
1129
938
  peg$currPos,
1130
939
  peg$FAILED,
1131
940
  peg$maxFailExpected,
1132
- peg$maxFailPos
941
+ peg$maxFailPos,
942
+ peg$success,
943
+ peg$throw: peg$success ? undefined : peg$throw,
1133
944
  });
1134
945
  }
1135
- if (peg$result !== peg$FAILED && peg$currPos === input.length) {
946
+ if (peg$success) {
1136
947
  return peg$result;
1137
948
  }
1138
949
  else {
1139
- if (peg$result !== peg$FAILED && peg$currPos < input.length) {
1140
- peg$fail(peg$endExpectation());
1141
- }
1142
- throw peg$buildStructuredError(peg$maxFailExpected, peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null, peg$maxFailPos < input.length
1143
- ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)
1144
- : peg$computeLocation(peg$maxFailPos, peg$maxFailPos));
950
+ peg$throw();
1145
951
  }
1146
952
  }
1147
953
  module.exports = {
1148
954
  StartRules: ["start"],
1149
955
  SyntaxError: peg$SyntaxError,
1150
- parse: peg$parse
956
+ parse: peg$parse,
1151
957
  };
1152
958
  //# sourceMappingURL=malloySQL.js.map