@eagleoutice/flowr 2.9.10 → 2.9.11

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.
Files changed (165) hide show
  1. package/README.md +48 -50
  2. package/abstract-interpretation/absint-visitor.js +2 -1
  3. package/abstract-interpretation/data-frame/mappers/arguments.d.ts +1 -1
  4. package/abstract-interpretation/data-frame/mappers/arguments.js +2 -2
  5. package/abstract-interpretation/domains/set-range-domain.js +1 -1
  6. package/abstract-interpretation/normalized-ast-fold.d.ts +2 -2
  7. package/abstract-interpretation/normalized-ast-fold.js +4 -3
  8. package/benchmark/slicer.js +5 -5
  9. package/benchmark/summarizer/first-phase/process.js +4 -4
  10. package/cli/repl/commands/repl-normalize.js +2 -2
  11. package/cli/repl/core.js +2 -2
  12. package/config.js +1 -1
  13. package/control-flow/control-flow-graph.d.ts +1 -1
  14. package/control-flow/control-flow-graph.js +1 -2
  15. package/control-flow/extract-cfg.js +4 -3
  16. package/dataflow/cluster.js +1 -1
  17. package/dataflow/environments/built-in.d.ts +2 -15
  18. package/dataflow/environments/built-in.js +11 -31
  19. package/dataflow/eval/resolve/alias-tracking.d.ts +1 -1
  20. package/dataflow/eval/resolve/alias-tracking.js +2 -1
  21. package/dataflow/eval/resolve/resolve.js +4 -3
  22. package/dataflow/fn/exceptions-of-function.d.ts +1 -1
  23. package/dataflow/fn/exceptions-of-function.js +2 -1
  24. package/dataflow/graph/call-graph.d.ts +1 -1
  25. package/dataflow/graph/call-graph.js +4 -3
  26. package/dataflow/graph/dataflowgraph-builder.d.ts +1 -1
  27. package/dataflow/graph/dataflowgraph-builder.js +21 -21
  28. package/dataflow/graph/graph.d.ts +4 -4
  29. package/dataflow/graph/graph.js +27 -22
  30. package/dataflow/internal/linker.d.ts +2 -2
  31. package/dataflow/internal/linker.js +10 -9
  32. package/dataflow/internal/process/functions/call/argument/make-argument.d.ts +2 -1
  33. package/dataflow/internal/process/functions/call/argument/make-argument.js +2 -1
  34. package/dataflow/internal/process/functions/call/built-in/built-in-access.d.ts +1 -1
  35. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +2 -1
  36. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +3 -5
  37. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.d.ts +1 -1
  38. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +6 -5
  39. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +1 -1
  40. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +3 -2
  41. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +4 -4
  42. package/dataflow/internal/process/functions/call/built-in/built-in-local.js +3 -3
  43. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.d.ts +1 -1
  44. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +2 -1
  45. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +3 -3
  46. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +3 -3
  47. package/dataflow/internal/process/functions/call/common.d.ts +1 -1
  48. package/dataflow/internal/process/functions/call/common.js +43 -35
  49. package/dataflow/internal/process/functions/process-argument.d.ts +1 -1
  50. package/dataflow/internal/process/functions/process-argument.js +3 -3
  51. package/dataflow/internal/process/functions/process-parameter.js +2 -2
  52. package/dataflow/origin/dfg-get-origin.d.ts +1 -1
  53. package/dataflow/origin/dfg-get-origin.js +2 -2
  54. package/documentation/doc-util/doc-types.js +1 -1
  55. package/documentation/wiki-cfg.js +3 -3
  56. package/documentation/wiki-mk/doc-context.d.ts +8 -0
  57. package/documentation/wiki-mk/doc-context.js +4 -0
  58. package/documentation/wiki-normalized-ast.d.ts +1 -1
  59. package/documentation/wiki-normalized-ast.js +9 -6
  60. package/linter/linter-format.d.ts +10 -0
  61. package/linter/linter-format.js +15 -0
  62. package/linter/rules/absolute-path.js +3 -3
  63. package/linter/rules/file-path-validity.js +1 -1
  64. package/package.json +1 -1
  65. package/project/plugins/file-plugins/files/flowr-description-file.d.ts +5 -0
  66. package/project/plugins/file-plugins/files/flowr-description-file.js +8 -0
  67. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.d.ts +1 -1
  68. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +4 -5
  69. package/queries/catalog/dependencies-query/dependencies-query-executor.js +2 -1
  70. package/queries/catalog/dependencies-query/dependencies-query-format.js +6 -5
  71. package/queries/catalog/does-call-query/does-call-query-executor.js +3 -3
  72. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.d.ts +1 -1
  73. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +2 -2
  74. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +1 -1
  75. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +1 -1
  76. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.d.ts +1 -1
  77. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.js +1 -1
  78. package/queries/query-print.d.ts +1 -1
  79. package/queries/query-print.js +4 -3
  80. package/r-bridge/lang-4.x/ast/model/model.d.ts +151 -4
  81. package/r-bridge/lang-4.x/ast/model/model.js +249 -0
  82. package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.d.ts +11 -1
  83. package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.js +13 -0
  84. package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +19 -1
  85. package/r-bridge/lang-4.x/ast/model/nodes/r-access.js +26 -0
  86. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +36 -3
  87. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.js +48 -13
  88. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +16 -1
  89. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.js +21 -0
  90. package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +11 -1
  91. package/r-bridge/lang-4.x/ast/model/nodes/r-break.js +14 -0
  92. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +8 -2
  93. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.js +11 -5
  94. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +23 -1
  95. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.js +32 -0
  96. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +11 -1
  97. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.js +14 -0
  98. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +19 -1
  99. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +26 -1
  100. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +11 -1
  101. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.js +14 -0
  102. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +11 -1
  103. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.js +14 -0
  104. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +12 -2
  105. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.js +14 -0
  106. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +20 -2
  107. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.js +26 -0
  108. package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +12 -2
  109. package/r-bridge/lang-4.x/ast/model/nodes/r-next.js +14 -0
  110. package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +8 -2
  111. package/r-bridge/lang-4.x/ast/model/nodes/r-number.js +11 -5
  112. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +17 -1
  113. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.js +22 -0
  114. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +16 -1
  115. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.js +22 -0
  116. package/r-bridge/lang-4.x/ast/model/nodes/r-project.d.ts +45 -8
  117. package/r-bridge/lang-4.x/ast/model/nodes/r-project.js +57 -16
  118. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +12 -2
  119. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.js +14 -0
  120. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +15 -3
  121. package/r-bridge/lang-4.x/ast/model/nodes/r-string.js +21 -6
  122. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +21 -6
  123. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.js +22 -5
  124. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +16 -1
  125. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.js +21 -0
  126. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +11 -1
  127. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.js +14 -0
  128. package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +39 -2
  129. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +52 -9
  130. package/r-bridge/lang-4.x/ast/model/processing/visitor.d.ts +8 -7
  131. package/r-bridge/lang-4.x/ast/model/processing/visitor.js +6 -13
  132. package/r-bridge/lang-4.x/ast/parser/json/parser.d.ts +1 -1
  133. package/r-bridge/lang-4.x/ast/parser/json/parser.js +1 -1
  134. package/r-bridge/lang-4.x/ast/parser/main/internal/expression/normalize-expression.js +4 -2
  135. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-number.js +1 -1
  136. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-string.js +2 -2
  137. package/r-bridge/lang-4.x/convert-values.d.ts +14 -5
  138. package/r-bridge/lang-4.x/convert-values.js +76 -72
  139. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +2 -2
  140. package/r-bridge/roxygen2/roxygen-parse.js +1 -1
  141. package/r-bridge/shell-executor.js +1 -1
  142. package/reconstruct/auto-select/magic-comments.js +4 -4
  143. package/reconstruct/reconstruct.js +2 -1
  144. package/search/search-executor/search-generators.js +2 -2
  145. package/slicing/criterion/filters/all-variables.js +1 -1
  146. package/slicing/criterion/parse.d.ts +1 -1
  147. package/slicing/criterion/parse.js +5 -3
  148. package/slicing/static/slice-call.d.ts +1 -1
  149. package/slicing/static/slice-call.js +2 -2
  150. package/statistics/features/supported/assignments/assignments.js +2 -2
  151. package/statistics/features/supported/control-flow/control-flow.js +2 -2
  152. package/statistics/features/supported/data-access/data-access.js +4 -3
  153. package/statistics/features/supported/defined-functions/defined-functions.js +9 -8
  154. package/statistics/features/supported/expression-list/statistics-expression-list.js +2 -2
  155. package/statistics/features/supported/loops/loops.js +6 -5
  156. package/statistics/features/supported/used-functions/used-functions.js +2 -2
  157. package/statistics/features/supported/variables/variables.js +8 -8
  158. package/util/mermaid/ast.js +2 -2
  159. package/util/mermaid/cfg.js +3 -4
  160. package/util/mermaid/dfg.d.ts +1 -1
  161. package/util/mermaid/dfg.js +9 -9
  162. package/util/simple-df/dfg-ascii.js +1 -1
  163. package/util/version.js +1 -1
  164. package/r-bridge/lang-4.x/ast/model/collect.d.ts +0 -10
  165. package/r-bridge/lang-4.x/ast/model/collect.js +0 -25
