1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-05-31 13:41:32 +00:00
8bitworkshop/src/common/basic/main.ts
2020-08-08 11:00:05 -05:00

25 lines
565 B
TypeScript

import { BASICParser } from "./compiler";
var parser = new BASICParser();
var readline = require('readline');
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
terminal: false
});
rl.on('line', function (line) {
parser.tokenize(line);
console.log(parser.tokens);
try {
var ast = parser.parse();
console.log(JSON.stringify(ast, null, 4));
} catch (e) {
console.log(e);
}
if (parser.errors.length) {
console.log(parser.errors);
parser.errors = [];
}
})