export interface TinyToken { cursor: number; type: string; text: string; } /** * Simple framework for writing schema parsers. The parsers using this felt * better than the more ad-hoc code they replaced, and are smaller than * using a parser generator. * * NOTE: All parse errors are exceptions. */ export declare class TinyParseError extends Error { } export declare class TinyParser { readonly input: string; private tokens; protected parseCursor: number; private lookAhead?; private tokenMap; /** * The token map is tested in order. Return TinyToken * is {type: tokenMapKey, text: matchingText }, except * for the special tokenMapKeys: * * space: skipped and never returned * * char: matched string return in both .type and .text * * q*: any token name starting with 'q' is assumed to be * a quoted string and the text will have the first and * last characters stripped */ constructor(input: string, tokenMap?: Record); parseError(str: string): TinyParseError; peek(): TinyToken; private getNext; /** * Return next token, if any token types are passed, read and require those * tokens, then return the last one. * @param types list of token types * @returns The last token read */ next(...types: string[]): TinyToken; nextText(...texts: string[]): TinyToken; skipTo(type: string): void; dump(): TinyToken[]; private tokenize; }