-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
29 lines (26 loc) · 1.07 KB
/
index.js
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
const { lexList, init } = require("./init/init");
const { scanAll } = require("./lexer/scanner");
const { gData } = require("./lexer/token");
const { statement } = require("./parser/parse");
const { printTree, showIn, logIn, treeIn } = require("./parser/showtree");
const { addBuildInMethod } = require("./semantic/buildlnFn");
const { interpretAST } = require("./semantic/interpreter");
function main(){
addBuildInMethod("log",logIn);
addBuildInMethod("show",showIn);
addBuildInMethod("tree",treeIn);
console.log("start compiling");
console.log("------------- Get Source Code --------------------------");
init();
console.log("------------- Start Lexical analysis -------------------");
scanAll();
console.log(lexList);
lexList.reverse();
console.log("------------- Start Syntax analysis --------------------");
let astNodeTree = statement();
printTree(astNodeTree);
console.log("------------- Start Semantic analysis ------------------");
interpretAST(astNodeTree,null,gData.gScope);
console.log("compiled finished");
}
main();