3 Part of CHR
(Constraint Handling Rules
)
6 E
-mail
: Tom
.Schrijvers
@cs.kuleuven
.be
7 WWW
: http
://www
.swi
-prolog
.org
8 Copyright
(C
): 2005, K
.U
. Leuven
10 This program is free software
; you can redistribute it
and/or
11 modify it under the terms of the GNU General Public License
12 as published by the Free Software Foundation
; either version
2
13 of the License
, or (at your option
) any later version
.
15 This program is distributed
in the hope that it will be useful
,
16 but WITHOUT ANY WARRANTY
; without even the implied warranty of
17 MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE
. See the
18 GNU General Public License
for more details
.
20 You should have received a copy of the GNU Lesser General Public
21 License along with this library
; if not, write to the Free Software
22 Foundation
, Inc
., 59 Temple Place
, Suite
330, Boston
, MA
02111-1307 USA
24 As a special exception
, if you
link this library with other files
,
25 compiled with a Free Software compiler
, to produce an executable
, this
26 library does
not by itself cause the resulting executable to be covered
27 by the GNU General Public License
. This exception does
not however
28 invalidate any other reasons why the executable file might be covered by
29 the GNU General Public License
.
31 :- module
(chr_compiler_errors
,
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
40 % chr_info
(+Type
,+FormattedMessage
,+MessageParameters
)
42 chr_info
(_
,Message
,Params
) :-
46 long_line_with_equality_signs
,
47 format
(user_error
,'CHR compiler:\n',[]),
48 format
(user_error
,Message
,Params
),
49 long_line_with_equality_signs
55 current_prolog_flag
(verbose
,V
), V \
== silent
,
56 current_prolog_flag
(verbose_load
,true
).
60 %% verbosity_on
. % at the moment
63 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
64 % chr_warning
(+Type
,+FormattedMessage
,+MessageParameters
)
66 chr_warning
(deprecated
(Term
),Message
,Params
) :- !,
67 long_line_with_equality_signs
,
68 format
(user_error
,'CHR compiler WARNING: deprecated syntax ~w.\n',[Term
]),
69 format
(user_error
,' `--> ',[]),
70 format
(user_error
,Message
,Params
),
71 format
(user_error
,' Support for deprecated syntax will be discontinued in the near future!\n',[]),
72 long_line_with_equality_signs
.
74 chr_warning
(internal
,Message
,Params
) :- !,
75 long_line_with_equality_signs
,
76 format
(user_error
,'CHR compiler WARNING: something unexpected happened in the CHR compiler.\n',[]),
77 format
(user_error
,' `--> ',[]),
78 format
(user_error
,Message
,Params
),
79 format
(user_error
,' Your program may not have been compiled correctly!\n',[]),
80 format
(user_error
,' Please contact tom.schrijvers@cs.kuleuven.be.\n',[]),
81 long_line_with_equality_signs
.
83 chr_warning
(unsupported_pragma
(Pragma
,Rule
),Message
,Params
) :- !,
84 long_line_with_equality_signs
,
85 format
(user_error
,'CHR compiler WARNING: unsupported pragma ~w in ~@.\n',[Pragma
,format_rule
(Rule
)]),
86 format
(user_error
,' `--> ',[]),
87 format
(user_error
,Message
,Params
),
88 format
(user_error
,' Pragma is ignored!\n',[]),
89 long_line_with_equality_signs
.
90 chr_warning
(problem_pragma
(Pragma
,Rule
),Message
,Params
) :- !,
91 long_line_with_equality_signs
,
92 format
(user_error
,'CHR compiler WARNING: unsupported pragma ~w in ~@.\n',[Pragma
,format_rule
(Rule
)]),
93 format
(user_error
,' `--> ',[]),
94 format
(user_error
,Message
,Params
),
95 long_line_with_equality_signs
.
97 chr_warning
(_
,Message
,Params
) :-
98 long_line_with_equality_signs
,
99 format
(user_error
,'CHR compiler WARNING:\n',[]),
100 format
(user_error
,' `--> ',[]),
101 format
(user_error
,Message
,Params
),
102 long_line_with_equality_signs
.
104 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
105 % chr_error
(+Type
,+FormattedMessage
,+MessageParameters
)
107 chr_error
(Type
,Message
,Params
) :-
108 throw
(chr_error
(error
(Type
,Message
,Params
))).
110 print_chr_error
(error
(Type
,Message
,Params
)) :-
111 print_chr_error
(Type
,Message
,Params
).
113 print_chr_error
(syntax
(Term
),Message
,Params
) :- !,
114 long_line_with_equality_signs
,
115 format
(user_error
,'CHR compiler ERROR: invalid syntax "~w".\n',[Term
]),
116 format
(user_error
,' `--> ',[]),
117 format
(user_error
,Message
,Params
),
118 long_line_with_equality_signs
.
120 print_chr_error
(internal
,Message
,Params
) :- !,
121 long_line_with_equality_signs
,
122 format
(user_error
,'CHR compiler ERROR: something unexpected happened in the CHR compiler.\n'),
123 format
(user_error
,' `--> ',[]),
124 format
(user_error
,Message
,Params
),
125 format
(user_error
,' Please contact tom.schrijvers@cs.kuleuven.be.\n'),
126 long_line_with_equality_signs
.
128 print_chr_error
(cyclic_alias
(Alias
),_Message
,_Params
) :- !,
129 long_line_with_equality_signs
,
130 format
(user_error
,'CHR compiler ERROR: cyclic alias "~w".\n',[Alias
]),
131 format
(user_error
,' `--> Aborting compilation.\n',[]),
132 long_line_with_equality_signs
.
134 print_chr_error
(_
,Message
,Params
) :-
135 long_line_with_equality_signs
,
136 format
(user_error
,'CHR compiler ERROR:\n',[]),
137 format
(user_error
,' `--> ',[]),
138 format
(user_error
,Message
,Params
),
139 long_line_with_equality_signs
.
141 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
144 format_rule
(PragmaRule
) :-
145 PragmaRule
= pragma
(_
,_
,_
,MaybeName
,N
),
146 ( MaybeName
= yes
(Name
) ->
147 write('rule '), write(Name
)
149 write('rule number '), write(N
)
152 long_line_with_equality_signs
:-
153 format
(user_error
,'================================================================================\n',[]).