slige/compiler/main.ts
2024-12-10 23:30:15 +01:00

21 lines
606 B
TypeScript

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";
const text = await Deno.readTextFile("example.slg");
const lexer = new Lexer(text);
const parser = new Parser(lexer);
const ast = parser.parseStmts();
new Resolver().resolve(ast);
new Checker().check(ast);
// console.log(JSON.stringify(ast, null, 4))
const lowerer = new Lowerer();
lowerer.lower(ast);
lowerer.printProgram();
const program = lowerer.finish();
console.log(JSON.stringify(program, null, 4));