/** * Lexer State * Tracks position in source text during tokenization */ import type { SourceLocation, TokenType } from '../types.js'; export interface LexerState { readonly source: string; pos: number; line: number; column: number; baseOffset: number; inFrontmatter: boolean; /** * Type of the token emitted immediately before the one being read, or * undefined at the start of input. Maintained by the `tokenize()` loop so * readers can branch on the preceding token exactly, rather than * re-deriving it from raw characters. */ prevTokenType: TokenType | undefined; /** * Value of that same token. Needed because DOLLAR is emitted for both the * `$` that prefixes a variable name and the self-contained accumulator * `$@`, which the type alone cannot tell apart. */ prevTokenValue: string | undefined; /** * True once the first non-whitespace character has been consumed. Used to * detect frontmatter delimiters at actual file start while tolerating * leading blank lines, without re-scanning consumed source on every `---` * match (see tokenizer.ts). */ sawNonWhitespace: boolean; } export declare function createLexerState(source: string, baseLocation?: SourceLocation): LexerState; export declare function currentLocation(state: LexerState): SourceLocation; export declare function peek(state: LexerState, offset?: number): string; export declare function peekString(state: LexerState, length: number): string; export declare function advance(state: LexerState): string; export declare function isAtEnd(state: LexerState): boolean;