@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
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.convertPreparedParsedData = exports.normalize = exports.parseLog = void 0;
4
+ const xml_1 = require("../xml");
5
+ const model_1 = require("../../model");
6
+ const objects_1 = require("../../../../../util/objects");
7
+ const format_1 = require("./format");
8
+ const internal_1 = require("../xml/internal");
9
+ const log_1 = require("../../../../../util/log");
10
+ exports.parseLog = log_1.log.getSubLogger({ name: 'ast-parser' });
11
+ function normalize(jsonString, hooks, getId = (0, model_1.deterministicCountingIdGenerator)(0)) {
12
+ const hooksWithDefaults = (0, objects_1.deepMergeObject)(xml_1.DEFAULT_PARSER_HOOKS, hooks);
13
+ const data = { hooks: hooksWithDefaults, currentRange: undefined, currentLexeme: undefined };
14
+ const object = convertPreparedParsedData((0, format_1.prepareParsedData)(jsonString));
15
+ return (0, model_1.decorateAst)((0, internal_1.parseRootObjToAst)(data, object), getId);
16
+ }
17
+ exports.normalize = normalize;
18
+ function convertPreparedParsedData(valueMapping) {
19
+ const exprlist = {};
20
+ exprlist[xml_1.nameKey] = 'exprlist';
21
+ const children = [];
22
+ for (const entry of valueMapping.values()) {
23
+ if (entry.parent == format_1.RootId) {
24
+ children.push(convertEntry(entry));
25
+ }
26
+ }
27
+ exprlist[xml_1.childrenKey] = children;
28
+ return { 'exprlist': exprlist };
29
+ }
30
+ exports.convertPreparedParsedData = convertPreparedParsedData;
31
+ function convertEntry(csvEntry) {
32
+ const xmlEntry = {};
33
+ xmlEntry[xml_1.attributesKey] = {
34
+ 'line1': csvEntry.line1,
35
+ 'col1': csvEntry.col1,
36
+ 'line2': csvEntry.line2,
37
+ 'col2': csvEntry.col2
38
+ };
39
+ xmlEntry[xml_1.nameKey] = csvEntry.token;
40
+ if (csvEntry.text) {
41
+ xmlEntry[xml_1.contentKey] = csvEntry.text;
42
+ }
43
+ // check and recursively iterate children
44
+ if (csvEntry.children && csvEntry.children.length > 0) {
45
+ xmlEntry[xml_1.childrenKey] = csvEntry.children
46
+ // we sort children the same way xmlparsedata does (by line, by column, by inverse end line, by inverse end column, by terminal state, by combined "start" tiebreaker value)
47
+ // (https://github.com/r-lib/xmlparsedata/blob/main/R/package.R#L153C72-L153C78)
48
+ .sort((c1, c2) => c1.line1 - c2.line1 || c1.col1 - c2.col1 || c2.line2 - c1.line2 || c2.col2 - c1.col2 || Number(c1.terminal) - Number(c2.terminal) || sortTiebreak(c1) - sortTiebreak(c2))
49
+ .map(convertEntry);
50
+ }
51
+ return xmlEntry;
52
+ }
53
+ function sortTiebreak(entry) {
54
+ // see https://github.com/r-lib/xmlparsedata/blob/main/R/package.R#L110C5-L110C11
55
+ return entry.line1 * (Math.max(entry.col1, entry.col2) + 1) + entry.col1;
56
+ }
57
+ //# sourceMappingURL=parser.js.map
@@ -1,14 +1,11 @@
1
1
  import type { MergeableRecord } from '../../../../../util/objects';
2
2
  import type { DeepReadonly } from 'ts-essentials';
3
- import type { XmlParserConfig } from './config';
4
3
  import type { XmlParserHooks } from './hooks';
5
4
  import type { SourceRange } from '../../../../../util/range';
6
5
  /**
7
6
  * Contains all information populated and present during parsing and normalization of the R AST.
8
7
  */
