slige/compiler/main.ts
2024-11-19 05:06:27 +01:00

25 lines
720 B
TypeScript

import { Lexer } from "./Lexer.ts";
import { Parser } from "./Parser.ts";
//const text = await Deno.readTextFile("example-no-types.slg");
const text = await Deno.readTextFile("example.slg");
const lexer = new Lexer(text);
console.log("type\tindex\tline:col");
let current = lexer.next();
while (current) {
console.log(
`${
current.identValue ?? current.type
}\t${current.pos.index}\t${current.pos.line}:${current.pos.col}`,
);
current = lexer.next();
}
const pos = lexer.currentPos();
console.log(`eof\t${pos.index}\t${pos.line}:${pos.col}`);
//const parser = new Parser(lexer);
//while (!parser.done()) {
// const result = parser.parseExpr();
// console.log(result);
//}