/** * Classes and functions for lexing PENMAN strings. */ import { DecodeError } from './exceptions'; export declare const PENMAN_RE: RegExp; export declare const TRIPLE_RE: RegExp; /** * A lexed token. */ export type Token = [ type: string, text: string, lineno: number, offset: number, line: string ]; /** * An iterator of Tokens with L1 lookahead. */ export declare class TokenIterator { _next: IteratorResult | null; _last: IteratorResult | null; iterator: IterableIterator; constructor(iterator: IterableIterator); [Symbol.iterator](): this; __bool__(): boolean; bool(): boolean; hasNext(): boolean; /** * Return the next token but do not advance the iterator. * * If the iterator is exhausted then a DecodeError is raised. */ peek(): Token; /** * Advance the iterator and return the next token. * * @throws {Error} If the iterator is already exhausted. */ next(): IteratorResult; /** * Return the next token if its type is in `choices`. * * The iterator is advanced if successful. * * @throws {DecodeError} If the next token type is not in `choices`. */ expect(...choices: string[]): Token; /** * Return the next token if its type is in *choices*. * * The iterator is advanced if successful. If unsuccessful, `None` is returned. */ accept(...choices: string[]): Token | null; error(message: string, token?: Token): DecodeError; } /** * Yield PENMAN tokens matched in `lines`. * * By default, this function lexes strings in `lines` using the basic pattern * for PENMAN graphs. If `pattern` is provided, it is used for lexing instead. * * @param lines - An iterable of lines to lex. * @param pattern - The pattern to use for lexing instead of the default ones. * @returns A `TokenIterator` object. */ export declare const lex: (lines: Iterable | string, pattern?: RegExp | string) => TokenIterator;