9
8
  export interface ParserData extends MergeableRecord {
10
- /** @see XmlParserConfig */
11
- readonly config: DeepReadonly<XmlParserConfig>;
12
9
  /** @see XmlParserHooks */
13
10
  readonly hooks: DeepReadonly<XmlParserHooks>;
14
11
  /**
@@ -1,5 +1,3 @@
1
1
  export * from './data';
2
2
  export * from './hooks';
3
- export * from './config';
4
- export * from './parser';
5
3
  export * from './input-format';
@@ -16,7 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./data"), exports);
18
18
  __exportStar(require("./hooks"), exports);
19
- __exportStar(require("./config"), exports);
20
- __exportStar(require("./parser"), exports);
21
19
  __exportStar(require("./input-format"), exports);
22
20
  //# sourceMappingURL=index.js.map
@@ -1,4 +1,8 @@
1
1
  import type { RawRType } from '../../model';
2
+ export declare const attributesKey = "a";
3
+ export declare const childrenKey = "c";
4
+ export declare const contentKey = "@";
5
+ export declare const nameKey = "#";
2
6
  /**
3
7
  * Thrown if the given input xml is not valid/contains unexpected elements.
4
8
  */
@@ -29,4 +33,4 @@ export interface NamedXmlBasedJson {
29
33
  * @typeParam T - the type of the values to retrieve. Note, that this type is not checked at runtime.
30
34
  */
31
35
  export declare function getKeysGuarded<T extends XmlBasedJsonValue>(obj: XmlBasedJson, key: string): T;
32
- export declare function getKeysGuarded<T extends XmlBasedJsonValue>(obj: XmlBasedJson, ...key: string[]): Record<string, T>;
36
+ export declare function getKeysGuarded<T extends XmlBasedJsonValue>(obj: XmlBasedJson, ...key: readonly string[]): Record<string, T>;
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getKeysGuarded = exports.XmlParseError = void 0;
3
+ exports.getKeysGuarded = exports.XmlParseError = exports.nameKey = exports.contentKey = exports.childrenKey = exports.attributesKey = void 0;
4
+ exports.attributesKey = 'a';
5
+ exports.childrenKey = 'c';
6
+ exports.contentKey = '@';
7
+ exports.nameKey = '#';
4
8
  /**
5
9
  * Thrown if the given input xml is not valid/contains unexpected elements.
6
10
  */
@@ -12,19 +16,12 @@ class XmlParseError extends Error {
12
16
  }
13
17
  exports.XmlParseError = XmlParseError;
14
18
  function getKeysGuarded(obj, ...key) {
15
- const keys = Object.keys(obj);
16
- const check = (key) => {
17
- if (!keys.includes(key)) {
18
- throw new XmlParseError(`expected obj to have key ${key}, yet received ${JSON.stringify(obj)}`);
19
- }
20
- return obj[key];
21
- };
22
19
  if (key.length === 1) {
23
- return check(key[0]);
20
+ return obj[key[0]];
24
21
  }
25
22
  else {
26
23
  return key.reduce((acc, key) => {
27
- acc[key] = check(key);
24
+ acc[key] = obj[key];
28
25
  return acc;
29
26
  }, {});
30
27
  }
@@ -2,12 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.tryNormalizeAccess = void 0;
4
4
  const meta_1 = require("./meta");
5
- const parser_1 = require("../parser");
6
5
  const hooks_1 = require("../hooks");
7
6
  const structure_1 = require("./structure");
8
7
  const assert_1 = require("../../../../../../util/assert");
9
8
  const arrays_1 = require("../../../../../../util/arrays");
10
9
  const argument_1 = require("./functions/argument");
10
+ const parser_1 = require("../../json/parser");
11
11
  /**
12
12
  * Tries to normalize the given data as access (e.g., indexing).
13
13
  *
@@ -75,7 +75,7 @@ function tryNormalizeAccess(data, mappedWithName) {
75
75
  (0, assert_1.guard)(first !== null && (first.type === "RSymbol" /* RType.Symbol */ || first.type === "RString" /* RType.String */ || first.type === "RLogical" /* RType.Logical */), () => `${JSON.stringify(operator)} requires one symbol, yet received ${JSON.stringify(parsedAccess)}`);
76
76
  resultingAccess = first.type === "RString" /* RType.String */ ? first.content.str : first.lexeme;
77
77
  }
