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 :- use_module
(chr_compiler_options
).
41 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
42 % chr_info
(+Type
,+FormattedMessage
,+MessageParameters
)
44 chr_info
(_
,Message
,Params
) :-
48 long_line_with_equality_signs
,
49 format
(user_error
,'CHR compiler:\n',[]),
50 format
(user_error
,Message
,Params
),
51 long_line_with_equality_signs
57 current_prolog_flag
(verbose
,V
), V \
== silent
,
58 current_prolog_flag
(verbose_load
,true
).
62 %% verbosity_on
. % at the moment
65 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
66 % chr_warning
(+Type
,+FormattedMessage
,+MessageParameters
)
68 chr_warning
(deprecated
(Term
),Message
,Params
) :- !,
69 long_line_with_equality_signs
,
70 format
(user_error
,'CHR compiler WARNING: deprecated syntax ~w.\n',[Term
]),
71 format
(user_error
,' `--> ',[]),
72 format
(user_error
,Message
,Params
),
73 format
(user_error
,' Support for deprecated syntax will be discontinued in the near future!\n',[]),
74 long_line_with_equality_signs
.
76 chr_warning
(internal
,Message
,Params
) :- !,
77 long_line_with_equality_signs
,
78 format
(user_error
,'CHR compiler WARNING: something unexpected happened in the CHR compiler.\n',[]),
79 format
(user_error
,' `--> ',[]),
80 format
(user_error
,Message
,Params
),
81 format
(user_error
,' Your program may not have been compiled correctly!\n',[]),
82 format
(user_error
,' Please contact tom.schrijvers@cs.kuleuven.be.\n',[]),
83 long_line_with_equality_signs
.
85 chr_warning
(unsupported_pragma
(Pragma
,Rule
),Message
,Params
) :- !,
86 long_line_with_equality_signs
,
87 format
(user_error
,'CHR compiler WARNING: unsupported pragma ~w in ~@.\n',[Pragma
,format_rule
(Rule
)]),
88 format
(user_error
,' `--> ',[]),
89 format
(user_error
,Message
,Params
),
90 format
(user_error
,' Pragma is ignored!\n',[]),
91 long_line_with_equality_signs
.
92 chr_warning
(problem_pragma
(Pragma
,Rule
),Message
,Params
) :- !,
93 long_line_with_equality_signs
,
94 format
(user_error
,'CHR compiler WARNING: unsupported pragma ~w in ~@.\n',[Pragma
,format_rule
(Rule
)]),
95 format
(user_error
,' `--> ',[]),
96 format
(user_error
,Message
,Params
),
97 long_line_with_equality_signs
.
99 chr_warning
(_
,Message
,Params
) :-
100 ( chr_pp_flag
(verbosity
,on
) ->
101 long_line_with_equality_signs
,
102 format
(user_error
,'CHR compiler WARNING:\n',[]),
103 format
(user_error
,' `--> ',[]),
104 format
(user_error
,Message
,Params
),
105 long_line_with_equality_signs
110 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
111 % chr_error
(+Type
,+FormattedMessage
,+MessageParameters
)
113 chr_error
(Type
,Message
,Params
) :-
114 throw
(chr_error
(error
(Type
,Message
,Params
))).
116 print_chr_error
(error
(Type
,Message
,Params
)) :-
117 print_chr_error
(Type
,Message
,Params
).
119 print_chr_error
(syntax
(Term
),Message
,Params
) :- !,
120 long_line_with_equality_signs
,
121 format
(user_error
,'CHR compiler ERROR: invalid syntax "~w".\n',[Term
]),
122 format
(user_error
,' `--> ',[]),
123 format
(user_error
,Message
,Params
),
124 long_line_with_equality_signs
.
126 print_chr_error
(type_error
,Message
,Params
) :- !,
127 long_line_with_equality_signs
,
128 format
(user_error
,'CHR compiler TYPE ERROR:\n',[]),
129 format
(user_error
,' `--> ',[]),
130 format
(user_error
,Message
,Params
),
131 long_line_with_equality_signs
.
133 print_chr_error
(internal
,Message
,Params
) :- !,
134 long_line_with_equality_signs
,
135 format
(user_error
,'CHR compiler ERROR: something unexpected happened in the CHR compiler.\n',[]),
136 format
(user_error
,' `--> ',[]),
137 format
(user_error
,Message
,Params
),
138 format
(user_error
,' Please contact tom.schrijvers@cs.kuleuven.be.\n',[]),
139 long_line_with_equality_signs
.
141 print_chr_error
(cyclic_alias
(Alias
),_Message
,_Params
) :- !,
142 long_line_with_equality_signs
,
143 format
(user_error
,'CHR compiler ERROR: cyclic alias "~w".\n',[Alias
]),
144 format
(user_error
,' `--> Aborting compilation.\n',[]),
145 long_line_with_equality_signs
.
147 print_chr_error
(_
,Message
,Params
) :-
148 long_line_with_equality_signs
,
149 format
(user_error
,'CHR compiler ERROR:\n',[]),
150 format
(user_error
,' `--> ',[]),
151 format
(user_error
,Message
,Params
),
152 long_line_with_equality_signs
.
154 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
157 format_rule
(PragmaRule
) :-
158 PragmaRule
= pragma
(_
,_
,Pragmas
,MaybeName
,N
),
159 ( MaybeName
= yes
(Name
) ->
160 write('rule '), write(Name
)
162 write('rule number '), write(N
)
164 ( memberchk
(line_number
(LineNumber
),Pragmas
) ->
172 long_line_with_equality_signs
:-
173 format
(user_error
,'================================================================================\n',[]).