slige/src/main.ts

17 lines
359 B
TypeScript
Raw Normal View History

2024-11-04 14:54:55 +01:00
import { Lexer } from "./Lexer.ts";
const text = `
a1 123 +
// comment
"hello"
"escaped\\"\\nnewline"
`;
const lexer = new Lexer(text);
let token = lexer.next();
while (token !== null) {
const value = token.identValue ?? token.intValue ?? token.stringValue ?? "";
console.log(`Lexed ${token}(${value})`);
token = lexer.next();
}