@@ -1,5 +1,5 @@
1
- import type { RAstNodeBase, Location, NoInfo } from '../model';
2
- import type { RType } from '../type';
1
+ import type { RAstNodeBase, Location, NoInfo, RNode } from '../model';
2
+ import { RType } from '../type';
3
3
  import type { RExpressionList } from './r-expression-list';
4
4
  /**
5
5
  * ```r
@@ -10,3 +10,13 @@ export interface RRepeatLoop<Info = NoInfo> extends RAstNodeBase<Info>, Location
10
10
  readonly type: RType.RepeatLoop;
11
11
  body: RExpressionList<Info>;
12
12
  }
13
+ /**
14
+ * Helper for working with {@link RRepeatLoop} AST nodes.
15
+ */
16
+ export declare const RRepeatLoop: {
17
+ readonly name: "RRepeatLoop";
18
+ /**
19
+ * Type guard for RRepeatLoop nodes.
20
+ */
21
+ readonly is: <Info = object>(this: void, node: RNode<Info> | undefined) => node is RRepeatLoop<Info>;
22
+ };
@@ -1,3 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RRepeatLoop = void 0;
4
+ const type_1 = require("../type");
5
+ /**
6
+ * Helper for working with {@link RRepeatLoop} AST nodes.
7
+ */
8
+ exports.RRepeatLoop = {
9
+ name: 'RRepeatLoop',
10
+ /**
11
+ * Type guard for RRepeatLoop nodes.
12
+ */
13
+ is(node) {
14
+ return node?.type === type_1.RType.RepeatLoop;
15
+ }
16
+ };
3
17
  //# sourceMappingURL=r-repeat-loop.js.map
