@eagleoutice/flowr 1.4.1 → 1.5.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.
Files changed (300) hide show
  1. package/README.md +3 -3
  2. package/abstract-interpretation/processor.js +9 -3
  3. package/config.d.ts +16 -0
  4. package/config.js +75 -0
  5. package/core/input.d.ts +1 -1
  6. package/core/output.d.ts +1 -2
  7. package/core/print/parse-printer.d.ts +1 -2
  8. package/core/print/parse-printer.js +6 -4
  9. package/core/print/slice-diff-ansi.js +7 -7
  10. package/core/slicer.js +4 -8
  11. package/core/steps.d.ts +355 -31
  12. package/core/steps.js +7 -14
  13. package/dataflow/environments/environment.js +8 -0
  14. package/dataflow/environments/register.js +1 -0
  15. package/dataflow/extractor.d.ts +2 -2
  16. package/dataflow/extractor.js +10 -2
  17. package/dataflow/internal/process/functions/function-call.js +7 -1
  18. package/dataflow/internal/process/functions/source.d.ts +8 -0
  19. package/dataflow/internal/process/functions/source.js +81 -0
  20. package/dataflow/processor.d.ts +10 -1
  21. package/index.d.ts +0 -2
  22. package/index.js +0 -2
  23. package/package.json +75 -202
  24. package/r-bridge/lang-4.x/ast/index.d.ts +1 -0
  25. package/r-bridge/lang-4.x/ast/index.js +3 -0
  26. package/r-bridge/lang-4.x/ast/model/processing/decorate.d.ts +2 -0
  27. package/r-bridge/lang-4.x/ast/model/processing/decorate.js +6 -1
  28. package/r-bridge/lang-4.x/ast/parser/json/format.d.ts +14 -0
  29. package/r-bridge/lang-4.x/ast/parser/json/format.js +26 -0
  30. package/r-bridge/lang-4.x/ast/parser/json/parser.d.ts +7 -0
  31. package/r-bridge/lang-4.x/ast/parser/json/parser.js +57 -0
  32. package/r-bridge/lang-4.x/ast/parser/xml/data.d.ts +0 -3
  33. package/r-bridge/lang-4.x/ast/parser/xml/index.d.ts +0 -2
  34. package/r-bridge/lang-4.x/ast/parser/xml/index.js +0 -2
  35. package/r-bridge/lang-4.x/ast/parser/xml/input-format.d.ts +5 -1
  36. package/r-bridge/lang-4.x/ast/parser/xml/input-format.js +7 -10
  37. package/r-bridge/lang-4.x/ast/parser/xml/internal/access.js +2 -2
  38. package/r-bridge/lang-4.x/ast/parser/xml/internal/control/if-then-else.js +1 -1
  39. package/r-bridge/lang-4.x/ast/parser/xml/internal/control/if-then.js +2 -2
  40. package/r-bridge/lang-4.x/ast/parser/xml/internal/expression/expression.js +4 -4
  41. package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/argument.js +2 -2
  42. package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/call.js +4 -4
  43. package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/definition.js +2 -2
  44. package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/parameter.js +2 -2
  45. package/r-bridge/lang-4.x/ast/parser/xml/internal/index.d.ts +0 -1
  46. package/r-bridge/lang-4.x/ast/parser/xml/internal/index.js +0 -1
  47. package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/break.js +2 -2
  48. package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/for.js +3 -6
  49. package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/next.js +2 -2
  50. package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/repeat.js +2 -2
  51. package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/while.js +2 -2
  52. package/r-bridge/lang-4.x/ast/parser/xml/internal/meta.d.ts +6 -11
  53. package/r-bridge/lang-4.x/ast/parser/xml/internal/meta.js +15 -23
  54. package/r-bridge/lang-4.x/ast/parser/xml/internal/operators/binary.js +6 -6
  55. package/r-bridge/lang-4.x/ast/parser/xml/internal/operators/unary.js +3 -3
  56. package/r-bridge/lang-4.x/ast/parser/xml/internal/other/comment.js +2 -2
  57. package/r-bridge/lang-4.x/ast/parser/xml/internal/other/line-directive.js +2 -2
  58. package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/elements.js +3 -3
  59. package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/root.js +3 -4
  60. package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/single-element.js +2 -2
  61. package/r-bridge/lang-4.x/ast/parser/xml/internal/values/number.js +2 -2
  62. package/r-bridge/lang-4.x/ast/parser/xml/internal/values/string.js +2 -2
  63. package/r-bridge/lang-4.x/ast/parser/xml/internal/values/symbol.js +4 -4
  64. package/r-bridge/lang-4.x/values.d.ts +0 -1
  65. package/r-bridge/lang-4.x/values.js +14 -6
  66. package/r-bridge/retriever.d.ts +25 -21
  67. package/r-bridge/retriever.js +73 -23
  68. package/r-bridge/shell-executor.d.ts +3 -17
  69. package/r-bridge/shell-executor.js +9 -78
  70. package/r-bridge/shell.d.ts +5 -27
  71. package/r-bridge/shell.js +31 -92
  72. package/{statistics/output → util}/ansi.js +1 -1
  73. package/util/args.d.ts +8 -4
  74. package/util/args.js +11 -4
  75. package/util/cfg/visitor.js +1 -1
  76. package/util/files.d.ts +6 -0
  77. package/util/files.js +11 -1
  78. package/util/log.js +3 -0
  79. package/util/{summarizer/summarizer.d.ts → summarizer.d.ts} +15 -1
  80. package/util/summarizer.js +37 -0
  81. package/util/version.d.ts +2 -0
  82. package/util/version.js +10 -0
  83. package/benchmark/index.d.ts +0 -3
  84. package/benchmark/index.js +0 -20
  85. package/benchmark/slicer.d.ts +0 -101
  86. package/benchmark/slicer.js +0 -225
  87. package/benchmark/stats/index.d.ts +0 -10
  88. package/benchmark/stats/index.js +0 -27
  89. package/benchmark/stats/print.d.ts +0 -7
  90. package/benchmark/stats/print.js +0 -157
  91. package/benchmark/stats/stats.d.ts +0 -41
  92. package/benchmark/stats/stats.js +0 -6
  93. package/benchmark/stopwatch.d.ts +0 -35
  94. package/benchmark/stopwatch.js +0 -79
  95. package/cli/benchmark-app.d.ts +0 -9
  96. package/cli/benchmark-app.js +0 -52
  97. package/cli/benchmark-helper-app.d.ts +0 -7
  98. package/cli/benchmark-helper-app.js +0 -60
  99. package/cli/common/features.d.ts +0 -3
  100. package/cli/common/features.js +0 -30
  101. package/cli/common/index.d.ts +0 -2
  102. package/cli/common/index.js +0 -19
  103. package/cli/common/options.d.ts +0 -20
  104. package/cli/common/options.js +0 -82
  105. package/cli/common/script.d.ts +0 -21
  106. package/cli/common/script.js +0 -61
  107. package/cli/common/scripts-info.d.ts +0 -24
  108. package/cli/common/scripts-info.js +0 -69
  109. package/cli/export-quads-app.d.ts +0 -7
  110. package/cli/export-quads-app.js +0 -46
  111. package/cli/repl/commands/cfg.d.ts +0 -3
  112. package/cli/repl/commands/cfg.js +0 -37
  113. package/cli/repl/commands/commands.d.ts +0 -11
  114. package/cli/repl/commands/commands.js +0 -103
  115. package/cli/repl/commands/dataflow.d.ts +0 -3
  116. package/cli/repl/commands/dataflow.js +0 -34
  117. package/cli/repl/commands/execute.d.ts +0 -4
  118. package/cli/repl/commands/execute.js +0 -27
  119. package/cli/repl/commands/index.d.ts +0 -2
  120. package/cli/repl/commands/index.js +0 -19
  121. package/cli/repl/commands/main.d.ts +0 -39
  122. package/cli/repl/commands/main.js +0 -14
  123. package/cli/repl/commands/normalize.d.ts +0 -3
  124. package/cli/repl/commands/normalize.js +0 -34
  125. package/cli/repl/commands/parse.d.ts +0 -2
  126. package/cli/repl/commands/parse.js +0 -109
  127. package/cli/repl/commands/quit.d.ts +0 -2
  128. package/cli/repl/commands/quit.js +0 -12
  129. package/cli/repl/commands/version.d.ts +0 -16
  130. package/cli/repl/commands/version.js +0 -33
  131. package/cli/repl/core.d.ts +0 -39
  132. package/cli/repl/core.js +0 -116
  133. package/cli/repl/execute.d.ts +0 -28
  134. package/cli/repl/execute.js +0 -79
  135. package/cli/repl/index.d.ts +0 -5
  136. package/cli/repl/index.js +0 -22
  137. package/cli/repl/prompt.d.ts +0 -2
  138. package/cli/repl/prompt.js +0 -9
  139. package/cli/repl/server/connection.d.ts +0 -21
  140. package/cli/repl/server/connection.js +0 -218
  141. package/cli/repl/server/messages/analysis.d.ts +0 -71
  142. package/cli/repl/server/messages/analysis.js +0 -21
  143. package/cli/repl/server/messages/error.d.ts +0 -11
  144. package/cli/repl/server/messages/error.js +0 -3
  145. package/cli/repl/server/messages/hello.d.ts +0 -20
  146. package/cli/repl/server/messages/hello.js +0 -3
  147. package/cli/repl/server/messages/index.d.ts +0 -1
  148. package/cli/repl/server/messages/index.js +0 -3
  149. package/cli/repl/server/messages/messages.d.ts +0 -35
  150. package/cli/repl/server/messages/messages.js +0 -40
  151. package/cli/repl/server/messages/repl.d.ts +0 -33
  152. package/cli/repl/server/messages/repl.js +0 -37
  153. package/cli/repl/server/messages/slice.d.ts +0 -25
  154. package/cli/repl/server/messages/slice.js +0 -37
  155. package/cli/repl/server/net.d.ts +0 -49
  156. package/cli/repl/server/net.js +0 -63
  157. package/cli/repl/server/send.d.ts +0 -4
  158. package/cli/repl/server/send.js +0 -18
  159. package/cli/repl/server/server.d.ts +0 -20
  160. package/cli/repl/server/server.js +0 -66
  161. package/cli/repl/server/validate.d.ts +0 -15
  162. package/cli/repl/server/validate.js +0 -34
  163. package/cli/slicer-app.d.ts +0 -11
  164. package/cli/slicer-app.js +0 -81
  165. package/cli/statistics-app.d.ts +0 -11
  166. package/cli/statistics-app.js +0 -98
  167. package/cli/statistics-helper-app.d.ts +0 -11
  168. package/cli/statistics-helper-app.js +0 -83
  169. package/cli/summarizer-app.d.ts +0 -18
  170. package/cli/summarizer-app.js +0 -67
  171. package/flowr.d.ts +0 -27
  172. package/flowr.js +0 -137
  173. package/r-bridge/lang-4.x/ast/parser/xml/config.d.ts +0 -25
  174. package/r-bridge/lang-4.x/ast/parser/xml/config.js +0 -16
  175. package/r-bridge/lang-4.x/ast/parser/xml/internal/xml-to-json.d.ts +0 -9
  176. package/r-bridge/lang-4.x/ast/parser/xml/internal/xml-to-json.js +0 -51
  177. package/r-bridge/lang-4.x/ast/parser/xml/parser.d.ts +0 -17
  178. package/r-bridge/lang-4.x/ast/parser/xml/parser.js +0 -30
  179. package/statistics/features/common-syntax-probability.d.ts +0 -31
  180. package/statistics/features/common-syntax-probability.js +0 -156
  181. package/statistics/features/feature.d.ts +0 -175
  182. package/statistics/features/feature.js +0 -30
  183. package/statistics/features/index.d.ts +0 -1
  184. package/statistics/features/index.js +0 -18
  185. package/statistics/features/post-processing.d.ts +0 -12
  186. package/statistics/features/post-processing.js +0 -21
  187. package/statistics/features/supported/assignments/assignments.d.ts +0 -11
  188. package/statistics/features/supported/assignments/assignments.js +0 -53
  189. package/statistics/features/supported/assignments/index.d.ts +0 -1
  190. package/statistics/features/supported/assignments/index.js +0 -6
  191. package/statistics/features/supported/assignments/post-process.d.ts +0 -3
  192. package/statistics/features/supported/assignments/post-process.js +0 -125
  193. package/statistics/features/supported/comments/comments.d.ts +0 -18
  194. package/statistics/features/supported/comments/comments.js +0 -133
  195. package/statistics/features/supported/comments/index.d.ts +0 -1
  196. package/statistics/features/supported/comments/index.js +0 -6
  197. package/statistics/features/supported/comments/post-process.d.ts +0 -3
  198. package/statistics/features/supported/comments/post-process.js +0 -50
  199. package/statistics/features/supported/control-flow/control-flow.d.ts +0 -17
  200. package/statistics/features/supported/control-flow/control-flow.js +0 -67
  201. package/statistics/features/supported/control-flow/index.d.ts +0 -1
  202. package/statistics/features/supported/control-flow/index.js +0 -6
  203. package/statistics/features/supported/control-flow/post-process.d.ts +0 -3
  204. package/statistics/features/supported/control-flow/post-process.js +0 -65
  205. package/statistics/features/supported/data-access/data-access.d.ts +0 -15
  206. package/statistics/features/supported/data-access/data-access.js +0 -118
  207. package/statistics/features/supported/data-access/index.d.ts +0 -1
  208. package/statistics/features/supported/data-access/index.js +0 -6
  209. package/statistics/features/supported/data-access/post-process.d.ts +0 -3
  210. package/statistics/features/supported/data-access/post-process.js +0 -107
  211. package/statistics/features/supported/defined-functions/defined-functions.d.ts +0 -35
  212. package/statistics/features/supported/defined-functions/defined-functions.js +0 -139
  213. package/statistics/features/supported/defined-functions/index.d.ts +0 -1
  214. package/statistics/features/supported/defined-functions/index.js +0 -6
  215. package/statistics/features/supported/defined-functions/post-process.d.ts +0 -6
  216. package/statistics/features/supported/defined-functions/post-process.js +0 -177
  217. package/statistics/features/supported/expression-list/expression-list.d.ts +0 -9
  218. package/statistics/features/supported/expression-list/expression-list.js +0 -36
  219. package/statistics/features/supported/expression-list/index.d.ts +0 -1
  220. package/statistics/features/supported/expression-list/index.js +0 -6
  221. package/statistics/features/supported/expression-list/post-process.d.ts +0 -3
  222. package/statistics/features/supported/expression-list/post-process.js +0 -44
  223. package/statistics/features/supported/index.d.ts +0 -10
  224. package/statistics/features/supported/index.js +0 -27
  225. package/statistics/features/supported/loops/index.d.ts +0 -1
  226. package/statistics/features/supported/loops/index.js +0 -6
  227. package/statistics/features/supported/loops/loops.d.ts +0 -20
  228. package/statistics/features/supported/loops/loops.js +0 -79
  229. package/statistics/features/supported/loops/post-process.d.ts +0 -3
  230. package/statistics/features/supported/loops/post-process.js +0 -72
  231. package/statistics/features/supported/used-functions/index.d.ts +0 -1
  232. package/statistics/features/supported/used-functions/index.js +0 -6
  233. package/statistics/features/supported/used-functions/post-process.d.ts +0 -6
  234. package/statistics/features/supported/used-functions/post-process.js +0 -179
  235. package/statistics/features/supported/used-functions/used-functions.d.ts +0 -24
  236. package/statistics/features/supported/used-functions/used-functions.js +0 -95
  237. package/statistics/features/supported/used-packages/index.d.ts +0 -1
  238. package/statistics/features/supported/used-packages/index.js +0 -6
  239. package/statistics/features/supported/used-packages/post-process.d.ts +0 -3
  240. package/statistics/features/supported/used-packages/post-process.js +0 -121
  241. package/statistics/features/supported/used-packages/used-packages.d.ts +0 -16
  242. package/statistics/features/supported/used-packages/used-packages.js +0 -130
  243. package/statistics/features/supported/values/index.d.ts +0 -1
  244. package/statistics/features/supported/values/index.js +0 -6
  245. package/statistics/features/supported/values/post-process.d.ts +0 -3
  246. package/statistics/features/supported/values/post-process.js +0 -72
  247. package/statistics/features/supported/values/values.d.ts +0 -14
  248. package/statistics/features/supported/values/values.js +0 -101
  249. package/statistics/features/supported/variables/index.d.ts +0 -1
  250. package/statistics/features/supported/variables/index.js +0 -6
  251. package/statistics/features/supported/variables/post-process.d.ts +0 -9
  252. package/statistics/features/supported/variables/post-process.js +0 -122
  253. package/statistics/features/supported/variables/variables.d.ts +0 -15
  254. package/statistics/features/supported/variables/variables.js +0 -70
  255. package/statistics/index.d.ts +0 -6
  256. package/statistics/index.js +0 -24
  257. package/statistics/meta-statistics.d.ts +0 -33
  258. package/statistics/meta-statistics.js +0 -17
  259. package/statistics/output/file-provider.d.ts +0 -37
  260. package/statistics/output/file-provider.js +0 -97
  261. package/statistics/output/index.d.ts +0 -4
  262. package/statistics/output/index.js +0 -21
  263. package/statistics/output/print-stats.d.ts +0 -17
  264. package/statistics/output/print-stats.js +0 -69
  265. package/statistics/output/statistics-file.d.ts +0 -37
  266. package/statistics/output/statistics-file.js +0 -69
  267. package/statistics/statistics.d.ts +0 -24
  268. package/statistics/statistics.js +0 -109
  269. package/util/summarizer/auto-detect.d.ts +0 -2
  270. package/util/summarizer/auto-detect.js +0 -32
  271. package/util/summarizer/benchmark/data.d.ts +0 -66
  272. package/util/summarizer/benchmark/data.js +0 -13
  273. package/util/summarizer/benchmark/first-phase/input.d.ts +0 -2
  274. package/util/summarizer/benchmark/first-phase/input.js +0 -59
  275. package/util/summarizer/benchmark/first-phase/process.d.ts +0 -10
  276. package/util/summarizer/benchmark/first-phase/process.js +0 -208
  277. package/util/summarizer/benchmark/second-phase/graph.d.ts +0 -2
  278. package/util/summarizer/benchmark/second-phase/graph.js +0 -54
  279. package/util/summarizer/benchmark/second-phase/process.d.ts +0 -4
  280. package/util/summarizer/benchmark/second-phase/process.js +0 -89
  281. package/util/summarizer/benchmark/summarizer.d.ts +0 -35
  282. package/util/summarizer/benchmark/summarizer.js +0 -49
  283. package/util/summarizer/statistics/first-phase/process.d.ts +0 -6
  284. package/util/summarizer/statistics/first-phase/process.js +0 -81
  285. package/util/summarizer/statistics/post-process/clusterer.d.ts +0 -26
  286. package/util/summarizer/statistics/post-process/clusterer.js +0 -43
  287. package/util/summarizer/statistics/post-process/file-based-count.d.ts +0 -17
  288. package/util/summarizer/statistics/post-process/file-based-count.js +0 -49
  289. package/util/summarizer/statistics/post-process/histogram.d.ts +0 -59
  290. package/util/summarizer/statistics/post-process/histogram.js +0 -128
  291. package/util/summarizer/statistics/post-process/index.d.ts +0 -4
  292. package/util/summarizer/statistics/post-process/index.js +0 -21
  293. package/util/summarizer/statistics/post-process/post-process-output.d.ts +0 -16
  294. package/util/summarizer/statistics/post-process/post-process-output.js +0 -104
  295. package/util/summarizer/statistics/second-phase/process.d.ts +0 -11
  296. package/util/summarizer/statistics/second-phase/process.js +0 -117
  297. package/util/summarizer/statistics/summarizer.d.ts +0 -35
  298. package/util/summarizer/statistics/summarizer.js +0 -135
  299. package/util/summarizer/summarizer.js +0 -13
  300. /package/{statistics/output → util}/ansi.d.ts +0 -0
