@fauton/cfg
Version:
A package to work with context free grammars and LL1 parsers
14 lines (13 loc) • 818 B
TypeScript
import { IContextFreeGrammar, IContextFreeGrammarInput } from './types';
/**
* Returns the first occurrence of unit production inside production rules
* @param variables Array of variables
* @param productionRules Production rules of CFG
* @returns A tuple where the first item is the variable which produces unit production, and second item indicates the rule position
*/
export declare function findFirstUnitProductionRule(variables: string[], productionRules: IContextFreeGrammar['productionRules']): readonly [string, number] | null;
/**
* Modifies the production rules of a cfg to remove unit production rules
* @param cfg Variable and production rules of a cfg
*/
export declare function removeUnitProduction(inputCfg: Pick<IContextFreeGrammarInput, 'variables' | 'productionRules'>): void;