@@ -1,6 +1,7 @@
1
1
  import type { Leaf, Location, NoInfo, RNode } from '../model';
2
2
  import type { RStringValue } from '../../../convert-values';
3
3
  import { RType } from '../type';
4
+ import { SemVer } from 'semver';
4
5
  /**
5
6
  * Represents a string like `"hello"`, including raw strings like `r"(hello)"`.
6
7
  * @see {@link isRString} - to check whether a node is an R string
@@ -10,7 +11,18 @@ export interface RString<Info = NoInfo> extends Leaf<Info>, Location {
10
11
  content: RStringValue;
11
12
  }
12
13
  /**
13
- * Type guard for RString nodes.
14
- * @see {@link RString}
14
+ * Helper for working with {@link RString} AST nodes.
15
15
  */
16
- export declare function isRString(node: RNode | undefined): node is RString;
16
+ export declare const RString: {
17
+ name: string;
18
+ /**
19
+ * Type guard for RString nodes.
20
+ * @see {@link RString}
21
+ */
22
+ is<Info = object>(this: void, node: RNode<Info> | undefined): node is RString<Info>;
23
+ /**
24
+ * Returns the minimum R version that supports raw strings (in a stable format).
25
+ * @see {@link RString}
26
+ */
27
+ rawStringAvailableFromRVersion(): SemVer;
28
+ };
@@ -1,12 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isRString = isRString;
3
+ exports.RString = void 0;
4
4
  const type_1 = require("../type");
5
+ const semver_1 = require("semver");
6
+ const versions_1 = require("../versions");
5
7
  /**
6
- * Type guard for RString nodes.
7
- * @see {@link RString}
8
+ * Helper for working with {@link RString} AST nodes.
8
9
  */
9
- function isRString(node) {
10
- return node?.type === type_1.RType.String;
11
- }
10
+ exports.RString = {
11
+ name: 'RString',
12
+ /**
13
+ * Type guard for RString nodes.
14
+ * @see {@link RString}
15
+ */
16
+ is(node) {
17
+ return node?.type === type_1.RType.String;
18
+ },
19
+ /**
20
+ * Returns the minimum R version that supports raw strings (in a stable format).
21
+ * @see {@link RString}
22
+ */
23
+ rawStringAvailableFromRVersion() {
24
+ return new semver_1.SemVer(versions_1.MIN_VERSION_RAW_STABLE);
25
+ }
26
+ };
12
27
  //# sourceMappingURL=r-string.js.map
@@ -1,10 +1,7 @@
1
- import type { Leaf, Location, NoInfo } from '../model';
2
- import type { RType } from '../type';
1
+ import type { Leaf, Location, NoInfo, RNode } from '../model';
2
+ import { RType } from '../type';
3
+ import { RNa, RNull } from '../../../convert-values';
3
4
  import type { Identifier } from '../../../../../dataflow/environments/identifier';
