@malloydata/malloy 0.0.36-dev230524224445 → 0.0.36-dev230525034638
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/lang/ast/expressions/expr-coalesce.d.ts +11 -0
- package/dist/lang/ast/expressions/expr-coalesce.js +59 -0
- package/dist/lang/ast/index.d.ts +1 -0
- package/dist/lang/ast/index.js +1 -0
- package/dist/lang/lib/Malloy/MalloyLexer.d.ts +71 -70
- package/dist/lang/lib/Malloy/MalloyLexer.js +1025 -1020
- package/dist/lang/lib/Malloy/MalloyParser.d.ts +111 -86
- package/dist/lang/lib/Malloy/MalloyParser.js +767 -638
- package/dist/lang/lib/Malloy/MalloyParserListener.d.ts +62 -23
- package/dist/lang/lib/Malloy/MalloyParserVisitor.d.ts +38 -14
- package/dist/lang/malloy-to-ast.d.ts +5 -2
- package/dist/lang/malloy-to-ast.js +19 -7
- package/dist/lang/test/parse.spec.js +1 -0
- package/package.json +1 -1
|
@@ -29,19 +29,22 @@ import { NestDefContext } from "./MalloyParser";
|
|
|
29
29
|
import { ExprFieldPathContext } from "./MalloyParser";
|
|
30
30
|
import { ExprFilterContext } from "./MalloyParser";
|
|
31
31
|
import { ExprLiteralContext } from "./MalloyParser";
|
|
32
|
-
import { ExprMinusContext } from "./MalloyParser";
|
|
33
32
|
import { ExprDurationContext } from "./MalloyParser";
|
|
34
33
|
import { ExprTimeTruncContext } from "./MalloyParser";
|
|
35
34
|
import { ExprSafeCastContext } from "./MalloyParser";
|
|
35
|
+
import { ExprMinusContext } from "./MalloyParser";
|
|
36
36
|
import { ExprMulDivContext } from "./MalloyParser";
|
|
37
37
|
import { ExprAddSubContext } from "./MalloyParser";
|
|
38
38
|
import { ExprRangeContext } from "./MalloyParser";
|
|
39
39
|
import { ExprForRangeContext } from "./MalloyParser";
|
|
40
|
-
import {
|
|
40
|
+
import { ExprAndTreeContext } from "./MalloyParser";
|
|
41
|
+
import { ExprOrTreeContext } from "./MalloyParser";
|
|
41
42
|
import { ExprCompareContext } from "./MalloyParser";
|
|
42
43
|
import { ExprApplyContext } from "./MalloyParser";
|
|
43
44
|
import { ExprNotContext } from "./MalloyParser";
|
|
44
|
-
import {
|
|
45
|
+
import { ExprLogicalAndContext } from "./MalloyParser";
|
|
46
|
+
import { ExprLogicalOrContext } from "./MalloyParser";
|
|
47
|
+
import { ExprCoalesceContext } from "./MalloyParser";
|
|
45
48
|
import { ExprCastContext } from "./MalloyParser";
|
|
46
49
|
import { ExprCountDisinctContext } from "./MalloyParser";
|
|
47
50
|
import { ExprAggregateContext } from "./MalloyParser";
|
|
@@ -538,18 +541,6 @@ export interface MalloyParserListener extends ParseTreeListener {
|
|
|
538
541
|
* @param ctx the parse tree
|
|
539
542
|
*/
|
|
540
543
|
exitExprLiteral?: (ctx: ExprLiteralContext) => void;
|
|
541
|
-
/**
|
|
542
|
-
* Enter a parse tree produced by the `exprMinus`
|
|
543
|
-
* labeled alternative in `MalloyParser.fieldExpr`.
|
|
544
|
-
* @param ctx the parse tree
|
|
545
|
-
*/
|
|
546
|
-
enterExprMinus?: (ctx: ExprMinusContext) => void;
|
|
547
|
-
/**
|
|
548
|
-
* Exit a parse tree produced by the `exprMinus`
|
|
549
|
-
* labeled alternative in `MalloyParser.fieldExpr`.
|
|
550
|
-
* @param ctx the parse tree
|
|
551
|
-
*/
|
|
552
|
-
exitExprMinus?: (ctx: ExprMinusContext) => void;
|
|
553
544
|
/**
|
|
554
545
|
* Enter a parse tree produced by the `exprDuration`
|
|
555
546
|
* labeled alternative in `MalloyParser.fieldExpr`.
|
|
@@ -586,6 +577,18 @@ export interface MalloyParserListener extends ParseTreeListener {
|
|
|
586
577
|
* @param ctx the parse tree
|
|
587
578
|
*/
|
|
588
579
|
exitExprSafeCast?: (ctx: ExprSafeCastContext) => void;
|
|
580
|
+
/**
|
|
581
|
+
* Enter a parse tree produced by the `exprMinus`
|
|
582
|
+
* labeled alternative in `MalloyParser.fieldExpr`.
|
|
583
|
+
* @param ctx the parse tree
|
|
584
|
+
*/
|
|
585
|
+
enterExprMinus?: (ctx: ExprMinusContext) => void;
|
|
586
|
+
/**
|
|
587
|
+
* Exit a parse tree produced by the `exprMinus`
|
|
588
|
+
* labeled alternative in `MalloyParser.fieldExpr`.
|
|
589
|
+
* @param ctx the parse tree
|
|
590
|
+
*/
|
|
591
|
+
exitExprMinus?: (ctx: ExprMinusContext) => void;
|
|
589
592
|
/**
|
|
590
593
|
* Enter a parse tree produced by the `exprMulDiv`
|
|
591
594
|
* labeled alternative in `MalloyParser.fieldExpr`.
|
|
@@ -635,17 +638,29 @@ export interface MalloyParserListener extends ParseTreeListener {
|
|
|
635
638
|
*/
|
|
636
639
|
exitExprForRange?: (ctx: ExprForRangeContext) => void;
|
|
637
640
|
/**
|
|
638
|
-
* Enter a parse tree produced by the `
|
|
641
|
+
* Enter a parse tree produced by the `exprAndTree`
|
|
639
642
|
* labeled alternative in `MalloyParser.fieldExpr`.
|
|
640
643
|
* @param ctx the parse tree
|
|
641
644
|
*/
|
|
642
|
-
|
|
645
|
+
enterExprAndTree?: (ctx: ExprAndTreeContext) => void;
|
|
643
646
|
/**
|
|
644
|
-
* Exit a parse tree produced by the `
|
|
647
|
+
* Exit a parse tree produced by the `exprAndTree`
|
|
645
648
|
* labeled alternative in `MalloyParser.fieldExpr`.
|
|
646
649
|
* @param ctx the parse tree
|
|
647
650
|
*/
|
|
648
|
-
|
|
651
|
+
exitExprAndTree?: (ctx: ExprAndTreeContext) => void;
|
|
652
|
+
/**
|
|
653
|
+
* Enter a parse tree produced by the `exprOrTree`
|
|
654
|
+
* labeled alternative in `MalloyParser.fieldExpr`.
|
|
655
|
+
* @param ctx the parse tree
|
|
656
|
+
*/
|
|
657
|
+
enterExprOrTree?: (ctx: ExprOrTreeContext) => void;
|
|
658
|
+
/**
|
|
659
|
+
* Exit a parse tree produced by the `exprOrTree`
|
|
660
|
+
* labeled alternative in `MalloyParser.fieldExpr`.
|
|
661
|
+
* @param ctx the parse tree
|
|
662
|
+
*/
|
|
663
|
+
exitExprOrTree?: (ctx: ExprOrTreeContext) => void;
|
|
649
664
|
/**
|
|
650
665
|
* Enter a parse tree produced by the `exprCompare`
|
|
651
666
|
* labeled alternative in `MalloyParser.fieldExpr`.
|
|
@@ -683,17 +698,41 @@ export interface MalloyParserListener extends ParseTreeListener {
|
|
|
683
698
|
*/
|
|
684
699
|
exitExprNot?: (ctx: ExprNotContext) => void;
|
|
685
700
|
/**
|
|
686
|
-
* Enter a parse tree produced by the `
|
|
701
|
+
* Enter a parse tree produced by the `exprLogicalAnd`
|
|
702
|
+
* labeled alternative in `MalloyParser.fieldExpr`.
|
|
703
|
+
* @param ctx the parse tree
|
|
704
|
+
*/
|
|
705
|
+
enterExprLogicalAnd?: (ctx: ExprLogicalAndContext) => void;
|
|
706
|
+
/**
|
|
707
|
+
* Exit a parse tree produced by the `exprLogicalAnd`
|
|
708
|
+
* labeled alternative in `MalloyParser.fieldExpr`.
|
|
709
|
+
* @param ctx the parse tree
|
|
710
|
+
*/
|
|
711
|
+
exitExprLogicalAnd?: (ctx: ExprLogicalAndContext) => void;
|
|
712
|
+
/**
|
|
713
|
+
* Enter a parse tree produced by the `exprLogicalOr`
|
|
714
|
+
* labeled alternative in `MalloyParser.fieldExpr`.
|
|
715
|
+
* @param ctx the parse tree
|
|
716
|
+
*/
|
|
717
|
+
enterExprLogicalOr?: (ctx: ExprLogicalOrContext) => void;
|
|
718
|
+
/**
|
|
719
|
+
* Exit a parse tree produced by the `exprLogicalOr`
|
|
720
|
+
* labeled alternative in `MalloyParser.fieldExpr`.
|
|
721
|
+
* @param ctx the parse tree
|
|
722
|
+
*/
|
|
723
|
+
exitExprLogicalOr?: (ctx: ExprLogicalOrContext) => void;
|
|
724
|
+
/**
|
|
725
|
+
* Enter a parse tree produced by the `exprCoalesce`
|
|
687
726
|
* labeled alternative in `MalloyParser.fieldExpr`.
|
|
688
727
|
* @param ctx the parse tree
|
|
689
728
|
*/
|
|
690
|
-
|
|
729
|
+
enterExprCoalesce?: (ctx: ExprCoalesceContext) => void;
|
|
691
730
|
/**
|
|
692
|
-
* Exit a parse tree produced by the `
|
|
731
|
+
* Exit a parse tree produced by the `exprCoalesce`
|
|
693
732
|
* labeled alternative in `MalloyParser.fieldExpr`.
|
|
694
733
|
* @param ctx the parse tree
|
|
695
734
|
*/
|
|
696
|
-
|
|
735
|
+
exitExprCoalesce?: (ctx: ExprCoalesceContext) => void;
|
|
697
736
|
/**
|
|
698
737
|
* Enter a parse tree produced by the `exprCast`
|
|
699
738
|
* labeled alternative in `MalloyParser.fieldExpr`.
|
|
@@ -29,19 +29,22 @@ import { NestDefContext } from "./MalloyParser";
|
|
|
29
29
|
import { ExprFieldPathContext } from "./MalloyParser";
|
|
30
30
|
import { ExprFilterContext } from "./MalloyParser";
|
|
31
31
|
import { ExprLiteralContext } from "./MalloyParser";
|
|
32
|
-
import { ExprMinusContext } from "./MalloyParser";
|
|
33
32
|
import { ExprDurationContext } from "./MalloyParser";
|
|
34
33
|
import { ExprTimeTruncContext } from "./MalloyParser";
|
|
35
34
|
import { ExprSafeCastContext } from "./MalloyParser";
|
|
35
|
+
import { ExprMinusContext } from "./MalloyParser";
|
|
36
36
|
import { ExprMulDivContext } from "./MalloyParser";
|
|
37
37
|
import { ExprAddSubContext } from "./MalloyParser";
|
|
38
38
|
import { ExprRangeContext } from "./MalloyParser";
|
|
39
39
|
import { ExprForRangeContext } from "./MalloyParser";
|
|
40
|
-
import {
|
|
40
|
+
import { ExprAndTreeContext } from "./MalloyParser";
|
|
41
|
+
import { ExprOrTreeContext } from "./MalloyParser";
|
|
41
42
|
import { ExprCompareContext } from "./MalloyParser";
|
|
42
43
|
import { ExprApplyContext } from "./MalloyParser";
|
|
43
44
|
import { ExprNotContext } from "./MalloyParser";
|
|
44
|
-
import {
|
|
45
|
+
import { ExprLogicalAndContext } from "./MalloyParser";
|
|
46
|
+
import { ExprLogicalOrContext } from "./MalloyParser";
|
|
47
|
+
import { ExprCoalesceContext } from "./MalloyParser";
|
|
45
48
|
import { ExprCastContext } from "./MalloyParser";
|
|
46
49
|
import { ExprCountDisinctContext } from "./MalloyParser";
|
|
47
50
|
import { ExprAggregateContext } from "./MalloyParser";
|
|
@@ -391,13 +394,6 @@ export interface MalloyParserVisitor<Result> extends ParseTreeVisitor<Result> {
|
|
|
391
394
|
* @return the visitor result
|
|
392
395
|
*/
|
|
393
396
|
visitExprLiteral?: (ctx: ExprLiteralContext) => Result;
|
|
394
|
-
/**
|
|
395
|
-
* Visit a parse tree produced by the `exprMinus`
|
|
396
|
-
* labeled alternative in `MalloyParser.fieldExpr`.
|
|
397
|
-
* @param ctx the parse tree
|
|
398
|
-
* @return the visitor result
|
|
399
|
-
*/
|
|
400
|
-
visitExprMinus?: (ctx: ExprMinusContext) => Result;
|
|
401
397
|
/**
|
|
402
398
|
* Visit a parse tree produced by the `exprDuration`
|
|
403
399
|
* labeled alternative in `MalloyParser.fieldExpr`.
|
|
@@ -419,6 +415,13 @@ export interface MalloyParserVisitor<Result> extends ParseTreeVisitor<Result> {
|
|
|
419
415
|
* @return the visitor result
|
|
420
416
|
*/
|
|
421
417
|
visitExprSafeCast?: (ctx: ExprSafeCastContext) => Result;
|
|
418
|
+
/**
|
|
419
|
+
* Visit a parse tree produced by the `exprMinus`
|
|
420
|
+
* labeled alternative in `MalloyParser.fieldExpr`.
|
|
421
|
+
* @param ctx the parse tree
|
|
422
|
+
* @return the visitor result
|
|
423
|
+
*/
|
|
424
|
+
visitExprMinus?: (ctx: ExprMinusContext) => Result;
|
|
422
425
|
/**
|
|
423
426
|
* Visit a parse tree produced by the `exprMulDiv`
|
|
424
427
|
* labeled alternative in `MalloyParser.fieldExpr`.
|
|
@@ -448,12 +451,19 @@ export interface MalloyParserVisitor<Result> extends ParseTreeVisitor<Result> {
|
|
|
448
451
|
*/
|
|
449
452
|
visitExprForRange?: (ctx: ExprForRangeContext) => Result;
|
|
450
453
|
/**
|
|
451
|
-
* Visit a parse tree produced by the `
|
|
454
|
+
* Visit a parse tree produced by the `exprAndTree`
|
|
452
455
|
* labeled alternative in `MalloyParser.fieldExpr`.
|
|
453
456
|
* @param ctx the parse tree
|
|
454
457
|
* @return the visitor result
|
|
455
458
|
*/
|
|
456
|
-
|
|
459
|
+
visitExprAndTree?: (ctx: ExprAndTreeContext) => Result;
|
|
460
|
+
/**
|
|
461
|
+
* Visit a parse tree produced by the `exprOrTree`
|
|
462
|
+
* labeled alternative in `MalloyParser.fieldExpr`.
|
|
463
|
+
* @param ctx the parse tree
|
|
464
|
+
* @return the visitor result
|
|
465
|
+
*/
|
|
466
|
+
visitExprOrTree?: (ctx: ExprOrTreeContext) => Result;
|
|
457
467
|
/**
|
|
458
468
|
* Visit a parse tree produced by the `exprCompare`
|
|
459
469
|
* labeled alternative in `MalloyParser.fieldExpr`.
|
|
@@ -476,12 +486,26 @@ export interface MalloyParserVisitor<Result> extends ParseTreeVisitor<Result> {
|
|
|
476
486
|
*/
|
|
477
487
|
visitExprNot?: (ctx: ExprNotContext) => Result;
|
|
478
488
|
/**
|
|
479
|
-
* Visit a parse tree produced by the `
|
|
489
|
+
* Visit a parse tree produced by the `exprLogicalAnd`
|
|
490
|
+
* labeled alternative in `MalloyParser.fieldExpr`.
|
|
491
|
+
* @param ctx the parse tree
|
|
492
|
+
* @return the visitor result
|
|
493
|
+
*/
|
|
494
|
+
visitExprLogicalAnd?: (ctx: ExprLogicalAndContext) => Result;
|
|
495
|
+
/**
|
|
496
|
+
* Visit a parse tree produced by the `exprLogicalOr`
|
|
497
|
+
* labeled alternative in `MalloyParser.fieldExpr`.
|
|
498
|
+
* @param ctx the parse tree
|
|
499
|
+
* @return the visitor result
|
|
500
|
+
*/
|
|
501
|
+
visitExprLogicalOr?: (ctx: ExprLogicalOrContext) => Result;
|
|
502
|
+
/**
|
|
503
|
+
* Visit a parse tree produced by the `exprCoalesce`
|
|
480
504
|
* labeled alternative in `MalloyParser.fieldExpr`.
|
|
481
505
|
* @param ctx the parse tree
|
|
482
506
|
* @return the visitor result
|
|
483
507
|
*/
|
|
484
|
-
|
|
508
|
+
visitExprCoalesce?: (ctx: ExprCoalesceContext) => Result;
|
|
485
509
|
/**
|
|
486
510
|
* Visit a parse tree produced by the `exprCast`
|
|
487
511
|
* labeled alternative in `MalloyParser.fieldExpr`.
|
|
@@ -119,8 +119,11 @@ export declare class MalloyToAST extends AbstractParseTreeVisitor<ast.MalloyElem
|
|
|
119
119
|
visitExprNot(pcx: parse.ExprNotContext): ast.ExprNot;
|
|
120
120
|
visitExprBool(pcx: parse.ExprBoolContext): ast.Boolean;
|
|
121
121
|
allFieldExpressions(exprList: parse.FieldExprContext[]): ast.ExpressionDef[];
|
|
122
|
-
|
|
123
|
-
|
|
122
|
+
visitExprLogicalOr(pcx: parse.ExprLogicalOrContext): ast.ExprLogicalOp;
|
|
123
|
+
visitExprLogicalAnd(pcx: parse.ExprLogicalAndContext): ast.ExprLogicalOp;
|
|
124
|
+
visitExprOrTree(pcx: parse.ExprOrTreeContext): ast.ExprAlternationTree;
|
|
125
|
+
visitExprAndTree(pcx: parse.ExprAndTreeContext): ast.ExprAlternationTree;
|
|
126
|
+
visitExprCoalesce(pcx: parse.ExprCoalesceContext): ast.ExprCoalesce;
|
|
124
127
|
visitPartialAllowedFieldExpr(pcx: parse.PartialAllowedFieldExprContext): ast.ExpressionDef;
|
|
125
128
|
visitExprString(pcx: parse.ExprStringContext): ast.ExprString;
|
|
126
129
|
visitExprRegex(pcx: parse.ExprRegexContext): ast.ExprRegEx;
|
|
@@ -705,15 +705,30 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
|
|
|
705
705
|
allFieldExpressions(exprList) {
|
|
706
706
|
return exprList.map(ecx => this.getFieldExpr(ecx));
|
|
707
707
|
}
|
|
708
|
-
|
|
708
|
+
visitExprLogicalOr(pcx) {
|
|
709
709
|
const left = this.getFieldExpr(pcx.fieldExpr(0));
|
|
710
710
|
const right = this.getFieldExpr(pcx.fieldExpr(1));
|
|
711
|
-
return new ast.ExprLogicalOp(left,
|
|
711
|
+
return new ast.ExprLogicalOp(left, 'or', right);
|
|
712
712
|
}
|
|
713
|
-
|
|
713
|
+
visitExprLogicalAnd(pcx) {
|
|
714
|
+
const left = this.getFieldExpr(pcx.fieldExpr(0));
|
|
715
|
+
const right = this.getFieldExpr(pcx.fieldExpr(1));
|
|
716
|
+
return new ast.ExprLogicalOp(left, 'and', right);
|
|
717
|
+
}
|
|
718
|
+
visitExprOrTree(pcx) {
|
|
719
|
+
const left = this.getFieldExpr(pcx.fieldExpr());
|
|
720
|
+
const right = this.getFieldExpr(pcx.partialAllowedFieldExpr());
|
|
721
|
+
return this.astAt(new ast.ExprAlternationTree(left, '|', right), pcx);
|
|
722
|
+
}
|
|
723
|
+
visitExprAndTree(pcx) {
|
|
714
724
|
const left = this.getFieldExpr(pcx.fieldExpr());
|
|
715
725
|
const right = this.getFieldExpr(pcx.partialAllowedFieldExpr());
|
|
716
|
-
return new ast.ExprAlternationTree(left,
|
|
726
|
+
return this.astAt(new ast.ExprAlternationTree(left, '&', right), pcx);
|
|
727
|
+
}
|
|
728
|
+
visitExprCoalesce(pcx) {
|
|
729
|
+
const left = this.getFieldExpr(pcx.fieldExpr()[0]);
|
|
730
|
+
const right = this.getFieldExpr(pcx.fieldExpr()[1]);
|
|
731
|
+
return this.astAt(new ast.ExprCoalesce(left, right), pcx);
|
|
717
732
|
}
|
|
718
733
|
visitPartialAllowedFieldExpr(pcx) {
|
|
719
734
|
var _a;
|
|
@@ -839,9 +854,6 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
|
|
|
839
854
|
return new ast.ExprNULL();
|
|
840
855
|
}
|
|
841
856
|
visitExprApply(pcx) {
|
|
842
|
-
if (pcx.COLON()) {
|
|
843
|
-
this.contextError(pcx, "':' for apply is deprecated, use '?'", 'warn');
|
|
844
|
-
}
|
|
845
857
|
return new ast.Apply(this.getFieldExpr(pcx.fieldExpr()), this.getFieldExpr(pcx.partialAllowedFieldExpr()));
|
|
846
858
|
}
|
|
847
859
|
visitExprRange(pcx) {
|
|
@@ -664,6 +664,7 @@ describe('expressions', () => {
|
|
|
664
664
|
test('not', exprOK('not true'));
|
|
665
665
|
test('and', exprOK('true and false'));
|
|
666
666
|
test('or', exprOK('true or false'));
|
|
667
|
+
test('null-check (??)', exprOK('ai ?? 7'));
|
|
667
668
|
test('disallow date OP number', () => {
|
|
668
669
|
expect(new test_translator_1.BetaExpression('@2001 = 7')).compileToFailWith('Cannot compare a date to a number');
|
|
669
670
|
});
|