@eagleoutice/flowr 2.13.9 → 2.13.11
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 +40 -40
- package/config.d.ts +50 -2
- package/config.js +37 -6
- package/dataflow/environments/apply-kill.js +4 -4
- package/dataflow/environments/built-in-props.d.ts +28 -4
- package/dataflow/environments/built-in-props.js +31 -8
- package/dataflow/environments/built-in.d.ts +7 -2
- package/dataflow/environments/built-in.js +10 -12
- package/dataflow/environments/default-builtin-config.d.ts +46 -6
- package/dataflow/environments/default-builtin-config.js +30 -16
- package/dataflow/environments/environment.d.ts +16 -0
- package/dataflow/environments/environment.js +114 -26
- package/dataflow/environments/identifier.d.ts +6 -0
- package/dataflow/environments/identifier.js +18 -5
- package/dataflow/environments/query-fn-props.js +34 -2
- package/dataflow/environments/reference-to-maybe.js +1 -1
- package/dataflow/environments/resolve-by-name.js +16 -6
- package/dataflow/environments/resolve-helper.d.ts +43 -0
- package/dataflow/environments/resolve-helper.js +47 -0
- package/dataflow/eval/resolve/alias-tracking.js +45 -1
- package/dataflow/eval/resolve/resolve-argument.js +25 -17
- package/dataflow/eval/resolve/resolve-strings.d.ts +17 -0
- package/dataflow/eval/resolve/resolve-strings.js +16 -9
- package/dataflow/eval/resolve/resolve.js +3 -1
- package/dataflow/graph/call-graph.d.ts +7 -0
- package/dataflow/graph/call-graph.js +103 -0
- package/dataflow/graph/df-helper.d.ts +50 -1
- package/dataflow/graph/df-helper.js +63 -0
- package/dataflow/graph/graph.d.ts +5 -8
- package/dataflow/graph/graph.js +24 -13
- package/dataflow/internal/linker.d.ts +5 -5
- package/dataflow/internal/linker.js +31 -92
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +3 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +4 -30
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +7 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-load.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +5 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-with.d.ts +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +5 -6
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +32 -14
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +16 -4
- package/dataflow/internal/process/functions/call/known-call-handling.js +29 -8
- package/documentation/data/faq/faqs.js +1 -1
- package/documentation/data/faq/wiki-faq-store.js +3 -2
- package/documentation/data/server/doc-data-server-messages.js +1 -1
- package/documentation/doc-readme.js +1 -1
- package/documentation/doc-util/doc-files.d.ts +5 -0
- package/documentation/doc-util/doc-files.js +13 -3
- package/documentation/doc-util/doc-sigdb.d.ts +9 -0
- package/documentation/doc-util/doc-sigdb.js +32 -0
- package/documentation/wiki-analyzer.js +10 -10
- package/documentation/wiki-core.js +1 -1
- package/documentation/wiki-dataflow-graph.js +3 -3
- package/documentation/wiki-interface.js +13 -2
- package/documentation/wiki-linting-and-testing.js +13 -13
- package/documentation/wiki-mk/doc-context.d.ts +1 -1
- package/documentation/wiki-mk/doc-context.js +9 -5
- package/documentation/wiki-normalized-ast.js +1 -1
- package/documentation/wiki-overview.js +2 -2
- package/documentation/wiki-query.js +4 -1
- package/documentation/wiki-setup.js +3 -3
- package/documentation/wiki-signature-database.js +2 -5
- package/gas.d.ts +6 -0
- package/gas.js +7 -1
- package/linter/linter-rules.d.ts +1 -1
- package/linter/rules/syntactically-valid.d.ts +12 -1
- package/linter/rules/syntactically-valid.js +88 -17
- package/package.json +7 -8
- package/project/attached-packages.d.ts +13 -0
- package/project/attached-packages.js +30 -0
- package/project/context/flowr-analyzer-context.d.ts +15 -0
- package/project/context/flowr-analyzer-context.js +14 -3
- package/project/context/flowr-analyzer-files-context.d.ts +11 -0
- package/project/context/flowr-analyzer-files-context.js +3 -0
- package/project/context/flowr-analyzer-incremental-analysis-context.d.ts +4 -0
- package/project/context/flowr-analyzer-incremental-analysis-context.js +69 -0
- package/project/context/flowr-analyzer-loading-order-context.d.ts +8 -0
- package/project/context/flowr-analyzer-loading-order-context.js +23 -2
- package/project/dependency-version-space.d.ts +33 -11
- package/project/dependency-version-space.js +58 -32
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +52 -24
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-library-plugin.d.ts +22 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-library-plugin.js +101 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +30 -11
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +79 -37
- package/project/plugins/plugin-registry.d.ts +2 -1
- package/project/plugins/plugin-registry.js +2 -0
- package/project/sigdb/manifest.js +9 -5
- package/project/sigdb/reader.d.ts +20 -0
- package/project/sigdb/reader.js +93 -10
- package/project/sigdb/signature-match.d.ts +5 -18
- package/project/sigdb/signature-match.js +5 -18
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +1 -1
- package/queries/catalog/call-graph-query/call-graph-query-executor.js +3 -1
- package/queries/catalog/call-graph-query/call-graph-query-format.d.ts +4 -0
- package/queries/catalog/call-graph-query/call-graph-query-format.js +4 -0
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +11 -3
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +25 -1
- package/queries/catalog/dependencies-query/dependencies-query-format.js +22 -2
- package/queries/catalog/dependencies-query/function-info/library-functions.js +7 -1
- package/queries/catalog/dependencies-query/function-info/read-functions.js +5 -5
- package/queries/catalog/dependencies-query/function-info/remote-functions.d.ts +18 -0
- package/queries/catalog/dependencies-query/function-info/remote-functions.js +46 -0
- package/queries/catalog/dependencies-query/function-info/visualize-functions.js +52 -2
- package/queries/catalog/dependencies-query/function-info/write-functions.js +8 -4
- package/queries/catalog/dependencies-query/link-devices.d.ts +16 -0
- package/queries/catalog/dependencies-query/link-devices.js +104 -0
- package/queries/catalog/dice-query/dice-query-format.d.ts +2 -0
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +25 -6
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +37 -6
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +17 -4
- package/queries/catalog/happens-before-query/happens-before-query-executor.js +2 -1
- package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +14 -0
- package/queries/catalog/happens-before-query/happens-before-query-format.js +18 -2
- package/queries/catalog/input-sources-query/input-sources-query-format.js +4 -0
- package/queries/catalog/input-sources-query/input-types.d.ts +10 -0
- package/queries/catalog/input-sources-query/input-types.js +10 -0
- package/queries/catalog/location-map-query/location-map-query-executor.js +16 -6
- package/queries/catalog/location-map-query/location-map-query-format.d.ts +15 -1
- package/queries/catalog/location-map-query/location-map-query-format.js +22 -5
- package/queries/catalog/signature-query/signature-query-executor.js +3 -0
- package/queries/catalog/signature-query/signature-query-format.d.ts +5 -0
- package/queries/catalog/slice-query-options.d.ts +11 -1
- package/queries/catalog/slice-query-options.js +8 -4
- package/queries/catalog/static-slice-query/static-slice-query-executor.js +4 -1
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +5 -1
- package/queries/query.d.ts +1 -1
- package/r-bridge/lang-4.x/ast/model/model.d.ts +23 -2
- package/r-bridge/lang-4.x/ast/model/model.js +44 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +8 -8
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +9 -46
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +0 -5
- package/r-bridge/lang-4.x/ast/model/processing/node-id.js +6 -3
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +1 -1
- package/reconstruct/reconstruct.d.ts +9 -0
- package/reconstruct/reconstruct.js +1 -0
- package/search/flowr-search-filters.d.ts +25 -1
- package/search/flowr-search-filters.js +42 -7
- package/search/search-executor/search-generators.js +7 -2
- package/search/search-executor/search-transformer.js +4 -1
- package/slicing/criterion/parse.d.ts +5 -25
- package/slicing/criterion/parse.js +15 -20
- package/slicing/static/fingerprint.js +18 -6
- package/slicing/static/slice-call.js +2 -2
- package/slicing/static/slicer-types.d.ts +10 -0
- package/slicing/static/static-slicer.d.ts +1 -1
- package/slicing/static/static-slicer.js +29 -6
- package/slicing/static/visiting-queue.d.ts +12 -2
- package/slicing/static/visiting-queue.js +28 -3
- package/util/arg-matching.d.ts +18 -0
- package/util/arg-matching.js +70 -0
- package/util/collections/bimap.d.ts +21 -1
- package/util/collections/bimap.js +43 -7
- package/util/r-regex.js +19 -1
- package/util/range.d.ts +7 -8
- package/util/range.js +10 -11
- package/util/version.js +1 -1
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DotsParameterName = void 0;
|
|
4
|
+
exports.matchArgumentsToParameters = matchArgumentsToParameters;
|
|
5
|
+
const prefix_1 = require("./prefix");
|
|
6
|
+
/** the name of the special `...` parameter which collects everything that finds no formal of its own */
|
|
7
|
+
exports.DotsParameterName = '...';
|
|
8
|
+
/**
|
|
9
|
+
* Bind the arguments of a call to the formal parameters of the called function, following R's argument matching
|
|
10
|
+
* rules (see https://cran.r-project.org/doc/manuals/R-lang.html#Argument-matching):
|
|
11
|
+
*
|
|
12
|
+
* 1. every named argument that *exactly* matches a formal takes it,
|
|
13
|
+
* 2. every remaining named argument that is a *unique prefix* of a still-free formal takes it (`pmatch`),
|
|
14
|
+
* 3. the remaining unnamed arguments fill the still-free formals from left to right, stopping at `...`
|
|
15
|
+
* (formals behind `...` can only be matched by name), and
|
|
16
|
+
* 4. everything that is still unmatched goes to `...` if the function has one.
|
|
17
|
+
*
|
|
18
|
+
* Both sides are given by their names alone (`undefined` for an unnamed argument or an anonymous formal), so this
|
|
19
|
+
* works for the normalized AST, the dataflow graph, and a plain signature list alike. An empty argument (`f(1, ,3)`)
|
|
20
|
+
* is an unnamed one: it takes its formal like any other, the caller just has nothing to bind to it.
|
|
21
|
+
* @returns for every argument (by index) the index of the parameter it binds to, `undefined` if it stays unbound
|
|
22
|
+
*/
|
|
23
|
+
function matchArgumentsToParameters(argNames, paramNames) {
|
|
24
|
+
const bound = Array.from(argNames, () => undefined);
|
|
25
|
+
const names = paramNames.map(p => p ?? '');
|
|
26
|
+
const dots = names.indexOf(exports.DotsParameterName);
|
|
27
|
+
const taken = new Set();
|
|
28
|
+
const take = (arg, param) => {
|
|
29
|
+
bound[arg] = param;
|
|
30
|
+
taken.add(param);
|
|
31
|
+
};
|
|
32
|
+
/** binds each still-free named argument to the formal `pick` names for it, as long as that one is still free too */
|
|
33
|
+
const byName = (pick) => {
|
|
34
|
+
for (let i = 0; i < argNames.length; i++) {
|
|
35
|
+
const name = argNames[i];
|
|
36
|
+
if (name === undefined || bound[i] !== undefined) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
const target = pick(name);
|
|
40
|
+
const param = target === undefined ? -1 : names.indexOf(target);
|
|
41
|
+
if (param >= 0 && !taken.has(param)) {
|
|
42
|
+
take(i, param);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
byName(name => name); // (1) exact
|
|
47
|
+
byName(name => (0, prefix_1.findByPrefixIfUnique)(name, names)); // (2) pmatch
|
|
48
|
+
// (3) positional
|
|
49
|
+
let formal = 0;
|
|
50
|
+
for (let i = 0; i < argNames.length; i++) {
|
|
51
|
+
if (argNames[i] !== undefined || bound[i] !== undefined) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
while (taken.has(formal)) {
|
|
55
|
+
formal++;
|
|
56
|
+
}
|
|
57
|
+
if (formal >= names.length || formal === dots) {
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
take(i, formal);
|
|
61
|
+
}
|
|
62
|
+
// (4) `...`
|
|
63
|
+
if (dots >= 0) {
|
|
64
|
+
for (let i = 0; i < argNames.length; i++) {
|
|
65
|
+
bound[i] ??= dots;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return bound;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=arg-matching.js.map
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* When to fill the value -> key direction of a {@link BiMap}.
|
|
3
|
+
*
|
|
4
|
+
* - `lazy` (default) fills it on the first reverse lookup and maintains it from then on, so a map nobody asks in
|
|
5
|
+
* reverse never pays a write per entry.
|
|
6
|
+
* - `eager` fills it from the start, for a map written once and then asked in reverse from a hot path.
|
|
7
|
+
*
|
|
8
|
+
* Both answer {@link BiMap#getKey|getKey} and {@link BiMap#hasValue|hasValue} the same, they differ only in when
|
|
9
|
+
* the work happens.
|
|
10
|
+
*/
|
|
11
|
+
export type BiMapReverse = 'lazy' | 'eager';
|
|
1
12
|
/**
|
|
2
13
|
* Implementation of a bidirectional map
|
|
3
14
|
*
|
|
@@ -8,7 +19,12 @@ export declare class BiMap<K, V extends object> implements Map<K, V> {
|
|
|
8
19
|
size: number;
|
|
9
20
|
private readonly k2v;
|
|
10
21
|
private v2k;
|
|
11
|
-
|
|
22
|
+
private readonly eager;
|
|
23
|
+
/**
|
|
24
|
+
* @param base - the entries to fill the map with
|
|
25
|
+
* @param reverse - when to fill the value -> key direction; see {@link BiMapReverse}
|
|
26
|
+
*/
|
|
27
|
+
constructor(base?: Iterable<[K, V]>, reverse?: BiMapReverse);
|
|
12
28
|
[Symbol.iterator](): MapIterator<[K, V]>;
|
|
13
29
|
clear(): void;
|
|
14
30
|
delete(key: K): boolean;
|
|
@@ -20,5 +36,9 @@ export declare class BiMap<K, V extends object> implements Map<K, V> {
|
|
|
20
36
|
hasValue(value: V): boolean;
|
|
21
37
|
keys(): MapIterator<K>;
|
|
22
38
|
set(key: K, value: V): this;
|
|
39
|
+
/** the reverse direction can no longer be maintained in place, so re-derive it (at once if eager) */
|
|
40
|
+
private staleReverse;
|
|
23
41
|
values(): MapIterator<V>;
|
|
42
|
+
/** the value -> key direction, filled from the entries already present if this is its first use */
|
|
43
|
+
private reverse;
|
|
24
44
|
}
|
|
@@ -10,8 +10,18 @@ class BiMap {
|
|
|
10
10
|
[Symbol.toStringTag] = 'BiMap';
|
|
11
11
|
size = 0;
|
|
12
12
|
k2v = new Map();
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
/* see {@link BiMapReverse}: `undefined` until the first reverse lookup unless this map was asked to be eager */
|
|
14
|
+
v2k;
|
|
15
|
+
eager;
|
|
16
|
+
/**
|
|
17
|
+
* @param base - the entries to fill the map with
|
|
18
|
+
* @param reverse - when to fill the value -> key direction; see {@link BiMapReverse}
|
|
19
|
+
*/
|
|
20
|
+
constructor(base, reverse = 'lazy') {
|
|
21
|
+
this.eager = reverse === 'eager';
|
|
22
|
+
if (this.eager) {
|
|
23
|
+
this.v2k = new WeakMap();
|
|
24
|
+
}
|
|
15
25
|
if (base != null) {
|
|
16
26
|
for (const [k, v] of base) {
|
|
17
27
|
this.set(k, v);
|
|
@@ -24,7 +34,7 @@ class BiMap {
|
|
|
24
34
|
clear() {
|
|
25
35
|
this.size = 0;
|
|
26
36
|
this.k2v.clear();
|
|
27
|
-
this.v2k = new WeakMap();
|
|
37
|
+
this.v2k = this.eager ? new WeakMap() : undefined;
|
|
28
38
|
}
|
|
29
39
|
delete(key) {
|
|
30
40
|
const value = this.k2v.get(key);
|
|
@@ -32,7 +42,8 @@ class BiMap {
|
|
|
32
42
|
return false;
|
|
33
43
|
}
|
|
34
44
|
this.k2v.delete(key);
|
|
35
|
-
this
|
|
45
|
+
/* another key may still hold this value, so dropping just its entry would lose a live mapping */
|
|
46
|
+
this.staleReverse();
|
|
36
47
|
this.size = this.k2v.size;
|
|
37
48
|
return true;
|
|
38
49
|
}
|
|
@@ -46,26 +57,51 @@ class BiMap {
|
|
|
46
57
|
return this.k2v.get(key);
|
|
47
58
|
}
|
|
48
59
|
getKey(value) {
|
|
49
|
-
return this.
|
|
60
|
+
return this.reverse().get(value);
|
|
50
61
|
}
|
|
51
62
|
has(key) {
|
|
52
63
|
return this.k2v.has(key);
|
|
53
64
|
}
|
|
54
65
|
hasValue(value) {
|
|
55
|
-
return this.
|
|
66
|
+
return this.reverse().has(value);
|
|
56
67
|
}
|
|
57
68
|
keys() {
|
|
58
69
|
return this.k2v.keys();
|
|
59
70
|
}
|
|
60
71
|
set(key, value) {
|
|
72
|
+
const replaced = this.k2v.get(key);
|
|
61
73
|
this.k2v.set(key, value);
|
|
62
|
-
|
|
74
|
+
if (replaced !== undefined && replaced !== value) {
|
|
75
|
+
/* the value this key held may now be unreachable, so its reverse entry cannot stand */
|
|
76
|
+
this.staleReverse();
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
this.v2k?.set(value, key);
|
|
80
|
+
}
|
|
63
81
|
this.size = this.k2v.size;
|
|
64
82
|
return this;
|
|
65
83
|
}
|
|
84
|
+
/** the reverse direction can no longer be maintained in place, so re-derive it (at once if eager) */
|
|
85
|
+
staleReverse() {
|
|
86
|
+
this.v2k = undefined;
|
|
87
|
+
if (this.eager) {
|
|
88
|
+
this.reverse();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
66
91
|
values() {
|
|
67
92
|
return this.k2v.values();
|
|
68
93
|
}
|
|
94
|
+
/** the value -> key direction, filled from the entries already present if this is its first use */
|
|
95
|
+
reverse() {
|
|
96
|
+
if (this.v2k === undefined) {
|
|
97
|
+
const v2k = new WeakMap();
|
|
98
|
+
for (const [k, v] of this.k2v) {
|
|
99
|
+
v2k.set(v, k);
|
|
100
|
+
}
|
|
101
|
+
this.v2k = v2k;
|
|
102
|
+
}
|
|
103
|
+
return this.v2k;
|
|
104
|
+
}
|
|
69
105
|
}
|
|
70
106
|
exports.BiMap = BiMap;
|
|
71
107
|
//# sourceMappingURL=bimap.js.map
|
package/util/r-regex.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RPunctuationChars = exports.RStandardRegexp = void 0;
|
|
4
4
|
exports.parseRRegexPattern = parseRRegexPattern;
|
|
5
|
+
const log_1 = require("./log");
|
|
5
6
|
/**
|
|
6
7
|
* Represents R's `.standard_regexps` definitions.
|
|
7
8
|
* @see https://github.com/r-devel/r-svn/blob/44474af03ae77fd3b9a340279fa10cb698d106c3/src/library/base/R/utils.R#L52-L53
|
|
@@ -40,6 +41,10 @@ const PosixClassMap = {
|
|
|
40
41
|
print: '\x20-\x7E'
|
|
41
42
|
};
|
|
42
43
|
const posixClassRegex = /\[:([a-z]+):]/g;
|
|
44
|
+
/** the flags R accepts inside the pattern (`(?i)foo`), which JavaScript only takes next to it */
|
|
45
|
+
const inlineFlags = /^\(\?([imsx]+)\)/;
|
|
46
|
+
/** what a pattern JavaScript cannot compile falls back to, so one bad pattern matches nothing rather than throwing */
|
|
47
|
+
const matchesNothing = /(?!)/;
|
|
43
48
|
/**
|
|
44
49
|
* Converts an R regex pattern (which may include POSIX character classes) into a JavaScript RegExp.
|
|
45
50
|
*/
|
|
@@ -52,6 +57,19 @@ function parseRRegexPattern(pattern) {
|
|
|
52
57
|
if (convertedPattern.startsWith('*') || convertedPattern.startsWith('+')) {
|
|
53
58
|
convertedPattern = '.' + convertedPattern;
|
|
54
59
|
}
|
|
55
|
-
|
|
60
|
+
let flags = '';
|
|
61
|
+
const inline = inlineFlags.exec(convertedPattern);
|
|
62
|
+
if (inline) {
|
|
63
|
+
/* `x` (extended) has no counterpart, the others carry over by name */
|
|
64
|
+
flags = inline[1].replaceAll('x', '');
|
|
65
|
+
convertedPattern = convertedPattern.slice(inline[0].length);
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
return new RegExp(convertedPattern, flags);
|
|
69
|
+
}
|
|
70
|
+
catch (e) {
|
|
71
|
+
log_1.log.warn(`R pattern ${JSON.stringify(pattern)} is no JavaScript regex, treating it as matching nothing: ${e.message}`);
|
|
72
|
+
return matchesNothing;
|
|
73
|
+
}
|
|
56
74
|
}
|
|
57
75
|
//# sourceMappingURL=r-regex.js.map
|
package/util/range.d.ts
CHANGED
|
@@ -101,10 +101,8 @@ export declare const SourceRange: {
|
|
|
101
101
|
* @returns true iff `r1` starts and ends before `r2` starts (i.e., if `r1` and `r2` do not overlap and `r1` comes before `r2`
|
|
102
102
|
*/
|
|
103
103
|
readonly startsCompletelyBefore: (this: void, [, , r1el, r1ec]: SourceRange, [r2sl, r2sc, ,]: SourceRange) => boolean;
|
|
104
|
-
/**
|
|
105
|
-
|
|
106
|
-
*/
|
|
107
|
-
readonly overlap: (this: void, [r1sl, r1sc, r1el, r1ec]: SourceRange, [r2sl, r2sc, r2el, r2ec]: SourceRange) => boolean;
|
|
104
|
+
/** Checks if the two ranges overlap, i.e. whether neither of them lies completely before the other. */
|
|
105
|
+
readonly overlap: (this: void, r1: SourceRange, r2: SourceRange) => boolean;
|
|
108
106
|
/**
|
|
109
107
|
* Calculates the component-wise sum of two ranges.
|
|
110
108
|
*/
|
|
@@ -169,17 +167,18 @@ export declare const SourceLocation: {
|
|
|
169
167
|
* Formats a {@link SourceLocation|source location} as a human-readable string.
|
|
170
168
|
*/
|
|
171
169
|
readonly format: (this: void, location: SourceLocation | undefined) => string;
|
|
170
|
+
/** Returns the {@link SourceRange|source range} part of a {@link SourceLocation|source location}, file excluded. */
|
|
171
|
+
readonly getRange: (this: void, [sl, sc, el, ec]: SourceLocation) => SourceRange;
|
|
172
172
|
/**
|
|
173
|
-
* Returns the
|
|
173
|
+
* Returns the file part of a {@link SourceLocation|source location}, or `undefined` if no file is set.
|
|
174
174
|
*/
|
|
175
|
-
readonly getRange: (this: void, location: SourceLocation) => SourceRange;
|
|
176
175
|
readonly getFile: (this: void, location: SourceLocation) => string | undefined;
|
|
177
176
|
/**
|
|
178
|
-
*
|
|
177
|
+
* Creates a {@link SourceLocation|source location} from a {@link SourceRange|source range} and a file name.
|
|
179
178
|
*/
|
|
180
179
|
readonly from: (this: void, range: SourceRange, file?: string) => SourceLocation;
|
|
181
180
|
/**
|
|
182
|
-
*
|
|
181
|
+
* The {@link SourceLocation|source location} of an AST node, file included.
|
|
183
182
|
* @returns undefined if the given range is undefined
|
|
184
183
|
* @see {@link SourceRange.fromNode} for getting the range from an AST node
|
|
185
184
|
*/
|
package/util/range.js
CHANGED
|
@@ -126,11 +126,9 @@ exports.SourceRange = {
|
|
|
126
126
|
startsCompletelyBefore([, , r1el, r1ec], [r2sl, r2sc, ,]) {
|
|
127
127
|
return r1el < r2sl || (r1el === r2sl && r1ec < r2sc);
|
|
128
128
|
},
|
|
129
|
-
/**
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
overlap([r1sl, r1sc, r1el, r1ec], [r2sl, r2sc, r2el, r2ec]) {
|
|
133
|
-
return r1sl <= r2el && r2sl <= r1el && r1sc <= r2ec && r2sc <= r1ec;
|
|
129
|
+
/** Checks if the two ranges overlap, i.e. whether neither of them lies completely before the other. */
|
|
130
|
+
overlap(r1, r2) {
|
|
131
|
+
return !exports.SourceRange.startsCompletelyBefore(r1, r2) && !exports.SourceRange.startsCompletelyBefore(r2, r1);
|
|
134
132
|
},
|
|
135
133
|
/**
|
|
136
134
|
* Calculates the component-wise sum of two ranges.
|
|
@@ -273,23 +271,24 @@ exports.SourceLocation = {
|
|
|
273
271
|
return exports.SourceRange.format(location);
|
|
274
272
|
}
|
|
275
273
|
},
|
|
274
|
+
/** Returns the {@link SourceRange|source range} part of a {@link SourceLocation|source location}, file excluded. */
|
|
275
|
+
getRange([sl, sc, el, ec]) {
|
|
276
|
+
return [sl, sc, el, ec];
|
|
277
|
+
},
|
|
276
278
|
/**
|
|
277
|
-
* Returns the
|
|
279
|
+
* Returns the file part of a {@link SourceLocation|source location}, or `undefined` if no file is set.
|
|
278
280
|
*/
|
|
279
|
-
getRange(location) {
|
|
280
|
-
return location;
|
|
281
|
-
},
|
|
282
281
|
getFile(location) {
|
|
283
282
|
return location[4];
|
|
284
283
|
},
|
|
285
284
|
/**
|
|
286
|
-
*
|
|
285
|
+
* Creates a {@link SourceLocation|source location} from a {@link SourceRange|source range} and a file name.
|
|
287
286
|
*/
|
|
288
287
|
from(range, file) {
|
|
289
288
|
return file !== undefined ? [...range, file] : range;
|
|
290
289
|
},
|
|
291
290
|
/**
|
|
292
|
-
*
|
|
291
|
+
* The {@link SourceLocation|source location} of an AST node, file included.
|
|
293
292
|
* @returns undefined if the given range is undefined
|
|
294
293
|
* @see {@link SourceRange.fromNode} for getting the range from an AST node
|
|
295
294
|
*/
|
package/util/version.js
CHANGED
|
@@ -42,7 +42,7 @@ const assert_1 = require("./assert");
|
|
|
42
42
|
const sigdb_download_1 = require("../project/sigdb/sigdb-download");
|
|
43
43
|
const doc_files_1 = require("../documentation/doc-util/doc-files");
|
|
44
44
|
// this is automatically replaced with the current version by release-it
|
|
45
|
-
const version = '2.13.
|
|
45
|
+
const version = '2.13.11';
|
|
46
46
|
// this is automatically replaced with the release date by release-it (regex-bumper, see package.json)
|
|
47
47
|
const versionDate = '2026-07-15T07:13:44Z';
|
|
48
48
|
/**
|