import { HashSet } from "things"; import { int, nat } from "things"; import { Hash } from "things"; import { Grammar, Rule } from "./cfg.js"; export declare class Item { rule: nat; dot: nat; lookahead: int; constructor(rule: nat, dot: nat, lookahead: int); symbolAfterDot(rhs: int[]): int; moveDot(): Item; } export declare const ItemHash: Hash; export type Items = HashSet; export declare function nonterminalsOfGrammar(grammar: Grammar): Set; export declare function terminalsOfGrammar(grammar: Grammar): Set; export declare function groupRules(grammar: Grammar): Map; export type XGrammar = { grammar: Grammar; terminals: Set; nonterminals: Set; grouped: Map; first: Map>; startRule: Rule; }; export declare function computeFirst(nonterminals: Set, grammar: Grammar): Map>; export declare function extendGrammar(grammar: Grammar): XGrammar; export declare function firstFrom(xgrammar: XGrammar, rhs: int[], lookahead: int, dot: nat): Set; export declare function computeClosure(xgrammar: XGrammar, items: Items): void; export declare function computeGoto(xgrammar: XGrammar, items: Items, symbol: int): Items; export type LR1Graph = { states: Items[]; symbols: int[]; graph: Map>; }; export declare function computeLR1Graph(xgrammar: XGrammar): LR1Graph; export declare enum ActionKind { SHIFT = 0, REDUCE = 1, ACCEPT = 2 } export type Shift = { kind: ActionKind.SHIFT; state: nat; }; export type Reduce = { kind: ActionKind.REDUCE; rule: nat; }; export type Accept = { kind: ActionKind.ACCEPT; }; export type Action = Shift | Reduce | Accept; export declare const Action: Hash; export type Actions = Map>; export declare function computeActionsOfState(xgrammar: XGrammar, lr1: LR1Graph, stateIndex: nat): Actions; export declare function filterConflictingActions(actions: Actions): Actions; export declare function isAccepting(actions: Actions): boolean; export declare function nextTerminalsOf(actions: Actions): Set;