@@ -2,13 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.tryNormalizeBinary = void 0;
4
4
  const input_format_1 = require("../../input-format");
5
- const parser_1 = require("../../parser");
6
5
  const meta_1 = require("../meta");
7
6
  const special_1 = require("./special");
8
7
  const structure_1 = require("../structure");
9
8
  const model_1 = require("../../../../model");
10
9
  const hooks_1 = require("../../hooks");
11
10
  const assert_1 = require("../../../../../../../util/assert");
11
+ const parser_1 = require("../../../json/parser");
12
12
  /**
13
13
  * Parsing binary operations includes the pipe, even though the produced PIPE construct is not a binary operation,
14
14
  * to ensure it is handled separately from the others (especially in the combination of a pipe bind)
@@ -46,18 +46,18 @@ exports.tryNormalizeBinary = tryNormalizeBinary;
46
46
  function parseBinaryOp(data, flavor, lhs, operator, rhs) {
47
47
  parser_1.parseLog.debug(`[binary op] trying to parse ${flavor}`);
48
48
  ({ flavor, lhs, rhs, operator } = (0, hooks_1.executeHook)(data.hooks.operators.onBinary.before, data, { flavor, lhs, operator, rhs }));
49
- (0, meta_1.ensureChildrenAreLhsAndRhsOrdered)(data.config, lhs.content, rhs.content);
49
+ (0, meta_1.ensureChildrenAreLhsAndRhsOrdered)(lhs.content, rhs.content);
50
50
  let parsedLhs = (0, structure_1.tryNormalizeSingleNode)(data, lhs);
51
51
  let parsedRhs = (0, structure_1.tryNormalizeSingleNode)(data, rhs);
52
52
  if (parsedLhs.type === "RDelimiter" /* RType.Delimiter */ || parsedRhs.type === "RDelimiter" /* RType.Delimiter */) {
53
53
  throw new input_format_1.XmlParseError(`unexpected under-sided binary op, received ${JSON.stringify([parsedLhs, parsedRhs])} for ${JSON.stringify([lhs, operator, rhs])}`);
54
54
  }
