@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,195 +1,173 @@
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 = ")";
156
- var peg$c2 = "%{";
157
- var peg$c3 = "}%";
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("query string");
165
- var peg$e1 = peg$anyExpectation();
166
- var peg$e2 = peg$literalExpectation("(", false);
167
- var peg$e3 = peg$literalExpectation(")", false);
168
- var peg$e4 = peg$literalExpectation("%{", false);
169
- var peg$e5 = peg$literalExpectation("}%", false);
170
- var peg$e6 = peg$otherExpectation("comment");
171
- var peg$e7 = peg$literalExpectation("//", false);
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$classExpectation([" ", "\t"], false, false);
176
- var peg$e12 = peg$otherExpectation("end of line");
177
- var peg$e13 = peg$classExpectation(["\n", "\r"], false, false);
178
- var peg$f0 = function (p) {
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 = ")";
136
+ const peg$c2 = "%{";
137
+ const peg$c3 = "}%";
138
+ const peg$c4 = "//";
139
+ const peg$c5 = "--";
140
+ const peg$c6 = "/*";
141
+ const peg$c7 = "*/";
142
+ const peg$e0 = peg$otherExpectation("query string");
143
+ const peg$e1 = peg$anyExpectation();
144
+ const peg$e2 = peg$literalExpectation("(", false);
145
+ const peg$e3 = peg$literalExpectation(")", false);
146
+ const peg$e4 = peg$literalExpectation("%{", false);
147
+ const peg$e5 = peg$literalExpectation("}%", false);
148
+ const peg$e6 = peg$otherExpectation("comment");
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$literalExpectation("*/", false);
153
+ const peg$e11 = peg$classExpectation([" ", "\t"], false, false, false);
154
+ const peg$e12 = peg$otherExpectation("end of line");
155
+ const peg$e13 = peg$classExpectation(["\n", "\r"], false, false, false);
156
+ function peg$f0(p) {
179
157
  return {
180
158
  parts: p,
181
159
  range: location(),
182
160
  statementText: p.map((s) => { return s.text; }).join('')
183
161
  };
184
- };
185
- var peg$f1 = function (s) {
162
+ }
163
+ function peg$f1(s) {
186
164
  return {
187
165
  type: "other",
188
166
  text: s,
189
167
  range: location()
190
168
  };
191
- };
192
- var peg$f2 = function (em) {
169
+ }
170
+ function peg$f2(em) {
193
171
  return {
194
172
  type: "malloy",
195
173
  text: text(),
@@ -198,8 +176,8 @@ function peg$parse(input, options) {
198
176
  range: location(),
199
177
  parenthesized: true
200
178
  };
201
- };
202
- var peg$f3 = function (m) {
179
+ }
180
+ function peg$f3(m) {
203
181
  return {
204
182
  type: "malloy",
205
183
  text: text(),
@@ -208,27 +186,28 @@ function peg$parse(input, options) {
208
186
  range: location(),
209
187
  parenthesized: false
210
188
  };
211
- };
212
- var peg$f4 = function () {
189
+ }
190
+ function peg$f4() {
213
191
  return {
214
192
  malloyRange: location(),
215
193
  text: text()
216
194
  };
217
- };
218
- var peg$f5 = function (c) {
195
+ }
196
+ function peg$f5(c) {
219
197
  return {
220
198
  type: "comment",
221
199
  text: c,
222
200
  range: location()
223
201
  };
224
- };
225
- var peg$currPos = options.peg$currPos | 0;
226
- var peg$savedPos = peg$currPos;
227
- var peg$posDetailsCache = [{ line: 1, column: 1 }];
228
- var peg$maxFailPos = peg$currPos;
229
- var peg$maxFailExpected = options.peg$maxFailExpected || [];
230
- var peg$silentFails = options.peg$silentFails | 0;
231
- var peg$result;
202
+ }
203
+ let peg$currPos = options.peg$currPos | 0;
204
+ let peg$savedPos = peg$currPos;
205
+ const peg$posDetailsCache = [{ line: 1, column: 1 }];
206
+ let peg$maxFailPos = peg$currPos;
207
+ let peg$maxFailExpected = options.peg$maxFailExpected || [];
208
+ let peg$silentFails = options.peg$silentFails | 0;
209
+ let peg$result;
210
+ let peg$charCode;
232
211
  if (options.startRule) {
233
212
  if (!(options.startRule in peg$startRuleFunctions)) {
234
213
  throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
@@ -245,7 +224,7 @@ function peg$parse(input, options) {
245
224
  return {
246
225
  source: peg$source,
247
226
  start: peg$savedPos,
248
- end: peg$currPos
227
+ end: peg$currPos,
249
228
  };
250
229
  }
251
230
  function location() {
@@ -263,11 +242,18 @@ function peg$parse(input, options) {
263
242
  : peg$computeLocation(peg$savedPos, peg$currPos);
264
243
  throw peg$buildSimpleError(message, location);
265
244
  }
245
+ function peg$getUnicode(pos = peg$currPos) {
246
+ const cp = input.codePointAt(pos);
247
+ if (cp === undefined) {
248
+ return "";
249
+ }
250
+ return String.fromCodePoint(cp);
251
+ }
266
252
  function peg$literalExpectation(text, ignoreCase) {
267
- return { type: "literal", text: text, ignoreCase: ignoreCase };
253
+ return { type: "literal", text, ignoreCase };
268
254
  }
269
- function peg$classExpectation(parts, inverted, ignoreCase) {
270
- return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase };
255
+ function peg$classExpectation(parts, inverted, ignoreCase, unicode) {
256
+ return { type: "class", parts, inverted, ignoreCase, unicode };
271
257
  }
272
258
  function peg$anyExpectation() {
273
259
  return { type: "any" };
@@ -276,11 +262,11 @@ function peg$parse(input, options) {
276
262
  return { type: "end" };
277
263
  }
278
264
  function peg$otherExpectation(description) {
279
- return { type: "other", description: description };
265
+ return { type: "other", description };
280
266
  }
281
267
  function peg$computePosDetails(pos) {
282
- var details = peg$posDetailsCache[pos];
283
- var p;
268
+ let details = peg$posDetailsCache[pos];
269
+ let p;
284
270
  if (details) {
285
271
  return details;
286
272
  }
@@ -295,7 +281,7 @@ function peg$parse(input, options) {
295
281
  details = peg$posDetailsCache[p];
296
282
  details = {
297
283
  line: details.line,
298
- column: details.column
284
+ column: details.column,
299
285
  };
300
286
  while (p < pos) {
301
287
  if (input.charCodeAt(p) === 10) {
@@ -312,20 +298,20 @@ function peg$parse(input, options) {
312
298
  }
313
299
  }
314
300
  function peg$computeLocation(startPos, endPos, offset) {
315
- var startPosDetails = peg$computePosDetails(startPos);
316
- var endPosDetails = peg$computePosDetails(endPos);
317
- var res = {
301
+ const startPosDetails = peg$computePosDetails(startPos);
302
+ const endPosDetails = peg$computePosDetails(endPos);
303
+ const res = {
318
304
  source: peg$source,
319
305
  start: {
320
306
  offset: startPos,
321
307
  line: startPosDetails.line,
322
- column: startPosDetails.column
308
+ column: startPosDetails.column,
323
309
  },
324
310
  end: {
325
311
  offset: endPos,
326
312
  line: endPosDetails.line,
327
- column: endPosDetails.column
328
- }
313
+ column: endPosDetails.column,
314
+ },
329
315
  };
330
316
  if (offset && peg$source && (typeof peg$source.offset === "function")) {
331
317
  res.start = peg$source.offset(res.start);
@@ -350,23 +336,15 @@ function peg$parse(input, options) {
350
336
  return new peg$SyntaxError(peg$SyntaxError.buildMessage(expected, found), expected, found, location);
351
337
  }
352
338
  function peg$parsestart() {
353
- var s0;
339
+ let s0;
354
340
  s0 = peg$parsestatement();
355
341
  return s0;
356
342
  }
357
343
  function peg$parsestatement() {
358
- var s0, s1, s2;
344
+ let s0, s1, s2;
359
345
  s0 = peg$currPos;
360
346
  s1 = [];
361
- s2 = peg$parsecomment();
362
- if (s2 === peg$FAILED) {
363
- s2 = peg$parseembedded_malloy();
364
- if (s2 === peg$FAILED) {
365
- s2 = peg$parseother();
366
- }
367
- }
368
- while (s2 !== peg$FAILED) {
369
- s1.push(s2);
347
+ for (;;) {
370
348
  s2 = peg$parsecomment();
371
349
  if (s2 === peg$FAILED) {
372
350
  s2 = peg$parseembedded_malloy();
@@ -374,6 +352,10 @@ function peg$parse(input, options) {
374
352
  s2 = peg$parseother();
375
353
  }
376
354
  }
355
+ if (s2 === peg$FAILED) {
356
+ break;
357
+ }
358
+ s1.push(s2);
377
359
  }
378
360
  peg$savedPos = s0;
379
361
  s1 = peg$f0(s1);
@@ -381,111 +363,51 @@ function peg$parse(input, options) {
381
363
  return s0;
382
364
  }
383
365
  function peg$parseother() {
384
- var s0, s1, s2, s3, s4, s5, s6;
366
+ let s0, s1, s2, s3, s4, s5, s6;
385
367
  peg$silentFails++;
386
368
  s0 = peg$currPos;
387
369
  s1 = peg$currPos;
388
370
  s2 = [];
389
- s3 = peg$currPos;
390
- s4 = peg$currPos;
391
- peg$silentFails++;
392
- s5 = peg$parsecomment();
393
- peg$silentFails--;
394
- if (s5 === peg$FAILED) {
395
- s4 = undefined;
396
- }
397
- else {
398
- peg$currPos = s4;
399
- s4 = peg$FAILED;
400
- }
401
- if (s4 !== peg$FAILED) {
402
- s5 = peg$currPos;
371
+ for (;;) {
372
+ s3 = peg$currPos;
373
+ s4 = peg$currPos;
403
374
  peg$silentFails++;
404
- s6 = peg$parseembedded_malloy();
375
+ s5 = peg$parsecomment();
405
376
  peg$silentFails--;
406
- if (s6 === peg$FAILED) {
407
- s5 = undefined;
408
- }
409
- else {
410
- peg$currPos = s5;
411
- s5 = peg$FAILED;
412
- }
413
- if (s5 !== peg$FAILED) {
414
- if (input.length > peg$currPos) {
415
- s6 = input.charAt(peg$currPos);
416
- peg$currPos++;
417
- }
418
- else {
419
- s6 = peg$FAILED;
420
- if (peg$silentFails === 0) {
421
- peg$fail(peg$e1);
422
- }
423
- }
424
- if (s6 !== peg$FAILED) {
425
- s4 = [s4, s5, s6];
426
- s3 = s4;
427
- }
428
- else {
429
- peg$currPos = s3;
430
- s3 = peg$FAILED;
431
- }
377
+ if (s5 === peg$FAILED) {
378
+ s4 = undefined;
432
379
  }
433
380
  else {
434
- peg$currPos = s3;
435
- s3 = peg$FAILED;
381
+ peg$currPos = s4;
382
+ s4 = peg$FAILED;
436
383
  }
437
- }
438
- else {
439
- peg$currPos = s3;
440
- s3 = peg$FAILED;
441
- }
442
- if (s3 !== peg$FAILED) {
443
- while (s3 !== peg$FAILED) {
444
- s2.push(s3);
445
- s3 = peg$currPos;
446
- s4 = peg$currPos;
384
+ if (s4 !== peg$FAILED) {
385
+ s5 = peg$currPos;
447
386
  peg$silentFails++;
448
- s5 = peg$parsecomment();
387
+ s6 = peg$parseembedded_malloy();
449
388
  peg$silentFails--;
450
- if (s5 === peg$FAILED) {
451
- s4 = undefined;
389
+ if (s6 === peg$FAILED) {
390
+ s5 = undefined;
452
391
  }
453
392
  else {
454
- peg$currPos = s4;
455
- s4 = peg$FAILED;
393
+ peg$currPos = s5;
394
+ s5 = peg$FAILED;
456
395
  }
457
- if (s4 !== peg$FAILED) {
458
- s5 = peg$currPos;
459
- peg$silentFails++;
460
- s6 = peg$parseembedded_malloy();
461
- peg$silentFails--;
462
- if (s6 === peg$FAILED) {
463
- s5 = undefined;
396
+ if (s5 !== peg$FAILED) {
397
+ if (input.length > peg$currPos) {
398
+ s6 = input.charAt(peg$currPos);
399
+ peg$currPos++;
464
400
  }
465
401
  else {
466
- peg$currPos = s5;
467
- s5 = peg$FAILED;
468
- }
469
- if (s5 !== peg$FAILED) {
470
- if (input.length > peg$currPos) {
471
- s6 = input.charAt(peg$currPos);
472
- peg$currPos++;
473
- }
474
- else {
475
- s6 = peg$FAILED;
476
- if (peg$silentFails === 0) {
477
- peg$fail(peg$e1);
478
- }
479
- }
480
- if (s6 !== peg$FAILED) {
481
- s4 = [s4, s5, s6];
482
- s3 = s4;
483
- }
484
- else {
485
- peg$currPos = s3;
486
- s3 = peg$FAILED;
402
+ s6 = peg$FAILED;
403
+ if (peg$silentFails === 0) {
404
+ peg$fail(peg$e1);
487
405
  }
488
406
  }
407
+ if (s6 !== peg$FAILED) {
408
+ s4 = [s4, s5, s6];
409
+ s3 = s4;
410
+ }
489
411
  else {
490
412
  peg$currPos = s3;
491
413
  s3 = peg$FAILED;
@@ -496,8 +418,16 @@ function peg$parse(input, options) {
496
418
  s3 = peg$FAILED;
497
419
  }
498
420
  }
421
+ else {
422
+ peg$currPos = s3;
423
+ s3 = peg$FAILED;
424
+ }
425
+ if (s3 === peg$FAILED) {
426
+ break;
427
+ }
428
+ s2.push(s3);
499
429
  }
500
- else {
430
+ if (s2.length < 1) {
501
431
  s2 = peg$FAILED;
502
432
  }
503
433
  if (s2 !== peg$FAILED) {
@@ -521,7 +451,7 @@ function peg$parse(input, options) {
521
451
  return s0;
522
452
  }
523
453
  function peg$parseembedded_malloy() {
524
- var s0;
454
+ let s0;
525
455
  s0 = peg$parseparenthesized_embedded_malloy();
526
456
  if (s0 === peg$FAILED) {
527
457
  s0 = peg$parseplain_embedded_malloy();
@@ -529,7 +459,7 @@ function peg$parse(input, options) {
529
459
  return s0;
530
460
  }
531
461
  function peg$parseparenthesized_embedded_malloy() {
532
- var s0, s1, s2, s3, s4, s5;
462
+ let s0, s1, s2, s3, s4, s5;
533
463
  s0 = peg$currPos;
534
464
  if (input.charCodeAt(peg$currPos) === 40) {
535
465
  s1 = peg$c0;
@@ -577,7 +507,7 @@ function peg$parse(input, options) {
577
507
  return s0;
578
508
  }
579
509
  function peg$parseplain_embedded_malloy() {
580
- var s0, s1, s2, s3;
510
+ let s0, s1, s2, s3;
581
511
  s0 = peg$currPos;
582
512
  if (input.substr(peg$currPos, 2) === peg$c2) {
583
513
  s1 = peg$c2;
@@ -617,56 +547,10 @@ function peg$parse(input, options) {
617
547
  return s0;
618
548
  }
619
549
  function peg$parsemalloy() {
620
- var s0, s1, s2, s3, s4;
550
+ let s0, s1, s2, s3, s4;
621
551
  s0 = peg$currPos;
622
552
  s1 = [];
623
- s2 = peg$currPos;
624
- s3 = peg$currPos;
625
- peg$silentFails++;
626
- if (input.substr(peg$currPos, 2) === peg$c3) {
627
- s4 = peg$c3;
628
- peg$currPos += 2;
629
- }
630
- else {
631
- s4 = peg$FAILED;
632
- if (peg$silentFails === 0) {
633
- peg$fail(peg$e5);
634
- }
635
- }
636
- peg$silentFails--;
637
- if (s4 === peg$FAILED) {
638
- s3 = undefined;
639
- }
640
- else {
641
- peg$currPos = s3;
642
- s3 = peg$FAILED;
643
- }
644
- if (s3 !== peg$FAILED) {
645
- if (input.length > peg$currPos) {
646
- s4 = input.charAt(peg$currPos);
647
- peg$currPos++;
648
- }
649
- else {
650
- s4 = peg$FAILED;
651
- if (peg$silentFails === 0) {
652
- peg$fail(peg$e1);
653
- }
654
- }
655
- if (s4 !== peg$FAILED) {
656
- s3 = [s3, s4];
657
- s2 = s3;
658
- }
659
- else {
660
- peg$currPos = s2;
661
- s2 = peg$FAILED;
662
- }
663
- }
664
- else {
665
- peg$currPos = s2;
666
- s2 = peg$FAILED;
667
- }
668
- while (s2 !== peg$FAILED) {
669
- s1.push(s2);
553
+ for (;;) {
670
554
  s2 = peg$currPos;
671
555
  s3 = peg$currPos;
672
556
  peg$silentFails++;
@@ -712,6 +596,10 @@ function peg$parse(input, options) {
712
596
  peg$currPos = s2;
713
597
  s2 = peg$FAILED;
714
598
  }
599
+ if (s2 === peg$FAILED) {
600
+ break;
601
+ }
602
+ s1.push(s2);
715
603
  }
716
604
  peg$savedPos = s0;
717
605
  s1 = peg$f4();
@@ -719,7 +607,7 @@ function peg$parse(input, options) {
719
607
  return s0;
720
608
  }
721
609
  function peg$parsecomment() {
722
- var s0, s1;
610
+ let s0, s1;
723
611
  peg$silentFails++;
724
612
  s0 = peg$currPos;
725
613
  s1 = peg$parsesingle_comment();
@@ -741,7 +629,7 @@ function peg$parse(input, options) {
741
629
  return s0;
742
630
  }
743
631
  function peg$parsesingle_comment() {
744
- var s0, s1, s2, s3, s4, s5, s6;
632
+ let s0, s1, s2, s3, s4, s5, s6;
745
633
  s0 = peg$currPos;
746
634
  s1 = peg$currPos;
747
635
  if (input.substr(peg$currPos, 2) === peg$c4) {
@@ -768,44 +656,7 @@ function peg$parse(input, options) {
768
656
  }
769
657
  if (s2 !== peg$FAILED) {
770
658
  s3 = [];
771
- s4 = peg$currPos;
772
- s5 = peg$currPos;
773
- peg$silentFails++;
774
- s6 = peg$parseEOL();
775
- peg$silentFails--;
776
- if (s6 === peg$FAILED) {
777
- s5 = undefined;
778
- }
779
- else {
780
- peg$currPos = s5;
781
- s5 = peg$FAILED;
782
- }
783
- if (s5 !== peg$FAILED) {
784
- if (input.length > peg$currPos) {
785
- s6 = input.charAt(peg$currPos);
786
- peg$currPos++;
787
- }
788
- else {
789
- s6 = peg$FAILED;
790
- if (peg$silentFails === 0) {
791
- peg$fail(peg$e1);
792
- }
793
- }
794
- if (s6 !== peg$FAILED) {
795
- s5 = [s5, s6];
796
- s4 = s5;
797
- }
798
- else {
799
- peg$currPos = s4;
800
- s4 = peg$FAILED;
801
- }
802
- }
803
- else {
804
- peg$currPos = s4;
805
- s4 = peg$FAILED;
806
- }
807
- while (s4 !== peg$FAILED) {
808
- s3.push(s4);
659
+ for (;;) {
809
660
  s4 = peg$currPos;
810
661
  s5 = peg$currPos;
811
662
  peg$silentFails++;
@@ -842,6 +693,10 @@ function peg$parse(input, options) {
842
693
  peg$currPos = s4;
843
694
  s4 = peg$FAILED;
844
695
  }
696
+ if (s4 === peg$FAILED) {
697
+ break;
698
+ }
699
+ s3.push(s4);
845
700
  }
846
701
  s4 = peg$parse__();
847
702
  s5 = peg$parseEOL();
@@ -870,7 +725,7 @@ function peg$parse(input, options) {
870
725
  return s0;
871
726
  }
872
727
  function peg$parsemulti_comment() {
873
- var s0, s1, s2, s3, s4, s5, s6;
728
+ let s0, s1, s2, s3, s4, s5, s6;
874
729
  s0 = peg$currPos;
875
730
  s1 = peg$currPos;
876
731
  if (input.substr(peg$currPos, 2) === peg$c6) {
@@ -885,53 +740,7 @@ function peg$parse(input, options) {
885
740
  }
886
741
  if (s2 !== peg$FAILED) {
887
742
  s3 = [];
888
- s4 = peg$currPos;
889
- s5 = peg$currPos;
890
- peg$silentFails++;
891
- if (input.substr(peg$currPos, 2) === peg$c7) {
892
- s6 = peg$c7;
893
- peg$currPos += 2;
894
- }
895
- else {
896
- s6 = peg$FAILED;
897
- if (peg$silentFails === 0) {
898
- peg$fail(peg$e10);
899
- }
900
- }
901
- peg$silentFails--;
902
- if (s6 === peg$FAILED) {
903
- s5 = undefined;
904
- }
905
- else {
906
- peg$currPos = s5;
907
- s5 = peg$FAILED;
908
- }
909
- if (s5 !== peg$FAILED) {
910
- if (input.length > peg$currPos) {
911
- s6 = input.charAt(peg$currPos);
912
- peg$currPos++;
913
- }
914
- else {
915
- s6 = peg$FAILED;
916
- if (peg$silentFails === 0) {
917
- peg$fail(peg$e1);
918
- }
919
- }
920
- if (s6 !== peg$FAILED) {
921
- s5 = [s5, s6];
922
- s4 = s5;
923
- }
924
- else {
925
- peg$currPos = s4;
926
- s4 = peg$FAILED;
927
- }
928
- }
929
- else {
930
- peg$currPos = s4;
931
- s4 = peg$FAILED;
932
- }
933
- while (s4 !== peg$FAILED) {
934
- s3.push(s4);
743
+ for (;;) {
935
744
  s4 = peg$currPos;
936
745
  s5 = peg$currPos;
937
746
  peg$silentFails++;
@@ -977,6 +786,10 @@ function peg$parse(input, options) {
977
786
  peg$currPos = s4;
978
787
  s4 = peg$FAILED;
979
788
  }
789
+ if (s4 === peg$FAILED) {
790
+ break;
791
+ }
792
+ s3.push(s4);
980
793
  }
981
794
  if (input.substr(peg$currPos, 2) === peg$c7) {
982
795
  s4 = peg$c7;
@@ -1010,19 +823,21 @@ function peg$parse(input, options) {
1010
823
  return s0;
1011
824
  }
1012
825
  function peg$parse__() {
1013
- var s0, s1;
826
+ let s0, s1;
1014
827
  s0 = [];
1015
- s1 = peg$parse_();
1016
- while (s1 !== peg$FAILED) {
1017
- s0.push(s1);
828
+ for (;;) {
1018
829
  s1 = peg$parse_();
830
+ if (s1 === peg$FAILED) {
831
+ break;
832
+ }
833
+ s0.push(s1);
1019
834
  }
1020
835
  return s0;
1021
836
  }
1022
837
  function peg$parse_() {
1023
- var s0;
838
+ let s0;
1024
839
  s0 = input.charAt(peg$currPos);
1025
- if (peg$r0.test(s0)) {
840
+ if ((peg$charCode = s0.charCodeAt(0), peg$charCode === 32 || peg$charCode === 9)) {
1026
841
  peg$currPos++;
1027
842
  }
1028
843
  else {
@@ -1034,10 +849,10 @@ function peg$parse(input, options) {
1034
849
  return s0;
1035
850
  }
1036
851
  function peg$parseEOL() {
1037
- var s0, s1;
852
+ let s0, s1;
1038
853
  peg$silentFails++;
1039
854
  s0 = input.charAt(peg$currPos);
1040
- if (peg$r1.test(s0)) {
855
+ if ((peg$charCode = s0.charCodeAt(0), peg$charCode === 10 || peg$charCode === 13)) {
1041
856
  peg$currPos++;
1042
857
  }
1043
858
  else {
@@ -1056,7 +871,7 @@ function peg$parse(input, options) {
1056
871
  return s0;
1057
872
  }
1058
873
  function peg$parseEOF() {
1059
- var s0, s1;
874
+ let s0, s1;
1060
875
  s0 = peg$currPos;
1061
876
  peg$silentFails++;
1062
877
  if (input.length > peg$currPos) {
@@ -1080,30 +895,36 @@ function peg$parse(input, options) {
1080
895
  return s0;
1081
896
  }
1082
897
  peg$result = peg$startRuleFunction();
898
+ const peg$success = (peg$result !== peg$FAILED && peg$currPos === input.length);
899
+ function peg$throw() {
900
+ if (peg$result !== peg$FAILED && peg$currPos < input.length) {
901
+ peg$fail(peg$endExpectation());
902
+ }
903
+ throw peg$buildStructuredError(peg$maxFailExpected, peg$maxFailPos < input.length ? peg$getUnicode(peg$maxFailPos) : null, peg$maxFailPos < input.length
904
+ ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)
905
+ : peg$computeLocation(peg$maxFailPos, peg$maxFailPos));
906
+ }
1083
907
  if (options.peg$library) {
1084
908
  return /** @type {any} */ ({
1085
909
  peg$result,
1086
910
  peg$currPos,
1087
911
  peg$FAILED,
1088
912
  peg$maxFailExpected,
1089
- peg$maxFailPos
913
+ peg$maxFailPos,
914
+ peg$success,
915
+ peg$throw: peg$success ? undefined : peg$throw,
1090
916
  });
1091
917
  }
1092
- if (peg$result !== peg$FAILED && peg$currPos === input.length) {
918
+ if (peg$success) {
1093
919
  return peg$result;
1094
920
  }
1095
921
  else {
1096
- if (peg$result !== peg$FAILED && peg$currPos < input.length) {
1097
- peg$fail(peg$endExpectation());
1098
- }
1099
- throw peg$buildStructuredError(peg$maxFailExpected, peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null, peg$maxFailPos < input.length
1100
- ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)
1101
- : peg$computeLocation(peg$maxFailPos, peg$maxFailPos));
922
+ peg$throw();
1102
923
  }
1103
924
  }
1104
925
  module.exports = {
1105
926
  StartRules: ["start"],
1106
927
  SyntaxError: peg$SyntaxError,
1107
- parse: peg$parse
928
+ parse: peg$parse,
1108
929
  };
1109
930
  //# sourceMappingURL=malloySQLSQL.js.map