This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/pl/messages.yap

1100 lines
37 KiB
Plaintext
Raw Normal View History

/*************************************************************************
* *
* YAP Prolog *
* *
2016-05-15 08:12:49 +01:00
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: utilities for displaying messages in YAP. *
* comments: error messages for YAP *
* *
* Last rev: $Date: 2008-07-16 10:58:59 $,$Author: vsc $ *
* *
* *
*************************************************************************/
2015-01-04 23:58:23 +00:00
/**
* @file messages.yap
* @author VITOR SANTOS COSTA <vsc@VITORs-MBP.lan>
* @date Thu Nov 19 10:22:26 2015
2016-03-03 23:23:32 +00:00
*
* @brief The YAP Message Handler
2016-03-03 23:23:32 +00:00
*
*
*/
2018-06-26 15:35:47 +01:00
:- module(system('$messages',[]),
2018-10-29 10:42:36 +00:00
[system_message/4,
prefix/2,
%prefix/5,
file_location/3]).
2018-06-05 20:51:49 +01:00
/**
2015-01-04 23:58:23 +00:00
@defgroup Messages Message Handling
2018-06-05 20:51:49 +01:00
@{
2015-01-04 23:58:23 +00:00
@ingroup YAPControl
2014-09-11 20:06:57 +01:00
The interaction between YAP and the user relies on YAP's ability to
portray messages. These messages range from prompts to error
information. All message processing is performed through the builtin
print_message/2, in two steps:
2014-12-24 15:32:29 +00:00
+ The message is processed into a list of commands
2014-09-11 20:06:57 +01:00
+ The commands in the list are sent to the `format/3` builtin
in sequence.
The first argument to print_message/2 specifies the importance of
the message. The options are:
+ `error`
error handling
+ `warning`
compilation and run-time warnings,
+ `informational`
generic informational messages
+ `help`
help messages (not currently implemented in YAP)
+ `query`
query used in query processing (not currently implemented in YAP)
2015-09-29 23:09:12 +01:00
+ `silent`,M,Na,Ar,File, FilePos]],
2018-10-29 10:42:36 +00:00
[nl, nl].
2015-09-29 23:09:12 +01:00
caller( error(_,Term), _) -->
2018-10-29 10:42:36 +00:00
{ lists:memberchk([g|g(Call)], Term) },
['~*|called from
2014-09-11 20:06:57 +01:00
messages that do not produce output but that can be intercepted by hooks.
The next table shows the main predicates and hooks associated to message
handling in YAP:
2016-11-08 07:37:36 +00:00
An error record comsists of An ISO compatible descriptor of the format
2018-04-07 19:45:18 +01:00
error(errror_kind(Culprit,..), In)
2016-11-08 07:37:36 +00:00
2018-01-05 16:57:38 +00:00
In YAP, the info field describes:
2016-11-08 07:37:36 +00:00
- what() more detauls on the event
2018-01-05 16:57:38 +00:00
- input_stream, may be one of;
2016-11-08 07:37:36 +00:00
2018-10-29 10:42:36 +00:00
- loop_stream
- file()
- none
2016-12-06 07:50:11 +00:00
2018-10-29 10:42:36 +00:00
- prolog_source(_) a record containing file, line, predicate, and clause
2016-11-08 07:37:36 +00:00
that activated the goal, or a list therof. YAP tries to search for the user
code generatinng the error.
- c_source(0), a record containing the line of C-code thhat caused the event. This
is reported under systm debugging mode, or if this is user code.
- stream_source() - a record containg data on the the I/O stream datum causisng the evwnt.
- user_message () - ttext on the event.
2014-09-11 20:06:57 +01:00
*/
2016-04-18 13:25:23 +01:00
2018-01-22 13:53:17 +00:00
:- abolish(prolog:print_message/2).
2014-09-11 20:06:57 +01:00
:- use_system_module( user, [message_hook/3]).
2014-04-09 12:39:29 +01:00
2017-06-06 12:47:59 +01:00
%:- start_low_level_trace.
2014-04-21 11:29:05 +01:00
:- multifile prolog:message/3.
2017-06-06 12:47:59 +01:00
%:- stop_low_level_trace.
:- multifile user:message_hook/3.
2014-01-07 01:10:48 +00:00
/** @pred message_to_string(+ _Term_, - _String_)
Translates a message-term into a string object. Primarily intended for SWI-Prolog emulation.
*/
prolog:message_to_string(Event, Message) :-
2018-10-29 10:42:36 +00:00
translate_message(Event, warning, Message, []).
%% @pred compose_message(+Term, +Level, +Lines, -Lines0) is det
%
% Print the message if the user did not intercept the message.
% The first is used for errors and warnings that can be related
% to source-location. Note that syntax errors have their own
% source-location and should therefore not be handled this way.
2018-10-29 13:32:29 +00:00
compose_message( Term, _Level ) -->
message(Term), !.
compose_message( query(_QueryResult,_), _Level) -->
2018-10-29 10:42:36 +00:00
[].
2016-02-11 14:17:30 +00:00
compose_message( absolute_file_path(File), _Level) -->
2018-10-29 10:42:36 +00:00
[ '~N~n absolute_file of ~w' - [File] ].
2015-09-21 23:05:36 +01:00
compose_message( absolute_file_path(Msg, Args), _Level) -->
2018-10-29 10:42:36 +00:00
[ ' : ' - [],
Msg - Args,
nl ].
2016-02-11 14:17:30 +00:00
compose_message( arguments([]), _Level) -->
2018-10-29 10:42:36 +00:00
[].
2016-02-11 14:17:30 +00:00
compose_message( arguments([A|As]), Level) -->
2018-10-29 10:42:36 +00:00
[ ' ~w' - [A],
nl ],
compose_message( arguments(As), Level).
compose_message( ancestors([]), _Level) -->
2018-10-29 10:42:36 +00:00
[ 'There are no ancestors.' ].
compose_message( breakp(bp(debugger,_,_,M:F/N,_),add,already), _Level) -->
2018-10-29 10:42:36 +00:00
[ 'There is already a spy point on ~w:~w/~w.' - [M,F,N] ].
compose_message( breakp(bp(debugger,_,_,M:F/N,_),add,ok), _Level) -->
2018-10-29 10:42:36 +00:00
[ 'Spy point set on ~w:~w/~w.' - [M,F,N] ].
compose_message( breakp(bp(debugger,_,_,M:F/N,_),remove,last), _Level) -->
2018-10-29 10:42:36 +00:00
[ 'Spy point on ~w:~w/~w removed.' - [M,F,N] ].
compose_message( breakp(no,breakpoint_for,M:F/N), _Level) -->
2018-10-29 10:42:36 +00:00
[ 'There is no spy point on ~w:~w/~w.' - [M,F,N] ].
compose_message( breakpoints([]), _Level) -->
2018-10-29 10:42:36 +00:00
[ 'There are no spy-points set.' ].
compose_message( breakpoints(L), _Level) -->
2018-10-29 10:42:36 +00:00
[ 'Spy-points set on:' ],
list_of_preds(L).
compose_message( clauses_not_together(P), _Level) -->
2018-10-29 10:42:36 +00:00
[ 'Discontiguous definition of ~q.' - [P] ].
compose_message( debug(debug), _Level) -->
2018-10-29 10:42:36 +00:00
[ 'Debug mode on.' - [] ].
compose_message( debug(off), _Level) -->
2018-10-29 10:42:36 +00:00
[ 'Debug mode off.'- [] ].
compose_message( debug(trace), _Level) -->
2018-10-29 10:42:36 +00:00
[ 'Trace mode on.'- [] ].
compose_message( declaration(Args,Action), _Level) -->
2018-10-29 10:42:36 +00:00
[ 'declaration ~w ~w.' - [Args,Action] ].
compose_message( defined_elsewhere(P,F), _Level) -->
2018-10-29 10:42:36 +00:00
[ 'predicate ~q previously defined in file ~w' - [P,F] ].
compose_message( functionality(Library), _Level) -->
2018-10-29 10:42:36 +00:00
[ '~q not available' - [Library] ].
compose_message( import(Pred,To,From,private), _Level) -->
2018-10-29 10:42:36 +00:00
[ 'Importing private predicate ~w:~w to ~w.' - [From,Pred,To] ].
compose_message( redefine_imported(M,M0,PI), _Level) -->
2018-10-29 10:42:36 +00:00
{ source_location(ParentF, Line) },
[ '~w:~w: Module ~w redefines imported predicate ~w:~w.' - [ParentF, Line, M,M0,PI] ].
compose_message( leash([]), _Level) -->
2018-10-29 10:42:36 +00:00
[ 'No leashing.' ].
compose_message( leash([A|B]), _Level) -->
2018-10-29 10:42:36 +00:00
[ 'Leashing set to ~w.' - [[A|B]] ].
compose_message( no, _Level) -->
2018-10-29 10:42:36 +00:00
[ 'no' - [] ].
compose_message( no_match(P), _Level) -->
2018-10-29 10:42:36 +00:00
[ 'No matching predicate for ~w.' - [P] ].
compose_message( leash([A|B]), _Level) -->
2018-10-29 10:42:36 +00:00
[ 'Leashing set to ~w.' - [[A|B]] ].
compose_message( halt, _Level) --> !,
2018-10-29 10:42:36 +00:00
[ 'YAP execution halted.'-[] ].
2018-10-29 10:42:36 +00:00
% syntax error.
2018-10-25 13:57:18 +01:00
compose_message( error(event(Type),Info), _Level ) -->
!,
event(Type, Info).
2018-10-22 12:38:13 +01:00
compose_message(error(warning(syntax_error,Info), Exc), Level) -->
!,
compose_message(error(syntax_error(Info), Exc), Level).
compose_message(error(E, Exc), Level) -->
2018-10-22 12:38:13 +01:00
{
2018-10-31 00:35:49 +00:00
'$show_consult_level'(LC)
2018-10-22 12:38:13 +01:00
},
location(error(E, Exc), Level, LC),
2018-07-02 15:20:17 +01:00
main_message(error(E,Exc) , Level, LC ),
2018-10-22 12:38:13 +01:00
c_goal( error(E, Exc), Level ),
caller( error(E, Exc), Level ),
extra_info( error(E, Exc), Level ),
2018-10-31 00:35:49 +00:00
stack_info( error(E, Exc), Level ),
% { stop_low_level_trace },
2018-10-22 12:38:13 +01:00
!,
[nl],
[nl].
compose_message( false, _Level) --> !,
2018-10-29 10:42:36 +00:00
[ 'false.'-[] ].
compose_message( '$abort', _Level) --> !,
2018-10-29 10:42:36 +00:00
[ 'YAP execution aborted'-[] ].
compose_message( abort(user), _Level) --> !,
2018-10-29 10:42:36 +00:00
[ 'YAP execution aborted' - [] ].
compose_message( loading(_,F), _Level) --> { F == user }, !.
compose_message( loading(What,FileName), _Level) --> !,
2018-10-29 10:42:36 +00:00
[ '~a ~w...' - [What, FileName] ].
compose_message( loaded(_,user,_,_,_), _Level) --> !.
compose_message( loaded(included,AbsFileName,Mod,Time,Space), _Level) --> !,
2018-10-29 10:42:36 +00:00
[ '~a included in module ~a, ~d msec ~d bytes' -
[AbsFileName,Mod,Time,Space] ].
compose_message( loaded(What,AbsoluteFileName,Mod,Time,Space), _Level) --> !,
2018-10-29 10:42:36 +00:00
[ '~a ~a in module ~a, ~d msec ~d bytes' -
[What, AbsoluteFileName,Mod,Time,Space] ].
2018-04-09 02:00:51 +01:00
compose_message(signal(SIG,_), _) -->
2018-10-29 10:42:36 +00:00
!,
[ 'UNEXPECTED SIGNAL: ~a' - [SIG] ].
compose_message(trace_command(C), _Leve) -->
2018-10-29 10:42:36 +00:00
!,
[ '~a is not a valid debugger command.' - [C] ].
compose_message(trace_help, _Leve) -->
2018-10-29 10:42:36 +00:00
!,
[ ' Please enter a valid debugger command (h for help).' ].
2018-10-25 13:57:18 +01:00
compose_message(version(Version), _Level) -->
2018-10-29 10:42:36 +00:00
!,
[ '~a' - [Version] ].
compose_message(myddas_version(Version), _Leve) -->
2018-10-29 10:42:36 +00:00
!,
[ 'MYDDAS version ~a' - [Version] ].
compose_message(style_check(What,FILE,Line,Clause), Level)-->
!,
{ '$show_consult_level'(LC) },
2018-10-29 10:42:36 +00:00
location(style_check(What,FILE,Line,Clause), Level, LC),
main_message(style_check(What,FILE,Line,Clause) , Level, LC ).
compose_message(yes, _Level) --> !,
2018-10-29 10:42:36 +00:00
[ 'yes'- [] ].
2018-07-17 11:43:57 +01:00
compose_message(Throw, _Level) -->
2018-10-29 10:42:36 +00:00
!,
[ 'UNHANDLED EXCEPTION - message ~w unknown' - [Throw] ].
2018-04-07 19:45:18 +01:00
2018-10-23 10:09:17 +01:00
location( error(_,Info), Level, _LC ) -->
2018-10-22 12:38:13 +01:00
{ '$error_descriptor'(Info, Desc) },
2018-10-23 10:09:17 +01:00
{ query_exception(prologConsulting, Desc, true) },
{ query_exception(parserReadingCode, Desc, true)},
2018-10-22 12:38:13 +01:00
!,
{
2018-10-29 10:42:36 +00:00
query_exception(parserFile, Desc, FileName),
query_exception(parserLine, Desc, LN)
2018-10-22 12:38:13 +01:00
},
2018-10-23 10:09:17 +01:00
[ '~a:~d:~d: ~a:' - [FileName,LN,0,Level] ] .
2018-06-22 23:55:50 +01:00
location(style_check(A,LN,FileName,B ), Level , LC) -->
2018-10-29 10:42:36 +00:00
!,
display_consulting( FileName, Level,style_check(A,LN,FileName,B ), LC ),
[ '~a:~d:0: ~a: ' - [FileName,LN,Level] ] .
location( error(_,Info), Level, LC ) -->
2018-07-02 15:20:17 +01:00
{ '$error_descriptor'(Info, Desc) },
2018-09-14 11:28:24 +01:00
{
2018-10-29 10:42:36 +00:00
query_exception(prologPredFile, Desc, File),
query_exception(prologPredLine, Desc, FilePos),
query_exception(prologPredModule, Desc, M),
query_exception(prologPredName, Desc, Na),
2018-10-31 00:35:49 +00:00
query_exception(prologPredArity, Desc, Ar)
2018-09-14 11:28:24 +01:00
},
2018-06-14 11:27:43 +01:00
!,
2018-10-29 10:24:32 +00:00
display_consulting( File, Level, Info, LC ),
2018-09-11 01:50:17 +01:00
{simplify_pred(M:Na/Ar,FF)},
2018-10-31 00:35:49 +00:00
[ '~a:~d:0 ~a while executing ~q:'-[File, FilePos,Level,FF] ].
2018-06-14 11:27:43 +01:00
location( error(_,Info), Level, LC ) -->
2018-10-29 10:42:36 +00:00
{ '$error_descriptor'(Info, Desc) },
2018-06-14 11:27:43 +01:00
{
2018-07-10 23:21:19 +01:00
query_exception(errorFile, Desc, File),
2018-10-29 10:42:36 +00:00
query_exception(errorLine, Desc, FilePos),
query_exception(errorFunction, Desc, F)
},
2018-06-14 11:27:43 +01:00
!,
display_consulting( File, Level, Info, LC ),
2018-09-11 01:50:17 +01:00
{simplify_pred(F,FF)},
2018-10-29 10:42:36 +00:00
[ '~a:~d:0 ~a while executing ~a().'-[File, FilePos,Level,FF] ].
location( _Ball, _Level, _LC ) --> [].
2018-10-25 13:57:18 +01:00
event(redo, _Info) --> {fail}.
event(fail, _Info) --> {fail}.
event(abort, Info) --> { throw(event(abort, Info)) }.
2018-09-11 01:50:17 +01:00
simplify_pred(user:F, F) :- !.
simplify_pred(prolog:F, F) :- !.
simplify_pred(F, F).
%message(loaded(Past,AbsoluteFileName,user,Msec,Bytes), Prefix, Suffix) :- !,
main_message(error(Msg,In), _, _) --> {var(Msg)}, !,
2018-10-29 10:42:36 +00:00
[ 'Uninstantiated message ~w~n.' - [error(Msg,In)], nl ].
2018-10-22 12:38:13 +01:00
main_message( error(syntax_error(Msg),Info), Level, _LC ) -->
!,
{
'$error_descriptor'(Info, Desc),
query_exception(parserTextA, Desc, J),
query_exception(parserTextB, Desc, T),
query_exception(parserLine, Desc, L)
2018-10-29 10:42:36 +00:00
},
[' syntax error ~s' - [Level,Msg]],
[nl],
[' ~s <<== at line ~d == ~s !' - [J,L,T], nl ].
2018-04-18 15:13:11 +01:00
main_message(style_check(singleton(SVs),_Pos,_File,P), _Level, _LC) -->
!,
% {writeln(ci)},
2018-10-29 10:42:36 +00:00
{ clause_to_indicator(P, I) },
[ nl, '~*|singleton variable~*c ~w in ~q.' - [ 10, NVs, 0's, SVsL, I] ],
{ svs(SVs,SVs,SVsL),
( SVs = [_] -> NVs = 0 ; NVs = 1 )
}.
2018-04-18 15:13:11 +01:00
main_message(style_check(multiple(N,A,Mod,I0),_Pos,File,_P), _Level, _LC) -->
!,
2018-09-11 01:50:17 +01:00
[ '~*|~a redefines ~q, originally defined in ~a.' - [ 10,File, Mod:N/A, I0] ].
2018-04-18 15:13:11 +01:00
main_message(style_check(discontiguous(N,A,Mod),_S,_W,_P) , _Level, _LC)-->
!,
2018-09-11 01:50:17 +01:00
[ '~*|discontiguous definition for ~p.' - [ 10,Mod:N/A] ].
main_message(error(ErrorInfo,_), _Level, _LC) -->
2018-10-29 10:42:36 +00:00
[nl],
main_error_message( ErrorInfo ),
[nl].
2018-09-11 01:50:17 +01:00
main_error_message(consistency_error(Who)) -->
[ '~*|** argument ~a not consistent with type **'-[ 10,Who] ].
main_error_message(domain_error(Who , Type)) -->
[ '~*|** ~q does not belong to domain ~a ** ' - [ 10,Type,Who], nl ].
main_error_message(evaluation_error(What)) -->
[ '~*|** found ~w during evaluation of arithmetic expression **' - [ 10,What], nl ].
main_error_message(evaluation_error(What, Who)) -->
[ '~*|** ~w caused ~a during evaluation of arithmetic expressions **' - [ 10,Who,What], nl ].
main_error_message(existence_error(Type , Who)) -->
2018-10-29 10:42:36 +00:00
[nl],
2018-09-11 01:50:17 +01:00
[ '~*|** ~q ~q could not be found **' - [ 10,Type, Who], nl ].
2018-10-10 12:33:05 +01:00
main_error_message(permission_error(Op, Type, Id)) -->
2018-10-29 10:42:36 +00:00
[ '~*|** value ~q is not allowed in ~a ~q **' - [ 10, Op, Type,Id], nl ].
2018-10-10 12:33:05 +01:00
main_error_message(instantiation_error) -->
2018-10-29 10:42:36 +00:00
[ '~*|** unbound variable **' - [10], nl ].
2018-09-11 01:50:17 +01:00
main_error_message(representation_error(Type)) -->
2018-10-29 10:42:36 +00:00
[ '~*|** YAP cannot represent ~w **' - [10, Type], nl ].
2018-09-11 01:50:17 +01:00
main_error_message(resource_error(Who)) -->
2018-10-29 10:42:36 +00:00
[ '~*|** ~q **' - [10,Who]],
[ nl ].
2018-09-11 01:50:17 +01:00
main_error_message(type_error(Type,Who)) -->
2018-10-29 10:42:36 +00:00
[ '~*|** ~q should be of type ~a **' - [10,Who,Type]],
[ nl ].
2018-10-16 14:33:16 +01:00
main_error_message(system_error(Who, In)) -->
2018-10-29 10:42:36 +00:00
[ '~*|** ~q ~q **' - [10,Who, In]],
[ nl ].
2018-09-11 01:50:17 +01:00
main_error_message(uninstantiation_error(T)) -->
2018-10-29 10:42:36 +00:00
[ '~*|** found ~q, expected unbound variable **' - [10,T], nl ].
2016-03-03 23:23:32 +00:00
2018-06-14 11:27:43 +01:00
display_consulting( F, Level, Info, LC) -->
{ LC > 0,
'$error_descriptor'(Info, Desc),
2018-07-10 23:21:19 +01:00
query_exception(prologParserFile, Desc, F0),
2018-09-14 11:28:24 +01:00
query_exception(prologParserLine, Desc, L),
2018-06-14 11:27:43 +01:00
F \= F0
}, !,
[ '~a:~d:0: ~a raised at:'-[F0,L,Level], nl ].
display_consulting( F, Level, _, LC) -->
2018-10-29 10:42:36 +00:00
{ LC > 0,
source_location(F0, L),
F \= F0
}, !,
[ '~a:~d:0: ~a while compiling.'-[F0,L,Level], nl ].
2018-06-14 11:27:43 +01:00
display_consulting(_F, _, _, _LC) -->
2018-10-29 10:42:36 +00:00
[].
2015-10-05 10:38:54 +01:00
2018-09-11 01:50:17 +01:00
c_goal( error(_,Info), _) -->
{ '$error_descriptor'(Info, Desc) },
2018-07-10 23:21:19 +01:00
({ query_exception(errorGoal, Desc, Call),
2018-10-29 10:42:36 +00:00
Call = M:(H :- G)
}
->
2018-05-13 12:59:17 +01:00
['~*|at ~w' - [10,M:G],
'~*|called from ~w' - [10,H]
]
;
2018-10-29 10:42:36 +00:00
{Call \= []}
2018-05-13 12:59:17 +01:00
->
['~*|by ~w' - [10,Call]]
;
2018-06-28 12:48:29 +01:00
[]
),
2018-10-29 10:42:36 +00:00
!.
2018-09-11 01:50:17 +01:00
c_goal(_,_) --> [].
2015-09-29 23:09:12 +01:00
2018-10-23 10:09:17 +01:00
caller( error(syntax_error(_),_Info), _Level ) --> !.
2018-09-11 01:50:17 +01:00
caller( error(_,Info), Level ) -->
{ '$error_descriptor'(Info, Desc) },
2018-07-10 23:21:19 +01:00
{ query_exception(errorFile, Desc, File),
2018-09-11 01:50:17 +01:00
File \= [],
query_exception(errorFunction, Desc, Func),
2018-04-04 01:37:15 +01:00
Func \= [],
2018-07-10 23:21:19 +01:00
query_exception(errorLine, Desc, Line)
2018-04-04 01:37:15 +01:00
},
2018-10-29 10:42:36 +00:00
!,
['~*|~a raised by foreign-function ~a(), at ~a:~d:0: '-[10, Level, Func, File, Line]],
[nl].
2018-09-11 01:50:17 +01:00
caller( _, _Level ) --> [].
extra_info( error(_,Info), _ ) -->
{ '$error_descriptor'(Info, Desc) },
{
2018-10-29 10:42:36 +00:00
query_exception(errorMsg, Desc, Msg),
Msg \= []
2018-09-11 01:50:17 +01:00
},
!,
['~*|user provided data is: ~q' - [10,Msg]],
[nl].
extra_info( _, _ ) -->
2018-10-29 10:42:36 +00:00
[].
2015-09-21 23:05:36 +01:00
2018-10-31 00:35:49 +00:00
stack_info( error(_,Info), _ ) -->
{ '$error_descriptor'(Info, Desc) },
{
query_exception(prologStack, Desc, Stack),
Stack \= []
},
!,
['~*|Prolog execution stack is:' - [10]],
[nl],
[Stack - []].
stack_info( _, _ ) -->
[].
prolog_message(X) -->
2018-10-29 10:42:36 +00:00
system_message(X).
2018-04-07 19:45:18 +01:00
system_message(error(Msg,In)) -->
2018-10-29 10:42:36 +00:00
( { var(Msg) } ; { var(In)} ), !,
['bad error ~w' - [error(Msg,In)]].
system_message(error(consistency_error(Who),Where)) -->
2018-10-29 10:42:36 +00:00
[ 'CONSISTENCY ERROR (arguments not compatible with format)- ~w ~w' - [Who,Where] ].
system_message(error(context_error(Goal,Who),Where)) -->
2018-10-29 10:42:36 +00:00
[ 'CONTEXT ERROR- ~w: ~w appeared in ~w' - [Goal,Who,Where] ].
system_message(error(domain_error(DomainType,Opt), Where)) -->
2018-10-29 10:42:36 +00:00
[ 'DOMAIN ERROR- ~w: ' - Where],
domain_error(DomainType, Opt).
2013-03-20 02:23:55 +00:00
system_message(error(format_argument_type(Type,Arg), Where)) -->
2018-10-29 10:42:36 +00:00
[ 'FORMAT ARGUMENT ERROR- ~~~a called with ~w in ~w: ' - [Type,Arg,Where]].
2011-07-22 23:38:19 +01:00
system_message(error(existence_error(directory,Key), Where)) -->
2018-10-29 10:42:36 +00:00
[ 'EXISTENCE ERROR- ~w: ~w not an existing directory' - [Where,Key] ].
2011-07-22 23:38:19 +01:00
system_message(error(existence_error(key,Key), Where)) -->
2018-10-29 10:42:36 +00:00
[ 'EXISTENCE ERROR- ~w: ~w not an existing key' - [Where,Key] ].
2014-11-27 10:02:04 +00:00
system_message(error(existence_error(mutex,Key), Where)) -->
[ 'EXISTENCE ERROR- ~w: ~w is an erased mutex' - [Where,Key] ].
2011-07-22 23:38:19 +01:00
system_message(existence_error(prolog_flag,F)) -->
2018-10-29 10:42:36 +00:00
[ 'Prolog Flag ~w: new Prolog flags must be created using create_prolog_flag/3.' - [F] ].
2010-02-28 00:42:47 +00:00
system_message(error(existence_error(prolog_flag,P), Where)) --> !,
2018-10-29 10:42:36 +00:00
[ 'EXISTENCE ERROR- ~w: prolog flag ~w is undefined' - [Where,P] ].
system_message(error(existence_error(procedure,P), context(Call,Parent))) --> !,
2018-10-29 10:42:36 +00:00
[ 'EXISTENCE ERROR- procedure ~w is undefined, called from context ~w~n Goal was ~w' - [P,Parent,Call] ].
system_message(error(existence_error(stream,Stream), Where)) -->
2018-10-29 10:42:36 +00:00
[ 'EXISTENCE ERROR- ~w: ~w not an open stream' - [Where,Stream] ].
system_message(error(existence_error(thread,Thread), Where)) -->
2018-10-29 10:42:36 +00:00
[ 'EXISTENCE ERROR- ~w: ~w not a running thread' - [Where,Thread] ].
system_message(error(existence_error(variable,Var), Where)) -->
2018-10-29 10:42:36 +00:00
[ 'EXISTENCE ERROR- ~w: variable ~w does not exist' - [Where,Var] ].
system_message(error(existence_error(Name,F), W)) -->
2018-10-29 10:42:36 +00:00
{ object_name(Name, ObjName) },
[ 'EXISTENCE ERROR- ~w could not open ~a ~w' - [W,ObjName,F] ].
system_message(error(evaluation_error(int_overflow), Where)) -->
2018-10-29 10:42:36 +00:00
[ 'INTEGER OVERFLOW ERROR- ~w' - [Where] ].
system_message(error(evaluation_error(float_overflow), Where)) -->
2018-10-29 10:42:36 +00:00
[ 'FLOATING POINT OVERFLOW ERROR- ~w' - [Where] ].
system_message(error(evaluation_error(undefined), Where)) -->
2018-10-29 10:42:36 +00:00
[ 'UNDEFINED ARITHMETIC RESULT ERROR- ~w' - [Where] ].
system_message(error(evaluation_error(underflow), Where)) -->
2018-10-29 10:42:36 +00:00
[ 'UNDERFLOW ERROR- ~w' - [Where] ].
system_message(error(evaluation_error(float_underflow), Where)) -->
2018-10-29 10:42:36 +00:00
[ 'FLOATING POINT UNDERFLOW ERROR- ~w' - [Where] ].
system_message(error(evaluation_error(zero_divisor), Where)) -->
2018-10-29 10:42:36 +00:00
[ 'ZERO DIVISOR ERROR- ~w' - [Where] ].
system_message(error(not_implemented(Type, What), Where)) -->
2018-10-29 10:42:36 +00:00
[ '~w: ~w not implemented- ~w' - [Where, Type, What] ].
2015-09-25 10:57:26 +01:00
system_message(error(operating_SYSTEM_ERROR_INTERNAL, Where)) -->
2018-10-29 10:42:36 +00:00
[ 'OPERATING SYSTEM ERROR- ~w' - [Where] ].
system_message(error(out_of_heap_error, Where)) -->
2018-10-29 10:42:36 +00:00
[ 'OUT OF DATABASE SPACE ERROR- ~w' - [Where] ].
system_message(error(out_of_stack_error, Where)) -->
2018-10-29 10:42:36 +00:00
[ 'OUT OF STACK SPACE ERROR- ~w' - [Where] ].
system_message(error(out_of_trail_error, Where)) -->
2018-10-29 10:42:36 +00:00
[ 'OUT OF TRAIL SPACE ERROR- ~w' - [Where] ].
system_message(error(out_of_attvars_error, Where)) -->
2018-10-29 10:42:36 +00:00
[ 'OUT OF STACK SPACE ERROR- ~w' - [Where] ].
system_message(error(out_of_auxspace_error, Where)) -->
2018-10-29 10:42:36 +00:00
[ 'OUT OF AUXILIARY STACK SPACE ERROR- ~w' - [Where] ].
system_message(error(permission_error(access,private_procedure,P), Where)) -->
2018-10-29 10:42:36 +00:00
[ 'PERMISSION ERROR- ~w: cannot see clauses for ~w' - [Where,P] ].
system_message(error(permission_error(access,static_procedure,P), Where)) -->
2018-10-29 10:42:36 +00:00
[ 'PERMISSION ERROR- ~w: cannot access static procedure ~w' - [Where,P] ].
system_message(error(permission_error(alias,new,P), Where)) -->
2018-10-29 10:42:36 +00:00
[ 'PERMISSION ERROR- ~w: cannot create alias ~w' - [Where,P] ].
system_message(error(permission_error(create,Name,P), Where)) -->
2018-10-29 10:42:36 +00:00
[ 'PERMISSION ERROR- ~w: cannot create ~a ~w' - [Where,Name,P] ].
2014-07-17 18:19:38 +01:00
system_message(error(permission_error(import,M1:I,redefined,SecondMod), Where)) -->
2018-10-29 10:42:36 +00:00
[ 'PERMISSION ERROR- loading ~w: modules ~w and ~w both define ~w' - [Where,M1,SecondMod,I] ].
system_message(error(permission_error(input,binary_stream,Stream), Where)) -->
2018-10-29 10:42:36 +00:00
[ 'PERMISSION ERROR- ~w: cannot read from binary stream ~w' - [Where,Stream] ].
system_message(error(permission_error(input,closed_stream,Stream), Where)) -->
2018-10-29 10:42:36 +00:00
[ 'PERMISSION ERROR- ~w: trying to read from closed stream ~w' - [Where,Stream] ].
system_message(error(permission_error(input,past_end_of_stream,Stream), Where)) -->
2018-10-29 10:42:36 +00:00
[ 'PERMISSION ERROR- ~w: past end of stream ~w' - [Where,Stream] ].
system_message(error(permission_error(input,stream,Stream), Where)) -->
2018-10-29 10:42:36 +00:00
[ 'PERMISSION ERROR- ~w: cannot read from ~w' - [Where,Stream] ].
system_message(error(permission_error(input,text_stream,Stream), Where)) -->
2018-10-29 10:42:36 +00:00
[ 'PERMISSION ERROR- ~w: cannot read from text stream ~w' - [Where,Stream] ].
system_message(error(permission_error(modify,dynamic_procedure,_), Where)) -->
2018-10-29 10:42:36 +00:00
[ 'PERMISSION ERROR- ~w: modifying a dynamic procedure' - [Where] ].
system_message(error(permission_error(modify,flag,W), _)) -->
2018-10-29 10:42:36 +00:00
[ 'PERMISSION ERROR- cannot modify flag ~w' - [W] ].
2010-09-27 22:31:06 +01:00
system_message(error(permission_error(modify,operator,W), Q)) -->
2018-10-29 10:42:36 +00:00
[ 'PERMISSION ERROR- ~w: cannot modify operator ~q' - [Q,W] ].
system_message(error(permission_error(modify,dynamic_procedure,F), Where)) -->
2018-10-29 10:42:36 +00:00
[ 'PERMISSION ERROR- ~w: modifying dynamic procedure ~w' - [Where,F] ].
system_message(error(permission_error(modify,static_procedure,F), Where)) -->
2018-10-29 10:42:36 +00:00
[ 'PERMISSION ERROR- ~w: modifying static procedure ~w' - [Where,F] ].
system_message(error(permission_error(modify,static_procedure_in_use,_), Where)) -->
2018-10-29 10:42:36 +00:00
[ 'PERMISSION ERROR- ~w: modifying a static procedure in use' - [Where] ].
system_message(error(permission_error(modify,table,P), _)) -->
2018-10-29 10:42:36 +00:00
[ 'PERMISSION ERROR- cannot table procedure ~w' - [P] ].
system_message(error(permission_error(module,redefined,Mod), Who)) -->
2018-10-29 10:42:36 +00:00
[ 'PERMISSION ERROR ~w- redefining module ~a in a different file' - [Who,Mod] ].
system_message(error(permission_error(open,source_sink,Stream), Where)) -->
2018-10-29 10:42:36 +00:00
[ 'PERMISSION ERROR- ~w: cannot open file ~w' - [Where,Stream] ].
system_message(error(permission_error(output,binary_stream,Stream), Where)) -->
2018-10-29 10:42:36 +00:00
[ 'PERMISSION ERROR- ~w: cannot
write to binary stream ~w' - [Where,Stream] ].
system_message(error(permission_error(output,stream,Stream), Where)) -->
2018-10-29 10:42:36 +00:00
[ 'PERMISSION ERROR- ~w: cannot write to ~w' - [Where,Stream] ].
system_message(error(permission_error(output,text_stream,Stream), Where)) -->
2018-10-29 10:42:36 +00:00
[ 'PERMISSION ERROR- ~w: cannot write to text stream ~w' - [Where,Stream] ].
system_message(error(permission_error(resize,array,P), Where)) -->
2018-10-29 10:42:36 +00:00
[ 'PERMISSION ERROR- ~w: cannot resize array ~w' - [Where,P] ].
system_message(error(permission_error(unlock,mutex,P), Where)) -->
2018-10-29 10:42:36 +00:00
[ 'PERMISSION ERROR- ~w: cannot unlock mutex ~w' - [Where,P] ].
system_message(error(representation_error(character), Where)) -->
2018-10-29 10:42:36 +00:00
[ 'REPRESENTATION ERROR- ~w: expected character' - [Where] ].
system_message(error(representation_error(character_code), Where)) -->
2018-10-29 10:42:36 +00:00
[ 'REPRESENTATION ERROR- ~w: expected character code' - [Where] ].
system_message(error(representation_error(max_arity), Where)) -->
2018-10-29 10:42:36 +00:00
[ 'REPRESENTATION ERROR- ~w: number too big' - [Where] ].
system_message(error(representation_error(variable), Where)) -->
2018-10-29 10:42:36 +00:00
[ 'REPRESENTATION ERROR- ~w: should be a variable' - [Where] ].
system_message(error(resource_error(code_space), Where)) -->
2018-10-29 10:42:36 +00:00
[ 'RESOURCE ERROR- not enough code space' - [Where] ].
system_message(error(resource_error(huge_int), Where)) -->
2018-10-29 10:42:36 +00:00
[ 'RESOURCE ERROR- too large an integer in absolute value' - [Where] ].
system_message(error(resource_error(memory), Where)) -->
2018-10-29 10:42:36 +00:00
[ 'RESOURCE ERROR- not enough virtual memory' - [Where] ].
system_message(error(resource_error(stack), Where)) -->
2018-10-29 10:42:36 +00:00
[ 'RESOURCE ERROR- not enough stack' - [Where] ].
system_message(error(resource_error(streams), Where)) -->
2018-10-29 10:42:36 +00:00
[ 'RESOURCE ERROR- could not find a free stream' - [Where] ].
system_message(error(resource_error(threads), Where)) -->
2018-10-29 10:42:36 +00:00
[ 'RESOURCE ERROR- too many open threads' - [Where] ].
system_message(error(resource_error(trail), Where)) -->
2018-10-29 10:42:36 +00:00
[ 'RESOURCE ERROR- not enough trail space' - [Where] ].
system_message(error(signal(SIG,_), _)) -->
2018-10-29 10:42:36 +00:00
[ 'UNEXPECTED SIGNAL: ~a' - [SIG] ].
2011-11-08 15:48:55 +00:00
% SWI like I/O error message.
2009-03-26 08:54:49 +00:00
system_message(error(unhandled_exception,Throw)) -->
2018-10-29 10:42:36 +00:00
[ 'UNHANDLED EXCEPTION - message ~w unknown' - [Throw] ].
system_message(error(uninstantiation_error(TE), _Where)) -->
2018-10-29 10:42:36 +00:00
[ 'UNINSTANTIATION ERROR - expected unbound term, got ~q' - [TE] ].
system_message(Messg) -->
2018-10-29 10:42:36 +00:00
[ '~q' - Messg ].
domain_error(array_overflow, Opt) --> !,
2018-10-29 10:42:36 +00:00
[ 'invalid static index ~w for array' - Opt ].
domain_error(array_type, Opt) --> !,
2018-10-29 10:42:36 +00:00
[ 'invalid static array type ~w' - Opt ].
domain_error(builtin_procedure, _) --> !,
2018-10-29 10:42:36 +00:00
[ 'non-iso built-in procedure' ].
domain_error(character_code_list, Opt) --> !,
2018-10-29 10:42:36 +00:00
[ 'invalid list of codes ~w' - [Opt] ].
domain_error(close_option, Opt) --> !,
2018-10-29 10:42:36 +00:00
[ 'invalid close option ~w' - [Opt] ].
domain_error(delete_file_option, Opt) --> !,
2018-10-29 10:42:36 +00:00
[ 'invalid list of options ~w' - [Opt] ].
domain_error(encoding, Opt) --> !,
2018-10-29 10:42:36 +00:00
[ 'invalid encoding ~w' - [Opt] ].
domain_error(flag_value, [Opt,Flag]) --> !,
2018-10-29 10:42:36 +00:00
[ 'invalid value ~w for flag ~w' - [Opt,Flag] ].
domain_error(flag_value, Opt) --> !,
2018-10-29 10:42:36 +00:00
[ 'invalid value ~w for flag' - [Opt] ].
domain_error(io_mode, Opt) --> !,
2018-10-29 10:42:36 +00:00
[ 'invalid io mode ~w' - [Opt] ].
domain_error(mutable, Opt) --> !,
2018-10-29 10:42:36 +00:00
[ 'invalid id mutable ~w' - [Opt] ].
domain_error(module_decl_options, Opt) --> !,
2018-10-29 10:42:36 +00:00
[ 'expect module declaration options, found ~w' - [Opt] ].
2009-06-03 16:43:40 +01:00
domain_error(non_empty_list, Opt) --> !,
2018-10-29 10:42:36 +00:00
[ 'found empty list' - [Opt] ].
domain_error(not_less_than_zero, Opt) --> !,
2018-10-29 10:42:36 +00:00
[ 'number ~w less than zero' - [Opt] ].
domain_error(not_newline, Opt) --> !,
2018-10-29 10:42:36 +00:00
[ 'number ~w not newline' - [Opt] ].
domain_error(not_zero, Opt) --> !,
2018-10-29 10:42:36 +00:00
[ '~w is not allowed in the domain' - [Opt] ].
domain_error(operator_priority, Opt) --> !,
2018-10-29 10:42:36 +00:00
[ '~w invalid operator priority' - [Opt] ].
domain_error(operator_specifier, Opt) --> !,
2018-10-29 10:42:36 +00:00
[ 'invalid operator specifier ~w' - [Opt] ].
domain_error(out_of_range, Opt) --> !,
2018-10-29 10:42:36 +00:00
[ 'expression ~w is out of range' - [Opt] ].
domain_error(predicate_spec, Opt) --> !,
2018-10-29 10:42:36 +00:00
[ '~w invalid predicate specifier' - [Opt] ].
domain_error(radix, Opt) --> !,
2018-10-29 10:42:36 +00:00
[ 'invalid radix ~w' - [Opt] ].
domain_error(read_option, Opt) --> !,
2018-10-29 10:42:36 +00:00
[ '~w invalid option to read_term' - [Opt] ].
domain_error(semantics_indicator, Opt) --> !,
2018-10-29 10:42:36 +00:00
[ 'predicate indicator, got ~w' - [Opt] ].
domain_error(shift_count_overflow, Opt) --> !,
2018-10-29 10:42:36 +00:00
[ 'shift count overflow in ~w' - [Opt] ].
domain_error(source_sink, Opt) --> !,
2018-10-29 10:42:36 +00:00
[ '~w is not a source sink term' - [Opt] ].
domain_error(stream, Opt) --> !,
2018-10-29 10:42:36 +00:00
[ '~w is not a stream' - [Opt] ].
domain_error(stream_or_alias, Opt) --> !,
2018-10-29 10:42:36 +00:00
[ '~w is not a stream (or alias)' - [Opt] ].
domain_error(stream_encoding, Opt) --> !,
2018-10-29 10:42:36 +00:00
[ '~w is not a supported stream encoding' - [Opt] ].
domain_error(stream_position, Opt) --> !,
2018-10-29 10:42:36 +00:00
[ '~w is not a stream position' - [Opt] ].
domain_error(stream_property, Opt) --> !,
2018-10-29 10:42:36 +00:00
[ '~w is not a stream property' - [Opt] ].
domain_error(syntax_error_handler, Opt) --> !,
2018-10-29 10:42:36 +00:00
[ '~w is not a syntax error handler' - [Opt] ].
domain_error(table, Opt) --> !,
2018-10-29 10:42:36 +00:00
[ 'non-tabled procedure ~w' - [Opt] ].
domain_error(thread_create_option, Opt) --> !,
2018-10-29 10:42:36 +00:00
[ '~w is not a thread_create option' - [Opt] ].
domain_error(time_out_spec, Opt) --> !,
2018-10-29 10:42:36 +00:00
[ '~w is not valid specificatin for time_out' - [Opt] ].
domain_error(unimplemented_option, Opt) --> !,
2018-10-29 10:42:36 +00:00
[ '~w is not yet implemented' - [Opt] ].
domain_error(write_option, Opt) --> !,
2018-10-29 10:42:36 +00:00
[ '~w invalid write option' - [Opt] ].
domain_error(Domain, Opt) -->
2018-10-29 10:42:36 +00:00
[ '~w not a valid element for ~w' - [Opt,Domain] ].
object_name(array, array).
object_name(atom, atom).
object_name(atomic, atomic).
object_name(byte, byte).
object_name(callable, 'callable goal').
object_name(char, char).
object_name(character_code, 'character code').
object_name(compound, 'compound term').
object_name(db_reference, 'data base reference').
object_name(evaluable, 'evaluable term').
object_name(file, file).
object_name(float, float).
object_name(in_byte, byte).
object_name(in_character, character).
object_name(integer, integer).
2015-09-29 23:09:12 +01:00
object_name(key, 'database key').
object_name(leash_mode, 'leash mode').
object_name(library, library).
object_name(list, list).
object_name(message_queue, 'message queue').
object_name(mutex, mutex).
object_name(number, number).
object_name(operator, operator).
object_name(pointer, pointer).
object_name(predicate_indicator, 'predicate indicator').
object_name(source_sink, file).
object_name(unsigned_byte, 'unsigned byte').
object_name(unsigned_char, 'unsigned char').
object_name(variable, 'unbound variable').
2015-11-05 17:23:26 +00:00
svs([A=VA], [A=VA], S) :- !,
2018-10-29 10:42:36 +00:00
atom_string(A, S).
2015-11-05 17:23:26 +00:00
svs([A=VA,B=VB], [A=VA,B=VB], SN) :- !,
2018-10-29 10:42:36 +00:00
atom_string(A, S),
atom_string(B, S1),
string_concat([S,` and `,S1], SN).
2015-11-05 17:23:26 +00:00
svs([A=_], _, SN) :- !,
2018-10-29 10:42:36 +00:00
atom_string(A, S),
string_concat(`, and `,S, SN).
2015-11-05 17:23:26 +00:00
svs([A=V|L], [A=V|L], SN) :- !,
2018-10-29 10:42:36 +00:00
atom_string(A, S),
svs(L, [A=V|L], S1 ),
string_concat([ S, S1], SN).
2015-11-05 17:23:26 +00:00
svs([A=_V|L], All, SN) :- !,
2018-10-29 10:42:36 +00:00
atom_string(A, S),
svs(L, All, S1 ),
string_concat([`, `, S, S1], SN).
list_of_preds([]) --> [].
list_of_preds([P|L]) -->
2018-10-29 10:42:36 +00:00
['~q' - [P]],
list_of_preds(L).
2018-10-16 14:33:16 +01:00
syntax_error_term(between(_I,J,_L),[S|T],_LC) -->
2018-10-29 10:42:36 +00:00
{string(S)},
!,
[ '~s' - [S] ],
[' <<<< at line ~d >>>> ~s' - [J,T], nl ].
2018-01-05 16:57:38 +00:00
syntax_error_term(between(_I,J,_L),LTaL,LC) -->
2018-10-29 10:42:36 +00:00
syntax_error_tokens(LTaL, J, LC).
2018-01-05 16:57:38 +00:00
syntax_error_tokens([], _, _LC) --> [].
syntax_error_tokens([T|L], J, LC) -->
2018-10-29 10:42:36 +00:00
syntax_error_token(T, J, LC),
syntax_error_tokens(L, J, LC).
2018-01-05 16:57:38 +00:00
syntax_error_token(atom(A), _, _LC) --> !,
2018-10-29 10:42:36 +00:00
[ '~q' - [A] ].
2018-01-05 16:57:38 +00:00
syntax_error_token(number(N), _, _LC) --> !,
2018-10-29 10:42:36 +00:00
[ '~w' - [N] ].
2018-01-05 16:57:38 +00:00
syntax_error_token(var(_,S), _, _LC) --> !,
2018-10-29 10:42:36 +00:00
[ '~a' - [S] ].
2018-01-05 16:57:38 +00:00
syntax_error_token(string(S), _, _LC) --> !,
2018-10-29 10:42:36 +00:00
[ '`~s`' - [S] ].
2018-01-05 16:57:38 +00:00
syntax_error_token(error, L, _LC) --> !,
2018-10-29 10:42:36 +00:00
[ ' <<<< at line ~d >>>> ' - [L] ].
2018-01-05 16:57:38 +00:00
syntax_error_token('EOT',_, _LC) --> !,
2018-10-29 10:42:36 +00:00
[ '.' - [], nl ].
2018-01-05 16:57:38 +00:00
syntax_error_token('(',_, _LC) --> !,
2018-10-29 10:42:36 +00:00
[ '( '- [] ].
2018-01-05 16:57:38 +00:00
syntax_error_token('{',_, _LC) --> !,
2018-10-29 10:42:36 +00:00
[ '{ '- [] ].
2018-01-05 16:57:38 +00:00
syntax_error_token('[', _, _LC) --> !,
2018-10-29 10:42:36 +00:00
[ '[' - [] ].
2018-01-05 16:57:38 +00:00
syntax_error_token(')',_, _LC) --> !,
2018-10-29 10:42:36 +00:00
[ ' )'- [] ].
2018-01-05 16:57:38 +00:00
syntax_error_token(']',_, _LC) --> !,
2018-10-29 10:42:36 +00:00
[ ']'- [] ].
2018-01-05 16:57:38 +00:00
syntax_error_token('}',_, _LC) --> !,
2018-10-29 10:42:36 +00:00
[ ' }' - [] ].
2018-01-05 16:57:38 +00:00
syntax_error_token(',',_, _LC) --> !,
2018-10-29 10:42:36 +00:00
[ ', ' - [] ].
2018-01-05 16:57:38 +00:00
syntax_error_token('.',_, _LC) --> !,
2018-10-29 10:42:36 +00:00
[ '.' - [] ].
2018-01-05 16:57:38 +00:00
syntax_error_token(';', _, _LC) --> !,
2018-10-29 10:42:36 +00:00
[ '; ' - [] ].
2018-01-05 16:57:38 +00:00
syntax_error_token(':', _, _LC) --> !,
2018-10-29 10:42:36 +00:00
[ ':' - [] ].
2018-01-05 16:57:38 +00:00
syntax_error_token('|', _, _LC) --> !,
2018-10-29 10:42:36 +00:00
[ '|' - [] ].
2018-01-05 16:57:38 +00:00
syntax_error_token('l',_, _LC) --> !,
2018-10-29 10:42:36 +00:00
[ '|' - [] ].
2018-01-05 16:57:38 +00:00
syntax_error_token(nl, _, LC) --> !,
2018-10-29 10:42:36 +00:00
[ '~*| ' -[LC], nl ].
2018-01-05 16:57:38 +00:00
syntax_error_token(B,_, _LC) --> !,
2018-10-29 10:42:36 +00:00
[ nl, 'bad_token: ~q' - [B], nl ].
print_lines( S, A, Key) -->
2018-10-29 10:42:36 +00:00
[Tok],
print_lines_(Tok, S, A, Key).
print_lines_( at_same_line, S, Prefix, Key) -->
2018-10-29 10:42:36 +00:00
!,
print_lines( S, Prefix, Key).
print_lines_(begin(Severity, OtherKey), S, Prefixes, Key) -->
2018-10-29 10:42:36 +00:00
!,
{ prefix( Severity, P ) },
print_message_lines(S, [P], OtherKey),
print_lines( S, Prefixes, Key ).
print_lines_( end(Key0), S, _, Key) -->
2018-10-29 10:42:36 +00:00
{ Key0 == Key },
!,
{ nl(S) }.
print_lines_( end(_OtherKey), S, Prefixes, Key) -->
2018-10-29 10:42:36 +00:00
!,
print_lines( S, Prefixes, Key ).
print_lines_( flush, S, _, Key) -->
2018-10-29 10:42:36 +00:00
[ end(Key0)],
{ Key == Key0 },
!,
{ flush_output(S) }.
print_lines_(flush, S, Prefixes, Key) -->
2018-10-29 10:42:36 +00:00
!,
{ flush_output(S) },
print_lines( S, Prefixes, Key ).
print_lines_(format(Fmt,Args), S, Prefixes, Key) -->
2018-10-29 10:42:36 +00:00
!,
{ format(S, Fmt, Args) },
print_lines( S, Prefixes, Key ).
print_lines_( nl, S, _, Key) -->
2018-10-29 10:42:36 +00:00
[ end(Key0)],
{ Key == Key0 },
!,
{ nl(S),
flush_output(S) }.
print_lines_(nl, S, Prefixes, Key) -->
2018-10-29 10:42:36 +00:00
!,
{ nl(S),
Prefixes = [PrefixS - Cmds|More],
format(S, PrefixS, Cmds)
},
{
More == []
->
NPrefixes = Prefixes
;
NPrefixes = More
},
print_lines( S, NPrefixes, Key).
2016-03-03 23:23:32 +00:00
% consider this a message within the message
print_lines_(prefix(Fmt-Args), S, Prefixes, Key) -->
2018-10-29 10:42:36 +00:00
!,
print_lines( S, [Fmt-Args|Prefixes], Key ).
print_lines_(prefix(Fmt), S, Prefixes, Key) -->
2018-10-29 10:42:36 +00:00
{ atom( Fmt ) ; string( Fmt ) },
!,
print_lines( S, [Fmt-[]|Prefixes], Key ).
print_lines_(Fmt-Args, S, Prefixes, Key) -->
2018-10-29 10:42:36 +00:00
!,
{ format(S, Fmt, Args) },
print_lines( S, Prefixes, Key ).
% deprecated....
print_lines_(Fmt, S, Prefixes, Key) -->
2018-10-29 10:42:36 +00:00
{ atom(Fmt) ; string( Fmt ) },
!,
{ format(S, Fmt, []) },
print_lines(S, Prefixes, Key).
print_lines_(Msg, S, _Prefixes, _Key) -->
2018-10-29 10:42:36 +00:00
{ format(S, 'Illegal message Component: ~q !!!.~n', [Msg]) }.
2015-11-05 17:23:26 +00:00
prefix(help, '~N'-[]).
prefix(query, '~N'-[]).
prefix(debug, '~N'-[]).
prefix(warning, '~N'-[]).
2018-06-25 13:44:09 +01:00
prefix(error, '~N'-[]).
prefix(banner, '~N'-[]).
2018-06-26 15:35:47 +01:00
prefix(informational, '~N~*|% '-[LC]) :-
'$show_consult_level'(LC),
LC > 0,
2018-10-29 10:42:36 +00:00
!.
2018-06-26 15:35:47 +01:00
prefix(informational, '~N'-[]).
2018-06-25 13:44:09 +01:00
prefix(debug(_), '~N'-[]).
/* { thread_self(Id) },
2018-10-29 10:42:36 +00:00
( { Id == main }
-> [ 'warning, ' - [] ]
; { atom(Id) }
-> ['warning [Thread ~a ], ' - [Id] ]
; ['warning [Thread ~d ], ' - [Id] ]
).
*/
2018-06-25 13:44:09 +01:00
/*
2018-10-29 10:42:36 +00:00
{ thread_self(Id) },
( { Id == main }
-> [ 'error ' ]
2015-11-05 17:23:26 +00:00
; { thread_main_name(Id) }
2018-10-29 10:42:36 +00:00
-> [ 'error [ Thread ~w ] ' - [Id] ]
),
!.
2014-11-27 10:02:04 +00:00
prefix(error, '', user_error) -->
2018-10-29 10:42:36 +00:00
{ thread_self(Id) },
( { Id == main }
-> [ 'error ' - [], nl ]
; { atom(Id) }
-> [ 'error [ Thread ~a ] ' - [Id], nl ]
; [ 'error [ Thread ~d ] ' - [Id], nl ]
).
*/
2018-06-25 13:44:09 +01:00
2015-11-05 17:23:26 +00:00
clause_to_indicator(T, MNameArity) :-
2018-10-29 10:42:36 +00:00
strip_module(T, M0, T1),
pred_arity( T1, M0, MNameArity ).
2015-11-05 17:23:26 +00:00
pred_arity(V, M, M:call/1) :- var(V), !.
pred_arity((:- _Path), _M, prolog:(:-)/1 ) :- !.
pred_arity((?- _Path), _M, prolog:(?)/1 ) :- !.
pred_arity((H:-_),M, MNameArity) :-
2014-09-10 05:53:41 +01:00
nonvar(H),
!,
2015-11-05 17:23:26 +00:00
strip_module(M:H, M1, H1),
pred_arity( H1, M1, MNameArity).
pred_arity((H-->_), M, M2:Name//Arity) :-
2015-09-21 23:05:36 +01:00
nonvar(H),
!,
2015-11-05 17:23:26 +00:00
strip_module(M:H, M1, H1),
pred_arity( H1, M1, M2:Name/Arity).
% special for a, [x] --> b, [y].
pred_arity((H,_), M, MNameArity) :-
2014-09-10 05:53:41 +01:00
nonvar(H),
!,
2015-11-05 17:23:26 +00:00
strip_module(M:H, M1, H1),
pred_arity( H1, M1, MNameArity).
pred_arity(Name/Arity, M, M:Name/Arity) :-
!.
pred_arity(Name//Arity, M, M:Name//Arity) :-
!.
pred_arity(H,M, M:Name/Arity) :-
2014-09-10 05:53:41 +01:00
functor(H,Name,Arity).
2014-09-11 20:06:57 +01:00
2015-11-05 17:23:26 +00:00
translate_message(Term, Level) -->
2018-10-29 10:42:36 +00:00
compose_message(Term, Level), !.
2015-11-05 17:23:26 +00:00
translate_message(Term, _) -->
2018-10-29 10:42:36 +00:00
{ Term = error(_, _) },
[ 'Unknown exception: ~p'-[Term] ].
2015-11-05 17:23:26 +00:00
translate_message(Term, _) -->
2018-10-29 10:42:36 +00:00
[ 'Unknown message: ~p'-[Term] ].
2015-07-06 12:04:42 +01:00
2015-11-05 17:23:26 +00:00
% print_message_lines(+Stream, +Prefix, +Lines)
%
% Quintus/SICStus/SWI compatibility predicate to print message lines
% using a prefix.
2015-11-05 17:23:26 +00:00
/** @pred print_message_lines(+ _Stream_, + _Prefix_, + _Lines_)
2015-11-05 17:23:26 +00:00
Print a message (see print_message/2) that has been translated to
a list of message elements. The elements of this list are:
2015-11-05 17:23:26 +00:00
+ _Format_-_Args_
Where _Format_ is an atom and _Args_ is a list
of format argument. Handed to `format/3`.
+ `flush`
If this appears as the last element, _Stream_ is flushed
(see `flush_output/1`) and no final newline is generated.
+ `at_same_line`
If this appears as first element, no prefix is printed for
the line and the line-position is not forced to 0
(see `format/1`, `~N`).
+ `prefix`(Prefix)
define a prefix for the next line, say `''` will be seen as an
empty prefix.
(see `format/1`, `~N`).
+ `<Format>`
Handed to `format/3` as `format(Stream, Format, [])`, may get confused
with other commands.
+ nl
A new line is started and if the message is not complete
the _Prefix_ is printed too.
*/
2015-11-05 17:23:26 +00:00
prolog:print_message_lines(S, Prefix0, Lines) :-
2018-10-29 10:42:36 +00:00
Lines = [begin(_, Key)|Msg],
(
atom(Prefix0)
->
Prefix = Prefix0-[]
;
string(Prefix0)
->
Prefix = Prefix0-[]
;
Prefix = Prefix0
),
(Msg = [at_same_line|Msg1]
->
print_lines(S, [Prefix], Key, Msg1, [])
;
print_lines(S, [Prefix], Key, [Prefix|Msg], [])
).
2015-11-05 17:23:26 +00:00
/** @pred prolog:print_message(+ Severity, +Term)
The predicate print_message/2 is used to print messages, notably from
exceptions, in a human-readable format. _Kind_ is one of
`informational`, `banner`, `warning`, `error`, `help` or `silent`. In YAP, the message is always outut to the stream user_error.
If the Prolog flag verbose is `silent`, messages with
_Kind_ `informational`, or `banner` are treated as
silent. See `-q` in [Running_YAP_Interactively].
This predicate first translates the _Term_ into a list of `message
lines` (see print_message_lines/3 for details). Next it will
call the hook message_hook/3 to allow the user intercepting the
message. If message_hook/3 fails it will print the message unless
_Kind_ is silent.
If you need to report errors from your own predicates, we advise you to
stick to the existing error terms if you can; but should you need to
invent new ones, you can define corresponding error messages by
asserting clauses for `prolog:message/2`. You will need to declare
2017-06-06 12:47:59 +01:00
the predicate as multifile/1.
Note: errors in the implementation of print_message/2 are very
confusing to YAP (who will process the error?). So we write this small
stub to ensure everything os ok
2018-06-28 12:48:29 +01:00
*/
2018-07-02 15:20:17 +01:00
:- dynamic in/0.
2018-06-28 12:48:29 +01:00
/*
prolog:print_message(Severity, Msg) :-
\+ in,
assert(in),
( prolog:print_message(Severity, Msg), fail;
retract(in)
2018-07-02 15:20:17 +01:00
).
*/
prolog:print_message(Severity, Msg) :-
2018-10-29 10:42:36 +00:00
(
var(Severity)
->
!,
format(user_error, 'malformed message ~q: message level is unbound~n', [Msg])
;
var(Msg)
->
!,
format(user_error, 'uninstantiated message~n', [])
2016-07-31 16:35:18 +01:00
;
2018-10-29 10:42:36 +00:00
Severity == silent
2016-07-31 16:35:18 +01:00
->
2018-10-29 10:42:36 +00:00
[]
;
'$pred_exists'(portray_message(_,_),user),
user:portray_message(Severity, Msg)
),
!.
2016-06-03 16:53:43 +01:00
prolog:print_message(Level, _Msg) :-
2018-10-29 10:42:36 +00:00
current_prolog_flag(verbose_load, false),
2018-10-31 00:35:49 +00:00
'$show_consult_level'(LC),
LC > 0,
2018-10-29 10:42:36 +00:00
Level = informational,
!.
2016-06-03 16:53:43 +01:00
prolog:print_message(Level, _Msg) :-
2018-10-29 10:42:36 +00:00
current_prolog_flag(verbose, silent),
Level \= error,
Level \= warning,
!.
2016-06-03 16:53:43 +01:00
prolog:print_message(_, _Msg) :-
2018-10-29 10:42:36 +00:00
% first step at hook processing
'__NB_getval__'('$if_skip_mode',skip,fail),
!.
prolog:print_message(force(_Severity), Msg) :- !,
2018-10-29 10:42:36 +00:00
print(user_error,Msg).
% This predicate has more hooks than a pirate ship!
2016-07-31 16:35:18 +01:00
prolog:print_message(Severity, Term) :-
2018-06-26 15:35:47 +01:00
message( Term,Lines0, [ end(Id)]),
2018-10-29 10:42:36 +00:00
Lines = [begin(Severity, Id)| Lines0],
(
user:message_hook(Term, Severity, Lines)
->
true
;
ignore((prefix( Severity, Prefix ),
prolog:print_message_lines(user_error, Prefix, Lines)))
),
!.
prolog:print_message(Severity, Term) :-
2018-07-02 15:20:17 +01:00
translate_message( Term, Severity, Lines0, [ end(Id)]),
2018-10-29 10:42:36 +00:00
Lines = [begin(Severity, Id)| Lines0],
(
user:message_hook(Term, Severity, Lines)
->
true
;
ignore(( prefix( Severity, Prefix ),
prolog:print_message_lines(user_error, Prefix, Lines)))
),
!.
2018-06-26 15:35:47 +01:00
prolog:print_message(_Severity, _Term) :-
2018-06-27 11:38:42 +01:00
format(user_error,'failed to print ~w: ~w~n' ,[ _Severity, _Term]).
2015-11-05 17:23:26 +00:00
2018-10-31 00:35:49 +00:00
'$error_descriptor'( V, Info ) :- var(V), !, Info = [].
2018-07-02 15:20:17 +01:00
'$error_descriptor'( exception(Info), Info ).
2018-06-27 11:38:42 +01:00
2018-07-10 23:21:19 +01:00
query_exception(K0,[H|L],V) :-
(atom(K0) -> atom_to_string(K0, K) ; K = K0),
!,
lists:member(K=V,[H|L]).
2018-09-10 17:06:13 +01:00
query_exception(M,K,V) :-
'$query_exception'(M,K,V).
2018-06-27 11:38:42 +01:00
2014-09-11 20:06:57 +01:00
/**
2015-01-04 23:58:23 +00:00
@}
2014-09-11 20:06:57 +01:00
*/
2018-10-29 10:42:36 +00:00