import { EqualityComparer } from "../collections/equalityComparison"; /** * A helper class for parsing strings into tokens. * This class provides methods to consume or lookahead for specific pattern, with traceback support. * * @experimental */ export declare class StringTokenParser { readonly source: string; /** Current position in the source string. */ position: number; private readonly _stateStack; /** * @param source The source string to be parsed. */ constructor(source: string); /** * Consumes the specified string if it matches the current position in the source. * Advances the position if the match is successful. * * @param needle The string to match. * @param comparer An optional equality comparer for custom string comparison. * @returns `true` if the string was successfully consumed; otherwise, `false`. */ consumeString(needle: string, comparer?: EqualityComparer): boolean; /** * Consumes the first matching string from the provided iterable if it matches the current position. * Advances the position if a match is found. * * @param needles One or more strings to match. * @param comparer An optional equality comparer for custom string comparison. * @returns The matched string if successful; otherwise, `undefined`. */ consumeAnyString(needles: Iterable, comparer?: EqualityComparer): string | undefined; /** * Consumes a regular expression match at the current position in the source. * Advances the position if the match is successful. * * @param needle The regular expression to match. Must include the `y` (sticky) flag. * @returns The match result if successful; otherwise, `undefined`. */ consumeRegExp(needle: RegExp): RegExpExecArray | RegExpMatchArray | undefined; /** * Checks if the specified string matches the current position in the source without consuming it. * * @param needle The string to match. * @param comparer An optional equality comparer for custom string comparison. * @returns `true` if the string matches; otherwise, `false`. */ peekString(needle: string, comparer?: EqualityComparer): boolean; /** * Checks if any of the provided strings match the current position in the source without consuming it. * * @param needles One or more strings to match. * @param comparer An optional equality comparer for custom string comparison. * @returns The matched string if successful; otherwise, `undefined`. */ peekAnyString(needles: Iterable, comparer?: EqualityComparer): string | undefined; /** * Checks if a regular expression matches the current position in the source without consuming it. * * @param needle The regular expression to match. Must include the `y` (sticky) flag. * @returns The match result if successful; otherwise, `undefined`. */ peekRegExp(needle: RegExp): RegExpExecArray | RegExpMatchArray | undefined; /** * Saves the current position in the source to the state stack. * * @see {@link acceptState} * @see {@link popState} * @see {@link checkStateStackEmpty} */ pushState(): void; /** * Restores the last saved position from the state stack. * This backtracks the parser to the last saved state. * * @throws {InvalidOperationError} If the state stack is empty. * @see {@link pushState} * @see {@link acceptState} */ popState(): void; /** * Removes the last saved position from the state stack without restoring it. * * @throws {InvalidOperationError} If the state stack is empty. */ acceptState(): void; /** * Checks if the state stack is empty. Throws an Error if not. * * @throws {InvalidOperationError} If the state stack is not empty. * @remarks * This method is useful for ensuring that all states have been accepted or popped before finalizing the parsing process. * @see {@link pushState} */ checkStateStackEmpty(): void; /** * Indicates whether the parser has reached the end of the source string. * * @returns `true` if the current position is at or beyond the end of the source; otherwise, `false`. */ get isEof(): boolean; private _matchString; private _matchAnyString; private _matchRegExp; } //# sourceMappingURL=stringTokenParser.d.ts.map