55
- const operationName = (0, meta_1.retrieveOpName)(data.config, operator);
55
+ const operationName = (0, meta_1.retrieveOpName)(operator);
56
56
  // special support for strings in assignments
57
57
  if (flavor === 'assignment') {
58
- [parsedLhs, parsedRhs] = processLhsAndRhsForAssignment(data, operationName, parsedLhs, parsedRhs);
58
+ [parsedLhs, parsedRhs] = processLhsAndRhsForAssignment(operationName, parsedLhs, parsedRhs);
59
59
  }
60
- const { location, content } = (0, meta_1.retrieveMetaStructure)(data.config, operator.content);
60
+ const { location, content } = (0, meta_1.retrieveMetaStructure)(operator.content);
61
61
  if (flavor === 'special') {
62
62
  flavor = (0, special_1.identifySpecialOp)(content);
63
63
  }
@@ -142,7 +142,7 @@ function parseBinaryOp(data, flavor, lhs, operator, rhs) {
142
142
  }
143
143
  return (0, hooks_1.executeHook)(data.hooks.operators.onBinary.after, data, result);
144
144
  }
145
- function processLhsAndRhsForAssignment(data, opName, parsedLhs, parsedRhs) {
145
+ function processLhsAndRhsForAssignment(opName, parsedLhs, parsedRhs) {
146
146
  const isRhs = opName === '->' || opName === '->>';
147
147
  const assigned = isRhs ? parsedRhs : parsedLhs;
148
148
  if (assigned.type !== "RString" /* RType.String */) {
@@ -2,11 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.tryNormalizeUnary = void 0;
4
4
  const meta_1 = require("../meta");
5
- const parser_1 = require("../../parser");
6
5
  const structure_1 = require("../structure");
7
6
  const assert_1 = require("../../../../../../../util/assert");
8
7
  const model_1 = require("../../../../model");
9
8
  const hooks_1 = require("../../hooks");
9
+ const parser_1 = require("../../../json/parser");
10
10
  /**
11
11
  * Parses the construct as a {@link RUnaryOp} (automatically identifies the flavor).
12
12
  *
@@ -39,8 +39,8 @@ function parseUnaryOp(data, flavor, operator, operand) {
39
39
  ({ flavor, operator, operand } = (0, hooks_1.executeHook)(data.hooks.operators.onUnary.before, data, { flavor, operator, operand }));
40
40
  const parsedOperand = (0, structure_1.tryNormalizeSingleNode)(data, operand);
41
41
  (0, assert_1.guard)(parsedOperand.type !== "RDelimiter" /* RType.Delimiter */, () => 'unexpected under-sided unary op');
42
- const operationName = (0, meta_1.retrieveOpName)(data.config, operator);
43
- const { location, content } = (0, meta_1.retrieveMetaStructure)(data.config, operator.content);
42
+ const operationName = (0, meta_1.retrieveOpName)(operator);
43
+ const { location, content } = (0, meta_1.retrieveMetaStructure)(operator.content);
44
44
  const result = {
45
45
  type: "RUnaryOp" /* RType.UnaryOp */,
46
46
  flavor,
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizeComment = void 0;
4
- const parser_1 = require("../../parser");
5
4
  const meta_1 = require("../meta");
6
5
  const assert_1 = require("../../../../../../../util/assert");
7
6
  const hooks_1 = require("../../hooks");
7
+ const parser_1 = require("../../../json/parser");
8
8
  /**
9
9
  * Normalize the given object as an R comment.
10
10
  * This requires you to check the corresponding name beforehand.
@@ -15,7 +15,7 @@ const hooks_1 = require("../../hooks");
15
15
  function normalizeComment(data, obj) {
16
16
  parser_1.parseLog.debug('[comment]');
17
17
  obj = (0, hooks_1.executeHook)(data.hooks.other.onComment.before, data, obj);
18
- const { location, content } = (0, meta_1.retrieveMetaStructure)(data.config, obj);
18
+ const { location, content } = (0, meta_1.retrieveMetaStructure)(obj);
19
19
  (0, assert_1.guard)(content.startsWith('#'), 'comment must start with #');
20
20
  const result = {
21
21
  type: "RComment" /* RType.Comment */,
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizeLineDirective = void 0;
4
- const parser_1 = require("../../parser");
5
4
  const meta_1 = require("../meta");
6
5
  const assert_1 = require("../../../../../../../util/assert");
7
6
  const hooks_1 = require("../../hooks");
7
+ const parser_1 = require("../../../json/parser");
8
8
  const LineDirectiveRegex = /^#line\s+(\d+)\s+"([^"]+)"\s*$/;
9
9
  /**
10
10
  * Normalize the given object as an R line directive (`#line <number> "<file>"`).
@@ -17,7 +17,7 @@ const LineDirectiveRegex = /^#line\s+(\d+)\s+"([^"]+)"\s*$/;
17
17
  function normalizeLineDirective(data, obj) {
18
18
  parser_1.parseLog.debug('[line-directive]');
19
19
  obj = (0, hooks_1.executeHook)(data.hooks.other.onLineDirective.before, data, obj);
20
- const { location, content } = (0, meta_1.retrieveMetaStructure)(data.config, obj);
20
+ const { location, content } = (0, meta_1.retrieveMetaStructure)(obj);
21
21
  (0, assert_1.guard)(content.startsWith('#line'), 'line directive must start with #line');
22
22
  const match = LineDirectiveRegex.exec(content);
23
23
  let result;
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseNodesWithUnknownType = exports.normalizeBasedOnType = exports.splitComments = void 0;
4
4
  const arrays_1 = require("../../../../../../../util/arrays");
5
- const parser_1 = require("../../parser");
6
5
  const meta_1 = require("../meta");
7
6
  const single_element_1 = require("./single-element");
8
7
  const values_1 = require("../values");
@@ -11,6 +10,7 @@ const loops_1 = require("../loops");
11
10
  const control_1 = require("../control");
12
11
  const log_1 = require("../../../../../../../util/log");
13
12
  const other_1 = require("../other");
13
+ const parser_1 = require("../../../json/parser");
14
14
  function normalizeMappedWithoutSemicolonBasedOnType(mappedWithName, data) {
15
15
  if (mappedWithName.length === 1) {
16
16
  return [(0, single_element_1.tryNormalizeSingleNode)(data, mappedWithName[0])];
@@ -103,14 +103,14 @@ function normalizeBasedOnType(data, obj) {
103
103
  mappedWithName = obj;
104
104
  }
105
105
  else {
106
- mappedWithName = (0, meta_1.getWithTokenType)(data.config.tokenMap, obj);
106
+ mappedWithName = (0, meta_1.getWithTokenType)(obj);
107
107
  }
108
108
  log_1.log.trace(`[parseBasedOnType] names: [${mappedWithName.map(({ name }) => name).join(', ')}]`);
109
109
  const semiColons = [];
110
110
  const splitOnSemicolon = (0, arrays_1.splitArrayOn)(mappedWithName, node => {
111
111
  const res = node.name === ";" /* RawRType.Semicolon */;
112
112
  if (res) {
113
- const { location, content } = (0, meta_1.retrieveMetaStructure)(data.config, node.content);
113
+ const { location, content } = (0, meta_1.retrieveMetaStructure)(node.content);
114
114
  semiColons.push({
115
115
  type: "RDelimiter" /* RType.Delimiter */,
116
116
  subtype: ";" /* RawRType.Semicolon */,
@@ -7,12 +7,11 @@ const elements_1 = require("./elements");
7
7
  const log_1 = require("../../../../../../../util/log");
8
8
  const arrays_1 = require("../../../../../../../util/arrays");
9
9
  function parseRootObjToAst(data, obj) {
10
- const config = data.config;
11
10
  const exprContent = (0, input_format_1.getKeysGuarded)(obj, "exprlist" /* RawRType.ExpressionList */);
12
- (0, meta_1.assureTokenType)(config.tokenMap, exprContent, "exprlist" /* RawRType.ExpressionList */);
11
+ (0, meta_1.assureTokenType)(exprContent, "exprlist" /* RawRType.ExpressionList */);
13
12
  let parsedChildren = [];
14
- if (config.childrenName in exprContent) {
15
- const children = (0, input_format_1.getKeysGuarded)(exprContent, config.childrenName);
13
+ if (input_format_1.childrenKey in exprContent) {
14
+ const children = (0, input_format_1.getKeysGuarded)(exprContent, input_format_1.childrenKey);
16
15
  parsedChildren = (0, elements_1.normalizeBasedOnType)(data, children);
17
16
  }
18
17
  else {
@@ -10,7 +10,7 @@ const other_1 = require("../other");
10
10
  const loops_1 = require("../loops");
11
11
  const line_directive_1 = require("../other/line-directive");
12
12
  function normalizeDelimiter(data, elem) {
13
- const { location, content } = (0, meta_1.retrieveMetaStructure)(data.config, elem.content);
13
+ const { location, content } = (0, meta_1.retrieveMetaStructure)(elem.content);
14
14
  return {
15
15
  type: "RDelimiter" /* RType.Delimiter */,
16
16
  location,
@@ -52,7 +52,7 @@ function tryNormalizeSingleNode(data, elem) {
52
52
  case "SYMBOL" /* RawRType.Symbol */:
53
53
  case "SLOT" /* RawRType.Slot */:
54
54
  case "NULL_CONST" /* RawRType.NullConst */: {
55
- const symbol = (0, values_1.tryNormalizeSymbol)(data, (0, meta_1.getWithTokenType)(data.config.tokenMap, [elem.content]));
55
+ const symbol = (0, values_1.tryNormalizeSymbol)(data, (0, meta_1.getWithTokenType)([elem.content]));
56
56
  (0, assert_1.guard)(symbol !== undefined, () => `should have been parsed to a symbol but was ${JSON.stringify(symbol)}`);
57
57
  return symbol;
58
58
  }
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizeNumber = void 0;
4
4
  const values_1 = require("../../../../../values");
5
- const parser_1 = require("../../parser");
6
5
  const meta_1 = require("../meta");
7
6
  const hooks_1 = require("../../hooks");
7
+ const parser_1 = require("../../../json/parser");
8
8
  /**
9
9
  * Normalize the given object as a R number (see {@link number2ts}), supporting booleans (see {@link boolean2ts}),
10
10
  * and special values.
@@ -16,7 +16,7 @@ const hooks_1 = require("../../hooks");
16
16
  function normalizeNumber(data, obj) {
17
17
  parser_1.parseLog.debug('[number]');
18
18
  obj = (0, hooks_1.executeHook)(data.hooks.values.onNumber.before, data, obj);
19
- const { location, content } = (0, meta_1.retrieveMetaStructure)(data.config, obj);
19
+ const { location, content } = (0, meta_1.retrieveMetaStructure)(obj);
20
20
  const common = {
21
21
  location,
22
22
  lexeme: content,
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizeString = void 0;
4
4
  const meta_1 = require("../meta");
5
5
  const values_1 = require("../../../../../values");
6
- const parser_1 = require("../../parser");
7
6
  const hooks_1 = require("../../hooks");
8
7
  const assert_1 = require("../../../../../../../util/assert");
8
+ const parser_1 = require("../../../json/parser");
9
9
  /**
10
10
  * Normalize the given object as a R string (see {@link string2ts}).
11
11
  * This requires you to check the corresponding name beforehand.
@@ -16,7 +16,7 @@ const assert_1 = require("../../../../../../../util/assert");
16
16
  function normalizeString(data, obj) {
17
17
  parser_1.parseLog.debug('[string]');
18
18
  obj = (0, hooks_1.executeHook)(data.hooks.values.onString.before, data, obj);
19
- const { location, content } = (0, meta_1.retrieveMetaStructure)(data.config, obj);
19
+ const { location, content } = (0, meta_1.retrieveMetaStructure)(obj);
20
20
  // based on https://www.rdocumentation.org/packages/utils/versions/3.6.2/topics/getParseData we do not get strings with 1000 characters or more within the text field.
21
21
  // therefore, we recover the full string from the surrounding expr lexeme field
22
22
  let stringContent = content;
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.tryNormalizeSymbol = void 0;
4
4
  const assert_1 = require("../../../../../../../util/assert");
5
5
  const meta_1 = require("../meta");
6
- const parser_1 = require("../../parser");
7
6
  const model_1 = require("../../../../model");
8
7
  const hooks_1 = require("../../hooks");
9
8
  const strings_1 = require("../../../../../../../util/strings");
9
+ const parser_1 = require("../../../json/parser");
10
10
  /**
11
11
  * Normalize the given object as an R symbol (incorporating namespace information).
12
12
  * <p>
@@ -23,16 +23,16 @@ function tryNormalizeSymbol(data, objs) {
23
23
  objs = (0, hooks_1.executeHook)(data.hooks.values.onSymbol.before, data, objs);
24
24
  let location, content, namespace;
25
25
  if (objs.length === 1 && (0, model_1.isSymbol)(objs[0].name)) {
26
- const meta = (0, meta_1.retrieveMetaStructure)(data.config, objs[0].content);
26
+ const meta = (0, meta_1.retrieveMetaStructure)(objs[0].content);
27
27
  location = meta.location;
28
28
  content = meta.content;
29
29
  namespace = undefined;
30
30
  }
31
31
  else if (objs.length === 3 && (0, model_1.isSymbol)(objs[2].name)) {
32
- const meta = (0, meta_1.retrieveMetaStructure)(data.config, objs[2].content);
32
+ const meta = (0, meta_1.retrieveMetaStructure)(objs[2].content);
33
33
  location = meta.location;
34
34
  content = meta.content;
35
- namespace = (0, meta_1.retrieveMetaStructure)(data.config, objs[0].content).content;
35
+ namespace = (0, meta_1.retrieveMetaStructure)(objs[0].content).content;
36
36
  }
37
37
  else {
38
38
  return (0, hooks_1.executeUnknownHook)(data.hooks.values.onSymbol.unknown, data, objs);
@@ -36,4 +36,3 @@ export declare function string2ts(value: string): RStringValue;
36
36
  export declare const RNa = "NA";
37
37
  export declare const RNull = "NULL";
38
38
  export declare function isNA(value: string): value is (typeof RNa);
39
- export declare function parseCSV(lines: string[]): string[][];
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseCSV = exports.isNA = exports.RNull = exports.RNa = exports.string2ts = exports.number2ts = exports.RInf = exports.RIntegerMarker = exports.RImaginaryMarker = exports.RNumHexFloatRegex = exports.boolean2ts = exports.isBoolean = exports.RFalse = exports.RTrue = exports.ts2r = void 0;
4
- const sync_1 = require("csv-parse/sync");
3
+ exports.isNA = exports.RNull = exports.RNa = exports.string2ts = exports.number2ts = exports.RInf = exports.RIntegerMarker = exports.RImaginaryMarker = exports.RNumHexFloatRegex = exports.boolean2ts = exports.isBoolean = exports.RFalse = exports.RTrue = exports.ts2r = void 0;
5
4
  class ValueConversionError extends Error {
6
5
  constructor(message) {
7
6
  super(message);
@@ -19,6 +18,12 @@ function ts2r(value) {
19
18
  return JSON.stringify(value);
20
19
  }
21
20
  else if (typeof value === 'number') {
21
+ if (isNaN(value)) {
22
+ return exports.RNa;
23
+ }
24
+ else if (!isFinite(value)) {
25
+ return exports.RInf;
26
+ }
22
27
  return value.toString();
23
28
  }
24
29
  else if (typeof value === 'boolean') {
@@ -81,6 +86,13 @@ function number2ts(value) {
81
86
  markedAsInt
82
87
  };
83
88
  }
89
+ if (value === exports.RNa) {
90
+ return {
91
+ num: NaN,
92
+ complexNumber,
93
+ markedAsInt
94
+ };
95
+ }
84
96
  const floatHex = lcValue.match(exports.RNumHexFloatRegex);
85
97
  if (floatHex == null) {
86
98
  return {
@@ -142,8 +154,4 @@ function isNA(value) {
142
154
  return value === exports.RNa;
143
155
  }
144
156
  exports.isNA = isNA;
145
- function parseCSV(lines) {
146
- return (0, sync_1.parse)(lines.join('\n'), { skipEmptyLines: true });
147
- }
148
- exports.parseCSV = parseCSV;
149
157
  //# sourceMappingURL=values.js.map
@@ -1,28 +1,34 @@
1
1
  import { type RShell } from './shell';
2
2
  import type { XmlParserHooks, NormalizedAst } from './lang-4.x';
3
- import type { DeepPartial, DeepReadonly } from 'ts-essentials';
3
+ import type { AsyncOrSync, DeepPartial } from 'ts-essentials';
4
+ import { RShellExecutor } from './shell-executor';
5
+ export declare const fileProtocol: "file://";
4
6
  export interface RParseRequestFromFile {
5
- request: 'file';
7
+ readonly request: 'file';
6
8
  /** The path to the file (absolute paths are probably best here */
7
- content: string;
9
+ readonly content: string;
8
10
  }
9
11
  export interface RParseRequestFromText {
10
- request: 'text';
11
- content: string;
12
+ readonly request: 'text';
13
+ readonly content: string;
12
14
  }
13
- interface RParseRequestBase {
14
- /**
15
- * Ensure that all required packages are present and if not install them?
16
- * The only reason to set this to `false` is probably in a series of parse requests for the same session.
17
- */
18
- ensurePackageInstalled: boolean;
15
+ /**
16
+ * A provider for an {@link RParseRequest} that can be used, for example, to override source file parsing behavior in tests
17
+ */
18
+ export interface RParseRequestProvider {
19
+ createRequest(path: string): RParseRequest;
19
20
  }
20
21
  /**
21
- * A request that can be passed along to {@link retrieveXmlFromRCode}.
22
+ * A request that can be passed along to {@link retrieveParseDataFromRCode}.
22
23
  */
23
- export type RParseRequest = (RParseRequestFromFile | RParseRequestFromText) & RParseRequestBase;
24
- export declare function requestFromInput(input: `file://${string}`): RParseRequestFromFile & RParseRequestBase;
25
- export declare function requestFromInput(input: string): RParseRequestFromText & RParseRequestBase;
24
+ export type RParseRequest = (RParseRequestFromFile | RParseRequestFromText);
25
+ export declare function requestFromInput(input: `${typeof fileProtocol}${string}`): RParseRequestFromFile;
26
+ export declare function requestFromInput(input: string): RParseRequestFromText;
27
+ export declare function requestProviderFromFile(): RParseRequestProvider;
28
+ export declare function requestProviderFromText(text: {
29
+ [path: string]: string;
30
+ }): RParseRequestProvider;
31
+ export declare function requestFingerprint(request: RParseRequest): string;
26
32
  /**
27
33
  * Provides the capability to parse R files/R code using the R parser.
28
34
  * Depends on {@link RShell} to provide a connection to R.
@@ -30,19 +36,17 @@ export declare function requestFromInput(input: string): RParseRequestFromText &
30
36
  * Throws if the file could not be parsed.
31
37
  * If successful, allows to further query the last result with {@link retrieveNumberOfRTokensOfLastParse}.
32
38
  */
33
- export declare function retrieveXmlFromRCode(request: RParseRequest, shell: RShell): Promise<string>;
39
+ export declare function retrieveParseDataFromRCode(request: RParseRequest, shell: (RShell | RShellExecutor)): AsyncOrSync<string>;
34
40
  /**
35
- * Uses {@link retrieveXmlFromRCode} and returns the nicely formatted object-AST.
41
+ * Uses {@link retrieveParseDataFromRCode} and returns the nicely formatted object-AST.
36
42
  * If successful, allows to further query the last result with {@link retrieveNumberOfRTokensOfLastParse}.
37
43
  */
38
44
  export declare function retrieveNormalizedAstFromRCode(request: RParseRequest, shell: RShell, hooks?: DeepPartial<XmlParserHooks>): Promise<NormalizedAst>;
39
45
  /**
40
46
  * If the string has (R-)quotes around it, they will be removed, otherwise the string is returned unchanged.
41
47
  */
42
- export declare function removeTokenMapQuotationMarks(str: string): string;
43
- export type TokenMap = DeepReadonly<Record<string, string>>;
48
+ export declare function removeRQuotes(str: string): string;
44
49
  /**
45
- * Needs to be called *after* {@link retrieveXmlFromRCode} (or {@link retrieveNormalizedAstFromRCode})
50
+ * Needs to be called *after* {@link retrieveParseDataFromRCode} (or {@link retrieveNormalizedAstFromRCode})
46
51
  */
47
52
  export declare function retrieveNumberOfRTokensOfLastParse(shell: RShell): Promise<number>;
48
- export {};
@@ -1,21 +1,53 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.retrieveNumberOfRTokensOfLastParse = exports.removeTokenMapQuotationMarks = exports.retrieveNormalizedAstFromRCode = exports.retrieveXmlFromRCode = exports.requestFromInput = void 0;
6
+ exports.retrieveNumberOfRTokensOfLastParse = exports.removeRQuotes = exports.retrieveNormalizedAstFromRCode = exports.retrieveParseDataFromRCode = exports.requestFingerprint = exports.requestProviderFromText = exports.requestProviderFromFile = exports.requestFromInput = exports.fileProtocol = void 0;
4
7
  const lang_4_x_1 = require("./lang-4.x");
5
8
  const strings_1 = require("../util/strings");
6
9
  const assert_1 = require("../util/assert");
10
+ const shell_executor_1 = require("./shell-executor");
11
+ const object_hash_1 = __importDefault(require("object-hash"));
12
+ const parser_1 = require("./lang-4.x/ast/parser/json/parser");
13
+ exports.fileProtocol = 'file://';
7
14
  /**
8
15
  * Creates a {@link RParseRequest} from a given input.
9
16
  */
10
17
  function requestFromInput(input) {
11
- const file = input.startsWith('file://');
18
+ const file = input.startsWith(exports.fileProtocol);
12
19
  return {
13
20
  request: file ? 'file' : 'text',
14
- content: file ? input.slice(7) : input,
15
- ensurePackageInstalled: false // should be called within describeSession for that!
21
+ content: file ? input.slice(7) : input
16
22
  };
17
23
  }
18
24
  exports.requestFromInput = requestFromInput;
25
+ function requestProviderFromFile() {
26
+ return {
27
+ createRequest(path) {
28
+ return {
29
+ request: 'file',
30
+ content: path,
31
+ };
32
+ }
33
+ };
34
+ }
35
+ exports.requestProviderFromFile = requestProviderFromFile;
36
+ function requestProviderFromText(text) {
37
+ return {
38
+ createRequest(path) {
39
+ return {
40
+ request: 'text',
41
+ content: text[path]
42
+ };
43
+ }
44
+ };
45
+ }
46
+ exports.requestProviderFromText = requestProviderFromText;
47
+ function requestFingerprint(request) {
48
+ return (0, object_hash_1.default)(request);
49
+ }
50
+ exports.requestFingerprint = requestFingerprint;
19
51
  const ErrorMarker = 'err';
20
52
  /**
21
53
  * Provides the capability to parse R files/R code using the R parser.
@@ -24,33 +56,47 @@ const ErrorMarker = 'err';
24
56
  * Throws if the file could not be parsed.
25
57
  * If successful, allows to further query the last result with {@link retrieveNumberOfRTokensOfLastParse}.
26
58
  */
27
- async function retrieveXmlFromRCode(request, shell) {
28
- if (request.ensurePackageInstalled) {
29
- await shell.ensurePackageInstalled('xmlparsedata', true);
30
- }
59
+ function retrieveParseDataFromRCode(request, shell) {
31
60
  const suffix = request.request === 'file' ? ', encoding="utf-8"' : '';
32
- shell.sendCommands(`flowr_output <- flowr_parsed <- "${ErrorMarker}"`,
33
- // now, try to retrieve the ast
34
- `try(flowr_parsed<-parse(${request.request}=${JSON.stringify(request.content)},keep.source=TRUE${suffix}),silent=FALSE)`, 'try(flowr_output<-xmlparsedata::xml_parse_data(flowr_parsed,includeText=TRUE,pretty=FALSE),silent=FALSE)');
35
- const xml = await shell.sendCommandWithOutput(`cat(flowr_output,${(0, lang_4_x_1.ts2r)(shell.options.eol)})`);
36
- const output = xml.join(shell.options.eol);
37
- (0, assert_1.guard)(output !== ErrorMarker, () => `unable to parse R code (see the log for more information) for request ${JSON.stringify(request)}}`);
38
- return output;
61
+ const eol = (0, lang_4_x_1.ts2r)(shell.options.eol);
62
+ const command =
63
+ /* first check if flowr_get is already part of the environment */
64
+ 'if(!exists("flowr_get")){'
65
+ /* if not, define it complete wrapped in a try so that we can handle failures gracefully on stdout */
66
+ + 'flowr_get<-function(...){tryCatch({'
67
+ /* the actual code to parse the R code, ... allows us to keep the old 'file=path' and 'text=content' semantics. we define flowr_output using the super assignment to persist it in the env! */
68
+ + 'flowr_output<<-utils::getParseData(parse(...,keep.source=TRUE),includeText=TRUE);'
69
+ /* json conversion of the output, dataframe="values" allows us to receive a list of lists (which is more compact)!
70
+ * so we do not depend on jsonlite and friends, we do so manually (:sparkles:)
71
+ */
72
+ + `cat("[",paste0(apply(flowr_output,1,function(o)sprintf("[%s,%s,%s,%s,%s,%s,%s,%s,%s]",o[[1]],o[[2]],o[[3]],o[[4]],o[[5]],o[[6]],deparse(o[[7]]),if(o[[8]])"true"else"false",deparse(o[[9]]))),collapse=","),"]",${eol},sep="")`
73
+ /* error handling (just produce the marker) */
74
+ + `},error=function(e){cat("${ErrorMarker}",${eol})})};`
75
+ /* compile the function to improve perf. */
76
+ + 'flowr_get<-compiler::cmpfun(flowr_get)};'
77
+ /* call the function with the request */
78
+ + `flowr_get(${request.request}=${JSON.stringify(request.content)}${suffix})`;
79
+ if (shell instanceof shell_executor_1.RShellExecutor) {
80
+ return guardRetrievedOutput(shell.run(command), request);
81
+ }
82
+ else {
83
+ return shell.sendCommandWithOutput(command).then(result => guardRetrievedOutput(result.join(shell.options.eol), request));
84
+ }
39
85
  }
40
- exports.retrieveXmlFromRCode = retrieveXmlFromRCode;
86
+ exports.retrieveParseDataFromRCode = retrieveParseDataFromRCode;
41
87
  /**
42
- * Uses {@link retrieveXmlFromRCode} and returns the nicely formatted object-AST.
88
+ * Uses {@link retrieveParseDataFromRCode} and returns the nicely formatted object-AST.
43
89
  * If successful, allows to further query the last result with {@link retrieveNumberOfRTokensOfLastParse}.
44
90
  */
45
91
  async function retrieveNormalizedAstFromRCode(request, shell, hooks) {
46
- const xml = await retrieveXmlFromRCode(request, shell);
47
- return await (0, lang_4_x_1.normalize)(xml, await shell.tokenMap(), hooks);
92
+ const data = await retrieveParseDataFromRCode(request, shell);
93
+ return (0, parser_1.normalize)(data, hooks);
48
94
  }
49
95
  exports.retrieveNormalizedAstFromRCode = retrieveNormalizedAstFromRCode;
50
96
  /**
51
97
  * If the string has (R-)quotes around it, they will be removed, otherwise the string is returned unchanged.
52
98
  */
53
- function removeTokenMapQuotationMarks(str) {
99
+ function removeRQuotes(str) {
54
100
  if (str.length > 1 && ((0, strings_1.startAndEndsWith)(str, '\'') || (0, strings_1.startAndEndsWith)(str, '"'))) {
55
101
  return str.slice(1, -1);
56
102
  }
@@ -58,14 +104,18 @@ function removeTokenMapQuotationMarks(str) {
58
104
  return str;
59
105
  }
60
106
  }
61
- exports.removeTokenMapQuotationMarks = removeTokenMapQuotationMarks;
107
+ exports.removeRQuotes = removeRQuotes;
62
108
  /**
63
- * Needs to be called *after* {@link retrieveXmlFromRCode} (or {@link retrieveNormalizedAstFromRCode})
109
+ * Needs to be called *after* {@link retrieveParseDataFromRCode} (or {@link retrieveNormalizedAstFromRCode})
64
110
  */
65
111
  async function retrieveNumberOfRTokensOfLastParse(shell) {
66
- const result = await shell.sendCommandWithOutput(`cat(nrow(getParseData(flowr_parsed)),${(0, lang_4_x_1.ts2r)(shell.options.eol)})`);
112
+ const result = await shell.sendCommandWithOutput(`cat(nrow(flowr_output),${(0, lang_4_x_1.ts2r)(shell.options.eol)})`);
67
113
  (0, assert_1.guard)(result.length === 1, () => `expected exactly one line to obtain the number of R tokens, but got: ${JSON.stringify(result)}`);
68
114
  return Number(result[0]);
69
115
  }
70
116
  exports.retrieveNumberOfRTokensOfLastParse = retrieveNumberOfRTokensOfLastParse;
117
+ function guardRetrievedOutput(output, request) {
118
+ (0, assert_1.guard)(output !== ErrorMarker, () => `unable to parse R code (see the log for more information) for request ${JSON.stringify(request)}}`);
119
+ return output;
120
+ }
71
121
  //# sourceMappingURL=retriever.js.map
@@ -1,25 +1,11 @@
1
1
  import type { RShellExecutionOptions } from './shell';
2
2
  import type { SemVer } from 'semver';
3
- import type { TokenMap } from './retriever';
4
3
  export declare class RShellExecutor {
5
4
  readonly options: Readonly<RShellExecutionOptions>;
6
- private readonly log;
7
5
  private readonly prerequisites;
8
6
  constructor(options?: Partial<RShellExecutionOptions>);
9
- continueOnError(): RShellExecutor;
10
- injectLibPaths(...paths: string[]): RShellExecutor;
11
- tryToInjectHomeLibPath(): RShellExecutor;
12
- addPrerequisites(commands: string | string[]): RShellExecutor;
7
+ continueOnError(): this;
8
+ addPrerequisites(commands: string | string[]): this;
13
9
  usedRVersion(): SemVer | null;
14
- allInstalledPackages(): string[];
15
- isPackageInstalled(packageName: string): boolean;
16
- ensurePackageInstalled(packageName: string, autoload?: boolean, force?: boolean): {
17
- packageName: string;
18
- packageExistedAlready: boolean;
19
- /** the temporary directory used for the installation, undefined if none was used */
20
- libraryLocation?: string;
21
- };
22
- obtainTempDir(): string;
23
- getTokenMap(): TokenMap;
24
- run(commands: string | string[], returnErr?: boolean): string;
10
+ run(command: string, returnErr?: boolean): string;
25
11
  }