/** * Query analysis - relates traced goals back to the query the user typed. * * The tracer reports goals with Prolog's internal variable names * ("likes(mary,_1102)"). Everything the user reads should instead speak in the * names from their own query ("likes(mary, X)"), which means matching each * top-level goal to the conjunct it came from. */ export interface QueryBinding { variable: string; value: string; } /** * Split a query into its top-level conjuncts. * "likes(mary, X), likes(john, X)" -> ["likes(mary, X)", "likes(john, X)"] */ export declare function splitConjuncts(query: string): string[]; /** * Parse a `functor(arg, ...)` term. Returns null for anything else. */ export declare function parseTerm(term: string): { functor: string; args: string[]; } | null; /** * True for a Prolog variable - a source name (X, Result) or an internal one (_1102). */ export declare function isVariable(term: string): boolean; /** * Find the conjunct a traced goal came from. * * Matches on functor and arity, then prefers the conjunct whose ground * arguments agree with the goal's - what distinguishes "likes(mary, X)" from * "likes(john, X)" when the goal is "likes(mary,_1102)". */ export declare function matchGoalToConjunct(goal: string, conjuncts: string[]): string | undefined; /** * Read the query variables' values out of a solved goal. * * Pairs the conjunct's arguments with the goal as it stood at EXIT: * "likes(mary, X)" + "likes(mary,wine)" -> X = wine. */ export declare function extractQueryBindings(conjunct: string, exitGoal: string): QueryBinding[]; /** * Distinct variables of a query, in order of first appearance, dropping the * anonymous `_`. Used to snapshot bindings at each solution. * "likes(mary, X), likes(john, X)" -> ["X"]; "append(A, B, [1,2])" -> ["A","B"] */ export declare function extractQueryVariables(query: string): string[]; /** * Parse a solution marker's binding term, as printed by Prolog, into pairs. * "[X=food]" -> [{variable:'X', value:'food'}]; "[]" -> [] */ export declare function parseSolutionBindings(raw: string): QueryBinding[]; /** * Split an argument list, respecting nested brackets. */ export declare function splitArguments(argsStr: string): string[]; //# sourceMappingURL=query.d.ts.map