2024-12-10 20:42:15 +00:00
|
|
|
import { Checker } from "./checker.ts";
|
|
|
|
import { Lexer } from "./lexer.ts";
|
|
|
|
import { Lowerer } from "./lowerer.ts";
|
|
|
|
import { Parser } from "./parser.ts";
|
|
|
|
import { Resolver } from "./resolver.ts";
|
2024-11-04 13:54:55 +00:00
|
|
|
|
2024-12-09 12:57:48 +00:00
|
|
|
const text = await Deno.readTextFile("example.slg");
|
2024-11-04 13:54:55 +00:00
|
|
|
|
|
|
|
const lexer = new Lexer(text);
|
2024-11-20 14:41:20 +00:00
|
|
|
|
2024-12-10 09:39:12 +00:00
|
|
|
const parser = new Parser(lexer);
|
|
|
|
const ast = parser.parseStmts();
|
|
|
|
new Resolver().resolve(ast);
|
|
|
|
new Checker().check(ast);
|
2024-12-09 12:57:48 +00:00
|
|
|
// console.log(JSON.stringify(ast, null, 4))
|
2024-12-10 13:36:41 +00:00
|
|
|
const lowerer = new Lowerer();
|
|
|
|
lowerer.lower(ast);
|
2024-12-10 22:30:15 +00:00
|
|
|
lowerer.printProgram();
|
2024-12-10 13:36:41 +00:00
|
|
|
const program = lowerer.finish();
|
2024-12-10 23:03:19 +00:00
|
|
|
//console.log(JSON.stringify(program, null, 4));
|
|
|
|
console.log(JSON.stringify(program));
|