-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug.ts
More file actions
62 lines (53 loc) · 1.23 KB
/
debug.ts
File metadata and controls
62 lines (53 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import { OneScript } from './src/OneScript.ts';
import { Node } from 'web-tree-sitter'
function walk(node: Node, depth = 0) {
const indent = ' '.repeat(depth);
console.log(`${indent}${node.type}: "${node.text}"`);
for (const child of node.children) {
if (child) {
walk(child, depth + 1);
}
}
}
(async () => {
const OS = new OneScript('./wasm/tree-sitter-onescript.wasm');
const source =
// `
// а = 1;
// Если а = 2 Тогда
// б = 2;
// КонецЕсли;
// `
`
а = 1;
б = 0;
Для н = 1 по 10 Цикл
а = а + н;
Прервать;
б = 1;
КонецЦикла;
`
;
// const tree = await OS.GetTree(source);
// if (tree) walk(tree.rootNode);
// console.log(tree?.rootNode.toString());
await OS.Run(source);
const variables = OS.dumpVariables();
console.log(variables);
})();
// (async () => {
// const OS = new OneScript('./wasm/tree-sitter-onescript.wasm');
// const source =
// `
// а = 1;
// Если 1 = 1 Тогда
// в = 1
// КонецЕсли;;
// `;
// const source2 =
// `
// а=1 + 1;
// `;
// await OS.Run(source);
// const variables = OS.dumpVariables();
// })();