slige/src/main.ts

14 lines
365 B
TypeScript
Raw Normal View History

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