@eagleoutice/flowr 1.4.1 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/abstract-interpretation/processor.js +9 -3
- package/benchmark/slicer.d.ts +0 -3
- package/benchmark/slicer.js +4 -16
- package/benchmark/stats/print.js +0 -2
- package/benchmark/stats/stats.d.ts +2 -3
- package/benchmark/stats/stats.js +1 -1
- package/cli/benchmark-app.d.ts +1 -0
- package/cli/benchmark-app.js +21 -6
- package/cli/benchmark-helper-app.d.ts +2 -0
- package/cli/benchmark-helper-app.js +15 -6
- package/cli/common/options.js +4 -1
- package/cli/common/scripts-info.d.ts +1 -0
- package/cli/common/scripts-info.js +15 -1
- package/cli/export-quads-app.js +1 -5
- package/cli/repl/commands/cfg.js +2 -2
- package/cli/repl/commands/commands.d.ts +3 -1
- package/cli/repl/commands/commands.js +67 -28
- package/cli/repl/commands/dataflow.js +2 -2
- package/cli/repl/commands/normalize.js +2 -2
- package/cli/repl/commands/parse.js +12 -12
- package/cli/repl/commands/quit.js +4 -1
- package/cli/repl/core.d.ts +4 -2
- package/cli/repl/core.js +63 -7
- package/cli/repl/execute.d.ts +1 -1
- package/cli/repl/execute.js +3 -3
- package/cli/repl/server/connection.js +3 -8
- package/cli/repl/server/net.js +2 -2
- package/cli/statistics-helper-app.js +0 -1
- package/cli/summarizer-app.js +1 -2
- package/config.d.ts +16 -0
- package/config.js +75 -0
- package/core/input.d.ts +1 -1
- package/core/output.d.ts +1 -2
- package/core/print/parse-printer.d.ts +1 -2
- package/core/print/parse-printer.js +6 -4
- package/core/slicer.js +4 -8
- package/core/steps.d.ts +7 -24
- package/core/steps.js +5 -12
- package/dataflow/environments/environment.js +8 -0
- package/dataflow/environments/register.js +1 -0
- package/dataflow/extractor.d.ts +2 -2
- package/dataflow/extractor.js +10 -2
- package/dataflow/internal/process/functions/function-call.js +7 -1
- package/dataflow/internal/process/functions/source.d.ts +8 -0
- package/dataflow/internal/process/functions/source.js +81 -0
- package/dataflow/processor.d.ts +10 -1
- package/flowr.d.ts +2 -0
- package/flowr.js +14 -9
- package/package.json +41 -18
- package/r-bridge/lang-4.x/ast/index.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/index.js +3 -0
- package/r-bridge/lang-4.x/ast/model/processing/decorate.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/processing/decorate.js +6 -1
- package/r-bridge/lang-4.x/ast/parser/json/format.d.ts +14 -0
- package/r-bridge/lang-4.x/ast/parser/json/format.js +26 -0
- package/r-bridge/lang-4.x/ast/parser/json/parser.d.ts +7 -0
- package/r-bridge/lang-4.x/ast/parser/json/parser.js +57 -0
- package/r-bridge/lang-4.x/ast/parser/xml/data.d.ts +0 -3
- package/r-bridge/lang-4.x/ast/parser/xml/index.d.ts +0 -2
- package/r-bridge/lang-4.x/ast/parser/xml/index.js +0 -2
- package/r-bridge/lang-4.x/ast/parser/xml/input-format.d.ts +5 -1
- package/r-bridge/lang-4.x/ast/parser/xml/input-format.js +7 -10
- package/r-bridge/lang-4.x/ast/parser/xml/internal/access.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/control/if-then-else.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/xml/internal/control/if-then.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/expression/expression.js +4 -4
- package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/argument.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/call.js +4 -4
- package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/definition.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/parameter.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/index.d.ts +0 -1
- package/r-bridge/lang-4.x/ast/parser/xml/internal/index.js +0 -1
- package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/break.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/for.js +3 -6
- package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/next.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/repeat.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/while.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/meta.d.ts +6 -11
- package/r-bridge/lang-4.x/ast/parser/xml/internal/meta.js +15 -23
- package/r-bridge/lang-4.x/ast/parser/xml/internal/operators/binary.js +6 -6
- package/r-bridge/lang-4.x/ast/parser/xml/internal/operators/unary.js +3 -3
- package/r-bridge/lang-4.x/ast/parser/xml/internal/other/comment.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/other/line-directive.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/elements.js +3 -3
- package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/root.js +3 -4
- package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/single-element.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/values/number.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/values/string.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/values/symbol.js +4 -4
- package/r-bridge/lang-4.x/values.d.ts +0 -1
- package/r-bridge/lang-4.x/values.js +14 -6
- package/r-bridge/retriever.d.ts +25 -21
- package/r-bridge/retriever.js +73 -23
- package/r-bridge/shell-executor.d.ts +3 -17
- package/r-bridge/shell-executor.js +9 -78
- package/r-bridge/shell.d.ts +5 -27
- package/r-bridge/shell.js +31 -92
- package/statistics/features/supported/assignments/post-process.js +6 -6
- package/statistics/features/supported/comments/post-process.js +2 -2
- package/statistics/features/supported/data-access/post-process.js +4 -4
- package/statistics/features/supported/defined-functions/post-process.js +4 -4
- package/statistics/features/supported/expression-list/post-process.js +3 -3
- package/statistics/features/supported/loops/post-process.js +3 -3
- package/statistics/features/supported/used-functions/post-process.js +5 -5
- package/statistics/features/supported/used-packages/post-process.js +5 -5
- package/statistics/features/supported/values/post-process.js +3 -3
- package/statistics/features/supported/variables/post-process.js +3 -3
- package/statistics/output/ansi.js +1 -1
- package/statistics/statistics.js +7 -8
- package/util/args.d.ts +8 -4
- package/util/args.js +11 -4
- package/util/cfg/visitor.js +1 -1
- package/util/files.d.ts +6 -0
- package/util/files.js +11 -1
- package/util/log.js +3 -0
- package/util/summarizer/benchmark/first-phase/input.d.ts +2 -1
- package/util/summarizer/benchmark/first-phase/input.js +20 -4
- package/util/summarizer/benchmark/first-phase/process.d.ts +2 -1
- package/util/summarizer/benchmark/first-phase/process.js +14 -5
- package/util/summarizer/benchmark/second-phase/graph.js +1 -1
- package/util/summarizer/benchmark/second-phase/process.d.ts +2 -0
- package/util/summarizer/benchmark/second-phase/process.js +48 -11
- package/util/summarizer/benchmark/summarizer.d.ts +0 -4
- package/util/summarizer/benchmark/summarizer.js +16 -7
- package/util/summarizer/statistics/first-phase/process.js +8 -8
- package/util/summarizer/statistics/post-process/post-process-output.js +4 -5
- package/r-bridge/lang-4.x/ast/parser/xml/config.d.ts +0 -25
- package/r-bridge/lang-4.x/ast/parser/xml/config.js +0 -16
- package/r-bridge/lang-4.x/ast/parser/xml/internal/xml-to-json.d.ts +0 -9
- package/r-bridge/lang-4.x/ast/parser/xml/internal/xml-to-json.js +0 -51
- package/r-bridge/lang-4.x/ast/parser/xml/parser.d.ts +0 -17
- package/r-bridge/lang-4.x/ast/parser/xml/parser.js +0 -30
|
@@ -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
|
|
20
|
+
return obj[key[0]];
|
|
24
21
|
}
|
|
25
22
|
else {
|
|
26
23
|
return key.reduce((acc, key) => {
|
|
27
|
-
acc[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)(
|
|
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)(
|
|
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)(
|
|
23
|
-
const childrenSource = (0, input_format_1.getKeysGuarded)(unwrappedObj,
|
|
24
|
-
const typed = (0, meta_1.getWithTokenType)(
|
|
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)(
|
|
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)(
|
|
35
|
-
const symbolContent = (0, input_format_1.getKeysGuarded)(unwrappedObj,
|
|
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)(
|
|
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)(
|
|
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)(
|
|
32
|
+
const { location, content } = (0, meta_1.retrieveMetaStructure)(symbol.content);
|
|
33
33
|
const result = {
|
|
34
34
|
type: "RParameter" /* RType.Parameter */,
|
|
35
35
|
location,
|
|
@@ -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)(
|
|
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)(
|
|
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,
|
|
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)(
|
|
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)(
|
|
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)(
|
|
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(
|
|
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
|
|
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(
|
|
37
|
-
export declare function getWithTokenType(
|
|
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(
|
|
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(
|
|
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.
|
|
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(
|
|
39
|
+
function retrieveMetaStructure(obj) {
|
|
41
40
|
const unwrappedObj = objectWithArrUnwrap(obj);
|
|
42
|
-
const attributes = obj[
|
|
43
|
-
const content = obj[
|
|
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
|
|
54
|
-
|
|
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(
|
|
73
|
-
return
|
|
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(
|
|
69
|
+
function getWithTokenType(obj) {
|
|
77
70
|
return obj.map((content) => ({
|
|
78
|
-
name: getTokenType(
|
|
71
|
+
name: getTokenType(content),
|
|
79
72
|
content
|
|
80
73
|
}));
|
|
81
74
|
}
|
|
82
75
|
exports.getWithTokenType = getWithTokenType;
|
|
83
|
-
function retrieveOpName(
|
|
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[
|
|
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(
|
|
98
|
-
const firstOtherLoc = extractLocation(first[
|
|
99
|
-
const secondOtherLoc = extractLocation(second[
|
|
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
|
}
|
|
@@ -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)(
|
|
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)(
|
|
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(
|
|
58
|
+
[parsedLhs, parsedRhs] = processLhsAndRhsForAssignment(operationName, parsedLhs, parsedRhs);
|
|
59
59
|
}
|
|
60
|
-
const { location, content } = (0, meta_1.retrieveMetaStructure)(
|
|
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(
|
|
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)(
|
|
43
|
-
const { location, content } = (0, meta_1.retrieveMetaStructure)(
|
|
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)(
|
|
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)(
|
|
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;
|