flowquery 1.0.15 → 1.0.17
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/python-publish.yml +97 -0
- package/dist/compute/runner.d.ts +3 -2
- package/dist/compute/runner.d.ts.map +1 -1
- package/dist/compute/runner.js +7 -7
- package/dist/compute/runner.js.map +1 -1
- package/dist/flowquery.min.js +1 -1
- package/dist/graph/data.d.ts +31 -0
- package/dist/graph/data.d.ts.map +1 -0
- package/dist/graph/data.js +110 -0
- package/dist/graph/data.js.map +1 -0
- package/dist/graph/database.d.ts +20 -0
- package/dist/graph/database.d.ts.map +1 -0
- package/dist/graph/database.js +77 -0
- package/dist/graph/database.js.map +1 -0
- package/dist/graph/hops.d.ts +11 -0
- package/dist/graph/hops.d.ts.map +1 -0
- package/dist/graph/hops.js +25 -0
- package/dist/graph/hops.js.map +1 -0
- package/dist/graph/node.d.ts +35 -0
- package/dist/graph/node.d.ts.map +1 -0
- package/dist/graph/node.js +113 -0
- package/dist/graph/node.js.map +1 -0
- package/dist/graph/node_data.d.ts +11 -0
- package/dist/graph/node_data.d.ts.map +1 -0
- package/dist/graph/node_data.js +20 -0
- package/dist/graph/node_data.js.map +1 -0
- package/dist/graph/node_reference.d.ts +10 -0
- package/dist/graph/node_reference.d.ts.map +1 -0
- package/dist/graph/node_reference.js +52 -0
- package/dist/graph/node_reference.js.map +1 -0
- package/dist/graph/pattern.d.ts +18 -0
- package/dist/graph/pattern.d.ts.map +1 -0
- package/dist/graph/pattern.js +114 -0
- package/dist/graph/pattern.js.map +1 -0
- package/dist/graph/pattern_expression.d.ts +14 -0
- package/dist/graph/pattern_expression.d.ts.map +1 -0
- package/dist/graph/pattern_expression.js +58 -0
- package/dist/graph/pattern_expression.js.map +1 -0
- package/dist/graph/patterns.d.ts +11 -0
- package/dist/graph/patterns.d.ts.map +1 -0
- package/dist/graph/patterns.js +49 -0
- package/dist/graph/patterns.js.map +1 -0
- package/dist/graph/physical_node.d.ts +10 -0
- package/dist/graph/physical_node.d.ts.map +1 -0
- package/dist/graph/physical_node.js +40 -0
- package/dist/graph/physical_node.js.map +1 -0
- package/dist/graph/physical_relationship.d.ts +10 -0
- package/dist/graph/physical_relationship.d.ts.map +1 -0
- package/dist/graph/physical_relationship.js +40 -0
- package/dist/graph/physical_relationship.js.map +1 -0
- package/dist/graph/relationship.d.ts +40 -0
- package/dist/graph/relationship.d.ts.map +1 -0
- package/dist/graph/relationship.js +124 -0
- package/dist/graph/relationship.js.map +1 -0
- package/dist/graph/relationship_data.d.ts +12 -0
- package/dist/graph/relationship_data.d.ts.map +1 -0
- package/dist/graph/relationship_data.js +40 -0
- package/dist/graph/relationship_data.js.map +1 -0
- package/dist/graph/relationship_match_collector.d.ts +19 -0
- package/dist/graph/relationship_match_collector.d.ts.map +1 -0
- package/dist/graph/relationship_match_collector.js +55 -0
- package/dist/graph/relationship_match_collector.js.map +1 -0
- package/dist/graph/relationship_reference.d.ts +8 -0
- package/dist/graph/relationship_reference.d.ts.map +1 -0
- package/dist/graph/relationship_reference.js +37 -0
- package/dist/graph/relationship_reference.js.map +1 -0
- package/dist/parsing/base_parser.d.ts +1 -0
- package/dist/parsing/base_parser.d.ts.map +1 -1
- package/dist/parsing/base_parser.js +4 -1
- package/dist/parsing/base_parser.js.map +1 -1
- package/dist/parsing/context.d.ts +2 -2
- package/dist/parsing/context.js +5 -5
- package/dist/parsing/expressions/boolean.d.ts +8 -0
- package/dist/parsing/expressions/boolean.d.ts.map +1 -0
- package/dist/parsing/expressions/boolean.js +26 -0
- package/dist/parsing/expressions/boolean.js.map +1 -0
- package/dist/parsing/expressions/expression.d.ts +4 -1
- package/dist/parsing/expressions/expression.d.ts.map +1 -1
- package/dist/parsing/expressions/expression.js +15 -8
- package/dist/parsing/expressions/expression.js.map +1 -1
- package/dist/parsing/expressions/expression_map.d.ts +1 -0
- package/dist/parsing/expressions/expression_map.d.ts.map +1 -1
- package/dist/parsing/expressions/expression_map.js +3 -0
- package/dist/parsing/expressions/expression_map.js.map +1 -1
- package/dist/parsing/expressions/operator.d.ts +1 -1
- package/dist/parsing/expressions/operator.d.ts.map +1 -1
- package/dist/parsing/expressions/operator.js.map +1 -1
- package/dist/parsing/functions/function_factory.d.ts +13 -13
- package/dist/parsing/functions/function_factory.d.ts.map +1 -1
- package/dist/parsing/functions/function_factory.js +20 -18
- package/dist/parsing/functions/function_factory.js.map +1 -1
- package/dist/parsing/operations/call.d.ts.map +1 -1
- package/dist/parsing/operations/call.js +3 -1
- package/dist/parsing/operations/call.js.map +1 -1
- package/dist/parsing/operations/create_node.d.ts +14 -0
- package/dist/parsing/operations/create_node.d.ts.map +1 -0
- package/dist/parsing/operations/create_node.js +51 -0
- package/dist/parsing/operations/create_node.js.map +1 -0
- package/dist/parsing/operations/create_relationship.d.ts +14 -0
- package/dist/parsing/operations/create_relationship.d.ts.map +1 -0
- package/dist/parsing/operations/create_relationship.js +51 -0
- package/dist/parsing/operations/create_relationship.js.map +1 -0
- package/dist/parsing/operations/match.d.ts +15 -0
- package/dist/parsing/operations/match.d.ts.map +1 -0
- package/dist/parsing/operations/match.js +45 -0
- package/dist/parsing/operations/match.js.map +1 -0
- package/dist/parsing/operations/operation.d.ts +1 -0
- package/dist/parsing/operations/operation.d.ts.map +1 -1
- package/dist/parsing/operations/operation.js +6 -0
- package/dist/parsing/operations/operation.js.map +1 -1
- package/dist/parsing/operations/return.d.ts +1 -0
- package/dist/parsing/operations/return.d.ts.map +1 -1
- package/dist/parsing/operations/return.js +7 -1
- package/dist/parsing/operations/return.js.map +1 -1
- package/dist/parsing/operations/where.d.ts +1 -1
- package/dist/parsing/operations/where.d.ts.map +1 -1
- package/dist/parsing/operations/where.js +4 -0
- package/dist/parsing/operations/where.js.map +1 -1
- package/dist/parsing/parser.d.ts +10 -0
- package/dist/parsing/parser.d.ts.map +1 -1
- package/dist/parsing/parser.js +344 -5
- package/dist/parsing/parser.js.map +1 -1
- package/dist/parsing/token_to_node.d.ts.map +1 -1
- package/dist/parsing/token_to_node.js +7 -0
- package/dist/parsing/token_to_node.js.map +1 -1
- package/dist/tokenization/keyword.d.ts +1 -0
- package/dist/tokenization/keyword.d.ts.map +1 -1
- package/dist/tokenization/keyword.js +1 -0
- package/dist/tokenization/keyword.js.map +1 -1
- package/dist/tokenization/token.d.ts +4 -0
- package/dist/tokenization/token.d.ts.map +1 -1
- package/dist/tokenization/token.js +14 -1
- package/dist/tokenization/token.js.map +1 -1
- package/dist/tokenization/token_type.d.ts +1 -0
- package/dist/tokenization/token_type.d.ts.map +1 -1
- package/dist/tokenization/token_type.js +1 -0
- package/dist/tokenization/token_type.js.map +1 -1
- package/dist/tokenization/tokenizer.d.ts +2 -1
- package/dist/tokenization/tokenizer.d.ts.map +1 -1
- package/dist/tokenization/tokenizer.js +25 -12
- package/dist/tokenization/tokenizer.js.map +1 -1
- package/docs/flowquery.min.js +1 -1
- package/flowquery-py/README.md +166 -0
- package/flowquery-py/pyproject.toml +75 -0
- package/flowquery-py/setup_env.ps1 +92 -0
- package/flowquery-py/setup_env.sh +87 -0
- package/flowquery-py/src/__init__.py +34 -0
- package/flowquery-py/src/__main__.py +10 -0
- package/flowquery-py/src/compute/__init__.py +5 -0
- package/flowquery-py/src/compute/runner.py +60 -0
- package/flowquery-py/src/extensibility.py +52 -0
- package/flowquery-py/src/graph/__init__.py +31 -0
- package/flowquery-py/src/graph/data.py +118 -0
- package/flowquery-py/src/graph/database.py +82 -0
- package/flowquery-py/src/graph/hops.py +43 -0
- package/flowquery-py/src/graph/node.py +112 -0
- package/flowquery-py/src/graph/node_data.py +26 -0
- package/flowquery-py/src/graph/node_reference.py +49 -0
- package/flowquery-py/src/graph/pattern.py +125 -0
- package/flowquery-py/src/graph/pattern_expression.py +62 -0
- package/flowquery-py/src/graph/patterns.py +42 -0
- package/flowquery-py/src/graph/physical_node.py +40 -0
- package/flowquery-py/src/graph/physical_relationship.py +36 -0
- package/flowquery-py/src/graph/relationship.py +135 -0
- package/flowquery-py/src/graph/relationship_data.py +33 -0
- package/flowquery-py/src/graph/relationship_match_collector.py +77 -0
- package/flowquery-py/src/graph/relationship_reference.py +21 -0
- package/flowquery-py/src/io/__init__.py +5 -0
- package/flowquery-py/src/io/command_line.py +67 -0
- package/flowquery-py/src/parsing/__init__.py +17 -0
- package/flowquery-py/src/parsing/alias.py +20 -0
- package/flowquery-py/src/parsing/alias_option.py +11 -0
- package/flowquery-py/src/parsing/ast_node.py +146 -0
- package/flowquery-py/src/parsing/base_parser.py +84 -0
- package/flowquery-py/src/parsing/components/__init__.py +19 -0
- package/flowquery-py/src/parsing/components/csv.py +8 -0
- package/flowquery-py/src/parsing/components/from_.py +10 -0
- package/flowquery-py/src/parsing/components/headers.py +12 -0
- package/flowquery-py/src/parsing/components/json.py +8 -0
- package/flowquery-py/src/parsing/components/null.py +10 -0
- package/flowquery-py/src/parsing/components/post.py +8 -0
- package/flowquery-py/src/parsing/components/text.py +8 -0
- package/flowquery-py/src/parsing/context.py +50 -0
- package/flowquery-py/src/parsing/data_structures/__init__.py +15 -0
- package/flowquery-py/src/parsing/data_structures/associative_array.py +41 -0
- package/flowquery-py/src/parsing/data_structures/json_array.py +30 -0
- package/flowquery-py/src/parsing/data_structures/key_value_pair.py +38 -0
- package/flowquery-py/src/parsing/data_structures/lookup.py +49 -0
- package/flowquery-py/src/parsing/data_structures/range_lookup.py +42 -0
- package/flowquery-py/src/parsing/expressions/__init__.py +57 -0
- package/flowquery-py/src/parsing/expressions/boolean.py +20 -0
- package/flowquery-py/src/parsing/expressions/expression.py +138 -0
- package/flowquery-py/src/parsing/expressions/expression_map.py +26 -0
- package/flowquery-py/src/parsing/expressions/f_string.py +27 -0
- package/flowquery-py/src/parsing/expressions/identifier.py +20 -0
- package/flowquery-py/src/parsing/expressions/number.py +32 -0
- package/flowquery-py/src/parsing/expressions/operator.py +169 -0
- package/flowquery-py/src/parsing/expressions/reference.py +47 -0
- package/flowquery-py/src/parsing/expressions/string.py +27 -0
- package/flowquery-py/src/parsing/functions/__init__.py +75 -0
- package/flowquery-py/src/parsing/functions/aggregate_function.py +60 -0
- package/flowquery-py/src/parsing/functions/async_function.py +62 -0
- package/flowquery-py/src/parsing/functions/avg.py +55 -0
- package/flowquery-py/src/parsing/functions/collect.py +75 -0
- package/flowquery-py/src/parsing/functions/function.py +68 -0
- package/flowquery-py/src/parsing/functions/function_factory.py +173 -0
- package/flowquery-py/src/parsing/functions/function_metadata.py +149 -0
- package/flowquery-py/src/parsing/functions/functions.py +59 -0
- package/flowquery-py/src/parsing/functions/join.py +47 -0
- package/flowquery-py/src/parsing/functions/keys.py +34 -0
- package/flowquery-py/src/parsing/functions/predicate_function.py +46 -0
- package/flowquery-py/src/parsing/functions/predicate_sum.py +47 -0
- package/flowquery-py/src/parsing/functions/rand.py +28 -0
- package/flowquery-py/src/parsing/functions/range_.py +34 -0
- package/flowquery-py/src/parsing/functions/reducer_element.py +15 -0
- package/flowquery-py/src/parsing/functions/replace.py +37 -0
- package/flowquery-py/src/parsing/functions/round_.py +32 -0
- package/flowquery-py/src/parsing/functions/size.py +32 -0
- package/flowquery-py/src/parsing/functions/split.py +47 -0
- package/flowquery-py/src/parsing/functions/stringify.py +47 -0
- package/flowquery-py/src/parsing/functions/sum.py +51 -0
- package/flowquery-py/src/parsing/functions/to_json.py +33 -0
- package/flowquery-py/src/parsing/functions/type_.py +47 -0
- package/flowquery-py/src/parsing/functions/value_holder.py +24 -0
- package/flowquery-py/src/parsing/logic/__init__.py +15 -0
- package/flowquery-py/src/parsing/logic/case.py +29 -0
- package/flowquery-py/src/parsing/logic/else_.py +12 -0
- package/flowquery-py/src/parsing/logic/end.py +8 -0
- package/flowquery-py/src/parsing/logic/then.py +12 -0
- package/flowquery-py/src/parsing/logic/when.py +10 -0
- package/flowquery-py/src/parsing/operations/__init__.py +35 -0
- package/flowquery-py/src/parsing/operations/aggregated_return.py +24 -0
- package/flowquery-py/src/parsing/operations/aggregated_with.py +22 -0
- package/flowquery-py/src/parsing/operations/call.py +74 -0
- package/flowquery-py/src/parsing/operations/create_node.py +34 -0
- package/flowquery-py/src/parsing/operations/create_relationship.py +34 -0
- package/flowquery-py/src/parsing/operations/group_by.py +130 -0
- package/flowquery-py/src/parsing/operations/limit.py +22 -0
- package/flowquery-py/src/parsing/operations/load.py +140 -0
- package/flowquery-py/src/parsing/operations/match.py +29 -0
- package/flowquery-py/src/parsing/operations/operation.py +69 -0
- package/flowquery-py/src/parsing/operations/projection.py +21 -0
- package/flowquery-py/src/parsing/operations/return_op.py +50 -0
- package/flowquery-py/src/parsing/operations/unwind.py +37 -0
- package/flowquery-py/src/parsing/operations/where.py +41 -0
- package/flowquery-py/src/parsing/operations/with_op.py +18 -0
- package/flowquery-py/src/parsing/parser.py +1011 -0
- package/flowquery-py/src/parsing/token_to_node.py +109 -0
- package/flowquery-py/src/tokenization/__init__.py +23 -0
- package/flowquery-py/src/tokenization/keyword.py +48 -0
- package/flowquery-py/src/tokenization/operator.py +29 -0
- package/flowquery-py/src/tokenization/string_walker.py +158 -0
- package/flowquery-py/src/tokenization/symbol.py +19 -0
- package/flowquery-py/src/tokenization/token.py +659 -0
- package/flowquery-py/src/tokenization/token_mapper.py +52 -0
- package/flowquery-py/src/tokenization/token_type.py +21 -0
- package/flowquery-py/src/tokenization/tokenizer.py +214 -0
- package/flowquery-py/src/tokenization/trie.py +124 -0
- package/flowquery-py/src/utils/__init__.py +6 -0
- package/flowquery-py/src/utils/object_utils.py +20 -0
- package/flowquery-py/src/utils/string_utils.py +113 -0
- package/flowquery-py/tests/__init__.py +1 -0
- package/flowquery-py/tests/compute/__init__.py +1 -0
- package/flowquery-py/tests/compute/test_runner.py +1335 -0
- package/flowquery-py/tests/graph/__init__.py +1 -0
- package/flowquery-py/tests/graph/test_create.py +56 -0
- package/flowquery-py/tests/graph/test_data.py +73 -0
- package/flowquery-py/tests/graph/test_match.py +40 -0
- package/flowquery-py/tests/parsing/__init__.py +1 -0
- package/flowquery-py/tests/parsing/test_context.py +34 -0
- package/flowquery-py/tests/parsing/test_expression.py +49 -0
- package/flowquery-py/tests/parsing/test_parser.py +674 -0
- package/flowquery-py/tests/test_extensibility.py +611 -0
- package/flowquery-py/tests/tokenization/__init__.py +1 -0
- package/flowquery-py/tests/tokenization/test_token_mapper.py +60 -0
- package/flowquery-py/tests/tokenization/test_tokenizer.py +164 -0
- package/flowquery-py/tests/tokenization/test_trie.py +30 -0
- package/flowquery-vscode/flowQueryEngine/flowquery.min.js +1 -1
- package/misc/apps/RAG/package.json +1 -1
- package/misc/apps/RAG/src/components/AdaptiveCardRenderer.tsx +76 -8
- package/misc/apps/RAG/src/components/index.ts +19 -10
- package/misc/apps/RAG/src/plugins/loaders/CatFacts.ts +21 -26
- package/misc/apps/RAG/src/plugins/loaders/FetchJson.ts +24 -25
- package/misc/apps/RAG/src/plugins/loaders/Form.ts +163 -147
- package/misc/apps/RAG/src/plugins/loaders/Llm.ts +103 -90
- package/misc/apps/RAG/src/plugins/loaders/MockData.ts +80 -130
- package/misc/apps/RAG/src/plugins/loaders/Table.ts +104 -101
- package/misc/apps/RAG/src/plugins/loaders/Weather.ts +47 -36
- package/misc/apps/RAG/src/prompts/FlowQuerySystemPrompt.ts +89 -78
- package/package.json +1 -1
- package/src/compute/runner.ts +24 -19
- package/src/graph/data.ts +112 -0
- package/src/graph/database.ts +63 -0
- package/src/graph/hops.ts +22 -0
- package/src/graph/node.ts +99 -0
- package/src/graph/node_data.ts +18 -0
- package/src/graph/node_reference.ts +33 -0
- package/src/graph/pattern.ts +101 -0
- package/src/graph/pattern_expression.ts +37 -0
- package/src/graph/patterns.ts +36 -0
- package/src/graph/physical_node.ts +23 -0
- package/src/graph/physical_relationship.ts +23 -0
- package/src/graph/relationship.ts +116 -0
- package/src/graph/relationship_data.ts +27 -0
- package/src/graph/relationship_match_collector.ts +58 -0
- package/src/graph/relationship_reference.ts +24 -0
- package/src/parsing/base_parser.ts +20 -14
- package/src/parsing/context.ts +14 -14
- package/src/parsing/expressions/boolean.ts +21 -0
- package/src/parsing/expressions/expression.ts +34 -26
- package/src/parsing/expressions/expression_map.ts +3 -0
- package/src/parsing/expressions/operator.ts +19 -1
- package/src/parsing/functions/function_factory.ts +45 -45
- package/src/parsing/operations/call.ts +3 -1
- package/src/parsing/operations/create_node.ts +39 -0
- package/src/parsing/operations/create_relationship.ts +38 -0
- package/src/parsing/operations/match.ts +31 -0
- package/src/parsing/operations/operation.ts +3 -0
- package/src/parsing/operations/return.ts +11 -7
- package/src/parsing/operations/where.ts +10 -6
- package/src/parsing/parser.ts +346 -8
- package/src/parsing/token_to_node.ts +6 -0
- package/src/tokenization/keyword.ts +41 -40
- package/src/tokenization/token.ts +21 -1
- package/src/tokenization/token_type.ts +2 -1
- package/src/tokenization/tokenizer.ts +52 -31
- package/tests/compute/runner.test.ts +660 -6
- package/tests/extensibility.test.ts +97 -93
- package/tests/graph/create.test.ts +36 -0
- package/tests/graph/data.test.ts +58 -0
- package/tests/graph/match.test.ts +29 -0
- package/tests/parsing/parser.test.ts +276 -8
- package/tests/tokenization/tokenizer.test.ts +107 -17
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
enum TokenType {
|
|
2
2
|
KEYWORD = "KEYWORD",
|
|
3
|
+
BOOLEAN = "BOOLEAN",
|
|
3
4
|
OPERATOR = "OPERATOR",
|
|
4
5
|
UNARY_OPERATOR = "UNARY_OPERATOR",
|
|
5
6
|
IDENTIFIER = "IDENTIFIER",
|
|
@@ -12,4 +13,4 @@ enum TokenType {
|
|
|
12
13
|
COMMENT = "COMMENT",
|
|
13
14
|
EOF = "EOF",
|
|
14
15
|
}
|
|
15
|
-
export default TokenType;
|
|
16
|
+
export default TokenType;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import Symbol from
|
|
6
|
-
import
|
|
7
|
-
import TokenMapper from
|
|
1
|
+
import StringUtils from "../utils/string_utils";
|
|
2
|
+
import Keyword from "./keyword";
|
|
3
|
+
import Operator from "./operator";
|
|
4
|
+
import StringWalker from "./string_walker";
|
|
5
|
+
import Symbol from "./symbol";
|
|
6
|
+
import Token from "./token";
|
|
7
|
+
import TokenMapper from "./token_mapper";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Tokenizes FlowQuery input strings into a sequence of tokens.
|
|
11
|
-
*
|
|
11
|
+
*
|
|
12
12
|
* The tokenizer performs lexical analysis, breaking down the input text into
|
|
13
13
|
* meaningful tokens such as keywords, identifiers, operators, strings, numbers,
|
|
14
14
|
* and symbols. It handles comments, whitespace, and f-strings.
|
|
15
|
-
*
|
|
15
|
+
*
|
|
16
16
|
* @example
|
|
17
17
|
* ```typescript
|
|
18
18
|
* const tokenizer = new Tokenizer("WITH x = 1 RETURN x");
|
|
@@ -27,7 +27,7 @@ class Tokenizer {
|
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* Creates a new Tokenizer instance for the given input.
|
|
30
|
-
*
|
|
30
|
+
*
|
|
31
31
|
* @param input - The FlowQuery input string to tokenize
|
|
32
32
|
*/
|
|
33
33
|
constructor(input: string) {
|
|
@@ -36,7 +36,7 @@ class Tokenizer {
|
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* Tokenizes the input string into an array of tokens.
|
|
39
|
-
*
|
|
39
|
+
*
|
|
40
40
|
* @returns An array of Token objects representing the tokenized input
|
|
41
41
|
* @throws {Error} If an unrecognized token is encountered
|
|
42
42
|
*/
|
|
@@ -60,7 +60,7 @@ class Tokenizer {
|
|
|
60
60
|
if (tokens.length === 0) {
|
|
61
61
|
return null;
|
|
62
62
|
}
|
|
63
|
-
if(!tokens[tokens.length - 1].isWhitespaceOrComment()) {
|
|
63
|
+
if (!tokens[tokens.length - 1].isWhitespaceOrComment()) {
|
|
64
64
|
return tokens[tokens.length - 1];
|
|
65
65
|
}
|
|
66
66
|
return null;
|
|
@@ -75,6 +75,7 @@ class Tokenizer {
|
|
|
75
75
|
this.whitespace() ||
|
|
76
76
|
this.lookup(this.keywords) ||
|
|
77
77
|
this.lookup(this.operators, last, this.skipMinus) ||
|
|
78
|
+
this.boolean() ||
|
|
78
79
|
this.identifier() ||
|
|
79
80
|
this.string() ||
|
|
80
81
|
this.number() ||
|
|
@@ -91,12 +92,26 @@ class Tokenizer {
|
|
|
91
92
|
return null;
|
|
92
93
|
}
|
|
93
94
|
|
|
95
|
+
private boolean(): Token | null {
|
|
96
|
+
const startPosition = this.walker.position;
|
|
97
|
+
if (this.walker.checkForString("TRUE")) {
|
|
98
|
+
return Token.BOOLEAN(this.walker.getString(startPosition).toUpperCase());
|
|
99
|
+
}
|
|
100
|
+
if (this.walker.checkForString("FALSE")) {
|
|
101
|
+
return Token.BOOLEAN(this.walker.getString(startPosition).toUpperCase());
|
|
102
|
+
}
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
|
|
94
106
|
private identifier(): Token | null {
|
|
95
107
|
const startPosition = this.walker.position;
|
|
96
108
|
if (this.walker.checkForUnderScore() || this.walker.checkForLetter()) {
|
|
97
|
-
while (
|
|
98
|
-
|
|
99
|
-
|
|
109
|
+
while (
|
|
110
|
+
!this.walker.isAtEnd &&
|
|
111
|
+
(this.walker.checkForLetter() ||
|
|
112
|
+
this.walker.checkForDigit() ||
|
|
113
|
+
this.walker.checkForUnderScore())
|
|
114
|
+
) {}
|
|
100
115
|
return Token.IDENTIFIER(this.walker.getString(startPosition));
|
|
101
116
|
}
|
|
102
117
|
return null;
|
|
@@ -127,7 +142,7 @@ class Tokenizer {
|
|
|
127
142
|
}
|
|
128
143
|
|
|
129
144
|
private *f_string(): Iterable<Token> {
|
|
130
|
-
if(!this.walker.checkForFStringStart()) {
|
|
145
|
+
if (!this.walker.checkForFStringStart()) {
|
|
131
146
|
return;
|
|
132
147
|
}
|
|
133
148
|
this.walker.moveNext(); // skip the f
|
|
@@ -142,20 +157,20 @@ class Tokenizer {
|
|
|
142
157
|
this.walker.moveNext();
|
|
143
158
|
continue;
|
|
144
159
|
}
|
|
145
|
-
if(this.walker.openingBrace()) {
|
|
160
|
+
if (this.walker.openingBrace()) {
|
|
146
161
|
yield Token.F_STRING(this.walker.getString(position), quoteChar);
|
|
147
162
|
position = this.walker.position;
|
|
148
163
|
yield Token.OPENING_BRACE;
|
|
149
164
|
this.walker.moveNext(); // skip the opening brace
|
|
150
165
|
position = this.walker.position;
|
|
151
|
-
while(!this.walker.isAtEnd && !this.walker.closingBrace()) {
|
|
166
|
+
while (!this.walker.isAtEnd && !this.walker.closingBrace()) {
|
|
152
167
|
const token = this.getNextToken();
|
|
153
|
-
if(token !== null) {
|
|
168
|
+
if (token !== null) {
|
|
154
169
|
yield token;
|
|
155
170
|
} else {
|
|
156
171
|
break;
|
|
157
172
|
}
|
|
158
|
-
if(this.walker.closingBrace()) {
|
|
173
|
+
if (this.walker.closingBrace()) {
|
|
159
174
|
yield Token.CLOSING_BRACE;
|
|
160
175
|
this.walker.moveNext(); // skip the closing brace
|
|
161
176
|
position = this.walker.position;
|
|
@@ -166,7 +181,7 @@ class Tokenizer {
|
|
|
166
181
|
if (this.walker.checkForString(quoteChar)) {
|
|
167
182
|
yield Token.F_STRING(this.walker.getString(position), quoteChar);
|
|
168
183
|
return;
|
|
169
|
-
}
|
|
184
|
+
}
|
|
170
185
|
this.walker.moveNext();
|
|
171
186
|
}
|
|
172
187
|
}
|
|
@@ -182,13 +197,15 @@ class Tokenizer {
|
|
|
182
197
|
|
|
183
198
|
private number(): Token | null {
|
|
184
199
|
const startPosition = this.walker.position;
|
|
185
|
-
if (this.walker.checkForString(
|
|
186
|
-
while (!this.walker.isAtEnd && this.walker.checkForDigit()) {
|
|
187
|
-
;
|
|
188
|
-
}
|
|
200
|
+
if (this.walker.checkForString("-") || this.walker.checkForDigit()) {
|
|
201
|
+
while (!this.walker.isAtEnd && this.walker.checkForDigit()) {}
|
|
189
202
|
if (this.walker.checkForString(Symbol.DOT)) {
|
|
203
|
+
let decimalDigits: number = 0;
|
|
190
204
|
while (!this.walker.isAtEnd && this.walker.checkForDigit()) {
|
|
191
|
-
|
|
205
|
+
decimalDigits++;
|
|
206
|
+
}
|
|
207
|
+
if (decimalDigits === 0) {
|
|
208
|
+
this.walker.movePrevious();
|
|
192
209
|
}
|
|
193
210
|
}
|
|
194
211
|
const _number = this.walker.getString(startPosition);
|
|
@@ -197,17 +214,21 @@ class Tokenizer {
|
|
|
197
214
|
return null;
|
|
198
215
|
}
|
|
199
216
|
|
|
200
|
-
private lookup(
|
|
217
|
+
private lookup(
|
|
218
|
+
mapper: TokenMapper,
|
|
219
|
+
last: Token | null = null,
|
|
220
|
+
skip?: (last: Token | null, current: Token) => boolean
|
|
221
|
+
): Token | null {
|
|
201
222
|
const token = mapper.map(this.walker.getRemainingString());
|
|
202
223
|
if (token !== undefined && token.value !== null) {
|
|
203
|
-
if(token.can_be_identifier && this.walker.word_continuation(token.value)) {
|
|
224
|
+
if (token.can_be_identifier && this.walker.word_continuation(token.value)) {
|
|
204
225
|
return null;
|
|
205
226
|
}
|
|
206
227
|
if (skip && last && skip(last, token)) {
|
|
207
228
|
return null;
|
|
208
229
|
}
|
|
209
230
|
this.walker.moveBy(token.value.length);
|
|
210
|
-
if(mapper.last_found !== null) {
|
|
231
|
+
if (mapper.last_found !== null) {
|
|
211
232
|
token.case_sensitive_value = mapper.last_found;
|
|
212
233
|
}
|
|
213
234
|
return token;
|
|
@@ -219,11 +240,11 @@ class Tokenizer {
|
|
|
219
240
|
if (last === null) {
|
|
220
241
|
return false;
|
|
221
242
|
}
|
|
222
|
-
if((last.isKeyword() || last.isComma() || last.isColon()) && current.isNegation()) {
|
|
243
|
+
if ((last.isKeyword() || last.isComma() || last.isColon()) && current.isNegation()) {
|
|
223
244
|
return true;
|
|
224
245
|
}
|
|
225
246
|
return false;
|
|
226
247
|
}
|
|
227
248
|
}
|
|
228
249
|
|
|
229
|
-
export default Tokenizer;
|
|
250
|
+
export default Tokenizer;
|