4
- /**
5
- *
6
- */
7
- export declare function isSpecialSymbol(symbol: RSymbol): boolean;
8
5
  /**
9
6
  * Represents identifiers (variables) such as `x` in `x <- 42` or `a::foo` in `a::foo()`.
10
7
  * See {@link Identifier} for more information about how identifiers are represented.
@@ -15,3 +12,21 @@ export interface RSymbol<Info = NoInfo, T extends Identifier = Identifier> exten
15
12
  readonly type: RType.Symbol;
16
13
  content: T;
17
14
  }
15
+ /**
16
+ * Helper for working with {@link RSymbol} AST nodes.
17
+ */
18
+ export declare const RSymbol: {
19
+ readonly name: "RSymbol";
20
+ /**
21
+ * Type guard for {@link RSymbol} nodes.
22
+ * @see {@link RSymbol.isSpecial} - to check whether a symbol is a special symbol like `NA` or `NULL`
23
+ */
24
+ readonly is: <OtherInfo = object>(this: void, node: RNode<OtherInfo> | undefined) => node is RSymbol<OtherInfo>;
25
+ /**
26
+ * Type guard for special symbols, i.e. `NA` and `NULL`.
27
+ * @see {@link RNa} - for the value of `NA`
28
+ * @see {@link RNull} - for the value of `NULL`
29
+ * @see {@link RSymbol.is} - to check whether a node is a symbol at all
30
+ */
31
+ readonly isSpecial: <OtherInfo = object>(this: void, node: RNode<OtherInfo> | undefined) => node is RSymbol<OtherInfo, typeof RNull | typeof RNa>;
32
+ };
@@ -1,11 +1,28 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isSpecialSymbol = isSpecialSymbol;
3
+ exports.RSymbol = void 0;
4
+ const type_1 = require("../type");
4
5
  const convert_values_1 = require("../../../convert-values");
5
6
  /**
6
- *
7
+ * Helper for working with {@link RSymbol} AST nodes.
7
8
  */
8
- function isSpecialSymbol(symbol) {
9
- return symbol.content === convert_values_1.RNull || symbol.content === convert_values_1.RNa;
10
- }
9
+ exports.RSymbol = {
10
+ name: 'RSymbol',
11
+ /**
12
+ * Type guard for {@link RSymbol} nodes.
13
+ * @see {@link RSymbol.isSpecial} - to check whether a symbol is a special symbol like `NA` or `NULL`
14
+ */
15
+ is(node) {
16
+ return node?.type === type_1.RType.Symbol;
17
+ },
18
+ /**
19
+ * Type guard for special symbols, i.e. `NA` and `NULL`.
20
+ * @see {@link RNa} - for the value of `NA`
21
+ * @see {@link RNull} - for the value of `NULL`
22
+ * @see {@link RSymbol.is} - to check whether a node is a symbol at all
23
+ */
24
+ isSpecial(node) {
25
+ return exports.RSymbol.is(node) && (node.content === convert_values_1.RNull || node.content === convert_values_1.RNa);
26
+ }
27
+ };
11
28
  //# sourceMappingURL=r-symbol.js.map
@@ -1,5 +1,6 @@
1
1
  import type { RAstNodeBase, Location, NoInfo, RNode } from '../model';
2
- import type { RType } from '../type';
2
+ import { RType } from '../type';
3
+ import type { OperatorInformationValue } from '../operators';
3
4
  /**
4
5
  * Unary operations like `+` and `-`
5
6
  */
@@ -8,3 +9,17 @@ export interface RUnaryOp<Info = NoInfo> extends RAstNodeBase<Info>, Location {
8
9
  operator: string;
9
10
  operand: RNode<Info>;
10
11
  }
12
+ /**
13
+ * Helper for working with {@link RUnaryOp} AST nodes.
14
+ */
15
+ export declare const RUnaryOp: {
16
+ readonly name: "RUnaryOp";
17
+ /**
18
+ * Type guard for {@link RUnaryOp} nodes.
19
+ */
20
+ readonly is: <Info = object>(this: void, node: RNode<Info> | undefined) => node is RUnaryOp<Info>;
21
+ /**
22
+ * Get the operator information for a binary operator node.
23
+ */
24
+ readonly getOperatorInfo: <Info = object>(node: RUnaryOp<Info>) => OperatorInformationValue | undefined;
25
+ };
@@ -1,3 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RUnaryOp = void 0;
4
+ const type_1 = require("../type");
5
+ const operators_1 = require("../operators");
6
+ /**
7
+ * Helper for working with {@link RUnaryOp} AST nodes.
8
+ */
9
+ exports.RUnaryOp = {
10
+ name: 'RUnaryOp',
11
+ /**
12
+ * Type guard for {@link RUnaryOp} nodes.
13
+ */
14
+ is(node) {
15
+ return node?.type === type_1.RType.UnaryOp;
16
+ },
17
+ /**
18
+ * Get the operator information for a binary operator node.
19
+ */
20
+ getOperatorInfo(node) {
21
+ return operators_1.OperatorDatabase[node.operator];
22
+ }
23
+ };
3
24
  //# sourceMappingURL=r-unary-op.js.map
