Did you know ... Search Documentation:
Pack pac -- prolog/pac/expand-pac.pl
PublicShow source
 regex(+W:regex, +S:string, -S0:string) is nondet
True if W is expande to qeury for parsing string S (minus S0), that is, a version of phrase/3 for string.
?- regex(w(".*"), "abc", R).
?- regex(w("."), "abc", R).
?- regex(wl(".*"), "abc", R).
?- regex(wl(".*", A), "abc", R).
 bepac is det
Enable PAC mode.
 epac is det
Disable PAC mode.
 bekind(+X) is det
Enable a kind block X.
 bekind(X:epac, O:options) is det
Enable a kind block X with options O.
 ekind is det
Disable kind block.
 betrs(+X) is det
Enable trs block X. betrs : BEgin of Term Rewriting System
 etrs is det
Disable trs block. etrs : End of Term Rewriting System
 befun is det
Enable a function declaration mode.
 expand_pac(+X:clause, -Y:clause) is det
True if X is expanded to Y.
 expand_query(+Q:goal, -Q0:goal) is det
A query Q is expanded to Q0.
 expand_query(?M:module, +Q:goal, -Q0:goal) is det
True if a top level query Q is expanded to Q0 at module M.
 show(+X:term) is det
?- show(pred([X, X])). ?- show(phrase(w("."))). ?- show(phrase(wl("[a-zA-Z]+", A, []))). ?- show(phrase(wl("[^a-zA-Z]+", A, []))). ?- show(phrase(wl("[^b-wB-W]+", A, []))).
 show(+X:phrase) is det
True if the expanded phrase of pac X is displayed.
 let(-F:var, +X:goal) is det
True if a F is unified with expanded goal X.
 expand_goal(+G:goal, +M:atom, -G0:goal, -P:list, -Q:list) is det
True if G is converted to G0 and the generated helper predicates in P (minus Q) so that G is equivalent to G0 with P (minus Q).
Simples usage: ?- pac:expand_goal((call(pred([a]), X), write(X)), user, G, L, []). G = (user:'pred#2'(X), user:write(X)), L = [ (user:'pred#2'(a) :- true)]
 expand_core(+Pac:pac, +M:atom, -G:pred, -P:list, -Q:list) is det
True if Pac is converted to a fresh predicate G in P (minus Q) at a module M.
Simplest usage: ?- expand_core(pred([X, Y] :- X\==Y), user, G, P, []). G = user:'pred#1', P = [ (user:'pred#1'(X, Y) :- user: (X\==Y))]
 expand_phrase(+G:phrase, +M:atom, -G0:phrase, -P:list, -Q:list) is det
True if G is converted to G0 and helper predicates in P (minus Q) at a module M.
Simplest usage: ?- expand_phrase((pred([X, f(X)]), pred(U, g(U))), user, G, L, []). G = (user:'pred#3', user:'pred#4'(U)), L = [ (user:'pred#3'(X, f(X)) :- true), (user:'pred#4'(U, g(U)):-true)] .
 expand_exp(+E:exp, +O:options) is det
Convert E to a goal G (see below) such that execution of G makes V be unified with the value.

options in O:

  • goal(G) : G is a goal whose execution gives the value V of the expression E.
  • pac(X-Y): generated helper predicates in the form of d-list X-Y.
  • expansion(true/false) : if true given, subterms of E
    are evaluated recursively unless it is a expression with a kind prefix like <kind>::<expression>.
  • run(true/false): 'true' is default, and then run the goal G.
  • val(V) : V is to be unified with the value of E.
 expand_exp(+E:exp, +S:kind, -U:term, +M:module, -G:goal, -P:list, -Q:list)
is semidet
True if G is a goal such that execution of G unifies a term U with the value of expression E, where H is the helper predidates for G generated as a difference list P with a tail Q, i.e, append(H, Q, P) is true. Typically atomic subgoals of G are of the form M:S(A, B). expand_exp/7 is used when compiling an equations in a kind, a set of equations, to a clause of the predicate M:S/2.
Simplest usage: ?- expand_exp(f(a), k, V, m, G, P, []). G = m:k(f(a), V), P = [].
?- expand_exp(f(a), call, V, m, G, P, []). G = m:f(a, V), P = [].
?- expand_exp(=(hello), call, V, user, G, P, []). G = user: (hello=V), P = [].

Features:

  1. PAC/Lambda/Kind are macros expanded on loading.
  2. The sorted expression `(S :: E) = V' is eqivalent to `S(E, V)'.
  3. Backquote '`' is for quoting term.
  4. no special runtime predicate is necessary.
  5. Arguments (in @ ) is evaluated before call.
  6. let/2 for dynamic compiling pacs.

Undocumented predicates

The following predicates are exported, but not or incorrectly documented.

 eval(Arg1, Arg2)
 efun
 pdef(Arg1, Arg2)
 nopac(Arg1)
 complete_args(Arg1, Arg2, Arg3)
 expand_arg(Arg1, Arg2, Arg3, Arg4, Arg5)
 expand_arg(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6)
 expand_arg_assert(Arg1, Arg2)
 expand_arg_compile(Arg1, Arg2)
 expand_basic_phrase(Arg1, Arg2, Arg3, Arg4)
 expand_basic_phrase(Arg1, Arg2, Arg3, Arg4, Arg5)
 expand_exp(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8)
 expand_fun(Arg1, Arg2)
 expand_kind_rule(Arg1, Arg2, Arg3, Arg4, Arg5)
 compile_kind_rule(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6)
 flip_list(Arg1, Arg2, Arg3)
 goal_to_pred(Arg1, Arg2, Arg3, Arg4, Arg5)
 partial_args_match(Arg1, Arg2)
 pdef(Arg1, Arg2)
 phrase_to_pred(Arg1, Arg2, Arg3, Arg4, Arg5)
 show_phrase(Arg1)
 show_exp(Arg1)