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.
|
true :- true.
|
||||||
|
|
||||||
'$live' :-
|
'$live' :-
|
||||||
@ -1123,20 +1127,38 @@ bootstrap(F) :-
|
|||||||
'$init_path_extensions'.
|
'$init_path_extensions'.
|
||||||
|
|
||||||
'$loop'(Stream,Status) :-
|
'$loop'(Stream,Status) :-
|
||||||
|
(
|
||||||
|
Status = top
|
||||||
|
;
|
||||||
|
'$undefined'(comment_hook(_,_,_),prolog)
|
||||||
|
;
|
||||||
|
'$number_of_clauses'(comment_hook(_,_,_),prolog,0)
|
||||||
|
), !,
|
||||||
repeat,
|
repeat,
|
||||||
%VSC ( '$current_stream'(_,_,Stream) -> true
|
|
||||||
%VSC ; '$abort_loop'(Stream)
|
|
||||||
%VSC ),
|
|
||||||
prompt1('| '), prompt(_,'| '),
|
prompt1('| '), prompt(_,'| '),
|
||||||
'$current_module'(OldModule),
|
'$current_module'(OldModule),
|
||||||
'$system_catch'('$enter_command'(Stream,Status), OldModule, Error,
|
'$system_catch'('$enter_command'(Stream,Status), OldModule, Error,
|
||||||
user:'$LoopError'(Error, Status)),
|
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) :-
|
'$enter_command'(Stream,Status) :-
|
||||||
'$read_vars'(Stream,Command,_,Pos,Vars, '|: ', no),
|
'$read_vars'(Stream,Command,_,Pos,Vars, '|: ', no),
|
||||||
'$command'(Command,Vars,Pos,Status).
|
'$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) :-
|
'$abort_loop'(Stream) :-
|
||||||
'$do_error'(permission_error(input,closed_stream,Stream), loop).
|
'$do_error'(permission_error(input,closed_stream,Stream), loop).
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user