@eagleoutice/flowr 1.4.2 → 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.
- package/core/print/slice-diff-ansi.js +7 -7
- package/core/steps.d.ts +352 -11
- package/core/steps.js +4 -4
- package/index.d.ts +0 -2
- package/index.js +0 -2
- package/package.json +65 -215
- package/util/{summarizer/summarizer.d.ts → summarizer.d.ts} +15 -1
- package/util/summarizer.js +37 -0
- package/util/version.d.ts +2 -0
- package/util/version.js +10 -0
- package/benchmark/index.d.ts +0 -3
- package/benchmark/index.js +0 -20
- package/benchmark/slicer.d.ts +0 -98
- package/benchmark/slicer.js +0 -213
- package/benchmark/stats/index.d.ts +0 -10
- package/benchmark/stats/index.js +0 -27
- package/benchmark/stats/print.d.ts +0 -7
- package/benchmark/stats/print.js +0 -155
- package/benchmark/stats/stats.d.ts +0 -40
- package/benchmark/stats/stats.js +0 -6
- package/benchmark/stopwatch.d.ts +0 -35
- package/benchmark/stopwatch.js +0 -79
- package/cli/benchmark-app.d.ts +0 -10
- package/cli/benchmark-app.js +0 -67
- package/cli/benchmark-helper-app.d.ts +0 -9
- package/cli/benchmark-helper-app.js +0 -69
- package/cli/common/features.d.ts +0 -3
- package/cli/common/features.js +0 -30
- package/cli/common/index.d.ts +0 -2
- package/cli/common/index.js +0 -19
- package/cli/common/options.d.ts +0 -20
- package/cli/common/options.js +0 -85
- package/cli/common/script.d.ts +0 -21
- package/cli/common/script.js +0 -61
- package/cli/common/scripts-info.d.ts +0 -25
- package/cli/common/scripts-info.js +0 -83
- package/cli/export-quads-app.d.ts +0 -7
- package/cli/export-quads-app.js +0 -42
- package/cli/repl/commands/cfg.d.ts +0 -3
- package/cli/repl/commands/cfg.js +0 -37
- package/cli/repl/commands/commands.d.ts +0 -13
- package/cli/repl/commands/commands.js +0 -142
- package/cli/repl/commands/dataflow.d.ts +0 -3
- package/cli/repl/commands/dataflow.js +0 -34
- package/cli/repl/commands/execute.d.ts +0 -4
- package/cli/repl/commands/execute.js +0 -27
- package/cli/repl/commands/index.d.ts +0 -2
- package/cli/repl/commands/index.js +0 -19
- package/cli/repl/commands/main.d.ts +0 -39
- package/cli/repl/commands/main.js +0 -14
- package/cli/repl/commands/normalize.d.ts +0 -3
- package/cli/repl/commands/normalize.js +0 -34
- package/cli/repl/commands/parse.d.ts +0 -2
- package/cli/repl/commands/parse.js +0 -109
- package/cli/repl/commands/quit.d.ts +0 -2
- package/cli/repl/commands/quit.js +0 -15
- package/cli/repl/commands/version.d.ts +0 -16
- package/cli/repl/commands/version.js +0 -33
- package/cli/repl/core.d.ts +0 -41
- package/cli/repl/core.js +0 -172
- package/cli/repl/execute.d.ts +0 -28
- package/cli/repl/execute.js +0 -79
- package/cli/repl/index.d.ts +0 -5
- package/cli/repl/index.js +0 -22
- package/cli/repl/prompt.d.ts +0 -2
- package/cli/repl/prompt.js +0 -9
- package/cli/repl/server/connection.d.ts +0 -21
- package/cli/repl/server/connection.js +0 -213
- package/cli/repl/server/messages/analysis.d.ts +0 -71
- package/cli/repl/server/messages/analysis.js +0 -21
- package/cli/repl/server/messages/error.d.ts +0 -11
- package/cli/repl/server/messages/error.js +0 -3
- package/cli/repl/server/messages/hello.d.ts +0 -20
- package/cli/repl/server/messages/hello.js +0 -3
- package/cli/repl/server/messages/index.d.ts +0 -1
- package/cli/repl/server/messages/index.js +0 -3
- package/cli/repl/server/messages/messages.d.ts +0 -35
- package/cli/repl/server/messages/messages.js +0 -40
- package/cli/repl/server/messages/repl.d.ts +0 -33
- package/cli/repl/server/messages/repl.js +0 -37
- package/cli/repl/server/messages/slice.d.ts +0 -25
- package/cli/repl/server/messages/slice.js +0 -37
- package/cli/repl/server/net.d.ts +0 -49
- package/cli/repl/server/net.js +0 -63
- package/cli/repl/server/send.d.ts +0 -4
- package/cli/repl/server/send.js +0 -18
- package/cli/repl/server/server.d.ts +0 -20
- package/cli/repl/server/server.js +0 -66
- package/cli/repl/server/validate.d.ts +0 -15
- package/cli/repl/server/validate.js +0 -34
- package/cli/slicer-app.d.ts +0 -11
- package/cli/slicer-app.js +0 -81
- package/cli/statistics-app.d.ts +0 -11
- package/cli/statistics-app.js +0 -98
- package/cli/statistics-helper-app.d.ts +0 -11
- package/cli/statistics-helper-app.js +0 -82
- package/cli/summarizer-app.d.ts +0 -18
- package/cli/summarizer-app.js +0 -66
- package/flowr.d.ts +0 -29
- package/flowr.js +0 -142
- package/statistics/features/common-syntax-probability.d.ts +0 -31
- package/statistics/features/common-syntax-probability.js +0 -156
- package/statistics/features/feature.d.ts +0 -175
- package/statistics/features/feature.js +0 -30
- package/statistics/features/index.d.ts +0 -1
- package/statistics/features/index.js +0 -18
- package/statistics/features/post-processing.d.ts +0 -12
- package/statistics/features/post-processing.js +0 -21
- package/statistics/features/supported/assignments/assignments.d.ts +0 -11
- package/statistics/features/supported/assignments/assignments.js +0 -53
- package/statistics/features/supported/assignments/index.d.ts +0 -1
- package/statistics/features/supported/assignments/index.js +0 -6
- package/statistics/features/supported/assignments/post-process.d.ts +0 -3
- package/statistics/features/supported/assignments/post-process.js +0 -125
- package/statistics/features/supported/comments/comments.d.ts +0 -18
- package/statistics/features/supported/comments/comments.js +0 -133
- package/statistics/features/supported/comments/index.d.ts +0 -1
- package/statistics/features/supported/comments/index.js +0 -6
- package/statistics/features/supported/comments/post-process.d.ts +0 -3
- package/statistics/features/supported/comments/post-process.js +0 -50
- package/statistics/features/supported/control-flow/control-flow.d.ts +0 -17
- package/statistics/features/supported/control-flow/control-flow.js +0 -67
- package/statistics/features/supported/control-flow/index.d.ts +0 -1
- package/statistics/features/supported/control-flow/index.js +0 -6
- package/statistics/features/supported/control-flow/post-process.d.ts +0 -3
- package/statistics/features/supported/control-flow/post-process.js +0 -65
- package/statistics/features/supported/data-access/data-access.d.ts +0 -15
- package/statistics/features/supported/data-access/data-access.js +0 -118
- package/statistics/features/supported/data-access/index.d.ts +0 -1
- package/statistics/features/supported/data-access/index.js +0 -6
- package/statistics/features/supported/data-access/post-process.d.ts +0 -3
- package/statistics/features/supported/data-access/post-process.js +0 -107
- package/statistics/features/supported/defined-functions/defined-functions.d.ts +0 -35
- package/statistics/features/supported/defined-functions/defined-functions.js +0 -139
- package/statistics/features/supported/defined-functions/index.d.ts +0 -1
- package/statistics/features/supported/defined-functions/index.js +0 -6
- package/statistics/features/supported/defined-functions/post-process.d.ts +0 -6
- package/statistics/features/supported/defined-functions/post-process.js +0 -177
- package/statistics/features/supported/expression-list/expression-list.d.ts +0 -9
- package/statistics/features/supported/expression-list/expression-list.js +0 -36
- package/statistics/features/supported/expression-list/index.d.ts +0 -1
- package/statistics/features/supported/expression-list/index.js +0 -6
- package/statistics/features/supported/expression-list/post-process.d.ts +0 -3
- package/statistics/features/supported/expression-list/post-process.js +0 -44
- package/statistics/features/supported/index.d.ts +0 -10
- package/statistics/features/supported/index.js +0 -27
- package/statistics/features/supported/loops/index.d.ts +0 -1
- package/statistics/features/supported/loops/index.js +0 -6
- package/statistics/features/supported/loops/loops.d.ts +0 -20
- package/statistics/features/supported/loops/loops.js +0 -79
- package/statistics/features/supported/loops/post-process.d.ts +0 -3
- package/statistics/features/supported/loops/post-process.js +0 -72
- package/statistics/features/supported/used-functions/index.d.ts +0 -1
- package/statistics/features/supported/used-functions/index.js +0 -6
- package/statistics/features/supported/used-functions/post-process.d.ts +0 -6
- package/statistics/features/supported/used-functions/post-process.js +0 -179
- package/statistics/features/supported/used-functions/used-functions.d.ts +0 -24
- package/statistics/features/supported/used-functions/used-functions.js +0 -95
- package/statistics/features/supported/used-packages/index.d.ts +0 -1
- package/statistics/features/supported/used-packages/index.js +0 -6
- package/statistics/features/supported/used-packages/post-process.d.ts +0 -3
- package/statistics/features/supported/used-packages/post-process.js +0 -121
- package/statistics/features/supported/used-packages/used-packages.d.ts +0 -16
- package/statistics/features/supported/used-packages/used-packages.js +0 -130
- package/statistics/features/supported/values/index.d.ts +0 -1
- package/statistics/features/supported/values/index.js +0 -6
- package/statistics/features/supported/values/post-process.d.ts +0 -3
- package/statistics/features/supported/values/post-process.js +0 -72
- package/statistics/features/supported/values/values.d.ts +0 -14
- package/statistics/features/supported/values/values.js +0 -101
- package/statistics/features/supported/variables/index.d.ts +0 -1
- package/statistics/features/supported/variables/index.js +0 -6
- package/statistics/features/supported/variables/post-process.d.ts +0 -9
- package/statistics/features/supported/variables/post-process.js +0 -122
- package/statistics/features/supported/variables/variables.d.ts +0 -15
- package/statistics/features/supported/variables/variables.js +0 -70
- package/statistics/index.d.ts +0 -6
- package/statistics/index.js +0 -24
- package/statistics/meta-statistics.d.ts +0 -33
- package/statistics/meta-statistics.js +0 -17
- package/statistics/output/file-provider.d.ts +0 -37
- package/statistics/output/file-provider.js +0 -97
- package/statistics/output/index.d.ts +0 -4
- package/statistics/output/index.js +0 -21
- package/statistics/output/print-stats.d.ts +0 -17
- package/statistics/output/print-stats.js +0 -69
- package/statistics/output/statistics-file.d.ts +0 -37
- package/statistics/output/statistics-file.js +0 -69
- package/statistics/statistics.d.ts +0 -24
- package/statistics/statistics.js +0 -108
- package/util/summarizer/auto-detect.d.ts +0 -2
- package/util/summarizer/auto-detect.js +0 -32
- package/util/summarizer/benchmark/data.d.ts +0 -66
- package/util/summarizer/benchmark/data.js +0 -13
- package/util/summarizer/benchmark/first-phase/input.d.ts +0 -3
- package/util/summarizer/benchmark/first-phase/input.js +0 -75
- package/util/summarizer/benchmark/first-phase/process.d.ts +0 -11
- package/util/summarizer/benchmark/first-phase/process.js +0 -217
- package/util/summarizer/benchmark/second-phase/graph.d.ts +0 -2
- package/util/summarizer/benchmark/second-phase/graph.js +0 -54
- package/util/summarizer/benchmark/second-phase/process.d.ts +0 -6
- package/util/summarizer/benchmark/second-phase/process.js +0 -126
- package/util/summarizer/benchmark/summarizer.d.ts +0 -31
- package/util/summarizer/benchmark/summarizer.js +0 -58
- package/util/summarizer/statistics/first-phase/process.d.ts +0 -6
- package/util/summarizer/statistics/first-phase/process.js +0 -81
- package/util/summarizer/statistics/post-process/clusterer.d.ts +0 -26
- package/util/summarizer/statistics/post-process/clusterer.js +0 -43
- package/util/summarizer/statistics/post-process/file-based-count.d.ts +0 -17
- package/util/summarizer/statistics/post-process/file-based-count.js +0 -49
- package/util/summarizer/statistics/post-process/histogram.d.ts +0 -59
- package/util/summarizer/statistics/post-process/histogram.js +0 -128
- package/util/summarizer/statistics/post-process/index.d.ts +0 -4
- package/util/summarizer/statistics/post-process/index.js +0 -21
- package/util/summarizer/statistics/post-process/post-process-output.d.ts +0 -16
- package/util/summarizer/statistics/post-process/post-process-output.js +0 -103
- package/util/summarizer/statistics/second-phase/process.d.ts +0 -11
- package/util/summarizer/statistics/second-phase/process.js +0 -117
- package/util/summarizer/statistics/summarizer.d.ts +0 -35
- package/util/summarizer/statistics/summarizer.js +0 -135
- package/util/summarizer/summarizer.js +0 -13
- /package/{statistics/output → util}/ansi.d.ts +0 -0
- /package/{statistics/output → util}/ansi.js +0 -0
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.longestCommandName = exports.asOptionName = exports.getCommand = exports.getCommandNames = exports.helpCommand = void 0;
|
|
4
|
-
const quit_1 = require("./quit");
|
|
5
|
-
const common_1 = require("../../common");
|
|
6
|
-
const execute_1 = require("../execute");
|
|
7
|
-
const args_1 = require("../../../util/args");
|
|
8
|
-
const prompt_1 = require("../prompt");
|
|
9
|
-
const statistics_1 = require("../../../statistics");
|
|
10
|
-
const version_1 = require("./version");
|
|
11
|
-
const parse_1 = require("./parse");
|
|
12
|
-
const assert_1 = require("../../../util/assert");
|
|
13
|
-
const execute_2 = require("./execute");
|
|
14
|
-
const normalize_1 = require("./normalize");
|
|
15
|
-
const dataflow_1 = require("./dataflow");
|
|
16
|
-
const cfg_1 = require("./cfg");
|
|
17
|
-
function printHelpForScript(script, f) {
|
|
18
|
-
const base = ` ${(0, statistics_1.bold)(padCmd(':' + script[0]), f)}${script[1].description}`;
|
|
19
|
-
if (script[1].aliases.length === 0) {
|
|
20
|
-
return base;
|
|
21
|
-
}
|
|
22
|
-
const aliases = script[1].aliases;
|
|
23
|
-
return `${base} (alias${aliases.length > 1 ? 'es' : ''}: ${aliases.map(a => (0, statistics_1.bold)(':' + a, f)).join(', ')})`;
|
|
24
|
-
}
|
|
25
|
-
exports.helpCommand = {
|
|
26
|
-
description: 'Show help information',
|
|
27
|
-
script: false,
|
|
28
|
-
usageExample: ':help',
|
|
29
|
-
aliases: ['h', '?'],
|
|
30
|
-
fn: output => {
|
|
31
|
-
initCommandMapping();
|
|
32
|
-
output.stdout(`
|
|
33
|
-
You can always just enter R expressions which get evaluated right away:
|
|
34
|
-
${prompt_1.rawPrompt} ${(0, statistics_1.bold)('1 + 1', output.formatter)}
|
|
35
|
-
${(0, statistics_1.italic)('[1] 2', output.formatter)}
|
|
36
|
-
|
|
37
|
-
Besides that, you can use the following commands. The scripts ${(0, statistics_1.italic)('can', output.formatter)} accept further arguments. There are the following basic commands:
|
|
38
|
-
${Array.from(Object.entries(commands())).filter(([, { script }]) => !script).map(c => printHelpForScript(c, output.formatter)).join('\n')}
|
|
39
|
-
|
|
40
|
-
Furthermore, you can directly call the following scripts which accept arguments. If you are unsure, try to add ${(0, statistics_1.italic)('--help', output.formatter)} after the command.
|
|
41
|
-
${Array.from(Object.entries(commands())).filter(([, { script }]) => script).map(([command, { description }]) => ` ${(0, statistics_1.bold)(padCmd(':' + command), output.formatter)}${description}`).join('\n')}
|
|
42
|
-
|
|
43
|
-
You can combine commands by separating them with a semicolon ${(0, statistics_1.bold)(';', output.formatter)}.
|
|
44
|
-
`);
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
/**
|
|
48
|
-
* All commands that should be available in the REPL.
|
|
49
|
-
*/
|
|
50
|
-
const _commands = {
|
|
51
|
-
'help': exports.helpCommand,
|
|
52
|
-
'quit': quit_1.quitCommand,
|
|
53
|
-
'version': version_1.versionCommand,
|
|
54
|
-
'execute': execute_2.executeCommand,
|
|
55
|
-
'parse': parse_1.parseCommand,
|
|
56
|
-
'normalize': normalize_1.normalizeCommand,
|
|
57
|
-
'normalize*': normalize_1.normalizeStarCommand,
|
|
58
|
-
'dataflow': dataflow_1.dataflowCommand,
|
|
59
|
-
'dataflow*': dataflow_1.dataflowStarCommand,
|
|
60
|
-
'controlflow': cfg_1.controlflowCommand,
|
|
61
|
-
'controlflow*': cfg_1.controlflowStarCommand
|
|
62
|
-
};
|
|
63
|
-
let commandsInitialized = false;
|
|
64
|
-
function commands() {
|
|
65
|
-
if (commandsInitialized) {
|
|
66
|
-
return _commands;
|
|
67
|
-
}
|
|
68
|
-
commandsInitialized = true;
|
|
69
|
-
for (const [script, { target, description, type }] of Object.entries(common_1.scripts)) {
|
|
70
|
-
if (type === 'master script') {
|
|
71
|
-
_commands[script] = {
|
|
72
|
-
description,
|
|
73
|
-
aliases: [],
|
|
74
|
-
script: true,
|
|
75
|
-
usageExample: `:${script} --help`,
|
|
76
|
-
fn: async (output, _s, remainingLine) => {
|
|
77
|
-
await (0, execute_1.waitOnScript)(`${__dirname}/../../${target}`, (0, args_1.splitAtEscapeSensitive)(remainingLine), stdio => (0, execute_1.stdioCaptureProcessor)(stdio, msg => output.stdout(msg), msg => output.stderr(msg)));
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return _commands;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* The names of all commands including their aliases (but without the leading `:`)
|
|
86
|
-
*/
|
|
87
|
-
function getCommandNames() {
|
|
88
|
-
if (commandNames === undefined) {
|
|
89
|
-
initCommandMapping();
|
|
90
|
-
}
|
|
91
|
-
return commandNames;
|
|
92
|
-
}
|
|
93
|
-
exports.getCommandNames = getCommandNames;
|
|
94
|
-
let commandNames = undefined;
|
|
95
|
-
// maps command names or aliases to the actual command name
|
|
96
|
-
let commandMapping = undefined;
|
|
97
|
-
function initCommandMapping() {
|
|
98
|
-
commandMapping = {};
|
|
99
|
-
commandNames = [];
|
|
100
|
-
for (const [command, { aliases }] of Object.entries(commands())) {
|
|
101
|
-
(0, assert_1.guard)(commandMapping[command] === undefined, `Command ${command} is already registered!`);
|
|
102
|
-
commandMapping[command] = command;
|
|
103
|
-
for (const alias of aliases) {
|
|
104
|
-
(0, assert_1.guard)(commandMapping[alias] === undefined, `Command (alias) ${alias} is already registered!`);
|
|
105
|
-
commandMapping[alias] = command;
|
|
106
|
-
}
|
|
107
|
-
commandNames.push(command);
|
|
108
|
-
commandNames.push(...aliases);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Get the command for a given command name or alias.
|
|
113
|
-
* @param command - The name of the command (without the leading `:`)
|
|
114
|
-
*/
|
|
115
|
-
function getCommand(command) {
|
|
116
|
-
if (commandMapping === undefined) {
|
|
117
|
-
initCommandMapping();
|
|
118
|
-
}
|
|
119
|
-
return commands()[commandMapping[command]];
|
|
120
|
-
}
|
|
121
|
-
exports.getCommand = getCommand;
|
|
122
|
-
function asOptionName(argument) {
|
|
123
|
-
if (argument.length == 1) {
|
|
124
|
-
return `-${argument}`;
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
return `--${argument}`;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
exports.asOptionName = asOptionName;
|
|
131
|
-
let _longestCommandName = undefined;
|
|
132
|
-
function longestCommandName() {
|
|
133
|
-
if (_longestCommandName === undefined) {
|
|
134
|
-
_longestCommandName = Array.from(Object.keys(commands()), k => k.length).reduce((p, n) => Math.max(p, n), 0);
|
|
135
|
-
}
|
|
136
|
-
return _longestCommandName;
|
|
137
|
-
}
|
|
138
|
-
exports.longestCommandName = longestCommandName;
|
|
139
|
-
function padCmd(string) {
|
|
140
|
-
return String(string).padEnd(longestCommandName() + 2, ' ');
|
|
141
|
-
}
|
|
142
|
-
//# sourceMappingURL=commands.js.map
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.dataflowStarCommand = exports.dataflowCommand = void 0;
|
|
4
|
-
const core_1 = require("../../../core");
|
|
5
|
-
const r_bridge_1 = require("../../../r-bridge");
|
|
6
|
-
const dfg_1 = require("../../../util/mermaid/dfg");
|
|
7
|
-
async function dataflow(shell, remainingLine) {
|
|
8
|
-
return await new core_1.SteppingSlicer({
|
|
9
|
-
stepOfInterest: 'dataflow',
|
|
10
|
-
shell,
|
|
11
|
-
request: (0, r_bridge_1.requestFromInput)(remainingLine.trim())
|
|
12
|
-
}).allRemainingSteps();
|
|
13
|
-
}
|
|
14
|
-
exports.dataflowCommand = {
|
|
15
|
-
description: `Get mermaid code for the dataflow graph of R code, start with '${r_bridge_1.fileProtocol}' to indicate a file`,
|
|
16
|
-
usageExample: ':dataflow',
|
|
17
|
-
aliases: ['d', 'df'],
|
|
18
|
-
script: false,
|
|
19
|
-
fn: async (output, shell, remainingLine) => {
|
|
20
|
-
const result = await dataflow(shell, remainingLine);
|
|
21
|
-
output.stdout((0, dfg_1.graphToMermaid)(result.dataflow.graph, result.normalize.idMap, undefined, undefined, false));
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
exports.dataflowStarCommand = {
|
|
25
|
-
description: `Get a mermaid url of the dataflow graph of R code, start with '${r_bridge_1.fileProtocol}' to indicate a file`,
|
|
26
|
-
usageExample: ':dataflow*',
|
|
27
|
-
aliases: ['d*', 'df*'],
|
|
28
|
-
script: false,
|
|
29
|
-
fn: async (output, shell, remainingLine) => {
|
|
30
|
-
const result = await dataflow(shell, remainingLine);
|
|
31
|
-
output.stdout((0, dfg_1.graphToMermaidUrl)(result.dataflow.graph, result.normalize.idMap, false));
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
//# sourceMappingURL=dataflow.js.map
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { RShell } from '../../../r-bridge';
|
|
2
|
-
import type { ReplCommand, ReplOutput } from './main';
|
|
3
|
-
export declare function executeRShellCommand(output: ReplOutput, shell: RShell, statement: string): Promise<void>;
|
|
4
|
-
export declare const executeCommand: ReplCommand;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.executeCommand = exports.executeRShellCommand = void 0;
|
|
4
|
-
const statistics_1 = require("../../../statistics");
|
|
5
|
-
async function executeRShellCommand(output, shell, statement) {
|
|
6
|
-
try {
|
|
7
|
-
const result = await shell.sendCommandWithOutput(statement, {
|
|
8
|
-
from: 'both',
|
|
9
|
-
automaticallyTrimOutput: true
|
|
10
|
-
});
|
|
11
|
-
output.stdout(`${(0, statistics_1.italic)(result.join('\n'), output.formatter)}\n`);
|
|
12
|
-
}
|
|
13
|
-
catch (e) {
|
|
14
|
-
output.stderr(`Error while executing '${statement}': ${e.message}`);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
exports.executeRShellCommand = executeRShellCommand;
|
|
18
|
-
exports.executeCommand = {
|
|
19
|
-
description: 'Execute the given code as R code (essentially similar to using now command)',
|
|
20
|
-
usageExample: ':execute',
|
|
21
|
-
aliases: ['e', 'r'],
|
|
22
|
-
script: false,
|
|
23
|
-
fn: async (output, shell, remainingLine) => {
|
|
24
|
-
await executeRShellCommand(output, shell, remainingLine);
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
//# sourceMappingURL=execute.js.map
|
|
@@ -1,19 +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("./main"), exports);
|
|
18
|
-
__exportStar(require("./commands"), exports);
|
|
19
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { RShell } from '../../../r-bridge';
|
|
2
|
-
import type { OutputFormatter } from '../../../statistics';
|
|
3
|
-
/**
|
|
4
|
-
* Defines the main interface for output of the repl.
|
|
5
|
-
* This allows us to redirect it (e.g., in the case of a server connection or tests).
|
|
6
|
-
*
|
|
7
|
-
* The formatter allows to dynamically change the use of ansi escape sequences (see {@link OutputFormatter})
|
|
8
|
-
*
|
|
9
|
-
* @see standardReplOutput
|
|
10
|
-
*/
|
|
11
|
-
export interface ReplOutput {
|
|
12
|
-
formatter: OutputFormatter;
|
|
13
|
-
stdout(msg: string): void;
|
|
14
|
-
stderr(msg: string): void;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Default repl output that redirects everything to the stdout and stderror channels (linked to `console`).
|
|
18
|
-
* @see ReplOutput
|
|
19
|
-
*/
|
|
20
|
-
export declare const standardReplOutput: ReplOutput;
|
|
21
|
-
/**
|
|
22
|
-
* Content of a single command in the repl.
|
|
23
|
-
* The command may execute an external script or simply call *flowR* functions.
|
|
24
|
-
*/
|
|
25
|
-
export interface ReplCommand {
|
|
26
|
-
/** Aliases of the command (without the leading colon), every alias must be unique (this is checked at runtime) */
|
|
27
|
-
aliases: string[];
|
|
28
|
-
/** A human-readable description of what the command does */
|
|
29
|
-
description: string;
|
|
30
|
-
/** Does the command invoke another script? this is mainly used to automatically generate two separate lists when asking for help */
|
|
31
|
-
script: boolean;
|
|
32
|
-
/** Example of how to use the command, for example `:slicer --help` */
|
|
33
|
-
usageExample: string;
|
|
34
|
-
/**
|
|
35
|
-
* Function to execute when the command is invoked, it must not write to the command line but instead use the output handler.
|
|
36
|
-
* Furthermore, it has to obey the formatter defined in the {@link ReplOutput}.
|
|
37
|
-
*/
|
|
38
|
-
fn: (output: ReplOutput, shell: RShell, remainingLine: string) => Promise<void> | void;
|
|
39
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.standardReplOutput = void 0;
|
|
4
|
-
const statistics_1 = require("../../../statistics");
|
|
5
|
-
/**
|
|
6
|
-
* Default repl output that redirects everything to the stdout and stderror channels (linked to `console`).
|
|
7
|
-
* @see ReplOutput
|
|
8
|
-
*/
|
|
9
|
-
exports.standardReplOutput = {
|
|
10
|
-
formatter: statistics_1.formatter,
|
|
11
|
-
stdout: console.log,
|
|
12
|
-
stderr: console.error
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=main.js.map
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.normalizeStarCommand = exports.normalizeCommand = void 0;
|
|
4
|
-
const core_1 = require("../../../core");
|
|
5
|
-
const r_bridge_1 = require("../../../r-bridge");
|
|
6
|
-
const mermaid_1 = require("../../../util/mermaid");
|
|
7
|
-
async function normalize(shell, remainingLine) {
|
|
8
|
-
return await new core_1.SteppingSlicer({
|
|
9
|
-
stepOfInterest: 'normalize',
|
|
10
|
-
shell,
|
|
11
|
-
request: (0, r_bridge_1.requestFromInput)(remainingLine.trim())
|
|
12
|
-
}).allRemainingSteps();
|
|
13
|
-
}
|
|
14
|
-
exports.normalizeCommand = {
|
|
15
|
-
description: `Get mermaid code for the normalized AST of R code, start with '${r_bridge_1.fileProtocol}' to indicate a file`,
|
|
16
|
-
usageExample: ':normalize',
|
|
17
|
-
aliases: ['n'],
|
|
18
|
-
script: false,
|
|
19
|
-
fn: async (output, shell, remainingLine) => {
|
|
20
|
-
const result = await normalize(shell, remainingLine);
|
|
21
|
-
output.stdout((0, mermaid_1.normalizedAstToMermaid)(result.normalize.ast));
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
exports.normalizeStarCommand = {
|
|
25
|
-
description: `Get a mermaid url of the normalized AST of R code, start with '${r_bridge_1.fileProtocol}' to indicate a file`,
|
|
26
|
-
usageExample: ':normalize',
|
|
27
|
-
aliases: ['n*'],
|
|
28
|
-
script: false,
|
|
29
|
-
fn: async (output, shell, remainingLine) => {
|
|
30
|
-
const result = await normalize(shell, remainingLine);
|
|
31
|
-
output.stdout((0, mermaid_1.normalizedAstToMermaidUrl)(result.normalize.ast));
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
//# sourceMappingURL=normalize.js.map
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseCommand = void 0;
|
|
4
|
-
const r_bridge_1 = require("../../../r-bridge");
|
|
5
|
-
const internal_1 = require("../../../r-bridge/lang-4.x/ast/parser/xml/internal");
|
|
6
|
-
const core_1 = require("../../../core");
|
|
7
|
-
const format_1 = require("../../../r-bridge/lang-4.x/ast/parser/json/format");
|
|
8
|
-
const parser_1 = require("../../../r-bridge/lang-4.x/ast/parser/json/parser");
|
|
9
|
-
function toDepthMap(xml) {
|
|
10
|
-
const root = (0, r_bridge_1.getKeysGuarded)(xml, "exprlist" /* RawRType.ExpressionList */);
|
|
11
|
-
const visit = [{ depth: 0, node: root }];
|
|
12
|
-
const result = [];
|
|
13
|
-
while (visit.length > 0) {
|
|
14
|
-
const current = visit.pop();
|
|
15
|
-
if (current === undefined) {
|
|
16
|
-
continue;
|
|
17
|
-
}
|
|
18
|
-
const children = current.node[r_bridge_1.childrenKey] ?? [];
|
|
19
|
-
result.push({ ...current, leaf: children.length === 0 });
|
|
20
|
-
children.reverse();
|
|
21
|
-
const nextDepth = current.depth + 1;
|
|
22
|
-
visit.push(...children.map(c => ({ depth: nextDepth, node: c })));
|
|
23
|
-
}
|
|
24
|
-
return result;
|
|
25
|
-
}
|
|
26
|
-
function lastElementInNesting(i, list, depth) {
|
|
27
|
-
for (let j = i + 1; j < list.length; j++) {
|
|
28
|
-
if (list[j].depth < depth) {
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
if (list[j].depth === depth) {
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
// only more deeply nested come after
|
|
36
|
-
return true;
|
|
37
|
-
}
|
|
38
|
-
function initialIndentation(i, depth, deadDepths, nextDepth, list, f) {
|
|
39
|
-
let result = `${i === 0 ? '' : '\n'}${f.getFormatString({ style: 2 /* FontStyles.Faint */ })}`;
|
|
40
|
-
// we know there never is something on the same level as the expression list
|
|
41
|
-
for (let d = 1; d < depth; d++) {
|
|
42
|
-
result += deadDepths.has(d) ? ' ' : '│ ';
|
|
43
|
-
}
|
|
44
|
-
if (nextDepth < depth) {
|
|
45
|
-
result += '╰ ';
|
|
46
|
-
}
|
|
47
|
-
else if (i > 0) {
|
|
48
|
-
// check if we are maybe the last one with this depth until someone with a lower depth comes around
|
|
49
|
-
const isLast = lastElementInNesting(i, list, depth);
|
|
50
|
-
result += isLast ? '╰ ' : '├ ';
|
|
51
|
-
if (isLast) {
|
|
52
|
-
deadDepths.add(depth);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return result;
|
|
56
|
-
}
|
|
57
|
-
function retrieveLocationString(locationRaw) {
|
|
58
|
-
const extracted = (0, internal_1.extractLocation)(locationRaw);
|
|
59
|
-
if (extracted.start.line === extracted.end.line && extracted.start.column === extracted.end.column) {
|
|
60
|
-
return ` (${extracted.start.line}:${extracted.start.column})`;
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
return ` (${extracted.start.line}:${extracted.start.column}─${extracted.end.line}:${extracted.end.column})`;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
function depthListToTextTree(list, f) {
|
|
67
|
-
let result = '';
|
|
68
|
-
const deadDepths = new Set();
|
|
69
|
-
let i = 0;
|
|
70
|
-
for (const { depth, node, leaf } of list) {
|
|
71
|
-
const nextDepth = i + 1 < list.length ? list[i + 1].depth : 0;
|
|
72
|
-
deadDepths.delete(depth);
|
|
73
|
-
result += initialIndentation(i, depth, deadDepths, nextDepth, list, f);
|
|
74
|
-
result += f.reset();
|
|
75
|
-
const raw = (0, internal_1.objectWithArrUnwrap)(node);
|
|
76
|
-
const content = raw[r_bridge_1.contentKey];
|
|
77
|
-
const locationRaw = raw[r_bridge_1.attributesKey];
|
|
78
|
-
let location = '';
|
|
79
|
-
if (locationRaw !== undefined) {
|
|
80
|
-
location = retrieveLocationString(locationRaw);
|
|
81
|
-
}
|
|
82
|
-
const type = (0, internal_1.getTokenType)(node);
|
|
83
|
-
if (leaf) {
|
|
84
|
-
const suffix = `${f.format(content ? JSON.stringify(content) : '', { style: 1 /* FontStyles.Bold */ })}${f.format(location, { style: 3 /* FontStyles.Italic */ })}`;
|
|
85
|
-
result += `${type} ${suffix}`;
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
result += f.format(type, { style: 1 /* FontStyles.Bold */ });
|
|
89
|
-
}
|
|
90
|
-
i++;
|
|
91
|
-
}
|
|
92
|
-
return result;
|
|
93
|
-
}
|
|
94
|
-
exports.parseCommand = {
|
|
95
|
-
description: `Prints ASCII Art of the parsed, unmodified AST, start with '${r_bridge_1.fileProtocol}' to indicate a file`,
|
|
96
|
-
usageExample: ':parse',
|
|
97
|
-
aliases: ['p'],
|
|
98
|
-
script: false,
|
|
99
|
-
fn: async (output, shell, remainingLine) => {
|
|
100
|
-
const result = await new core_1.SteppingSlicer({
|
|
101
|
-
stepOfInterest: 'parse',
|
|
102
|
-
shell,
|
|
103
|
-
request: (0, r_bridge_1.requestFromInput)((0, r_bridge_1.removeRQuotes)(remainingLine.trim()))
|
|
104
|
-
}).allRemainingSteps();
|
|
105
|
-
const object = (0, parser_1.convertPreparedParsedData)((0, format_1.prepareParsedData)(result.parse));
|
|
106
|
-
output.stdout(depthListToTextTree(toDepthMap(object), output.formatter));
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
//# sourceMappingURL=parse.js.map
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.quitCommand = void 0;
|
|
4
|
-
const log_1 = require("../../../util/log");
|
|
5
|
-
exports.quitCommand = {
|
|
6
|
-
description: 'End the repl',
|
|
7
|
-
aliases: ['q', 'exit'],
|
|
8
|
-
usageExample: ':quit',
|
|
9
|
-
script: false,
|
|
10
|
-
fn: () => {
|
|
11
|
-
log_1.log.info('bye');
|
|
12
|
-
process.exit(0);
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
//# sourceMappingURL=quit.js.map
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { ReplCommand, ReplOutput } from './main';
|
|
2
|
-
import { RShell } from '../../../r-bridge';
|
|
3
|
-
type Version = `${number}.${number}.${number}`;
|
|
4
|
-
/**
|
|
5
|
-
* Describes the version of flowR and the used R interpreter.
|
|
6
|
-
*/
|
|
7
|
-
export interface VersionInformation {
|
|
8
|
-
/** The version of flowR */
|
|
9
|
-
flowr: Version;
|
|
10
|
-
/** The version of R identified by the underlying {@link RShell} */
|
|
11
|
-
r: Version | 'unknown';
|
|
12
|
-
}
|
|
13
|
-
export declare function retrieveVersionInformation(shell?: RShell): Promise<VersionInformation>;
|
|
14
|
-
export declare function printVersionInformation(output: ReplOutput, shell?: RShell): Promise<void>;
|
|
15
|
-
export declare const versionCommand: ReplCommand;
|
|
16
|
-
export {};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.versionCommand = exports.printVersionInformation = exports.retrieveVersionInformation = void 0;
|
|
4
|
-
const r_bridge_1 = require("../../../r-bridge");
|
|
5
|
-
const package_json_1 = require("../../../../package.json");
|
|
6
|
-
const assert_1 = require("../../../util/assert");
|
|
7
|
-
const versionRegex = /^\d+\.\d+\.\d+/m;
|
|
8
|
-
async function retrieveVersionInformation(shell) {
|
|
9
|
-
if (shell === undefined) {
|
|
10
|
-
shell = new r_bridge_1.RShell();
|
|
11
|
-
process.on('exit', () => shell.close());
|
|
12
|
-
}
|
|
13
|
-
const flowr = package_json_1.version;
|
|
14
|
-
const r = (await shell.usedRVersion())?.format() ?? 'unknown';
|
|
15
|
-
(0, assert_1.guard)(versionRegex.test(flowr), `flowR version ${flowr} does not match the expected format!`);
|
|
16
|
-
(0, assert_1.guard)(r === 'unknown' || versionRegex.test(r), `R version ${r} does not match the expected format!`);
|
|
17
|
-
return { flowr: flowr, r: r };
|
|
18
|
-
}
|
|
19
|
-
exports.retrieveVersionInformation = retrieveVersionInformation;
|
|
20
|
-
async function printVersionInformation(output, shell) {
|
|
21
|
-
const { flowr, r } = await retrieveVersionInformation(shell);
|
|
22
|
-
output.stdout(`flowR: ${flowr}`);
|
|
23
|
-
output.stdout(`R: ${r}`);
|
|
24
|
-
}
|
|
25
|
-
exports.printVersionInformation = printVersionInformation;
|
|
26
|
-
exports.versionCommand = {
|
|
27
|
-
description: 'Prints the version of flowR as well as the current version of R',
|
|
28
|
-
aliases: [],
|
|
29
|
-
usageExample: ':version',
|
|
30
|
-
script: false,
|
|
31
|
-
fn: (output, shell) => printVersionInformation(output, shell)
|
|
32
|
-
};
|
|
33
|
-
//# sourceMappingURL=version.js.map
|
package/cli/repl/core.d.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/**
|
|
3
|
-
* Basically a helper file to allow the main 'flowr' script (located in the source root) to provide its repl
|
|
4
|
-
*
|
|
5
|
-
* @module
|
|
6
|
-
*/
|
|
7
|
-
import { RShell } from '../../r-bridge';
|
|
8
|
-
import type { ReplOutput } from './commands';
|
|
9
|
-
import * as readline from 'readline';
|
|
10
|
-
/**
|
|
11
|
-
* Used by the repl to provide automatic completions for a given (partial) input line
|
|
12
|
-
*/
|
|
13
|
-
export declare function replCompleter(line: string): [string[], string];
|
|
14
|
-
export declare const DEFAULT_REPL_READLINE_CONFIGURATION: readline.ReadLineOptions;
|
|
15
|
-
/**
|
|
16
|
-
* This function interprets the given `expr` as a REPL command (see {@link repl} for more on the semantics).
|
|
17
|
-
*
|
|
18
|
-
* @param output - Defines two methods that every function in the repl uses to output its data.
|
|
19
|
-
* @param expr - The expression to process.
|
|
20
|
-
* @param shell - The {@link RShell} to use (see {@link repl}).
|
|
21
|
-
*/
|
|
22
|
-
export declare function replProcessAnswer(output: ReplOutput, expr: string, shell: RShell): Promise<void>;
|
|
23
|
-
/**
|
|
24
|
-
* Provides a never-ending repl (read-evaluate-print loop) processor that can be used to interact with a {@link RShell} as well as all flowR scripts.
|
|
25
|
-
*
|
|
26
|
-
* The repl allows for two kinds of inputs:
|
|
27
|
-
* - Starting with a colon `:`, indicating a command (probe `:help`, and refer to {@link commands}) </li>
|
|
28
|
-
* - Starting with anything else, indicating default R code to be directly executed. If you kill the underlying shell, that is on you! </li>
|
|
29
|
-
*
|
|
30
|
-
* @param shell - The shell to use, if you do not pass one it will automatically create a new one with the `revive` option set to 'always'
|
|
31
|
-
* @param rl - A potentially customized readline interface to be used for the repl to *read* from the user, we write the output with the {@link ReplOutput | `output` } interface.
|
|
32
|
-
* If you want to provide a custom one but use the same `completer`, refer to {@link replCompleter}.
|
|
33
|
-
* For the default arguments, see {@link DEFAULT_REPL_READLINE_CONFIGURATION}.
|
|
34
|
-
* @param output - Defines two methods that every function in the repl uses to output its data.
|
|
35
|
-
* @param historyFile - The file to use for persisting the repl's history. Passing undefined causes history not to be saved.
|
|
36
|
-
*
|
|
37
|
-
* For the execution, this function makes use of {@link replProcessAnswer}
|
|
38
|
-
*
|
|
39
|
-
*/
|
|
40
|
-
export declare function repl(shell?: RShell, rl?: readline.Interface, output?: ReplOutput, historyFile?: string | undefined): Promise<void>;
|
|
41
|
-
export declare function loadReplHistory(historyFile: string): string[] | undefined;
|