2010-06-03 Jb Evain <jbevain@novell.com>
[mcs.git] / jay / error.c
blobdd8bf291c20ddf5a445cd8b4f2d187c5b2d18dba
1 /*
2 * Copyright (c) 1989 The Regents of the University of California.
3 * All rights reserved.
5 * This code is derived from software contributed to Berkeley by
6 * Robert Paul Corbett.
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.
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.
37 #ifndef lint
38 static char sccsid[] = "@(#)error.c 5.3 (Berkeley) 6/1/90";
39 #endif /* not lint */
41 /* routines for printing error messages */
43 #include "defs.h"
46 fatal(msg)
47 char *msg;
49 fprintf(stderr, "%s: f - %s\n", myname, msg);
50 done(2);
54 no_space()
56 fprintf(stderr, "%s: f - out of space\n", myname);
57 done(2);
61 open_error(filename)
62 char *filename;
64 fprintf(stderr, "%s: f - cannot open \"%s\"\n", myname, filename);
65 done(2);
69 unexpected_EOF()
71 fprintf(stderr, "%s: e - line %d of \"%s\", unexpected end-of-file\n",
72 myname, lineno, input_file_name);
73 done(1);
77 print_pos(st_line, st_cptr)
78 char *st_line;
79 char *st_cptr;
81 register char *s;
83 if (st_line == 0) return;
84 for (s = st_line; *s != '\n'; ++s)
86 if (isprint(*s) || *s == '\t')
87 putc(*s, stderr);
88 else
89 putc('?', stderr);
91 putc('\n', stderr);
92 for (s = st_line; s < st_cptr; ++s)
94 if (*s == '\t')
95 putc('\t', stderr);
96 else
97 putc(' ', stderr);
99 putc('^', stderr);
100 putc('\n', stderr);
104 syntax_error(st_lineno, st_line, st_cptr)
105 int st_lineno;
106 char *st_line;
107 char *st_cptr;
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);
116 unterminated_comment(c_lineno, c_line, c_cptr)
117 int c_lineno;
118 char *c_line;
119 char *c_cptr;
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);
128 unterminated_string(s_lineno, s_line, s_cptr)
129 int s_lineno;
130 char *s_line;
131 char *s_cptr;
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);
140 unterminated_text(t_lineno, t_line, t_cptr)
141 int t_lineno;
142 char *t_line;
143 char *t_cptr;
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);
152 illegal_tag(t_lineno, t_line, t_cptr)
153 int t_lineno;
154 char *t_line;
155 char *t_cptr;
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);
164 illegal_character(c_cptr)
165 char *c_cptr;
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);
174 used_reserved(s)
175 char *s;
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);
183 tokenized_start(s)
184 char *s;
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);
192 retyped_warning(s)
193 char *s;
195 fprintf(stderr, "%s: w - line %d of \"%s\", the type of %s has been \
196 redeclared\n", myname, lineno, input_file_name, s);
200 reprec_warning(s)
201 char *s;
203 fprintf(stderr, "%s: w - line %d of \"%s\", the precedence of %s has been \
204 redeclared\n", myname, lineno, input_file_name, s);
208 revalued_warning(s)
209 char *s;
211 fprintf(stderr, "%s: w - line %d of \"%s\", the value of %s has been \
212 redeclared\n", myname, lineno, input_file_name, s);
216 terminal_start(s)
217 char *s;
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);
225 restarted_warning()
227 fprintf(stderr, "%s: w - line %d of \"%s\", the start symbol has been \
228 redeclared\n", myname, lineno, input_file_name);
232 no_grammar()
234 fprintf(stderr, "%s: e - line %d of \"%s\", no grammar has been \
235 specified\n", myname, lineno, input_file_name);
236 done(1);
240 terminal_lhs(s_lineno)
241 int s_lineno;
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);
249 prec_redeclared()
251 fprintf(stderr, "%s: w - line %d of \"%s\", conflicting %%prec \
252 specifiers\n", myname, lineno, input_file_name);
256 unterminated_action(a_lineno, a_line, a_cptr)
257 int a_lineno;
258 char *a_line;
259 char *a_cptr;
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);
268 dollar_warning(a_lineno, i)
269 int a_lineno;
270 int i;
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);
277 dollar_error(a_lineno, a_line, a_cptr)
278 int a_lineno;
279 char *a_line;
280 char *a_cptr;
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);
289 untyped_lhs()
291 fprintf(stderr, "%s: w - line %d of \"%s\", $$ is untyped\n",
292 myname, lineno, input_file_name);
293 /** done(1); */
297 untyped_rhs(i, s)
298 int i;
299 char *s;
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); */
307 unknown_rhs(i)
308 int i;
310 fprintf(stderr, "%s: e - line %d of \"%s\", $%d is untyped\n",
311 myname, lineno, input_file_name, i);
312 done(1);
316 default_action_warning()
318 fprintf(stderr, "%s: w - line %d of \"%s\", the default action assigns an \
319 undefined value to $$\n", myname, lineno, input_file_name);
323 undefined_goal(s)
324 char *s;
326 fprintf(stderr, "%s: e - the start symbol %s is undefined\n", myname, s);
327 done(1);
331 undefined_symbol_warning(s)
332 char *s;
334 fprintf(stderr, "%s: w - the symbol %s is undefined\n", myname, s);