@@ -1,5 +1,5 @@
1
1
  import type { RAstNodeBase, Location, NoInfo, RNode } from '../model';
2
- import type { RType } from '../type';
2
+ import { RType } from '../type';
3
3
  import type { RExpressionList } from './r-expression-list';
4
4
  /**
5
5
  * ```r
@@ -11,3 +11,13 @@ export interface RWhileLoop<Info = NoInfo> extends RAstNodeBase<Info>, Location
11
11
  condition: RNode<Info>;
12
12
  body: RExpressionList<Info>;
13
13
  }
14
+ /**
15
+ * Helper for working with {@link RWhileLoop} AST nodes.
16
+ */
17
+ export declare const RWhileLoop: {
18
+ readonly name: "RWhileLoop";
19
+ /**
20
+ * Type guard for {@link RWhileLoop} nodes.
21
+ */
22
+ readonly is: <Info = object>(this: void, node: RNode<Info> | undefined) => node is RWhileLoop<Info>;
23
+ };
@@ -1,3 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RWhileLoop = void 0;
4
+ const type_1 = require("../type");
5
+ /**
6
+ * Helper for working with {@link RWhileLoop} AST nodes.
7
+ */
8
+ exports.RWhileLoop = {
9
+ name: 'RWhileLoop',
10
+ /**
11
+ * Type guard for {@link RWhileLoop} nodes.
12
+ */
13
+ is(node) {
14
+ return node?.type === type_1.RType.WhileLoop;
15
+ }
16
+ };
3
17
  //# sourceMappingURL=r-while-loop.js.map
@@ -4,8 +4,45 @@ import type { DataflowGraph } from '../../../../../dataflow/graph/graph';
4
4
  export type NodeId<T extends string | number = string | number> = T & {
5
5
  __brand?: 'node-id';
6
6
  };
