flowquery 1.0.46 → 1.0.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/flowquery.min.js +1 -1
- package/dist/index.d.ts +0 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -4
- package/dist/index.js.map +1 -1
- package/dist/parsing/data_structures/list_comprehension.d.ts +56 -0
- package/dist/parsing/data_structures/list_comprehension.d.ts.map +1 -0
- package/dist/parsing/data_structures/list_comprehension.js +102 -0
- package/dist/parsing/data_structures/list_comprehension.js.map +1 -0
- package/dist/parsing/parser.d.ts +18 -0
- package/dist/parsing/parser.d.ts.map +1 -1
- package/dist/parsing/parser.js +92 -0
- package/dist/parsing/parser.js.map +1 -1
- package/package.json +4 -1
- package/.editorconfig +0 -21
- package/.gitattributes +0 -3
- package/.github/workflows/npm-publish.yml +0 -32
- package/.github/workflows/python-publish.yml +0 -143
- package/.github/workflows/release.yml +0 -107
- package/.husky/pre-commit +0 -28
- package/.prettierrc +0 -22
- package/CODE_OF_CONDUCT.md +0 -10
- package/FlowQueryLogoIcon.png +0 -0
- package/SECURITY.md +0 -14
- package/SUPPORT.md +0 -13
- package/docs/flowquery.min.js +0 -1
- package/docs/index.html +0 -105
- package/flowquery-py/CONTRIBUTING.md +0 -127
- package/flowquery-py/README.md +0 -67
- package/flowquery-py/misc/data/test.json +0 -10
- package/flowquery-py/misc/data/users.json +0 -242
- package/flowquery-py/notebooks/TestFlowQuery.ipynb +0 -440
- package/flowquery-py/pyproject.toml +0 -121
- package/flowquery-py/setup_env.ps1 +0 -92
- package/flowquery-py/setup_env.sh +0 -87
- package/flowquery-py/src/__init__.py +0 -38
- package/flowquery-py/src/__main__.py +0 -10
- package/flowquery-py/src/compute/__init__.py +0 -6
- package/flowquery-py/src/compute/flowquery.py +0 -68
- package/flowquery-py/src/compute/runner.py +0 -64
- package/flowquery-py/src/extensibility.py +0 -52
- package/flowquery-py/src/graph/__init__.py +0 -31
- package/flowquery-py/src/graph/data.py +0 -136
- package/flowquery-py/src/graph/database.py +0 -141
- package/flowquery-py/src/graph/hops.py +0 -43
- package/flowquery-py/src/graph/node.py +0 -143
- package/flowquery-py/src/graph/node_data.py +0 -26
- package/flowquery-py/src/graph/node_reference.py +0 -50
- package/flowquery-py/src/graph/pattern.py +0 -115
- package/flowquery-py/src/graph/pattern_expression.py +0 -67
- package/flowquery-py/src/graph/patterns.py +0 -42
- package/flowquery-py/src/graph/physical_node.py +0 -41
- package/flowquery-py/src/graph/physical_relationship.py +0 -36
- package/flowquery-py/src/graph/relationship.py +0 -193
- package/flowquery-py/src/graph/relationship_data.py +0 -36
- package/flowquery-py/src/graph/relationship_match_collector.py +0 -85
- package/flowquery-py/src/graph/relationship_reference.py +0 -21
- package/flowquery-py/src/io/__init__.py +0 -5
- package/flowquery-py/src/io/command_line.py +0 -108
- package/flowquery-py/src/parsing/__init__.py +0 -17
- package/flowquery-py/src/parsing/alias.py +0 -20
- package/flowquery-py/src/parsing/alias_option.py +0 -11
- package/flowquery-py/src/parsing/ast_node.py +0 -147
- package/flowquery-py/src/parsing/base_parser.py +0 -84
- package/flowquery-py/src/parsing/components/__init__.py +0 -19
- package/flowquery-py/src/parsing/components/csv.py +0 -8
- package/flowquery-py/src/parsing/components/from_.py +0 -12
- package/flowquery-py/src/parsing/components/headers.py +0 -12
- package/flowquery-py/src/parsing/components/json.py +0 -8
- package/flowquery-py/src/parsing/components/null.py +0 -10
- package/flowquery-py/src/parsing/components/post.py +0 -8
- package/flowquery-py/src/parsing/components/text.py +0 -8
- package/flowquery-py/src/parsing/context.py +0 -50
- package/flowquery-py/src/parsing/data_structures/__init__.py +0 -15
- package/flowquery-py/src/parsing/data_structures/associative_array.py +0 -41
- package/flowquery-py/src/parsing/data_structures/json_array.py +0 -30
- package/flowquery-py/src/parsing/data_structures/key_value_pair.py +0 -38
- package/flowquery-py/src/parsing/data_structures/lookup.py +0 -51
- package/flowquery-py/src/parsing/data_structures/range_lookup.py +0 -42
- package/flowquery-py/src/parsing/expressions/__init__.py +0 -61
- package/flowquery-py/src/parsing/expressions/boolean.py +0 -20
- package/flowquery-py/src/parsing/expressions/expression.py +0 -141
- package/flowquery-py/src/parsing/expressions/expression_map.py +0 -26
- package/flowquery-py/src/parsing/expressions/f_string.py +0 -27
- package/flowquery-py/src/parsing/expressions/identifier.py +0 -21
- package/flowquery-py/src/parsing/expressions/number.py +0 -32
- package/flowquery-py/src/parsing/expressions/operator.py +0 -271
- package/flowquery-py/src/parsing/expressions/reference.py +0 -47
- package/flowquery-py/src/parsing/expressions/string.py +0 -27
- package/flowquery-py/src/parsing/functions/__init__.py +0 -127
- package/flowquery-py/src/parsing/functions/aggregate_function.py +0 -60
- package/flowquery-py/src/parsing/functions/async_function.py +0 -65
- package/flowquery-py/src/parsing/functions/avg.py +0 -55
- package/flowquery-py/src/parsing/functions/coalesce.py +0 -43
- package/flowquery-py/src/parsing/functions/collect.py +0 -75
- package/flowquery-py/src/parsing/functions/count.py +0 -79
- package/flowquery-py/src/parsing/functions/date_.py +0 -61
- package/flowquery-py/src/parsing/functions/datetime_.py +0 -62
- package/flowquery-py/src/parsing/functions/duration.py +0 -159
- package/flowquery-py/src/parsing/functions/element_id.py +0 -50
- package/flowquery-py/src/parsing/functions/function.py +0 -68
- package/flowquery-py/src/parsing/functions/function_factory.py +0 -170
- package/flowquery-py/src/parsing/functions/function_metadata.py +0 -148
- package/flowquery-py/src/parsing/functions/functions.py +0 -67
- package/flowquery-py/src/parsing/functions/head.py +0 -39
- package/flowquery-py/src/parsing/functions/id_.py +0 -49
- package/flowquery-py/src/parsing/functions/join.py +0 -49
- package/flowquery-py/src/parsing/functions/keys.py +0 -34
- package/flowquery-py/src/parsing/functions/last.py +0 -39
- package/flowquery-py/src/parsing/functions/localdatetime.py +0 -60
- package/flowquery-py/src/parsing/functions/localtime.py +0 -57
- package/flowquery-py/src/parsing/functions/max_.py +0 -49
- package/flowquery-py/src/parsing/functions/min_.py +0 -49
- package/flowquery-py/src/parsing/functions/nodes.py +0 -48
- package/flowquery-py/src/parsing/functions/predicate_function.py +0 -47
- package/flowquery-py/src/parsing/functions/predicate_sum.py +0 -49
- package/flowquery-py/src/parsing/functions/properties.py +0 -50
- package/flowquery-py/src/parsing/functions/rand.py +0 -28
- package/flowquery-py/src/parsing/functions/range_.py +0 -41
- package/flowquery-py/src/parsing/functions/reducer_element.py +0 -15
- package/flowquery-py/src/parsing/functions/relationships.py +0 -46
- package/flowquery-py/src/parsing/functions/replace.py +0 -39
- package/flowquery-py/src/parsing/functions/round_.py +0 -34
- package/flowquery-py/src/parsing/functions/schema.py +0 -40
- package/flowquery-py/src/parsing/functions/size.py +0 -34
- package/flowquery-py/src/parsing/functions/split.py +0 -54
- package/flowquery-py/src/parsing/functions/string_distance.py +0 -92
- package/flowquery-py/src/parsing/functions/stringify.py +0 -49
- package/flowquery-py/src/parsing/functions/substring.py +0 -76
- package/flowquery-py/src/parsing/functions/sum.py +0 -51
- package/flowquery-py/src/parsing/functions/tail.py +0 -37
- package/flowquery-py/src/parsing/functions/temporal_utils.py +0 -186
- package/flowquery-py/src/parsing/functions/time_.py +0 -57
- package/flowquery-py/src/parsing/functions/timestamp.py +0 -37
- package/flowquery-py/src/parsing/functions/to_float.py +0 -46
- package/flowquery-py/src/parsing/functions/to_integer.py +0 -46
- package/flowquery-py/src/parsing/functions/to_json.py +0 -35
- package/flowquery-py/src/parsing/functions/to_lower.py +0 -37
- package/flowquery-py/src/parsing/functions/to_string.py +0 -41
- package/flowquery-py/src/parsing/functions/trim.py +0 -37
- package/flowquery-py/src/parsing/functions/type_.py +0 -47
- package/flowquery-py/src/parsing/functions/value_holder.py +0 -24
- package/flowquery-py/src/parsing/logic/__init__.py +0 -15
- package/flowquery-py/src/parsing/logic/case.py +0 -28
- package/flowquery-py/src/parsing/logic/else_.py +0 -12
- package/flowquery-py/src/parsing/logic/end.py +0 -8
- package/flowquery-py/src/parsing/logic/then.py +0 -12
- package/flowquery-py/src/parsing/logic/when.py +0 -12
- package/flowquery-py/src/parsing/operations/__init__.py +0 -46
- package/flowquery-py/src/parsing/operations/aggregated_return.py +0 -25
- package/flowquery-py/src/parsing/operations/aggregated_with.py +0 -22
- package/flowquery-py/src/parsing/operations/call.py +0 -73
- package/flowquery-py/src/parsing/operations/create_node.py +0 -35
- package/flowquery-py/src/parsing/operations/create_relationship.py +0 -35
- package/flowquery-py/src/parsing/operations/delete_node.py +0 -29
- package/flowquery-py/src/parsing/operations/delete_relationship.py +0 -29
- package/flowquery-py/src/parsing/operations/group_by.py +0 -148
- package/flowquery-py/src/parsing/operations/limit.py +0 -33
- package/flowquery-py/src/parsing/operations/load.py +0 -148
- package/flowquery-py/src/parsing/operations/match.py +0 -52
- package/flowquery-py/src/parsing/operations/operation.py +0 -69
- package/flowquery-py/src/parsing/operations/order_by.py +0 -114
- package/flowquery-py/src/parsing/operations/projection.py +0 -21
- package/flowquery-py/src/parsing/operations/return_op.py +0 -88
- package/flowquery-py/src/parsing/operations/union.py +0 -115
- package/flowquery-py/src/parsing/operations/union_all.py +0 -17
- package/flowquery-py/src/parsing/operations/unwind.py +0 -42
- package/flowquery-py/src/parsing/operations/where.py +0 -43
- package/flowquery-py/src/parsing/operations/with_op.py +0 -18
- package/flowquery-py/src/parsing/parser.py +0 -1384
- package/flowquery-py/src/parsing/parser_state.py +0 -26
- package/flowquery-py/src/parsing/token_to_node.py +0 -109
- package/flowquery-py/src/tokenization/__init__.py +0 -23
- package/flowquery-py/src/tokenization/keyword.py +0 -54
- package/flowquery-py/src/tokenization/operator.py +0 -29
- package/flowquery-py/src/tokenization/string_walker.py +0 -158
- package/flowquery-py/src/tokenization/symbol.py +0 -19
- package/flowquery-py/src/tokenization/token.py +0 -693
- package/flowquery-py/src/tokenization/token_mapper.py +0 -53
- package/flowquery-py/src/tokenization/token_type.py +0 -21
- package/flowquery-py/src/tokenization/tokenizer.py +0 -214
- package/flowquery-py/src/tokenization/trie.py +0 -125
- package/flowquery-py/src/utils/__init__.py +0 -6
- package/flowquery-py/src/utils/object_utils.py +0 -20
- package/flowquery-py/src/utils/string_utils.py +0 -113
- package/flowquery-py/tests/__init__.py +0 -1
- package/flowquery-py/tests/compute/__init__.py +0 -1
- package/flowquery-py/tests/compute/test_runner.py +0 -4902
- package/flowquery-py/tests/graph/__init__.py +0 -1
- package/flowquery-py/tests/graph/test_create.py +0 -56
- package/flowquery-py/tests/graph/test_data.py +0 -73
- package/flowquery-py/tests/graph/test_match.py +0 -40
- package/flowquery-py/tests/parsing/__init__.py +0 -1
- package/flowquery-py/tests/parsing/test_context.py +0 -34
- package/flowquery-py/tests/parsing/test_expression.py +0 -248
- package/flowquery-py/tests/parsing/test_parser.py +0 -1237
- package/flowquery-py/tests/test_extensibility.py +0 -611
- package/flowquery-py/tests/tokenization/__init__.py +0 -1
- package/flowquery-py/tests/tokenization/test_token_mapper.py +0 -60
- package/flowquery-py/tests/tokenization/test_tokenizer.py +0 -198
- package/flowquery-py/tests/tokenization/test_trie.py +0 -30
- package/flowquery-vscode/.vscode-test.mjs +0 -5
- package/flowquery-vscode/.vscodeignore +0 -13
- package/flowquery-vscode/LICENSE +0 -21
- package/flowquery-vscode/README.md +0 -11
- package/flowquery-vscode/demo/FlowQueryVSCodeDemo.gif +0 -0
- package/flowquery-vscode/eslint.config.mjs +0 -25
- package/flowquery-vscode/extension.js +0 -508
- package/flowquery-vscode/flowQueryEngine/flowquery.min.js +0 -1
- package/flowquery-vscode/flowquery-worker.js +0 -66
- package/flowquery-vscode/images/FlowQueryLogoIcon.png +0 -0
- package/flowquery-vscode/jsconfig.json +0 -13
- package/flowquery-vscode/libs/page.css +0 -53
- package/flowquery-vscode/libs/table.css +0 -13
- package/flowquery-vscode/libs/tabs.css +0 -66
- package/flowquery-vscode/package-lock.json +0 -2917
- package/flowquery-vscode/package.json +0 -51
- package/flowquery-vscode/test/extension.test.js +0 -196
- package/flowquery-vscode/test/worker.test.js +0 -25
- package/flowquery-vscode/vsc-extension-quickstart.md +0 -42
- package/jest.config.js +0 -14
- package/misc/apps/RAG/README.md +0 -29
- package/misc/apps/RAG/data/chats.json +0 -302
- package/misc/apps/RAG/data/emails.json +0 -182
- package/misc/apps/RAG/data/events.json +0 -226
- package/misc/apps/RAG/data/files.json +0 -172
- package/misc/apps/RAG/data/users.json +0 -158
- package/misc/apps/RAG/jest.config.js +0 -21
- package/misc/apps/RAG/package.json +0 -48
- package/misc/apps/RAG/public/index.html +0 -18
- package/misc/apps/RAG/src/App.css +0 -42
- package/misc/apps/RAG/src/App.tsx +0 -50
- package/misc/apps/RAG/src/components/AdaptiveCardRenderer.css +0 -172
- package/misc/apps/RAG/src/components/AdaptiveCardRenderer.tsx +0 -380
- package/misc/apps/RAG/src/components/ApiKeySettings.tsx +0 -245
- package/misc/apps/RAG/src/components/ChatContainer.css +0 -67
- package/misc/apps/RAG/src/components/ChatContainer.tsx +0 -242
- package/misc/apps/RAG/src/components/ChatInput.css +0 -23
- package/misc/apps/RAG/src/components/ChatInput.tsx +0 -76
- package/misc/apps/RAG/src/components/ChatMessage.css +0 -160
- package/misc/apps/RAG/src/components/ChatMessage.tsx +0 -286
- package/misc/apps/RAG/src/components/FlowQueryAgent.ts +0 -708
- package/misc/apps/RAG/src/components/FlowQueryRunner.css +0 -113
- package/misc/apps/RAG/src/components/FlowQueryRunner.tsx +0 -371
- package/misc/apps/RAG/src/components/index.ts +0 -28
- package/misc/apps/RAG/src/graph/index.ts +0 -19
- package/misc/apps/RAG/src/graph/initializeGraph.ts +0 -254
- package/misc/apps/RAG/src/index.tsx +0 -29
- package/misc/apps/RAG/src/prompts/FlowQuerySystemPrompt.ts +0 -327
- package/misc/apps/RAG/src/prompts/index.ts +0 -10
- package/misc/apps/RAG/src/tests/graph.test.ts +0 -35
- package/misc/apps/RAG/src/utils/FlowQueryExecutor.ts +0 -130
- package/misc/apps/RAG/src/utils/FlowQueryExtractor.ts +0 -208
- package/misc/apps/RAG/src/utils/Llm.ts +0 -248
- package/misc/apps/RAG/src/utils/index.ts +0 -12
- package/misc/apps/RAG/tsconfig.json +0 -22
- package/misc/apps/RAG/webpack.config.js +0 -43
- package/misc/apps/README.md +0 -1
- package/misc/queries/analyze_catfacts.cql +0 -75
- package/misc/queries/azure_openai_completions.cql +0 -13
- package/misc/queries/azure_openai_models.cql +0 -9
- package/misc/queries/mock_pipeline.cql +0 -84
- package/misc/queries/openai_completions.cql +0 -15
- package/misc/queries/openai_models.cql +0 -13
- package/misc/queries/test.cql +0 -6
- package/misc/queries/tool_inference.cql +0 -24
- package/misc/queries/wisdom.cql +0 -6
- package/misc/queries/wisdom_letter_histogram.cql +0 -8
- package/src/compute/flowquery.ts +0 -46
- package/src/compute/runner.ts +0 -66
- package/src/extensibility.ts +0 -45
- package/src/graph/data.ts +0 -130
- package/src/graph/database.ts +0 -143
- package/src/graph/hops.ts +0 -22
- package/src/graph/node.ts +0 -122
- package/src/graph/node_data.ts +0 -18
- package/src/graph/node_reference.ts +0 -38
- package/src/graph/pattern.ts +0 -110
- package/src/graph/pattern_expression.ts +0 -48
- package/src/graph/patterns.ts +0 -36
- package/src/graph/physical_node.ts +0 -23
- package/src/graph/physical_relationship.ts +0 -23
- package/src/graph/relationship.ts +0 -167
- package/src/graph/relationship_data.ts +0 -31
- package/src/graph/relationship_match_collector.ts +0 -64
- package/src/graph/relationship_reference.ts +0 -25
- package/src/index.browser.ts +0 -46
- package/src/index.node.ts +0 -55
- package/src/index.ts +0 -12
- package/src/io/command_line.ts +0 -74
- package/src/parsing/alias.ts +0 -23
- package/src/parsing/alias_option.ts +0 -5
- package/src/parsing/ast_node.ts +0 -153
- package/src/parsing/base_parser.ts +0 -98
- package/src/parsing/components/csv.ts +0 -9
- package/src/parsing/components/from.ts +0 -12
- package/src/parsing/components/headers.ts +0 -12
- package/src/parsing/components/json.ts +0 -9
- package/src/parsing/components/null.ts +0 -9
- package/src/parsing/components/post.ts +0 -9
- package/src/parsing/components/text.ts +0 -9
- package/src/parsing/context.ts +0 -54
- package/src/parsing/data_structures/associative_array.ts +0 -43
- package/src/parsing/data_structures/json_array.ts +0 -31
- package/src/parsing/data_structures/key_value_pair.ts +0 -37
- package/src/parsing/data_structures/lookup.ts +0 -44
- package/src/parsing/data_structures/range_lookup.ts +0 -36
- package/src/parsing/expressions/boolean.ts +0 -21
- package/src/parsing/expressions/expression.ts +0 -150
- package/src/parsing/expressions/expression_map.ts +0 -22
- package/src/parsing/expressions/f_string.ts +0 -26
- package/src/parsing/expressions/identifier.ts +0 -22
- package/src/parsing/expressions/number.ts +0 -40
- package/src/parsing/expressions/operator.ts +0 -354
- package/src/parsing/expressions/reference.ts +0 -45
- package/src/parsing/expressions/string.ts +0 -34
- package/src/parsing/functions/aggregate_function.ts +0 -58
- package/src/parsing/functions/async_function.ts +0 -64
- package/src/parsing/functions/avg.ts +0 -47
- package/src/parsing/functions/coalesce.ts +0 -49
- package/src/parsing/functions/collect.ts +0 -54
- package/src/parsing/functions/count.ts +0 -54
- package/src/parsing/functions/date.ts +0 -63
- package/src/parsing/functions/datetime.ts +0 -63
- package/src/parsing/functions/duration.ts +0 -143
- package/src/parsing/functions/element_id.ts +0 -51
- package/src/parsing/functions/function.ts +0 -60
- package/src/parsing/functions/function_factory.ts +0 -195
- package/src/parsing/functions/function_metadata.ts +0 -217
- package/src/parsing/functions/functions.ts +0 -70
- package/src/parsing/functions/head.ts +0 -42
- package/src/parsing/functions/id.ts +0 -51
- package/src/parsing/functions/join.ts +0 -40
- package/src/parsing/functions/keys.ts +0 -29
- package/src/parsing/functions/last.ts +0 -42
- package/src/parsing/functions/localdatetime.ts +0 -63
- package/src/parsing/functions/localtime.ts +0 -58
- package/src/parsing/functions/max.ts +0 -37
- package/src/parsing/functions/min.ts +0 -37
- package/src/parsing/functions/nodes.ts +0 -54
- package/src/parsing/functions/predicate_function.ts +0 -48
- package/src/parsing/functions/predicate_sum.ts +0 -47
- package/src/parsing/functions/properties.ts +0 -56
- package/src/parsing/functions/rand.ts +0 -21
- package/src/parsing/functions/range.ts +0 -37
- package/src/parsing/functions/reducer_element.ts +0 -10
- package/src/parsing/functions/relationships.ts +0 -52
- package/src/parsing/functions/replace.ts +0 -38
- package/src/parsing/functions/round.ts +0 -28
- package/src/parsing/functions/schema.ts +0 -39
- package/src/parsing/functions/size.ts +0 -28
- package/src/parsing/functions/split.ts +0 -45
- package/src/parsing/functions/string_distance.ts +0 -83
- package/src/parsing/functions/stringify.ts +0 -37
- package/src/parsing/functions/substring.ts +0 -68
- package/src/parsing/functions/sum.ts +0 -41
- package/src/parsing/functions/tail.ts +0 -39
- package/src/parsing/functions/temporal_utils.ts +0 -180
- package/src/parsing/functions/time.ts +0 -58
- package/src/parsing/functions/timestamp.ts +0 -37
- package/src/parsing/functions/to_float.ts +0 -50
- package/src/parsing/functions/to_integer.ts +0 -50
- package/src/parsing/functions/to_json.ts +0 -28
- package/src/parsing/functions/to_lower.ts +0 -28
- package/src/parsing/functions/to_string.ts +0 -32
- package/src/parsing/functions/trim.ts +0 -28
- package/src/parsing/functions/type.ts +0 -39
- package/src/parsing/functions/value_holder.ts +0 -13
- package/src/parsing/logic/case.ts +0 -26
- package/src/parsing/logic/else.ts +0 -12
- package/src/parsing/logic/end.ts +0 -9
- package/src/parsing/logic/then.ts +0 -12
- package/src/parsing/logic/when.ts +0 -12
- package/src/parsing/operations/aggregated_return.ts +0 -22
- package/src/parsing/operations/aggregated_with.ts +0 -18
- package/src/parsing/operations/call.ts +0 -69
- package/src/parsing/operations/create_node.ts +0 -39
- package/src/parsing/operations/create_relationship.ts +0 -38
- package/src/parsing/operations/delete_node.ts +0 -33
- package/src/parsing/operations/delete_relationship.ts +0 -32
- package/src/parsing/operations/group_by.ts +0 -137
- package/src/parsing/operations/limit.ts +0 -31
- package/src/parsing/operations/load.ts +0 -146
- package/src/parsing/operations/match.ts +0 -54
- package/src/parsing/operations/operation.ts +0 -69
- package/src/parsing/operations/order_by.ts +0 -126
- package/src/parsing/operations/projection.ts +0 -18
- package/src/parsing/operations/return.ts +0 -76
- package/src/parsing/operations/union.ts +0 -114
- package/src/parsing/operations/union_all.ts +0 -16
- package/src/parsing/operations/unwind.ts +0 -36
- package/src/parsing/operations/where.ts +0 -42
- package/src/parsing/operations/with.ts +0 -20
- package/src/parsing/parser.ts +0 -1641
- package/src/parsing/parser_state.ts +0 -25
- package/src/parsing/token_to_node.ts +0 -114
- package/src/tokenization/keyword.ts +0 -50
- package/src/tokenization/operator.ts +0 -25
- package/src/tokenization/string_walker.ts +0 -197
- package/src/tokenization/symbol.ts +0 -15
- package/src/tokenization/token.ts +0 -764
- package/src/tokenization/token_mapper.ts +0 -53
- package/src/tokenization/token_type.ts +0 -16
- package/src/tokenization/tokenizer.ts +0 -250
- package/src/tokenization/trie.ts +0 -117
- package/src/utils/object_utils.ts +0 -17
- package/src/utils/string_utils.ts +0 -114
- package/tests/compute/runner.test.ts +0 -4559
- package/tests/extensibility.test.ts +0 -643
- package/tests/graph/create.test.ts +0 -36
- package/tests/graph/data.test.ts +0 -58
- package/tests/graph/match.test.ts +0 -29
- package/tests/parsing/context.test.ts +0 -27
- package/tests/parsing/expression.test.ts +0 -303
- package/tests/parsing/parser.test.ts +0 -1327
- package/tests/tokenization/token_mapper.test.ts +0 -47
- package/tests/tokenization/tokenizer.test.ts +0 -191
- package/tests/tokenization/trie.test.ts +0 -20
- package/tsconfig.json +0 -19
- package/typedoc.json +0 -16
- package/vscode-settings.json.recommended +0 -16
- package/webpack.config.js +0 -26
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
"""Graph relationship representation for FlowQuery."""
|
|
2
|
-
|
|
3
|
-
from __future__ import annotations
|
|
4
|
-
|
|
5
|
-
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
|
|
6
|
-
|
|
7
|
-
from ..parsing.ast_node import ASTNode
|
|
8
|
-
from .hops import Hops
|
|
9
|
-
from .relationship_data import RelationshipData
|
|
10
|
-
from .relationship_match_collector import RelationshipMatchCollector, RelationshipMatchRecord
|
|
11
|
-
|
|
12
|
-
if TYPE_CHECKING:
|
|
13
|
-
from .node import Node
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
class Relationship(ASTNode):
|
|
17
|
-
"""Represents a relationship in a graph pattern."""
|
|
18
|
-
|
|
19
|
-
def __init__(self) -> None:
|
|
20
|
-
super().__init__()
|
|
21
|
-
self._identifier: Optional[str] = None
|
|
22
|
-
self._types: List[str] = []
|
|
23
|
-
self._hops: Hops = Hops()
|
|
24
|
-
self._source: Optional['Node'] = None
|
|
25
|
-
self._target: Optional['Node'] = None
|
|
26
|
-
self._direction: str = "right"
|
|
27
|
-
self._data: Optional['RelationshipData'] = None
|
|
28
|
-
self._value: Optional[Union[RelationshipMatchRecord, List[RelationshipMatchRecord]]] = None
|
|
29
|
-
self._matches: RelationshipMatchCollector = RelationshipMatchCollector()
|
|
30
|
-
self._properties: Dict[str, Any] = {}
|
|
31
|
-
|
|
32
|
-
@property
|
|
33
|
-
def identifier(self) -> Optional[str]:
|
|
34
|
-
return self._identifier
|
|
35
|
-
|
|
36
|
-
@identifier.setter
|
|
37
|
-
def identifier(self, value: str) -> None:
|
|
38
|
-
self._identifier = value
|
|
39
|
-
|
|
40
|
-
@property
|
|
41
|
-
def type(self) -> Optional[str]:
|
|
42
|
-
return self._types[0] if self._types else None
|
|
43
|
-
|
|
44
|
-
@type.setter
|
|
45
|
-
def type(self, value: str) -> None:
|
|
46
|
-
self._types = [value]
|
|
47
|
-
|
|
48
|
-
@property
|
|
49
|
-
def types(self) -> List[str]:
|
|
50
|
-
return self._types
|
|
51
|
-
|
|
52
|
-
@types.setter
|
|
53
|
-
def types(self, value: List[str]) -> None:
|
|
54
|
-
self._types = value
|
|
55
|
-
|
|
56
|
-
@property
|
|
57
|
-
def hops(self) -> Hops:
|
|
58
|
-
return self._hops
|
|
59
|
-
|
|
60
|
-
@hops.setter
|
|
61
|
-
def hops(self, value: Hops) -> None:
|
|
62
|
-
self._hops = value
|
|
63
|
-
|
|
64
|
-
@property
|
|
65
|
-
def properties(self) -> Dict[str, Any]:
|
|
66
|
-
return self._properties
|
|
67
|
-
|
|
68
|
-
@properties.setter
|
|
69
|
-
def properties(self, value: Dict[str, Any]) -> None:
|
|
70
|
-
self._properties = value
|
|
71
|
-
|
|
72
|
-
def _matches_properties(self, hop: int = 0) -> bool:
|
|
73
|
-
"""Check if current record matches all constraint properties."""
|
|
74
|
-
if not self._properties:
|
|
75
|
-
return True
|
|
76
|
-
if self._data is None:
|
|
77
|
-
return True
|
|
78
|
-
for key, expression in self._properties.items():
|
|
79
|
-
record = self._data.current(hop)
|
|
80
|
-
if record is None:
|
|
81
|
-
raise ValueError("No current relationship data available")
|
|
82
|
-
if key not in record:
|
|
83
|
-
raise ValueError("Relationship does not have property")
|
|
84
|
-
return bool(record[key] == expression.value())
|
|
85
|
-
return True
|
|
86
|
-
|
|
87
|
-
@property
|
|
88
|
-
def source(self) -> Optional['Node']:
|
|
89
|
-
return self._source
|
|
90
|
-
|
|
91
|
-
@source.setter
|
|
92
|
-
def source(self, value: 'Node') -> None:
|
|
93
|
-
self._source = value
|
|
94
|
-
|
|
95
|
-
@property
|
|
96
|
-
def target(self) -> Optional['Node']:
|
|
97
|
-
return self._target
|
|
98
|
-
|
|
99
|
-
@target.setter
|
|
100
|
-
def target(self, value: 'Node') -> None:
|
|
101
|
-
self._target = value
|
|
102
|
-
|
|
103
|
-
@property
|
|
104
|
-
def direction(self) -> str:
|
|
105
|
-
return self._direction
|
|
106
|
-
|
|
107
|
-
@direction.setter
|
|
108
|
-
def direction(self, value: str) -> None:
|
|
109
|
-
self._direction = value
|
|
110
|
-
|
|
111
|
-
# Keep start/end aliases for backward compatibility
|
|
112
|
-
@property
|
|
113
|
-
def start(self) -> Optional['Node']:
|
|
114
|
-
return self._source
|
|
115
|
-
|
|
116
|
-
@start.setter
|
|
117
|
-
def start(self, value: 'Node') -> None:
|
|
118
|
-
self._source = value
|
|
119
|
-
|
|
120
|
-
@property
|
|
121
|
-
def end(self) -> Optional['Node']:
|
|
122
|
-
return self._target
|
|
123
|
-
|
|
124
|
-
@end.setter
|
|
125
|
-
def end(self, value: 'Node') -> None:
|
|
126
|
-
self._target = value
|
|
127
|
-
|
|
128
|
-
def set_data(self, data: Optional['RelationshipData']) -> None:
|
|
129
|
-
self._data = data
|
|
130
|
-
|
|
131
|
-
def get_data(self) -> Optional['RelationshipData']:
|
|
132
|
-
return self._data
|
|
133
|
-
|
|
134
|
-
def set_value(self, relationship: 'Relationship', traversal_id: str = "") -> None:
|
|
135
|
-
"""Set value by pushing match to collector."""
|
|
136
|
-
self._matches.push(relationship, traversal_id)
|
|
137
|
-
self._value = self._matches.value()
|
|
138
|
-
|
|
139
|
-
def value(self) -> Optional[Union[RelationshipMatchRecord, List[RelationshipMatchRecord]]]:
|
|
140
|
-
return self._value
|
|
141
|
-
|
|
142
|
-
@property
|
|
143
|
-
def matches(self) -> List[RelationshipMatchRecord]:
|
|
144
|
-
return self._matches.matches
|
|
145
|
-
|
|
146
|
-
def set_end_node(self, node: 'Node') -> None:
|
|
147
|
-
"""Set the end node for the current match."""
|
|
148
|
-
self._matches.end_node = node
|
|
149
|
-
|
|
150
|
-
def _left_id_or_right_id(self) -> str:
|
|
151
|
-
return "left_id" if self._direction == "left" else "right_id"
|
|
152
|
-
|
|
153
|
-
async def find(self, left_id: str, hop: int = 0) -> None:
|
|
154
|
-
"""Find relationships starting from the given node ID."""
|
|
155
|
-
# Save original source node
|
|
156
|
-
original = self._source
|
|
157
|
-
if hop > 0:
|
|
158
|
-
# For hops greater than 0, the source becomes the target of the previous hop
|
|
159
|
-
self._source = self._target
|
|
160
|
-
if hop == 0:
|
|
161
|
-
if self._data:
|
|
162
|
-
self._data.reset()
|
|
163
|
-
|
|
164
|
-
# Handle zero-hop case: when min is 0 on a variable-length relationship,
|
|
165
|
-
# match source node as target (no traversal)
|
|
166
|
-
if self._hops and self._hops.multi() and self._hops.min == 0 and self._target:
|
|
167
|
-
# For zero-hop, target finds the same node as source (left_id)
|
|
168
|
-
# No relationship match is pushed since no edge is traversed
|
|
169
|
-
await self._target.find(left_id, hop)
|
|
170
|
-
|
|
171
|
-
while self._data and self._data.find(left_id, hop, self._direction):
|
|
172
|
-
data = self._data.current(hop)
|
|
173
|
-
if data is None:
|
|
174
|
-
continue
|
|
175
|
-
id = data[self._left_id_or_right_id()]
|
|
176
|
-
if hop + 1 >= self._hops.min:
|
|
177
|
-
self.set_value(self, left_id)
|
|
178
|
-
if not self._matches_properties(hop):
|
|
179
|
-
continue
|
|
180
|
-
if self._target:
|
|
181
|
-
await self._target.find(id, hop)
|
|
182
|
-
if hop + 1 < self._hops.max:
|
|
183
|
-
if self._matches.is_circular(id):
|
|
184
|
-
self._matches.pop()
|
|
185
|
-
continue
|
|
186
|
-
await self.find(id, hop + 1)
|
|
187
|
-
self._matches.pop()
|
|
188
|
-
else:
|
|
189
|
-
# Below minimum hops: traverse the edge without yielding a match
|
|
190
|
-
await self.find(id, hop + 1)
|
|
191
|
-
|
|
192
|
-
# Restore original source node
|
|
193
|
-
self._source = original
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"""Relationship data class for FlowQuery."""
|
|
2
|
-
|
|
3
|
-
from typing import Any, Dict, List, Optional, TypedDict
|
|
4
|
-
|
|
5
|
-
from .data import Data
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class RelationshipRecord(TypedDict, total=False):
|
|
9
|
-
"""Represents a relationship record from the database."""
|
|
10
|
-
left_id: str
|
|
11
|
-
right_id: str
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
class RelationshipData(Data):
|
|
15
|
-
"""Relationship data class extending Data with left_id and right_id indexing."""
|
|
16
|
-
|
|
17
|
-
def __init__(self, records: Optional[List[Dict[str, Any]]] = None):
|
|
18
|
-
super().__init__(records)
|
|
19
|
-
self._build_index("left_id")
|
|
20
|
-
self._build_index("right_id")
|
|
21
|
-
|
|
22
|
-
def find(self, id: str, hop: int = 0, direction: str = "right") -> bool:
|
|
23
|
-
"""Find a relationship by node ID and direction."""
|
|
24
|
-
key = "right_id" if direction == "left" else "left_id"
|
|
25
|
-
return self._find(id, hop, key)
|
|
26
|
-
|
|
27
|
-
def properties(self) -> Optional[Dict[str, Any]]:
|
|
28
|
-
"""Get properties of current relationship, excluding left_id, right_id, and _type."""
|
|
29
|
-
current = self.current()
|
|
30
|
-
if current:
|
|
31
|
-
props = dict(current)
|
|
32
|
-
props.pop("left_id", None)
|
|
33
|
-
props.pop("right_id", None)
|
|
34
|
-
props.pop("_type", None)
|
|
35
|
-
return props
|
|
36
|
-
return None
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"""Collector for relationship match records."""
|
|
2
|
-
|
|
3
|
-
from __future__ import annotations
|
|
4
|
-
|
|
5
|
-
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
|
|
6
|
-
|
|
7
|
-
if TYPE_CHECKING:
|
|
8
|
-
from .node import Node
|
|
9
|
-
from .relationship import Relationship
|
|
10
|
-
|
|
11
|
-
# A relationship match record is a plain dict with known keys (type,
|
|
12
|
-
# startNode, endNode, properties) plus any extra relationship-property
|
|
13
|
-
# keys spread at the top level – mirroring the TypeScript version that
|
|
14
|
-
# uses an index signature ``[key: string]: any``.
|
|
15
|
-
RelationshipMatchRecord = Dict[str, Any]
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
class RelationshipMatchCollector:
|
|
19
|
-
"""Collects relationship matches during graph traversal."""
|
|
20
|
-
|
|
21
|
-
def __init__(self) -> None:
|
|
22
|
-
self._matches: List[RelationshipMatchRecord] = []
|
|
23
|
-
self._node_ids: List[str] = []
|
|
24
|
-
|
|
25
|
-
def push(self, relationship: 'Relationship', traversal_id: str = "") -> RelationshipMatchRecord:
|
|
26
|
-
"""Push a new match onto the collector."""
|
|
27
|
-
start_node_value = relationship.source.value() if relationship.source else None
|
|
28
|
-
rel_data = relationship.get_data()
|
|
29
|
-
current_record = rel_data.current() if rel_data else None
|
|
30
|
-
default_type = relationship.type or ""
|
|
31
|
-
if current_record and isinstance(current_record, dict):
|
|
32
|
-
actual_type = current_record.get('_type', default_type)
|
|
33
|
-
else:
|
|
34
|
-
actual_type = default_type
|
|
35
|
-
rel_props: Dict[str, Any] = (rel_data.properties() or {}) if rel_data else {}
|
|
36
|
-
match: RelationshipMatchRecord = {
|
|
37
|
-
**rel_props,
|
|
38
|
-
"type": actual_type,
|
|
39
|
-
"startNode": start_node_value or {},
|
|
40
|
-
"endNode": None,
|
|
41
|
-
"properties": rel_props,
|
|
42
|
-
}
|
|
43
|
-
self._matches.append(match)
|
|
44
|
-
self._node_ids.append(traversal_id)
|
|
45
|
-
return match
|
|
46
|
-
|
|
47
|
-
@property
|
|
48
|
-
def end_node(self) -> Any:
|
|
49
|
-
"""Get the end node of the last match."""
|
|
50
|
-
if self._matches:
|
|
51
|
-
return self._matches[-1].get("endNode")
|
|
52
|
-
return None
|
|
53
|
-
|
|
54
|
-
@end_node.setter
|
|
55
|
-
def end_node(self, node: 'Node') -> None:
|
|
56
|
-
"""Set the end node of the last match."""
|
|
57
|
-
if self._matches:
|
|
58
|
-
node_value = node.value()
|
|
59
|
-
self._matches[-1]["endNode"] = node_value if node_value else None
|
|
60
|
-
|
|
61
|
-
def pop(self) -> Optional[RelationshipMatchRecord]:
|
|
62
|
-
"""Pop the last match from the collector."""
|
|
63
|
-
if self._node_ids:
|
|
64
|
-
self._node_ids.pop()
|
|
65
|
-
if self._matches:
|
|
66
|
-
return self._matches.pop()
|
|
67
|
-
return None
|
|
68
|
-
|
|
69
|
-
def value(self) -> Optional[Union[RelationshipMatchRecord, List[RelationshipMatchRecord]]]:
|
|
70
|
-
"""Get the current value(s)."""
|
|
71
|
-
if len(self._matches) == 0:
|
|
72
|
-
return None
|
|
73
|
-
elif len(self._matches) == 1:
|
|
74
|
-
return self._matches[0]
|
|
75
|
-
else:
|
|
76
|
-
return self._matches
|
|
77
|
-
|
|
78
|
-
@property
|
|
79
|
-
def matches(self) -> List[RelationshipMatchRecord]:
|
|
80
|
-
"""Get all matches."""
|
|
81
|
-
return self._matches
|
|
82
|
-
|
|
83
|
-
def is_circular(self, next_id: str = "") -> bool:
|
|
84
|
-
"""Check if traversing to the given node id would form a cycle."""
|
|
85
|
-
return next_id in self._node_ids
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
from typing import Any, Optional
|
|
2
|
-
|
|
3
|
-
from ..parsing.ast_node import ASTNode
|
|
4
|
-
from .relationship import Relationship
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class RelationshipReference(Relationship):
|
|
8
|
-
"""Represents a reference to an existing relationship variable."""
|
|
9
|
-
|
|
10
|
-
def __init__(self, relationship: Relationship, referred: ASTNode) -> None:
|
|
11
|
-
super().__init__()
|
|
12
|
-
self._referred = referred
|
|
13
|
-
if relationship.types:
|
|
14
|
-
self.types = relationship.types
|
|
15
|
-
|
|
16
|
-
@property
|
|
17
|
-
def referred(self) -> ASTNode:
|
|
18
|
-
return self._referred
|
|
19
|
-
|
|
20
|
-
def value(self) -> Optional[Any]:
|
|
21
|
-
return self._referred.value() if self._referred else None
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
"""Interactive command-line interface for FlowQuery."""
|
|
2
|
-
|
|
3
|
-
import argparse
|
|
4
|
-
import asyncio
|
|
5
|
-
|
|
6
|
-
from ..compute.runner import Runner
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class CommandLine:
|
|
10
|
-
"""Interactive command-line interface for FlowQuery.
|
|
11
|
-
|
|
12
|
-
Provides a REPL (Read-Eval-Print Loop) for executing FlowQuery statements
|
|
13
|
-
and displaying results.
|
|
14
|
-
|
|
15
|
-
Example:
|
|
16
|
-
cli = CommandLine()
|
|
17
|
-
cli.loop() # Starts interactive mode
|
|
18
|
-
|
|
19
|
-
# Or execute a single query:
|
|
20
|
-
cli.execute("load json from 'https://example.com/data' as d return d")
|
|
21
|
-
"""
|
|
22
|
-
|
|
23
|
-
def execute(self, query: str) -> None:
|
|
24
|
-
"""Execute a single FlowQuery statement and print results.
|
|
25
|
-
|
|
26
|
-
Args:
|
|
27
|
-
query: The FlowQuery statement to execute.
|
|
28
|
-
"""
|
|
29
|
-
# Remove the termination semicolon if present
|
|
30
|
-
query = query.strip().rstrip(";")
|
|
31
|
-
|
|
32
|
-
try:
|
|
33
|
-
runner = Runner(query)
|
|
34
|
-
asyncio.run(self._execute(runner))
|
|
35
|
-
except Exception as e:
|
|
36
|
-
print(f"Error: {e}")
|
|
37
|
-
|
|
38
|
-
def loop(self) -> None:
|
|
39
|
-
"""Starts the interactive command loop.
|
|
40
|
-
|
|
41
|
-
Prompts the user for FlowQuery statements, executes them, and displays results.
|
|
42
|
-
Type "exit" to quit the loop. End multi-line queries with ";".
|
|
43
|
-
"""
|
|
44
|
-
print('Welcome to FlowQuery! Type "exit" to quit.')
|
|
45
|
-
print('End queries with ";" to execute. Multi-line input supported.')
|
|
46
|
-
|
|
47
|
-
while True:
|
|
48
|
-
try:
|
|
49
|
-
lines = []
|
|
50
|
-
prompt = "> "
|
|
51
|
-
while True:
|
|
52
|
-
line = input(prompt)
|
|
53
|
-
if line.strip() == "exit":
|
|
54
|
-
print("Exiting FlowQuery.")
|
|
55
|
-
return
|
|
56
|
-
lines.append(line)
|
|
57
|
-
user_input = "\n".join(lines)
|
|
58
|
-
if user_input.strip().endswith(";"):
|
|
59
|
-
break
|
|
60
|
-
prompt = "... "
|
|
61
|
-
except EOFError:
|
|
62
|
-
break
|
|
63
|
-
|
|
64
|
-
if user_input.strip() == "":
|
|
65
|
-
continue
|
|
66
|
-
|
|
67
|
-
# Remove the termination semicolon before sending to the engine
|
|
68
|
-
user_input = user_input.strip().rstrip(";")
|
|
69
|
-
|
|
70
|
-
try:
|
|
71
|
-
runner = Runner(user_input)
|
|
72
|
-
asyncio.run(self._execute(runner))
|
|
73
|
-
except Exception as e:
|
|
74
|
-
print(f"Error: {e}")
|
|
75
|
-
|
|
76
|
-
print("Exiting FlowQuery.")
|
|
77
|
-
|
|
78
|
-
async def _execute(self, runner: Runner) -> None:
|
|
79
|
-
await runner.run()
|
|
80
|
-
print(runner.results)
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
def main() -> None:
|
|
84
|
-
"""Entry point for the flowquery CLI command.
|
|
85
|
-
|
|
86
|
-
Usage:
|
|
87
|
-
flowquery # Start interactive mode
|
|
88
|
-
flowquery -c "query" # Execute a single query
|
|
89
|
-
flowquery --command "query"
|
|
90
|
-
"""
|
|
91
|
-
parser = argparse.ArgumentParser(
|
|
92
|
-
description="FlowQuery - A declarative query language for data processing pipelines",
|
|
93
|
-
prog="flowquery"
|
|
94
|
-
)
|
|
95
|
-
parser.add_argument(
|
|
96
|
-
"-c", "--command",
|
|
97
|
-
type=str,
|
|
98
|
-
metavar="QUERY",
|
|
99
|
-
help="Execute a FlowQuery statement and exit"
|
|
100
|
-
)
|
|
101
|
-
|
|
102
|
-
args = parser.parse_args()
|
|
103
|
-
cli = CommandLine()
|
|
104
|
-
|
|
105
|
-
if args.command:
|
|
106
|
-
cli.execute(args.command)
|
|
107
|
-
else:
|
|
108
|
-
cli.loop()
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"""Parsing module for FlowQuery."""
|
|
2
|
-
|
|
3
|
-
from .alias import Alias
|
|
4
|
-
from .alias_option import AliasOption
|
|
5
|
-
from .ast_node import ASTNode
|
|
6
|
-
from .base_parser import BaseParser
|
|
7
|
-
from .context import Context
|
|
8
|
-
from .parser import Parser
|
|
9
|
-
|
|
10
|
-
__all__ = [
|
|
11
|
-
"ASTNode",
|
|
12
|
-
"Context",
|
|
13
|
-
"Alias",
|
|
14
|
-
"AliasOption",
|
|
15
|
-
"BaseParser",
|
|
16
|
-
"Parser",
|
|
17
|
-
]
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"""Alias node for FlowQuery AST."""
|
|
2
|
-
|
|
3
|
-
from .ast_node import ASTNode
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class Alias(ASTNode):
|
|
7
|
-
"""Represents an alias in the FlowQuery AST."""
|
|
8
|
-
|
|
9
|
-
def __init__(self, alias: str):
|
|
10
|
-
super().__init__()
|
|
11
|
-
self._alias = alias
|
|
12
|
-
|
|
13
|
-
def __str__(self) -> str:
|
|
14
|
-
return f"Alias ({self._alias})"
|
|
15
|
-
|
|
16
|
-
def get_alias(self) -> str:
|
|
17
|
-
return self._alias
|
|
18
|
-
|
|
19
|
-
def value(self) -> str:
|
|
20
|
-
return self._alias
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
"""Represents a node in the Abstract Syntax Tree (AST)."""
|
|
2
|
-
|
|
3
|
-
from __future__ import annotations
|
|
4
|
-
|
|
5
|
-
from typing import Any, Generator, List, Optional
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class ASTNode:
|
|
9
|
-
"""Represents a node in the Abstract Syntax Tree (AST).
|
|
10
|
-
|
|
11
|
-
The AST is a tree representation of the parsed FlowQuery statement structure.
|
|
12
|
-
Each node can have children and maintains a reference to its parent.
|
|
13
|
-
|
|
14
|
-
Example:
|
|
15
|
-
root = ASTNode()
|
|
16
|
-
child = ASTNode()
|
|
17
|
-
root.add_child(child)
|
|
18
|
-
"""
|
|
19
|
-
|
|
20
|
-
def __init__(self) -> None:
|
|
21
|
-
self._parent: Optional[ASTNode] = None
|
|
22
|
-
self.children: List[ASTNode] = []
|
|
23
|
-
|
|
24
|
-
def add_child(self, child: ASTNode) -> None:
|
|
25
|
-
"""Adds a child node to this node and sets the child's parent reference.
|
|
26
|
-
|
|
27
|
-
Args:
|
|
28
|
-
child: The child node to add
|
|
29
|
-
"""
|
|
30
|
-
child._parent = self
|
|
31
|
-
self.children.append(child)
|
|
32
|
-
|
|
33
|
-
def first_child(self) -> ASTNode:
|
|
34
|
-
"""Returns the first child node.
|
|
35
|
-
|
|
36
|
-
Returns:
|
|
37
|
-
The first child node
|
|
38
|
-
|
|
39
|
-
Raises:
|
|
40
|
-
ValueError: If the node has no children
|
|
41
|
-
"""
|
|
42
|
-
if len(self.children) == 0:
|
|
43
|
-
raise ValueError('Expected child')
|
|
44
|
-
return self.children[0]
|
|
45
|
-
|
|
46
|
-
def last_child(self) -> ASTNode:
|
|
47
|
-
"""Returns the last child node.
|
|
48
|
-
|
|
49
|
-
Returns:
|
|
50
|
-
The last child node
|
|
51
|
-
|
|
52
|
-
Raises:
|
|
53
|
-
ValueError: If the node has no children
|
|
54
|
-
"""
|
|
55
|
-
if len(self.children) == 0:
|
|
56
|
-
raise ValueError('Expected child')
|
|
57
|
-
return self.children[-1]
|
|
58
|
-
|
|
59
|
-
def get_children(self) -> List[ASTNode]:
|
|
60
|
-
"""Returns all child nodes.
|
|
61
|
-
|
|
62
|
-
Returns:
|
|
63
|
-
Array of child nodes
|
|
64
|
-
"""
|
|
65
|
-
return self.children
|
|
66
|
-
|
|
67
|
-
def child_count(self) -> int:
|
|
68
|
-
"""Returns the number of child nodes.
|
|
69
|
-
|
|
70
|
-
Returns:
|
|
71
|
-
The count of children
|
|
72
|
-
"""
|
|
73
|
-
return len(self.children)
|
|
74
|
-
|
|
75
|
-
def value(self) -> Any:
|
|
76
|
-
"""Returns the value of this node. Override in subclasses to provide specific values.
|
|
77
|
-
|
|
78
|
-
Returns:
|
|
79
|
-
The node's value, or None if not applicable
|
|
80
|
-
"""
|
|
81
|
-
return None
|
|
82
|
-
|
|
83
|
-
def is_operator(self) -> bool:
|
|
84
|
-
"""Checks if this node represents an operator.
|
|
85
|
-
|
|
86
|
-
Returns:
|
|
87
|
-
True if this is an operator node, False otherwise
|
|
88
|
-
"""
|
|
89
|
-
return False
|
|
90
|
-
|
|
91
|
-
def is_operand(self) -> bool:
|
|
92
|
-
"""Checks if this node represents an operand (the opposite of an operator).
|
|
93
|
-
|
|
94
|
-
Returns:
|
|
95
|
-
True if this is an operand node, False otherwise
|
|
96
|
-
"""
|
|
97
|
-
return not self.is_operator()
|
|
98
|
-
|
|
99
|
-
@property
|
|
100
|
-
def precedence(self) -> int:
|
|
101
|
-
"""Gets the operator precedence for this node. Higher values indicate higher precedence.
|
|
102
|
-
|
|
103
|
-
Returns:
|
|
104
|
-
The precedence value (0 for non-operators)
|
|
105
|
-
"""
|
|
106
|
-
return 0
|
|
107
|
-
|
|
108
|
-
@property
|
|
109
|
-
def left_associative(self) -> bool:
|
|
110
|
-
"""Indicates whether this operator is left-associative.
|
|
111
|
-
|
|
112
|
-
Returns:
|
|
113
|
-
True if left-associative, False otherwise
|
|
114
|
-
"""
|
|
115
|
-
return False
|
|
116
|
-
|
|
117
|
-
def print(self) -> str:
|
|
118
|
-
"""Prints a string representation of the AST tree starting from this node.
|
|
119
|
-
|
|
120
|
-
Returns:
|
|
121
|
-
A formatted string showing the tree structure
|
|
122
|
-
"""
|
|
123
|
-
return '\n'.join(self._print(0))
|
|
124
|
-
|
|
125
|
-
def _print(self, indent: int) -> Generator[str, None, None]:
|
|
126
|
-
"""Generator function for recursively printing the tree structure.
|
|
127
|
-
|
|
128
|
-
Args:
|
|
129
|
-
indent: The current indentation level
|
|
130
|
-
|
|
131
|
-
Yields:
|
|
132
|
-
Lines representing each node in the tree
|
|
133
|
-
"""
|
|
134
|
-
if indent == 0:
|
|
135
|
-
yield self.__class__.__name__
|
|
136
|
-
elif indent > 0:
|
|
137
|
-
yield '-' * indent + f' {self}'
|
|
138
|
-
for child in self.children:
|
|
139
|
-
yield from child._print(indent + 1)
|
|
140
|
-
|
|
141
|
-
def __str__(self) -> str:
|
|
142
|
-
"""Returns a string representation of this node. Override in subclasses for custom formatting.
|
|
143
|
-
|
|
144
|
-
Returns:
|
|
145
|
-
The string representation
|
|
146
|
-
"""
|
|
147
|
-
return self.__class__.__name__
|