cfg-first-follow
Version:
Calculate FIRST and FOLLOW set of a Context Free Grammar symbol
26 lines • 816 B
TypeScript
export declare type NonTerminalSymbol = string;
export declare type TerminalSymbol = string;
export declare type ProductionHead = NonTerminalSymbol;
export declare type ProductionExpression = Array<NonTerminalSymbol | TerminalSymbol> | null;
/**
* An object that contains production rules for a `Context Free Grammar`
* @example
* ```ts
* const grammar: ContextFreeGrammar = {
* // E -> TE`
* E: [['T', 'E`']],
* // E` -> *TE` | epsilon
* 'E`': [['*', 'T', 'E`'], null],
* // T -> FT`
* T: [['F', 'T`']],
* // T` -> epsilon | +FT`
* 'T`': [null, ['+', 'F', 'T`']],
* // F -> id | (E
* F: [['id'], ['(', 'E']],
* }
* ```
*/
export interface ContextFreeGrammar {
[key: ProductionHead]: Array<ProductionExpression>;
}
//# sourceMappingURL=typings.d.ts.map