slige/src/main.ts

14 lines
365 B
TypeScript
Raw Normal View History

2024-11-04 13:54:55 +00:00
import { Lexer } from "./Lexer.ts";
2024-11-15 14:20:49 +00:00
import { readFileSync } from 'node:fs';
2024-11-04 13:54:55 +00:00
2024-11-15 14:20:49 +00:00
const text = readFileSync("example.slg").toString()
2024-11-04 13:54:55 +00:00
const lexer = new Lexer(text);
let token = lexer.next();
while (token !== null) {
const value = token.identValue ?? token.intValue ?? token.stringValue ?? "";
2024-11-15 14:20:49 +00:00
console.log(`${token.type}\t${value}`)
2024-11-04 13:54:55 +00:00
token = lexer.next();
}