@eagleoutice/flowr 2.0.25 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/benchmark/slicer.js +2 -1
- package/benchmark/stats/print.js +3 -4
- package/benchmark/stats/size-of.js +9 -7
- package/benchmark/summarizer/first-phase/input.d.ts +0 -1
- package/benchmark/summarizer/first-phase/input.js +2 -3
- package/benchmark/summarizer/first-phase/process.js +7 -7
- package/benchmark/summarizer/second-phase/graph.js +1 -2
- package/benchmark/summarizer/second-phase/process.d.ts +0 -1
- package/benchmark/summarizer/second-phase/process.js +4 -5
- package/benchmark/summarizer/summarizer.js +7 -1
- package/cli/benchmark-app.js +6 -1
- package/cli/common/features.js +2 -3
- package/cli/common/script.js +2 -3
- package/cli/common/scripts-info.d.ts +69 -1
- package/cli/common/scripts-info.js +6 -6
- package/cli/flowr-main-options.d.ts +4 -0
- package/cli/flowr-main-options.js +88 -0
- package/cli/flowr.d.ts +3 -3
- package/cli/flowr.js +22 -31
- package/cli/repl/commands/{cfg.d.ts → repl-cfg.d.ts} +1 -1
- package/cli/repl/commands/{cfg.js → repl-cfg.js} +3 -3
- package/cli/repl/commands/{commands.d.ts → repl-commands.d.ts} +3 -1
- package/cli/repl/commands/{commands.js → repl-commands.js} +56 -35
- package/cli/repl/commands/{dataflow.d.ts → repl-dataflow.d.ts} +1 -1
- package/cli/repl/commands/{dataflow.js → repl-dataflow.js} +2 -2
- package/cli/repl/commands/{execute.d.ts → repl-execute.d.ts} +1 -1
- package/cli/repl/commands/{execute.js → repl-execute.js} +3 -3
- package/cli/repl/commands/repl-lineage.d.ts +15 -0
- package/cli/repl/commands/{lineage.js → repl-lineage.js} +14 -12
- package/cli/repl/commands/{main.js → repl-main.js} +1 -1
- package/cli/repl/commands/{normalize.d.ts → repl-normalize.d.ts} +1 -1
- package/cli/repl/commands/{normalize.js → repl-normalize.js} +3 -3
- package/cli/repl/commands/{parse.d.ts → repl-parse.d.ts} +1 -1
- package/cli/repl/commands/{parse.js → repl-parse.js} +3 -2
- package/cli/repl/commands/repl-query.d.ts +8 -0
- package/cli/repl/commands/repl-query.js +155 -0
- package/cli/repl/commands/repl-quit.d.ts +2 -0
- package/cli/repl/commands/{quit.js → repl-quit.js} +1 -1
- package/cli/repl/commands/{version.d.ts → repl-version.d.ts} +1 -1
- package/cli/repl/commands/{version.js → repl-version.js} +4 -4
- package/cli/repl/core.d.ts +1 -2
- package/cli/repl/core.js +13 -13
- package/cli/repl/execute.d.ts +1 -2
- package/cli/repl/execute.js +2 -3
- package/cli/repl/print-version.js +3 -4
- package/cli/repl/server/connection.d.ts +1 -0
- package/cli/repl/server/connection.js +45 -12
- package/cli/repl/server/messages/{messages.d.ts → all-messages.d.ts} +8 -7
- package/cli/repl/server/messages/{messages.js → all-messages.js} +1 -1
- package/cli/repl/server/messages/{analysis.d.ts → message-analysis.d.ts} +2 -1
- package/cli/repl/server/messages/message-analysis.js +39 -0
- package/cli/repl/server/messages/{error.d.ts → message-error.d.ts} +1 -1
- package/cli/repl/server/messages/{error.js → message-error.js} +1 -1
- package/cli/repl/server/messages/{hello.d.ts → message-hello.d.ts} +4 -3
- package/cli/repl/server/messages/message-hello.js +20 -0
- package/cli/repl/server/messages/{lineage.d.ts → message-lineage.d.ts} +2 -1
- package/cli/repl/server/messages/message-lineage.js +25 -0
- package/cli/repl/server/messages/message-query.d.ts +16 -0
- package/cli/repl/server/messages/message-query.js +26 -0
- package/cli/repl/server/messages/{repl.d.ts → message-repl.d.ts} +3 -1
- package/cli/repl/server/messages/message-repl.js +53 -0
- package/cli/repl/server/messages/{slice.d.ts → message-slice.d.ts} +2 -1
- package/cli/repl/server/messages/{slice.js → message-slice.js} +14 -6
- package/cli/repl/server/net.d.ts +0 -1
- package/cli/repl/server/send.d.ts +1 -1
- package/cli/repl/server/send.js +2 -3
- package/cli/repl/server/server.js +2 -2
- package/cli/repl/server/validate.d.ts +1 -1
- package/cli/repl/server/validate.js +5 -6
- package/cli/run-script.d.ts +8 -0
- package/cli/run-script.js +18 -0
- package/cli/script-core/statistics-core.d.ts +2 -0
- package/cli/script-core/statistics-core.js +100 -0
- package/cli/script-core/statistics-helper-core.d.ts +2 -0
- package/cli/script-core/statistics-helper-core.js +81 -0
- package/cli/script-core/summarizer-core.d.ts +2 -0
- package/cli/script-core/summarizer-core.js +51 -0
- package/cli/statistics-app.js +3 -87
- package/cli/statistics-helper-app.js +3 -77
- package/cli/summarizer-app.js +2 -48
- package/config.d.ts +20 -4
- package/config.js +62 -36
- package/core/pipeline-executor.js +11 -1
- package/core/print/dataflow-printer.js +4 -5
- package/core/print/normalize-printer.js +4 -5
- package/core/print/parse-printer.js +1 -2
- package/core/print/print.js +2 -3
- package/core/print/slice-diff-ansi.js +1 -2
- package/core/steps/pipeline/create-pipeline.js +1 -2
- package/core/steps/pipeline/default-pipelines.d.ts +18 -18
- package/core/steps/pipeline/pipeline.js +1 -2
- package/dataflow/environments/append.js +1 -2
- package/dataflow/environments/built-in-config.d.ts +47 -0
- package/dataflow/environments/built-in-config.js +83 -0
- package/dataflow/environments/built-in.d.ts +49 -6
- package/dataflow/environments/built-in.js +29 -97
- package/dataflow/environments/clone.js +2 -2
- package/dataflow/environments/default-builtin-config.d.ts +5 -0
- package/dataflow/environments/default-builtin-config.js +83 -0
- package/dataflow/environments/define.js +1 -2
- package/dataflow/environments/diff.js +5 -6
- package/dataflow/environments/environment.js +8 -7
- package/dataflow/environments/identifier.d.ts +39 -8
- package/dataflow/environments/identifier.js +33 -0
- package/dataflow/environments/overwrite.d.ts +6 -5
- package/dataflow/environments/overwrite.js +16 -9
- package/dataflow/environments/resolve-by-name.d.ts +3 -1
- package/dataflow/environments/resolve-by-name.js +40 -8
- package/dataflow/environments/scoping.js +2 -3
- package/dataflow/extractor.js +25 -24
- package/dataflow/graph/dataflowgraph-builder.d.ts +139 -0
- package/dataflow/graph/dataflowgraph-builder.js +247 -0
- package/dataflow/graph/diff.js +12 -11
- package/dataflow/graph/edge.d.ts +2 -2
- package/dataflow/graph/edge.js +46 -20
- package/dataflow/graph/graph.d.ts +14 -6
- package/dataflow/graph/graph.js +25 -21
- package/dataflow/graph/quads.js +1 -2
- package/dataflow/graph/resolve-graph.d.ts +7 -0
- package/dataflow/graph/resolve-graph.js +51 -0
- package/dataflow/graph/vertex.d.ts +12 -4
- package/dataflow/graph/vertex.js +19 -11
- package/dataflow/info.d.ts +3 -7
- package/dataflow/info.js +7 -8
- package/dataflow/internal/linker.d.ts +3 -1
- package/dataflow/internal/linker.js +77 -32
- package/dataflow/internal/process/functions/call/argument/make-argument.js +5 -5
- package/dataflow/internal/process/functions/call/argument/unpack-argument.js +1 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +10 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +5 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +27 -10
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +40 -26
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +30 -20
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +10 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +12 -11
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +6 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +7 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +4 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +10 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +7 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +2 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +5 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +6 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +6 -5
- package/dataflow/internal/process/functions/call/common.js +30 -19
- package/dataflow/internal/process/functions/call/default-call-handling.js +1 -2
- package/dataflow/internal/process/functions/call/known-call-handling.js +8 -6
- package/dataflow/internal/process/functions/call/named-call-handling.js +7 -6
- package/dataflow/internal/process/functions/call/unnamed-call-handling.js +11 -7
- package/dataflow/internal/process/functions/process-argument.js +10 -8
- package/dataflow/internal/process/functions/process-parameter.js +8 -6
- package/dataflow/internal/process/process-named-call.js +3 -3
- package/dataflow/internal/process/process-symbol.js +5 -4
- package/dataflow/internal/process/process-uninteresting-leaf.js +1 -2
- package/dataflow/internal/process/process-value.js +5 -4
- package/dataflow/processor.js +1 -2
- package/documentation/data/dfg/doc-data-dfg-util.d.ts +20 -0
- package/documentation/data/dfg/doc-data-dfg-util.js +13 -0
- package/documentation/data/query/example-query-code.d.ts +1 -0
- package/documentation/data/query/example-query-code.js +25 -0
- package/documentation/data/server/doc-data-server-messages.d.ts +1 -0
- package/documentation/data/server/doc-data-server-messages.js +508 -0
- package/documentation/doc-util/doc-auto-gen.d.ts +7 -0
- package/documentation/doc-util/doc-auto-gen.js +9 -0
- package/documentation/doc-util/doc-cfg.d.ts +7 -0
- package/documentation/doc-util/doc-cfg.js +18 -0
- package/documentation/doc-util/doc-cli-option.d.ts +8 -0
- package/documentation/doc-util/doc-cli-option.js +36 -0
- package/documentation/doc-util/doc-code.d.ts +1 -0
- package/documentation/doc-util/doc-code.js +7 -0
- package/documentation/doc-util/doc-dfg.d.ts +21 -0
- package/documentation/doc-util/doc-dfg.js +93 -0
- package/documentation/doc-util/doc-docker.d.ts +1 -0
- package/documentation/doc-util/doc-docker.js +5 -0
- package/documentation/doc-util/doc-env.d.ts +2 -0
- package/documentation/doc-util/doc-env.js +20 -0
- package/documentation/doc-util/doc-files.d.ts +6 -0
- package/documentation/doc-util/doc-files.js +25 -0
- package/documentation/doc-util/doc-general.d.ts +2 -0
- package/documentation/doc-util/doc-general.js +16 -0
- package/documentation/doc-util/doc-hover-over.d.ts +1 -0
- package/documentation/doc-util/doc-hover-over.js +7 -0
- package/documentation/doc-util/doc-issue.d.ts +1 -0
- package/documentation/doc-util/doc-issue.js +6 -0
- package/documentation/doc-util/doc-ms.d.ts +1 -0
- package/documentation/doc-util/doc-ms.js +8 -0
- package/documentation/doc-util/doc-normalized-ast.d.ts +11 -0
- package/documentation/doc-util/doc-normalized-ast.js +71 -0
- package/documentation/doc-util/doc-query.d.ts +24 -0
- package/documentation/doc-util/doc-query.js +113 -0
- package/documentation/doc-util/doc-repl.d.ts +13 -0
- package/documentation/doc-util/doc-repl.js +79 -0
- package/documentation/doc-util/doc-server-message.d.ts +37 -0
- package/documentation/doc-util/doc-server-message.js +153 -0
- package/documentation/doc-util/doc-structure.d.ts +12 -0
- package/documentation/doc-util/doc-structure.js +21 -0
- package/documentation/doc-util/doc-types.d.ts +38 -0
- package/documentation/doc-util/doc-types.js +276 -0
- package/{r-bridge/data/print.js → documentation/print-capabilities-markdown.js} +8 -4
- package/documentation/print-dataflow-graph-wiki.d.ts +1 -0
- package/documentation/print-dataflow-graph-wiki.js +849 -0
- package/documentation/print-interface-wiki.d.ts +1 -0
- package/documentation/print-interface-wiki.js +401 -0
- package/documentation/print-normalized-ast-wiki.d.ts +1 -0
- package/documentation/print-normalized-ast-wiki.js +98 -0
- package/documentation/print-query-wiki.d.ts +1 -0
- package/documentation/print-query-wiki.js +215 -0
- package/package.json +29 -33
- package/queries/base-query-format.d.ts +11 -0
- package/{cli/repl/server/messages/hello.js → queries/base-query-format.js} +1 -1
- package/queries/call-context-query/call-context-query-executor.d.ts +11 -0
- package/queries/call-context-query/call-context-query-executor.js +255 -0
- package/queries/call-context-query/call-context-query-format.d.ts +72 -0
- package/queries/call-context-query/call-context-query-format.js +17 -0
- package/queries/query-schema.d.ts +7 -0
- package/queries/query-schema.js +31 -0
- package/queries/query.d.ts +35 -0
- package/queries/query.js +57 -0
- package/queries/two-layer-collector.d.ts +8 -0
- package/queries/two-layer-collector.js +31 -0
- package/queries/virtual-query/compound-query.d.ts +24 -0
- package/queries/virtual-query/compound-query.js +18 -0
- package/queries/virtual-query/virtual-queries.d.ts +15 -0
- package/queries/virtual-query/virtual-queries.js +8 -0
- package/r-bridge/data/data.d.ts +5 -0
- package/r-bridge/data/data.js +6 -0
- package/r-bridge/data/get.js +2 -3
- package/r-bridge/init.js +2 -2
- package/r-bridge/lang-4.x/ast/model/collect.js +1 -2
- package/r-bridge/lang-4.x/ast/model/model.d.ts +1 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +5 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +4 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +1 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +10 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +5 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +1 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.js +1 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +2 -2
- package/r-bridge/lang-4.x/ast/model/operators.js +27 -26
- package/r-bridge/lang-4.x/ast/model/processing/decorate.js +9 -9
- package/r-bridge/lang-4.x/ast/model/processing/fold.js +1 -2
- package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +5 -0
- package/r-bridge/lang-4.x/ast/model/processing/node-id.js +26 -3
- package/r-bridge/lang-4.x/ast/model/processing/role.js +1 -2
- package/r-bridge/lang-4.x/ast/model/processing/stateful-fold.js +23 -23
- package/r-bridge/lang-4.x/ast/model/processing/visitor.js +23 -23
- package/r-bridge/lang-4.x/ast/model/type.d.ts +2 -2
- package/r-bridge/lang-4.x/ast/model/type.js +221 -12
- package/r-bridge/lang-4.x/ast/parser/json/format.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/json/parser.js +6 -5
- package/r-bridge/lang-4.x/ast/parser/xml/input-format.js +3 -3
- package/r-bridge/lang-4.x/ast/parser/xml/internal/control/normalize-if-then-else.js +4 -4
- package/r-bridge/lang-4.x/ast/parser/xml/internal/control/normalize-if-then.js +7 -7
- package/r-bridge/lang-4.x/ast/parser/xml/internal/expression/normalize-expression.js +4 -4
- package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/normalize-argument.js +10 -10
- package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/normalize-call.js +18 -18
- package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/normalize-definition.js +8 -8
- package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/normalize-parameter.js +9 -9
- package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/normalize-break.js +3 -3
- package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/normalize-for.js +10 -10
- package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/normalize-next.js +3 -3
- package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/normalize-repeat.js +5 -5
- package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/normalize-while.js +7 -7
- package/r-bridge/lang-4.x/ast/parser/xml/internal/normalize-access.js +12 -12
- package/r-bridge/lang-4.x/ast/parser/xml/internal/operators/normalize-binary.js +14 -14
- package/r-bridge/lang-4.x/ast/parser/xml/internal/operators/normalize-unary.js +4 -4
- package/r-bridge/lang-4.x/ast/parser/xml/internal/other/normalize-comment.js +3 -3
- package/r-bridge/lang-4.x/ast/parser/xml/internal/other/normalize-line-directive.js +4 -4
- package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/normalize-delimiter.js +3 -3
- package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/normalize-expressions.js +13 -13
- package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/normalize-root.js +6 -6
- package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/normalize-single-node.js +19 -19
- package/r-bridge/lang-4.x/ast/parser/xml/internal/values/normalize-number.js +5 -5
- package/r-bridge/lang-4.x/ast/parser/xml/internal/values/normalize-string.js +3 -3
- package/r-bridge/lang-4.x/ast/parser/xml/internal/values/normalize-symbol.js +2 -3
- package/r-bridge/lang-4.x/ast/parser/xml/normalize-meta.js +12 -12
- package/r-bridge/lang-4.x/convert-values.js +7 -7
- package/r-bridge/retriever.js +12 -11
- package/r-bridge/shell.d.ts +0 -1
- package/r-bridge/shell.js +6 -1
- package/reconstruct/auto-select/auto-select-defaults.js +1 -2
- package/reconstruct/auto-select/magic-comments.js +3 -3
- package/reconstruct/reconstruct.js +4 -3
- package/slicing/criterion/collect-all.js +1 -2
- package/slicing/criterion/parse.d.ts +1 -1
- package/slicing/criterion/parse.js +6 -5
- package/slicing/static/fingerprint.js +2 -3
- package/slicing/static/slice-call.js +9 -9
- package/slicing/static/static-slicer.js +5 -4
- package/statistics/features/common-syntax-probability.js +13 -13
- package/statistics/features/feature.d.ts +5 -9
- package/statistics/features/feature.js +2 -2
- package/statistics/features/post-processing.js +2 -3
- package/statistics/features/supported/assignments/assignments.js +3 -2
- package/statistics/features/supported/assignments/post-process.js +1 -2
- package/statistics/features/supported/comments/post-process.js +1 -2
- package/statistics/features/supported/control-flow/control-flow.js +4 -3
- package/statistics/features/supported/control-flow/post-process.js +1 -2
- package/statistics/features/supported/data-access/data-access.d.ts +2 -2
- package/statistics/features/supported/data-access/data-access.js +3 -2
- package/statistics/features/supported/data-access/post-process.js +1 -2
- package/statistics/features/supported/defined-functions/defined-functions.js +9 -7
- package/statistics/features/supported/defined-functions/post-process.d.ts +1 -1
- package/statistics/features/supported/defined-functions/post-process.js +2 -3
- package/statistics/features/supported/expression-list/post-process.js +1 -2
- package/statistics/features/supported/expression-list/{expression-list.js → statistics-expression-list.js} +4 -3
- package/statistics/features/supported/loops/loops.js +8 -7
- package/statistics/features/supported/loops/post-process.js +1 -2
- package/statistics/features/supported/used-functions/post-process.js +2 -3
- package/statistics/features/supported/used-functions/used-functions.d.ts +1 -1
- package/statistics/features/supported/used-functions/used-functions.js +4 -3
- package/statistics/features/supported/used-packages/post-process.js +1 -2
- package/statistics/features/supported/values/post-process.js +1 -2
- package/statistics/features/supported/variables/post-process.js +2 -3
- package/statistics/features/supported/variables/variables.js +2 -1
- package/statistics/meta-statistics.js +1 -2
- package/statistics/output/print-stats.js +4 -5
- package/statistics/output/statistics-file.js +5 -5
- package/statistics/statistics.js +2 -3
- package/statistics/summarizer/auto-detect.js +1 -2
- package/statistics/summarizer/post-process/clusterer.js +1 -2
- package/statistics/summarizer/post-process/file-based-count.js +2 -3
- package/statistics/summarizer/post-process/histogram.js +3 -4
- package/statistics/summarizer/post-process/post-process-output.js +2 -3
- package/statistics/summarizer/second-phase/process.d.ts +2 -0
- package/statistics/summarizer/second-phase/process.js +2 -2
- package/statistics/summarizer/summarizer.js +8 -1
- package/util/ansi.d.ts +1 -0
- package/util/ansi.js +27 -4
- package/util/args.js +2 -3
- package/util/arrays.js +8 -9
- package/util/assert.js +5 -6
- package/util/bimap.d.ts +4 -4
- package/util/cfg/cfg.d.ts +1 -0
- package/util/cfg/cfg.js +8 -5
- package/util/cfg/visitor.d.ts +8 -13
- package/util/cfg/visitor.js +22 -56
- package/util/diff.js +1 -2
- package/util/files.d.ts +0 -1
- package/util/files.js +11 -8
- package/util/json.js +2 -3
- package/util/mermaid/ast.js +7 -7
- package/util/mermaid/cfg.js +2 -3
- package/util/mermaid/dfg.d.ts +12 -4
- package/util/mermaid/dfg.js +28 -16
- package/util/mermaid/mermaid.js +5 -4
- package/util/numbers.js +1 -2
- package/util/objects.d.ts +7 -0
- package/util/objects.js +13 -3
- package/util/os.js +1 -2
- package/util/quads.js +5 -5
- package/util/random.js +2 -2
- package/util/range.js +8 -9
- package/util/schema.d.ts +11 -0
- package/util/schema.js +75 -0
- package/util/set.js +2 -3
- package/util/strings.js +3 -4
- package/util/summarizer.js +4 -4
- package/util/text.d.ts +1 -0
- package/util/text.js +20 -0
- package/util/time.js +1 -2
- package/util/version.js +2 -3
- package/cli/repl/commands/lineage.d.ts +0 -15
- package/cli/repl/commands/quit.d.ts +0 -2
- package/cli/repl/server/messages/analysis.js +0 -21
- package/cli/repl/server/messages/lineage.js +0 -17
- package/cli/repl/server/messages/repl.js +0 -37
- /package/cli/repl/commands/{main.d.ts → repl-main.d.ts} +0 -0
- /package/{r-bridge/data/print.d.ts → documentation/print-capabilities-markdown.d.ts} +0 -0
- /package/statistics/features/supported/expression-list/{expression-list.d.ts → statistics-expression-list.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const shell_1 = require("../r-bridge/shell");
|
|
4
|
+
const log_1 = require("../../test/functionality/_helper/log");
|
|
5
|
+
const doc_files_1 = require("./doc-util/doc-files");
|
|
6
|
+
const doc_auto_gen_1 = require("./doc-util/doc-auto-gen");
|
|
7
|
+
const doc_cli_option_1 = require("./doc-util/doc-cli-option");
|
|
8
|
+
const doc_server_message_1 = require("./doc-util/doc-server-message");
|
|
9
|
+
const doc_data_server_messages_1 = require("./data/server/doc-data-server-messages");
|
|
10
|
+
const doc_code_1 = require("./doc-util/doc-code");
|
|
11
|
+
const retriever_1 = require("../r-bridge/retriever");
|
|
12
|
+
const doc_docker_1 = require("./doc-util/doc-docker");
|
|
13
|
+
const doc_repl_1 = require("./doc-util/doc-repl");
|
|
14
|
+
const doc_dfg_1 = require("./doc-util/doc-dfg");
|
|
15
|
+
const config_1 = require("../config");
|
|
16
|
+
const schema_1 = require("../util/schema");
|
|
17
|
+
const ansi_1 = require("../util/ansi");
|
|
18
|
+
const flowr_main_options_1 = require("../cli/flowr-main-options");
|
|
19
|
+
const doc_issue_1 = require("./doc-util/doc-issue");
|
|
20
|
+
const pipeline_executor_1 = require("../core/pipeline-executor");
|
|
21
|
+
async function explainServer(shell) {
|
|
22
|
+
(0, doc_data_server_messages_1.documentAllMessages)();
|
|
23
|
+
return `
|
|
24
|
+
As explained in the [Overview](${doc_files_1.FlowrWikiBaseRef}/Overview), you can simply run the [TCP](https://de.wikipedia.org/wiki/Transmission_Control_Protocol) server by adding the ${(0, doc_cli_option_1.getCliLongOptionOf)('flowr', 'server', true)} flag (and, due to the interactive mode, exit with the conventional <kbd>CTRL</kbd>+<kbd>C</kbd>).
|
|
25
|
+
Currently, every connection is handled by the same underlying \`${shell_1.RShell.name}\` - so the server is not designed to handle many clients at a time.
|
|
26
|
+
Additionally, the server is not well guarded against attacks (e.g., you can theoretically spawn an arbitrary number of ${shell_1.RShell.name} sessions on the target machine).
|
|
27
|
+
|
|
28
|
+
Every message has to be given in a single line (i.e., without a newline in-between) and end with a newline character. Nevertheless, we will pretty-print example given in the following segments for the ease of reading.
|
|
29
|
+
|
|
30
|
+
> [!NOTE]
|
|
31
|
+
> The default ${(0, doc_cli_option_1.getCliLongOptionOf)('flowr', 'server', false)} uses a simple [TCP](https://de.wikipedia.org/wiki/Transmission_Control_Protocol)
|
|
32
|
+
> connection. If you want _flowR_ to expose a [WebSocket](https://de.wikipedia.org/wiki/WebSocket) server instead, add the ${(0, doc_cli_option_1.getCliLongOptionOf)('flowr', 'server', false)} flag (i.e., ${(0, doc_cli_option_1.multipleCliOptions)('flowr', 'server', 'ws')}) when starting _flowR_ from the command line.
|
|
33
|
+
|
|
34
|
+
${await (0, doc_server_message_1.printServerMessages)(shell)}
|
|
35
|
+
|
|
36
|
+
### 📡 Ways of Connecting
|
|
37
|
+
|
|
38
|
+
If you are interested in clients that communicate with _flowR_, please check out the [R adapter](${doc_files_1.FlowrGithubBaseRef}/flowr-r-adapter)
|
|
39
|
+
as well as the [Visual Studio Code extension](${doc_files_1.FlowrGithubBaseRef}/vscode-flowr).
|
|
40
|
+
|
|
41
|
+
<ol>
|
|
42
|
+
|
|
43
|
+
<li>
|
|
44
|
+
<a id="using-netcat-without-websocket"></a>Using Netcat
|
|
45
|
+
|
|
46
|
+
<details>
|
|
47
|
+
|
|
48
|
+
<summary>Without Websocket</summary>
|
|
49
|
+
|
|
50
|
+
Suppose, you want to launch the server using a docker container. Then, start the server by (forwarding the internal default port):
|
|
51
|
+
|
|
52
|
+
${(0, doc_code_1.codeBlock)('shell', `docker run -p1042:1042 -it --rm ${doc_docker_1.DockerName} --server`)}
|
|
53
|
+
|
|
54
|
+
Now, using a tool like [_netcat_](https://linux.die.net/man/1/nc) to connect:
|
|
55
|
+
|
|
56
|
+
${(0, doc_code_1.codeBlock)('shell', 'nc 127.0.0.1 1042')}
|
|
57
|
+
|
|
58
|
+
Within the started session, type the following message (as a single line) and press enter to see the response:
|
|
59
|
+
|
|
60
|
+
${(0, doc_code_1.codeBlock)('json', (0, retriever_1.removeRQuotes)(JSON.stringify({ type: 'request-file-analysis', content: 'x <- 1', id: '1' })))}
|
|
61
|
+
|
|
62
|
+
</details>
|
|
63
|
+
</li>
|
|
64
|
+
|
|
65
|
+
<li> Using Python
|
|
66
|
+
<details>
|
|
67
|
+
<summary>Without Websocket</summary>
|
|
68
|
+
|
|
69
|
+
In Python, a similar process would look like this. After starting the server as with using [netcat](#using-netcat-without-websocket), you can use the following script to connect:
|
|
70
|
+
|
|
71
|
+
${(0, doc_code_1.codeBlock)('python', `
|
|
72
|
+
import socket
|
|
73
|
+
|
|
74
|
+
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
|
75
|
+
s.connect(('127.0.0.1', 1042))
|
|
76
|
+
print(s.recv(4096)) # for the hello message
|
|
77
|
+
|
|
78
|
+
s.send(b'${(0, retriever_1.removeRQuotes)(JSON.stringify({ type: 'request-file-analysis', content: 'x <- 1', id: '1' }))}\\n')
|
|
79
|
+
|
|
80
|
+
print(s.recv(65536)) # for the response (please use a more sophisticated mechanism)
|
|
81
|
+
`)}
|
|
82
|
+
|
|
83
|
+
</details>
|
|
84
|
+
</li>
|
|
85
|
+
|
|
86
|
+
</ol>
|
|
87
|
+
|
|
88
|
+
`;
|
|
89
|
+
}
|
|
90
|
+
async function explainRepl(shell) {
|
|
91
|
+
return `
|
|
92
|
+
> [!NOTE]
|
|
93
|
+
> To execute arbitrary R commands with a repl request, _flowR_ has to be started explicitly with ${(0, doc_cli_option_1.getCliLongOptionOf)('flowr', 'r-session-access')}.
|
|
94
|
+
> Please be aware that this introduces a security risk.
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
Although primarily meant for users to explore,
|
|
98
|
+
there is nothing which forbids simply calling _flowR_ as a subprocess to use standard-in, -output, and -error
|
|
99
|
+
for communication (although you can access the REPL using the server as well,
|
|
100
|
+
with the [REPL Request](#message-request-repl-execution) message).
|
|
101
|
+
|
|
102
|
+
The read-eval-print loop (REPL) works relatively simple.
|
|
103
|
+
You can submit an expression (using enter),
|
|
104
|
+
which is interpreted as an R expression by default but interpreted as a *command* if it starts with a colon (\`:\`).
|
|
105
|
+
The best command to get started with the REPL is ${(0, doc_cli_option_1.getReplCommand)('help')}.
|
|
106
|
+
Besides, you can leave the REPL either with the command ${(0, doc_cli_option_1.getReplCommand)('quit')} or by pressing <kbd>CTRL</kbd>+<kbd>C</kbd> twice.
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
<details>
|
|
110
|
+
<summary>Available Commands</summary>
|
|
111
|
+
|
|
112
|
+
We currently offer the following commands (this with a \`[*]\` suffix are available with and without the star):
|
|
113
|
+
|
|
114
|
+
${(0, doc_repl_1.printReplHelpAsMarkdownTable)()}
|
|
115
|
+
|
|
116
|
+
</details>
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
### Example: Retrieving the Dataflow Graph
|
|
120
|
+
|
|
121
|
+
To retrieve a URL to the [mermaid](https://mermaid.js.org/) diagram of the dataflow of a given expression,
|
|
122
|
+
use ${(0, doc_cli_option_1.getReplCommand)('dataflow*')} (or ${(0, doc_cli_option_1.getReplCommand)('dataflow')} to get the mermaid code in the cli):
|
|
123
|
+
|
|
124
|
+
${await (0, doc_repl_1.documentReplSession)(shell, [{
|
|
125
|
+
command: ':dataflow* y <- 1 + x',
|
|
126
|
+
description: `Retrieve the dataflow graph of the expression \`y <- 1 + x\`. It looks like this:\n${await (0, doc_dfg_1.printDfGraphForCode)(shell, 'y <- 1 + x')}.`
|
|
127
|
+
}])}
|
|
128
|
+
|
|
129
|
+
For the slicing with ${(0, doc_cli_option_1.getReplCommand)('slicer')}, you have access to the same [magic comments](#slice-magic-comments) as with the [slice request](#message-request-slice).
|
|
130
|
+
|
|
131
|
+
### Example: Interfacing with the File System
|
|
132
|
+
|
|
133
|
+
Many commands that allow for an R-expression (like ${(0, doc_cli_option_1.getReplCommand)('dataflow*')}) allow for a file as well
|
|
134
|
+
if the argument starts with \`${retriever_1.fileProtocol}\`.
|
|
135
|
+
If you are working from the root directory of the _flowR_ repository, the following gives you the parsed AST of the example file using the ${(0, doc_cli_option_1.getReplCommand)('parse')} command:
|
|
136
|
+
|
|
137
|
+
${await (0, doc_repl_1.documentReplSession)(shell, [{
|
|
138
|
+
command: `:parse ${retriever_1.fileProtocol}test/testfiles/example.R`,
|
|
139
|
+
description: `Retrieve the parsed AST of the example file.
|
|
140
|
+
|
|
141
|
+
<details>
|
|
142
|
+
|
|
143
|
+
<summary>File Content</summary>
|
|
144
|
+
|
|
145
|
+
${(0, doc_code_1.codeBlock)('r', (0, doc_files_1.getFileContentFromRoot)('test/testfiles/example.R'))}
|
|
146
|
+
|
|
147
|
+
</details>
|
|
148
|
+
|
|
149
|
+
As _flowR_ directly transforms this AST the output focuses on being human-readable instead of being machine-readable.
|
|
150
|
+
`
|
|
151
|
+
}])}
|
|
152
|
+
`;
|
|
153
|
+
}
|
|
154
|
+
function explainConfigFile() {
|
|
155
|
+
return `
|
|
156
|
+
|
|
157
|
+
When running _flowR_, you may want to specify some behaviors with a dedicated configuration file.
|
|
158
|
+
By default, flowR looks for a file named \`${flowr_main_options_1.defaultConfigFile}\` in the current working directory (or any higher directory).
|
|
159
|
+
You can also specify a different file with ${(0, doc_cli_option_1.getCliLongOptionOf)('flowr', 'config-file')} or pass the configuration inline using ${(0, doc_cli_option_1.getCliLongOptionOf)('flowr', 'config-json')}.
|
|
160
|
+
|
|
161
|
+
The following summarizes the configuration options:
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
- \`ignoreSourceCalls\`: If set to \`true\`, _flowR_ will ignore source calls when analyzing the code, i.e., ignoring the inclusion of other files.
|
|
165
|
+
- \`rPath\`: The path to the R executable. If not set, _flowR_ will try to find the R executable in the system's PATH.
|
|
166
|
+
- \`semantics\`: allows to configure the way _flowR_ handles R, although we currently only support \`semantics/environment/overwriteBuiltIns\`.
|
|
167
|
+
You may use this to overwrite _flowR_'s handling of built-in function and even completely clear the preset definitions shipped with flowR.
|
|
168
|
+
See [Configure BuiltIn Semantics](#configure-builtin-semantics) for more information.
|
|
169
|
+
|
|
170
|
+
So you can configure _flowR_ by adding a file like the following:
|
|
171
|
+
|
|
172
|
+
<details>
|
|
173
|
+
|
|
174
|
+
<summary>Example Configuration File</summary>
|
|
175
|
+
|
|
176
|
+
${(0, doc_code_1.codeBlock)('json', JSON.stringify({
|
|
177
|
+
ignoreSourceCalls: true,
|
|
178
|
+
rPath: '/usr/bin/R',
|
|
179
|
+
semantics: {
|
|
180
|
+
environment: {
|
|
181
|
+
overwriteBuiltIns: {
|
|
182
|
+
definitions: [
|
|
183
|
+
{ type: 'function', names: ['foo'], processor: 'builtin:assignment', config: {} }
|
|
184
|
+
]
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}, null, 2))}
|
|
189
|
+
|
|
190
|
+
</details>
|
|
191
|
+
|
|
192
|
+
<details>
|
|
193
|
+
<a id='configure-builtin-semantics'></a>
|
|
194
|
+
<summary>Configure Built-In Semantics</summary>
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
\`semantics/environment/overwriteBuiltins\` accepts two keys:
|
|
198
|
+
|
|
199
|
+
- \`loadDefaults\` (boolean, initially \`true\`): If set to \`true\`, the default built-in definitions are loaded before applying the custom definitions. Setting this flag to \`false\` explicitly disables the loading of the default definitions.
|
|
200
|
+
- \`definitions\` (array, initially empty): Allows to overwrite or define new built-in elements. Each object within must have a \`type\` which is one of the below. Furthermore, they may define a string array of \`names\` which specifies the identifiers to bind the definitions to. You may use \`assumePrimitive\` to specify whether _flowR_ should assume that this is a primitive non-library definition (so you probably just do not want to specify the key).
|
|
201
|
+
|
|
202
|
+
| Type | Description | Example |
|
|
203
|
+
| ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
|
|
204
|
+
| \`constant\` | Additionally allows for a \`value\` this should resolve to. | \`{ type: 'constant', names: ['NULL', 'NA'], value: null }\` |
|
|
205
|
+
| \`function\` | Is a rather flexible way to define and bind built-in functions. For the time, we do not have extensive documentation to cover all the cases, so please either consult the sources with the \`default-builtin-config.ts\` or open a [new issue](${doc_issue_1.NewIssueUrl}). | \`{ type: 'function', names: ['next'], processor: 'builtin:default', config: { cfg: ExitPointType.Next } }\` |
|
|
206
|
+
| \`replacement\` | A comfortable way to specify replacement functions like \`$<-\` or \`names<-\`. \`suffixes\` describes the... suffixes to attach automatically. | \`{ type: 'replacement', suffixes: ['<-', '<<-'], names: ['[', '[['] }\` |
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
</details>
|
|
210
|
+
|
|
211
|
+
<details>
|
|
212
|
+
|
|
213
|
+
<summary style='color:gray'>Full Configuration-File Schema</summary>
|
|
214
|
+
|
|
215
|
+
${(0, schema_1.describeSchema)(config_1.flowrConfigFileSchema, ansi_1.markdownFormatter)}
|
|
216
|
+
|
|
217
|
+
</details>
|
|
218
|
+
|
|
219
|
+
`;
|
|
220
|
+
}
|
|
221
|
+
function explainWritingCode(shell) {
|
|
222
|
+
return `
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
_flowR_ can be used as a [module](${doc_files_1.FlowrNpmRef}) and offers several main classes and interfaces that are interesting for extension writers
|
|
226
|
+
(see the [Visual Studio Code extension](${doc_files_1.FlowrGithubBaseRef}/vscode-flowr) or the [core](${doc_files_1.FlowrWikiBaseRef}/Core) wiki page for more information).
|
|
227
|
+
|
|
228
|
+
### Using the \`${shell_1.RShell.name}\` to Interact with R
|
|
229
|
+
|
|
230
|
+
The \`${shell_1.RShell.name}\` class allows to interface with the \`R\` ecosystem installed on the host system.
|
|
231
|
+
For now there are no (real) alternatives, although we plan on providing more flexible drop-in replacements.
|
|
232
|
+
|
|
233
|
+
> [!IMPORTANT]
|
|
234
|
+
> Each \`${shell_1.RShell.name}\` controls a new instance of the R interpreter, make sure to call \`${shell_1.RShell.name}::${shell.close.name}()\` when you’re done.
|
|
235
|
+
|
|
236
|
+
You can start a new "session" simply by constructing a new object with \`new ${shell_1.RShell.name}()\`.
|
|
237
|
+
|
|
238
|
+
However, there are several options which may be of interest (e.g., to automatically revive the shell in case of errors or to control the name location of the R process on the system).
|
|
239
|
+
|
|
240
|
+
With a shell object (let's call it \`shell\`), you can execute R code by using \`${shell_1.RShell.name}::${shell.sendCommand.name}\`,
|
|
241
|
+
for example \`shell.${shell.sendCommand.name}("1 + 1")\`.
|
|
242
|
+
However, this does not return anything, so if you want to collect the output of your command, use \`${shell_1.RShell.name}::${shell.sendCommandWithOutput.name}\` instead.
|
|
243
|
+
|
|
244
|
+
Besides that, the command \`${shell_1.RShell.name}::${shell.tryToInjectHomeLibPath.name}\` may be of interest, as it enables all libraries available on the host system.
|
|
245
|
+
|
|
246
|
+
### The Pipeline Executor
|
|
247
|
+
|
|
248
|
+
Once, in the beginning, _flowR_ was meant to produce a dataflow graph merely to provide *program slices*.
|
|
249
|
+
However, with continuous updates, the [dataflow graph](${doc_files_1.FlowrWikiBaseRef}/Dataflow&20Graph) repeatedly proves to be the more interesting part.
|
|
250
|
+
With this, we restructured _flowR_'s originally *hardcoded* pipeline to be far more flexible.
|
|
251
|
+
Now, it can be theoretically extended or replaced with arbitrary steps, optional steps, and what we call 'decorations' of these steps.
|
|
252
|
+
In short, if you still "just want to slice" you can do it like this:
|
|
253
|
+
|
|
254
|
+
${(0, doc_code_1.codeBlock)('ts', `
|
|
255
|
+
const slicer = new ${pipeline_executor_1.PipelineExecutor.name}(DEFAULT_SLICING_PIPELINE, {
|
|
256
|
+
shell: new ${shell_1.RShell.name}(),
|
|
257
|
+
request: ${retriever_1.requestFromInput.name}('x <- 1\\nx + 1'),
|
|
258
|
+
criterion: ['2@x']
|
|
259
|
+
})
|
|
260
|
+
const slice = await slicer.allRemainingSteps()
|
|
261
|
+
// console.log(slice.reconstruct.code)
|
|
262
|
+
`)}
|
|
263
|
+
|
|
264
|
+
<details>
|
|
265
|
+
|
|
266
|
+
<summary style='color:gray'>More Information</summary>
|
|
267
|
+
|
|
268
|
+
If you compare this, with what you would have done with the old (and removed) \`SteppingSlicer\`,
|
|
269
|
+
this essentially just requires you to replace the \`SteppingSlicer\` with the \`${pipeline_executor_1.PipelineExecutor.name}\`
|
|
270
|
+
and to pass the \`DEFAULT_SLICING_PIPELINE\` as the first argument.
|
|
271
|
+
The \`${pipeline_executor_1.PipelineExecutor.name}\`...
|
|
272
|
+
|
|
273
|
+
1. allows investigating the results of all intermediate steps
|
|
274
|
+
2. Can be executed step-by-step
|
|
275
|
+
3. Can repeat steps (e.g., to calculate multiple slices on the same input)
|
|
276
|
+
|
|
277
|
+
See the in-code documentation for more information.
|
|
278
|
+
|
|
279
|
+
</details>
|
|
280
|
+
|
|
281
|
+
### Generate Statistics
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
<details>
|
|
285
|
+
|
|
286
|
+
<summary>Adding a New Feature to Extract</summary>
|
|
287
|
+
|
|
288
|
+
In this example, we construct a new feature to extract, with the name "*example*".
|
|
289
|
+
Whenever this name appears, you may substitute this with whatever name fits your feature best (as long as the name is unique).
|
|
290
|
+
|
|
291
|
+
1. **Create a new file in \`src/statistics/features/supported\`**\\
|
|
292
|
+
Create the file \`example.ts\`, and add its export to the \`index.ts\` file in the same directory (if not done automatically).
|
|
293
|
+
|
|
294
|
+
2. **Create the basic structure**\\
|
|
295
|
+
To get a better feel of what a feature must have, let's look
|
|
296
|
+
at the basic structure (of course, due to TypeScript syntax,
|
|
297
|
+
there are other ways to achieve the same goal):
|
|
298
|
+
|
|
299
|
+
\`\`\`ts
|
|
300
|
+
const initialExampleInfo = {
|
|
301
|
+
/* whatever start value is good for you */
|
|
302
|
+
someCounter: 0
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
export type ExampleInfo = Writable<typeof initialExampleInfo>
|
|
306
|
+
|
|
307
|
+
export const example: Feature<ExampleInfo> = {
|
|
308
|
+
name: 'Example Feature',
|
|
309
|
+
description: 'A longer example description',
|
|
310
|
+
|
|
311
|
+
process(existing: ExampleInfo, input: FeatureProcessorInput): ExampleInfo {
|
|
312
|
+
/* perform analysis on the input */
|
|
313
|
+
return existing
|
|
314
|
+
},
|
|
315
|
+
|
|
316
|
+
initialValue: initialExampleInfo
|
|
317
|
+
}
|
|
318
|
+
\`\`\`
|
|
319
|
+
|
|
320
|
+
The \`initialExampleInfo\` type holds the initial values for each counter that you want to maintain during the feature extraction (they will usually be initialized with 0). The resulting \`ExampleInfo\` type holds the structure of the data that is to be counted. Due to the vast amount of data processed, information like the name and location of a function call is not stored here, but instead written to disk (see below).
|
|
321
|
+
|
|
322
|
+
Every new feature must be of the \`Feature<Info>\` type, with \`Info\` referring to a \`FeatureInfo\` (like \`ExampleInfo\` in this example). Next to a \`name\` and a \`description\`, each Feature must provide:
|
|
323
|
+
|
|
324
|
+
- a processor that extracts the information from the input, adding it to the existing information.
|
|
325
|
+
- a function returning the initial value of the information (in this case, \`initialExampleInfo\`).
|
|
326
|
+
|
|
327
|
+
3. **Add it to the feature-mapping**\\
|
|
328
|
+
Now, in the \`feature.ts\` file in \`src/statistics/features\`, add your feature to the \`ALL_FEATURES\` object.
|
|
329
|
+
|
|
330
|
+
Now, we want to extract something. For the *example* feature created in the previous steps, we choose to count the amount of \`COMMENT\` tokens.
|
|
331
|
+
So we define a corresponding [XPath](https://developer.mozilla.org/en-US/docs/Web/XPath) query:
|
|
332
|
+
|
|
333
|
+
\`\`\`ts
|
|
334
|
+
const commentQuery: Query = xpath.parse('//COMMENT')
|
|
335
|
+
\`\`\`
|
|
336
|
+
|
|
337
|
+
Within our feature's \`process\` function, running the query is as simple as:
|
|
338
|
+
|
|
339
|
+
\`\`\`ts
|
|
340
|
+
const comments = commentQuery.select({ node: input.parsedRAst })
|
|
341
|
+
\`\`\`
|
|
342
|
+
|
|
343
|
+
Now we could do a lot of further processing, but for simplicity, we only record every comment found this way:
|
|
344
|
+
|
|
345
|
+
\`\`\`ts
|
|
346
|
+
appendStatisticsFile(example.name, 'comments', comments, input.filepath)
|
|
347
|
+
\`\`\`
|
|
348
|
+
|
|
349
|
+
We use \`example.name\` to avoid duplication with the name that we’ve assigned to the feature. It corresponds to the name of the folder in the statistics output.
|
|
350
|
+
\`'comments'\` refers to a freely chosen (but unique) name, that will be used as the name for the output file within the folder. The \`comments\` variable holds the result of the query, which is an array of nodes. Finally, we pass the \`filepath\` of the file that was analyzed (if known), so that it can be added to the statistics file (as additional information).
|
|
351
|
+
|
|
352
|
+
</details>
|
|
353
|
+
`;
|
|
354
|
+
}
|
|
355
|
+
async function getText(shell) {
|
|
356
|
+
const rversion = (await shell.usedRVersion())?.format() ?? 'unknown';
|
|
357
|
+
return `${(0, doc_auto_gen_1.autoGenHeader)({ filename: module.filename, purpose: 'interfaces', rVersion: rversion })}
|
|
358
|
+
|
|
359
|
+
Although far from being as detailed as the in-depth explanation of
|
|
360
|
+
[_flowR_](${doc_files_1.FlowrWikiBaseRef}/Core),
|
|
361
|
+
this wiki page explains how to interface with _flowR_ in more detail.
|
|
362
|
+
In general, command line arguments and other options provide short descriptions on hover over.
|
|
363
|
+
|
|
364
|
+
* [💬 Communicating with the Server](#communicating-with-the-server)
|
|
365
|
+
* [💻 Using the REPL](#using-the-repl)
|
|
366
|
+
* [⚙️ Configuring FlowR](#configuring-flowr)
|
|
367
|
+
* [⚒️ Writing Code](#writing-code)
|
|
368
|
+
|
|
369
|
+
<a id='communicating-with-the-server'></a>
|
|
370
|
+
## 💬 Communicating with the Server
|
|
371
|
+
|
|
372
|
+
${await explainServer(shell)}
|
|
373
|
+
|
|
374
|
+
<a id='using-the-repl'></a>
|
|
375
|
+
## 💻 Using the REPL
|
|
376
|
+
|
|
377
|
+
${await explainRepl(shell)}
|
|
378
|
+
|
|
379
|
+
<a id='configuring-flowr'></a>
|
|
380
|
+
## ⚙️ Configuring FlowR
|
|
381
|
+
|
|
382
|
+
${explainConfigFile()}
|
|
383
|
+
|
|
384
|
+
<a id='writing-code'></a>
|
|
385
|
+
## ⚒️ Writing Code
|
|
386
|
+
|
|
387
|
+
${explainWritingCode(shell)}
|
|
388
|
+
|
|
389
|
+
`;
|
|
390
|
+
}
|
|
391
|
+
/** if we run this script, we want a Markdown representation of the capabilities */
|
|
392
|
+
if (require.main === module) {
|
|
393
|
+
(0, log_1.setMinLevelOfAllLogs)(6 /* LogLevel.Fatal */);
|
|
394
|
+
const shell = new shell_1.RShell();
|
|
395
|
+
void getText(shell).then(str => {
|
|
396
|
+
console.log(str);
|
|
397
|
+
}).finally(() => {
|
|
398
|
+
shell.close();
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
//# sourceMappingURL=print-interface-wiki.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,98 @@
|
|
|
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 shell_1 = require("../r-bridge/shell");
|
|
7
|
+
const log_1 = require("../../test/functionality/_helper/log");
|
|
8
|
+
const doc_auto_gen_1 = require("./doc-util/doc-auto-gen");
|
|
9
|
+
const doc_code_1 = require("./doc-util/doc-code");
|
|
10
|
+
const doc_normalized_ast_1 = require("./doc-util/doc-normalized-ast");
|
|
11
|
+
const doc_types_1 = require("./doc-util/doc-types");
|
|
12
|
+
const path_1 = __importDefault(require("path"));
|
|
13
|
+
const doc_files_1 = require("./doc-util/doc-files");
|
|
14
|
+
const doc_ms_1 = require("./doc-util/doc-ms");
|
|
15
|
+
const doc_cli_option_1 = require("./doc-util/doc-cli-option");
|
|
16
|
+
async function getText(shell) {
|
|
17
|
+
const rversion = (await shell.usedRVersion())?.format() ?? 'unknown';
|
|
18
|
+
const now = performance.now();
|
|
19
|
+
const types = (0, doc_types_1.getTypesFromFolderAsMermaid)({
|
|
20
|
+
rootFolder: path_1.default.resolve('./src/r-bridge/lang-4.x/ast/model/'),
|
|
21
|
+
typeName: 'RNode',
|
|
22
|
+
inlineTypes: doc_types_1.mermaidHide
|
|
23
|
+
});
|
|
24
|
+
const elapsed = performance.now() - now;
|
|
25
|
+
return `${(0, doc_auto_gen_1.autoGenHeader)({ filename: module.filename, purpose: 'normalized ast', rVersion: rversion })}
|
|
26
|
+
|
|
27
|
+
_flowR_ produces a normalized version of R's abstract syntax tree (AST),
|
|
28
|
+
offering the following benefits:
|
|
29
|
+
|
|
30
|
+
1. abstract away from intricacies of the R parser
|
|
31
|
+
2. provide a version-independent representation of the program
|
|
32
|
+
3. decorate the AST with additional information, e.g., parent relations and nesting information
|
|
33
|
+
|
|
34
|
+
In general, the mapping should be rather intuitive and focused primarily on the
|
|
35
|
+
syntactic structure of the program.
|
|
36
|
+
Consider the following example which shows the normalized AST of the code
|
|
37
|
+
|
|
38
|
+
${(0, doc_code_1.codeBlock)('r', 'x <- 2 * 3 + 1')}
|
|
39
|
+
|
|
40
|
+
Each node in the AST contains the type, the id, and the lexeme (if applicable).
|
|
41
|
+
Each edge is labeled with the type of the parent-child relationship (the "role").
|
|
42
|
+
|
|
43
|
+
${await (0, doc_normalized_ast_1.printNormalizedAstForCode)(shell, 'x <- 2 * 3 + 1')}
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
> [!TIP]
|
|
48
|
+
> If you want to investigate the normalized AST,
|
|
49
|
+
> you can either use the [Visual Studio Code extension](${doc_files_1.FlowrGithubBaseRef}/vscode-flowr) or the ${(0, doc_cli_option_1.getReplCommand)('normalize*')}
|
|
50
|
+
> command in the REPL (see the [Interface wiki page](${doc_files_1.FlowrWikiBaseRef}/Interface) for more information).
|
|
51
|
+
|
|
52
|
+
Indicative is the root expression list node, which is present in every normalized AST.
|
|
53
|
+
In general, we provide node types for:
|
|
54
|
+
|
|
55
|
+
1. literals (e.g., numbers and strings)
|
|
56
|
+
2. references (e.g., symbols, parameters and function calls)
|
|
57
|
+
3. constructs (e.g., loops and function definitions)
|
|
58
|
+
4. branches (e.g., \`next\` and \`break\`)
|
|
59
|
+
5. operators (e.g. \`+\`, \`-\`, and \`*\`)
|
|
60
|
+
|
|
61
|
+
<details>
|
|
62
|
+
|
|
63
|
+
<summary style="color:gray">Complete Class Diagram</summary>
|
|
64
|
+
|
|
65
|
+
Every node is a link, which directly refers to the implementation in the source code.
|
|
66
|
+
Grayed-out parts are used for structuring the AST, grouping together related nodes.
|
|
67
|
+
|
|
68
|
+
${(0, doc_code_1.codeBlock)('mermaid', types.text)}
|
|
69
|
+
|
|
70
|
+
_The generation of the class diagram required ${(0, doc_ms_1.printAsMs)(elapsed)}._
|
|
71
|
+
</details>
|
|
72
|
+
|
|
73
|
+
Node types are controlled by the \`${'RType'}\` enum (see ${(0, doc_files_1.getFilePathMd)('../r-bridge/lang-4.x/ast/model/type.ts')}),
|
|
74
|
+
which is used to distinguish between different types of nodes.
|
|
75
|
+
Additionally, every AST node is generic with respect to the \`Info\` type which allows for arbitrary decorations (e.g., parent inforamtion or dataflow constraints).
|
|
76
|
+
Most notably, the \`info\` field holds the \`id\` of the node, which is used to reference the node in the [dataflow graph](${doc_files_1.FlowrWikiBaseRef}/Dataflow%20Graph).
|
|
77
|
+
|
|
78
|
+
In summary, we have the following types:
|
|
79
|
+
|
|
80
|
+
${(0, doc_types_1.printHierarchy)({ program: types.program, hierarchy: types.info, root: 'RNode', collapseFromNesting: Number.MAX_VALUE })}
|
|
81
|
+
|
|
82
|
+
With this, the example file produced the following AST (shown from left to right for space reasons):
|
|
83
|
+
|
|
84
|
+
${await (0, doc_normalized_ast_1.printNormalizedAstForCode)(shell, (0, doc_files_1.getFileContentFromRoot)('test/testfiles/example.R'), { prefix: 'flowchart LR\n' })}
|
|
85
|
+
|
|
86
|
+
`;
|
|
87
|
+
}
|
|
88
|
+
/** if we run this script, we want a Markdown representation of the capabilities */
|
|
89
|
+
if (require.main === module) {
|
|
90
|
+
(0, log_1.setMinLevelOfAllLogs)(6 /* LogLevel.Fatal */);
|
|
91
|
+
const shell = new shell_1.RShell();
|
|
92
|
+
void getText(shell).then(str => {
|
|
93
|
+
console.log(str);
|
|
94
|
+
}).finally(() => {
|
|
95
|
+
shell.close();
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=print-normalized-ast-wiki.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|