7
- /** used so that we do not have to store strings for the default numeric ids */
8
- export declare function normalizeIdToNumberIfPossible(id: NodeId): NodeId;
7
+ /**
8
+ * A variant of {@link NodeId} that represents built-in functions or operators. The string is prefixed with `built-in:` to avoid confusion with other node ids.
9
+ */
10
+ export type BuiltIn<T extends string = string> = `built-in:${T}`;
11
+ /**
12
+ * The type of the id assigned to each node. Branded to avoid problematic usages with other string or numeric types.
13
+ * The default ids are numeric, but we use a branded type to avoid confusion with other numeric types.
14
+ * Custom ids or scoped ids can be strings, but they will be normalized to numbers if they are numeric strings.
15
+ */
16
+ export declare const NodeId: {
17
+ readonly name: "NodeId";
18
+ /**
19
+ * Normalizes a node id by converting numeric strings to numbers.
20
+ * This allows us to use numeric ids without storing them as strings, while still allowing custom string ids if needed.
21
+ */
22
+ readonly normalize: (this: void, id: NodeId) => NodeId;
23
+ /**
24
+ * The prefix used for built-in function or operator ids.
25
+ */
26
+ readonly builtInPrefix: "built-in:";
27
+ /**
28
+ * Checks if a given node id is a built-in function or operator id by checking if it is a string that starts with the built-in prefix.
29
+ * @see {@link toBuiltIn} - to convert a built-in function or operator name to a built-in id
30
+ * @see {@link fromBuiltIn} - to recover the built-in function or operator name from a built-in id
31
+ */
32
+ readonly isBuiltIn: (this: void, id: BuiltIn | NodeId | undefined) => id is BuiltIn;
33
+ /**
34
+ * Converts a built-in function or operator name to a built-in id by prefixing it with the built-in prefix.
35
+ * @see {@link isBuiltIn} - to check if a given node id is a built-in function or operator id
36
+ * @see {@link fromBuiltIn} - to recover the built-in function or operator name from a built-in id
37
+ */
38
+ readonly toBuiltIn: <T extends string>(this: void, name: T) => BuiltIn<T>;
39
+ /**
40
+ * Recovers the built-in function or operator name from a built-in id by removing the built-in prefix.
41
+ * @see {@link isBuiltIn} - to check if a given node id is a built-in function or operator id
42
+ * @see {@link toBuiltIn} - to convert a built-in function or operator name to a built-in id
43
+ */
44
+ readonly fromBuiltIn: <T extends string>(this: void, id: BuiltIn<T>) => T;
45
+ };
9
46
  /**
10
47
  * Recovers the lexeme of a {@link RNode|node} from its id in the {@link AstIdMap|id map}.
11
48
  * @see {@link recoverContent} - to recover the content of a node
@@ -1,20 +1,63 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.normalizeIdToNumberIfPossible = normalizeIdToNumberIfPossible;
3
+ exports.NodeId = void 0;
4
4
  exports.recoverName = recoverName;
5
5
  exports.recoverContent = recoverContent;
6
6
  const vertex_1 = require("../../../../../dataflow/graph/vertex");
7
7
  const retriever_1 = require("../../../../retriever");
8
8
  const identifier_1 = require("../../../../../dataflow/environments/identifier");
9
- const numIdRegex = /^\d+$/;
10
- /** used so that we do not have to store strings for the default numeric ids */
11
- function normalizeIdToNumberIfPossible(id) {
12
- // check if string is number
13
- if (typeof id === 'string' && numIdRegex.test(id)) {
14
- return Number(id);
9
+ /**
10
+ * The type of the id assigned to each node. Branded to avoid problematic usages with other string or numeric types.
11
+ * The default ids are numeric, but we use a branded type to avoid confusion with other numeric types.
12
+ * Custom ids or scoped ids can be strings, but they will be normalized to numbers if they are numeric strings.
13
+ */
14
+ exports.NodeId = {
15
+ name: 'NodeId',
16
+ /**
17
+ * Normalizes a node id by converting numeric strings to numbers.
18
+ * This allows us to use numeric ids without storing them as strings, while still allowing custom string ids if needed.
19
+ */
20
+ normalize(id) {
21
+ // check if string is number
22
+ if (typeof id === 'string') {
23
+ /* typescript is a beautiful converter */
24
+ const num = +id;
25
+ if (!Number.isNaN(num)) {
26
+ return num;
27
+ }
28
+ }
29
+ return id;
30
+ },
31
+ /**
32
+ * The prefix used for built-in function or operator ids.
33
+ */
34
+ builtInPrefix: 'built-in:',
35
+ /**
36
+ * Checks if a given node id is a built-in function or operator id by checking if it is a string that starts with the built-in prefix.
37
+ * @see {@link toBuiltIn} - to convert a built-in function or operator name to a built-in id
38
+ * @see {@link fromBuiltIn} - to recover the built-in function or operator name from a built-in id
39
+ */
40
+ isBuiltIn(id) {
41
+ return typeof id === 'string' && id.startsWith(exports.NodeId.builtInPrefix);
42
+ },
43
+ /**
44
+ * Converts a built-in function or operator name to a built-in id by prefixing it with the built-in prefix.
45
+ * @see {@link isBuiltIn} - to check if a given node id is a built-in function or operator id
46
+ * @see {@link fromBuiltIn} - to recover the built-in function or operator name from a built-in id
47
+ */
48
+ toBuiltIn(name) {
49
+ return `built-in:${name}`;
50
+ },
51
+ /**
52
+ * Recovers the built-in function or operator name from a built-in id by removing the built-in prefix.
53
+ * @see {@link isBuiltIn} - to check if a given node id is a built-in function or operator id
54
+ * @see {@link toBuiltIn} - to convert a built-in function or operator name to a built-in id
55
+ */
56
+ fromBuiltIn(id) {
57
+ return id.slice(builtInPrefixLength);
15
58
  }
16
- return id;
17
- }
59
+ };
60
+ const builtInPrefixLength = exports.NodeId.builtInPrefix.length;
18
61
  /**
19
62
  * Recovers the lexeme of a {@link RNode|node} from its id in the {@link AstIdMap|id map}.
20
63
  * @see {@link recoverContent} - to recover the content of a node
@@ -1,12 +1,13 @@
1
1
  import type { NoInfo, RNode } from '../model';
2
+ import type { EmptyArgument } from '../nodes/r-function-call';
2
3
  /** Return `true` to stop visiting from this node (i.e., do not continue to visit this node *and* the children) */
3
4
  export type OnEnter<OtherInfo> = (node: RNode<OtherInfo>) => (boolean | void);
4
5
  /** Similar to {@link OnEnter} but called when leaving a node. Can't stop exploration as the subtree is already visited! */
5
6
  export type OnExit<OtherInfo> = (node: RNode<OtherInfo>) => void;
6
- /**
7
- * Visits all node ids within a tree given by a respective root node using a depth-first search with prefix order.
8
- * @param nodes - The root id nodes to start collecting from
9
- * @param onVisit - Called before visiting the subtree of each node. Can be used to stop visiting the subtree starting with this node (return `true` stop)
10
- * @param onExit - Called after the subtree of a node has been visited, called for leafs too (even though their subtree is empty)
11
- */
12
- export declare function visitAst<OtherInfo = NoInfo>(nodes: RNode<OtherInfo> | (RNode<OtherInfo> | null | undefined)[] | undefined, onVisit?: OnEnter<OtherInfo>, onExit?: OnExit<OtherInfo>): void;
7
+ export declare class NodeVisitor<OtherInfo = NoInfo> {
8
+ private readonly onEnter?;
9
+ private readonly onExit?;
10
+ constructor(onEnter?: OnEnter<OtherInfo>, onExit?: OnExit<OtherInfo>);
11
+ private visitSingle;
12
+ visit(nodes: RNode<OtherInfo> | readonly (RNode<OtherInfo> | null | undefined | typeof EmptyArgument)[] | undefined | null): void;
13
+ }
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.visitAst = visitAst;
3
+ exports.NodeVisitor = void 0;
4
4
  const type_1 = require("../type");
5
5
  const assert_1 = require("../../../../../util/assert");
6
- const r_function_call_1 = require("../nodes/r-function-call");
6
+ const r_access_1 = require("../nodes/r-access");
7
+ const graph_1 = require("../../../../../dataflow/graph/graph");
7
8
  // capsuled as a class to avoid passing onExit and onEnter on *each* visit call
8
9
  class NodeVisitor {
9
10
  onEnter;
@@ -66,7 +67,7 @@ class NodeVisitor {
66
67
  break;
67
68
  case type_1.RType.Access:
68
69
  this.visitSingle(node.accessed);
69
- if (node.operator === '[' || node.operator === '[[') {
70
+ if (r_access_1.RAccess.isIndex(node)) {
70
71
  this.visit(node.access);
71
72
  }
72
73
  break;
@@ -89,7 +90,7 @@ class NodeVisitor {
89
90
  if (Array.isArray(nodes)) {
90
91
  const n = nodes;
91
92
  for (const node of n) {
92
- if (node && node !== r_function_call_1.EmptyArgument) {
93
+ if (node && graph_1.FunctionArgument.isNotEmpty(node)) {
93
94
  this.visitSingle(node);
94
95
  }
95
96
  }
@@ -99,13 +100,5 @@ class NodeVisitor {
99
100
  }
100
101
  }
101
102
  }
102
- /**
103
- * Visits all node ids within a tree given by a respective root node using a depth-first search with prefix order.
104
- * @param nodes - The root id nodes to start collecting from
105
- * @param onVisit - Called before visiting the subtree of each node. Can be used to stop visiting the subtree starting with this node (return `true` stop)
106
- * @param onExit - Called after the subtree of a node has been visited, called for leafs too (even though their subtree is empty)
107
- */
108
- function visitAst(nodes, onVisit, onExit) {
109
- return new NodeVisitor(onVisit, onExit).visit(nodes);
110
- }
103
+ exports.NodeVisitor = NodeVisitor;
111
104
  //# sourceMappingURL=visitor.js.map
@@ -3,7 +3,7 @@ import type { NoInfo } from '../../model/model';
3
3
  import type { ParseStepOutput, ParseStepOutputSingleFile } from '../../../../parser';
4
4
  import { type FlowrConfigOptions } from '../../../../../config';
5
5
  import type { Tree } from 'web-tree-sitter';
6
- import type { RProject } from '../../model/nodes/r-project';
6
+ import { RProject } from '../../model/nodes/r-project';
7
7
  export declare const parseLog: import("tslog").Logger<import("tslog").ILogObj>;
8
8
  /**
9
9
  * Take the output as produced by the parse step and normalize the AST from the R parser.
@@ -18,7 +18,7 @@ exports.parseLog = log_1.log.getSubLogger({ name: 'ast-parser' });
18
18
  * @see {@link normalizeTreeSitter} - for a version that normalizes the AST from the TreeSitter parser
19
19
  */
20
20
  function normalize(parsed, getId = (0, decorate_1.deterministicCountingIdGenerator)(0)) {
21
- return (0, decorate_1.decorateAst)((0, r_project_1.mergeProjects)(parsed.files.map(normalizeButNotDecorated)), { getId });
21
+ return (0, decorate_1.decorateAst)(r_project_1.RProject.merge(parsed.files.map(normalizeButNotDecorated)), { getId });
22
22
  }
23
23
  /**
24
24
  * Take the output as produced by the parse step and normalize the AST from the R parser.
@@ -9,6 +9,8 @@ const normalize_call_1 = require("../functions/normalize-call");
9
9
  const normalize_definition_1 = require("../functions/normalize-definition");
10
10
  const type_1 = require("../../../../model/type");
11
11
  const normalize_comment_1 = require("../other/normalize-comment");
12
+ const r_delimiter_1 = require("../../../../model/nodes/info/r-delimiter");
13
+ const r_comment_1 = require("../../../../model/nodes/r-comment");
12
14
  /**
13
15
  * Returns an expression list if there are multiple children, otherwise returns the single child directly with no expr wrapper
14
16
  * @param data - The data used by the parser (see {@link NormalizerData})
@@ -36,10 +38,10 @@ function normalizeExpression(data, entry) {
36
38
  return maybeFunctionDefinition;
37
39
  }
38
40
  const children = (0, normalize_expressions_1.normalizeExpressions)(childData, childrenSource);
39
- const [delimiters, nodes] = (0, arrays_1.partition)(children, x => x.type === type_1.RType.Delimiter || x.type === type_1.RType.Comment);
41
+ const [delimiters, nodes] = (0, arrays_1.partition)(children, x => r_delimiter_1.RDelimiter.is(x) || r_comment_1.RComment.is(x));
40
42
  if (nodes.length === 1) {
41
43
  const result = nodes[0];
42
- result.info.adToks = [...result.info.adToks ?? [], ...delimiters];
44
+ result.info.adToks = result.info.adToks ? result.info.adToks.concat(delimiters) : delimiters.slice();
43
45
  return result;
44
46
  }
45
47
  else {
@@ -41,7 +41,7 @@ function normalizeNumber(data, obj) {
41
41
  return {
42
42
  ...common,
43
43
  type: type_1.RType.Number,
44
- content: (0, convert_values_1.number2ts)(content)
44
+ content: convert_values_1.RNumberValue.fromRLexeme(content)
45
45
  };
46
46
  }
47
47
  }
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizeString = normalizeString;
4
4
  const normalize_meta_1 = require("../../normalize-meta");
5
5
  const assert_1 = require("../../../../../../../util/assert");
6
- const convert_values_1 = require("../../../../../convert-values");
7
6
  const type_1 = require("../../../../model/type");
7
+ const convert_values_1 = require("../../../../../convert-values");
8
8
  /**
9
9
  * Normalize the given object as a R string (see {@link string2ts}).
10
10
  * This requires you to check the corresponding name beforehand.
@@ -23,7 +23,7 @@ function normalizeString(data, obj) {
23
23
  return {
24
24
  type: type_1.RType.String,
25
25
  location,
26
- content: (0, convert_values_1.string2ts)(stringContent),
26
+ content: convert_values_1.RStringValue.fromRLexeme(stringContent),
27
27
  lexeme: stringContent,
28
28
  info: {
29
29
  fullRange: data.currentRange,
@@ -30,10 +30,13 @@ export interface RNumberValue {
30
30
  /** see {@link RImaginaryMarker}, compound imaginary numbers are expressions in R */
31
31
  complexNumber: boolean;
32
32
  }
33
+ export declare const RNumberValue: {
34
+ readonly name: "RNumberValue";
35
+ readonly fromRLexeme: (this: void, value: string) => RNumberValue;
36
+ };
33
37
  /**
34
- * Convert a valid R number into a {@link RNumberValue}.
38
+ * Represents a string value in R, including the type of quotes used and whether it is a raw string.
35
39
  */
36
- export declare function number2ts(value: string): RNumberValue;
37
40
  export interface RStringValue {
38
41
  str: string;
39
42
  /** from the R-language definition a string is either delimited by a pair of single or double quotes, 'none' strings are syntactically unquoted but treated as strings */
@@ -42,10 +45,16 @@ export interface RStringValue {
42
45
  flag?: 'raw';
43
46
  }
44
47
  /**
45
- * Convert a valid R string into a {@link RStringValue}.
46
- * @throws {@link ValueConversionError} if the string has an unknown starting quote
48
+ * Checks whether the given string is an R string literal (including raw strings).
47
49
  */
48
- export declare function string2ts(value: string): RStringValue;
50
+ export declare const RStringValue: {
51
+ readonly name: "RStringValue";
52
+ /**
53
+ * Convert a valid R string into a {@link RStringValue}.
54
+ * @throws {@link ValueConversionError} if the string has an unknown starting quote
55
+ */
56
+ readonly fromRLexeme: (this: void, value: string) => RStringValue;
57
+ };
49
58
  export declare const RNa = "NA";
50
59
  export declare const RNull = "NULL";
51
60
  /**