UNPKG

@fauton/cfg

Version:

A package to work with context free grammars and LL1 parsers

22 lines (21 loc) 1.08 kB
import { ICfgLanguageGenerationOption, IContextFreeGrammarInput } from './types'; interface IQueueItem { path: string[]; label: string; rules: Array<[string, number]>; tokens: string[]; sentence: string; } /** * Generates all the strings of a given cfg within certain length along with the path taken to generate them * @param cfg Variables and transition Record for the cfg * @param maxTokenLength Maximum length of the generated string * @param skipSimplification Should the cfg simplification process be skipped, useful if you already have a simplified cfg, and dont want to spend additional computational power behind it, also sometimes you dont want to simplify cfg as it updates the production rules * @returns A record of generated string and the path taken to generate them */ export declare function generateCfgLanguage(inputCfg: IContextFreeGrammarInput, options: ICfgLanguageGenerationOption): { tree: Record<string, IQueueItem>; language: string[]; productionRules: Record<string, string[]>; }; export {};