import { Ast, File } from "./ast.ts"; import { Checker } from "./checker.ts"; import { Reporter } from "./info.ts"; import { Lexer } from "./lexer.ts"; import { Lowerer } from "./lowerer.ts"; import { Parser } from "./parser.ts"; import { Resolver } from "./resolver.ts"; class Compilation { private files: File[] = []; public constructor(private startFile: string) {} public compile(): Ast { throw new Error(); } } //const text = await Deno.readTextFile("example.slg"); const text = await Deno.readTextFile(Deno.args[0]); const reporter = new Reporter(); const lexer = new Lexer(text, reporter); const parser = new Parser(lexer, reporter); const ast = parser.parse(); // console.log(JSON.stringify(ast, null, 4)); new Resolver(reporter).resolve(ast); new Checker(reporter).check(ast); if (reporter.errorOccured()) { console.error("Errors occurred, stopping compilation."); Deno.exit(1); } const lowerer = new Lowerer(); lowerer.lower(ast); lowerer.printProgram(); const program = lowerer.finish(); //console.log(JSON.stringify(program, null, 4)); // console.log(JSON.stringify(program)); await Deno.writeTextFile("out.slgbc", JSON.stringify(program));