import type { BiPredicate } from "@rickosborne/typical"; declare abstract class AStringTokenizer { protected _at: number; protected _text: string | undefined; protected readonly ahead: string[]; protected iteratorDone: boolean; protected constructor(text?: string | undefined, at?: number); protected assertPositiveInt(value: number): void; /** * Get the location of the next character available to be consumed. */ get at(): number; /** * Whether all the text has already been tokenized. */ get done(): boolean; protected forward(length: number): void; /** * Get the number of characters available in the lookahead buffer. */ get lookahead(): number; /** * Get the text being tokenized. */ get text(): string | undefined; } /** * Primitive string tokenizer upon which parsers could be built. */ export declare class StringTokenizer extends AStringTokenizer { static forIterator(iterator: StringIterator): StringTokenizer; static forText(text: string, at?: number): StringTokenizer; private readonly iterator; protected constructor(iterator: Iterator, text?: string | undefined, at?: number); /** * Consume up to the given number of characters. May return * fewer characters if the end of the text is encountered. * @throws {@link RangeError} * For invalid length. */ consumeCount(length: number): string; /** * Consume text which is expected to match the given string. * If it does match, return it. Otherwise, throw an error and * nothing is consumed. * Use {@link tryConsume} if you want to return `undefined` * instead of throwing an error. * @throws {@link ValidationError} * If the exact text cannot be consumed. */ consumeExact(exact: string): string; /** * Helper for "skip past anything which would be considered whitespace". */ consumeSpace(): string; /** * Repeatedly peek ahead for as long as the given predicate returns * `true`, returning the matched text once it returns `false` or * the end of the text is encountered. * Note that the number in the predicate is the relative offset, * the `ahead` value, not the `at` value. It always starts at zero. */ consumeWhile(predicate: BiPredicate): string; /** * Get the next character available via the string iterator. * Returns `undefined` if the iterator is done. * Does not modify `at`. */ protected next(): string | undefined; /** * Get a character without moving `at`. If a number is provided, * look that many characters ahead. * @param forward - Number of characters ahead to peek. Must be at least 0. * @throws {@link RangeError} * For invalid `forward` values. */ peek(forward?: number): string | undefined; /** * Try to consume the given text. If found, it is consumed and * returned. If not found, nothing is consumed and `undefined` * is returned. Use {@link consumeExact} if you want to throw * an error instead of returning `undefined`. */ tryConsume(exact: string): boolean; } export declare class AsyncStringTokenizer extends AStringTokenizer { static forText(text: string, at?: number): AsyncStringTokenizer; private readonly iterator; protected constructor(iterator: AsyncIterator, text?: string | undefined, at?: number); /** * Consume up to the given number of characters. May return * fewer characters if the end of the text is encountered. * @throws {@link RangeError} * For invalid length. */ consumeCount(length: number): Promise; next(): Promise; peek(forward?: number): Promise; /** * Consume text which is expected to match the given string. * If it does match, return it. Otherwise, throw an error and * nothing is consumed. * Use {@link tryConsume} if you want to return `undefined` * instead of throwing an error. * @throws {@link ValidationError} * If the exact text cannot be consumed. */ consumeExact(exact: string): Promise; /** * Helper for "skip past anything which would be considered whitespace". */ consumeSpace(): Promise; /** * Repeatedly peek ahead for as long as the given predicate returns * `true`, returning the matched text once it returns `false` or * the end of the text is encountered. * Note that the number in the predicate is the relative offset, * the `ahead` value, not the `at` value. It always starts at zero. */ consumeWhile(predicate: BiPredicate): Promise; /** * Try to consume the given text. If found, it is consumed and * returned. If not found, nothing is consumed and `undefined` * is returned. Use {@link AStringTokenizer#consumeExact} if you want to throw * an error instead of returning `undefined`. */ tryConsume(exact: string): Promise; } export {}; //# sourceMappingURL=string-tokenizer.d.ts.map