@eagleoutice/flowr 1.3.11 → 1.3.13

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 (125) hide show
  1. package/cli/common/scripts-info.d.ts +1 -1
  2. package/package.json +3 -4
  3. package/benchmark/benchmark-slicer.js +0 -223
  4. package/core/pipeline-executor.js +0 -221
  5. package/core/stepping-slicer.js +0 -160
  6. package/core/steps/all/00-parse.js +0 -19
  7. package/core/steps/all/10-normalize.js +0 -21
  8. package/core/steps/all/20-dataflow.js +0 -21
  9. package/core/steps/all/30-slice.js +0 -16
  10. package/core/steps/all/40-reconstruct.js +0 -16
  11. package/core/steps/all/core/00-parse.js +0 -24
  12. package/core/steps/all/core/10-normalize.js +0 -46
  13. package/core/steps/all/core/20-dataflow.js +0 -39
  14. package/core/steps/all/static-slicing/00-slice.js +0 -21
  15. package/core/steps/all/static-slicing/10-reconstruct.js +0 -21
  16. package/core/steps/index.js +0 -21
  17. package/core/steps/input.js +0 -3
  18. package/core/steps/output.js +0 -3
  19. package/core/steps/pipeline/create.js +0 -130
  20. package/core/steps/pipeline/default.js +0 -15
  21. package/core/steps/pipeline/dependency-checker.js +0 -76
  22. package/core/steps/pipeline/index.js +0 -20
  23. package/core/steps/pipeline/invalid-pipeline-error.js +0 -14
  24. package/core/steps/pipeline/pipeline.js +0 -28
  25. package/core/steps/step.js +0 -8
  26. package/core/steps/steps-provider.js +0 -3
  27. package/core/steps/steps.js +0 -35
  28. package/dataflow/common/environments/append.js +0 -48
  29. package/dataflow/common/environments/environment.js +0 -165
  30. package/dataflow/common/environments/index.js +0 -23
  31. package/dataflow/common/environments/overwrite.js +0 -82
  32. package/dataflow/common/environments/register.js +0 -49
  33. package/dataflow/common/environments/resolve-by-name.js +0 -35
  34. package/dataflow/common/environments/scopes.js +0 -6
  35. package/dataflow/common/environments/scoping.js +0 -27
  36. package/dataflow/graph/equal.js +0 -127
  37. package/dataflow/v1/extractor.js +0 -60
  38. package/dataflow/v1/graph/diff.js +0 -206
  39. package/dataflow/v1/graph/edge.js +0 -32
  40. package/dataflow/v1/graph/graph.js +0 -298
  41. package/dataflow/v1/graph/index.js +0 -21
  42. package/dataflow/v1/graph/quads.js +0 -27
  43. package/dataflow/v1/graph/vertex.js +0 -3
  44. package/dataflow/v1/index.js +0 -24
  45. package/dataflow/v1/internal/info.js +0 -16
  46. package/dataflow/v1/internal/linker.js +0 -255
  47. package/dataflow/v1/internal/process/access.js +0 -54
  48. package/dataflow/v1/internal/process/expression-list.js +0 -154
  49. package/dataflow/v1/internal/process/functions/argument.js +0 -46
  50. package/dataflow/v1/internal/process/functions/exit-points.js +0 -125
  51. package/dataflow/v1/internal/process/functions/function-call.js +0 -99
  52. package/dataflow/v1/internal/process/functions/function-definition.js +0 -176
  53. package/dataflow/v1/internal/process/functions/parameter.js +0 -47
  54. package/dataflow/v1/internal/process/if-then-else.js +0 -57
  55. package/dataflow/v1/internal/process/loops/for-loop.js +0 -54
  56. package/dataflow/v1/internal/process/loops/repeat-loop.js +0 -21
  57. package/dataflow/v1/internal/process/loops/while-loop.js +0 -31
  58. package/dataflow/v1/internal/process/operators/assignment.js +0 -129
  59. package/dataflow/v1/internal/process/operators/non-assignment-binary-op.js +0 -25
  60. package/dataflow/v1/internal/process/operators/pipe.js +0 -46
  61. package/dataflow/v1/internal/process/operators/unary-op.js +0 -10
  62. package/dataflow/v1/internal/process/symbol.js +0 -21
  63. package/dataflow/v1/internal/process/uninteresting-leaf.js +0 -9
  64. package/dataflow/v1/processor.js +0 -20
  65. package/dataflow/v2/entry.js +0 -11
  66. package/flowr-1.3.7.tgz +0 -0
  67. package/r-bridge/lang-4.x/ast/parser/xml/common/config.js +0 -16
  68. package/r-bridge/lang-4.x/ast/parser/xml/common/input-format.js +0 -42
  69. package/r-bridge/lang-4.x/ast/parser/xml/common/meta.js +0 -118
  70. package/r-bridge/lang-4.x/ast/parser/xml/common/xml-to-json.js +0 -58
  71. package/r-bridge/lang-4.x/ast/parser/xml/v1/data.js +0 -3
  72. package/r-bridge/lang-4.x/ast/parser/xml/v1/hooks.js +0 -136
  73. package/r-bridge/lang-4.x/ast/parser/xml/v1/index.js +0 -22
  74. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/access.js +0 -107
  75. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/control/if-then-else.js +0 -32
  76. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/control/if-then.js +0 -46
  77. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/control/index.js +0 -19
  78. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/expression/expression.js +0 -65
  79. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/expression/index.js +0 -18
  80. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/functions/argument.js +0 -74
  81. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/functions/call.js +0 -149
  82. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/functions/definition.js +0 -60
  83. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/functions/index.js +0 -20
  84. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/functions/parameter.js +0 -64
  85. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/index.js +0 -27
  86. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/loops/break.js +0 -24
  87. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/loops/for.js +0 -72
  88. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/loops/index.js +0 -22
  89. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/loops/next.js +0 -24
  90. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/loops/repeat.js +0 -42
  91. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/loops/while.js +0 -45
  92. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/operators/binary.js +0 -162
  93. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/operators/index.js +0 -20
  94. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/operators/special.js +0 -24
  95. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/operators/unary.js +0 -59
  96. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/other/comment.js +0 -34
  97. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/other/index.js +0 -18
  98. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/other/line-directive.js +0 -55
  99. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/structure/elements.js +0 -159
  100. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/structure/index.js +0 -20
  101. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/structure/root.js +0 -34
  102. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/structure/single-element.js +0 -64
  103. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/values/index.js +0 -20
  104. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/values/number.js +0 -56
  105. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/values/string.js +0 -41
  106. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/values/symbol.js +0 -56
  107. package/r-bridge/lang-4.x/ast/parser/xml/v1/normalize.js +0 -30
  108. package/r-bridge/lang-4.x/ast/parser/xml/v2/data.js +0 -3
  109. package/r-bridge/lang-4.x/ast/parser/xml/v2/internal/access.js +0 -95
  110. package/r-bridge/lang-4.x/ast/parser/xml/v2/internal/expression.js +0 -99
  111. package/r-bridge/lang-4.x/ast/parser/xml/v2/internal/functions/argument.js +0 -71
  112. package/r-bridge/lang-4.x/ast/parser/xml/v2/internal/operators/binary.js +0 -30
  113. package/r-bridge/lang-4.x/ast/parser/xml/v2/internal/operators/index.js +0 -19
  114. package/r-bridge/lang-4.x/ast/parser/xml/v2/internal/operators/unary.js +0 -35
  115. package/r-bridge/lang-4.x/ast/parser/xml/v2/internal/other/comment.js +0 -25
  116. package/r-bridge/lang-4.x/ast/parser/xml/v2/internal/other/index.js +0 -18
  117. package/r-bridge/lang-4.x/ast/parser/xml/v2/internal/other/line-directive.js +0 -38
  118. package/r-bridge/lang-4.x/ast/parser/xml/v2/internal/root.js +0 -26
  119. package/r-bridge/lang-4.x/ast/parser/xml/v2/internal/single-element.js +0 -63
  120. package/r-bridge/lang-4.x/ast/parser/xml/v2/internal/values/index.js +0 -18
  121. package/r-bridge/lang-4.x/ast/parser/xml/v2/internal/values/number.js +0 -46
  122. package/r-bridge/lang-4.x/ast/parser/xml/v2/internal/values/string.js +0 -33
  123. package/r-bridge/lang-4.x/ast/parser/xml/v2/internal/values/symbol.js +0 -63
  124. package/r-bridge/lang-4.x/ast/parser/xml/v2/normalize.js +0 -25
  125. package/util/summarizer/benchmark/benchmark-summarizer.js +0 -208
