insert SWI-compatible hook for comment processing.

This commit is contained in:
Vitor Santos Costa 2011-06-14 09:01:10 +01:00
parent 82ecc61f6d
commit 9c8d759a43

View File

@ -15,6 +15,10 @@
* *
*************************************************************************/
%
%
%
true :- true.
'$live' :-
@ -1123,20 +1127,38 @@ bootstrap(F) :-
'$init_path_extensions'.
'$loop'(Stream,Status) :-
(
Status = top
;
'$undefined'(comment_hook(_,_,_),prolog)
;
'$number_of_clauses'(comment_hook(_,_,_),prolog,0)
), !,
repeat,
%VSC ( '$current_stream'(_,_,Stream) -> true
%VSC ; '$abort_loop'(Stream)
%VSC ),
prompt1('| '), prompt(_,'| '),
'$current_module'(OldModule),
'$system_catch'('$enter_command'(Stream,Status), OldModule, Error,
user:'$LoopError'(Error, Status)),
!.
% support comment hook
'$loop'(Stream,Status) :-
repeat,
prompt1('| '), prompt(_,'| '),
'$current_module'(OldModule),
'$system_catch'('$enter_command_with_hook'(Stream,Status), OldModule, Error,
user:'$LoopError'(Error, Status)),
!.
'$enter_command'(Stream,Status) :-
'$read_vars'(Stream,Command,_,Pos,Vars, '|: ', no),
'$command'(Command,Vars,Pos,Status).
% support SWI hook in a separate predicate, to avoid slow down standard consult.
'$enter_command_with_hook'(Stream,Status) :-
'$read_vars'(Stream,Command,_,Pos,Vars, '|: ', Comments),
('$notrace'(prolog:comment_hook(Comments,Pos,Command)) -> true ; true ),
'$command'(Command,Vars,Pos,Status).
'$abort_loop'(Stream) :-
'$do_error'(permission_error(input,closed_stream,Stream), loop).