slige-mirror/compiler/parser/token.ts
2025-01-27 23:57:27 +01:00

30 lines
631 B
TypeScript

import { Span } from "../diagnostics.ts";
export type Token = {
type: string;
span: Span;
length: number;
identValue?: string;
intValue?: number;
stringValue?: string;
};
export interface TokenIter {
next(): Token | null;
}
export class SigFilter implements TokenIter {
public constructor(private iter: TokenIter) {}
next(): Token | null {
const token = this.iter.next();
if (token === null) {
return token;
}
if (token?.type === "whitespace" || token?.type === "comment") {
return this.next();
}
return token;
}
}