@@ -1,159 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseNodesWithUnknownType = exports.normalizeBasedOnType = exports.splitComments = void 0;
4
- const arrays_1 = require("../../../../../../../../util/arrays");
5
- const normalize_1 = require("../../normalize");
6
- const meta_1 = require("../../../common/meta");
7
- const single_element_1 = require("./single-element");
8
- const values_1 = require("../values");
9
- const operators_1 = require("../operators");
10
- const loops_1 = require("../loops");
11
- const control_1 = require("../control");
12
- const log_1 = require("../../../../../../../../util/log");
13
- const other_1 = require("../other");
14
- function normalizeMappedWithoutSemicolonBasedOnType(mappedWithName, data) {
15
- if (mappedWithName.length === 1) {
16
- return [(0, single_element_1.tryNormalizeSingleNode)(data, mappedWithName[0])];
17
- }
18
- else if (mappedWithName.length === 2) {
19
- const unaryOp = (0, operators_1.tryNormalizeUnary)(data, mappedWithName[0], mappedWithName[1]);
20
- if (unaryOp !== undefined) {
21
- return [unaryOp];
22
- }
23
- const repeatLoop = (0, loops_1.tryNormalizeRepeat)(data, mappedWithName[0], mappedWithName[1]);
24
- if (repeatLoop !== undefined) {
25
- return [repeatLoop];
26
- }
27
- }
28
- else if (mappedWithName.length === 3) {
29
- const binary = (0, operators_1.tryNormalizeBinary)(data, mappedWithName[0], mappedWithName[1], mappedWithName[2]);
30
- if (binary !== undefined) {
31
- return [binary];
32
- }
33
- else {
34
- const forLoop = (0, loops_1.tryNormalizeFor)(data, mappedWithName[0], mappedWithName[1], mappedWithName[2]);
35
- if (forLoop !== undefined) {
36
- return [forLoop];
37
- }
38
- else {
39
- // could be a symbol with namespace information
40
- const symbol = (0, values_1.tryNormalizeSymbol)(data, mappedWithName);
41
- if (symbol !== undefined) {
42
- return [symbol];
43
- }
44
- }
45
- }
46
- }
47
- else if (mappedWithName.length === 5) {
48
- const ifThen = (0, control_1.tryNormalizeIfThen)(data, [
49
- mappedWithName[0],
50
- mappedWithName[1],
51
- mappedWithName[2],
52
- mappedWithName[3],
53
- mappedWithName[4]
54
- ]);
55
- if (ifThen !== undefined) {
56
- return [ifThen];
57
- }
58
- else {
59
- const whileLoop = (0, loops_1.tryNormalizeWhile)(data, mappedWithName[0], mappedWithName[1], mappedWithName[2], mappedWithName[3], mappedWithName[4]);
60
- if (whileLoop !== undefined) {
61
- return [whileLoop];
62
- }
63
- }
64
- }
65
- else if (mappedWithName.length === 7) {
66
- const ifThenElse = (0, control_1.tryNormalizeIfThenElse)(data, [
67
- mappedWithName[0],
68
- mappedWithName[1],
69
- mappedWithName[2],
70
- mappedWithName[3],
71
- mappedWithName[4],
72
- mappedWithName[5],
73
- mappedWithName[6]
74
- ]);
75
- if (ifThenElse !== undefined) {
76
- return [ifThenElse];
77
- }
78
- }
79
- // otherwise perform default parsing
80
- return parseNodesWithUnknownType(data, mappedWithName);
81
- }
82
- function splitComments(mappedWithName) {
83
- const comments = [];
84
- const others = [];
85
- for (const elem of mappedWithName) {
86
- if (elem.name === "COMMENT" /* RawRType.Comment */) {
87
- comments.push(elem);
88
- }
89
- else {
90
- others.push(elem);
91
- }
92
- }
93
- return { comments, others };
94
- }
95
- exports.splitComments = splitComments;
96
- function normalizeBasedOnType(data, obj) {
97
- if (obj.length === 0) {
98
- normalize_1.parseLog.warn('no children received, skipping');
99
- return [];
100
- }
101
- let mappedWithName;
102
- if (obj[0].name) {
103
- mappedWithName = obj;
104
- }
105
- else {
106
- mappedWithName = (0, meta_1.getWithTokenType)(data.config.tokenMap, obj);
107
- }
108
- log_1.log.trace(`[parseBasedOnType] names: [${mappedWithName.map(({ name }) => name).join(', ')}]`);
109
- const semiColons = [];
110
- const splitOnSemicolon = (0, arrays_1.splitArrayOn)(mappedWithName, node => {
111
- const res = node.name === ";" /* RawRType.Semicolon */;
112
- if (res) {
113
- const { location, content } = (0, meta_1.retrieveMetaStructure)(data.config, node.content);
114
- semiColons.push({
115
- type: "RDelimiter" /* RType.Delimiter */,
116
- subtype: ";" /* RawRType.Semicolon */,
117
- location: location,
118
- lexeme: content
119
- });
120
- }
121
- return res;
122
- });
123
- if (splitOnSemicolon.length > 1) {
124
- log_1.log.trace(`found ${splitOnSemicolon.length} expressions by semicolon-split, parsing them separately`);
125
- const flattened = [];
126
- for (const sub of splitOnSemicolon) {
127
- const result = normalizeBasedOnType(data, sub);
128
- if (result.length === 1 && result[0].type === "RExpressionList" /* RType.ExpressionList */) {
129
- flattened.push(...result[0].children);
130
- }
131
- else {
132
- flattened.push(...result);
133
- }
134
- }
135
- return [...flattened, ...semiColons];
136
- }
137
- /*
138
- * if splitOnSemicolon.length === 1, we can continue with the normal parsing, but we may have had a trailing semicolon, with this, it is removed as well.
139
- * splitOnSemicolon.length === 0 is not possible, as we would have had an empty array before, split does not add elements.
140
- */
141
- mappedWithName = splitOnSemicolon[0];
142
- const { comments, others } = splitComments(mappedWithName);
143
- const parsedComments = comments.map(c => (0, other_1.normalizeComment)(data, c.content));
144
- const result = normalizeMappedWithoutSemicolonBasedOnType(others, data);
145
- // we hoist comments
146
- return [...parsedComments, ...result];
147
- }
148
- exports.normalizeBasedOnType = normalizeBasedOnType;
149
- function parseNodesWithUnknownType(data, mappedWithName) {
150
- const parsedNodes = [];
151
- // used to indicate the new root node of this set of nodes
152
- for (const elem of mappedWithName) {
153
- const retrieved = (0, single_element_1.tryNormalizeSingleNode)(data, elem);
154
- parsedNodes.push(retrieved);
155
- }
156
- return parsedNodes;
157
- }
158
- exports.parseNodesWithUnknownType = parseNodesWithUnknownType;
159
- //# sourceMappingURL=elements.js.map
@@ -1,20 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./root"), exports);
18
- __exportStar(require("./elements"), exports);
19
- __exportStar(require("./single-element"), exports);
20
- //# sourceMappingURL=index.js.map
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.normalizeRootObjToAst = void 0;
4
- const input_format_1 = require("../../../common/input-format");
5
- const meta_1 = require("../../../common/meta");
6
- const elements_1 = require("./elements");
7
- const log_1 = require("../../../../../../../../util/log");
8
- const arrays_1 = require("../../../../../../../../util/arrays");
9
- function normalizeRootObjToAst(data, obj) {
10
- const config = data.config;
11
- const exprContent = (0, input_format_1.getKeyGuarded)(obj, "exprlist" /* RawRType.ExpressionList */);
12
- (0, meta_1.assureTokenType)(config.tokenMap, exprContent, "exprlist" /* RawRType.ExpressionList */);
13
- let parsedChildren = [];
14
- if (config.children in exprContent) {
15
- const children = (0, input_format_1.getKeyGuarded)(exprContent, config.children);
16
- parsedChildren = (0, elements_1.normalizeBasedOnType)(data, children);
17
- }
18
- else {
19
- log_1.log.debug('no children found, assume empty input');
20
- }
21
- const [delimiters, nodes] = (0, arrays_1.partition)(parsedChildren, x => x.type === "RDelimiter" /* RType.Delimiter */);
22
- return {
23
- type: "RExpressionList" /* RType.ExpressionList */,
24
- children: nodes,
25
- lexeme: undefined,
26
- info: {
27
- fullRange: data.currentRange,
28
- additionalTokens: delimiters,
29
- fullLexeme: data.currentLexeme
30
- }
31
- };
32
- }
33
- exports.normalizeRootObjToAst = normalizeRootObjToAst;
34
- //# sourceMappingURL=root.js.map
@@ -1,64 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.tryNormalizeSingleNode = void 0;
4
- const input_format_1 = require("../../../common/input-format");
5
- const values_1 = require("../values");
6
- const assert_1 = require("../../../../../../../../util/assert");
7
- const expression_1 = require("../expression");
8
- const meta_1 = require("../../../common/meta");
9
- const other_1 = require("../other");
10
- const loops_1 = require("../loops");
11
- const line_directive_1 = require("../other/line-directive");
12
- function normalizeDelimiter(data, elem) {
13
- const { location, content } = (0, meta_1.retrieveMetaStructure)(data.config, elem.content);
14
- return {
15
- type: "RDelimiter" /* RType.Delimiter */,
16
- location,
17
- lexeme: content,
18
- subtype: elem.name
19
- };
20
- }
21
- /**
22
- * Parses a single structure in the ast based on its type (e.g., a string, a number, a symbol, ...)
23
- *
24
- * @param data - The data used by the parser (see {@link ParserData})
25
- * @param elem - The element to parse
26
- *
27
- * @returns The parsed element as an `RNode` or an `RDelimiter` if it is such.
28
- */
29
- function tryNormalizeSingleNode(data, elem) {
30
- switch (elem.name) {
31
- case "(" /* RawRType.ParenLeft */:
32
- case ")" /* RawRType.ParenRight */:
33
- case "{" /* RawRType.BraceLeft */:
34
- case "}" /* RawRType.BraceRight */:
35
- return normalizeDelimiter(data, elem);
36
- case "COMMENT" /* RawRType.Comment */:
37
- return (0, other_1.normalizeComment)(data, elem.content);
38
- case "LINE_DIRECTIVE" /* RawRType.LineDirective */:
39
- return (0, line_directive_1.normalizeLineDirective)(data, elem.content);
40
- case "exprlist" /* RawRType.ExpressionList */:
41
- case "expr" /* RawRType.Expression */:
42
- case "expr_or_assign_or_help" /* RawRType.ExprOfAssignOrHelp */:
43
- return (0, expression_1.normalizeExpression)(data, elem.content);
44
- case "NUM_CONST" /* RawRType.NumericConst */:
45
- return (0, values_1.normalizeNumber)(data, elem.content);
46
- case "STR_CONST" /* RawRType.StringConst */:
47
- return (0, values_1.normalizeString)(data, elem.content);
48
- case "BREAK" /* RawRType.Break */:
49
- return (0, loops_1.normalizeBreak)(data, elem.content);
50
- case "NEXT" /* RawRType.Next */:
51
- return (0, loops_1.normalizeNext)(data, elem.content);
52
- case "SYMBOL" /* RawRType.Symbol */:
53
- case "SLOT" /* RawRType.Slot */:
54
- case "NULL_CONST" /* RawRType.NullConst */: {
55
- const symbol = (0, values_1.tryNormalizeSymbol)(data, (0, meta_1.getWithTokenType)(data.config.tokenMap, [elem.content]));
56
- (0, assert_1.guard)(symbol !== undefined, () => `should have been parsed to a symbol but was ${JSON.stringify(symbol)}`);
57
- return symbol;
58
- }
59
- default:
60
- throw new input_format_1.XmlParseError(`unknown type ${elem.name} for ${JSON.stringify(elem)} in ${JSON.stringify(data)}`);
61
- }
62
- }
63
- exports.tryNormalizeSingleNode = tryNormalizeSingleNode;
64
- //# sourceMappingURL=single-element.js.map
@@ -1,20 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./number"), exports);
18
- __exportStar(require("./string"), exports);
19
- __exportStar(require("./symbol"), exports);
20
- //# sourceMappingURL=index.js.map
@@ -1,56 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.normalizeNumber = void 0;
4
- const values_1 = require("../../../../../../values");
5
- const normalize_1 = require("../../normalize");
6
- const meta_1 = require("../../../common/meta");
7
- const hooks_1 = require("../../hooks");
8
- /**
9
- * Normalize the given object as a R number (see {@link number2ts}), supporting booleans (see {@link boolean2ts}),
10
- * and special values.
11
- * This requires you to check the corresponding name beforehand.
12
- *
13
- * @param data - The data used by the parser (see {@link ParserData})
14
- * @param obj - The json object to extract the meta-information from
15
- */
16
- function normalizeNumber(data, obj) {
17
- normalize_1.parseLog.debug('[number]');
18
- obj = (0, hooks_1.executeHook)(data.hooks.values.onNumber.before, data, obj);
19
- const { location, content } = (0, meta_1.retrieveMetaStructure)(data.config, obj);
20
- const common = {
21
- location,
22
- lexeme: content,
23
- info: {
24
- fullRange: data.currentRange,
25
- additionalTokens: [],
26
- fullLexeme: data.currentLexeme
27
- }
28
- };
29
- let result;
30
- /* the special symbol */
31
- if ((0, values_1.isNA)(content)) {
32
- result = {
33
- ...common,
34
- namespace: undefined,
35
- type: "RSymbol" /* RType.Symbol */,
36
- content
37
- };
38
- }
39
- else if ((0, values_1.isBoolean)(content)) {
40
- result = {
41
- ...common,
42
- type: "RLogical" /* RType.Logical */,
43
- content: (0, values_1.boolean2ts)(content)
44
- };
45
- }
46
- else {
47
- result = {
48
- ...common,
49
- type: "RNumber" /* RType.Number */,
50
- content: (0, values_1.number2ts)(content)
51
- };
52
- }
53
- return (0, hooks_1.executeHook)(data.hooks.values.onNumber.after, data, result);
54
- }
55
- exports.normalizeNumber = normalizeNumber;
56
- //# sourceMappingURL=number.js.map
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.normalizeString = void 0;
4
- const meta_1 = require("../../../common/meta");
5
- const values_1 = require("../../../../../../values");
6
- const normalize_1 = require("../../normalize");
7
- const hooks_1 = require("../../hooks");
8
- const assert_1 = require("../../../../../../../../util/assert");
9
- /**
10
- * Normalize the given object as a R string (see {@link string2ts}).
11
- * This requires you to check the corresponding name beforehand.
12
- *
13
- * @param data - The data used by the parser (see {@link ParserData})
14
- * @param obj - The json object to extract the meta-information from
15
- */
16
- function normalizeString(data, obj) {
17
- normalize_1.parseLog.debug('[string]');
18
- obj = (0, hooks_1.executeHook)(data.hooks.values.onString.before, data, obj);
19
- const { location, content } = (0, meta_1.retrieveMetaStructure)(data.config, obj);
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
- // therefore, we recover the full string from the surrounding expr lexeme field
22
- let stringContent = content;
23
- if (stringContent.startsWith('[')) { // something like "[9999 chars quoted with '"']"
24
- (0, assert_1.guard)(data.currentLexeme !== undefined, 'need current lexeme wrapper for too long strings as they are not stored by the R parser post-processor');
25
- stringContent = data.currentLexeme;
26
- }
27
- const result = {
28
- type: "RString" /* RType.String */,
29
- location,
30
- content: (0, values_1.string2ts)(stringContent),
31
- lexeme: stringContent,
32
- info: {
33
- fullRange: data.currentRange,
34
- additionalTokens: [],
35
- fullLexeme: data.currentLexeme
36
- }
37
- };
38
- return (0, hooks_1.executeHook)(data.hooks.values.onString.after, data, result);
39
- }
40
- exports.normalizeString = normalizeString;
41
- //# sourceMappingURL=string.js.map
@@ -1,56 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.tryNormalizeSymbol = void 0;
4
- const assert_1 = require("../../../../../../../../util/assert");
5
- const meta_1 = require("../../../common/meta");
6
- const normalize_1 = require("../../normalize");
7
- const model_1 = require("../../../../../model");
8
- const hooks_1 = require("../../hooks");
9
- const strings_1 = require("../../../../../../../../util/strings");
10
- /**
11
- * Normalize the given object as an R symbol (incorporating namespace information).
12
- * <p>
13
- * The special symbols `T` and `F` are parsed as logic values.
14
- *
15
- * @param data - The data used by the parser (see {@link ParserData})
16
- * @param objs - The json object to extract the meta-information from
17
- *
18
- * @returns The parsed symbol (with populated namespace information) or `undefined` if the given object is not a symbol.
19
- */
20
- function tryNormalizeSymbol(data, objs) {
21
- (0, assert_1.guard)(objs.length > 0, 'to parse symbols we need at least one object to work on!');
22
- normalize_1.parseLog.debug('trying to parse symbol');
23
- objs = (0, hooks_1.executeHook)(data.hooks.values.onSymbol.before, data, objs);
24
- let location, content, namespace;
25
- if (objs.length === 1 && (0, model_1.isSymbol)(objs[0].name)) {
26
- const meta = (0, meta_1.retrieveMetaStructure)(data.config, objs[0].content);
27
- location = meta.location;
28
- content = meta.content;
29
- namespace = undefined;
30
- }
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);
33
- location = meta.location;
34
- content = meta.content;
35
- namespace = (0, meta_1.retrieveMetaStructure)(data.config, objs[0].content).content;
36
- }
37
- else {
38
- return (0, hooks_1.executeUnknownHook)(data.hooks.values.onSymbol.unknown, data, objs);
39
- }
40
- const result = {
41
- type: "RSymbol" /* RType.Symbol */,
42
- namespace,
43
- location,
44
- // remove backticks from symbol
45
- content: (0, strings_1.startAndEndsWith)(content, '`') ? content.substring(1, content.length - 1) : content,
46
- lexeme: content,
47
- info: {
48
- fullRange: data.currentRange,
49
- additionalTokens: [],
50
- fullLexeme: data.currentLexeme
51
- }
52
- };
53
- return (0, hooks_1.executeHook)(data.hooks.values.onSymbol.after, data, result);
54
- }
55
- exports.tryNormalizeSymbol = tryNormalizeSymbol;
56
- //# sourceMappingURL=symbol.js.map
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.normalize = exports.parseLog = void 0;
4
- const objects_1 = require("../../../../../../util/objects");
5
- const log_1 = require("../../../../../../util/log");
6
- const config_1 = require("../common/config");
7
- const internal_1 = require("./internal");
8
- const model_1 = require("../../../model");
9
- const hooks_1 = require("./hooks");
10
- exports.parseLog = log_1.log.getSubLogger({ name: 'ast-parser' });
11
- /**
12
- * The main entry point to normalize the given R ast.
13
- * You probably want to use {@link retrieveNormalizedAstFromRCode} to directly normalize a piece of code.
14
- *
15
- * @param xmlString - The XML string obtained probably by {@link retrieveXmlFromRCode} for normalization.
16
- * @param tokenMap - The token replacement map in effect by the XML parser
17
- * @param hooks - Optional hooks to customize the normalization process (see {@link XmlParserHooks} for details)
18
- * @param getId - The function to be used to generate unique ids for the nodes of the ast. It is up to you to ensure that the ids are unique!
19
- *
20
- * @returns The normalized and decorated AST (i.e., as a doubly linked tree)
21
- */
22
- async function normalize(xmlString, tokenMap, hooks, getId = (0, model_1.deterministicCountingIdGenerator)(0)) {
23
- const config = { ...config_1.DEFAULT_XML_PARSER_CONFIG, tokenMap };
24
- const hooksWithDefaults = (0, objects_1.deepMergeObject)(hooks_1.DEFAULT_PARSER_HOOKS, hooks);
25
- const data = { config, hooks: hooksWithDefaults, currentRange: undefined, currentLexeme: undefined };
26
- const object = await (0, internal_1.xlm2jsonObject)(config, xmlString);
27
- return (0, model_1.decorateAst)((0, internal_1.normalizeRootObjToAst)(data, object), getId);
28
- }
29
- exports.normalize = normalize;
30
- //# sourceMappingURL=normalize.js.map
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=data.js.map
@@ -1,95 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.normalizeAccess = void 0;
4
- const input_format_1 = require("../../common/input-format");
5
- const meta_1 = require("../../common/meta");
6
- const assert_1 = require("../../../../../../../util/assert");
7
- const arrays_1 = require("../../../../../../../util/arrays");
8
- const single_element_1 = require("./single-element");
9
- const argument_1 = require("./functions/argument");
10
- /**
11
- * Normalize the given data as access (e.g., indexing).
12
- *
13
- * @param configuration - The data used by the parser (see {@link NormalizeConfiguration})
14
- * @param tokens - The json object to extract the meta-information from
15
- * @param accessType - The type of the access (e.g., `[[` or `$`)
16
- *
17
- * @returns The parsed {@link RAccess} or `undefined` if the given construct is not accessing a value
18
- */
19
- function normalizeAccess(configuration, tokens, accessType) {
20
- let closingLength = 0;
21
- // TODO: shorthand combinations like `[<-` or `$<-`
22
- switch (accessType) {
23
- case "$" /* RawRType.Dollar */:
24
- case "@" /* RawRType.At */:
25
- break;
26
- case "[" /* RawRType.BracketLeft */:
27
- closingLength = 1;
28
- break;
29
- case "LBB" /* RawRType.DoubleBracketLeft */:
30
- closingLength = 2;
31
- break;
32
- default:
33
- throw new input_format_1.XmlParseError(`expected second element to be an access operator, yet received ${accessType}`);
34
- }
35
- const first = (0, meta_1.getTokenType)(configuration.tokenMap, tokens[0]);
36
- (0, assert_1.guard)(first === "expr" /* RawRType.Expression */ || first === "expr_or_assign_or_help" /* RawRType.ExprOfAssignOrHelp */, () => `expected accessed element to be wrapped an expression, yet received ${first}`);
37
- const parsedAccessed = (0, single_element_1.normalizeSingleToken)(configuration, tokens[0]);
38
- const { content, location } = (0, meta_1.retrieveMetaStructure)(configuration, tokens[1]);
39
- // we can handle $ and @ directly
40
- if (closingLength === 0) {
41
- return {
42
- type: "RFunctionCall" /* RType.FunctionCall */,
43
- location,
44
- lexeme: content,
45
- info: {},
46
- flavor: 'named',
47
- functionName: {
48
- type: "RSymbol" /* RType.Symbol */,
49
- // TODO: just lock "internal" here
50
- namespace: undefined,
51
- lexeme: content,
52
- info: {},
53
- content,
54
- location
55
- },
56
- arguments: [
57
- parsedAccessed,
58
- // normalize the symbol following
59
- (0, single_element_1.normalizeSingleToken)(configuration, tokens[2])
60
- ],
61
- };
62
- }
63
- // otherwise we have to process
64
- const remaining = tokens.slice(2, tokens.length - closingLength);
65
- const splitAccessOnComma = (0, arrays_1.splitArrayOn)(remaining, elem => elem.name === "," /* RawRType.Comma */);
66
- const parsedAccess = splitAccessOnComma.map((elems) => elems.length === 0 ? undefined : normalizeAccessArgument(configuration, elems));
67
- return {
68
- type: "RFunctionCall" /* RType.FunctionCall */,
69
- location,
70
- lexeme: content,
71
- info: {},
72
- flavor: 'named',
73
- functionName: {
74
- type: "RSymbol" /* RType.Symbol */,
75
- // TODO: just lock "internal" here
76
- namespace: undefined,
77
- lexeme: content,
78
- info: {},
79
- content,
80
- location
81
- },
82
- arguments: [
83
- parsedAccessed,
84
- // normalize the symbol following
85
- ...parsedAccess
86
- ],
87
- };
88
- }
89
- exports.normalizeAccess = normalizeAccess;
90
- function normalizeAccessArgument(config, elements) {
91
- const res = (0, argument_1.tryToNormalizeArgument)(config, elements);
92
- (0, assert_1.guard)(res !== undefined, () => `expected one access result in access as argument, yet received ${JSON.stringify(res)} for ${JSON.stringify(elements)}`);
93
- return res;
94
- }
95
- //# sourceMappingURL=access.js.map