From 9c8d759a439159d4c524252693fa4fe1756f7e70 Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Tue, 14 Jun 2011 09:01:10 +0100 Subject: [PATCH] insert SWI-compatible hook for comment processing. --- pl/boot.yap | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/pl/boot.yap b/pl/boot.yap index 61640fd76..4bd391611 100755 --- a/pl/boot.yap +++ b/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).