/** * Variable Binding Tracker * * Tracks variable bindings through recursive Prolog execution by processing * trace events in order and maintaining accumulated state. */ import { TraceEvent } from './timeline.js'; export declare class VariableBindingTracker { private bindings; private topLevelQuery; private queryVarName; constructor(originalQuery: string); /** * Extract the query variable name from the original query * e.g., "append([1,2], [3,4], X)" -> "X" * e.g., "factorial(3, Result)" -> "Result" */ private extractQueryVarName; /** * Process a trace event and update bindings */ processEvent(event: TraceEvent): void; /** * Process CALL event - extract variable relationships from parent_info * * Key insight: parent_info.goal shows how the PARENT sees its own result variable * at the moment it's calling this child. */ private processCall; /** * Process EXIT event - we now know the final value */ private processExit; /** * Propagate a binding up through parent levels */ private propagateBinding; /** * Get the accumulated query variable state for a given level * This shows what the top-level query variable looks like at this point */ getQueryVarState(level: number): string | null; /** * Extract the result variable/pattern from a goal * For "append([1,2],[3,4],_79984)", returns "_79984" * For "append([1,2],[3,4],[1|_79854])", returns "[1|_79854]" */ private extractResultVariable; /** * Substitute a variable with a value in a pattern * e.g., substitute("[1|_79854]", "_79854", "[2|_79774]") -> "[1|[2|_79774]]" */ private substitute; /** * Clean up a pattern to show holes * Replace unbound variables with ? and simplify nested lists */ private cleanupPattern; /** * Split arguments respecting parentheses and brackets */ private splitArguments; /** * Escape special regex characters */ private escapeRegex; } //# sourceMappingURL=variable-tracker.d.ts.map