import { int, nat } from "things"; import { GrammarSymbols } from "./grammar_symbols.js"; import { Actions } from "./lr.js"; export declare enum ActionPlanKind { SHIFT = 0, REDUCE = 1, ACCEPT = 2, READ = 3, ERROR = 4 } export type ActionPlanShift = { kind: ActionPlanKind.SHIFT; /** The state to shift onto the stack. */ state: nat; /** How many of the tokens read to get into this state are actually munched? */ munch: nat; }; export type ActionPlanReduce = { kind: ActionPlanKind.REDUCE; /** The rule to reduce with. */ rule: nat; }; export type ActionPlanAccept = { kind: ActionPlanKind.ACCEPT; }; export type ActionPlanRead = { kind: ActionPlanKind.READ; /** Which action plan to execute next depending on which terminal is read. */ options: [Set, ActionPlan][]; }; export type ActionPlanError = { kind: ActionPlanKind.ERROR; }; export type ActionPlan = ActionPlanShift | ActionPlanReduce | ActionPlanAccept | ActionPlanRead | ActionPlanError; export declare function planActions(symbols: GrammarSymbols, nextTerminalsOfState: Set[], actions: Actions): ActionPlan; export declare function planContainsError(plan: ActionPlan): boolean; export declare function depthOfPlan(plan: ActionPlan): nat; export declare function planHasAmbiguousReads(plan: ActionPlan): boolean; export declare function printActionPlan(symbols: GrammarSymbols, plan: ActionPlan, print?: (s: string) => void): void; export declare function printActions(symbols: GrammarSymbols, nextTerminals: Set[], actions: Actions, print?: (s: string) => void): void;