* roottypes.cs: Rename from tree.cs.
[mono.git] / mcs / jay / error.c
1 /*
2  * Copyright (c) 1989 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * This code is derived from software contributed to Berkeley by
6  * Robert Paul Corbett.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  * 3. All advertising materials mentioning features or use of this software
17  *    must display the following acknowledgement:
18  *      This product includes software developed by the University of
19  *      California, Berkeley and its contributors.
20  * 4. Neither the name of the University nor the names of its contributors
21  *    may be used to endorse or promote products derived from this software
22  *    without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34  * SUCH DAMAGE.
35  */
36
37 #ifndef lint
38 static char sccsid[] = "@(#)error.c     5.3 (Berkeley) 6/1/90";
39 #endif /* not lint */
40
41 /* routines for printing error messages  */
42
43 #include "defs.h"
44
45
46 fatal(msg)
47 char *msg;
48 {
49     fprintf(stderr, "%s: f - %s\n", myname, msg);
50     done(2);
51 }
52
53
54 no_space()
55 {
56     fprintf(stderr, "%s: f - out of space\n", myname);
57     done(2);
58 }
59
60
61 open_error(filename)
62 char *filename;
63 {
64     fprintf(stderr, "%s: f - cannot open \"%s\"\n", myname, filename);
65     done(2);
66 }
67
68
69 unexpected_EOF()
70 {
71     fprintf(stderr, "%s: e - line %d of \"%s\", unexpected end-of-file\n",
72             myname, lineno, input_file_name);
73     done(1);
74 }
75
76
77 print_pos(st_line, st_cptr)
78 char *st_line;
79 char *st_cptr;
80 {
81     register char *s;
82
83     if (st_line == 0) return;
84     for (s = st_line; *s != '\n'; ++s)
85     {
86         if (isprint(*s) || *s == '\t')
87             putc(*s, stderr);
88         else
89             putc('?', stderr);
90     }
91     putc('\n', stderr);
92     for (s = st_line; s < st_cptr; ++s)
93     {
94         if (*s == '\t')
95             putc('\t', stderr);
96         else
97             putc(' ', stderr);
98     }
99     putc('^', stderr);
100     putc('\n', stderr);
101 }
102
103
104 syntax_error(st_lineno, st_line, st_cptr)
105 int st_lineno;
106 char *st_line;
107 char *st_cptr;
108 {
109     fprintf(stderr, "%s: e - line %d of \"%s\", syntax error\n",
110             myname, st_lineno, input_file_name);
111     print_pos(st_line, st_cptr);
112     done(1);
113 }
114
115
116 unterminated_comment(c_lineno, c_line, c_cptr)
117 int c_lineno;
118 char *c_line;
119 char *c_cptr;
120 {
121     fprintf(stderr, "%s: e - line %d of \"%s\", unmatched /*\n",
122             myname, c_lineno, input_file_name);
123     print_pos(c_line, c_cptr);
124     done(1);
125 }
126
127
128 unterminated_string(s_lineno, s_line, s_cptr)
129 int s_lineno;
130 char *s_line;
131 char *s_cptr;
132 {
133     fprintf(stderr, "%s: e - line %d of \"%s\", unterminated string\n",
134             myname, s_lineno, input_file_name);
135     print_pos(s_line, s_cptr);
136     done(1);
137 }
138
139
140 unterminated_text(t_lineno, t_line, t_cptr)
141 int t_lineno;
142 char *t_line;
143 char *t_cptr;
144 {
145     fprintf(stderr, "%s: e - line %d of \"%s\", unmatched %%{\n",
146             myname, t_lineno, input_file_name);
147     print_pos(t_line, t_cptr);
148     done(1);
149 }
150
151
152 illegal_tag(t_lineno, t_line, t_cptr)
153 int t_lineno;
154 char *t_line;
155 char *t_cptr;
156 {
157     fprintf(stderr, "%s: e - line %d of \"%s\", illegal tag\n",
158             myname, t_lineno, input_file_name);
159     print_pos(t_line, t_cptr);
160     done(1);
161 }
162
163
164 illegal_character(c_cptr)
165 char *c_cptr;
166 {
167     fprintf(stderr, "%s: e - line %d of \"%s\", illegal character\n",
168             myname, lineno, input_file_name);
169     print_pos(line, c_cptr);
170     done(1);
171 }
172
173
174 used_reserved(s)
175 char *s;
176 {
177     fprintf(stderr, "%s: e - line %d of \"%s\", illegal use of reserved symbol \
178 %s\n", myname, lineno, input_file_name, s);
179     done(1);
180 }
181
182
183 tokenized_start(s)
184 char *s;
185 {
186      fprintf(stderr, "%s: e - line %d of \"%s\", the start symbol %s cannot be \
187 declared to be a token\n", myname, lineno, input_file_name, s);
188      done(1);
189 }
190
191
192 retyped_warning(s)
193 char *s;
194 {
195     fprintf(stderr, "%s: w - line %d of \"%s\", the type of %s has been \
196 redeclared\n", myname, lineno, input_file_name, s);
197 }
198
199
200 reprec_warning(s)
201 char *s;
202 {
203     fprintf(stderr, "%s: w - line %d of \"%s\", the precedence of %s has been \
204 redeclared\n", myname, lineno, input_file_name, s);
205 }
206
207
208 revalued_warning(s)
209 char *s;
210 {
211     fprintf(stderr, "%s: w - line %d of \"%s\", the value of %s has been \
212 redeclared\n", myname, lineno, input_file_name, s);
213 }
214
215
216 terminal_start(s)
217 char *s;
218 {
219     fprintf(stderr, "%s: e - line %d of \"%s\", the start symbol %s is a \
220 token\n", myname, lineno, input_file_name, s);
221     done(1);
222 }
223
224
225 restarted_warning()
226 {
227     fprintf(stderr, "%s: w - line %d of \"%s\", the start symbol has been \
228 redeclared\n", myname, lineno, input_file_name);
229 }
230
231
232 no_grammar()
233 {
234     fprintf(stderr, "%s: e - line %d of \"%s\", no grammar has been \
235 specified\n", myname, lineno, input_file_name);
236     done(1);
237 }
238
239
240 terminal_lhs(s_lineno)
241 int s_lineno;
242 {
243     fprintf(stderr, "%s: e - line %d of \"%s\", a token appears on the lhs \
244 of a production\n", myname, s_lineno, input_file_name);
245     done(1);
246 }
247
248
249 prec_redeclared()
250 {
251     fprintf(stderr, "%s: w - line %d of  \"%s\", conflicting %%prec \
252 specifiers\n", myname, lineno, input_file_name);
253 }
254
255
256 unterminated_action(a_lineno, a_line, a_cptr)
257 int a_lineno;
258 char *a_line;
259 char *a_cptr;
260 {
261     fprintf(stderr, "%s: e - line %d of \"%s\", unterminated action\n",
262             myname, a_lineno, input_file_name);
263     print_pos(a_line, a_cptr);
264     done(1);
265 }
266
267
268 dollar_warning(a_lineno, i)
269 int a_lineno;
270 int i;
271 {
272     fprintf(stderr, "%s: w - line %d of \"%s\", $%d references beyond the \
273 end of the current rule\n", myname, a_lineno, input_file_name, i);
274 }
275
276
277 dollar_error(a_lineno, a_line, a_cptr)
278 int a_lineno;
279 char *a_line;
280 char *a_cptr;
281 {
282     fprintf(stderr, "%s: e - line %d of \"%s\", illegal $-name\n",
283             myname, a_lineno, input_file_name);
284     print_pos(a_line, a_cptr);
285     done(1);
286 }
287
288
289 untyped_lhs()
290 {
291     fprintf(stderr, "%s: w - line %d of \"%s\", $$ is untyped\n",
292             myname, lineno, input_file_name);
293     /** done(1); */
294 }
295
296
297 untyped_rhs(i, s)
298 int i;
299 char *s;
300 {
301     fprintf(stderr, "%s: w - line %d of \"%s\", $%d (%s) is untyped\n",
302             myname, lineno, input_file_name, i, s);
303     /** done(1); */
304 }
305
306
307 unknown_rhs(i)
308 int i;
309 {
310     fprintf(stderr, "%s: e - line %d of \"%s\", $%d is untyped\n",
311             myname, lineno, input_file_name, i);
312     done(1);
313 }
314
315
316 default_action_warning()
317 {
318     fprintf(stderr, "%s: w - line %d of \"%s\", the default action assigns an \
319 undefined value to $$\n", myname, lineno, input_file_name);
320 }
321
322
323 undefined_goal(s)
324 char *s;
325 {
326     fprintf(stderr, "%s: e - the start symbol %s is undefined\n", myname, s);
327     done(1);
328 }
329
330
331 undefined_symbol_warning(s)
332 char *s;
333 {
334     fprintf(stderr, "%s: w - the symbol %s is undefined\n", myname, s);
335 }