import { Listeners } from "./InputState"; import { Term } from "./Matchers"; import { TermDef } from "./matchers/Concat"; import { DismatchReport, PatternMatch } from "./PatternMatch"; import { InputStream } from "./spi/InputStream"; import { SkipCapable, WhiteSpaceHandler } from "./Config"; import { MatchReport } from "./MatchReport"; export declare type AllowableTermDef = (TermDef | ((ctx: PARAMS & any) => any) | { [index: string]: any; }); export declare type TermsDefinition = Record> & Partial & Partial & { [index: string]: any; }; /** * Record with values of any type for every key K found in T. * Convenient inferred return type for microgrammar. */ export declare type AnyKeysOf = Record; /** * Central interface for microgrammar usage. * Represents a microgrammar that we can use to match input * in a string or stream. */ export interface Grammar extends Term { /** * Generator for matching the given input. * @param {string | InputStream} input * @param {{}} parseContext * @param {Listeners} l * @return {Iterable} */ matchIterator(input: string | InputStream, parseContext?: object, l?: Listeners): Iterable; /** * Convenience method to find matches. Note that this will parse the entire input in one pass. * Use matchIterator if you are likely to try to stop part-way through, or want to be * kinder to the event loop. * @param input * @param parseContext context for the whole parsing operation * @param l listeners observing input characters as they are read * @return {PatternMatch[]} */ findMatches(input: string | InputStream, parseContext?: object, l?: Listeners): Array; /** * Convenient method to find the first match, or null if not found. * Stops searching after the first match. * @param input * @param l listeners observing input characters as they are read * @returns {PatternMatch[]} */ firstMatch(input: string | InputStream, l?: Listeners): PatternMatch & T | null; /** * Return a match if it explains the whole of the input. * This style of usage is more like a traditional parser, * building an AST for a whole file. * @param input * @param parseContext context for the whole parsing operation * @param l listeners observing input characters as they are read * @return {PatternMatch&T} * @deprecated use perfectMatch; wrap in toPatternMatchOrDismatchReport if needed */ exactMatch(input: string | InputStream, parseContext?: object, l?: Listeners): PatternMatch & T | DismatchReport; /** * Return a match (or failure to match) with all structural information * including matches that succeeded, and matches that failed * @param input * @param parseContext context for the whole parsing operation * @param l listeners observing input characters as they are read * @return MatchReport */ perfectMatch(input: string | InputStream, parseContext?: object, l?: Listeners): MatchReport; }