UNPKG

@multila/multila-parser-generator

Version:
71 lines (70 loc) 1.67 kB
/** * production rule */ export declare class LR1_Rule { /** * index of the current rule */ index: number; /** * ID of the non-terminal on the left-hand side */ lhs: string; /** * items of the right-hand side of the rule */ rhs: LR1_RuleItem[]; /** * (optional) identifier of a function that is called after reduction of rule. */ callBackId: string; /** * Creates a new rule. * @param lhs non-terminal of the left-hand side of the rule */ constructor(lhs?: string); /** * Adds a new terminal item to the right-hand side of the rule. * @param s 'INT' for integer constant, 'REAL' for real valued constant, * 'HEX' for hexadecimal values, 'ID' for identifier', 'STR' for a string, * ':TER' for a terminal (with TER an arbitrary string) */ addTerminalItem(s: string): void; /** * Adds a new non-terminal item to the right-hand side of the rule. * @param s identifier of the non-terminal */ addNonTerminalItem(s: string): void; /** * Stringify rule. * @param dotPos (optionally) writes '.' after the i-th item of the right-hand * side of the rule * @returns stringified rule */ toString(dotPos?: number): string; } /** * type of rule items */ export declare enum LR1_RuleItemType { Terminal = "T", NonTerminal = "NT" } /** * rule item */ export declare class LR1_RuleItem { /** * type */ type: LR1_RuleItemType; /** * value */ value: string; /** * Stringify item. * @returns stringified item */ toString(): string; }