make top-level more SWI like
This commit is contained in:
parent
a83546e313
commit
e2179a277d
46
pl/boot.yap
46
pl/boot.yap
@ -143,8 +143,8 @@ true :- true.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* main execution loop */
|
/* main execution loop */
|
||||||
'$read_vars'(user_input, Goal, Mod, Pos, Bindings, Prompt, ReadComments) :-
|
'$read_toplevel'(Goal, Bindings) :-
|
||||||
'$swi_current_prolog_flag'(readline, true),
|
'$swi_current_prolog_flag'(readline, true), !,
|
||||||
read_history(h, '!h',
|
read_history(h, '!h',
|
||||||
[trace, end_of_file],
|
[trace, end_of_file],
|
||||||
Prompt, Goal, Bindings), !,
|
Prompt, Goal, Bindings), !,
|
||||||
@ -153,13 +153,28 @@ true :- true.
|
|||||||
;
|
;
|
||||||
true
|
true
|
||||||
).
|
).
|
||||||
'$read_vars'(Stream, T, Mod, Pos, V, _Prompt, ReadComments) :-
|
'$read_toplevel'(Goal, Bindings) :-
|
||||||
'$read'(true, T, Mod, V, Pos, Err, ReadComments, Stream),
|
prompt(_,'?- '),
|
||||||
(nonvar(Err) ->
|
prompt1('|: '),
|
||||||
print_message(error,Err), fail
|
'$system_catch'('$raw_read'(user_input, Line), prolog, E,
|
||||||
;
|
(print_message(error, E),
|
||||||
true
|
( E = error(syntax_error(_), _)
|
||||||
).
|
-> fail
|
||||||
|
; throw(E)
|
||||||
|
))),
|
||||||
|
( current_predicate(_, user:rl_add_history(_))
|
||||||
|
-> format(atom(CompleteLine), '~W~W',
|
||||||
|
[ Line, [partial(true)],
|
||||||
|
'.', [partial(true)]
|
||||||
|
]),
|
||||||
|
call(user:rl_add_history(CompleteLine))
|
||||||
|
; true
|
||||||
|
),
|
||||||
|
'$system_catch'(atom_to_term(Line, Goal, Bindings), prolog, E,
|
||||||
|
( print_message(error, E),
|
||||||
|
fail
|
||||||
|
)), !.
|
||||||
|
|
||||||
|
|
||||||
% reset alarms when entering top-level.
|
% reset alarms when entering top-level.
|
||||||
'$enter_top_level' :-
|
'$enter_top_level' :-
|
||||||
@ -191,15 +206,13 @@ true :- true.
|
|||||||
set_value('$live','$false').
|
set_value('$live','$false').
|
||||||
'$enter_top_level' :-
|
'$enter_top_level' :-
|
||||||
'$disable_docreep',
|
'$disable_docreep',
|
||||||
prompt(_,'| '),
|
|
||||||
'$run_toplevel_hooks',
|
'$run_toplevel_hooks',
|
||||||
prompt1('|: '),
|
'$read_toplevel'(Command,Varnames),
|
||||||
'$read_vars'(user_input,Command,_,Pos,Varnames, ' ?- ', no),
|
|
||||||
nb_setval('$spy_gn',1),
|
nb_setval('$spy_gn',1),
|
||||||
% stop at spy-points if debugging is on.
|
% stop at spy-points if debugging is on.
|
||||||
nb_setval('$debug_run',off),
|
nb_setval('$debug_run',off),
|
||||||
nb_setval('$debug_jump',off),
|
nb_setval('$debug_jump',off),
|
||||||
'$command'(Command,Varnames,Pos,top),
|
'$command'(Command,Varnames,_Pos,top),
|
||||||
'$sync_mmapped_arrays',
|
'$sync_mmapped_arrays',
|
||||||
set_value('$live','$false').
|
set_value('$live','$false').
|
||||||
|
|
||||||
@ -1102,6 +1115,13 @@ bootstrap(F) :-
|
|||||||
!,
|
!,
|
||||||
close(Stream).
|
close(Stream).
|
||||||
|
|
||||||
|
'$read_vars'(Stream, T, Mod, Pos, V, _Prompt, ReadComments) :-
|
||||||
|
'$read'(true, T, Mod, V, Pos, Err, ReadComments, Stream),
|
||||||
|
(nonvar(Err) ->
|
||||||
|
print_message(error,Err), fail
|
||||||
|
;
|
||||||
|
true
|
||||||
|
).
|
||||||
|
|
||||||
'$init_path_extensions' :-
|
'$init_path_extensions' :-
|
||||||
get_value('$extend_file_search_path',P), !,
|
get_value('$extend_file_search_path',P), !,
|
||||||
|
Reference in New Issue
Block a user