@gooddata/maql-antlr4ts 0.5.1-6d2b4f4a.0 → 0.5.1-885c13db.0
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/LICENSE +7 -0
- package/NOTICE +76 -0
- package/README.md +28 -25
- package/esm/antlr/CaseInsensitiveCharStream.d.ts +13 -0
- package/esm/antlr/CaseInsensitiveCharStream.js +31 -0
- package/esm/antlr/SyntaxErrorListener.d.ts +16 -0
- package/esm/antlr/SyntaxErrorListener.js +17 -0
- package/esm/ast/AstNode.d.ts +46 -0
- package/esm/ast/AstNode.js +42 -0
- package/esm/ast/CaseNode.d.ts +28 -0
- package/esm/ast/CaseNode.js +46 -0
- package/esm/ast/FunctionNode.d.ts +109 -0
- package/esm/ast/FunctionNode.js +192 -0
- package/esm/ast/IdentifierNode.d.ts +19 -0
- package/esm/ast/IdentifierNode.js +24 -0
- package/esm/ast/LiteralNode.d.ts +42 -0
- package/esm/ast/LiteralNode.js +107 -0
- package/esm/ast/OperatorNode.d.ts +11 -0
- package/esm/ast/OperatorNode.js +29 -0
- package/esm/ast/Range.d.ts +17 -0
- package/esm/ast/Range.js +12 -0
- package/esm/ast/SelectNode.d.ts +82 -0
- package/esm/ast/SelectNode.js +138 -0
- package/esm/gen/antlr/MaqlLexer.d.ts +172 -0
- package/esm/gen/antlr/MaqlLexer.js +1028 -0
- package/esm/gen/antlr/MaqlParser.d.ts +1427 -0
- package/esm/gen/antlr/MaqlParser.js +7963 -0
- package/esm/gen/antlr/MaqlParserListener.d.ts +1262 -0
- package/esm/gen/antlr/MaqlParserListener.js +2 -0
- package/esm/gen/antlr/MaqlParserVisitor.d.ts +801 -0
- package/esm/gen/antlr/MaqlParserVisitor.js +2 -0
- package/esm/gen/type/functions.d.ts +850 -0
- package/esm/gen/type/functions.js +1237 -0
- package/esm/gen.d.ts +5 -0
- package/esm/gen.js +7 -0
- package/esm/index.d.ts +14 -0
- package/esm/index.js +17 -0
- package/esm/visitor/ast/AbstractAstVisitor.d.ts +49 -0
- package/esm/visitor/ast/AbstractAstVisitor.js +129 -0
- package/esm/visitor/ast/AstNormalizer.d.ts +13 -0
- package/esm/visitor/ast/AstNormalizer.js +38 -0
- package/esm/visitor/parser/MaqlAstVisitor.d.ts +124 -0
- package/esm/visitor/parser/MaqlAstVisitor.js +581 -0
- package/package.json +55 -42
- package/dist/index.d.ts +0 -4835
- package/dist/index.js +0 -11920
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright (c) 2020-2022 GoodData Corporation
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
================================================================================
|
|
2
|
+
================================================================================
|
|
3
|
+
|
|
4
|
+
Third-Party Software for @gooddata/maql-antlr4ts
|
|
5
|
+
|
|
6
|
+
--------------------------------------------------------------------------------
|
|
7
|
+
|
|
8
|
+
The following 3rd-party software packages may be used by or distributed with
|
|
9
|
+
@gooddata/maql-antlr4ts. Any information relevant to third-party vendors listed
|
|
10
|
+
below are collected using common, reasonable means.
|
|
11
|
+
|
|
12
|
+
Date generated: 2026-10-20
|
|
13
|
+
|
|
14
|
+
================================================================================
|
|
15
|
+
================================================================================
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
================================================================================
|
|
19
|
+
|
|
20
|
+
Dependencies
|
|
21
|
+
|
|
22
|
+
================================================================================
|
|
23
|
+
|
|
24
|
+
- antlr4ts (0.5.0-alpha.4) [BSD-3-Clause]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
--------------------------------------------------------------------------------
|
|
28
|
+
Package Title: antlr4ts (0.5.0-alpha.4)
|
|
29
|
+
|
|
30
|
+
Package Locator: npm+antlr4ts$0.5.0-alpha.4
|
|
31
|
+
|
|
32
|
+
Package Depth: Direct
|
|
33
|
+
--------------------------------------------------------------------------------
|
|
34
|
+
|
|
35
|
+
* Declared Licenses *
|
|
36
|
+
BSD-3-Clause
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
[The "BSD license"]
|
|
40
|
+
Copyright (c) 2016 The ANTLR Project
|
|
41
|
+
All rights reserved.
|
|
42
|
+
|
|
43
|
+
Redistribution and use in source and binary forms, with or without
|
|
44
|
+
modification, are permitted provided that the following conditions
|
|
45
|
+
are met:
|
|
46
|
+
|
|
47
|
+
1. Redistributions of source code must retain the above copyright
|
|
48
|
+
notice, this list of conditions and the following disclaimer.
|
|
49
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
50
|
+
notice, this list of conditions and the following disclaimer in the
|
|
51
|
+
documentation and/or other materials provided with the distribution.
|
|
52
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
53
|
+
contributors may be used to endorse or promote products derived from
|
|
54
|
+
this software without specific prior written permission.
|
|
55
|
+
|
|
56
|
+
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
57
|
+
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
58
|
+
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
59
|
+
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
60
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
61
|
+
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
62
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
63
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
64
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
65
|
+
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
* Package Info *
|
|
69
|
+
|
|
70
|
+
Authors: Terence Parr, Sam Harwell, and Burt Harris
|
|
71
|
+
|
|
72
|
+
Package Homepage: https://github.com/tunnelvisionlabs/antlr4ts
|
|
73
|
+
|
|
74
|
+
Package Download URL: https://registry.npmjs.org/antlr4ts/-/antlr4ts-0.5.0-alpha.4.tgz
|
|
75
|
+
|
|
76
|
+
--------------------------------------------------------------------------------
|
package/README.md
CHANGED
|
@@ -19,7 +19,8 @@ import {
|
|
|
19
19
|
AstNormalizer,
|
|
20
20
|
} from "@gooddata/maql-antlr4ts";
|
|
21
21
|
|
|
22
|
-
const maql =
|
|
22
|
+
const maql =
|
|
23
|
+
"parse metric SELECT SUM(0.81 * {fact/price} * {fact/quantity}) BY {attribute/country} WITHOUT PF";
|
|
23
24
|
const charStream = new CaseInsensitiveCharStream(maql);
|
|
24
25
|
const lexer = new MaqlLexer(charStream);
|
|
25
26
|
const tokenStream = new CommonTokenStream(lexer);
|
|
@@ -33,30 +34,32 @@ const normalizedAst = normalizer.visit(ast);
|
|
|
33
34
|
|
|
34
35
|
## Local development
|
|
35
36
|
|
|
36
|
-
> Requirements: [`
|
|
37
|
+
> Requirements: [`pnpm`](https://pnpm.io)
|
|
37
38
|
|
|
38
|
-
| command
|
|
39
|
-
|
|
40
|
-
| `
|
|
41
|
-
| `
|
|
42
|
-
| `
|
|
43
|
-
| `
|
|
44
|
-
| `
|
|
45
|
-
| `
|
|
46
|
-
| `
|
|
47
|
-
| `
|
|
48
|
-
| `
|
|
39
|
+
| command | effect |
|
|
40
|
+
| ---------------- | ----------------------------------------------------------------- |
|
|
41
|
+
| `pnpm install` | install all dependencies |
|
|
42
|
+
| `pnpm build` | generate source files, compile files, bundle files into a package |
|
|
43
|
+
| `pnpm antlr4` | generate source files from MAQL grammar |
|
|
44
|
+
| `pnpm funcdef` | generate source files from MAQL function definitions |
|
|
45
|
+
| `pnpm compile` | compile TypeScript |
|
|
46
|
+
| `pnpm rollup -c` | bundle files into a package |
|
|
47
|
+
| `pnpm test` | run ESLint, Prettier, and all tests |
|
|
48
|
+
| `pnpm test-ci` | run `pnpm test` with CI options and junit.xml output file |
|
|
49
|
+
| `pnpm fix` | automatically fix ESLint and Prettier errors |
|
|
49
50
|
|
|
50
51
|
## Linking the package to other modules
|
|
51
52
|
|
|
52
|
-
First build and bundle the module.
|
|
53
|
+
First install the dependencies, then build and bundle the module.
|
|
53
54
|
|
|
54
|
-
`
|
|
55
|
+
`pnpm install`
|
|
55
56
|
|
|
56
|
-
|
|
57
|
+
`pnpm build`
|
|
58
|
+
|
|
59
|
+
> Warning: Do not use `pnpm link` or `npm link`.
|
|
57
60
|
>
|
|
58
61
|
> Currently, there exists an issue which causes a runtime error when symbolically linking
|
|
59
|
-
> this package using `
|
|
62
|
+
> this package using `pnpm` or `npm`. The error seems to involve the `antlr4ts` library,
|
|
60
63
|
> because it results in every single token having index of -1.
|
|
61
64
|
|
|
62
65
|
Use [yalc](https://github.com/wclr/yalc) to link the package to other repositories.
|
|
@@ -83,17 +86,17 @@ This section records how it was set up, so that you can change it or set it up a
|
|
|
83
86
|
|
|
84
87
|
You can set it up in one of these ways:
|
|
85
88
|
|
|
86
|
-
|
|
87
|
-
|
|
89
|
+
- **In the npm UI** at https://www.npmjs.com/package/@gooddata/maql-antlr4ts/access.
|
|
90
|
+
- **With the npm CLI.** Use npm 11.10.0 or newer, which has the `npm trust` command.
|
|
88
91
|
Log in to npm (`npm login`) as user `gooddata-ci`.
|
|
89
92
|
The user must have publish access to `@gooddata/maql-antlr4ts` and two-factor authentication.
|
|
90
93
|
Then run:
|
|
91
94
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
95
|
+
```sh
|
|
96
|
+
npm trust github @gooddata/maql-antlr4ts \
|
|
97
|
+
--file publish_maql_antlr4ts_npm.yml \
|
|
98
|
+
--repo gooddata/gdc-nas \
|
|
99
|
+
--allow-publish
|
|
100
|
+
```
|
|
98
101
|
|
|
99
102
|
To see the current configuration, run `npm trust list @gooddata/maql-antlr4ts`.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CodePointCharStream } from "antlr4ts";
|
|
2
|
+
/**
|
|
3
|
+
* ANTLR4 CharStream extension that sees all characters as lowercase
|
|
4
|
+
*/
|
|
5
|
+
export declare class CaseInsensitiveCharStream extends CodePointCharStream {
|
|
6
|
+
constructor(s: string, sourceName?: string);
|
|
7
|
+
/**
|
|
8
|
+
* Modified lookahead method.
|
|
9
|
+
* Transform the character to lowercase before passing it to the caller.
|
|
10
|
+
* The input string is not modified.
|
|
11
|
+
*/
|
|
12
|
+
LA(i: number): number;
|
|
13
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// (C) 2022 GoodData Corporation
|
|
2
|
+
import { CodePointBuffer, CodePointCharStream, IntStream } from "antlr4ts";
|
|
3
|
+
/**
|
|
4
|
+
* ANTLR4 CharStream extension that sees all characters as lowercase
|
|
5
|
+
*/
|
|
6
|
+
export class CaseInsensitiveCharStream extends CodePointCharStream {
|
|
7
|
+
constructor(s, sourceName) {
|
|
8
|
+
// buffer creation inspired by CharStreams.fromString implementation
|
|
9
|
+
const bufferBuilder = CodePointBuffer.builder(s.length);
|
|
10
|
+
const chars = new Uint16Array(s.length);
|
|
11
|
+
for (let i = 0; i < s.length; i++) {
|
|
12
|
+
// as we are within the string length the result of codePointAt will never be undefined
|
|
13
|
+
chars[i] = s.codePointAt(i);
|
|
14
|
+
}
|
|
15
|
+
bufferBuilder.append(chars);
|
|
16
|
+
const buffer = bufferBuilder.build();
|
|
17
|
+
super(buffer.array(), buffer.position, buffer.remaining, sourceName ?? IntStream.UNKNOWN_SOURCE_NAME);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Modified lookahead method.
|
|
21
|
+
* Transform the character to lowercase before passing it to the caller.
|
|
22
|
+
* The input string is not modified.
|
|
23
|
+
*/
|
|
24
|
+
LA(i) {
|
|
25
|
+
const c = super.LA(i);
|
|
26
|
+
if (c < 0) {
|
|
27
|
+
return c;
|
|
28
|
+
}
|
|
29
|
+
return String.fromCodePoint(c).toLowerCase().codePointAt(0) ?? c;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ANTLRErrorListener, Recognizer, Token } from "antlr4ts";
|
|
2
|
+
import type { RecognitionException } from "antlr4ts/RecognitionException.js";
|
|
3
|
+
import type { IPosition } from "../ast/Range.js";
|
|
4
|
+
/**
|
|
5
|
+
* ANTLR error listener that saves encountered errors
|
|
6
|
+
*/
|
|
7
|
+
export declare class SyntaxErrorListener implements ANTLRErrorListener<Token> {
|
|
8
|
+
readonly antlrErrors: IAntlrError[];
|
|
9
|
+
syntaxError(_recognizer: Recognizer<Token, any>, offendingToken: Token | undefined, line: number, startCharacter: number, msg: string, error: RecognitionException | undefined): void;
|
|
10
|
+
}
|
|
11
|
+
export interface IAntlrError {
|
|
12
|
+
position: IPosition;
|
|
13
|
+
message: string;
|
|
14
|
+
offendingToken?: Token;
|
|
15
|
+
error?: RecognitionException;
|
|
16
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// (C) 2022 GoodData Corporation
|
|
2
|
+
/**
|
|
3
|
+
* ANTLR error listener that saves encountered errors
|
|
4
|
+
*/
|
|
5
|
+
export class SyntaxErrorListener {
|
|
6
|
+
antlrErrors = [];
|
|
7
|
+
syntaxError(
|
|
8
|
+
// oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
+
_recognizer, offendingToken, line, startCharacter, msg, error) {
|
|
10
|
+
this.antlrErrors.push({
|
|
11
|
+
position: { line: line - 1, character: startCharacter },
|
|
12
|
+
message: msg,
|
|
13
|
+
offendingToken,
|
|
14
|
+
error,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { AbstractAstVisitor } from "../visitor/ast/AbstractAstVisitor.js";
|
|
2
|
+
import type { Case, Conditional, Else } from "./CaseNode.js";
|
|
3
|
+
import type { Direction, Image, LastFirstValueFunction, List, MaqlFunction, MetricReference, OrderBy, OrderByElement, RankFunction, RankingFilter, RunningFunction, Window, WindowBound } from "./FunctionNode.js";
|
|
4
|
+
import type { Identifier, ObjectId, ObjectSpace, ObjectType } from "./IdentifierNode.js";
|
|
5
|
+
import type { BooleanLiteral, Granularity, NullLiteral, NumberLiteral, StringLiteral } from "./LiteralNode.js";
|
|
6
|
+
import type { Operator } from "./OperatorNode.js";
|
|
7
|
+
import type { IRange } from "./Range.js";
|
|
8
|
+
import type { By, DatetimeTransformation, DimensionOperator, Expression, Filter, ForEach, ModificationOperator, ParentFilterModification, Select, Using } from "./SelectNode.js";
|
|
9
|
+
/**
|
|
10
|
+
* AST node interface compatible with the AST nodes from the Kotlin implementation of MAQL Parser
|
|
11
|
+
*/
|
|
12
|
+
export interface IAstNode {
|
|
13
|
+
readonly type: AstType;
|
|
14
|
+
readonly value: string;
|
|
15
|
+
readonly content: IAstNode[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Base class for MAQL AST nodes
|
|
19
|
+
*/
|
|
20
|
+
export declare class AstNode implements IAstNode {
|
|
21
|
+
readonly type: AstType;
|
|
22
|
+
readonly value: string;
|
|
23
|
+
readonly content: AstNode[];
|
|
24
|
+
/**
|
|
25
|
+
* Range in the original query with only meaningful tokens. Does not overlap with sibling nodes
|
|
26
|
+
*/
|
|
27
|
+
range?: IRange;
|
|
28
|
+
/**
|
|
29
|
+
* Range in the original query with meaningful and adjacent tokens e.g. whitespace. May overlap with sibling nodes
|
|
30
|
+
*/
|
|
31
|
+
contextRange?: IRange;
|
|
32
|
+
constructor(type?: AstType, value?: string, content?: AstNode[]);
|
|
33
|
+
accept<Result>(visitor: AbstractAstVisitor<Result>): Result;
|
|
34
|
+
}
|
|
35
|
+
export type AstType = Empty | Select | Expression | By | DimensionOperator | DatetimeTransformation | Filter | Using | ParentFilterModification | ModificationOperator | Case | Conditional | Else | MaqlFunction | RunningFunction | Window | WindowBound | RankFunction | Direction | LastFirstValueFunction | OrderBy | OrderByElement | Image | RankingFilter | MetricReference | BooleanLiteral | Identifier | ObjectType | ObjectSpace | ObjectId | NumberLiteral | StringLiteral | NullLiteral | Granularity | Operator | List | ForEach;
|
|
36
|
+
type Empty = "";
|
|
37
|
+
/**
|
|
38
|
+
* Empty node serves as a placeholder or as an error node. It should never appear from a well-formed query
|
|
39
|
+
*/
|
|
40
|
+
export declare class EmptyNode extends AstNode {
|
|
41
|
+
type: Empty;
|
|
42
|
+
constructor(value?: string, content?: AstNode[]);
|
|
43
|
+
accept<Result>(visitor: AbstractAstVisitor<Result>): Result;
|
|
44
|
+
}
|
|
45
|
+
export declare function nonNullContent<T extends IAstNode>(...nodes: (T | undefined)[]): T[];
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// (C) 2022 GoodData Corporation
|
|
2
|
+
/**
|
|
3
|
+
* Base class for MAQL AST nodes
|
|
4
|
+
*/
|
|
5
|
+
export class AstNode {
|
|
6
|
+
type;
|
|
7
|
+
value;
|
|
8
|
+
content;
|
|
9
|
+
/**
|
|
10
|
+
* Range in the original query with only meaningful tokens. Does not overlap with sibling nodes
|
|
11
|
+
*/
|
|
12
|
+
range;
|
|
13
|
+
/**
|
|
14
|
+
* Range in the original query with meaningful and adjacent tokens e.g. whitespace. May overlap with sibling nodes
|
|
15
|
+
*/
|
|
16
|
+
contextRange;
|
|
17
|
+
constructor(type = "", value = "", content = []) {
|
|
18
|
+
this.type = type;
|
|
19
|
+
this.value = value;
|
|
20
|
+
this.content = content;
|
|
21
|
+
}
|
|
22
|
+
accept(visitor) {
|
|
23
|
+
return visitor.visitChildren(this);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Empty node serves as a placeholder or as an error node. It should never appear from a well-formed query
|
|
28
|
+
*/
|
|
29
|
+
export class EmptyNode extends AstNode {
|
|
30
|
+
type;
|
|
31
|
+
constructor(value, content) {
|
|
32
|
+
const type = "";
|
|
33
|
+
super(type, value, content);
|
|
34
|
+
this.type = type;
|
|
35
|
+
}
|
|
36
|
+
accept(visitor) {
|
|
37
|
+
return visitor.visitEmptyNode(this);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export function nonNullContent(...nodes) {
|
|
41
|
+
return nodes.filter((node) => node !== undefined);
|
|
42
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { AbstractAstVisitor } from "../visitor/ast/AbstractAstVisitor.js";
|
|
2
|
+
import { AstNode } from "./AstNode.js";
|
|
3
|
+
declare const _caseTypes: readonly ["case"];
|
|
4
|
+
export type Case = (typeof _caseTypes)[number];
|
|
5
|
+
export declare class CaseNode extends AstNode {
|
|
6
|
+
readonly branches: AstNode[];
|
|
7
|
+
readonly elseBranch?: AstNode | undefined;
|
|
8
|
+
type: Case;
|
|
9
|
+
constructor(branches: AstNode[], elseBranch?: AstNode | undefined);
|
|
10
|
+
accept<Result>(visitor: AbstractAstVisitor<Result>): Result;
|
|
11
|
+
}
|
|
12
|
+
declare const _conditionalTypes: readonly ["when"];
|
|
13
|
+
export type Conditional = (typeof _conditionalTypes)[number];
|
|
14
|
+
export declare class ConditionalNode extends AstNode {
|
|
15
|
+
readonly condition: AstNode;
|
|
16
|
+
readonly expression: AstNode;
|
|
17
|
+
type: Conditional;
|
|
18
|
+
constructor(condition: AstNode, expression: AstNode);
|
|
19
|
+
accept<Result>(visitor: AbstractAstVisitor<Result>): Result;
|
|
20
|
+
}
|
|
21
|
+
declare const _elseTypes: readonly ["else"];
|
|
22
|
+
export type Else = (typeof _elseTypes)[number];
|
|
23
|
+
export declare class ElseNode extends AstNode {
|
|
24
|
+
type: Else;
|
|
25
|
+
constructor(expression: AstNode);
|
|
26
|
+
accept<Result>(visitor: AbstractAstVisitor<Result>): Result;
|
|
27
|
+
}
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// (C) 2022 GoodData Corporation
|
|
2
|
+
import { AstNode, nonNullContent } from "./AstNode.js";
|
|
3
|
+
const _caseTypes = ["case"];
|
|
4
|
+
export class CaseNode extends AstNode {
|
|
5
|
+
branches;
|
|
6
|
+
elseBranch;
|
|
7
|
+
type;
|
|
8
|
+
constructor(branches, elseBranch) {
|
|
9
|
+
const type = "case";
|
|
10
|
+
super(type, undefined, nonNullContent(...branches, elseBranch));
|
|
11
|
+
this.branches = branches;
|
|
12
|
+
this.elseBranch = elseBranch;
|
|
13
|
+
this.type = type;
|
|
14
|
+
}
|
|
15
|
+
accept(visitor) {
|
|
16
|
+
return visitor.visitCaseNode(this);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const _conditionalTypes = ["when"];
|
|
20
|
+
export class ConditionalNode extends AstNode {
|
|
21
|
+
condition;
|
|
22
|
+
expression;
|
|
23
|
+
type;
|
|
24
|
+
constructor(condition, expression) {
|
|
25
|
+
const type = "when";
|
|
26
|
+
super(type, undefined, nonNullContent(condition, expression));
|
|
27
|
+
this.condition = condition;
|
|
28
|
+
this.expression = expression;
|
|
29
|
+
this.type = type;
|
|
30
|
+
}
|
|
31
|
+
accept(visitor) {
|
|
32
|
+
return visitor.visitConditionalNode(this);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const _elseTypes = ["else"];
|
|
36
|
+
export class ElseNode extends AstNode {
|
|
37
|
+
type;
|
|
38
|
+
constructor(expression) {
|
|
39
|
+
const type = "else";
|
|
40
|
+
super(type, undefined, [expression]);
|
|
41
|
+
this.type = type;
|
|
42
|
+
}
|
|
43
|
+
accept(visitor) {
|
|
44
|
+
return visitor.visitElseNode(this);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type { AbstractAstVisitor } from "../visitor/ast/AbstractAstVisitor.js";
|
|
2
|
+
import { AstNode } from "./AstNode.js";
|
|
3
|
+
declare const functionTypes: readonly ["function", "time macro"];
|
|
4
|
+
export type MaqlFunction = (typeof functionTypes)[number];
|
|
5
|
+
export declare function isMaqlFunction(type: string): type is MaqlFunction;
|
|
6
|
+
export declare class FunctionNode extends AstNode {
|
|
7
|
+
readonly name: string;
|
|
8
|
+
type: MaqlFunction;
|
|
9
|
+
constructor(type: MaqlFunction, name: string, operands: AstNode[]);
|
|
10
|
+
accept<Result>(visitor: AbstractAstVisitor<Result>): Result;
|
|
11
|
+
}
|
|
12
|
+
declare const _runningFunctionTypes: readonly ["running function"];
|
|
13
|
+
export type RunningFunction = (typeof _runningFunctionTypes)[number];
|
|
14
|
+
export declare class RunningFunctionNode extends AstNode {
|
|
15
|
+
readonly within?: AstNode | undefined;
|
|
16
|
+
readonly rollWindow?: AstNode | undefined;
|
|
17
|
+
type: RunningFunction;
|
|
18
|
+
readonly functionNode: FunctionNode;
|
|
19
|
+
constructor(name: string, operand: AstNode, within?: AstNode | undefined, rollWindow?: AstNode | undefined);
|
|
20
|
+
accept<Result>(visitor: AbstractAstVisitor<Result>): Result;
|
|
21
|
+
}
|
|
22
|
+
declare const _windowTypes: readonly ["window"];
|
|
23
|
+
export type Window = (typeof _windowTypes)[number];
|
|
24
|
+
export declare class WindowNode extends AstNode {
|
|
25
|
+
type: Window;
|
|
26
|
+
constructor(bounds: AstNode[]);
|
|
27
|
+
accept<Result>(visitor: AbstractAstVisitor<Result>): Result;
|
|
28
|
+
}
|
|
29
|
+
declare const windowBoundTypes: readonly ["preceding", "following", "current"];
|
|
30
|
+
export type WindowBound = (typeof windowBoundTypes)[number];
|
|
31
|
+
export declare function isWindowBound(type: string): type is WindowBound;
|
|
32
|
+
export declare class WindowBoundNode extends AstNode {
|
|
33
|
+
type: WindowBound;
|
|
34
|
+
constructor(type: WindowBound, value?: "unbounded" | string);
|
|
35
|
+
accept<Result>(visitor: AbstractAstVisitor<Result>): Result;
|
|
36
|
+
}
|
|
37
|
+
declare const _rankFunctionTypes: readonly ["rank function"];
|
|
38
|
+
export type RankFunction = (typeof _rankFunctionTypes)[number];
|
|
39
|
+
export declare class RankFunctionNode extends AstNode {
|
|
40
|
+
readonly within?: AstNode | undefined;
|
|
41
|
+
type: RankFunction;
|
|
42
|
+
readonly functionNode: FunctionNode;
|
|
43
|
+
constructor(name: string, operands: AstNode[], rankDir?: string, within?: AstNode | undefined);
|
|
44
|
+
accept<Result>(visitor: AbstractAstVisitor<Result>): Result;
|
|
45
|
+
}
|
|
46
|
+
declare const _directionTypes: readonly ["direction"];
|
|
47
|
+
export type Direction = (typeof _directionTypes)[number];
|
|
48
|
+
export declare class DirectionNode extends AstNode {
|
|
49
|
+
type: Direction;
|
|
50
|
+
constructor(direction: string);
|
|
51
|
+
accept<Result>(visitor: AbstractAstVisitor<Result>): Result;
|
|
52
|
+
}
|
|
53
|
+
declare const _lastFirstValueFunctionTypes: readonly ["lastfirstvalue function"];
|
|
54
|
+
export type LastFirstValueFunction = (typeof _lastFirstValueFunctionTypes)[number];
|
|
55
|
+
export declare class LastFirstValueFunctionNode extends AstNode {
|
|
56
|
+
readonly orderBy: AstNode;
|
|
57
|
+
readonly within?: AstNode | undefined;
|
|
58
|
+
type: LastFirstValueFunction;
|
|
59
|
+
readonly functionNode: FunctionNode;
|
|
60
|
+
constructor(name: string, operands: AstNode[], orderBy: AstNode, within?: AstNode | undefined);
|
|
61
|
+
accept<Result>(visitor: AbstractAstVisitor<Result>): Result;
|
|
62
|
+
}
|
|
63
|
+
declare const _orderByTypes: readonly ["order by"];
|
|
64
|
+
export type OrderBy = (typeof _orderByTypes)[number];
|
|
65
|
+
export declare class OrderByNode extends AstNode {
|
|
66
|
+
type: OrderBy;
|
|
67
|
+
constructor(operands: AstNode[]);
|
|
68
|
+
accept<Result>(visitor: AbstractAstVisitor<Result>): Result;
|
|
69
|
+
}
|
|
70
|
+
declare const _orderByElementTypes: readonly ["order by element"];
|
|
71
|
+
export type OrderByElement = (typeof _orderByElementTypes)[number];
|
|
72
|
+
export declare class OrderByElementNode extends AstNode {
|
|
73
|
+
type: OrderByElement;
|
|
74
|
+
constructor(operand: AstNode, rankDir?: string);
|
|
75
|
+
accept<Result>(visitor: AbstractAstVisitor<Result>): Result;
|
|
76
|
+
}
|
|
77
|
+
declare const _metricReferenceTypes: readonly ["report metric"];
|
|
78
|
+
export type MetricReference = (typeof _metricReferenceTypes)[number];
|
|
79
|
+
export declare class MetricReferenceNode extends AstNode {
|
|
80
|
+
type: MetricReference;
|
|
81
|
+
constructor(operand: AstNode);
|
|
82
|
+
accept<Result>(visitor: AbstractAstVisitor<Result>): Result;
|
|
83
|
+
}
|
|
84
|
+
declare const _listTypes: readonly ["list", "()", "of"];
|
|
85
|
+
export type List = (typeof _listTypes)[number];
|
|
86
|
+
export declare class ListNode extends AstNode {
|
|
87
|
+
type: List;
|
|
88
|
+
constructor(type: List, operands: AstNode[]);
|
|
89
|
+
accept<Result>(visitor: AbstractAstVisitor<Result>): Result;
|
|
90
|
+
}
|
|
91
|
+
declare const _imageTypes: readonly ["image"];
|
|
92
|
+
export type Image = (typeof _imageTypes)[number];
|
|
93
|
+
export declare class ImageNode extends AstNode {
|
|
94
|
+
type: Image;
|
|
95
|
+
constructor(expression: AstNode, mapping: AstNode[]);
|
|
96
|
+
accept<Result>(visitor: AbstractAstVisitor<Result>): Result;
|
|
97
|
+
}
|
|
98
|
+
declare const rankingFilterTypes: readonly ["top", "bottom"];
|
|
99
|
+
export type RankingFilter = (typeof rankingFilterTypes)[number];
|
|
100
|
+
export declare function isRankingFilter(type: string): type is RankingFilter;
|
|
101
|
+
export declare class RankingFilterNode extends AstNode {
|
|
102
|
+
readonly rankSpec: AstNode;
|
|
103
|
+
readonly operands: AstNode[];
|
|
104
|
+
readonly within?: AstNode | undefined;
|
|
105
|
+
type: RankingFilter;
|
|
106
|
+
constructor(type: RankingFilter, rankSpec: AstNode, operands: AstNode[], within?: AstNode | undefined);
|
|
107
|
+
accept<Result>(visitor: AbstractAstVisitor<Result>): Result;
|
|
108
|
+
}
|
|
109
|
+
export {};
|