try to improve error handling and warnings from within consults.
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1280 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
3ecff9c37a
commit
668a3dce2b
@ -371,7 +371,7 @@ Yap_Error(yap_error_number type, Term where, char *format,...)
|
|||||||
char *tp = tmpbuf;
|
char *tp = tmpbuf;
|
||||||
int psize = YAP_BUF_SIZE;
|
int psize = YAP_BUF_SIZE;
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG_STRICT
|
||||||
if (Yap_heap_regs && !(Yap_PrologMode & BootMode))
|
if (Yap_heap_regs && !(Yap_PrologMode & BootMode))
|
||||||
fprintf(stderr,"***** Processing Error %d (%lx,%x) %s***\n", type, (unsigned long int)ActiveSignals,Yap_PrologMode,format);
|
fprintf(stderr,"***** Processing Error %d (%lx,%x) %s***\n", type, (unsigned long int)ActiveSignals,Yap_PrologMode,format);
|
||||||
else
|
else
|
||||||
|
@ -11,8 +11,11 @@
|
|||||||
* File: checker.yap *
|
* File: checker.yap *
|
||||||
* comments: style checker for Prolog *
|
* comments: style checker for Prolog *
|
||||||
* *
|
* *
|
||||||
* Last rev: $Date: 2005-04-20 04:08:20 $,$Author: vsc $ *
|
* Last rev: $Date: 2005-04-20 20:06:11 $,$Author: vsc $ *
|
||||||
* $Log: not supported by cvs2svn $
|
* $Log: not supported by cvs2svn $
|
||||||
|
* Revision 1.17 2005/04/20 04:08:20 vsc
|
||||||
|
* fix warnings
|
||||||
|
*
|
||||||
* Revision 1.16 2005/01/13 05:47:27 vsc
|
* Revision 1.16 2005/01/13 05:47:27 vsc
|
||||||
* lgamma broke arithmetic optimisation
|
* lgamma broke arithmetic optimisation
|
||||||
* integer_y has type y
|
* integer_y has type y
|
||||||
@ -138,7 +141,7 @@ no_style_check([H|T]) :- no_style_check(H), no_style_check(T).
|
|||||||
'$number_of_clauses'(H,M,ClN0),
|
'$number_of_clauses'(H,M,ClN0),
|
||||||
ClN is ClN0+1
|
ClN is ClN0+1
|
||||||
),
|
),
|
||||||
print_message(warning,singletons(SVs,(M:Name/Arity),LN,ClN)).
|
print_message(warning,singletons(SVs,(M:Name/Arity),ClN)).
|
||||||
|
|
||||||
'$xtract_head'(V,M,M,V,call,1) :- var(V), !.
|
'$xtract_head'(V,M,M,V,call,1) :- var(V), !.
|
||||||
'$xtract_head'((H:-_),OM,M,NH,Name,Arity) :- !,
|
'$xtract_head'((H:-_),OM,M,NH,Name,Arity) :- !,
|
||||||
@ -158,8 +161,7 @@ no_style_check([H|T]) :- no_style_check(H), no_style_check(T).
|
|||||||
recorded('$discontiguous_defs','$df'(F,A,M),_), !.
|
recorded('$discontiguous_defs','$df'(F,A,M),_), !.
|
||||||
'$handle_discontiguous'(F,A,M) :-
|
'$handle_discontiguous'(F,A,M) :-
|
||||||
'$in_this_file_before'(F,A,M),
|
'$in_this_file_before'(F,A,M),
|
||||||
'$start_line'(LN),
|
print_message(warning,clauses_not_together((M:F/A))).
|
||||||
print_message(warning,clauses_not_together((M:F/A),LN)).
|
|
||||||
|
|
||||||
'$handle_multiple'(F,A,M) :-
|
'$handle_multiple'(F,A,M) :-
|
||||||
\+ '$first_clause_in_file'(F,A,M), !.
|
\+ '$first_clause_in_file'(F,A,M), !.
|
||||||
@ -182,7 +184,7 @@ no_style_check([H|T]) :- no_style_check(H), no_style_check(T).
|
|||||||
'$test_if_well_reconsulting'(F,F,_) :- !.
|
'$test_if_well_reconsulting'(F,F,_) :- !.
|
||||||
'$test_if_well_reconsulting'(_,Fil,P) :-
|
'$test_if_well_reconsulting'(_,Fil,P) :-
|
||||||
'$start_line'(LN),
|
'$start_line'(LN),
|
||||||
print_message(warning,defined_elsewhere(P,Fil,LN)).
|
print_message(warning,defined_elsewhere(P,Fil)).
|
||||||
|
|
||||||
'$multifile'(V, _) :- var(V), !,
|
'$multifile'(V, _) :- var(V), !,
|
||||||
'$do_error'(instantiation_error,multifile(V)).
|
'$do_error'(instantiation_error,multifile(V)).
|
||||||
|
@ -287,12 +287,15 @@ remove_from_path(New) :- '$check_path'(New,Path),
|
|||||||
'$add_multifile'(File,Name,Arity,Module).
|
'$add_multifile'(File,Name,Arity,Module).
|
||||||
|
|
||||||
'$add_multifile'(File,Name,Arity,Module) :-
|
'$add_multifile'(File,Name,Arity,Module) :-
|
||||||
recordzifnot('$multifile_defs','$defined'(File,Name,Arity,Module),_), !,
|
recorded('$multifile_defs','$defined'(File,Name,Arity,Module), _), !,
|
||||||
|
'$print_message'(warning,declaration((multifile Module:Name/Arity),ignored)).
|
||||||
|
'$add_multifile'(File,Name,Arity,Module) :-
|
||||||
|
recordz('$multifile_defs','$defined'(File,Name,Arity,Module),_), !,
|
||||||
fail.
|
fail.
|
||||||
'$add_multifile'(File,Name,Arity,Module) :-
|
'$add_multifile'(File,Name,Arity,Module) :-
|
||||||
recorded('$mf','$mf_clause'(File,Name,Arity,Module,Ref),R),
|
recorded('$mf','$mf_clause'(File,Name,Arity,Module,Ref),R),
|
||||||
erase(R),
|
erase(R),
|
||||||
erase(Ref),
|
'$erase_clause'(Ref,Module),
|
||||||
fail.
|
fail.
|
||||||
'$add_multifile'(_,_,_,_).
|
'$add_multifile'(_,_,_,_).
|
||||||
|
|
||||||
|
@ -11,8 +11,14 @@
|
|||||||
* File: errors.yap *
|
* File: errors.yap *
|
||||||
* comments: error messages for YAP *
|
* comments: error messages for YAP *
|
||||||
* *
|
* *
|
||||||
* Last rev: $Date: 2005-04-07 17:55:05 $,$Author: ricroc $ *
|
* Last rev: $Date: 2005-04-20 20:06:26 $,$Author: vsc $ *
|
||||||
* $Log: not supported by cvs2svn $
|
* $Log: not supported by cvs2svn $
|
||||||
|
* Revision 1.62 2005/04/07 17:55:05 ricroc
|
||||||
|
* Adding tabling support for mixed strategy evaluation (batched and local scheduling)
|
||||||
|
* UPDATE: compilation flags -DTABLING_BATCHED_SCHEDULING and -DTABLING_LOCAL_SCHEDULING removed. To support tabling use -DTABLING in the Makefile or --enable-tabling in configure.
|
||||||
|
* NEW: yap_flag(tabling_mode,MODE) changes the tabling execution mode of all tabled predicates to MODE (batched, local or default).
|
||||||
|
* NEW: tabling_mode(PRED,MODE) changes the default tabling execution mode of predicate PRED to MODE (batched or local).
|
||||||
|
*
|
||||||
* Revision 1.61 2005/02/21 16:50:21 vsc
|
* Revision 1.61 2005/02/21 16:50:21 vsc
|
||||||
* amd64 fixes
|
* amd64 fixes
|
||||||
* library fixes
|
* library fixes
|
||||||
@ -107,8 +113,10 @@ print_message(Level, Mss) :-
|
|||||||
( var(Msg) ; var(Info) ), !,
|
( var(Msg) ; var(Info) ), !,
|
||||||
format(user_error,'% YAP: no handler for error ~w~n', [error(Msg,Info)]).
|
format(user_error,'% YAP: no handler for error ~w~n', [error(Msg,Info)]).
|
||||||
'$print_message'(error,error(syntax_error(A,B,C,D,E,F),_)) :- !,
|
'$print_message'(error,error(syntax_error(A,B,C,D,E,F),_)) :- !,
|
||||||
|
'$output_error_location',
|
||||||
'$output_error_message'(syntax_error(A,B,C,D,E,F), 'SYNTAX ERROR').
|
'$output_error_message'(syntax_error(A,B,C,D,E,F), 'SYNTAX ERROR').
|
||||||
'$print_message'(error,error(Msg,[Info|local_sp(Where,Envs,CPs)])) :-
|
'$print_message'(error,error(Msg,[Info|local_sp(Where,Envs,CPs)])) :-
|
||||||
|
'$output_error_location',
|
||||||
'$prepare_loc'(Info,Where,Location),
|
'$prepare_loc'(Info,Where,Location),
|
||||||
'$output_error_message'(Msg, Location), !,
|
'$output_error_message'(Msg, Location), !,
|
||||||
'$do_stack_dump'(Envs, CPs).
|
'$do_stack_dump'(Envs, CPs).
|
||||||
@ -123,6 +131,7 @@ print_message(Level, Mss) :-
|
|||||||
true
|
true
|
||||||
).
|
).
|
||||||
'$print_message'(warning,M) :-
|
'$print_message'(warning,M) :-
|
||||||
|
'$output_error_location',
|
||||||
format(user_error, '% ', []),
|
format(user_error, '% ', []),
|
||||||
'$do_print_message'(M),
|
'$do_print_message'(M),
|
||||||
format(user_error, '~n', []).
|
format(user_error, '~n', []).
|
||||||
@ -130,6 +139,18 @@ print_message(Level, Mss) :-
|
|||||||
'$do_print_message'(M),
|
'$do_print_message'(M),
|
||||||
format(user_error, '~n', []).
|
format(user_error, '~n', []).
|
||||||
|
|
||||||
|
'$output_error_location' :-
|
||||||
|
get_value('$consulting_file',FileName),
|
||||||
|
FileName \= [],
|
||||||
|
'$start_line'(LN),
|
||||||
|
'$show_consult_level'(LC),
|
||||||
|
'$output_file_pos'(FileName,LN,LC),
|
||||||
|
format(user_error, '~*|', [LC]).
|
||||||
|
|
||||||
|
'$output_file_pos'(user_input,LN,LC) :- !,
|
||||||
|
format(user_error,'~*|% In user_input near line ~d,~n',[LC,LN]).
|
||||||
|
'$output_file_pos'(FileName,LN,LC) :-
|
||||||
|
format(user_error,'~*|% In file ~a, near line ~d,~n',[LC,FileName,LN]).
|
||||||
|
|
||||||
'$do_informational_message'(halt) :- !,
|
'$do_informational_message'(halt) :- !,
|
||||||
format(user_error, '% YAP execution halted~n', []).
|
format(user_error, '% YAP execution halted~n', []).
|
||||||
@ -173,15 +194,17 @@ print_message(Level, Mss) :-
|
|||||||
'$do_print_message'(breakpoints(L)) :- !,
|
'$do_print_message'(breakpoints(L)) :- !,
|
||||||
format(user_error,'Spy-points set on:', []),
|
format(user_error,'Spy-points set on:', []),
|
||||||
'$print_list_of_preds'(L).
|
'$print_list_of_preds'(L).
|
||||||
'$do_print_message'(clauses_not_together(P,LN)) :- !,
|
'$do_print_message'(clauses_not_together(P)) :- !,
|
||||||
format(user_error, 'Discontiguous definition of ~q, at line ~d.',[P,LN]).
|
format(user_error, 'Discontiguous definition of ~q.',[P]).
|
||||||
'$do_print_message'(debug(debug)) :- !,
|
'$do_print_message'(debug(debug)) :- !,
|
||||||
format(user_error,'Debug mode on.',[]).
|
format(user_error,'Debug mode on.',[]).
|
||||||
'$do_print_message'(debug(off)) :- !,
|
'$do_print_message'(debug(off)) :- !,
|
||||||
format(user_error,'Debug mode off.',[]).
|
format(user_error,'Debug mode off.',[]).
|
||||||
'$do_print_message'(debug(trace)) :- !,
|
'$do_print_message'(debug(trace)) :- !,
|
||||||
format(user_error,'Trace mode on.',[]).
|
format(user_error,'Trace mode on.',[]).
|
||||||
'$do_print_message'(defined_elsewhere(P,F,LN)) :- !,
|
'$do_print_message'(declaration(Args,Action)) :- !,
|
||||||
|
format(user_error,'declaration ~w ~w.', [Args,Action]).
|
||||||
|
'$do_print_message'(defined_elsewhere(P,F)) :- !,
|
||||||
format(user_error, 'predicate ~q, at line ~d, previously defined in file ~a.',[P,LN,F]).
|
format(user_error, 'predicate ~q, at line ~d, previously defined in file ~a.',[P,LN,F]).
|
||||||
'$do_print_message'(import(Pred,To,From,private)) :- !,
|
'$do_print_message'(import(Pred,To,From,private)) :- !,
|
||||||
format(user_error,'Importing private predicate ~w:~w to ~w.',
|
format(user_error,'Importing private predicate ~w:~w to ~w.',
|
||||||
@ -200,10 +223,10 @@ print_message(Level, Mss) :-
|
|||||||
'$do_print_message'(leash([A|B])) :- !,
|
'$do_print_message'(leash([A|B])) :- !,
|
||||||
format(user_error,'Leashing set to ~w.',
|
format(user_error,'Leashing set to ~w.',
|
||||||
[[A|B]]).
|
[[A|B]]).
|
||||||
'$do_print_message'(singletons(SVs,P,LN,CLN)) :- !,
|
'$do_print_message'(singletons(SVs,P,CLN)) :- !,
|
||||||
format(user_error, 'Singleton variable',[]),
|
format(user_error, 'Singleton variable',[]),
|
||||||
'$write_svs'(SVs),
|
'$write_svs'(SVs),
|
||||||
format(user_error, ' in ~q at line ~d, clause ~d.',[P,LN,CLN]).
|
format(user_error, ' in ~q, clause ~d.',[P,CLN]).
|
||||||
'$do_print_message'(trace_help) :- !,
|
'$do_print_message'(trace_help) :- !,
|
||||||
format(user_error,' Please enter a valid debugger command (h for help).', []).
|
format(user_error,' Please enter a valid debugger command (h for help).', []).
|
||||||
'$do_print_message'(version(Version)) :- !,
|
'$do_print_message'(version(Version)) :- !,
|
||||||
@ -633,12 +656,12 @@ print_message(Level, Mss) :-
|
|||||||
format(user_error,'% REPRESENTATION ERROR- ~w: number too big~n',
|
format(user_error,'% REPRESENTATION ERROR- ~w: number too big~n',
|
||||||
[Where]).
|
[Where]).
|
||||||
'$output_error_message'(syntax_error(G,0,Msg,[],0,0), Where) :- !,
|
'$output_error_message'(syntax_error(G,0,Msg,[],0,0), Where) :- !,
|
||||||
format(user_error,'% SYNTAX ERROR in ~w: ~a~n',[G,Msg]).
|
format(user_error,'% SYNTAX ERROR: ~a',[G,Msg]).
|
||||||
'$output_error_message'(syntax_error(_,Position,_,Term,Pos,Start), Where) :-
|
'$output_error_message'(syntax_error(_,_,_,Term,Pos,Start), Where) :-
|
||||||
format(user_error,'% ~w ',[Where]),
|
format(user_error,'% ~w ',[Where]),
|
||||||
'$dump_syntax_error_line'(Start,Position),
|
% '$dump_syntax_error_line'(Start,Position),
|
||||||
'$dump_syntax_error_term'(10,Pos, Term),
|
'$dump_syntax_error_term'(10,Pos, Term),
|
||||||
format(user_error,'.~n]~n',[]).
|
format(user_error,'.~n',[]).
|
||||||
'$output_error_message'(system_error, Where) :-
|
'$output_error_message'(system_error, Where) :-
|
||||||
format(user_error,'% SYSTEM ERROR- ~w~n',
|
format(user_error,'% SYSTEM ERROR- ~w~n',
|
||||||
[Where]).
|
[Where]).
|
||||||
@ -731,9 +754,8 @@ print_message(Level, Mss) :-
|
|||||||
[Where]).
|
[Where]).
|
||||||
|
|
||||||
|
|
||||||
'$dump_syntax_error_line'(Pos,_) :-
|
'$dump_syntax_error_line'(_,Position) :-
|
||||||
format(user_error,'at line ~d:~n',
|
format(user_error,'% near line ~d,~n',[Position]).
|
||||||
[Pos]).
|
|
||||||
|
|
||||||
'$dump_syntax_error_term'(0,J,L) :- !,
|
'$dump_syntax_error_term'(0,J,L) :- !,
|
||||||
format(user_error,'~n', []),
|
format(user_error,'~n', []),
|
||||||
|
Reference in New Issue
Block a user