@eagleoutice/flowr 2.2.7 → 2.2.8
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 +4 -4
- package/cli/flowr-main-options.js +6 -0
- package/cli/flowr.d.ts +1 -0
- package/cli/flowr.js +2 -1
- package/config.d.ts +4 -0
- package/config.js +2 -1
- package/documentation/print-engines-wiki.js +1 -0
- package/package.json +1 -1
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.d.ts +5 -0
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +28 -7
- package/util/version.js +1 -1
package/README.md
CHANGED
|
@@ -48,7 +48,7 @@ It offers a wide variety of features, for example:
|
|
|
48
48
|
|
|
49
49
|
```shell
|
|
50
50
|
$ docker run -it --rm eagleoutice/flowr # or npm run flowr
|
|
51
|
-
flowR repl using flowR v2.2.
|
|
51
|
+
flowR repl using flowR v2.2.7, R v4.4.0 (r-shell engine)
|
|
52
52
|
R> :slicer test/testfiles/example.R --criterion "11@sum"
|
|
53
53
|
```
|
|
54
54
|
|
|
@@ -95,7 +95,7 @@ It offers a wide variety of features, for example:
|
|
|
95
95
|
|
|
96
96
|
|
|
97
97
|
* 🚀 **fast data- and control-flow graphs**\
|
|
98
|
-
Within just <i><span title="This measurement is automatically fetched from the latest benchmark!">
|
|
98
|
+
Within just <i><span title="This measurement is automatically fetched from the latest benchmark!">118 ms</i></span> (as of Feb 19, 2025),
|
|
99
99
|
_flowR_ can analyze the data- and control-flow of the average real-world R script. See the [benchmarks](https://flowr-analysis.github.io/flowr/wiki/stats/benchmark) for more information,
|
|
100
100
|
and consult the [wiki pages](https://github.com/flowr-analysis/flowr/wiki/Dataflow-Graph) for more details on the dataflow graph.
|
|
101
101
|
|
|
@@ -131,7 +131,7 @@ It offers a wide variety of features, for example:
|
|
|
131
131
|
|
|
132
132
|
```shell
|
|
133
133
|
$ docker run -it --rm eagleoutice/flowr # or npm run flowr
|
|
134
|
-
flowR repl using flowR v2.2.
|
|
134
|
+
flowR repl using flowR v2.2.7, R v4.4.0 (r-shell engine)
|
|
135
135
|
R> :dataflow* test/testfiles/example.R
|
|
136
136
|
```
|
|
137
137
|
|
|
@@ -375,7 +375,7 @@ It offers a wide variety of features, for example:
|
|
|
375
375
|
52 -->|"argument"| 50
|
|
376
376
|
```
|
|
377
377
|
|
|
378
|
-
(The analysis required
|
|
378
|
+
(The analysis required _23.15 ms_ (including parse and normalize, using the [r-shell](https://github.com/flowr-analysis/flowr/wiki/Engines) engine) within the generation environment.)
|
|
379
379
|
|
|
380
380
|
|
|
381
381
|
|
|
@@ -111,6 +111,12 @@ exports.flowrMainOptionDefinitions = [
|
|
|
111
111
|
description: 'The path to the tree-sitter WASM binary to use. Defaults to the path specified by the tree-sitter package.',
|
|
112
112
|
multiple: false
|
|
113
113
|
},
|
|
114
|
+
{
|
|
115
|
+
name: 'engine.tree-sitter.lax',
|
|
116
|
+
type: Boolean,
|
|
117
|
+
description: 'Use the lax parser for parsing R code (allowing for syntax errors).',
|
|
118
|
+
multiple: false
|
|
119
|
+
},
|
|
114
120
|
{
|
|
115
121
|
name: 'default-engine',
|
|
116
122
|
type: String,
|
package/cli/flowr.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export interface FlowrCliOptions {
|
|
|
20
20
|
'engine.tree-sitter.disabled': boolean;
|
|
21
21
|
'engine.tree-sitter.wasm-path': string | undefined;
|
|
22
22
|
'engine.tree-sitter.tree-sitter-wasm-path': string | undefined;
|
|
23
|
+
'engine.tree-sitter.lax': boolean;
|
|
23
24
|
}
|
|
24
25
|
export declare const optionHelp: ({
|
|
25
26
|
header: string;
|
package/cli/flowr.js
CHANGED
|
@@ -79,7 +79,8 @@ if (!options['engine.tree-sitter.disabled']) {
|
|
|
79
79
|
(0, config_1.amendConfig)({ engines: [{
|
|
80
80
|
type: 'tree-sitter',
|
|
81
81
|
wasmPath: options['engine.tree-sitter.wasm-path'],
|
|
82
|
-
treeSitterWasmPath: options['engine.tree-sitter.tree-sitter-wasm-path']
|
|
82
|
+
treeSitterWasmPath: options['engine.tree-sitter.tree-sitter-wasm-path'],
|
|
83
|
+
lax: options['engine.tree-sitter.lax']
|
|
83
84
|
}] });
|
|
84
85
|
}
|
|
85
86
|
if (options['default-engine']) {
|
package/config.d.ts
CHANGED
|
@@ -61,6 +61,10 @@ export interface TreeSitterEngineConfig extends MergeableRecord {
|
|
|
61
61
|
* The path to the tree-sitter WASM binary to use. If this is undefined, the path specified by the tree-sitter package will be used.
|
|
62
62
|
*/
|
|
63
63
|
readonly treeSitterWasmPath?: string;
|
|
64
|
+
/**
|
|
65
|
+
* Whether to use the lax parser for parsing R code (allowing for syntax errors). If this is undefined, the strict parser will be used.
|
|
66
|
+
*/
|
|
67
|
+
readonly lax?: boolean;
|
|
64
68
|
}
|
|
65
69
|
export interface RShellEngineConfig extends MergeableRecord {
|
|
66
70
|
readonly type: 'r-shell';
|
package/config.js
CHANGED
|
@@ -59,7 +59,8 @@ exports.flowrConfigFileSchema = joi_1.default.object({
|
|
|
59
59
|
engines: joi_1.default.array().items(joi_1.default.alternatives(joi_1.default.object({
|
|
60
60
|
type: joi_1.default.string().required().valid('tree-sitter').description('Use the tree sitter engine.'),
|
|
61
61
|
wasmPath: joi_1.default.string().optional().description('The path to the tree-sitter-r WASM binary to use. If this is undefined, this uses the default path.'),
|
|
62
|
-
treeSitterWasmPath: joi_1.default.string().optional().description('The path to the tree-sitter WASM binary to use. If this is undefined, this uses the default path.')
|
|
62
|
+
treeSitterWasmPath: joi_1.default.string().optional().description('The path to the tree-sitter WASM binary to use. If this is undefined, this uses the default path.'),
|
|
63
|
+
lax: joi_1.default.boolean().optional().description('Whether to use the lax parser for parsing R code (allowing for syntax errors). If this is undefined, the strict parser will be used.')
|
|
63
64
|
}).description('The configuration for the tree sitter engine.'), joi_1.default.object({
|
|
64
65
|
type: joi_1.default.string().required().valid('r-shell').description('Use the R shell engine.'),
|
|
65
66
|
rPath: joi_1.default.string().optional().description('The path to the R executable to use. If this is undefined, this uses the default path.')
|
|
@@ -39,6 +39,7 @@ are exposed with some command line options (e.g., when using the docker image of
|
|
|
39
39
|
- ${(0, doc_cli_option_1.getCliLongOptionOf)('flowr', 'engine.r-shell.disabled', false)} to disable the ${(0, doc_types_1.shortLink)(shell_1.RShell.name, types.info)} engine
|
|
40
40
|
- ${(0, doc_cli_option_1.getCliLongOptionOf)('flowr', 'engine.r-shell.r-path', false)} (which is the canonical version of ${(0, doc_cli_option_1.getCliLongOptionOf)('flowr', 'r-path')})
|
|
41
41
|
- ${(0, doc_cli_option_1.getCliLongOptionOf)('flowr', 'engine.tree-sitter.disabled', false)} to disable the ${(0, doc_types_1.shortLink)(tree_sitter_executor_1.TreeSitterExecutor.name, types.info)} engine
|
|
42
|
+
- ${(0, doc_cli_option_1.getCliLongOptionOf)('flowr', 'engine.tree-sitter.lax', false)} to use lax parsing with tree-sitter
|
|
42
43
|
- ${(0, doc_cli_option_1.getCliLongOptionOf)('flowr', 'engine.tree-sitter.wasm-path', false)} pass the path to the wasm of the r grammar of tree-sitter (see [below](#tree-sitter))
|
|
43
44
|
- ${(0, doc_cli_option_1.getCliLongOptionOf)('flowr', 'engine.tree-sitter.tree-sitter-wasm-path', false)} pass the path to the wasm of tree-sitter (see [below](#tree-sitter))
|
|
44
45
|
- ${(0, doc_cli_option_1.getCliLongOptionOf)('flowr', 'default-engine', false)} to set the default engine to use
|
package/package.json
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import type { RExpressionList } from '../ast/model/nodes/r-expression-list';
|
|
2
2
|
import type { Tree } from 'web-tree-sitter';
|
|
3
|
+
/**
|
|
4
|
+
* @param tree - The tree to normalize
|
|
5
|
+
*/
|
|
3
6
|
export declare function normalizeTreeSitterTreeToAst(tree: Tree): RExpressionList;
|
|
7
|
+
export declare function makeTreeSitterLax(): void;
|
|
8
|
+
export declare function makeTreeSitterStrict(): void;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizeTreeSitterTreeToAst = normalizeTreeSitterTreeToAst;
|
|
4
|
+
exports.makeTreeSitterLax = makeTreeSitterLax;
|
|
5
|
+
exports.makeTreeSitterStrict = makeTreeSitterStrict;
|
|
4
6
|
const normalizer_data_1 = require("../ast/parser/main/normalizer-data");
|
|
5
7
|
const tree_sitter_types_1 = require("./tree-sitter-types");
|
|
6
8
|
const type_1 = require("../ast/model/type");
|
|
@@ -10,20 +12,39 @@ const normalize_meta_1 = require("../ast/parser/main/normalize-meta");
|
|
|
10
12
|
const arrays_1 = require("../../../util/arrays");
|
|
11
13
|
const r_function_call_1 = require("../ast/model/nodes/r-function-call");
|
|
12
14
|
const strings_1 = require("../../../util/strings");
|
|
15
|
+
const config_1 = require("../../../config");
|
|
16
|
+
const log_1 = require("../../../util/log");
|
|
17
|
+
/**
|
|
18
|
+
* @param tree - The tree to normalize
|
|
19
|
+
*/
|
|
13
20
|
function normalizeTreeSitterTreeToAst(tree) {
|
|
21
|
+
const lax = (0, config_1.getEngineConfig)('tree-sitter')?.lax;
|
|
22
|
+
if (lax) {
|
|
23
|
+
makeTreeSitterLax();
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
makeTreeSitterStrict();
|
|
27
|
+
}
|
|
14
28
|
const root = convertTreeNode(tree.rootNode);
|
|
15
29
|
if (root.type !== type_1.RType.ExpressionList) {
|
|
16
30
|
throw new normalizer_data_1.ParseError(`expected root to resolve to an expression list, got a ${root.type}`);
|
|
17
31
|
}
|
|
18
32
|
return root;
|
|
19
33
|
}
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
34
|
+
function nonErrorChildrenStrict(node) {
|
|
35
|
+
return node.hasError ? [] : node.children;
|
|
36
|
+
}
|
|
37
|
+
function nonErrorChildrenLax(node) {
|
|
38
|
+
return node.hasError ? node.children.filter(n => n.type !== tree_sitter_types_1.TreeSitterType.Error) : node.children;
|
|
39
|
+
}
|
|
40
|
+
let nonErrorChildren = nonErrorChildrenStrict;
|
|
41
|
+
function makeTreeSitterLax() {
|
|
42
|
+
log_1.log.info('[Tree-Sitter] Lax parsing active');
|
|
43
|
+
nonErrorChildren = nonErrorChildrenLax;
|
|
44
|
+
}
|
|
45
|
+
function makeTreeSitterStrict() {
|
|
46
|
+
log_1.log.info('[Tree-Sitter] Strict parsing active');
|
|
47
|
+
nonErrorChildren = nonErrorChildrenStrict;
|
|
27
48
|
}
|
|
28
49
|
function convertTreeNode(node) {
|
|
29
50
|
// generally, the grammar source file dictates what children a node has in what order:
|
package/util/version.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.flowrVersion = flowrVersion;
|
|
4
4
|
const semver_1 = require("semver");
|
|
5
5
|
// this is automatically replaced with the current version by release-it
|
|
6
|
-
const version = '2.2.
|
|
6
|
+
const version = '2.2.8';
|
|
7
7
|
function flowrVersion() {
|
|
8
8
|
return new semver_1.SemVer(version);
|
|
9
9
|
}
|