@rsconcept/domain 1.0.0 → 1.2.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/README.md +3 -3
- package/dist/analyzer-DlSq3Y3r.d.ts +39 -0
- package/dist/arguments-extractor-1acwjQNc.d.ts +38 -0
- package/dist/ast-C8sIpKdL.d.ts +51 -0
- package/dist/ast-annotations-BiMjkKvz.d.ts +16 -0
- package/dist/branded-ZlzIcxzu.d.ts +9 -0
- package/dist/calculator-C9W2jkSx.d.ts +39 -0
- package/dist/cctext/index.d.ts +2 -1
- package/dist/cctext/index.js +2 -42
- package/dist/cctext/language-api.d.ts +10 -12
- package/dist/cctext/language-api.js +157 -227
- package/dist/cctext/language-api.js.map +1 -1
- package/dist/cctext/language.d.ts +24 -22
- package/dist/cctext/language.js +43 -39
- package/dist/cctext/language.js.map +1 -1
- package/dist/error-E1LVq_3w.d.ts +87 -0
- package/dist/graph/graph.d.ts +2 -62
- package/dist/graph/graph.js +339 -382
- package/dist/graph/graph.js.map +1 -1
- package/dist/graph/index.d.ts +2 -1
- package/dist/graph/index.js +2 -384
- package/dist/graph-DR8rL2o3.d.ts +64 -0
- package/dist/hash-Y8I4c6Al.d.ts +8 -0
- package/dist/index-BKZ67WMa.d.ts +1 -0
- package/dist/index-BVVgDSdq.d.ts +1 -0
- package/dist/index-DmtQKWjk.d.ts +1 -0
- package/dist/index-_6s0AX1B.d.ts +1 -0
- package/dist/index.d.ts +27 -28
- package/dist/index.js +23 -5851
- package/dist/lezer-tree-iS7LpLBJ.d.ts +14 -0
- package/dist/library/folder-tree.d.ts +22 -20
- package/dist/library/folder-tree.js +108 -130
- package/dist/library/folder-tree.js.map +1 -1
- package/dist/library/index.d.ts +8 -17
- package/dist/library/index.js +7 -2800
- package/dist/library/library-api.d.ts +3 -1
- package/dist/library/library-api.js +9 -8
- package/dist/library/library-api.js.map +1 -1
- package/dist/library/library.d.ts +2 -56
- package/dist/library/library.js +23 -19
- package/dist/library/library.js.map +1 -1
- package/dist/library/oss-api.d.ts +26 -37
- package/dist/library/oss-api.js +258 -1096
- package/dist/library/oss-api.js.map +1 -1
- package/dist/library/oss-layout-api.d.ts +28 -28
- package/dist/library/oss-layout-api.js +239 -316
- package/dist/library/oss-layout-api.js.map +1 -1
- package/dist/library/oss-layout.d.ts +2 -25
- package/dist/library/oss-layout.js +1 -1
- package/dist/library/oss.d.ts +87 -89
- package/dist/library/oss.js +27 -26
- package/dist/library/oss.js.map +1 -1
- package/dist/library/rsengine.d.ts +100 -106
- package/dist/library/rsengine.js +439 -2599
- package/dist/library/rsengine.js.map +1 -1
- package/dist/library/rsform-api.d.ts +11 -16
- package/dist/library/rsform-api.js +313 -825
- package/dist/library/rsform-api.js.map +1 -1
- package/dist/library/rsform.d.ts +159 -167
- package/dist/library/rsform.js +29 -28
- package/dist/library/rsform.js.map +1 -1
- package/dist/library/rsmodel-api.d.ts +8 -15
- package/dist/library/rsmodel-api.js +172 -813
- package/dist/library/rsmodel-api.js.map +1 -1
- package/dist/library/rsmodel.d.ts +27 -33
- package/dist/library/rsmodel.js +16 -23
- package/dist/library/rsmodel.js.map +1 -1
- package/dist/library/structure-planner.d.ts +20 -26
- package/dist/library/structure-planner.js +106 -474
- package/dist/library/structure-planner.js.map +1 -1
- package/dist/library-CYun28Xz.d.ts +58 -0
- package/dist/oss-layout-3glgAqfn.d.ts +27 -0
- package/dist/parser-Bwd8LxJ1.d.ts +7 -0
- package/dist/parsing/ast.d.ts +2 -49
- package/dist/parsing/ast.js +68 -76
- package/dist/parsing/ast.js.map +1 -1
- package/dist/parsing/index.d.ts +3 -3
- package/dist/parsing/index.js +3 -141
- package/dist/parsing/lezer-tree.d.ts +2 -13
- package/dist/parsing/lezer-tree.js +50 -43
- package/dist/parsing/lezer-tree.js.map +1 -1
- package/dist/rslang/api.d.ts +9 -14
- package/dist/rslang/api.js +114 -827
- package/dist/rslang/api.js.map +1 -1
- package/dist/rslang/ast-annotations.d.ts +2 -18
- package/dist/rslang/ast-annotations.js +34 -45
- package/dist/rslang/ast-annotations.js.map +1 -1
- package/dist/rslang/error.d.ts +2 -85
- package/dist/rslang/error.js +88 -150
- package/dist/rslang/error.js.map +1 -1
- package/dist/rslang/eval/calculator.d.ts +2 -43
- package/dist/rslang/eval/calculator.js +81 -1636
- package/dist/rslang/eval/calculator.js.map +1 -1
- package/dist/rslang/eval/evaluation-cache.d.ts +22 -26
- package/dist/rslang/eval/evaluation-cache.js +168 -287
- package/dist/rslang/eval/evaluation-cache.js.map +1 -1
- package/dist/rslang/eval/evaluator.d.ts +59 -63
- package/dist/rslang/eval/evaluator.js +602 -1509
- package/dist/rslang/eval/evaluator.js.map +1 -1
- package/dist/rslang/eval/value-api.d.ts +2 -48
- package/dist/rslang/eval/value-api.js +2 -490
- package/dist/rslang/eval/value.d.ts +2 -36
- package/dist/rslang/eval/value.js +2 -118
- package/dist/rslang/index.d.ts +14 -17
- package/dist/rslang/index.js +12 -4314
- package/dist/rslang/labels.d.ts +6 -6
- package/dist/rslang/labels.js +139 -305
- package/dist/rslang/labels.js.map +1 -1
- package/dist/rslang/parser/expression-generator.d.ts +5 -5
- package/dist/rslang/parser/expression-generator.js +248 -446
- package/dist/rslang/parser/expression-generator.js.map +1 -1
- package/dist/rslang/parser/normalize.d.ts +4 -8
- package/dist/rslang/parser/normalize.js +286 -481
- package/dist/rslang/parser/normalize.js.map +1 -1
- package/dist/rslang/parser/parser.d.ts +2 -5
- package/dist/rslang/parser/parser.js +30 -21
- package/dist/rslang/parser/parser.js.map +1 -1
- package/dist/rslang/parser/parser.terms.d.ts +43 -41
- package/dist/rslang/parser/parser.terms.js +44 -83
- package/dist/rslang/parser/parser.terms.js.map +1 -1
- package/dist/rslang/parser/syntax-errors.d.ts +5 -8
- package/dist/rslang/parser/syntax-errors.js +113 -382
- package/dist/rslang/parser/syntax-errors.js.map +1 -1
- package/dist/rslang/parser/token.d.ts +2 -79
- package/dist/rslang/parser/token.js +81 -93
- package/dist/rslang/parser/token.js.map +1 -1
- package/dist/rslang/semantic/analyzer.d.ts +2 -39
- package/dist/rslang/semantic/analyzer.js +186 -2600
- package/dist/rslang/semantic/analyzer.js.map +1 -1
- package/dist/rslang/semantic/arguments-extractor.d.ts +2 -42
- package/dist/rslang/semantic/arguments-extractor.js +202 -361
- package/dist/rslang/semantic/arguments-extractor.js.map +1 -1
- package/dist/rslang/semantic/type-auditor.d.ts +64 -68
- package/dist/rslang/semantic/type-auditor.js +594 -1564
- package/dist/rslang/semantic/type-auditor.js.map +1 -1
- package/dist/rslang/semantic/typification-api.d.ts +4 -7
- package/dist/rslang/semantic/typification-api.js +162 -303
- package/dist/rslang/semantic/typification-api.js.map +1 -1
- package/dist/rslang/semantic/typification-parser.d.ts +2 -12
- package/dist/rslang/semantic/typification-parser.js +165 -219
- package/dist/rslang/semantic/typification-parser.js.map +1 -1
- package/dist/rslang/semantic/typification.d.ts +2 -119
- package/dist/rslang/semantic/typification.js +66 -52
- package/dist/rslang/semantic/typification.js.map +1 -1
- package/dist/rslang/semantic/value-auditor.d.ts +32 -38
- package/dist/rslang/semantic/value-auditor.js +206 -518
- package/dist/rslang/semantic/value-auditor.js.map +1 -1
- package/dist/rslang/semantic/value-class.d.ts +2 -10
- package/dist/rslang/semantic/value-class.js +8 -7
- package/dist/rslang/semantic/value-class.js.map +1 -1
- package/dist/rslang/typification-graph.d.ts +2 -33
- package/dist/rslang/typification-graph.js +94 -306
- package/dist/rslang/typification-graph.js.map +1 -1
- package/dist/shared/branded.d.ts +2 -7
- package/dist/shared/branded.js +1 -1
- package/dist/shared/hash.d.ts +2 -6
- package/dist/shared/hash.js +13 -13
- package/dist/shared/hash.js.map +1 -1
- package/dist/shared/index.d.ts +3 -2
- package/dist/shared/index.js +2 -18
- package/dist/token-DeXAmzwr.d.ts +81 -0
- package/dist/typification-Dk-fisgO.d.ts +120 -0
- package/dist/typification-graph-6HcZ-rKH.d.ts +30 -0
- package/dist/typification-parser-BBVx1RxP.d.ts +13 -0
- package/dist/value-B8UtCqaK.js +366 -0
- package/dist/value-B8UtCqaK.js.map +1 -0
- package/dist/value-CTjX6825.d.ts +33 -0
- package/dist/value-api-Bw-SgaYY.d.ts +49 -0
- package/dist/value-class-CNI-lqXJ.d.ts +12 -0
- package/package.json +8 -8
- package/src/library/oss-api.test.ts +76 -0
- package/src/library/oss-api.ts +4 -1
- package/src/library/rsform-api.test.ts +24 -0
- package/src/library/rsform-api.ts +12 -4
- package/dist/cctext/index.js.map +0 -1
- package/dist/graph/index.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/library/index.js.map +0 -1
- package/dist/library/oss-layout.js.map +0 -1
- package/dist/parsing/index.js.map +0 -1
- package/dist/rslang/eval/value-api.js.map +0 -1
- package/dist/rslang/eval/value.js.map +0 -1
- package/dist/rslang/index.js.map +0 -1
- package/dist/shared/branded.js.map +0 -1
- package/dist/shared/index.js.map +0 -1
package/dist/parsing/index.js
CHANGED
|
@@ -1,141 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
let nextUid = 1;
|
|
5
|
-
function genUid() {
|
|
6
|
-
return nextUid++;
|
|
7
|
-
}
|
|
8
|
-
return buildTreeInternal(cursor, null, genUid);
|
|
9
|
-
}
|
|
10
|
-
function flattenAst(node, parent = null, out = []) {
|
|
11
|
-
out.push({
|
|
12
|
-
uid: node.uid,
|
|
13
|
-
parent,
|
|
14
|
-
typeID: node.typeID,
|
|
15
|
-
from: node.from,
|
|
16
|
-
to: node.to,
|
|
17
|
-
data: node.data,
|
|
18
|
-
annotation: node.annotation
|
|
19
|
-
});
|
|
20
|
-
for (const child of node.children) {
|
|
21
|
-
flattenAst(child, node.uid, out);
|
|
22
|
-
}
|
|
23
|
-
return out;
|
|
24
|
-
}
|
|
25
|
-
function visitAstDFS(node, callback) {
|
|
26
|
-
for (const child of node.children) {
|
|
27
|
-
visitAstDFS(child, callback);
|
|
28
|
-
}
|
|
29
|
-
callback(node);
|
|
30
|
-
}
|
|
31
|
-
function findByUid(root, uid) {
|
|
32
|
-
let found = null;
|
|
33
|
-
visitAstDFS(root, (node) => {
|
|
34
|
-
if (node.uid === uid && !found) {
|
|
35
|
-
found = node;
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
return found;
|
|
39
|
-
}
|
|
40
|
-
function printAst(node, printNode) {
|
|
41
|
-
let children = "";
|
|
42
|
-
for (const child of node.children) {
|
|
43
|
-
children += `${printAst(child, printNode)}`;
|
|
44
|
-
}
|
|
45
|
-
return `[${printNode(node)}${children}]`;
|
|
46
|
-
}
|
|
47
|
-
function getNodeText(node) {
|
|
48
|
-
if (node.data.dataType === "string" && typeof node.data.value === "string") {
|
|
49
|
-
return node.data.value;
|
|
50
|
-
}
|
|
51
|
-
return `NO DATA NODE: ${node.typeID}`;
|
|
52
|
-
}
|
|
53
|
-
function getNodeIndices(node) {
|
|
54
|
-
if (node.data.dataType === "string[]" && Array.isArray(node.data.value)) {
|
|
55
|
-
return node.data.value.map((s) => parseInt(s, 10)).filter((n) => !isNaN(n));
|
|
56
|
-
}
|
|
57
|
-
return [];
|
|
58
|
-
}
|
|
59
|
-
function buildTreeInternal(cursor, parent = null, genUid) {
|
|
60
|
-
const node = cursor.node;
|
|
61
|
-
const result = {
|
|
62
|
-
uid: genUid(),
|
|
63
|
-
typeID: node.type.isError ? 0 : node.type.id,
|
|
64
|
-
from: node.from,
|
|
65
|
-
to: node.to,
|
|
66
|
-
hasError: node.type.isError,
|
|
67
|
-
data: node.type.isError ? { dataType: "null", value: null } : { dataType: "string", value: node.type.name },
|
|
68
|
-
parent,
|
|
69
|
-
children: []
|
|
70
|
-
};
|
|
71
|
-
if (cursor.firstChild()) {
|
|
72
|
-
do {
|
|
73
|
-
const child = buildTreeInternal(cursor, result, genUid);
|
|
74
|
-
if (child.hasError) {
|
|
75
|
-
result.hasError = true;
|
|
76
|
-
}
|
|
77
|
-
result.children.push(child);
|
|
78
|
-
} while (cursor.nextSibling());
|
|
79
|
-
cursor.parent();
|
|
80
|
-
}
|
|
81
|
-
return result;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// src/parsing/lezer-tree.ts
|
|
85
|
-
function printTree(tree) {
|
|
86
|
-
const state = {
|
|
87
|
-
output: "",
|
|
88
|
-
prefixes: []
|
|
89
|
-
};
|
|
90
|
-
traverseTree(tree, {
|
|
91
|
-
onEnter: (node) => {
|
|
92
|
-
state.output += "[";
|
|
93
|
-
state.output += node.type.name;
|
|
94
|
-
},
|
|
95
|
-
onLeave: () => {
|
|
96
|
-
state.output += "]";
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
return state.output;
|
|
100
|
-
}
|
|
101
|
-
function cursorNode({ type, from, to }, isLeaf = false) {
|
|
102
|
-
return { type, from, to, isLeaf };
|
|
103
|
-
}
|
|
104
|
-
function traverseTree(tree, { beforeEnter, onEnter, onLeave }) {
|
|
105
|
-
const cursor = tree.cursor();
|
|
106
|
-
for (; ; ) {
|
|
107
|
-
let node = cursorNode(cursor);
|
|
108
|
-
let leave = false;
|
|
109
|
-
const enter = !node.type.isAnonymous;
|
|
110
|
-
if (enter && beforeEnter) beforeEnter(cursor);
|
|
111
|
-
node.isLeaf = !cursor.firstChild();
|
|
112
|
-
if (enter) {
|
|
113
|
-
leave = true;
|
|
114
|
-
if (onEnter(node) === false) return;
|
|
115
|
-
}
|
|
116
|
-
if (!node.isLeaf) continue;
|
|
117
|
-
for (; ; ) {
|
|
118
|
-
node = cursorNode(cursor, node.isLeaf);
|
|
119
|
-
if (leave && onLeave) {
|
|
120
|
-
if (onLeave(node) === false) return;
|
|
121
|
-
}
|
|
122
|
-
leave = cursor.type.isAnonymous;
|
|
123
|
-
node.isLeaf = false;
|
|
124
|
-
if (cursor.nextSibling()) break;
|
|
125
|
-
if (!cursor.parent()) return;
|
|
126
|
-
leave = true;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
export {
|
|
131
|
-
TOKEN_ERROR,
|
|
132
|
-
buildTree,
|
|
133
|
-
findByUid,
|
|
134
|
-
flattenAst,
|
|
135
|
-
getNodeIndices,
|
|
136
|
-
getNodeText,
|
|
137
|
-
printAst,
|
|
138
|
-
printTree,
|
|
139
|
-
visitAstDFS
|
|
140
|
-
};
|
|
141
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import { TOKEN_ERROR, buildTree, findByUid, flattenAst, getNodeIndices, getNodeText, printAst, visitAstDFS } from "./ast.js";
|
|
2
|
+
import { printTree } from "./lezer-tree.js";
|
|
3
|
+
export { TOKEN_ERROR, buildTree, findByUid, flattenAst, getNodeIndices, getNodeText, printAst, printTree, visitAstDFS };
|
|
@@ -1,13 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { TreeCursor }
|
|
3
|
-
|
|
4
|
-
/** Represents syntax tree node data. */
|
|
5
|
-
interface CMSyntaxNode {
|
|
6
|
-
type: NodeType;
|
|
7
|
-
from: number;
|
|
8
|
-
to: number;
|
|
9
|
-
}
|
|
10
|
-
/** Prints tree to compact string. */
|
|
11
|
-
declare function printTree(tree: Tree): string;
|
|
12
|
-
|
|
13
|
-
export { type CMSyntaxNode, printTree };
|
|
1
|
+
import { n as TreeCursor, r as printTree, t as CMSyntaxNode } from "../lezer-tree-iS7LpLBJ.js";
|
|
2
|
+
export { CMSyntaxNode, type TreeCursor, printTree };
|
|
@@ -1,50 +1,57 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/parsing/lezer-tree.ts
|
|
2
|
+
/** Prints tree to compact string. */
|
|
2
3
|
function printTree(tree) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
4
|
+
const state = {
|
|
5
|
+
output: "",
|
|
6
|
+
prefixes: []
|
|
7
|
+
};
|
|
8
|
+
traverseTree(tree, {
|
|
9
|
+
onEnter: (node) => {
|
|
10
|
+
state.output += "[";
|
|
11
|
+
state.output += node.type.name;
|
|
12
|
+
},
|
|
13
|
+
onLeave: () => {
|
|
14
|
+
state.output += "]";
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return state.output;
|
|
17
18
|
}
|
|
18
19
|
function cursorNode({ type, from, to }, isLeaf = false) {
|
|
19
|
-
|
|
20
|
+
return {
|
|
21
|
+
type,
|
|
22
|
+
from,
|
|
23
|
+
to,
|
|
24
|
+
isLeaf
|
|
25
|
+
};
|
|
20
26
|
}
|
|
27
|
+
/** Implements depth-first traversal. */
|
|
21
28
|
function traverseTree(tree, { beforeEnter, onEnter, onLeave }) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
29
|
+
const cursor = tree.cursor();
|
|
30
|
+
for (;;) {
|
|
31
|
+
let node = cursorNode(cursor);
|
|
32
|
+
let leave = false;
|
|
33
|
+
const enter = !node.type.isAnonymous;
|
|
34
|
+
if (enter && beforeEnter) beforeEnter(cursor);
|
|
35
|
+
node.isLeaf = !cursor.firstChild();
|
|
36
|
+
if (enter) {
|
|
37
|
+
leave = true;
|
|
38
|
+
if (onEnter(node) === false) return;
|
|
39
|
+
}
|
|
40
|
+
if (!node.isLeaf) continue;
|
|
41
|
+
for (;;) {
|
|
42
|
+
node = cursorNode(cursor, node.isLeaf);
|
|
43
|
+
if (leave && onLeave) {
|
|
44
|
+
if (onLeave(node) === false) return;
|
|
45
|
+
}
|
|
46
|
+
leave = cursor.type.isAnonymous;
|
|
47
|
+
node.isLeaf = false;
|
|
48
|
+
if (cursor.nextSibling()) break;
|
|
49
|
+
if (!cursor.parent()) return;
|
|
50
|
+
leave = true;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
46
53
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
54
|
+
//#endregion
|
|
55
|
+
export { printTree };
|
|
56
|
+
|
|
50
57
|
//# sourceMappingURL=lezer-tree.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/parsing/lezer-tree.ts"],"sourcesContent":["import { type NodeType, type Tree, type TreeCursor } from '@lezer/common';\nexport { type TreeCursor } from '@lezer/common';\n\n/** Represents syntax tree node data. */\nexport interface CMSyntaxNode {\n type: NodeType;\n from: number;\n to: number;\n}\n\n/** Prints tree to compact string. */\nexport function printTree(tree: Tree): string {\n const state = {\n output: '',\n prefixes: [] as string[]\n };\n traverseTree(tree, {\n onEnter: node => {\n state.output += '[';\n state.output += node.type.name;\n },\n onLeave: () => {\n state.output += ']';\n }\n });\n return state.output;\n}\n\n// ======== Internals ========\n\ninterface CursorNode extends CMSyntaxNode {\n isLeaf: boolean;\n}\n\nfunction cursorNode({ type, from, to }: TreeCursor, isLeaf = false): CursorNode {\n return { type, from, to, isLeaf };\n}\n\ninterface TreeTraversalOptions {\n beforeEnter?: (cursor: TreeCursor) => void;\n onEnter: (node: CursorNode) => false | void;\n onLeave?: (node: CursorNode) => false | void;\n}\n\n/** Implements depth-first traversal. */\nfunction traverseTree(tree: Tree, { beforeEnter, onEnter, onLeave }: TreeTraversalOptions) {\n const cursor = tree.cursor();\n for (;;) {\n let node = cursorNode(cursor);\n let leave = false;\n const enter = !node.type.isAnonymous;\n if (enter && beforeEnter) beforeEnter(cursor);\n node.isLeaf = !cursor.firstChild();\n if (enter) {\n leave = true;\n if (onEnter(node) === false) return;\n }\n if (!node.isLeaf) continue;\n for (;;) {\n node = cursorNode(cursor, node.isLeaf);\n if (leave && onLeave) if (onLeave(node) === false) return;\n leave = cursor.type.isAnonymous;\n node.isLeaf = false;\n if (cursor.nextSibling()) break;\n if (!cursor.parent()) return;\n leave = true;\n }\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"lezer-tree.js","names":[],"sources":["../../src/parsing/lezer-tree.ts"],"sourcesContent":["import { type NodeType, type Tree, type TreeCursor } from '@lezer/common';\nexport { type TreeCursor } from '@lezer/common';\n\n/** Represents syntax tree node data. */\nexport interface CMSyntaxNode {\n type: NodeType;\n from: number;\n to: number;\n}\n\n/** Prints tree to compact string. */\nexport function printTree(tree: Tree): string {\n const state = {\n output: '',\n prefixes: [] as string[]\n };\n traverseTree(tree, {\n onEnter: node => {\n state.output += '[';\n state.output += node.type.name;\n },\n onLeave: () => {\n state.output += ']';\n }\n });\n return state.output;\n}\n\n// ======== Internals ========\n\ninterface CursorNode extends CMSyntaxNode {\n isLeaf: boolean;\n}\n\nfunction cursorNode({ type, from, to }: TreeCursor, isLeaf = false): CursorNode {\n return { type, from, to, isLeaf };\n}\n\ninterface TreeTraversalOptions {\n beforeEnter?: (cursor: TreeCursor) => void;\n onEnter: (node: CursorNode) => false | void;\n onLeave?: (node: CursorNode) => false | void;\n}\n\n/** Implements depth-first traversal. */\nfunction traverseTree(tree: Tree, { beforeEnter, onEnter, onLeave }: TreeTraversalOptions) {\n const cursor = tree.cursor();\n for (;;) {\n let node = cursorNode(cursor);\n let leave = false;\n const enter = !node.type.isAnonymous;\n if (enter && beforeEnter) beforeEnter(cursor);\n node.isLeaf = !cursor.firstChild();\n if (enter) {\n leave = true;\n if (onEnter(node) === false) return;\n }\n if (!node.isLeaf) continue;\n for (;;) {\n node = cursorNode(cursor, node.isLeaf);\n if (leave && onLeave) if (onLeave(node) === false) return;\n leave = cursor.type.isAnonymous;\n node.isLeaf = false;\n if (cursor.nextSibling()) break;\n if (!cursor.parent()) return;\n leave = true;\n }\n }\n}\n"],"mappings":";;AAWA,SAAgB,UAAU,MAAoB;CAC5C,MAAM,QAAQ;EACZ,QAAQ;EACR,UAAU,CAAC;CACb;CACA,aAAa,MAAM;EACjB,UAAS,SAAQ;GACf,MAAM,UAAU;GAChB,MAAM,UAAU,KAAK,KAAK;EAC5B;EACA,eAAe;GACb,MAAM,UAAU;EAClB;CACF,CAAC;CACD,OAAO,MAAM;AACf;AAQA,SAAS,WAAW,EAAE,MAAM,MAAM,MAAkB,SAAS,OAAmB;CAC9E,OAAO;EAAE;EAAM;EAAM;EAAI;CAAO;AAClC;;AASA,SAAS,aAAa,MAAY,EAAE,aAAa,SAAS,WAAiC;CACzF,MAAM,SAAS,KAAK,OAAO;CAC3B,SAAS;EACP,IAAI,OAAO,WAAW,MAAM;EAC5B,IAAI,QAAQ;EACZ,MAAM,QAAQ,CAAC,KAAK,KAAK;EACzB,IAAI,SAAS,aAAa,YAAY,MAAM;EAC5C,KAAK,SAAS,CAAC,OAAO,WAAW;EACjC,IAAI,OAAO;GACT,QAAQ;GACR,IAAI,QAAQ,IAAI,MAAM,OAAO;EAC/B;EACA,IAAI,CAAC,KAAK,QAAQ;EAClB,SAAS;GACP,OAAO,WAAW,QAAQ,KAAK,MAAM;GACrC,IAAI,SAAS;QAAa,QAAQ,IAAI,MAAM,OAAO;GAAA;GACnD,QAAQ,OAAO,KAAK;GACpB,KAAK,SAAS;GACd,IAAI,OAAO,YAAY,GAAG;GAC1B,IAAI,CAAC,OAAO,OAAO,GAAG;GACtB,QAAQ;EACV;CACF;AACF"}
|
package/dist/rslang/api.d.ts
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
import { AstNode } from
|
|
2
|
-
import { ArgumentsType } from
|
|
3
|
-
|
|
4
|
-
import '@lezer/common';
|
|
5
|
-
import './semantic/typification.js';
|
|
6
|
-
import '../shared/branded.js';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Module: API for RSLanguage.
|
|
10
|
-
*/
|
|
1
|
+
import { t as AstNode } from "../ast-C8sIpKdL.js";
|
|
2
|
+
import { n as ArgumentsType } from "../arguments-extractor-1acwjQNc.js";
|
|
3
|
+
import { generateExpressionFromAst } from "./parser/expression-generator.js";
|
|
11
4
|
|
|
5
|
+
//#region src/rslang/api.d.ts
|
|
12
6
|
/** Represents alias mapping. */
|
|
13
7
|
type AliasMapping = Record<string, string>;
|
|
14
8
|
/** Extract arguments from AST. */
|
|
@@ -34,8 +28,8 @@ declare function isSetTypification(text: string): boolean;
|
|
|
34
28
|
* // result: `{ head: 'header', body: 'body content' }`
|
|
35
29
|
*/
|
|
36
30
|
declare function splitTemplateDefinition(target: string): {
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
head: string;
|
|
32
|
+
body: string;
|
|
39
33
|
};
|
|
40
34
|
/**
|
|
41
35
|
* Substitutes values for template arguments in a given expression.
|
|
@@ -49,5 +43,6 @@ declare function substituteTemplateArgs(expression: string, mapping: AliasMappin
|
|
|
49
43
|
declare function applyAliasMapping(target: string, mapping: AliasMapping): string;
|
|
50
44
|
/** Apply alias typification mapping. */
|
|
51
45
|
declare function applyTypificationMapping(target: string, mapping: AliasMapping): string;
|
|
52
|
-
|
|
53
|
-
export {
|
|
46
|
+
//#endregion
|
|
47
|
+
export { AliasMapping, applyAliasMapping, applyTypificationMapping, extractArguments, extractGlobals, generateExpressionFromAst, isSetTypification, isSimpleExpression, splitTemplateDefinition, substituteTemplateArgs };
|
|
48
|
+
//# sourceMappingURL=api.d.ts.map
|