ephemeral-writer
Version:
A procedural text generation system.
109 lines • 4.22 kB
TypeScript
export { modifiers } from "./modifiers.js";
export function createGrammar(raw: string): Grammar;
export class Grammar {
constructor(raw: Record<string, string | string[]>);
modifiers: Record<string, (s: string, params: string[]) => string>;
depth: number;
symbols: {
[x: string]: EphemeralSymbol;
};
subgrammars: Grammar[];
errors: string[];
raw: Record<string, string | string[]>;
clearState: () => void;
addModifiers: (mods: Record<string, (s: string, params: string[]) => string>) => void;
withModifiers: (mods: Record<string, (s: string, params: string[]) => string>) => Grammar;
createRoot: (rule: string, scratch: Record<string, string> | undefined) => EphemeralNode;
expandChildren: (rule: string, allowEscapeChars: boolean, scratch: Record<string, string> | undefined) => string[];
expand: (rule: string, allowEscapeChars: boolean, scratch: Record<string, string> | undefined) => EphemeralNode;
flatten: (rule: string, allowEscapeChars: boolean, scratch: Record<string, string> | undefined) => string;
toJSON: () => string;
pushRules: (key: string, rawRules: [grammar: Grammar, key: string, rawRules: string | string[] | undefined][2], sourceAction: NodeAction | null) => void;
popRules: (key: string) => void;
selectRule: (key: string, node: EphemeralNode, errors: string[]) => string | null;
}
declare class EphemeralSymbol {
constructor(grammar: Grammar, key: string, rawRules: string | string[] | undefined);
key: string;
grammar: Grammar;
rawRules: string | string[] | undefined;
baseRules: RuleSet;
stack: RuleSet[];
uses: {
node: EphemeralNode;
}[];
isDynamic: boolean;
clearState: () => void;
pushRules: (rawRules: string | string[] | undefined) => void;
popRules: () => void;
selectRule: (node: EphemeralNode, errors: string[]) => string | null;
getActiveRules: () => string | null;
}
declare class EphemeralNode {
constructor(parent: EphemeralNode | null, grammar: Grammar, childIndex: number, settings: {
raw: string;
scratch: Record<string, string> | undefined;
type: number;
});
errors: string[];
depth: number;
childIndex: number;
scratch: Record<string, string> | undefined;
grammar: Grammar;
parent: EphemeralNode | null;
children: EphemeralNode[];
finishedText: string;
raw: string;
type: number;
isExpanded: boolean;
toString: () => string;
expandChildren: (childRule: string, preventRecursion: boolean) => void;
childRule: string | undefined;
expand: (preventRecursion: boolean) => void;
expansionErrors: string[] | undefined;
preactions: NodeAction[] | undefined;
postactions: NodeAction[] | undefined;
symbol: string | undefined;
modifiers: string[] | undefined;
action: NodeAction | undefined;
varop: NodeVariableOp | undefined;
clearEscapeChars: () => void;
}
declare function NodeAction(node: EphemeralNode, raw: string): void;
declare class NodeAction {
constructor(node: EphemeralNode, raw: string);
raw: string;
node: EphemeralNode;
target: string;
type: number;
rule: string | undefined;
createUndo(): NodeAction | null;
activate(): void;
ruleSections: string[] | undefined;
finishedRules: string[] | undefined;
toText(): string;
}
declare function RuleSet(grammar: Grammar, raw: string | string[] | undefined): void;
declare class RuleSet {
constructor(grammar: Grammar, raw: string | string[] | undefined);
raw: string | string[] | undefined;
grammar: Grammar;
falloff: number;
defaultRules: string[] | undefined;
conditionalRule: string | undefined;
lastIndex: number;
selectRule(errors: string[]): string | null;
clearState(): void;
}
declare function NodeVariableOp(node: EphemeralNode, raw: string): void;
declare class NodeVariableOp {
constructor(node: EphemeralNode, raw: string);
node: EphemeralNode;
scratch: Record<string, string> | undefined;
type: number;
target: string;
value: string | undefined;
conditional: string | undefined;
activate(): void;
}
//# sourceMappingURL=ephemeral.d.ts.map