@malloydata/malloy 0.0.1
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/README.md +39 -0
- package/dist/connection_utils.d.ts +1 -0
- package/dist/connection_utils.js +56 -0
- package/dist/dialect/dialect-map.d.ts +3 -0
- package/dist/dialect/dialect-map.js +33 -0
- package/dist/dialect/dialect.d.ts +64 -0
- package/dist/dialect/dialect.js +64 -0
- package/dist/dialect/dialect_map.d.ts +3 -0
- package/dist/dialect/dialect_map.js +35 -0
- package/dist/dialect/duckdb.d.ts +49 -0
- package/dist/dialect/duckdb.js +349 -0
- package/dist/dialect/index.d.ts +6 -0
- package/dist/dialect/index.js +27 -0
- package/dist/dialect/postgres.d.ts +49 -0
- package/dist/dialect/postgres.js +308 -0
- package/dist/dialect/standardsql.d.ts +46 -0
- package/dist/dialect/standardsql.js +361 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +47 -0
- package/dist/lang/ast/apply-expr.d.ts +16 -0
- package/dist/lang/ast/apply-expr.js +215 -0
- package/dist/lang/ast/ast-expr.d.ts +291 -0
- package/dist/lang/ast/ast-expr.js +1056 -0
- package/dist/lang/ast/ast-main.d.ts +480 -0
- package/dist/lang/ast/ast-main.js +2096 -0
- package/dist/lang/ast/ast-time-expr.d.ts +109 -0
- package/dist/lang/ast/ast-time-expr.js +550 -0
- package/dist/lang/ast/ast-types.d.ts +83 -0
- package/dist/lang/ast/ast-types.js +215 -0
- package/dist/lang/ast/index.d.ts +5 -0
- package/dist/lang/ast/index.js +34 -0
- package/dist/lang/ast/time-utils.d.ts +8 -0
- package/dist/lang/ast/time-utils.js +83 -0
- package/dist/lang/field-space.d.ts +157 -0
- package/dist/lang/field-space.js +651 -0
- package/dist/lang/field-utils.d.ts +5 -0
- package/dist/lang/field-utils.js +33 -0
- package/dist/lang/index.d.ts +9 -0
- package/dist/lang/index.js +22 -0
- package/dist/lang/lib/Malloy/MalloyLexer.d.ts +156 -0
- package/dist/lang/lib/Malloy/MalloyLexer.js +1163 -0
- package/dist/lang/lib/Malloy/MalloyListener.d.ts +2026 -0
- package/dist/lang/lib/Malloy/MalloyListener.js +4 -0
- package/dist/lang/lib/Malloy/MalloyParser.d.ts +1920 -0
- package/dist/lang/lib/Malloy/MalloyParser.js +11790 -0
- package/dist/lang/lib/Malloy/MalloyVisitor.d.ts +1276 -0
- package/dist/lang/lib/Malloy/MalloyVisitor.js +4 -0
- package/dist/lang/parse-log.d.ts +27 -0
- package/dist/lang/parse-log.js +41 -0
- package/dist/lang/parse-malloy.d.ts +245 -0
- package/dist/lang/parse-malloy.js +729 -0
- package/dist/lang/parse-to-ast.d.ts +156 -0
- package/dist/lang/parse-to-ast.js +945 -0
- package/dist/lang/parse-tree-walkers/document-completion-walker.d.ts +10 -0
- package/dist/lang/parse-tree-walkers/document-completion-walker.js +136 -0
- package/dist/lang/parse-tree-walkers/document-help-context-walker.d.ts +9 -0
- package/dist/lang/parse-tree-walkers/document-help-context-walker.js +97 -0
- package/dist/lang/parse-tree-walkers/document-highlight-walker.d.ts +83 -0
- package/dist/lang/parse-tree-walkers/document-highlight-walker.js +375 -0
- package/dist/lang/parse-tree-walkers/document-symbol-walker.d.ts +11 -0
- package/dist/lang/parse-tree-walkers/document-symbol-walker.js +172 -0
- package/dist/lang/parse-tree-walkers/explore-query-walker.d.ts +34 -0
- package/dist/lang/parse-tree-walkers/explore-query-walker.js +64 -0
- package/dist/lang/parse-tree-walkers/find-external-references.d.ts +11 -0
- package/dist/lang/parse-tree-walkers/find-external-references.js +51 -0
- package/dist/lang/reference-list.d.ts +10 -0
- package/dist/lang/reference-list.js +80 -0
- package/dist/lang/space-field.d.ts +119 -0
- package/dist/lang/space-field.js +339 -0
- package/dist/lang/test/document-help-context-walker.spec.d.ts +1 -0
- package/dist/lang/test/document-help-context-walker.spec.js +45 -0
- package/dist/lang/test/document-symbol-walker.spec.d.ts +1 -0
- package/dist/lang/test/document-symbol-walker.spec.js +100 -0
- package/dist/lang/test/field-symbols.spec.d.ts +1 -0
- package/dist/lang/test/field-symbols.spec.js +172 -0
- package/dist/lang/test/parse.spec.d.ts +12 -0
- package/dist/lang/test/parse.spec.js +1936 -0
- package/dist/lang/test/test-translator.d.ts +38 -0
- package/dist/lang/test/test-translator.js +334 -0
- package/dist/lang/zone.d.ts +57 -0
- package/dist/lang/zone.js +97 -0
- package/dist/malloy.d.ts +1134 -0
- package/dist/malloy.js +2354 -0
- package/dist/model/index.d.ts +2 -0
- package/dist/model/index.js +34 -0
- package/dist/model/malloy-query.d.ts +313 -0
- package/dist/model/malloy-query.js +2603 -0
- package/dist/model/malloy-types.d.ts +404 -0
- package/dist/model/malloy-types.js +242 -0
- package/dist/model/malloy_query.d.ts +353 -0
- package/dist/model/malloy_query.js +2990 -0
- package/dist/model/malloy_types.d.ts +502 -0
- package/dist/model/malloy_types.js +283 -0
- package/dist/model/sql-block.d.ts +11 -0
- package/dist/model/sql-block.js +38 -0
- package/dist/model/sql_block.d.ts +11 -0
- package/dist/model/sql_block.js +41 -0
- package/dist/model/utils.d.ts +21 -0
- package/dist/model/utils.js +84 -0
- package/dist/runtime-types.d.ts +116 -0
- package/dist/runtime-types.js +40 -0
- package/dist/runtime_types.d.ts +119 -0
- package/dist/runtime_types.js +15 -0
- package/package.json +36 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { ParserRuleContext } from "antlr4ts";
|
|
2
|
+
import type { ParseTree } from "antlr4ts/tree";
|
|
3
|
+
import { AbstractParseTreeVisitor } from "antlr4ts/tree/AbstractParseTreeVisitor";
|
|
4
|
+
import { MalloyVisitor } from "./lib/Malloy/MalloyVisitor";
|
|
5
|
+
import * as parse from "./lib/Malloy/MalloyParser";
|
|
6
|
+
import * as ast from "./ast";
|
|
7
|
+
import { MessageLogger } from "./parse-log";
|
|
8
|
+
import { MalloyParseRoot } from "./parse-malloy";
|
|
9
|
+
import { LogSeverity } from "./parse-log";
|
|
10
|
+
/**
|
|
11
|
+
* ANTLR visitor pattern parse tree traversal. Generates a Malloy
|
|
12
|
+
* AST from an ANTLR parse tree.
|
|
13
|
+
*/
|
|
14
|
+
export declare class MalloyToAST extends AbstractParseTreeVisitor<ast.MalloyElement> implements MalloyVisitor<ast.MalloyElement> {
|
|
15
|
+
readonly parse: MalloyParseRoot;
|
|
16
|
+
readonly msgLog: MessageLogger;
|
|
17
|
+
constructor(parse: MalloyParseRoot, msgLog: MessageLogger);
|
|
18
|
+
/**
|
|
19
|
+
* Mostly used to flag a case where the grammar and the type system are
|
|
20
|
+
* no longer in sync. A visitor was written based on a grammar which
|
|
21
|
+
* apparently has changed and now an unexpected element type has appeared.
|
|
22
|
+
* This is a non recoverable error, since the parser and the grammar
|
|
23
|
+
* are not compatible.
|
|
24
|
+
* @returns an error object to throw.
|
|
25
|
+
*/
|
|
26
|
+
protected internalError(cx: ParserRuleContext, msg: string): Error;
|
|
27
|
+
/**
|
|
28
|
+
* Log an error message relative to an AST node
|
|
29
|
+
*/
|
|
30
|
+
protected astError(el: ast.MalloyElement, str: string, sev?: LogSeverity): void;
|
|
31
|
+
/**
|
|
32
|
+
* Log an error message relative to a parse node
|
|
33
|
+
*/
|
|
34
|
+
protected contextError(cx: ParserRuleContext, msg: string, sev?: LogSeverity): void;
|
|
35
|
+
protected onlyExploreProperties(els: ast.MalloyElement[]): ast.ExploreProperty[];
|
|
36
|
+
protected onlyJoins(els: ast.MalloyElement[]): ast.Join[];
|
|
37
|
+
protected onlyDocStatements(els: ast.MalloyElement[]): ast.DocStatement[];
|
|
38
|
+
protected onlyNestedQueries(els: ast.MalloyElement[]): ast.NestedQuery[];
|
|
39
|
+
protected onlyQueryRefs(els: ast.MalloyElement[]): ast.QueryItem[];
|
|
40
|
+
protected getNumber(term: ParseTree): number;
|
|
41
|
+
protected getIdText(fromTerm: ParseTree): string;
|
|
42
|
+
protected getFieldName(cx: ParserRuleContext): ast.FieldName;
|
|
43
|
+
protected getModelEntryName(cx: ParserRuleContext): ast.ModelEntryReference;
|
|
44
|
+
protected stripQuotes(s: string): string;
|
|
45
|
+
protected optionalText(idCx: ParseTree | undefined): string | undefined;
|
|
46
|
+
defaultResult(): ast.MalloyElement;
|
|
47
|
+
protected astAt<MT extends ast.MalloyElement>(el: MT, cx: ParserRuleContext): MT;
|
|
48
|
+
protected getSourceCode(cx: ParserRuleContext): string;
|
|
49
|
+
protected getFilterElement(cx: parse.FieldExprContext): ast.FilterElement;
|
|
50
|
+
protected getFieldDefs(cxList: ParserRuleContext[], isAgg?: boolean): ast.FieldDeclaration[];
|
|
51
|
+
protected getFieldExpr(cx: parse.FieldExprContext): ast.ExpressionDef;
|
|
52
|
+
protected getSegments(segments: parse.PipeElementContext[]): ast.QOPDesc[];
|
|
53
|
+
protected getFilterShortcut(cx: parse.FilterShortcutContext): ast.Filter;
|
|
54
|
+
protected getExploreSource(pcx: parse.ExploreSourceContext): ast.Mallobj;
|
|
55
|
+
visitMalloyDocument(pcx: parse.MalloyDocumentContext): ast.Document;
|
|
56
|
+
visitDefineExploreStatement(pcx: parse.DefineExploreStatementContext): ast.DefineSourceList | ast.DefineExplore;
|
|
57
|
+
visitExploreDefinition(pcx: parse.ExploreDefinitionContext): ast.DefineExplore;
|
|
58
|
+
visitExplore(pcx: parse.ExploreContext): ast.Mallobj;
|
|
59
|
+
visitExploreProperties(pcx: parse.ExplorePropertiesContext): ast.ExploreDesc;
|
|
60
|
+
visitExploreTable(pcx: parse.ExploreTableContext): ast.TableSource;
|
|
61
|
+
visitTableSource(pcx: parse.TableSourceContext): ast.TableSource;
|
|
62
|
+
visitSQLSource(pcx: parse.SQLSourceContext): ast.SQLSource;
|
|
63
|
+
visitQuerySource(pcx: parse.QuerySourceContext): ast.Mallobj;
|
|
64
|
+
visitDefJoinMany(pcx: parse.DefJoinManyContext): ast.Joins;
|
|
65
|
+
visitDefJoinOne(pcx: parse.DefJoinOneContext): ast.Joins;
|
|
66
|
+
visitDefJoinCross(pcx: parse.DefJoinCrossContext): ast.Joins;
|
|
67
|
+
protected getJoinList(pcx: parse.JoinListContext): ast.MalloyElement[];
|
|
68
|
+
protected getJoinSource(name: ast.ModelEntryReference, ecx: parse.ExploreContext | undefined): ast.Mallobj;
|
|
69
|
+
visitJoinOn(pcx: parse.JoinOnContext): ast.Join;
|
|
70
|
+
visitJoinWith(pcx: parse.JoinWithContext): ast.Join;
|
|
71
|
+
visitFieldDef(pcx: parse.FieldDefContext): ast.FieldDeclaration;
|
|
72
|
+
visitDefExploreDimension(pcx: parse.DefExploreDimensionContext): ast.Dimensions;
|
|
73
|
+
visitDefExploreMeasure(pcx: parse.DefExploreMeasureContext): ast.Measures;
|
|
74
|
+
visitDeclareStatement(pcx: parse.DeclareStatementContext): ast.DeclareFields;
|
|
75
|
+
visitExploreRenameDef(pcx: parse.ExploreRenameDefContext): ast.RenameField;
|
|
76
|
+
visitDefExploreRename(pcx: parse.DefExploreRenameContext): ast.Renames;
|
|
77
|
+
visitFilterClauseList(pcx: parse.FilterClauseListContext): ast.Filter;
|
|
78
|
+
visitFilterByShortcut(pcx: parse.FilterByShortcutContext): ast.Filter;
|
|
79
|
+
visitWhereStatement(pcx: parse.WhereStatementContext): ast.Filter;
|
|
80
|
+
visitHavingStatement(pcx: parse.HavingStatementContext): ast.Filter;
|
|
81
|
+
visitSubQueryDefList(pcx: parse.SubQueryDefListContext): ast.Turtles;
|
|
82
|
+
visitDefExplorePrimaryKey(pcx: parse.DefExplorePrimaryKeyContext): ast.PrimaryKey;
|
|
83
|
+
visitFieldNameList(pcx: parse.FieldNameListContext): ast.FieldReferences;
|
|
84
|
+
visitDefExploreEditField(pcx: parse.DefExploreEditFieldContext): ast.FieldListEdit;
|
|
85
|
+
visitQueryProperties(pcx: parse.QueryPropertiesContext): ast.QOPDesc;
|
|
86
|
+
visitFieldPath(pcx: parse.FieldPathContext): ast.FieldReference;
|
|
87
|
+
visitQueryFieldDef(pcx: parse.QueryFieldDefContext): ast.QueryItem;
|
|
88
|
+
visitQueryFieldRef(pcx: parse.QueryFieldRefContext): ast.QueryItem;
|
|
89
|
+
protected getQueryItems(pcx: parse.QueryFieldListContext): ast.QueryItem[];
|
|
90
|
+
visitAggregateStatement(pcx: parse.AggregateStatementContext): ast.Aggregate;
|
|
91
|
+
visitGroupByStatement(pcx: parse.GroupByStatementContext): ast.GroupBy;
|
|
92
|
+
visitFieldCollection(pcx: parse.FieldCollectionContext): ast.ProjectStatement;
|
|
93
|
+
visitWildMember(pcx: parse.WildMemberContext): ast.FieldReferenceElement;
|
|
94
|
+
visitIndexFields(pcx: parse.IndexFieldsContext): ast.FieldReferences;
|
|
95
|
+
visitIndexStatement(pcx: parse.IndexStatementContext): ast.Index;
|
|
96
|
+
visitLimitStatement(pcx: parse.LimitStatementContext): ast.Limit;
|
|
97
|
+
visitOrderBySpec(pcx: parse.OrderBySpecContext): ast.OrderBy;
|
|
98
|
+
visitOrdering(pcx: parse.OrderingContext): ast.Ordering;
|
|
99
|
+
visitTopStatement(pcx: parse.TopStatementContext): ast.Top;
|
|
100
|
+
visitExploreName(pcx: parse.ExploreNameContext): ast.NamedSource;
|
|
101
|
+
protected buildPipelineFromName(pipe: ast.TurtleHeadedPipe, pipeCx: parse.PipelineFromNameContext): void;
|
|
102
|
+
visitExploreArrowQuery(pcx: parse.ExploreArrowQueryContext): ast.FullQuery;
|
|
103
|
+
visitArrowQuery(pcx: parse.ArrowQueryContext): ast.ExistingQuery;
|
|
104
|
+
visitTopLevelQueryDefs(pcx: parse.TopLevelQueryDefsContext): ast.DocStatement;
|
|
105
|
+
visitTopLevelQueryDef(pcx: parse.TopLevelQueryDefContext): ast.DefineQuery;
|
|
106
|
+
visitAnonymousQuery(pcx: parse.AnonymousQueryContext): ast.AnonymousQuery;
|
|
107
|
+
visitNestedQueryList(pcx: parse.NestedQueryListContext): ast.MalloyElement;
|
|
108
|
+
visitNestExisting(pcx: parse.NestExistingContext): ast.NestedQuery;
|
|
109
|
+
visitNestDef(pcx: parse.NestDefContext): ast.NestDefinition;
|
|
110
|
+
visitExploreQueryDef(pcx: parse.ExploreQueryDefContext): ast.TurtleDecl;
|
|
111
|
+
visitExprNot(pcx: parse.ExprNotContext): ast.ExprNot;
|
|
112
|
+
visitExprBool(pcx: parse.ExprBoolContext): ast.Boolean;
|
|
113
|
+
allFieldExpressions(exprList: parse.FieldExprContext[]): ast.ExpressionDef[];
|
|
114
|
+
visitExprLogical(pcx: parse.ExprLogicalContext): ast.ExprLogicalOp;
|
|
115
|
+
visitExprLogicalTree(pcx: parse.ExprLogicalTreeContext): ast.ExprAlternationTree;
|
|
116
|
+
visitExprNotPartial(pcx: parse.ExprNotPartialContext): ast.ExpressionDef;
|
|
117
|
+
visitExprPartialCompare(pcx: parse.ExprPartialCompareContext): ast.MalloyElement;
|
|
118
|
+
visitExprString(pcx: parse.ExprStringContext): ast.ExprString;
|
|
119
|
+
visitExprRegex(pcx: parse.ExprRegexContext): ast.ExprRegEx;
|
|
120
|
+
visitExprNow(_pcx: parse.ExprNowContext): ast.ExprNow;
|
|
121
|
+
visitExprNumber(pcx: parse.ExprNumberContext): ast.ExprNumber;
|
|
122
|
+
visitExprFieldPath(pcx: parse.ExprFieldPathContext): ast.ExprIdReference;
|
|
123
|
+
visitExprNULL(_pcx: parse.ExprNULLContext): ast.ExprNULL;
|
|
124
|
+
visitExprExpr(pcx: parse.ExprExprContext): ast.ExprParens;
|
|
125
|
+
visitExprMinus(pcx: parse.ExprMinusContext): ast.ExprMinus;
|
|
126
|
+
visitExprAddSub(pcx: parse.ExprAddSubContext): ast.ExprAddSub;
|
|
127
|
+
visitExprMulDiv(pcx: parse.ExprMulDivContext): ast.ExprMulDiv;
|
|
128
|
+
visitExprCompare(pcx: parse.ExprCompareContext): ast.ExprCompare;
|
|
129
|
+
visitExprCountDisinct(pcx: parse.ExprCountDisinctContext): ast.ExprCountDistinct;
|
|
130
|
+
visitExprUngroup(pcx: parse.ExprUngroupContext): ast.ExprUngroup;
|
|
131
|
+
visitExprAggregate(pcx: parse.ExprAggregateContext): ast.ExpressionDef;
|
|
132
|
+
visitExprApply(pcx: parse.ExprApplyContext): ast.Apply;
|
|
133
|
+
visitExprRange(pcx: parse.ExprRangeContext): ast.Range;
|
|
134
|
+
visitExprCast(pcx: parse.ExprCastContext): ast.ExpressionDef;
|
|
135
|
+
visitExprSafeCast(pcx: parse.ExprSafeCastContext): ast.ExpressionDef;
|
|
136
|
+
visitExprTimeTrunc(pcx: parse.ExprTimeTruncContext): ast.ExprGranularTime;
|
|
137
|
+
visitTimeframe(pcx: parse.TimeframeContext): ast.Timeframe;
|
|
138
|
+
visitExprForRange(pcx: parse.ExprForRangeContext): ast.ForRange;
|
|
139
|
+
visitExprFunc(pcx: parse.ExprFuncContext): ast.ExpressionDef;
|
|
140
|
+
visitExprDuration(pcx: parse.ExprDurationContext): ast.ExprDuration;
|
|
141
|
+
visitPickStatement(pcx: parse.PickStatementContext): ast.Pick;
|
|
142
|
+
visitNamedSource(pcx: parse.NamedSourceContext): ast.NamedSource;
|
|
143
|
+
visitExprFilter(pcx: parse.ExprFilterContext): ast.ExprFilter;
|
|
144
|
+
protected getLiteralTime(cx: ParserRuleContext): ast.ExpressionDef;
|
|
145
|
+
visitLiteralTimestamp(pcx: parse.LiteralTimestampContext): ast.ExpressionDef;
|
|
146
|
+
visitLiteralDay(pcx: parse.LiteralDayContext): ast.ExpressionDef;
|
|
147
|
+
visitLiteralWeek(pcx: parse.LiteralWeekContext): ast.ExpressionDef;
|
|
148
|
+
visitLiteralMonth(pcx: parse.LiteralMonthContext): ast.ExpressionDef;
|
|
149
|
+
visitLiteralQuarter(pcx: parse.LiteralQuarterContext): ast.ExpressionDef;
|
|
150
|
+
visitLiteralYear(pcx: parse.LiteralYearContext): ast.ExpressionDef;
|
|
151
|
+
visitImportStatement(pcx: parse.ImportStatementContext): ast.ImportStatement;
|
|
152
|
+
visitJustExpr(pcx: parse.JustExprContext): ast.ExpressionDef;
|
|
153
|
+
visitDefineSQLStatement(pcx: parse.DefineSQLStatementContext): ast.SQLStatement;
|
|
154
|
+
visitSQLStatementDef(pcx: parse.SqlStatementDefContext): ast.SQLStatement;
|
|
155
|
+
visitSampleStatement(pcx: parse.SampleStatementContext): ast.SampleProperty;
|
|
156
|
+
}
|