2 * Copyright (c) 1989 The Regents of the University of California.
5 * This code is derived from software contributed to Berkeley by
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
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
39 static char sccsid[] = "@(#)error.c 5.3 (Berkeley) 6/1/90";
42 #include <sys/cdefs.h>
43 __FBSDID("$FreeBSD$");
45 /* routines for printing error messages */
49 static void print_pos(char *, char *);
63 warnx("f - out of space");
72 warnx("f - cannot open \"%s\"", filename);
80 warnx("e - line %d of \"%s\", unexpected end-of-file",
81 lineno, input_file_name);
87 print_pos(st_line, st_cptr)
93 if (st_line == 0) return;
94 for (s = st_line; *s != '\n'; ++s)
96 if (isprint(*s) || *s == '\t')
102 for (s = st_line; s < st_cptr; ++s)
115 syntax_error(st_lineno, st_line, st_cptr)
120 warnx("e - line %d of \"%s\", syntax error",
121 st_lineno, input_file_name);
122 print_pos(st_line, st_cptr);
128 unterminated_comment(c_lineno, c_line, c_cptr)
133 warnx("e - line %d of \"%s\", unmatched /*",
134 c_lineno, input_file_name);
135 print_pos(c_line, c_cptr);
141 unterminated_string(s_lineno, s_line, s_cptr)
146 warnx("e - line %d of \"%s\", unterminated string",
147 s_lineno, input_file_name);
148 print_pos(s_line, s_cptr);
154 unterminated_text(t_lineno, t_line, t_cptr)
159 warnx("e - line %d of \"%s\", unmatched %%{",
160 t_lineno, input_file_name);
161 print_pos(t_line, t_cptr);
167 unterminated_union(u_lineno, u_line, u_cptr)
172 warnx("e - line %d of \"%s\", unterminated %%union declaration",
173 u_lineno, input_file_name);
174 print_pos(u_line, u_cptr);
180 over_unionized(u_cptr)
183 warnx("e - line %d of \"%s\", too many %%union declarations",
184 lineno, input_file_name);
185 print_pos(line, u_cptr);
191 illegal_tag(t_lineno, t_line, t_cptr)
196 warnx("e - line %d of \"%s\", illegal tag", t_lineno, input_file_name);
197 print_pos(t_line, t_cptr);
203 illegal_character(c_cptr)
206 warnx("e - line %d of \"%s\", illegal character", lineno, input_file_name);
207 print_pos(line, c_cptr);
216 warnx("e - line %d of \"%s\", illegal use of reserved symbol %s",
217 lineno, input_file_name, s);
226 warnx("e - line %d of \"%s\", the start symbol %s cannot be \
227 declared to be a token", lineno, input_file_name, s);
236 warnx("w - line %d of \"%s\", the type of %s has been redeclared",
237 lineno, input_file_name, s);
245 warnx("w - line %d of \"%s\", the precedence of %s has been redeclared",
246 lineno, input_file_name, s);
254 warnx("w - line %d of \"%s\", the value of %s has been redeclared",
255 lineno, input_file_name, s);
263 warnx("e - line %d of \"%s\", the start symbol %s is a token",
264 lineno, input_file_name, s);
272 warnx("w - line %d of \"%s\", the start symbol has been redeclared",
273 lineno, input_file_name);
280 warnx("e - line %d of \"%s\", no grammar has been specified",
281 lineno, input_file_name);
287 terminal_lhs(s_lineno)
290 warnx("e - line %d of \"%s\", a token appears on the lhs of a production",
291 s_lineno, input_file_name);
299 warnx("w - line %d of \"%s\", conflicting %%prec specifiers",
300 lineno, input_file_name);
305 unterminated_action(a_lineno, a_line, a_cptr)
310 warnx("e - line %d of \"%s\", unterminated action",
311 a_lineno, input_file_name);
312 print_pos(a_line, a_cptr);
318 dollar_warning(a_lineno, i)
322 warnx("w - line %d of \"%s\", $%d references beyond the \
323 end of the current rule", a_lineno, input_file_name, i);
328 dollar_error(a_lineno, a_line, a_cptr)
333 warnx("e - line %d of \"%s\", illegal $-name", a_lineno, input_file_name);
334 print_pos(a_line, a_cptr);
342 warnx("e - line %d of \"%s\", $$ is untyped", lineno, input_file_name);
352 warnx("e - line %d of \"%s\", $%d (%s) is untyped",
353 lineno, input_file_name, i, s);
362 warnx("e - line %d of \"%s\", $%d is untyped", lineno, input_file_name, i);
368 default_action_warning()
370 warnx("w - line %d of \"%s\", the default action assigns an \
371 undefined value to $$", lineno, input_file_name);
379 warnx("e - the start symbol %s is undefined", s);
385 undefined_symbol_warning(s)
388 warnx("w - the symbol %s is undefined", s);