import { EventEmitter } from "events";
import * as Stmt from "./Statement";
import { Lexeme, Token } from "../lexer";
import { ParseError } from "./ParseError";
/** The results of a Parser's parsing pass. */
export interface ParseResults {
    /** The statements produced by the parser. */
    statements: Stmt.Statement[];
    /** The errors encountered by the Parser. */
    errors: ParseError[];
    /** Libraries usage encountered by the Parser */
    libraries: Map<string, boolean>;
}
export declare class Parser {
    /** Allows consumers to observe errors as they're detected. */
    readonly events: EventEmitter<[never]>;
    readonly stats: Map<Lexeme, Set<any>>;
    constructor();
    /**
     * A convenience function, equivalent to `new Parser().parse(toParse)`, that parses an array of
     * `Token`s into an abstract syntax tree that can be executed with the `Interpreter`.
     * @param toParse the array of tokens to parse
     * @returns an array of `Statement` objects that together form the abstract syntax tree of the
     *          program
     */
    static parse(toParse: readonly Token[]): ParseResults;
    /**
     * Convenience function to subscribe to the `err` events emitted by `parser.events`.
     * @param errorHandler the function to call for every Parser error emitted after subscribing
     * @returns an object with a `dispose` function, used to unsubscribe from errors
     */
    onError(errorHandler: (err: ParseError) => void): {
        dispose: () => void;
    };
    /**
     * Convenience function to subscribe to a single `err` event emitted by `parser.events`.
     * @param errorHandler the function to call for the first Parser error emitted after subscribing
     */
    onErrorOnce(errorHandler: (err: ParseError) => void): void;
    /**
     * Parses an array of `Token`s into an abstract syntax tree that can be executed with the `Interpreter`.
     * @param toParse the array of tokens to parse
     * @returns an array of `Statement` objects that together form the abstract syntax tree of the
     *          program
     */
    parse(toParse: readonly Token[]): ParseResults;
}
