diff --git a/pl/CMakeFiles/progress.marks b/pl/CMakeFiles/progress.marks index 21e72e8ac..0691f67b2 100644 --- a/pl/CMakeFiles/progress.marks +++ b/pl/CMakeFiles/progress.marks @@ -1 +1 @@ -48 +52 diff --git a/pl/arith.yap b/pl/arith.yap index bd9323168..cac89fa61 100644 --- a/pl/arith.yap +++ b/pl/arith.yap @@ -112,7 +112,7 @@ q(A):- A is 22. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -*/ +w*/ do_not_compile_expressions :- set_value('$c_arith',[]). '$c_built_in'(IN, M, H, OUT) :- @@ -128,14 +128,12 @@ do_c_built_in(Mod:G, _, H, OUT) :- var(G1), !, do_c_built_metacall(G1, M1, H, OUT). do_c_built_in('C'(A,B,C), _, _, (A=[B|C])) :- !. -do_c_built_in('$do_error'( Error, Goal), M, H, - ('$p_and_cp'(Goal, Caller), - functor(H,Na,Ar), - throw(error(Error, [g=Goal,c=c(M:Na/Ar,File,FilePos),p=Caller])) +do_c_built_in('$do_error'( Error, Goal), M, Head, + (clause_location(Call, Caller), + strip_module(M:Goal,M1,NGoal), + throw(error(Error, [[g|g(M1:NGoal)],[p|Call],[e|Caller],[h|g(Head)]])) ) - ):- - stream_property( loop_stream, name(File) ), - stream_property( loop_stream, position(FilePos) ). + ) :- !. do_c_built_in(X is Y, M, H, P) :- primitive(X), !, do_c_built_in(X =:= Y, M, H, P). @@ -157,7 +155,7 @@ do_c_built_in(phrase(NT,Xs0,Xs), Mod, _, NewGoal) :- '$goal_expansion_allowed'(phrase(NT,Xs0,Xs), Mod), Goal = phrase(NT,Xs0,Xs), callable(NT), - catch('$translate_rule'((pseudo_nt --> NT), Rule), + catch(prolog:'$translate_rule'((pseudo_nt --> NT), Rule), error(Pat,ImplDep), ( \+ '$harmless_dcgexception'(Pat), throw(error(Pat,ImplDep)) @@ -374,7 +372,7 @@ expand_expr(Op, X, Y, O, Q, P) :- '$harmless_dcgexception'(type_error(callable,_)). % ex: phrase(27,L) - +:- set_value('$c_arith',true). /** @} */ diff --git a/pl/boot.yap b/pl/boot.yap index ae81404f9..cd610c1c6 100644 --- a/pl/boot.yap +++ b/pl/boot.yap @@ -186,6 +186,7 @@ list, since backtracking could not "pass through" the cut. */ + system_module(_init, _SysExps, _Decls) :- !. system_module(M, SysExps, Decls) :- '$current_module'(prolog, M), @@ -286,6 +287,49 @@ private(_). :- use_system_module( '$_strict_iso', ['$check_iso_strict_clause'/1, '$iso_check_goal'/2]). +'$prepare_goals'((A,B),(NA,NB),Any) :- + !, + '$prepare_goals'(A,NA,Any), + '$prepare_goals'(B,NB,Any). +'$prepare_goals'((A;B),(NA;NB),Any) :- + !, + '$prepare_goals'(A,NA,Any), + '$prepare_goals'(B,NB,Any). +'$prepare_goals'((A->B),(NA->NB),Any) :- + !, + '$prepare_goals'(A,NA,Any), + '$prepare_goals'(B,NB,Any). +'$prepare_goals'((A*->B),(NA*->NB),Any) :- + !, + '$prepare_goals'(A,NA,Any), + '$prepare_goals'(B,NB,Any). +'$prepare_goals'((\+ A),(\+ NA),Any) :- + !, + '$prepare_goals'(A,NA,Any). +'$prepare_goals'('$do_error'(Error,Goal), + (clause_location(Call, Caller), + writeln(Goal), + strip_module(M:Goal,M1,NGoal), + throw(error(Error, [[g|g(M1:NGoal)],[p|Call],[e|Caller],[h|g(Head)]])) + ), + true) :- + !. +'$prepare_goals'(X is AOB, + is(X, IOp, A, B ), + true) :- + var(X), + functor(AOB, Op, 2), + arg(1, AOB, A), + arg(2, AOB, B), + !, + '$binary_op_as_integer'(Op,IOp). +'$prepare_goals'((A,B),(A,B),_Any). + +'$prepare_clause'((H :- B), (H:-NB)) :- + '$prepare_goals'(B,NB,Any), + Any==true. + + % % @@ -1326,6 +1370,7 @@ bootstrap(F) :- '$start_consult'(consult, File, LC), file_directory_name(File, Dir), working_directory(OldD, Dir), + ( current_prolog_flag(verbose_load, silent) -> @@ -1452,7 +1497,7 @@ expand_term(Term,Expanded) :- % Grammar Rules expansion % '$expand_term_grammar'((A-->B), C) :- - '$translate_rule'((A-->B),C), !. + prolog:'$translate_rule'((A-->B),C), !. '$expand_term_grammar'(A, A). % diff --git a/pl/consult.yap b/pl/consult.yap index 73a33cf59..97faf5897 100644 --- a/pl/consult.yap +++ b/pl/consult.yap @@ -431,8 +431,8 @@ load_files(Files,Opts) :- b_setval('$source_file', File), ( var(Stream) -> /* need_to_open_file */ - '$full_filename'(File, Y, Call), - open(Y, read, Stream) + ( '$full_filename'(File, Y, Call) -> true ; '$do_error'(existence_error(source_sink,File),Call) ), + ( open(Y, read, Stream) -> true ; '$do_error'(permission_error(input,stream,Y),Call) ) ; stream_property(Stream, file_name(Y)) ), !, @@ -446,8 +446,7 @@ load_files(Files,Opts) :- '$start_lf'(If, Mod, Stream, TOpts, File, Y, Reexport, Imports), % stop_low_level_trace, close(Stream). -'$lf'(X, _, Call, _) :- - '$do_error'(permission_error(input,stream,X),Call). + '$start_lf'(not_loaded, Mod, _Stream, TOpts, UserFile, File, Reexport,Imports) :- '$file_loaded'(File, Mod, Imports, TOpts), !, diff --git a/pl/grammar.yap b/pl/grammar.yap index eac07275d..e692c2deb 100644 --- a/pl/grammar.yap +++ b/pl/grammar.yap @@ -78,7 +78,7 @@ Grammar related built-in predicates: :- use_system_module( '$_errors', ['$do_error'/2]). % :- meta_predicate ^(?,0,?). -% ^(Xs, Goal, Xs) :- call(Goal). + % ^(Xs, Goal, Xs) :- call(Goal). % :- meta_predicate ^(?,1,?,?). % ^(Xs0, Goal, Xs0, Xs) :- call(Goal, Xs). diff --git a/pl/init.yap b/pl/init.yap index 33ca7edf6..8e0bbb0c4 100644 --- a/pl/init.yap +++ b/pl/init.yap @@ -119,7 +119,7 @@ print_message(_, loaded(F,C,_M,T,H)) :- !, print_message(_, Msg) :- format(user_error, '~w ~n', [Msg]). -:- bootstrap('errors.yap'). +:- bootstrap( 'arith.yap'). :- bootstrap('lists.yap'). :- bootstrap('consult.yap'). :- bootstrap('preddecls.yap'). @@ -129,14 +129,14 @@ print_message(_, Msg) :- :- bootstrap('atoms.yap'). :- bootstrap('os.yap'). :- bootstrap('absf.yap'). -xs%:- start_low_level_trace. +%:- Start_low_level_trace. :-set_prolog_flag(verbose, normal). :-set_prolog_flag(gc_trace, verbose). %:- set_prolog_flag( verbose_file_search, true ). :- [ - 'arith.yap', + 'errors.yap', 'directives.yap', 'utils.yap', 'control.yap',