insert SWI-compatible hook for comment processing.
This commit is contained in:
parent
82ecc61f6d
commit
9c8d759a43
28
pl/boot.yap
28
pl/boot.yap
@ -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).
|
||||
|
||||
|
Reference in New Issue
Block a user