Did you know ... Search Documentation:
Pack dcgutils -- prolog/dcg_shell.pl
PublicShow source
 dcgshell(+Interp, +Id, ?S1, ?S2) is semidet
 dcgshell(+Id, ?S1, ?S2) is semidet
 dcgshell(?S1, ?S2) is semidet
Runs an interactive shell where typed commands are interepreted as DCG phrases. The cumulative result of all these phrases takes the DCG state from S1 to S2. If present, Id is used to identify the shell and is written as part of the prompt. The default prompt is 'dcg'.

Pressing Ctrl-D at the prompt or typing 'halt' or 'end_of_file' terminates the shell unifying S2 with the final state. The command 'fail' terminates the shell and causes dcgshell/2 or dcgshell/3 as a whole to fail, without leaving any choice points.

dcgshell/4 allows the specification of an alternate interpreter other than call_dcg/3, which is the default in the other forms.

Special commands

Switches context module of interpreter to M.
Change to a new interpreter. Eg, interp(time) will cause timing information to be printed after each command is interpreted.
X ^ Phrase
Causes Phrase to be interpreted after binding X to the id of the current interpreter. Since the id can be any term, you can use it as simple sort of environment in which you can keep data that might be useful later on.
 make// is det
DCG shell command to update loaded files, just as with make/0.
 help(+Topic)// is det
Look-up help on Topic, just as with help/1.
 time(+G:phrase(S))// is semidet
 time(+G:pred(A,S,S), ?X:A)// is semidet
 time(+G:pred(A,B,S,S), ?X:A, ?Y:B)// is semidet
Time execution of DCG phrase G. Any extra arguments are passed to G as in call/N.
 profile_phrase(+G:phrase(_))// is semidet
Profile execution of DCG phrase G.

Undocumented predicates

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

 dcgshell(Arg1, Arg2)
 dcgshell(Arg1, Arg2, Arg3)
 time(Arg1, Arg2, Arg3, Arg4)
 time(Arg1, Arg2, Arg3, Arg4, Arg5)
 trace(Arg1, Arg2, Arg3)
 catch(Arg1, Arg2, Arg3, Arg4, Arg5)