import { HashMap } from "../misc/HashMap.js"; import { ParserRuleContext } from "../ParserRuleContext.js"; import { DoubleDict } from "../utils/DoubleDict.js"; import { ATN } from "./ATN.js"; import { PredictionContext } from "./PredictionContext.js"; import { PredictionContextCache } from "./PredictionContextCache.js"; import { SingletonPredictionContext } from "./SingletonPredictionContext.js"; /** * Convert a {@link RuleContext} tree to a {@link PredictionContext} graph. * Return {@link EMPTY} if `outerContext` is empty or null. */ export declare const predictionContextFromRuleContext: (atn: ATN, outerContext?: ParserRuleContext) => PredictionContext; export declare const getCachedPredictionContext: (context: PredictionContext, contextCache: PredictionContextCache, visited: HashMap) => PredictionContext; export declare const merge: (a: PredictionContext, b: PredictionContext, rootIsWildcard: boolean, mergeCache: DoubleDict | null) => PredictionContext; /** * Make pass over all *M* `parents`; merge any `equals()` * ones. */ export declare const combineCommonParents: (parents: Array) => void; /** * Merge two {@link SingletonPredictionContext} instances. * * Stack tops equal, parents merge is same; return left graph.
* * * Same stack top, parents differ; merge parents giving array node, then * remainders of those graphs. A new root node is created to point to the * merged parents.
* * * Different stack tops pointing to same parent. Make array node for the * root where both element in the root point to the same (original) * parent.
* * * Different stack tops pointing to different parents. Make array node for * the root where each element points to the corresponding original * parent.
* * * @param a the first {@link SingletonPredictionContext} * @param b the second {@link SingletonPredictionContext} * @param rootIsWildcard `true` if this is a local-context merge, * otherwise false to indicate a full-context merge * @param mergeCache tbd */ export declare const mergeSingletons: (a: SingletonPredictionContext, b: SingletonPredictionContext, rootIsWildcard: boolean, mergeCache: DoubleDict | null) => PredictionContext; /** * Handle case where at least one of `a` or `b` is * {@link EMPTY}. In the following diagrams, the symbol `$` is used * to represent {@link EMPTY}. * *

Local-Context Merges

* * These local-context merge operations are used when `rootIsWildcard` * is true. * * {@link EMPTY} is superset of any graph; return {@link EMPTY}.
* * * {@link EMPTY} and anything is `//EMPTY`, so merged parent is * `//EMPTY`; return left graph.
* * * Special case of last merge if local context.
* * *

Full-Context Merges

* * These full-context merge operations are used when `rootIsWildcard` * is false. * * * * Must keep all contexts; {@link EMPTY} in array is a special value (and * null parent).
* * * * * @param a the first {@link SingletonPredictionContext} * @param b the second {@link SingletonPredictionContext} * @param rootIsWildcard `true` if this is a local-context merge, * otherwise false to indicate a full-context merge */ export declare const mergeRoot: (a: SingletonPredictionContext, b: SingletonPredictionContext, rootIsWildcard: boolean) => PredictionContext | null;