78
- const { content, location } = (0, meta_1.retrieveMetaStructure)(data.config, accessOp.content);
78
+ const { content, location } = (0, meta_1.retrieveMetaStructure)(accessOp.content);
79
79
  const result = {
80
80
  type: "RAccess" /* RType.Access */,
81
81
  location,
@@ -2,11 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.tryNormalizeIfThenElse = void 0;
4
4
  const structure_1 = require("../structure");
5
- const parser_1 = require("../../parser");
6
5
  const if_then_1 = require("./if-then");
7
6
  const assert_1 = require("../../../../../../../util/assert");
8
7
  const hooks_1 = require("../../hooks");
9
8
  const meta_1 = require("../meta");
9
+ const parser_1 = require("../../../json/parser");
10
10
  /**
11
11
  * Try to parse the construct as a {@link RIfThenElse}.
12
12
  */
@@ -4,8 +4,8 @@ exports.tryNormalizeIfThen = void 0;
4
4
  const input_format_1 = require("../../input-format");
5
5
  const structure_1 = require("../structure");
6
6
  const meta_1 = require("../meta");
7
- const parser_1 = require("../../parser");
8
7
  const hooks_1 = require("../../hooks");
8
+ const parser_1 = require("../../../json/parser");
9
9
  /**
10
10
  * Try to parse the construct as a {@link RIfThenElse}.
11
11
  */
@@ -27,7 +27,7 @@ function tryNormalizeIfThen(data, tokens) {
27
27
  if (parsedCondition.type === "RDelimiter" /* RType.Delimiter */ || parsedThen.type === "RDelimiter" /* RType.Delimiter */) {
28
28
  throw new input_format_1.XmlParseError(`unexpected missing parts of if, received ${JSON.stringify([parsedCondition, parsedThen])} for ${JSON.stringify(tokens)}`);
29
29
  }
30
- const { location, content } = (0, meta_1.retrieveMetaStructure)(data.config, tokens[0].content);
30
+ const { location, content } = (0, meta_1.retrieveMetaStructure)(tokens[0].content);
31
31
  const result = {
32
32
  type: "RIfThenElse" /* RType.IfThenElse */,
33
33
  condition: parsedCondition,
@@ -3,13 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizeExpression = void 0;
4
4
  const input_format_1 = require("../../input-format");
5
5
  const meta_1 = require("../meta");
6
- const parser_1 = require("../../parser");
7
6
  const structure_1 = require("../structure");
8
7
  const functions_1 = require("../functions");
9
8
  const hooks_1 = require("../../hooks");
10
9
  const access_1 = require("../access");
11
10
  const other_1 = require("../other");
12
11
  const arrays_1 = require("../../../../../../../util/arrays");
12
+ const parser_1 = require("../../../json/parser");
13
13
  /**
14
14
  * Returns an expression list if there are multiple children, otherwise returns the single child directly with no expr wrapper
15
15
  *
@@ -19,9 +19,9 @@ const arrays_1 = require("../../../../../../../util/arrays");
19
19
  function normalizeExpression(data, obj) {
20
20
  parser_1.parseLog.debug('Parsing expr');
21
21
  obj = (0, hooks_1.executeHook)(data.hooks.expression.onExpression.before, data, obj);
22
- const { unwrappedObj, content, location } = (0, meta_1.retrieveMetaStructure)(data.config, obj);
23
- const childrenSource = (0, input_format_1.getKeysGuarded)(unwrappedObj, data.config.childrenName);
24
- const typed = (0, meta_1.getWithTokenType)(data.config.tokenMap, childrenSource);
22
+ const { unwrappedObj, content, location } = (0, meta_1.retrieveMetaStructure)(obj);
23
+ const childrenSource = (0, input_format_1.getKeysGuarded)(unwrappedObj, input_format_1.childrenKey);
24
+ const typed = (0, meta_1.getWithTokenType)(childrenSource);
25
25
  const { others, comments } = (0, structure_1.splitComments)(typed);
26
26
  const childData = { ...data, currentRange: location, currentLexeme: content };
27
27
  const maybeFunctionCall = (0, functions_1.tryNormalizeFunctionCall)(childData, others);
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.tryToNormalizeArgument = void 0;
4
- const parser_1 = require("../../parser");
5
4
  const meta_1 = require("../meta");
6
5
  const hooks_1 = require("../../hooks");
7
6
  const log_1 = require("../../../../../../../util/log");
8
7
  const assert_1 = require("../../../../../../../util/assert");
9
8
  const structure_1 = require("../structure");
9
+ const parser_1 = require("../../../json/parser");
10
10
  /**
11
11
  * Either parses `[expr]` or `[SYMBOL_SUB, EQ_SUB, expr]` as an argument of a function call in R.
12
12
  * Probably directly called by the function call parser as otherwise, we do not expect to find arguments.
@@ -24,7 +24,7 @@ function tryToNormalizeArgument(data, objs) {
24
24
  return (0, hooks_1.executeUnknownHook)(data.hooks.functions.onArgument.unknown, data, objs);
25
25
  }
26
26
  const symbolOrExpr = objs[0];
27
- const { location, content } = (0, meta_1.retrieveMetaStructure)(data.config, symbolOrExpr.content);
27
+ const { location, content } = (0, meta_1.retrieveMetaStructure)(symbolOrExpr.content);
28
28
  let parsedValue;
29
29
  let name;
30
30
  if (symbolOrExpr.name === "expr" /* RawRType.Expression */) {
@@ -5,11 +5,11 @@ const input_format_1 = require("../../input-format");
5
5
  const assert_1 = require("../../../../../../../util/assert");
6
6
  const meta_1 = require("../meta");
7
7
  const arrays_1 = require("../../../../../../../util/arrays");
8
- const parser_1 = require("../../parser");
9
8
  const values_1 = require("../values");
10
9
  const hooks_1 = require("../../hooks");
11
10
  const argument_1 = require("./argument");
12
11
  const expression_1 = require("../expression");
12
+ const parser_1 = require("../../../json/parser");
13
13
  /**
14
14
  * Tries to parse the given data as a function call.
15
15
  *
@@ -31,10 +31,10 @@ function tryNormalizeFunctionCall(data, mappedWithName) {
31
31
  }
32
32
  parser_1.parseLog.trace('trying to parse function call');
33
33
  mappedWithName = (0, hooks_1.executeHook)(data.hooks.functions.onFunctionCall.before, data, mappedWithName);
34
- const { unwrappedObj, content, location } = (0, meta_1.retrieveMetaStructure)(data.config, fnBase.content);
35
- const symbolContent = (0, input_format_1.getKeysGuarded)(unwrappedObj, data.config.childrenName);
34
+ const { unwrappedObj, content, location } = (0, meta_1.retrieveMetaStructure)(fnBase.content);
35
+ const symbolContent = (0, input_format_1.getKeysGuarded)(unwrappedObj, input_format_1.childrenKey);
36
36
  let result;
37
- const namedSymbolContent = (0, meta_1.getWithTokenType)(data.config.tokenMap, symbolContent);
37
+ const namedSymbolContent = (0, meta_1.getWithTokenType)(symbolContent);
38
38
  if (namedSymbolContent.length === 1 && namedSymbolContent[0].name === "STR_CONST" /* RawRType.StringConst */) {
39
39
  // special handling when someone calls a function by string
40
40
  result = parseNamedFunctionCall(data, namedSymbolContent, mappedWithName, location, content);
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.tryNormalizeFunctionDefinition = void 0;
4
- const parser_1 = require("../../parser");
5
4
  const hooks_1 = require("../../hooks");
6
5
  const meta_1 = require("../meta");
7
6
  const assert_1 = require("../../../../../../../util/assert");
@@ -9,6 +8,7 @@ const arrays_1 = require("../../../../../../../util/arrays");
9
8
  const structure_1 = require("../structure");
10
9
  const parameter_1 = require("./parameter");
11
10
  const log_1 = require("../../../../../../../util/log");
11
+ const parser_1 = require("../../../json/parser");
12
12
  /**
13
13
  * Tries to parse the given data as a function definition.
14
14
  *
@@ -25,7 +25,7 @@ function tryNormalizeFunctionDefinition(data, mappedWithName) {
25
25
  }
26
26
  parser_1.parseLog.trace('trying to parse function definition');
27
27
  mappedWithName = (0, hooks_1.executeHook)(data.hooks.functions.onFunctionDefinition.before, data, mappedWithName);
28
- const { content, location } = (0, meta_1.retrieveMetaStructure)(data.config, fnBase.content);
28
+ const { content, location } = (0, meta_1.retrieveMetaStructure)(fnBase.content);
29
29
  const openParen = mappedWithName[1];
30
30
  (0, assert_1.guard)(openParen.name === "(" /* RawRType.ParenLeft */, () => `expected opening parenthesis, yet received ${openParen.name}`);
31
31
  const closingParenIndex = mappedWithName.findIndex(x => x.name === ")" /* RawRType.ParenRight */);
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.tryNormalizeParameter = void 0;
4
- const parser_1 = require("../../parser");
5
4
  const meta_1 = require("../meta");
6
5
  const hooks_1 = require("../../hooks");
7
6
  const log_1 = require("../../../../../../../util/log");
8
7
  const assert_1 = require("../../../../../../../util/assert");
9
8
  const structure_1 = require("../structure");
9
+ const parser_1 = require("../../../json/parser");
10
10
  /**
11
11
  * Either parses `[SYMBOL_FORMALS]` or `[SYMBOL_FORMALS, EQ_FORMALS, expr]` as a parameter of a function definition in R.
12
12
  * Probably directly called by the function definition parser as otherwise, we do not expect to find parameters.
@@ -29,7 +29,7 @@ function tryNormalizeParameter(data, objs) {
29
29
  return (0, hooks_1.executeUnknownHook)(data.hooks.functions.onParameter.unknown, data, objs);
30
30
  }
31
31
  const defaultValue = objs.length === 3 ? parseWithDefaultValue(data, objs) : undefined;
32
- const { location, content } = (0, meta_1.retrieveMetaStructure)(data.config, symbol.content);
32
+ const { location, content } = (0, meta_1.retrieveMetaStructure)(symbol.content);
33
33
  const result = {
34
34
  type: "RParameter" /* RType.Parameter */,
35
35
  location,
@@ -7,4 +7,3 @@ export * from './operators';
7
7
  export * from './structure';
8
8
  export * from './expression';
9
9
  export * from './meta';
10
- export * from './xml-to-json';
@@ -23,5 +23,4 @@ __exportStar(require("./operators"), exports);
23
23
  __exportStar(require("./structure"), exports);
24
24
  __exportStar(require("./expression"), exports);
25
25
  __exportStar(require("./meta"), exports);
26
- __exportStar(require("./xml-to-json"), exports);
27
26
  //# sourceMappingURL=index.js.map
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizeBreak = void 0;
4
- const parser_1 = require("../../parser");
5
4
  const hooks_1 = require("../../hooks");
6
5
  const meta_1 = require("../meta");
6
+ const parser_1 = require("../../../json/parser");
7
7
  function normalizeBreak(data, obj) {
8
8
  parser_1.parseLog.debug(`[break] try: ${JSON.stringify(obj)}`);
9
9
  obj = (0, hooks_1.executeHook)(data.hooks.loops.onBreak.before, data, obj);
10
- const { location, content } = (0, meta_1.retrieveMetaStructure)(data.config, obj);
10
+ const { location, content } = (0, meta_1.retrieveMetaStructure)(obj);
11
11
  const result = {
12
12
  type: "RBreak" /* RType.Break */,
13
13
  location,
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.tryNormalizeFor = void 0;
4
4
  const input_format_1 = require("../../input-format");
5
5
  const meta_1 = require("../meta");
6
- const parser_1 = require("../../parser");
7
6
  const assert_1 = require("../../../../../../../util/assert");
8
7
  const values_1 = require("../values");
9
8
  const structure_1 = require("../structure");
10
9
  const hooks_1 = require("../../hooks");
11
10
  const other_1 = require("../other");
11
+ const parser_1 = require("../../../json/parser");
12
12
  function tryNormalizeFor(data, forToken, head, body) {
13
13
  // funny, for does not use top-level parenthesis
14
14
  if (forToken.name !== "FOR" /* RawRType.For */) {
@@ -35,7 +35,7 @@ function tryNormalizeFor(data, forToken, head, body) {
35
35
  parseBody,
36
36
  ])}`);
37
37
  }
38
- const { location, content } = (0, meta_1.retrieveMetaStructure)(data.config, forToken.content);
38
+ const { location, content } = (0, meta_1.retrieveMetaStructure)(forToken.content);
39
39
  const result = {
40
40
  type: "RForLoop" /* RType.ForLoop */,
41
41
  variable: parsedVariable,
@@ -54,10 +54,7 @@ function tryNormalizeFor(data, forToken, head, body) {
54
54
  exports.tryNormalizeFor = tryNormalizeFor;
55
55
  function normalizeForHead(data, forCondition) {
56
56
  // must have a child which is `in`, a variable on the left, and a vector on the right
57
- const children = (0, input_format_1.getKeysGuarded)(forCondition, data.config.childrenName).map(content => ({
58
- name: (0, meta_1.getTokenType)(data.config.tokenMap, content),
59
- content
60
- }));
57
+ const children = (0, input_format_1.getKeysGuarded)(forCondition, input_format_1.childrenKey).map(content => ({ name: (0, meta_1.getTokenType)(content), content }));
61
58
  const { comments, others } = (0, structure_1.splitComments)(children);
62
59
  const inPosition = others.findIndex(elem => elem.name === "IN" /* RawRType.ForIn */);
63
60
  (0, assert_1.guard)(inPosition > 0 && inPosition < others.length - 1, () => `for loop searched in and found at ${inPosition}, but this is not in legal bounds for ${JSON.stringify(children)}`);
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizeNext = void 0;
4
- const parser_1 = require("../../parser");
5
4
  const hooks_1 = require("../../hooks");
6
5
  const meta_1 = require("../meta");
6
+ const parser_1 = require("../../../json/parser");
7
7
  function normalizeNext(data, obj) {
8
8
  parser_1.parseLog.debug(`[next] try: ${JSON.stringify(obj)}`);
9
9
  obj = (0, hooks_1.executeHook)(data.hooks.loops.onNext.before, data, obj);
10
- const { location, content } = (0, meta_1.retrieveMetaStructure)(data.config, obj);
10
+ const { location, content } = (0, meta_1.retrieveMetaStructure)(obj);
11
11
  const result = {
12
12
  type: "RNext" /* RType.Next */,
13
13
  location,
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.tryNormalizeRepeat = 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 hooks_1 = require("../../hooks");
8
+ const parser_1 = require("../../../json/parser");
9
9
  /**
10
10
  * Try to parse the construct as a {@link RRepeatLoop}.
11
11
  *
@@ -24,7 +24,7 @@ function tryNormalizeRepeat(data, repeatToken, body) {
24
24
  ({ repeatToken, body } = (0, hooks_1.executeHook)(data.hooks.loops.onRepeatLoop.before, data, { repeatToken, body }));
25
25
  const parseBody = (0, structure_1.tryNormalizeSingleNode)(data, body);
26
26
  (0, assert_1.guard)(parseBody.type !== "RDelimiter" /* RType.Delimiter */, () => `no body for repeat-loop ${JSON.stringify(repeatToken)} (${JSON.stringify(body)})`);
27
- const { location, content } = (0, meta_1.retrieveMetaStructure)(data.config, repeatToken.content);
27
+ const { location, content } = (0, meta_1.retrieveMetaStructure)(repeatToken.content);
28
28
  const result = {
29
29
  type: "RRepeatLoop" /* RType.RepeatLoop */,
30
30
  location,
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.tryNormalizeWhile = void 0;
4
4
  const input_format_1 = require("../../input-format");
5
5
  const meta_1 = require("../meta");
6
- const parser_1 = require("../../parser");
7
6
  const structure_1 = require("../structure");
8
7
  const hooks_1 = require("../../hooks");
8
+ const parser_1 = require("../../../json/parser");
9
9
  function tryNormalizeWhile(data, whileToken, leftParen, condition, rightParen, body) {
10
10
  if (whileToken.name !== "WHILE" /* RawRType.While */) {
11
11
  parser_1.parseLog.debug('encountered non-while token for supposed while-loop structure');
@@ -26,7 +26,7 @@ function tryNormalizeWhile(data, whileToken, leftParen, condition, rightParen, b
26
26
  parseBody,
27
27
  ])} for ${JSON.stringify([whileToken, condition, body])}`);
28
28
  }
29
- const { location, content } = (0, meta_1.retrieveMetaStructure)(data.config, whileToken.content);
29
+ const { location, content } = (0, meta_1.retrieveMetaStructure)(whileToken.content);
30
30
  const result = {
31
31
  type: "RWhileLoop" /* RType.WhileLoop */,
32
32
  condition: parsedCondition,
@@ -1,6 +1,5 @@
1
1
  import type { NamedXmlBasedJson, XmlBasedJson } from '../input-format';
2
2
  import type { SourceRange } from '../../../../../../util/range';
3
- import type { XmlParserConfig } from '../config';
4
3
  import type { RawRType, RExpressionList, RNode } from '../../../model';
5
4
  /**
6
5
  * if the passed object is an array with only one element, remove the array wrapper
@@ -14,37 +13,33 @@ export declare function extractLocation(ast: XmlBasedJson): SourceRange;
14
13
  * The json object that represents the input xml contains various meta-information.
15
14
  * This function extracts the meta-information and returns it.
16
15
  *
17
- * @param config - The configuration of the parser to use to retrieve the corresponding name fields
18
16
  * @param obj - The json object to extract the meta-information from
19
17
  */
20
- export declare function retrieveMetaStructure(config: XmlParserConfig, obj: XmlBasedJson): {
18
+ export declare function retrieveMetaStructure(obj: XmlBasedJson): {
21
19
  /** the obj passed in, but potentially without surrounding array wrappers (see {@link objectWithArrUnwrap}) */
22
20
  unwrappedObj: XmlBasedJson;
23
21
  /** location information of the corresponding R-ast element */
24
22
  location: SourceRange;
25
23
  content: string;
26
24
  };
27
- export declare function revertTokenReplacement(tokenMap: XmlParserConfig['tokenMap'], token: string): string;
28
- export declare function assureTokenType(tokenMap: XmlParserConfig['tokenMap'], obj: XmlBasedJson, expectedName: RawRType): void;
25
+ export declare function assureTokenType(obj: XmlBasedJson, expectedName: RawRType): void;
29
26
  /**
30
27
  * Extract the token-type of the given object. This is based on the knowledge, that all json objects created
31
28
  * from the R xml have a name attached.
32
29
  *
33
- * @param tokenMap - used to revert token types (i.e., revert `xmlparsedata`)
34
30
  * @param content - the json object to extract the token-type from
35
31
  */
36
- export declare function getTokenType(tokenMap: XmlParserConfig['tokenMap'], content: XmlBasedJson): RawRType;
37
- export declare function getWithTokenType(tokenMap: XmlParserConfig['tokenMap'], obj: XmlBasedJson[]): {
32
+ export declare function getTokenType(content: XmlBasedJson): RawRType;
33
+ export declare function getWithTokenType(obj: XmlBasedJson[]): {
38
34
  name: RawRType;
39
35
  content: XmlBasedJson;
40
36
  }[];
41
- export declare function retrieveOpName(config: XmlParserConfig, operator: NamedXmlBasedJson): string;
37
+ export declare function retrieveOpName(operator: NamedXmlBasedJson): string;
42
38
  /**
43
39
  * Ensure that the first child is completely before the second child.
44
40
  *
45
- * @param config - the configuration of the parser to use to retrieve the corresponding name fields
46
41
  * @param first - the first child which should be the lhs
47
42
  * @param second - the second child which should be the rhs
48
43
  */
49
- export declare function ensureChildrenAreLhsAndRhsOrdered(config: XmlParserConfig, first: XmlBasedJson, second: XmlBasedJson): void;
44
+ export declare function ensureChildrenAreLhsAndRhsOrdered(first: XmlBasedJson, second: XmlBasedJson): void;
50
45
  export declare function ensureExpressionList<Info>(node: RNode<Info>): RExpressionList<Info>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ensureExpressionList = exports.ensureChildrenAreLhsAndRhsOrdered = exports.retrieveOpName = exports.getWithTokenType = exports.getTokenType = exports.assureTokenType = exports.revertTokenReplacement = exports.retrieveMetaStructure = exports.extractLocation = exports.objectWithArrUnwrap = void 0;
3
+ exports.ensureExpressionList = exports.ensureChildrenAreLhsAndRhsOrdered = exports.retrieveOpName = exports.getWithTokenType = exports.getTokenType = exports.assureTokenType = exports.retrieveMetaStructure = exports.extractLocation = exports.objectWithArrUnwrap = void 0;
4
4
  const input_format_1 = require("../input-format");
5
5
  const range_1 = require("../../../../../../util/range");
6
6
  const assert_1 = require("../../../../../../util/assert");
@@ -34,13 +34,12 @@ exports.extractLocation = extractLocation;
34
34
  * The json object that represents the input xml contains various meta-information.
35
35
  * This function extracts the meta-information and returns it.
36
36
  *
37
- * @param config - The configuration of the parser to use to retrieve the corresponding name fields
38
37
  * @param obj - The json object to extract the meta-information from
39
38
  */
40
- function retrieveMetaStructure(config, obj) {
39
+ function retrieveMetaStructure(obj) {
41
40
  const unwrappedObj = objectWithArrUnwrap(obj);
42
- const attributes = obj[config.attributeName];
43
- const content = obj[config.contentName] ?? '';
41
+ const attributes = obj[input_format_1.attributesKey];
42
+ const content = obj[input_format_1.contentKey] ?? '';
44
43
  (0, assert_1.guard)(attributes !== undefined, () => `expected attributes to be defined for ${JSON.stringify(obj)}`);
45
44
  const location = extractLocation(attributes);
46
45
  return {
@@ -50,13 +49,8 @@ function retrieveMetaStructure(config, obj) {
50
49
  };
51
50
  }
52
51
  exports.retrieveMetaStructure = retrieveMetaStructure;
53
- function revertTokenReplacement(tokenMap, token) {
54
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- it is still necessary as we do not know if we have a replacement for the given token
55
- return tokenMap[token] ?? token;
56
- }
57
- exports.revertTokenReplacement = revertTokenReplacement;
58
- function assureTokenType(tokenMap, obj, expectedName) {
59
- const name = getTokenType(tokenMap, obj);
52
+ function assureTokenType(obj, expectedName) {
53
+ const name = getTokenType(obj);
60
54
  if (name !== expectedName) {
61
55
  throw new input_format_1.XmlParseError(`expected name to be ${expectedName}, yet received ${name} for ${JSON.stringify(obj)}`);
62
56
  }
@@ -66,37 +60,35 @@ exports.assureTokenType = assureTokenType;
66
60
  * Extract the token-type of the given object. This is based on the knowledge, that all json objects created
67
61
  * from the R xml have a name attached.
68
62
  *
69
- * @param tokenMap - used to revert token types (i.e., revert `xmlparsedata`)
70
63
  * @param content - the json object to extract the token-type from
71
64
  */
72
- function getTokenType(tokenMap, content) {
73
- return revertTokenReplacement(tokenMap, (0, input_format_1.getKeysGuarded)(content, '#name'));
65
+ function getTokenType(content) {
66
+ return (0, input_format_1.getKeysGuarded)(content, input_format_1.nameKey);
74
67
  }
75
68
  exports.getTokenType = getTokenType;
76
- function getWithTokenType(tokenMap, obj) {
69
+ function getWithTokenType(obj) {
77
70
  return obj.map((content) => ({
78
- name: getTokenType(tokenMap, content),
71
+ name: getTokenType(content),
79
72
  content
80
73
  }));
81
74
  }
82
75
  exports.getWithTokenType = getWithTokenType;
83
- function retrieveOpName(config, operator) {
76
+ function retrieveOpName(operator) {
84
77
  /*
85
78
  * only real arithmetic ops have their operation as their own name, the others identify via content
86
79
  */
87
- return operator.content[config.contentName];
80
+ return operator.content[input_format_1.contentKey];
88
81
  }
89
82
  exports.retrieveOpName = retrieveOpName;
90
83
  /**
91
84
  * Ensure that the first child is completely before the second child.
92
85
  *
93
- * @param config - the configuration of the parser to use to retrieve the corresponding name fields
94
86
  * @param first - the first child which should be the lhs
95
87
  * @param second - the second child which should be the rhs
96
88
  */
97
- function ensureChildrenAreLhsAndRhsOrdered(config, first, second) {
98
- const firstOtherLoc = extractLocation(first[config.attributeName]);
99
- const secondOtherLoc = extractLocation(second[config.attributeName]);
89
+ function ensureChildrenAreLhsAndRhsOrdered(first, second) {
90
+ const firstOtherLoc = extractLocation(first[input_format_1.attributesKey]);
91
+ const secondOtherLoc = extractLocation(second[input_format_1.attributesKey]);
100
92
  if (!(0, range_1.rangeStartsCompletelyBefore)(firstOtherLoc, secondOtherLoc)) {
101
93
  throw new input_format_1.XmlParseError(`expected the first child to be the lhs, yet received ${JSON.stringify(first)} & ${JSON.stringify(second)}`);
102
94
  }