brogue
Version:
A Grammar based generative text library based on Tracery.
17 lines (16 loc) • 754 B
TypeScript
import { Grammar, Lexeme, Rule } from "./grammar";
declare class ExpansionContext {
recursionDepth: number;
grammar: Grammar;
variableStack: (Map<string, string> | undefined)[];
uniqueTrackers: Set<Lexeme>[];
constructor(grammar: Grammar);
pushUniqueTracker(): void;
popUniqueTracker(): void;
markLexemeAsSeen(lexeme: Lexeme): void;
hasSeenLexeme(lexeme: Lexeme): boolean;
}
declare function pickLexeme(rule: Rule, context: ExpansionContext): Lexeme | undefined;
declare function expandLexeme(lexeme: Lexeme, context: ExpansionContext, trackUniqueExpansions: boolean): string | undefined;
declare function expand(grammar: Grammar, text: string): string;
export { expand, pickLexeme, expandLexeme, ExpansionContext, };