@malloydata/malloy 0.0.51-dev230629171920 → 0.0.51-dev230705184641
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.
- package/dist/index.d.ts +1 -1
- package/dist/lang/ast/elements/define-query.d.ts +3 -5
- package/dist/lang/ast/elements/define-query.js +1 -4
- package/dist/lang/ast/elements/define-source.d.ts +3 -5
- package/dist/lang/ast/elements/define-source.js +1 -4
- package/dist/lang/ast/elements/import-statement.d.ts +2 -1
- package/dist/lang/ast/elements/import-statement.js +12 -5
- package/dist/lang/ast/index.d.ts +1 -0
- package/dist/lang/ast/index.js +1 -0
- package/dist/lang/ast/query-elements/anonymous-query.d.ts +1 -2
- package/dist/lang/ast/query-elements/anonymous-query.js +0 -1
- package/dist/lang/ast/query-elements/run-query.d.ts +3 -4
- package/dist/lang/ast/sources/from-sql-source.d.ts +7 -0
- package/dist/lang/ast/sources/from-sql-source.js +68 -0
- package/dist/lang/ast/sources/sql-source.d.ts +15 -4
- package/dist/lang/ast/sources/sql-source.js +79 -27
- package/dist/lang/ast/sql-elements/sql-statement.d.ts +3 -1
- package/dist/lang/ast/sql-elements/sql-statement.js +21 -10
- package/dist/lang/ast/sql-elements/sql-string.d.ts +1 -0
- package/dist/lang/ast/sql-elements/sql-string.js +8 -0
- package/dist/lang/ast/types/malloy-element.d.ts +9 -6
- package/dist/lang/ast/types/malloy-element.js +42 -14
- package/dist/lang/lib/Malloy/MalloyLexer.d.ts +73 -72
- package/dist/lang/lib/Malloy/MalloyLexer.js +1078 -1072
- package/dist/lang/lib/Malloy/MalloyParser.d.ts +86 -73
- package/dist/lang/lib/Malloy/MalloyParser.js +1198 -1135
- package/dist/lang/lib/Malloy/MalloyParserListener.d.ts +13 -0
- package/dist/lang/lib/Malloy/MalloyParserVisitor.d.ts +8 -0
- package/dist/lang/malloy-to-ast.d.ts +3 -2
- package/dist/lang/malloy-to-ast.js +17 -3
- package/dist/lang/parse-malloy.js +3 -3
- package/dist/lang/test/parse.spec.js +88 -1
- package/dist/lang/zone.d.ts +1 -1
- package/dist/malloy.js +1 -1
- package/dist/tags.d.ts +1 -1
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ModelAnnotation = exports.ObjectAnnotation = exports.Document = exports.
|
|
6
|
+
exports.ModelAnnotation = exports.ObjectAnnotation = exports.Document = exports.DocStatementList = exports.ListOf = exports.isDocStatementOrDocStatementList = exports.isDocStatement = exports.ModelEntryReference = exports.Unimplemented = exports.MalloyElement = void 0;
|
|
7
7
|
/*
|
|
8
8
|
* Copyright 2023 Google LLC
|
|
9
9
|
*
|
|
@@ -202,16 +202,15 @@ class MalloyElement {
|
|
|
202
202
|
}
|
|
203
203
|
return asString;
|
|
204
204
|
}
|
|
205
|
-
walk(
|
|
206
|
-
callBack(this);
|
|
205
|
+
*walk() {
|
|
207
206
|
for (const kidLabel of Object.keys(this.children)) {
|
|
208
207
|
const kiddle = this.children[kidLabel];
|
|
209
208
|
if (kiddle instanceof MalloyElement) {
|
|
210
|
-
kiddle
|
|
209
|
+
yield kiddle;
|
|
211
210
|
}
|
|
212
211
|
else {
|
|
213
212
|
for (const k of kiddle) {
|
|
214
|
-
k
|
|
213
|
+
yield k;
|
|
215
214
|
}
|
|
216
215
|
}
|
|
217
216
|
}
|
|
@@ -234,6 +233,13 @@ class MalloyElement {
|
|
|
234
233
|
this.log(`INTERNAL ERROR IN TRANSLATION: ${msg}`);
|
|
235
234
|
return new Error(msg);
|
|
236
235
|
}
|
|
236
|
+
needs(doc) {
|
|
237
|
+
for (const child of this.walk()) {
|
|
238
|
+
const childNeeds = child.needs(doc);
|
|
239
|
+
if (childNeeds)
|
|
240
|
+
return childNeeds;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
237
243
|
}
|
|
238
244
|
exports.MalloyElement = MalloyElement;
|
|
239
245
|
class Unimplemented extends MalloyElement {
|
|
@@ -262,6 +268,10 @@ function isDocStatement(e) {
|
|
|
262
268
|
return e.execute !== undefined;
|
|
263
269
|
}
|
|
264
270
|
exports.isDocStatement = isDocStatement;
|
|
271
|
+
function isDocStatementOrDocStatementList(el) {
|
|
272
|
+
return el instanceof DocStatementList || isDocStatement(el);
|
|
273
|
+
}
|
|
274
|
+
exports.isDocStatementOrDocStatementList = isDocStatementOrDocStatementList;
|
|
265
275
|
class ListOf extends MalloyElement {
|
|
266
276
|
constructor(elements) {
|
|
267
277
|
super();
|
|
@@ -285,9 +295,16 @@ class ListOf extends MalloyElement {
|
|
|
285
295
|
this.newContents();
|
|
286
296
|
return this.elements;
|
|
287
297
|
}
|
|
298
|
+
needs(doc) {
|
|
299
|
+
for (const element of this.elements) {
|
|
300
|
+
const elementNeeds = element.needs(doc);
|
|
301
|
+
if (elementNeeds)
|
|
302
|
+
return elementNeeds;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
288
305
|
}
|
|
289
306
|
exports.ListOf = ListOf;
|
|
290
|
-
class
|
|
307
|
+
class DocStatementList extends ListOf {
|
|
291
308
|
constructor() {
|
|
292
309
|
super(...arguments);
|
|
293
310
|
this.elementType = 'topLevelStatements';
|
|
@@ -307,18 +324,30 @@ class RunList extends ListOf {
|
|
|
307
324
|
}
|
|
308
325
|
this.noteCursor += 1;
|
|
309
326
|
}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
327
|
+
// For DocStatementLists, we want to incrementally execute
|
|
328
|
+
// the list, returning needs only when individual statements
|
|
329
|
+
// report needs, not when the whole list has needs (because
|
|
330
|
+
// the needs of one statement in a list may depend on those
|
|
331
|
+
// of another statement earlier in the list). For regular
|
|
332
|
+
// DocStatements, we first check their needs and return them
|
|
333
|
+
// if there are any; otherwise we execute the statement.
|
|
334
|
+
if (el instanceof DocStatementList) {
|
|
335
|
+
const needs = el.executeList(doc);
|
|
336
|
+
if (needs)
|
|
337
|
+
return needs;
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
const needs = el.needs(doc);
|
|
341
|
+
if (needs)
|
|
342
|
+
return needs;
|
|
343
|
+
el.execute(doc);
|
|
315
344
|
}
|
|
316
345
|
this.execCursor += 1;
|
|
317
346
|
}
|
|
318
347
|
return undefined;
|
|
319
348
|
}
|
|
320
349
|
}
|
|
321
|
-
exports.
|
|
350
|
+
exports.DocStatementList = DocStatementList;
|
|
322
351
|
/**
|
|
323
352
|
* The Document class is a little weird because we might need to bounce back
|
|
324
353
|
* to the requestor, which might be on the other side of a wire, to get
|
|
@@ -342,7 +371,7 @@ class Document extends MalloyElement {
|
|
|
342
371
|
this.sqlBlocks = [];
|
|
343
372
|
this.didInitModel = false;
|
|
344
373
|
this.notes = [];
|
|
345
|
-
this.statements = new
|
|
374
|
+
this.statements = new DocStatementList(statements);
|
|
346
375
|
this.has({ statements: statements });
|
|
347
376
|
}
|
|
348
377
|
initModelDef(extendingModelDef) {
|
|
@@ -435,7 +464,6 @@ class ModelAnnotation extends ObjectAnnotation {
|
|
|
435
464
|
}
|
|
436
465
|
execute(doc) {
|
|
437
466
|
doc.notes = doc.notes.concat(this.notes);
|
|
438
|
-
return;
|
|
439
467
|
}
|
|
440
468
|
}
|
|
441
469
|
exports.ModelAnnotation = ModelAnnotation;
|
|
@@ -31,7 +31,7 @@ export declare class MalloyLexer extends Lexer {
|
|
|
31
31
|
static readonly SAMPLE = 26;
|
|
32
32
|
static readonly SELECT = 27;
|
|
33
33
|
static readonly SOURCE = 28;
|
|
34
|
-
static readonly
|
|
34
|
+
static readonly SQLC = 29;
|
|
35
35
|
static readonly TOP = 30;
|
|
36
36
|
static readonly WHERE = 31;
|
|
37
37
|
static readonly TIMEZONE = 32;
|
|
@@ -78,77 +78,78 @@ export declare class MalloyLexer extends Lexer {
|
|
|
78
78
|
static readonly SECOND = 73;
|
|
79
79
|
static readonly STRING = 74;
|
|
80
80
|
static readonly SUM = 75;
|
|
81
|
-
static readonly
|
|
82
|
-
static readonly
|
|
83
|
-
static readonly
|
|
84
|
-
static readonly
|
|
85
|
-
static readonly
|
|
86
|
-
static readonly
|
|
87
|
-
static readonly
|
|
88
|
-
static readonly
|
|
89
|
-
static readonly
|
|
90
|
-
static readonly
|
|
91
|
-
static readonly
|
|
92
|
-
static readonly
|
|
93
|
-
static readonly
|
|
94
|
-
static readonly
|
|
95
|
-
static readonly
|
|
96
|
-
static readonly
|
|
97
|
-
static readonly
|
|
98
|
-
static readonly
|
|
99
|
-
static readonly
|
|
100
|
-
static readonly
|
|
101
|
-
static readonly
|
|
102
|
-
static readonly
|
|
103
|
-
static readonly
|
|
104
|
-
static readonly
|
|
105
|
-
static readonly
|
|
106
|
-
static readonly
|
|
107
|
-
static readonly
|
|
108
|
-
static readonly
|
|
109
|
-
static readonly
|
|
110
|
-
static readonly
|
|
111
|
-
static readonly
|
|
112
|
-
static readonly
|
|
113
|
-
static readonly
|
|
114
|
-
static readonly
|
|
115
|
-
static readonly
|
|
116
|
-
static readonly
|
|
117
|
-
static readonly
|
|
118
|
-
static readonly
|
|
119
|
-
static readonly
|
|
120
|
-
static readonly
|
|
121
|
-
static readonly
|
|
122
|
-
static readonly
|
|
123
|
-
static readonly
|
|
124
|
-
static readonly
|
|
125
|
-
static readonly
|
|
126
|
-
static readonly
|
|
127
|
-
static readonly
|
|
128
|
-
static readonly
|
|
129
|
-
static readonly
|
|
130
|
-
static readonly
|
|
131
|
-
static readonly
|
|
132
|
-
static readonly
|
|
133
|
-
static readonly
|
|
134
|
-
static readonly
|
|
135
|
-
static readonly
|
|
136
|
-
static readonly
|
|
137
|
-
static readonly
|
|
138
|
-
static readonly
|
|
139
|
-
static readonly
|
|
140
|
-
static readonly
|
|
141
|
-
static readonly
|
|
142
|
-
static readonly
|
|
143
|
-
static readonly
|
|
144
|
-
static readonly
|
|
145
|
-
static readonly
|
|
146
|
-
static readonly
|
|
147
|
-
static readonly
|
|
148
|
-
static readonly
|
|
149
|
-
static readonly
|
|
150
|
-
static readonly
|
|
151
|
-
static readonly
|
|
81
|
+
static readonly SQL = 76;
|
|
82
|
+
static readonly TABLE = 77;
|
|
83
|
+
static readonly THEN = 78;
|
|
84
|
+
static readonly THIS = 79;
|
|
85
|
+
static readonly TIMESTAMP = 80;
|
|
86
|
+
static readonly TO = 81;
|
|
87
|
+
static readonly TRUE = 82;
|
|
88
|
+
static readonly TURTLE = 83;
|
|
89
|
+
static readonly WEEK = 84;
|
|
90
|
+
static readonly WHEN = 85;
|
|
91
|
+
static readonly WITH = 86;
|
|
92
|
+
static readonly YEAR = 87;
|
|
93
|
+
static readonly UNGROUPED = 88;
|
|
94
|
+
static readonly STRING_ESCAPE = 89;
|
|
95
|
+
static readonly HACKY_REGEX = 90;
|
|
96
|
+
static readonly STRING_LITERAL = 91;
|
|
97
|
+
static readonly DOC_ANNOTATION = 92;
|
|
98
|
+
static readonly ANNOTATION = 93;
|
|
99
|
+
static readonly AMPER = 94;
|
|
100
|
+
static readonly ARROW = 95;
|
|
101
|
+
static readonly FAT_ARROW = 96;
|
|
102
|
+
static readonly OPAREN = 97;
|
|
103
|
+
static readonly CPAREN = 98;
|
|
104
|
+
static readonly OBRACK = 99;
|
|
105
|
+
static readonly CBRACK = 100;
|
|
106
|
+
static readonly OCURLY = 101;
|
|
107
|
+
static readonly CCURLY = 102;
|
|
108
|
+
static readonly DOUBLECOLON = 103;
|
|
109
|
+
static readonly TRIPLECOLON = 104;
|
|
110
|
+
static readonly EXCLAM = 105;
|
|
111
|
+
static readonly COLON = 106;
|
|
112
|
+
static readonly COMMA = 107;
|
|
113
|
+
static readonly DOT = 108;
|
|
114
|
+
static readonly LT = 109;
|
|
115
|
+
static readonly GT = 110;
|
|
116
|
+
static readonly EQ = 111;
|
|
117
|
+
static readonly NE = 112;
|
|
118
|
+
static readonly LTE = 113;
|
|
119
|
+
static readonly GTE = 114;
|
|
120
|
+
static readonly PLUS = 115;
|
|
121
|
+
static readonly MINUS = 116;
|
|
122
|
+
static readonly STAR = 117;
|
|
123
|
+
static readonly STARSTAR = 118;
|
|
124
|
+
static readonly SLASH = 119;
|
|
125
|
+
static readonly BAR = 120;
|
|
126
|
+
static readonly SEMI = 121;
|
|
127
|
+
static readonly NOT_MATCH = 122;
|
|
128
|
+
static readonly MATCH = 123;
|
|
129
|
+
static readonly PERCENT = 124;
|
|
130
|
+
static readonly DOUBLE_QMARK = 125;
|
|
131
|
+
static readonly QMARK = 126;
|
|
132
|
+
static readonly LITERAL_TIMESTAMP = 127;
|
|
133
|
+
static readonly LITERAL_HOUR = 128;
|
|
134
|
+
static readonly LITERAL_DAY = 129;
|
|
135
|
+
static readonly LITERAL_QUARTER = 130;
|
|
136
|
+
static readonly LITERAL_MONTH = 131;
|
|
137
|
+
static readonly LITERAL_WEEK = 132;
|
|
138
|
+
static readonly LITERAL_YEAR = 133;
|
|
139
|
+
static readonly IDENTIFIER = 134;
|
|
140
|
+
static readonly PERCENT_LITERAL = 135;
|
|
141
|
+
static readonly INTEGER_LITERAL = 136;
|
|
142
|
+
static readonly NUMERIC_LITERAL = 137;
|
|
143
|
+
static readonly OBJECT_NAME_LITERAL = 138;
|
|
144
|
+
static readonly BLOCK_COMMENT = 139;
|
|
145
|
+
static readonly COMMENT_TO_EOL = 140;
|
|
146
|
+
static readonly WHITE_SPACE = 141;
|
|
147
|
+
static readonly SQL_BEGIN = 142;
|
|
148
|
+
static readonly CLOSE_CODE = 143;
|
|
149
|
+
static readonly UNWATED_CHARS_TRAILING_NUMBERS = 144;
|
|
150
|
+
static readonly UNEXPECTED_CHAR = 145;
|
|
151
|
+
static readonly OPEN_CODE = 146;
|
|
152
|
+
static readonly SQL_END = 147;
|
|
152
153
|
static readonly SQL_MODE = 1;
|
|
153
154
|
static readonly channelNames: string[];
|
|
154
155
|
static readonly modeNames: string[];
|