1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-06-03 04:29:33 +00:00
8bitworkshop/src/common/ecs/main.ts
2022-02-24 13:31:09 -06:00

33 lines
992 B
TypeScript

import { readFileSync } from "fs";
import { ECSCompiler } from "./compiler";
import { Dialect_CA65, EntityManager, SourceFileExport } from "./ecs";
class ECSMain {
compiler = new ECSCompiler(new EntityManager(new Dialect_CA65()), true); // TODO
constructor(readonly args: string[]) {
}
run() {
for (let path of this.args) {
let text = readFileSync(path, 'utf-8');
try {
this.compiler.parseFile(text, path);
if (this.compiler.errors.length == 0) {
let file = new SourceFileExport();
this.compiler.exportToFile(file);
console.log(file.toString());
}
} catch (e) {
console.error(e);
}
for (let err of this.compiler.errors) {
console.error(`${err.path}:${err.line}:${err.start}: ${err.msg}`);
}
}
}
}
new ECSMain(process.argv.slice(2)).run();