flowquery 1.0.0 → 1.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/.github/workflows/npm-publish.yml +2 -0
- package/.github/workflows/release.yml +18 -9
- package/dist/compute/runner.js +75 -0
- package/dist/compute/runner.js.map +1 -0
- package/dist/flowquery.min.js +1 -0
- package/dist/index.browser.js +119 -0
- package/dist/index.browser.js.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/index.node.js +123 -0
- package/dist/index.node.js.map +1 -0
- package/dist/io/command_line.js +102 -0
- package/dist/io/command_line.js.map +1 -0
- package/dist/parsing/alias.js +23 -0
- package/dist/parsing/alias.js.map +1 -0
- package/dist/parsing/alias_option.js +11 -0
- package/dist/parsing/alias_option.js.map +1 -0
- package/dist/parsing/ast_node.js +145 -0
- package/dist/parsing/ast_node.js.map +1 -0
- package/dist/parsing/base_parser.js +92 -0
- package/dist/parsing/base_parser.js.map +1 -0
- package/dist/parsing/components/csv.js +13 -0
- package/dist/parsing/components/csv.js.map +1 -0
- package/dist/parsing/components/from.js +16 -0
- package/dist/parsing/components/from.js.map +1 -0
- package/dist/parsing/components/headers.js +16 -0
- package/dist/parsing/components/headers.js.map +1 -0
- package/dist/parsing/components/json.js +13 -0
- package/dist/parsing/components/json.js.map +1 -0
- package/dist/parsing/components/null.js +13 -0
- package/dist/parsing/components/null.js.map +1 -0
- package/dist/parsing/components/post.js +13 -0
- package/dist/parsing/components/post.js.map +1 -0
- package/dist/parsing/components/text.js +13 -0
- package/dist/parsing/components/text.js.map +1 -0
- package/dist/parsing/context.js +47 -0
- package/dist/parsing/context.js.map +1 -0
- package/dist/parsing/data_structures/associative_array.js +45 -0
- package/dist/parsing/data_structures/associative_array.js.map +1 -0
- package/dist/parsing/data_structures/json_array.js +35 -0
- package/dist/parsing/data_structures/json_array.js.map +1 -0
- package/dist/parsing/data_structures/key_value_pair.js +41 -0
- package/dist/parsing/data_structures/key_value_pair.js.map +1 -0
- package/dist/parsing/data_structures/lookup.js +44 -0
- package/dist/parsing/data_structures/lookup.js.map +1 -0
- package/dist/parsing/data_structures/range_lookup.js +40 -0
- package/dist/parsing/data_structures/range_lookup.js.map +1 -0
- package/dist/parsing/expressions/expression.js +142 -0
- package/dist/parsing/expressions/expression.js.map +1 -0
- package/dist/parsing/expressions/f_string.js +29 -0
- package/dist/parsing/expressions/f_string.js.map +1 -0
- package/dist/parsing/expressions/identifier.js +26 -0
- package/dist/parsing/expressions/identifier.js.map +1 -0
- package/dist/parsing/expressions/number.js +41 -0
- package/dist/parsing/expressions/number.js.map +1 -0
- package/dist/parsing/expressions/operator.js +180 -0
- package/dist/parsing/expressions/operator.js.map +1 -0
- package/dist/parsing/expressions/reference.js +45 -0
- package/dist/parsing/expressions/reference.js.map +1 -0
- package/dist/parsing/expressions/string.js +34 -0
- package/dist/parsing/expressions/string.js.map +1 -0
- package/dist/parsing/functions/aggregate_function.js +58 -0
- package/dist/parsing/functions/aggregate_function.js.map +1 -0
- package/dist/parsing/functions/async_function.js +119 -0
- package/dist/parsing/functions/async_function.js.map +1 -0
- package/dist/parsing/functions/avg.js +43 -0
- package/dist/parsing/functions/avg.js.map +1 -0
- package/dist/parsing/functions/collect.js +52 -0
- package/dist/parsing/functions/collect.js.map +1 -0
- package/dist/parsing/functions/function.js +59 -0
- package/dist/parsing/functions/function.js.map +1 -0
- package/dist/parsing/functions/function_factory.js +259 -0
- package/dist/parsing/functions/function_factory.js.map +1 -0
- package/dist/parsing/functions/function_metadata.js +159 -0
- package/dist/parsing/functions/function_metadata.js.map +1 -0
- package/dist/parsing/functions/functions.js +47 -0
- package/dist/parsing/functions/functions.js.map +1 -0
- package/dist/parsing/functions/join.js +29 -0
- package/dist/parsing/functions/join.js.map +1 -0
- package/dist/parsing/functions/predicate_function.js +37 -0
- package/dist/parsing/functions/predicate_function.js.map +1 -0
- package/dist/parsing/functions/predicate_function_factory.js +19 -0
- package/dist/parsing/functions/predicate_function_factory.js.map +1 -0
- package/dist/parsing/functions/predicate_sum.js +33 -0
- package/dist/parsing/functions/predicate_sum.js.map +1 -0
- package/dist/parsing/functions/rand.js +17 -0
- package/dist/parsing/functions/rand.js.map +1 -0
- package/dist/parsing/functions/range.js +22 -0
- package/dist/parsing/functions/range.js.map +1 -0
- package/dist/parsing/functions/reducer_element.js +12 -0
- package/dist/parsing/functions/reducer_element.js.map +1 -0
- package/dist/parsing/functions/replace.js +23 -0
- package/dist/parsing/functions/replace.js.map +1 -0
- package/dist/parsing/functions/round.js +21 -0
- package/dist/parsing/functions/round.js.map +1 -0
- package/dist/parsing/functions/size.js +21 -0
- package/dist/parsing/functions/size.js.map +1 -0
- package/dist/parsing/functions/split.js +29 -0
- package/dist/parsing/functions/split.js.map +1 -0
- package/dist/parsing/functions/stringify.js +29 -0
- package/dist/parsing/functions/stringify.js.map +1 -0
- package/dist/parsing/functions/sum.js +38 -0
- package/dist/parsing/functions/sum.js.map +1 -0
- package/dist/parsing/functions/to_json.js +21 -0
- package/dist/parsing/functions/to_json.js.map +1 -0
- package/dist/parsing/functions/value_holder.js +16 -0
- package/dist/parsing/functions/value_holder.js.map +1 -0
- package/dist/parsing/logic/case.js +27 -0
- package/dist/parsing/logic/case.js.map +1 -0
- package/dist/parsing/logic/else.js +16 -0
- package/dist/parsing/logic/else.js.map +1 -0
- package/dist/parsing/logic/end.js +13 -0
- package/dist/parsing/logic/end.js.map +1 -0
- package/dist/parsing/logic/then.js +16 -0
- package/dist/parsing/logic/then.js.map +1 -0
- package/dist/parsing/logic/when.js +16 -0
- package/dist/parsing/logic/when.js.map +1 -0
- package/dist/parsing/operations/aggregated_return.js +35 -0
- package/dist/parsing/operations/aggregated_return.js.map +1 -0
- package/dist/parsing/operations/aggregated_with.js +41 -0
- package/dist/parsing/operations/aggregated_with.js.map +1 -0
- package/dist/parsing/operations/group_by.js +139 -0
- package/dist/parsing/operations/group_by.js.map +1 -0
- package/dist/parsing/operations/limit.js +38 -0
- package/dist/parsing/operations/limit.js.map +1 -0
- package/dist/parsing/operations/load.js +174 -0
- package/dist/parsing/operations/load.js.map +1 -0
- package/dist/parsing/operations/operation.js +81 -0
- package/dist/parsing/operations/operation.js.map +1 -0
- package/dist/parsing/operations/projection.js +21 -0
- package/dist/parsing/operations/projection.js.map +1 -0
- package/dist/parsing/operations/return.js +60 -0
- package/dist/parsing/operations/return.js.map +1 -0
- package/dist/parsing/operations/unwind.js +46 -0
- package/dist/parsing/operations/unwind.js.map +1 -0
- package/dist/parsing/operations/where.js +53 -0
- package/dist/parsing/operations/where.js.map +1 -0
- package/dist/parsing/operations/with.js +36 -0
- package/dist/parsing/operations/with.js.map +1 -0
- package/dist/parsing/parser.js +812 -0
- package/dist/parsing/parser.js.map +1 -0
- package/dist/parsing/token_to_node.js +121 -0
- package/dist/parsing/token_to_node.js.map +1 -0
- package/dist/tokenization/keyword.js +46 -0
- package/dist/tokenization/keyword.js.map +1 -0
- package/dist/tokenization/operator.js +28 -0
- package/dist/tokenization/operator.js.map +1 -0
- package/dist/tokenization/string_walker.js +165 -0
- package/dist/tokenization/string_walker.js.map +1 -0
- package/dist/tokenization/symbol.js +18 -0
- package/dist/tokenization/symbol.js.map +1 -0
- package/dist/tokenization/token.js +484 -0
- package/dist/tokenization/token.js.map +1 -0
- package/dist/tokenization/token_mapper.js +55 -0
- package/dist/tokenization/token_mapper.js.map +1 -0
- package/dist/tokenization/token_type.js +19 -0
- package/dist/tokenization/token_type.js.map +1 -0
- package/dist/tokenization/tokenizer.js +220 -0
- package/dist/tokenization/tokenizer.js.map +1 -0
- package/dist/tokenization/trie.js +111 -0
- package/dist/tokenization/trie.js.map +1 -0
- package/dist/utils/object_utils.js +19 -0
- package/dist/utils/object_utils.js.map +1 -0
- package/dist/utils/string_utils.js +110 -0
- package/dist/utils/string_utils.js.map +1 -0
- package/docs/flowquery.min.js +1 -1
- package/flowquery-vscode/flowQueryEngine/flowquery.min.js +1 -1
- package/package.json +21 -4
- package/src/compute/runner.ts +45 -0
- package/src/index.browser.ts +118 -0
- package/src/index.node.ts +141 -0
- package/src/parsing/functions/async_function.ts +95 -0
- package/src/parsing/functions/function_factory.ts +230 -1
- package/src/parsing/functions/function_metadata.ts +238 -0
- package/src/parsing/functions/functions.ts +43 -0
- package/src/parsing/operations/load.ts +51 -2
- package/src/parsing/parser.ts +46 -5
- package/tests/parsing/function_plugins.test.ts +369 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
const runner_1 = __importDefault(require("../compute/runner"));
|
|
40
|
+
const readline = __importStar(require("readline"));
|
|
41
|
+
/**
|
|
42
|
+
* Interactive command-line interface for FlowQuery.
|
|
43
|
+
*
|
|
44
|
+
* Provides a REPL (Read-Eval-Print Loop) for executing FlowQuery statements
|
|
45
|
+
* and displaying results.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* const cli = new CommandLine();
|
|
50
|
+
* cli.loop(); // Starts interactive mode
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
class CommandLine {
|
|
54
|
+
/**
|
|
55
|
+
* Creates a new CommandLine interface.
|
|
56
|
+
*/
|
|
57
|
+
constructor() {
|
|
58
|
+
this.rl = readline.createInterface({
|
|
59
|
+
input: process.stdin,
|
|
60
|
+
output: process.stdout
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Starts the interactive command loop.
|
|
65
|
+
*
|
|
66
|
+
* Prompts the user for FlowQuery statements, executes them, and displays results.
|
|
67
|
+
* Type "exit" to quit the loop.
|
|
68
|
+
*/
|
|
69
|
+
loop() {
|
|
70
|
+
console.log('Welcome to FlowQuery! Type "exit" to quit.');
|
|
71
|
+
this.rl.setPrompt('> ');
|
|
72
|
+
this.rl.prompt();
|
|
73
|
+
this.rl.on('line', (input) => {
|
|
74
|
+
if (input === 'exit') {
|
|
75
|
+
this.rl.close();
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if (input.trim() === '') {
|
|
79
|
+
this.rl.prompt();
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
try {
|
|
83
|
+
const runner = new runner_1.default(input);
|
|
84
|
+
const promise = runner.run();
|
|
85
|
+
promise.then(() => {
|
|
86
|
+
console.log(runner.results);
|
|
87
|
+
});
|
|
88
|
+
promise.catch((e) => console.error(e));
|
|
89
|
+
promise.finally(() => this.rl.prompt());
|
|
90
|
+
}
|
|
91
|
+
catch (e) {
|
|
92
|
+
console.error(e);
|
|
93
|
+
this.rl.prompt();
|
|
94
|
+
}
|
|
95
|
+
}).on('close', () => {
|
|
96
|
+
console.log('Exiting FlowQuery.');
|
|
97
|
+
process.exit(0);
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
exports.default = CommandLine;
|
|
102
|
+
//# sourceMappingURL=command_line.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command_line.js","sourceRoot":"","sources":["../../src/io/command_line.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+DAAuC;AACvC,mDAAqC;AAErC;;;;;;;;;;;GAWG;AACH,MAAM,WAAW;IAGb;;OAEG;IACH;QACI,IAAI,CAAC,EAAE,GAAG,QAAQ,CAAC,eAAe,CAAC;YAC/B,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,MAAM,EAAE,OAAO,CAAC,MAAM;SACzB,CAAC,CAAC;IACP,CAAC;IAED;;;;;OAKG;IACI,IAAI;QACP,OAAO,CAAC,GAAG,CAAC,4CAA4C,CAAC,CAAC;QAC1D,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACxB,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC;QAEjB,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE;YACjC,IAAI,KAAK,KAAK,MAAM,EAAE,CAAC;gBACnB,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC;gBAChB,OAAO;YACX,CAAC;YACD,IAAG,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;gBACrB,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC;gBACjB,OAAO;YACX,CAAC;YACD,IAAI,CAAC;gBACD,MAAM,MAAM,GAAG,IAAI,gBAAM,CAAC,KAAK,CAAC,CAAC;gBACjC,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,EAAE,CAAC;gBAC7B,OAAO,CAAC,IAAI,CACR,GAAG,EAAE;oBACD,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;gBAChC,CAAC,CACJ,CAAC;gBACF,OAAO,CAAC,KAAK,CACT,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAC1B,CAAC;gBACF,OAAO,CAAC,OAAO,CACX,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,CACzB,CAAC;YACN,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACT,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBACjB,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC;YACrB,CAAC;QACL,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;YAChB,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;YAClC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACpB,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAED,kBAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const ast_node_1 = __importDefault(require("./ast_node"));
|
|
7
|
+
class Alias extends ast_node_1.default {
|
|
8
|
+
constructor(alias) {
|
|
9
|
+
super();
|
|
10
|
+
this.alias = alias;
|
|
11
|
+
}
|
|
12
|
+
toString() {
|
|
13
|
+
return `Alias (${this.alias})`;
|
|
14
|
+
}
|
|
15
|
+
getAlias() {
|
|
16
|
+
return this.alias;
|
|
17
|
+
}
|
|
18
|
+
value() {
|
|
19
|
+
return this.alias;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.default = Alias;
|
|
23
|
+
//# sourceMappingURL=alias.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alias.js","sourceRoot":"","sources":["../../src/parsing/alias.ts"],"names":[],"mappings":";;;;;AAAA,0DAAiC;AAEjC,MAAM,KAAM,SAAQ,kBAAO;IAEvB,YAAY,KAAa;QACrB,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;IAEM,QAAQ;QACX,OAAO,UAAU,IAAI,CAAC,KAAK,GAAG,CAAC;IACnC,CAAC;IAEM,QAAQ;QACX,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAEM,KAAK;QACR,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;CACJ;AAED,kBAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AliasOption = void 0;
|
|
4
|
+
var AliasOption;
|
|
5
|
+
(function (AliasOption) {
|
|
6
|
+
AliasOption[AliasOption["NOT_ALLOWED"] = 0] = "NOT_ALLOWED";
|
|
7
|
+
AliasOption[AliasOption["OPTIONAL"] = 1] = "OPTIONAL";
|
|
8
|
+
AliasOption[AliasOption["REQUIRED"] = 2] = "REQUIRED";
|
|
9
|
+
})(AliasOption || (exports.AliasOption = AliasOption = {}));
|
|
10
|
+
;
|
|
11
|
+
//# sourceMappingURL=alias_option.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alias_option.js","sourceRoot":"","sources":["../../src/parsing/alias_option.ts"],"names":[],"mappings":";;;AAAA,IAAY,WAIX;AAJD,WAAY,WAAW;IACnB,2DAAe,CAAA;IACf,qDAAY,CAAA;IACZ,qDAAY,CAAA;AAChB,CAAC,EAJW,WAAW,2BAAX,WAAW,QAItB;AAAA,CAAC"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Represents a node in the Abstract Syntax Tree (AST).
|
|
5
|
+
*
|
|
6
|
+
* The AST is a tree representation of the parsed FlowQuery statement structure.
|
|
7
|
+
* Each node can have children and maintains a reference to its parent.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const root = new ASTNode();
|
|
12
|
+
* const child = new ASTNode();
|
|
13
|
+
* root.addChild(child);
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
class ASTNode {
|
|
17
|
+
constructor() {
|
|
18
|
+
this._parent = null;
|
|
19
|
+
this.children = [];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Adds a child node to this node and sets the child's parent reference.
|
|
23
|
+
*
|
|
24
|
+
* @param child - The child node to add
|
|
25
|
+
*/
|
|
26
|
+
addChild(child) {
|
|
27
|
+
child._parent = this;
|
|
28
|
+
this.children.push(child);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Returns the first child node.
|
|
32
|
+
*
|
|
33
|
+
* @returns The first child node
|
|
34
|
+
* @throws {Error} If the node has no children
|
|
35
|
+
*/
|
|
36
|
+
firstChild() {
|
|
37
|
+
if (this.children.length === 0) {
|
|
38
|
+
throw new Error('Expected child');
|
|
39
|
+
}
|
|
40
|
+
return this.children[0];
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Returns the last child node.
|
|
44
|
+
*
|
|
45
|
+
* @returns The last child node
|
|
46
|
+
* @throws {Error} If the node has no children
|
|
47
|
+
*/
|
|
48
|
+
lastChild() {
|
|
49
|
+
if (this.children.length === 0) {
|
|
50
|
+
throw new Error('Expected child');
|
|
51
|
+
}
|
|
52
|
+
return this.children[this.children.length - 1];
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Returns all child nodes.
|
|
56
|
+
*
|
|
57
|
+
* @returns Array of child nodes
|
|
58
|
+
*/
|
|
59
|
+
getChildren() {
|
|
60
|
+
return this.children;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Returns the number of child nodes.
|
|
64
|
+
*
|
|
65
|
+
* @returns The count of children
|
|
66
|
+
*/
|
|
67
|
+
childCount() {
|
|
68
|
+
return this.children.length;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Returns the value of this node. Override in subclasses to provide specific values.
|
|
72
|
+
*
|
|
73
|
+
* @returns The node's value, or null if not applicable
|
|
74
|
+
*/
|
|
75
|
+
value() {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Checks if this node represents an operator.
|
|
80
|
+
*
|
|
81
|
+
* @returns True if this is an operator node, false otherwise
|
|
82
|
+
*/
|
|
83
|
+
isOperator() {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Checks if this node represents an operand (the opposite of an operator).
|
|
88
|
+
*
|
|
89
|
+
* @returns True if this is an operand node, false otherwise
|
|
90
|
+
*/
|
|
91
|
+
isOperand() {
|
|
92
|
+
return !this.isOperator();
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Gets the operator precedence for this node. Higher values indicate higher precedence.
|
|
96
|
+
*
|
|
97
|
+
* @returns The precedence value (0 for non-operators)
|
|
98
|
+
*/
|
|
99
|
+
get precedence() {
|
|
100
|
+
return 0;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Indicates whether this operator is left-associative.
|
|
104
|
+
*
|
|
105
|
+
* @returns True if left-associative, false otherwise
|
|
106
|
+
*/
|
|
107
|
+
get leftAssociative() {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Prints a string representation of the AST tree starting from this node.
|
|
112
|
+
*
|
|
113
|
+
* @returns A formatted string showing the tree structure
|
|
114
|
+
*/
|
|
115
|
+
print() {
|
|
116
|
+
return Array.from(this._print(0)).join('\n');
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Generator function for recursively printing the tree structure.
|
|
120
|
+
*
|
|
121
|
+
* @param indent - The current indentation level
|
|
122
|
+
* @yields Lines representing each node in the tree
|
|
123
|
+
*/
|
|
124
|
+
*_print(indent) {
|
|
125
|
+
if (indent === 0) {
|
|
126
|
+
yield this.constructor.name;
|
|
127
|
+
}
|
|
128
|
+
else if (indent > 0) {
|
|
129
|
+
yield '-'.repeat(indent) + ` ${this.toString()}`;
|
|
130
|
+
}
|
|
131
|
+
for (const child of this.children) {
|
|
132
|
+
yield* child._print(indent + 1);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Returns a string representation of this node. Override in subclasses for custom formatting.
|
|
137
|
+
*
|
|
138
|
+
* @returns The string representation
|
|
139
|
+
*/
|
|
140
|
+
toString() {
|
|
141
|
+
return this.constructor.name;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
exports.default = ASTNode;
|
|
145
|
+
//# sourceMappingURL=ast_node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast_node.js","sourceRoot":"","sources":["../../src/parsing/ast_node.ts"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO;IAAb;QACc,YAAO,GAAmB,IAAI,CAAC;QAC/B,aAAQ,GAAc,EAAE,CAAC;IAuIvC,CAAC;IArIG;;;;OAIG;IACI,QAAQ,CAAC,KAAc;QAC1B,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;IAED;;;;;OAKG;IACI,UAAU;QACb,IAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;QACtC,CAAC;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC;IAED;;;;;OAKG;IACI,SAAS;QACZ,IAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;QACtC,CAAC;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACnD,CAAC;IAED;;;;OAIG;IACI,WAAW;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAED;;;;OAIG;IACI,UAAU;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;IAChC,CAAC;IAED;;;;OAIG;IACI,KAAK;QACR,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;OAIG;IACI,UAAU;QACb,OAAO,KAAK,CAAC;IACjB,CAAC;IAED;;;;OAIG;IACI,SAAS;QACZ,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;IAC9B,CAAC;IAED;;;;OAIG;IACH,IAAW,UAAU;QACjB,OAAO,CAAC,CAAC;IACb,CAAC;IAED;;;;OAIG;IACH,IAAW,eAAe;QACtB,OAAO,KAAK,CAAC;IACjB,CAAC;IAED;;;;OAIG;IACI,KAAK;QACR,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjD,CAAC;IAED;;;;;OAKG;IACK,CAAC,MAAM,CAAC,MAAc;QAC1B,IAAG,MAAM,KAAK,CAAC,EAAE,CAAC;YACd,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;QAChC,CAAC;aAAM,IAAG,MAAM,GAAG,CAAC,EAAE,CAAC;YACnB,MAAM,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,IAAI,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC;QACrD,CAAC;QACD,KAAI,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC/B,KAAK,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACpC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACO,QAAQ;QACd,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;IACjC,CAAC;CACJ;AAED,kBAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const token_1 = __importDefault(require("../tokenization/token"));
|
|
7
|
+
const tokenizer_1 = __importDefault(require("../tokenization/tokenizer"));
|
|
8
|
+
/**
|
|
9
|
+
* Base class for parsers providing common token manipulation functionality.
|
|
10
|
+
*
|
|
11
|
+
* This class handles tokenization and provides utility methods for navigating
|
|
12
|
+
* through tokens, peeking ahead, and checking token sequences.
|
|
13
|
+
*/
|
|
14
|
+
class BaseParser {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.tokens = [];
|
|
17
|
+
this.tokenIndex = 0;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Tokenizes a statement and initializes the token array.
|
|
21
|
+
*
|
|
22
|
+
* @param statement - The input statement to tokenize
|
|
23
|
+
*/
|
|
24
|
+
tokenize(statement) {
|
|
25
|
+
this.tokens = new tokenizer_1.default(statement).tokenize();
|
|
26
|
+
this.tokenIndex = 0;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Advances to the next token in the sequence.
|
|
30
|
+
*/
|
|
31
|
+
setNextToken() {
|
|
32
|
+
this.tokenIndex++;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Peeks at the next token without advancing the current position.
|
|
36
|
+
*
|
|
37
|
+
* @returns The next token, or null if at the end of the token stream
|
|
38
|
+
*/
|
|
39
|
+
peek() {
|
|
40
|
+
if (this.tokenIndex + 1 >= this.tokens.length) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
return this.tokens[this.tokenIndex + 1];
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Checks if a sequence of tokens appears ahead in the token stream.
|
|
47
|
+
*
|
|
48
|
+
* @param tokens - The sequence of tokens to look for
|
|
49
|
+
* @param skipWhitespaceAndComments - Whether to skip whitespace and comments when matching
|
|
50
|
+
* @returns True if the token sequence is found ahead, false otherwise
|
|
51
|
+
*/
|
|
52
|
+
ahead(tokens, skipWhitespaceAndComments = true) {
|
|
53
|
+
let j = 0;
|
|
54
|
+
for (let i = this.tokenIndex; i < this.tokens.length; i++) {
|
|
55
|
+
if (skipWhitespaceAndComments && this.tokens[i].isWhitespaceOrComment()) {
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
if (!this.tokens[i].equals(tokens[j])) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
j++;
|
|
62
|
+
if (j === tokens.length) {
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return j === tokens.length;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Gets the current token.
|
|
70
|
+
*
|
|
71
|
+
* @returns The current token, or EOF if at the end
|
|
72
|
+
*/
|
|
73
|
+
get token() {
|
|
74
|
+
if (this.tokenIndex >= this.tokens.length) {
|
|
75
|
+
return token_1.default.EOF;
|
|
76
|
+
}
|
|
77
|
+
return this.tokens[this.tokenIndex];
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Gets the previous token.
|
|
81
|
+
*
|
|
82
|
+
* @returns The previous token, or EOF if at the beginning
|
|
83
|
+
*/
|
|
84
|
+
get previousToken() {
|
|
85
|
+
if (this.tokenIndex - 1 < 0) {
|
|
86
|
+
return token_1.default.EOF;
|
|
87
|
+
}
|
|
88
|
+
return this.tokens[this.tokenIndex - 1];
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
exports.default = BaseParser;
|
|
92
|
+
//# sourceMappingURL=base_parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base_parser.js","sourceRoot":"","sources":["../../src/parsing/base_parser.ts"],"names":[],"mappings":";;;;;AAAA,kEAA0C;AAC1C,0EAAkD;AAElD;;;;;GAKG;AACH,MAAM,UAAU;IAAhB;QACY,WAAM,GAAqB,EAAE,CAAC;QAC9B,eAAU,GAAW,CAAC,CAAC;IA8EnC,CAAC;IA5EG;;;;OAIG;IACO,QAAQ,CAAC,SAAiB;QAChC,IAAI,CAAC,MAAM,GAAG,IAAI,mBAAS,CAAC,SAAS,CAAC,CAAC,QAAQ,EAAE,CAAC;QAClD,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC;IACxB,CAAC;IAED;;OAEG;IACO,YAAY;QAClB,IAAI,CAAC,UAAU,EAAE,CAAC;IACtB,CAAC;IAED;;;;OAIG;IACO,IAAI;QACV,IAAG,IAAI,CAAC,UAAU,GAAG,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;YAC3C,OAAO,IAAI,CAAC;QAChB,CAAC;QACD,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC;IAC5C,CAAC;IAED;;;;;;OAMG;IACO,KAAK,CAAC,MAAe,EAAE,4BAAqC,IAAI;QACtE,IAAI,CAAC,GAAG,CAAC,CAAC;QACV,KAAI,IAAI,CAAC,GAAC,IAAI,CAAC,UAAU,EAAE,CAAC,GAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACnD,IAAG,yBAAyB,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,qBAAqB,EAAE,EAAE,CAAC;gBACrE,SAAS;YACb,CAAC;YACD,IAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBACnC,OAAO,KAAK,CAAC;YACjB,CAAC;YACD,CAAC,EAAE,CAAC;YACJ,IAAG,CAAC,KAAK,MAAM,CAAC,MAAM,EAAE,CAAC;gBACrB,MAAM;YACV,CAAC;QACL,CAAC;QACD,OAAO,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC;IAC/B,CAAC;IAED;;;;OAIG;IACH,IAAc,KAAK;QACf,IAAG,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;YACvC,OAAO,eAAK,CAAC,GAAG,CAAC;QACrB,CAAC;QACD,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACxC,CAAC;IAED;;;;OAIG;IACH,IAAc,aAAa;QACvB,IAAG,IAAI,CAAC,UAAU,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACzB,OAAO,eAAK,CAAC,GAAG,CAAC;QACrB,CAAC;QACD,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC;IAC5C,CAAC;CACJ;AAED,kBAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const ast_node_1 = __importDefault(require("../ast_node"));
|
|
7
|
+
class CSV extends ast_node_1.default {
|
|
8
|
+
constructor() {
|
|
9
|
+
super();
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.default = CSV;
|
|
13
|
+
//# sourceMappingURL=csv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"csv.js","sourceRoot":"","sources":["../../../src/parsing/components/csv.ts"],"names":[],"mappings":";;;;;AAAA,2DAAkC;AAElC,MAAM,GAAI,SAAQ,kBAAO;IACvB;QACE,KAAK,EAAE,CAAC;IACV,CAAC;CACF;AAED,kBAAe,GAAG,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const ast_node_1 = __importDefault(require("../ast_node"));
|
|
7
|
+
class From extends ast_node_1.default {
|
|
8
|
+
constructor() {
|
|
9
|
+
super();
|
|
10
|
+
}
|
|
11
|
+
value() {
|
|
12
|
+
return this.children[0].value();
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.default = From;
|
|
16
|
+
//# sourceMappingURL=from.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"from.js","sourceRoot":"","sources":["../../../src/parsing/components/from.ts"],"names":[],"mappings":";;;;;AAAA,2DAAkC;AAElC,MAAM,IAAK,SAAQ,kBAAO;IACxB;QACE,KAAK,EAAE,CAAA;IACT,CAAC;IACM,KAAK;QACV,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;IAClC,CAAC;CACF;AAED,kBAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const ast_node_1 = __importDefault(require("../ast_node"));
|
|
7
|
+
class Headers extends ast_node_1.default {
|
|
8
|
+
constructor() {
|
|
9
|
+
super();
|
|
10
|
+
}
|
|
11
|
+
value() {
|
|
12
|
+
return this.firstChild().value() || {};
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.default = Headers;
|
|
16
|
+
//# sourceMappingURL=headers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"headers.js","sourceRoot":"","sources":["../../../src/parsing/components/headers.ts"],"names":[],"mappings":";;;;;AAAA,2DAAkC;AAElC,MAAM,OAAQ,SAAQ,kBAAO;IAC3B;QACE,KAAK,EAAE,CAAA;IACT,CAAC;IACM,KAAK;QACV,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC,KAAK,EAAY,IAAI,EAAE,CAAC;IACnD,CAAC;CACF;AAED,kBAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const ast_node_1 = __importDefault(require("../ast_node"));
|
|
7
|
+
class JSON extends ast_node_1.default {
|
|
8
|
+
constructor() {
|
|
9
|
+
super();
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.default = JSON;
|
|
13
|
+
//# sourceMappingURL=json.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.js","sourceRoot":"","sources":["../../../src/parsing/components/json.ts"],"names":[],"mappings":";;;;;AAAA,2DAAkC;AAElC,MAAM,IAAK,SAAQ,kBAAO;IACxB;QACE,KAAK,EAAE,CAAC;IACV,CAAC;CACF;AAED,kBAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const ast_node_1 = __importDefault(require("../ast_node"));
|
|
7
|
+
class Null extends ast_node_1.default {
|
|
8
|
+
constructor() {
|
|
9
|
+
super();
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.default = Null;
|
|
13
|
+
//# sourceMappingURL=null.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"null.js","sourceRoot":"","sources":["../../../src/parsing/components/null.ts"],"names":[],"mappings":";;;;;AAAA,2DAAkC;AAElC,MAAM,IAAK,SAAQ,kBAAO;IACtB;QACI,KAAK,EAAE,CAAC;IACZ,CAAC;CACJ;AAED,kBAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const ast_node_1 = __importDefault(require("../ast_node"));
|
|
7
|
+
class Post extends ast_node_1.default {
|
|
8
|
+
constructor() {
|
|
9
|
+
super();
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.default = Post;
|
|
13
|
+
//# sourceMappingURL=post.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"post.js","sourceRoot":"","sources":["../../../src/parsing/components/post.ts"],"names":[],"mappings":";;;;;AAAA,2DAAkC;AAElC,MAAM,IAAK,SAAQ,kBAAO;IACtB;QACI,KAAK,EAAE,CAAA;IACX,CAAC;CACJ;AAED,kBAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const ast_node_1 = __importDefault(require("../ast_node"));
|
|
7
|
+
class Text extends ast_node_1.default {
|
|
8
|
+
constructor() {
|
|
9
|
+
super();
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.default = Text;
|
|
13
|
+
//# sourceMappingURL=text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.js","sourceRoot":"","sources":["../../../src/parsing/components/text.ts"],"names":[],"mappings":";;;;;AAAA,2DAAkC;AAElC,MAAM,IAAK,SAAQ,kBAAO;IACxB;QACE,KAAK,EAAE,CAAC;IACV,CAAC;CACF;AAED,kBAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Maintains a stack of AST nodes to track parsing context.
|
|
5
|
+
*
|
|
6
|
+
* Used during parsing to maintain the current context and check for specific node types
|
|
7
|
+
* in the parsing hierarchy, which helps with context-sensitive parsing decisions.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const context = new Context();
|
|
12
|
+
* context.push(node);
|
|
13
|
+
* const hasReturn = context.containsType(Return);
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
class Context {
|
|
17
|
+
constructor() {
|
|
18
|
+
this.stack = [];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Pushes a node onto the context stack.
|
|
22
|
+
*
|
|
23
|
+
* @param node - The AST node to push
|
|
24
|
+
*/
|
|
25
|
+
push(node) {
|
|
26
|
+
this.stack.push(node);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Pops the top node from the context stack.
|
|
30
|
+
*
|
|
31
|
+
* @returns The popped node, or undefined if the stack is empty
|
|
32
|
+
*/
|
|
33
|
+
pop() {
|
|
34
|
+
return this.stack.pop();
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Checks if the stack contains a node of the specified type.
|
|
38
|
+
*
|
|
39
|
+
* @param type - The constructor of the node type to search for
|
|
40
|
+
* @returns True if a node of the specified type is found in the stack, false otherwise
|
|
41
|
+
*/
|
|
42
|
+
containsType(type) {
|
|
43
|
+
return this.stack.some((v) => v instanceof type);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.default = Context;
|
|
47
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/parsing/context.ts"],"names":[],"mappings":";;AAEA;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO;IAAb;QACY,UAAK,GAAc,EAAE,CAAC;IA6BlC,CAAC;IA3BG;;;;OAIG;IACI,IAAI,CAAC,IAAa;QACrB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAED;;;;OAIG;IACI,GAAG;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;IAC5B,CAAC;IAED;;;;;OAKG;IACI,YAAY,CAAC,IAAqC;QACrD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,YAAY,IAAI,CAAC,CAAC;IACrD,CAAC;CACJ;AAED,kBAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const ast_node_1 = __importDefault(require("../ast_node"));
|
|
7
|
+
/**
|
|
8
|
+
* Represents an associative array (object/dictionary) in the AST.
|
|
9
|
+
*
|
|
10
|
+
* Associative arrays map string keys to values, similar to JSON objects.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* // For { name: "Alice", age: 30 }
|
|
15
|
+
* const obj = new AssociativeArray();
|
|
16
|
+
* obj.addKeyValue(new KeyValuePair("name", nameExpr));
|
|
17
|
+
* obj.addKeyValue(new KeyValuePair("age", ageExpr));
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
class AssociativeArray extends ast_node_1.default {
|
|
21
|
+
/**
|
|
22
|
+
* Adds a key-value pair to the associative array.
|
|
23
|
+
*
|
|
24
|
+
* @param keyValuePair - The key-value pair to add
|
|
25
|
+
*/
|
|
26
|
+
addKeyValue(keyValuePair) {
|
|
27
|
+
this.addChild(keyValuePair);
|
|
28
|
+
}
|
|
29
|
+
toString() {
|
|
30
|
+
return 'AssociativeArray';
|
|
31
|
+
}
|
|
32
|
+
*_value() {
|
|
33
|
+
for (const child of this.children) {
|
|
34
|
+
const key_value = child;
|
|
35
|
+
yield {
|
|
36
|
+
[key_value.key]: key_value._value
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
value() {
|
|
41
|
+
return Object.assign({}, ...this._value());
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.default = AssociativeArray;
|
|
45
|
+
//# sourceMappingURL=associative_array.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"associative_array.js","sourceRoot":"","sources":["../../../src/parsing/data_structures/associative_array.ts"],"names":[],"mappings":";;;;;AAAA,2DAAkC;AAGlC;;;;;;;;;;;;GAYG;AACH,MAAM,gBAAiB,SAAQ,kBAAO;IAClC;;;;OAIG;IACI,WAAW,CAAC,YAA0B;QACzC,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IAChC,CAAC;IAEM,QAAQ;QACX,OAAO,kBAAkB,CAAC;IAC9B,CAAC;IACO,CAAC,MAAM;QACX,KAAI,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC/B,MAAM,SAAS,GAAG,KAAqB,CAAC;YACxC,MAAM;gBACF,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC,MAAM;aACpC,CAAC;QACN,CAAC;IACL,CAAC;IACM,KAAK;QACR,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IAC/C,CAAC;CACJ;AAED,kBAAe,gBAAgB,CAAC"}
|