@malloydata/malloy 0.0.375 → 0.0.377
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/dialect/duckdb/duckdb.js +17 -27
- package/dist/dialect/tiny_parser.d.ts +53 -18
- package/dist/dialect/tiny_parser.js +182 -76
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -3
- package/dist/internal.d.ts +3 -0
- package/dist/internal.js +22 -0
- package/dist/model/index.d.ts +1 -1
- package/dist/model/index.js +2 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +8 -4
|
@@ -420,22 +420,18 @@ class DuckDBTypeParser extends tiny_parser_1.TinyParser {
|
|
|
420
420
|
return token.text.toUpperCase();
|
|
421
421
|
}
|
|
422
422
|
typeDef() {
|
|
423
|
-
|
|
423
|
+
var _a, _b;
|
|
424
|
+
const wantID = this.expect('id');
|
|
424
425
|
const id = this.sqlID(wantID);
|
|
425
426
|
let baseType;
|
|
426
427
|
if (id === 'VARCHAR') {
|
|
427
|
-
|
|
428
|
-
this.next();
|
|
429
|
-
}
|
|
428
|
+
this.match('size');
|
|
430
429
|
}
|
|
431
|
-
if ((id === 'DECIMAL' || id === 'NUMERIC') &&
|
|
432
|
-
this.peek().type === 'precision') {
|
|
433
|
-
this.next();
|
|
430
|
+
if ((id === 'DECIMAL' || id === 'NUMERIC') && this.match('precision')) {
|
|
434
431
|
baseType = { type: 'number', numberType: 'float' };
|
|
435
432
|
}
|
|
436
433
|
else if (id === 'TIMESTAMP') {
|
|
437
|
-
if (this.
|
|
438
|
-
this.nextText('WITH', 'TIME', 'ZONE');
|
|
434
|
+
if (this.matchText('WITH', 'TIME', 'ZONE')) {
|
|
439
435
|
baseType = { type: 'timestamptz' };
|
|
440
436
|
}
|
|
441
437
|
else {
|
|
@@ -446,24 +442,21 @@ class DuckDBTypeParser extends tiny_parser_1.TinyParser {
|
|
|
446
442
|
baseType = duckDBToMalloyTypes[id];
|
|
447
443
|
}
|
|
448
444
|
else if (id === 'STRUCT') {
|
|
449
|
-
this.
|
|
445
|
+
this.expect('(');
|
|
450
446
|
baseType = { type: 'record', fields: [] };
|
|
451
447
|
for (;;) {
|
|
452
|
-
const fieldName = this.
|
|
453
|
-
if (fieldName
|
|
454
|
-
|
|
455
|
-
fieldName.type === 'id') {
|
|
456
|
-
const fieldType = this.typeDef();
|
|
457
|
-
baseType.fields.push((0, malloy_types_1.mkFieldDef)(fieldType, this.unquoteName(fieldName)));
|
|
458
|
-
}
|
|
459
|
-
else {
|
|
460
|
-
if (fieldName.type !== ')') {
|
|
448
|
+
const fieldName = (_b = (_a = this.match('qsingle')) !== null && _a !== void 0 ? _a : this.match('qdouble')) !== null && _b !== void 0 ? _b : this.match('id');
|
|
449
|
+
if (!fieldName) {
|
|
450
|
+
if (!this.match(')')) {
|
|
461
451
|
throw this.parseError('Expected identifier or ) to end STRUCT');
|
|
462
452
|
}
|
|
463
453
|
break;
|
|
464
454
|
}
|
|
465
|
-
|
|
466
|
-
|
|
455
|
+
const fieldType = this.typeDef();
|
|
456
|
+
baseType.fields.push((0, malloy_types_1.mkFieldDef)(fieldType, this.unquoteName(fieldName)));
|
|
457
|
+
if (!this.match(',')) {
|
|
458
|
+
this.expect(')');
|
|
459
|
+
break;
|
|
467
460
|
}
|
|
468
461
|
}
|
|
469
462
|
}
|
|
@@ -472,10 +465,8 @@ class DuckDBTypeParser extends tiny_parser_1.TinyParser {
|
|
|
472
465
|
// unknown field type, strip all type decorations, there was a regex for this
|
|
473
466
|
// in the pre-parser code, but no tests, so this is also untested
|
|
474
467
|
let idEnd = wantID.cursor + wantID.text.length;
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
}
|
|
478
|
-
if (this.peek().type === 'eof') {
|
|
468
|
+
this.match('precision');
|
|
469
|
+
if (this.eof()) {
|
|
479
470
|
idEnd = this.input.length;
|
|
480
471
|
}
|
|
481
472
|
baseType = {
|
|
@@ -487,8 +478,7 @@ class DuckDBTypeParser extends tiny_parser_1.TinyParser {
|
|
|
487
478
|
throw this.parseError('Could not understand type');
|
|
488
479
|
}
|
|
489
480
|
}
|
|
490
|
-
while (this.
|
|
491
|
-
this.next();
|
|
481
|
+
while (this.match('arrayOf')) {
|
|
492
482
|
if (baseType.type === 'record') {
|
|
493
483
|
baseType = {
|
|
494
484
|
type: 'array',
|
|
@@ -4,9 +4,41 @@ export interface TinyToken {
|
|
|
4
4
|
text: string;
|
|
5
5
|
}
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* Tiny combined lexer/parser for short recursive-descent parsers.
|
|
8
|
+
*
|
|
9
|
+
* TinyParser is intentionally small and biased toward readability over
|
|
10
|
+
* framework features. It is primarily used for schema and type parsers where
|
|
11
|
+
* a hand-written parser is clearer than ad-hoc regex matching, but a parser
|
|
12
|
+
* generator would be overkill.
|
|
13
|
+
*
|
|
14
|
+
* Design goals:
|
|
15
|
+
* - Keep parser implementations short and readable.
|
|
16
|
+
* - Support custom tokenization rules per parser.
|
|
17
|
+
* - Make parser intent obvious at call sites.
|
|
18
|
+
* - Minimize hidden consumption and parser-state surprises.
|
|
19
|
+
*
|
|
20
|
+
* Core parser API:
|
|
21
|
+
* - peek(): inspect the next token without consuming it.
|
|
22
|
+
* - read(): consume and return the next token, regardless of type.
|
|
23
|
+
* - eof(): true if the next token is end-of-input.
|
|
24
|
+
* - expect(...types): consume a required sequence of token types.
|
|
25
|
+
* - expectText(...texts): consume a required sequence of token texts.
|
|
26
|
+
* - match(...types): consume an optional sequence of token types.
|
|
27
|
+
* - matchText(...texts): consume an optional sequence of token texts.
|
|
28
|
+
*
|
|
29
|
+
* Semantics:
|
|
30
|
+
* - expect*() is for required grammar and throws on failure.
|
|
31
|
+
* - match*() is for optional grammar and is atomic. If the full sequence does
|
|
32
|
+
* not match, nothing is consumed.
|
|
33
|
+
* - peek() remains available, but most optional syntax should prefer match*().
|
|
34
|
+
*
|
|
35
|
+
* Token rules are tested in order. The first matching rule wins.
|
|
36
|
+
*
|
|
37
|
+
* Special token rule names:
|
|
38
|
+
* - space: matched text is skipped and never returned.
|
|
39
|
+
* - char: matched text becomes both token.type and token.text.
|
|
40
|
+
* - q*: any token name starting with q is treated as quoted text and has its
|
|
41
|
+
* first and last characters stripped from token.text.
|
|
10
42
|
*
|
|
11
43
|
* NOTE: All parse errors are exceptions.
|
|
12
44
|
*/
|
|
@@ -14,33 +46,36 @@ export declare class TinyParseError extends Error {
|
|
|
14
46
|
}
|
|
15
47
|
export declare class TinyParser {
|
|
16
48
|
readonly input: string;
|
|
17
|
-
private tokens;
|
|
49
|
+
private readonly tokens;
|
|
50
|
+
private tokenCursor;
|
|
51
|
+
private scanCursor;
|
|
52
|
+
private scanState;
|
|
18
53
|
protected parseCursor: number;
|
|
19
|
-
private
|
|
20
|
-
private tokenMap;
|
|
54
|
+
private readonly tokenMap;
|
|
21
55
|
/**
|
|
22
|
-
* The token map is tested in order
|
|
23
|
-
* is {type: tokenMapKey, text: matchingText }, except
|
|
24
|
-
* for the special tokenMapKeys:
|
|
25
|
-
* * space: skipped and never returned
|
|
26
|
-
* * char: matched string return in both .type and .text
|
|
27
|
-
* * q*: any token name starting with 'q' is assumed to be
|
|
28
|
-
* a quoted string and the text will have the first and
|
|
29
|
-
* last characters stripped
|
|
56
|
+
* The token map is tested in order and the first matching rule wins.
|
|
30
57
|
*/
|
|
31
58
|
constructor(input: string, tokenMap?: Record<string, RegExp>);
|
|
32
59
|
parseError(str: string): TinyParseError;
|
|
33
60
|
peek(): TinyToken;
|
|
34
|
-
|
|
61
|
+
read(): TinyToken;
|
|
62
|
+
eof(): boolean;
|
|
63
|
+
private peekAt;
|
|
35
64
|
/**
|
|
36
65
|
* Return next token, if any token types are passed, read and require those
|
|
37
66
|
* tokens, then return the last one.
|
|
38
67
|
* @param types list of token types
|
|
39
68
|
* @returns The last token read
|
|
40
69
|
*/
|
|
41
|
-
|
|
42
|
-
|
|
70
|
+
expect(...types: string[]): TinyToken;
|
|
71
|
+
expectText(...texts: string[]): TinyToken;
|
|
72
|
+
match(...types: string[]): TinyToken | undefined;
|
|
73
|
+
matchText(...texts: string[]): TinyToken | undefined;
|
|
43
74
|
skipTo(type: string): void;
|
|
44
75
|
dump(): TinyToken[];
|
|
45
|
-
private
|
|
76
|
+
private fillBufferTo;
|
|
77
|
+
private consume;
|
|
78
|
+
private readNextToken;
|
|
79
|
+
private scanToken;
|
|
80
|
+
private eofToken;
|
|
46
81
|
}
|
|
@@ -8,9 +8,41 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.TinyParser = exports.TinyParseError = void 0;
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* Tiny combined lexer/parser for short recursive-descent parsers.
|
|
12
|
+
*
|
|
13
|
+
* TinyParser is intentionally small and biased toward readability over
|
|
14
|
+
* framework features. It is primarily used for schema and type parsers where
|
|
15
|
+
* a hand-written parser is clearer than ad-hoc regex matching, but a parser
|
|
16
|
+
* generator would be overkill.
|
|
17
|
+
*
|
|
18
|
+
* Design goals:
|
|
19
|
+
* - Keep parser implementations short and readable.
|
|
20
|
+
* - Support custom tokenization rules per parser.
|
|
21
|
+
* - Make parser intent obvious at call sites.
|
|
22
|
+
* - Minimize hidden consumption and parser-state surprises.
|
|
23
|
+
*
|
|
24
|
+
* Core parser API:
|
|
25
|
+
* - peek(): inspect the next token without consuming it.
|
|
26
|
+
* - read(): consume and return the next token, regardless of type.
|
|
27
|
+
* - eof(): true if the next token is end-of-input.
|
|
28
|
+
* - expect(...types): consume a required sequence of token types.
|
|
29
|
+
* - expectText(...texts): consume a required sequence of token texts.
|
|
30
|
+
* - match(...types): consume an optional sequence of token types.
|
|
31
|
+
* - matchText(...texts): consume an optional sequence of token texts.
|
|
32
|
+
*
|
|
33
|
+
* Semantics:
|
|
34
|
+
* - expect*() is for required grammar and throws on failure.
|
|
35
|
+
* - match*() is for optional grammar and is atomic. If the full sequence does
|
|
36
|
+
* not match, nothing is consumed.
|
|
37
|
+
* - peek() remains available, but most optional syntax should prefer match*().
|
|
38
|
+
*
|
|
39
|
+
* Token rules are tested in order. The first matching rule wins.
|
|
40
|
+
*
|
|
41
|
+
* Special token rule names:
|
|
42
|
+
* - space: matched text is skipped and never returned.
|
|
43
|
+
* - char: matched text becomes both token.type and token.text.
|
|
44
|
+
* - q*: any token name starting with q is treated as quoted text and has its
|
|
45
|
+
* first and last characters stripped from token.text.
|
|
14
46
|
*
|
|
15
47
|
* NOTE: All parse errors are exceptions.
|
|
16
48
|
*/
|
|
@@ -19,17 +51,14 @@ class TinyParseError extends Error {
|
|
|
19
51
|
exports.TinyParseError = TinyParseError;
|
|
20
52
|
class TinyParser {
|
|
21
53
|
/**
|
|
22
|
-
* The token map is tested in order
|
|
23
|
-
* is {type: tokenMapKey, text: matchingText }, except
|
|
24
|
-
* for the special tokenMapKeys:
|
|
25
|
-
* * space: skipped and never returned
|
|
26
|
-
* * char: matched string return in both .type and .text
|
|
27
|
-
* * q*: any token name starting with 'q' is assumed to be
|
|
28
|
-
* a quoted string and the text will have the first and
|
|
29
|
-
* last characters stripped
|
|
54
|
+
* The token map is tested in order and the first matching rule wins.
|
|
30
55
|
*/
|
|
31
56
|
constructor(input, tokenMap) {
|
|
32
57
|
this.input = input;
|
|
58
|
+
this.tokens = [];
|
|
59
|
+
this.tokenCursor = 0;
|
|
60
|
+
this.scanCursor = 0;
|
|
61
|
+
this.scanState = 'scanning';
|
|
33
62
|
this.parseCursor = 0;
|
|
34
63
|
this.tokenMap = tokenMap !== null && tokenMap !== void 0 ? tokenMap : {
|
|
35
64
|
space: /^\s+/,
|
|
@@ -37,30 +66,29 @@ class TinyParser {
|
|
|
37
66
|
id: /^\w+/,
|
|
38
67
|
qstr: /^"\w+"/,
|
|
39
68
|
};
|
|
40
|
-
this.tokens = this.tokenize(input);
|
|
41
69
|
}
|
|
42
70
|
parseError(str) {
|
|
71
|
+
this.parseCursor = this.peek().cursor;
|
|
43
72
|
const errText = `INTERNAL ERROR parsing schema: ${str}\n` +
|
|
44
73
|
`${this.input}\n` +
|
|
45
74
|
`${' '.repeat(this.parseCursor)}^`;
|
|
46
75
|
return new TinyParseError(errText);
|
|
47
76
|
}
|
|
48
77
|
peek() {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const { value } = this.tokens.next();
|
|
54
|
-
const peekVal = value !== null && value !== void 0 ? value : { type: 'eof', text: '' };
|
|
55
|
-
this.lookAhead = peekVal;
|
|
56
|
-
return peekVal;
|
|
57
|
-
}
|
|
78
|
+
return this.peekAt(0);
|
|
79
|
+
}
|
|
80
|
+
read() {
|
|
81
|
+
return this.consume();
|
|
58
82
|
}
|
|
59
|
-
|
|
83
|
+
eof() {
|
|
84
|
+
return this.peek().type === 'eof';
|
|
85
|
+
}
|
|
86
|
+
peekAt(offset) {
|
|
60
87
|
var _a;
|
|
61
|
-
|
|
62
|
-
this.
|
|
63
|
-
|
|
88
|
+
this.fillBufferTo(this.tokenCursor + offset);
|
|
89
|
+
const token = (_a = this.tokens[this.tokenCursor + offset]) !== null && _a !== void 0 ? _a : this.eofToken();
|
|
90
|
+
this.parseCursor = token.cursor;
|
|
91
|
+
return token;
|
|
64
92
|
}
|
|
65
93
|
/**
|
|
66
94
|
* Return next token, if any token types are passed, read and require those
|
|
@@ -68,43 +96,59 @@ class TinyParser {
|
|
|
68
96
|
* @param types list of token types
|
|
69
97
|
* @returns The last token read
|
|
70
98
|
*/
|
|
71
|
-
|
|
72
|
-
if (types.length === 0)
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
let
|
|
99
|
+
expect(...types) {
|
|
100
|
+
if (types.length === 0) {
|
|
101
|
+
throw new Error('TinyParser.expect() requires at least one token type');
|
|
102
|
+
}
|
|
103
|
+
let next;
|
|
76
104
|
for (const typ of types) {
|
|
77
|
-
next = this.
|
|
78
|
-
expected = typ;
|
|
105
|
+
next = this.peek();
|
|
79
106
|
if (next.type !== typ) {
|
|
80
|
-
|
|
81
|
-
break;
|
|
107
|
+
throw this.parseError(`Expected token type '${typ}'`);
|
|
82
108
|
}
|
|
109
|
+
this.consume();
|
|
110
|
+
}
|
|
111
|
+
return next;
|
|
112
|
+
}
|
|
113
|
+
expectText(...texts) {
|
|
114
|
+
if (texts.length === 0) {
|
|
115
|
+
throw new Error('TinyParser.expectText() requires at least one token text');
|
|
83
116
|
}
|
|
84
|
-
|
|
85
|
-
return next;
|
|
86
|
-
throw this.parseError(`Expected token type '${expected}'`);
|
|
87
|
-
}
|
|
88
|
-
nextText(...texts) {
|
|
89
|
-
if (texts.length === 0)
|
|
90
|
-
return this.getNext();
|
|
91
|
-
let next = undefined;
|
|
92
|
-
let expected = texts[0];
|
|
117
|
+
let next;
|
|
93
118
|
for (const txt of texts) {
|
|
94
|
-
next = this.
|
|
95
|
-
expected = txt;
|
|
119
|
+
next = this.peek();
|
|
96
120
|
if (next.text.toUpperCase() !== txt.toUpperCase()) {
|
|
97
|
-
|
|
98
|
-
|
|
121
|
+
throw this.parseError(`Expected '${txt}'`);
|
|
122
|
+
}
|
|
123
|
+
this.consume();
|
|
124
|
+
}
|
|
125
|
+
return next;
|
|
126
|
+
}
|
|
127
|
+
match(...types) {
|
|
128
|
+
if (types.length === 0) {
|
|
129
|
+
throw new Error('TinyParser.match() requires at least one token type');
|
|
130
|
+
}
|
|
131
|
+
for (let index = 0; index < types.length; index += 1) {
|
|
132
|
+
if (this.peekAt(index).type !== types[index]) {
|
|
133
|
+
return undefined;
|
|
99
134
|
}
|
|
100
135
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
136
|
+
return this.consume(types.length);
|
|
137
|
+
}
|
|
138
|
+
matchText(...texts) {
|
|
139
|
+
if (texts.length === 0) {
|
|
140
|
+
throw new Error('TinyParser.matchText() requires at least one token text');
|
|
141
|
+
}
|
|
142
|
+
for (let index = 0; index < texts.length; index += 1) {
|
|
143
|
+
if (this.peekAt(index).text.toUpperCase() !== texts[index].toUpperCase()) {
|
|
144
|
+
return undefined;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return this.consume(texts.length);
|
|
104
148
|
}
|
|
105
149
|
skipTo(type) {
|
|
106
150
|
for (;;) {
|
|
107
|
-
const next = this.
|
|
151
|
+
const next = this.read();
|
|
108
152
|
if (next.type === 'eof') {
|
|
109
153
|
throw this.parseError(`Expected token '${type}`);
|
|
110
154
|
}
|
|
@@ -114,41 +158,103 @@ class TinyParser {
|
|
|
114
158
|
}
|
|
115
159
|
}
|
|
116
160
|
dump() {
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
161
|
+
const parts = [];
|
|
162
|
+
let cursor = 0;
|
|
163
|
+
let state = 'scanning';
|
|
164
|
+
while (state !== 'done') {
|
|
165
|
+
const { token, nextCursor, nextState } = this.scanToken(cursor, state);
|
|
166
|
+
if (token.type === 'eof') {
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
parts.push(token);
|
|
170
|
+
cursor = nextCursor;
|
|
171
|
+
state = nextState;
|
|
172
|
+
}
|
|
120
173
|
return parts;
|
|
121
174
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
175
|
+
fillBufferTo(index) {
|
|
176
|
+
while (this.tokens.length <= index) {
|
|
177
|
+
this.tokens.push(this.readNextToken());
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
consume(count = 1) {
|
|
181
|
+
let token = this.peek();
|
|
182
|
+
for (let index = 0; index < count; index += 1) {
|
|
183
|
+
token = this.peek();
|
|
184
|
+
this.tokenCursor += 1;
|
|
185
|
+
}
|
|
186
|
+
this.parseCursor = this.peek().cursor;
|
|
187
|
+
return token;
|
|
188
|
+
}
|
|
189
|
+
readNextToken() {
|
|
190
|
+
const { token, nextCursor, nextState } = this.scanToken(this.scanCursor, this.scanState);
|
|
191
|
+
this.scanCursor = nextCursor;
|
|
192
|
+
this.scanState = nextState;
|
|
193
|
+
return token;
|
|
194
|
+
}
|
|
195
|
+
scanToken(cursor, state) {
|
|
196
|
+
if (state === 'done') {
|
|
197
|
+
return {
|
|
198
|
+
token: this.eofToken(),
|
|
199
|
+
nextCursor: this.input.length,
|
|
200
|
+
nextState: 'done',
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
if (state === 'afterUnexpected' || cursor >= this.input.length) {
|
|
204
|
+
return {
|
|
205
|
+
token: this.eofToken(),
|
|
206
|
+
nextCursor: this.input.length,
|
|
207
|
+
nextState: 'done',
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
let nextCursor = cursor;
|
|
211
|
+
while (nextCursor < this.input.length) {
|
|
212
|
+
const srcAtCursor = this.input.slice(nextCursor);
|
|
213
|
+
let matched = false;
|
|
214
|
+
for (const tokenType in this.tokenMap) {
|
|
215
|
+
const foundToken = srcAtCursor.match(this.tokenMap[tokenType]);
|
|
129
216
|
if (foundToken) {
|
|
130
|
-
|
|
217
|
+
matched = true;
|
|
131
218
|
let tokenText = foundToken[0];
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
if (tokenType
|
|
135
|
-
if (tokenType[0] === 'q') {
|
|
136
|
-
tokenText = tokenText.slice(1, -1); // strip quotes
|
|
137
|
-
}
|
|
138
|
-
yield {
|
|
139
|
-
cursor,
|
|
140
|
-
type: tokenType === 'char' ? tokenText : tokenType,
|
|
141
|
-
text: tokenText,
|
|
142
|
-
};
|
|
219
|
+
const tokenCursor = nextCursor;
|
|
220
|
+
nextCursor += tokenText.length;
|
|
221
|
+
if (tokenType === 'space') {
|
|
143
222
|
break;
|
|
144
223
|
}
|
|
224
|
+
if (tokenType[0] === 'q') {
|
|
225
|
+
tokenText = tokenText.slice(1, -1);
|
|
226
|
+
}
|
|
227
|
+
return {
|
|
228
|
+
token: {
|
|
229
|
+
cursor: tokenCursor,
|
|
230
|
+
type: tokenType === 'char' ? tokenText : tokenType,
|
|
231
|
+
text: tokenText,
|
|
232
|
+
},
|
|
233
|
+
nextCursor,
|
|
234
|
+
nextState: 'scanning',
|
|
235
|
+
};
|
|
145
236
|
}
|
|
146
237
|
}
|
|
147
|
-
if (
|
|
148
|
-
|
|
149
|
-
|
|
238
|
+
if (!matched) {
|
|
239
|
+
return {
|
|
240
|
+
token: {
|
|
241
|
+
cursor: nextCursor,
|
|
242
|
+
type: 'unexpected token',
|
|
243
|
+
text: this.input,
|
|
244
|
+
},
|
|
245
|
+
nextCursor: this.input.length,
|
|
246
|
+
nextState: 'afterUnexpected',
|
|
247
|
+
};
|
|
150
248
|
}
|
|
151
249
|
}
|
|
250
|
+
return {
|
|
251
|
+
token: this.eofToken(),
|
|
252
|
+
nextCursor: this.input.length,
|
|
253
|
+
nextState: 'done',
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
eofToken() {
|
|
257
|
+
return { cursor: this.input.length, type: 'eof', text: '' };
|
|
152
258
|
}
|
|
153
259
|
}
|
|
154
260
|
exports.TinyParser = TinyParser;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { DuckDBDialect, StandardSQLDialect, TrinoDialect, PostgresDialect, SnowflakeDialect, MySQLDialect, DatabricksDialect, registerDialect, arg, qtz, overload, minScalar, anyExprType, minAggregate, maxScalar, sql, makeParam, param, variadicParam, literal, spread, Dialect,
|
|
2
|
-
export type { DialectFieldList, DialectFunctionOverloadDef, QueryInfo, MalloyStandardFunctionImplementations, DefinitionBlueprint, DefinitionBlueprintMap, OverloadedDefinitionBlueprint,
|
|
1
|
+
export { DuckDBDialect, StandardSQLDialect, TrinoDialect, PostgresDialect, SnowflakeDialect, MySQLDialect, DatabricksDialect, registerDialect, arg, qtz, overload, minScalar, anyExprType, minAggregate, maxScalar, sql, makeParam, param, variadicParam, literal, spread, Dialect, } from './dialect';
|
|
2
|
+
export type { DialectFieldList, DialectFunctionOverloadDef, QueryInfo, MalloyStandardFunctionImplementations, DefinitionBlueprint, DefinitionBlueprintMap, OverloadedDefinitionBlueprint, } from './dialect';
|
|
3
3
|
export type { QueryRecord, StructDef, TableSourceDef, SQLSourceDef, SourceDef, JoinFieldDef, NamedSourceDefs, MalloyQueryData, DateUnit, ExtractUnit, TimestampUnit, TemporalFieldType, QueryData, QueryValue, Expr, FilterCondition, Argument, Parameter, FieldDef, PipeSegment, QueryFieldDef, IndexFieldDef, TurtleDef, SearchValueMapResult, SearchIndexResult, ModelDef, Query, QueryResult, QueryResultDef, QueryRunStats, QueryScalar, NamedQueryDef, NamedModelObject, ExpressionType, FunctionDef, FunctionOverloadDef, FunctionParameterDef, ExpressionValueType, TypeDesc, FunctionParamTypeDesc, DocumentLocation, DocumentRange, DocumentPosition, Sampling, Annotation, BasicAtomicTypeDef, BasicAtomicDef, AtomicTypeDef, AtomicFieldDef, ArrayDef, ArrayTypeDef, RecordTypeDef, RepeatedRecordTypeDef, RecordDef, RepeatedRecordDef, RecordLiteralNode, StringLiteralNode, ArrayLiteralNode, SourceComponentInfo, DateLiteralNode, TimestampLiteralNode, TimestamptzLiteralNode, TimeLiteralExpr, TypecastExpr, BuildID, BuildManifest, BuildManifestEntry, VirtualMap, } from './model';
|
|
4
4
|
export { isSourceDef, isAtomic, isBasicAtomic, isCompoundArrayData, isJoined, isJoinedSource, isSamplingEnable, isSamplingPercent, isSamplingRows, isRepeatedRecord, isBasicArray, mkArrayDef, mkFieldDef, expressionIsAggregate, expressionIsAnalytic, expressionIsCalculation, expressionIsScalar, expressionIsUngroupedAggregate, indent, composeSQLExpr, isTimestampUnit, isDateUnit, constantExprToSQL, } from './model';
|
|
5
5
|
export { malloyToQuery, MalloyTranslator, } from './lang';
|
package/dist/index.js
CHANGED
|
@@ -33,8 +33,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.Malloy = exports.Model = exports.MalloyTranslator = exports.malloyToQuery = exports.constantExprToSQL = exports.isDateUnit = exports.isTimestampUnit = exports.composeSQLExpr = exports.indent = exports.expressionIsUngroupedAggregate = exports.expressionIsScalar = exports.expressionIsCalculation = exports.expressionIsAnalytic = exports.expressionIsAggregate = exports.mkFieldDef = exports.mkArrayDef = exports.isBasicArray = exports.isRepeatedRecord = exports.isSamplingRows = exports.isSamplingPercent = exports.isSamplingEnable = exports.isJoinedSource = exports.isJoined = exports.isCompoundArrayData = exports.isBasicAtomic = exports.isAtomic = exports.isSourceDef = exports.
|
|
37
|
-
exports.makeDigest = exports.EMPTY_BUILD_MANIFEST = exports.PersistSource = exports.annotationToTaglines = exports.annotationToTag = exports.sqlKey = exports.API = exports.sourceDefToSourceInfo = exports.modelDefToModelInfo = exports.toAsyncGenerator = exports.createConnectionsFromConfig = exports.getRegisteredConnectionTypes = exports.getConnectionTypeDisplayName = exports.getConnectionProperties = exports.registerConnectionType = exports.discoverConfig = exports.defaultConfigOverlays = exports.contextOverlay = exports.envOverlay = exports.MalloyConfig = exports.Manifest = exports.CacheManager = exports.InMemoryModelCache = exports.Explore = exports.DataWriter = exports.Parse = exports.JSONWriter = exports.CSVWriter = exports.QueryMaterializer = exports.Result = exports.PreparedResult = exports.TimestampTimeframe = exports.DateTimeframe = exports.SourceRelationship = exports.JoinRelationship = exports.MalloyError = exports.FixedConnectionMap = exports.InMemoryURLReader = exports.EmptyURLReader = exports.SingleConnectionRuntime = exports.ConnectionRuntime = exports.AtomicFieldType =
|
|
36
|
+
exports.Runtime = exports.Malloy = exports.Model = exports.MalloyTranslator = exports.malloyToQuery = exports.constantExprToSQL = exports.isDateUnit = exports.isTimestampUnit = exports.composeSQLExpr = exports.indent = exports.expressionIsUngroupedAggregate = exports.expressionIsScalar = exports.expressionIsCalculation = exports.expressionIsAnalytic = exports.expressionIsAggregate = exports.mkFieldDef = exports.mkArrayDef = exports.isBasicArray = exports.isRepeatedRecord = exports.isSamplingRows = exports.isSamplingPercent = exports.isSamplingEnable = exports.isJoinedSource = exports.isJoined = exports.isCompoundArrayData = exports.isBasicAtomic = exports.isAtomic = exports.isSourceDef = exports.Dialect = exports.spread = exports.literal = exports.variadicParam = exports.param = exports.makeParam = exports.sql = exports.maxScalar = exports.minAggregate = exports.anyExprType = exports.minScalar = exports.overload = exports.qtz = exports.arg = exports.registerDialect = exports.DatabricksDialect = exports.MySQLDialect = exports.SnowflakeDialect = exports.PostgresDialect = exports.TrinoDialect = exports.StandardSQLDialect = exports.DuckDBDialect = void 0;
|
|
37
|
+
exports.makeDigest = exports.EMPTY_BUILD_MANIFEST = exports.PersistSource = exports.annotationToTaglines = exports.annotationToTag = exports.sqlKey = exports.API = exports.sourceDefToSourceInfo = exports.modelDefToModelInfo = exports.toAsyncGenerator = exports.createConnectionsFromConfig = exports.getRegisteredConnectionTypes = exports.getConnectionTypeDisplayName = exports.getConnectionProperties = exports.registerConnectionType = exports.discoverConfig = exports.defaultConfigOverlays = exports.contextOverlay = exports.envOverlay = exports.MalloyConfig = exports.Manifest = exports.CacheManager = exports.InMemoryModelCache = exports.Explore = exports.DataWriter = exports.Parse = exports.JSONWriter = exports.CSVWriter = exports.QueryMaterializer = exports.Result = exports.PreparedResult = exports.TimestampTimeframe = exports.DateTimeframe = exports.SourceRelationship = exports.JoinRelationship = exports.MalloyError = exports.FixedConnectionMap = exports.InMemoryURLReader = exports.EmptyURLReader = exports.SingleConnectionRuntime = exports.ConnectionRuntime = exports.AtomicFieldType = void 0;
|
|
38
38
|
/*
|
|
39
39
|
* Copyright 2023 Google LLC
|
|
40
40
|
*
|
|
@@ -80,7 +80,6 @@ Object.defineProperty(exports, "variadicParam", { enumerable: true, get: functio
|
|
|
80
80
|
Object.defineProperty(exports, "literal", { enumerable: true, get: function () { return dialect_1.literal; } });
|
|
81
81
|
Object.defineProperty(exports, "spread", { enumerable: true, get: function () { return dialect_1.spread; } });
|
|
82
82
|
Object.defineProperty(exports, "Dialect", { enumerable: true, get: function () { return dialect_1.Dialect; } });
|
|
83
|
-
Object.defineProperty(exports, "TinyParser", { enumerable: true, get: function () { return dialect_1.TinyParser; } });
|
|
84
83
|
var model_1 = require("./model");
|
|
85
84
|
Object.defineProperty(exports, "isSourceDef", { enumerable: true, get: function () { return model_1.isSourceDef; } });
|
|
86
85
|
// Used in Composer Demo
|
package/dist/internal.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright Contributors to the Malloy project
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.TinyParser = exports.TinyParseError = exports.pathToKey = exports.mkTableSourceDef = exports.mkSQLSourceDef = exports.mkQuerySourceDef = exports.mkModelDef = exports.mkFieldDef = exports.mkArrayTypeDef = exports.mkArrayDef = void 0;
|
|
8
|
+
// Unstable implementation-facing exports for Malloy packages, tests, and
|
|
9
|
+
// advanced integrations. Do not treat this surface as public API.
|
|
10
|
+
var model_1 = require("./model");
|
|
11
|
+
Object.defineProperty(exports, "mkArrayDef", { enumerable: true, get: function () { return model_1.mkArrayDef; } });
|
|
12
|
+
Object.defineProperty(exports, "mkArrayTypeDef", { enumerable: true, get: function () { return model_1.mkArrayTypeDef; } });
|
|
13
|
+
Object.defineProperty(exports, "mkFieldDef", { enumerable: true, get: function () { return model_1.mkFieldDef; } });
|
|
14
|
+
Object.defineProperty(exports, "mkModelDef", { enumerable: true, get: function () { return model_1.mkModelDef; } });
|
|
15
|
+
Object.defineProperty(exports, "mkQuerySourceDef", { enumerable: true, get: function () { return model_1.mkQuerySourceDef; } });
|
|
16
|
+
Object.defineProperty(exports, "mkSQLSourceDef", { enumerable: true, get: function () { return model_1.mkSQLSourceDef; } });
|
|
17
|
+
Object.defineProperty(exports, "mkTableSourceDef", { enumerable: true, get: function () { return model_1.mkTableSourceDef; } });
|
|
18
|
+
Object.defineProperty(exports, "pathToKey", { enumerable: true, get: function () { return model_1.pathToKey; } });
|
|
19
|
+
var tiny_parser_1 = require("./dialect/tiny_parser");
|
|
20
|
+
Object.defineProperty(exports, "TinyParseError", { enumerable: true, get: function () { return tiny_parser_1.TinyParseError; } });
|
|
21
|
+
Object.defineProperty(exports, "TinyParser", { enumerable: true, get: function () { return tiny_parser_1.TinyParser; } });
|
|
22
|
+
//# sourceMappingURL=internal.js.map
|
package/dist/model/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { QueryQuery } from './query_query';
|
|
|
4
4
|
import { QueryModelImpl } from './query_model_impl';
|
|
5
5
|
export { QueryField, QueryStruct, QueryQuery, QueryModelImpl as QueryModel };
|
|
6
6
|
export { getResultStructDefForQuery, getResultStructDefForView, } from './query_model_impl';
|
|
7
|
-
export { indent, composeSQLExpr, makeDigest, mkModelDef } from './utils';
|
|
7
|
+
export { indent, composeSQLExpr, makeDigest, mkModelDef, pathToKey, } from './utils';
|
|
8
8
|
export { constantExprToSQL } from './constant_expression_compiler';
|
|
9
9
|
export { getCompiledSQL } from './sql_compiled';
|
|
10
10
|
export { mkSourceID, mkBuildID, mkQuerySourceDef, mkSQLSourceDef, mkTableSourceDef, resolveSourceID, registerSource, hasSourceRegistryEntry, } from './source_def_utils';
|
package/dist/model/index.js
CHANGED
|
@@ -36,7 +36,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
36
36
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.hasSourceRegistryEntry = exports.registerSource = exports.resolveSourceID = exports.mkTableSourceDef = exports.mkSQLSourceDef = exports.mkQuerySourceDef = exports.mkBuildID = exports.mkSourceID = exports.getCompiledSQL = exports.constantExprToSQL = exports.mkModelDef = exports.makeDigest = exports.composeSQLExpr = exports.indent = exports.getResultStructDefForView = exports.getResultStructDefForQuery = exports.QueryModel = exports.QueryQuery = exports.QueryStruct = exports.QueryField = void 0;
|
|
39
|
+
exports.hasSourceRegistryEntry = exports.registerSource = exports.resolveSourceID = exports.mkTableSourceDef = exports.mkSQLSourceDef = exports.mkQuerySourceDef = exports.mkBuildID = exports.mkSourceID = exports.getCompiledSQL = exports.constantExprToSQL = exports.pathToKey = exports.mkModelDef = exports.makeDigest = exports.composeSQLExpr = exports.indent = exports.getResultStructDefForView = exports.getResultStructDefForQuery = exports.QueryModel = exports.QueryQuery = exports.QueryStruct = exports.QueryField = void 0;
|
|
40
40
|
__exportStar(require("./malloy_types"), exports);
|
|
41
41
|
const query_node_1 = require("./query_node");
|
|
42
42
|
Object.defineProperty(exports, "QueryField", { enumerable: true, get: function () { return query_node_1.QueryField; } });
|
|
@@ -60,6 +60,7 @@ Object.defineProperty(exports, "indent", { enumerable: true, get: function () {
|
|
|
60
60
|
Object.defineProperty(exports, "composeSQLExpr", { enumerable: true, get: function () { return utils_1.composeSQLExpr; } });
|
|
61
61
|
Object.defineProperty(exports, "makeDigest", { enumerable: true, get: function () { return utils_1.makeDigest; } });
|
|
62
62
|
Object.defineProperty(exports, "mkModelDef", { enumerable: true, get: function () { return utils_1.mkModelDef; } });
|
|
63
|
+
Object.defineProperty(exports, "pathToKey", { enumerable: true, get: function () { return utils_1.pathToKey; } });
|
|
63
64
|
var constant_expression_compiler_1 = require("./constant_expression_compiler");
|
|
64
65
|
Object.defineProperty(exports, "constantExprToSQL", { enumerable: true, get: function () { return constant_expression_compiler_1.constantExprToSQL; } });
|
|
65
66
|
var sql_compiled_1 = require("./sql_compiled");
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const MALLOY_VERSION = "0.0.
|
|
1
|
+
export declare const MALLOY_VERSION = "0.0.377";
|
package/dist/version.js
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MALLOY_VERSION = void 0;
|
|
4
4
|
// generated with 'generate-version-file' script; do not edit manually
|
|
5
|
-
exports.MALLOY_VERSION = '0.0.
|
|
5
|
+
exports.MALLOY_VERSION = '0.0.377';
|
|
6
6
|
//# sourceMappingURL=version.js.map
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@malloydata/malloy",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.377",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/index.js",
|
|
7
|
+
"./internal": "./dist/internal.js",
|
|
7
8
|
"./test": "./dist/test/index.js",
|
|
8
9
|
"./test/matchers": "./dist/test/matchers.js",
|
|
9
10
|
"./connection": "./dist/connection/index.js",
|
|
@@ -14,6 +15,9 @@
|
|
|
14
15
|
"index": [
|
|
15
16
|
"./dist/index.d.ts"
|
|
16
17
|
],
|
|
18
|
+
"internal": [
|
|
19
|
+
"./dist/internal.d.ts"
|
|
20
|
+
],
|
|
17
21
|
"test": [
|
|
18
22
|
"./dist/test/index.d.ts"
|
|
19
23
|
],
|
|
@@ -47,9 +51,9 @@
|
|
|
47
51
|
"generate-version-file": "VERSION=$(npm pkg get version --workspaces=false | tr -d \\\")\necho \"// generated with 'generate-version-file' script; do not edit manually\\nexport const MALLOY_VERSION = '$VERSION';\" > src/version.ts"
|
|
48
52
|
},
|
|
49
53
|
"dependencies": {
|
|
50
|
-
"@malloydata/malloy-filter": "0.0.
|
|
51
|
-
"@malloydata/malloy-interfaces": "0.0.
|
|
52
|
-
"@malloydata/malloy-tag": "0.0.
|
|
54
|
+
"@malloydata/malloy-filter": "0.0.377",
|
|
55
|
+
"@malloydata/malloy-interfaces": "0.0.377",
|
|
56
|
+
"@malloydata/malloy-tag": "0.0.377",
|
|
53
57
|
"@noble/hashes": "^1.8.0",
|
|
54
58
|
"antlr4ts": "^0.5.0-alpha.4",
|
|
55
59
|
"assert": "^2.0.0",
|