import { type IComparable } from "antlr4ng";
import type { IRule } from "../types.js";
import { Alternative } from "./Alternative.js";
import { AttributeDict } from "./AttributeDict.js";
import { Grammar } from "./Grammar.js";
import { IAttribute } from "./IAttribute.js";
import { IAttributeResolver } from "./IAttributeResolver.js";
import { LabelElementPair } from "./LabelElementPair.js";
import { LabelType } from "./LabelType.js";
import { ActionAST } from "./ast/ActionAST.js";
import { AltAST } from "./ast/AltAST.js";
import { GrammarAST } from "./ast/GrammarAST.js";
import { PredAST } from "./ast/PredAST.js";
import { RuleAST } from "./ast/RuleAST.js";
export declare class Rule implements IAttributeResolver, IComparable, IRule {
    static readonly validLexerCommands: Set<string>;
    readonly name: string;
    modifiers?: GrammarAST[];
    ast: RuleAST;
    args?: AttributeDict;
    retvals?: AttributeDict;
    locals?: AttributeDict;
    /** In which grammar does this rule live? */
    readonly g: Grammar;
    /** If we're in a lexer grammar, we might be in a mode. */
    readonly mode?: string;
    /** If null then use value from global option that is false by default. */
    readonly caseInsensitive: boolean;
    /**
     * Map a name to an action for this rule like `@init {...}`. The code generator will use this to fill holes in the
     * rule template. I track the AST node for the action in case I need the line number for errors.
     */
    namedActions: Map<string, ActionAST>;
    /**
     * Track exception handlers; points at "catch" node of (catch exception action) don't track finally action.
     */
    exceptions: GrammarAST[];
    /**
     * Track all executable actions other than named actions like `@init` and catch/finally (not in an alt). Also tracks
     * predicates, rewrite actions. We need to examine these actions before code generation so that we can detect
     * refs to $rule.attr etc...
     *
     * This tracks per rule. Alternative objs also track per alt.
     */
    actions: ActionAST[];
    /** Set by SymbolCollector. */
    finallyAction?: ActionAST;
    readonly numberOfAlts: number;
    /** Nobody calls us. */
    isStartRule: boolean;
    /** 1..n alts */
    alt: Alternative[];
    /** All rules have unique index 0..n - 1. */
    index: number;
    /** If lexer; 0..n-1 for n actions in a rule. */
    actionIndex: number;
    constructor(g: Grammar, name: string, ast: RuleAST, numberOfAlts: number, lexerMode?: string, caseInsensitive?: boolean);
    hashCode(): number;
    defineActionInAlt(currentAlt: number, actionAST: ActionAST): void;
    /**
     * Lexer actions are numbered across rules 0..n - 1.
     *
     * @param actionAST The action to define.
     */
    defineLexerAction(actionAST: ActionAST): void;
    definePredicateInAlt(currentAlt: number, predAST: PredAST): void;
    resolveRetvalOrProperty(y: string): IAttribute | null;
    getTokenRefs(): Set<string>;
    getElementLabelNames(): Set<string> | null;
    getElementLabelDefs(): Map<string, LabelElementPair[]>;
    hasAltSpecificContexts(): boolean;
    /**
     * Used for recursive rules (subclass), which have 1 alt, but many original alts.
     *
     * @returns The original alt number for this rule.
     */
    getOriginalNumberOfAlts(): number;
    /**
     * Gets `#` labels. The keys of the map are the labels applied to outer alternatives of a lexer rule, and the
     * values are collections of pairs (alternative number and {@link AltAST}) identifying the alternatives with
     * this label. Unlabeled alternatives are not included in the result.
     *
     * @returns A map of `#` labels to their AST nodes they are applied to, or `null` if no such labels are present.
     */
    getAltLabels(): Map<string, Array<[number, AltAST]>> | null;
    getUnlabeledAltASTs(): AltAST[] | null;
    /** $x Attribute: rule arguments, return values, predefined rule prop. */
    resolveToAttribute(x: string, node: ActionAST | null): IAttribute | null;
    /** $x.y Attribute: x is surrounding rule, label ref (in any alts). */
    resolveToAttribute(x: string, y: string, node: ActionAST | null): IAttribute | null;
    resolvesToLabel(x: string, node: ActionAST): boolean;
    resolvesToListLabel(x: string, node: ActionAST): boolean;
    resolvesToToken(x: string, node: ActionAST): boolean;
    resolvesToAttributeDict(x: string, node: ActionAST): boolean;
    resolveToRule(x: string): Rule | null;
    getAnyLabelDef(x: string): LabelElementPair | null;
    getPredefinedScope(labelType: LabelType): AttributeDict | null;
    isFragment(): boolean;
    equals(obj: unknown): boolean;
    toString(): string;
}
