lispToMmix/main.js

28 lines
823 B
JavaScript
Raw Normal View History

2022-10-14 19:30:47 +02:00
import * as fs from "fs";
import { context } from "./js/ctx.js";
import { execute } from "./js/execute.js";
import { LISPcmd, LISPstring, createType } from "./js/lexer.js";
var path = process.argv[2];
var pathout = process.argv[3];
if (!path || !pathout) {
console.log("PLease this Schema: node ToAs.js [path] [pathout]");
process.exit();
}
var file = fs.readFileSync(path).toString();
var data = new LISPcmd("(\n" + file + "\n)", 0, 0);
let code = "";
var ctx = new context();
for (var i = 0; i < data.length; i++) {
let { code: c, type } = execute({ data: data[i], ctx });
if(c=="")continue;
code += c+"\n";
2022-10-14 19:30:47 +02:00
}
let result = ctx.build();
result+=code;
fs.writeFileSync(pathout, result);
console.log(`Finished compiling in ${Math.round(performance.now()) / 1000}sec. Assembly saved to: ${pathout}`);