slige/compiler/main.ts
2024-12-10 14:36:41 +01:00

20 lines
582 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);
const program = lowerer.finish();
console.log(JSON.stringify(program, null, 4));