mirror of
https://git.sfja.dk/Mikkel/slige.git
synced 2025-01-18 23:46:31 +00:00
17 lines
359 B
TypeScript
17 lines
359 B
TypeScript
|
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();
|
||
|
}
|