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
36 * @(#)error.c 5.3 (Berkeley) 6/1/90
37 * $FreeBSD: src/usr.bin/yacc/error.c,v 1.7 1999/08/28 01:07:59 peter Exp $
38 * $DragonFly: src/usr.bin/yacc/error.c,v 1.3 2003/10/04 20:36:55 hmp Exp $
41 /* routines for printing error messages */
45 static void print_pos(char *, char *);
58 warnx("f - out of space");
64 open_error(char *filename)
66 warnx("f - cannot open \"%s\"", filename);
74 warnx("e - line %d of \"%s\", unexpected end-of-file",
75 lineno, input_file_name);
81 print_pos(char *st_line, char *st_cptr)
85 if (st_line == 0) return;
86 for (s = st_line; *s != '\n'; ++s)
88 if (isprint(*s) || *s == '\t')
94 for (s = st_line; s < st_cptr; ++s)
107 syntax_error(int st_lineno, char *st_line, char *st_cptr)
109 warnx("e - line %d of \"%s\", syntax error",
110 st_lineno, input_file_name);
111 print_pos(st_line, st_cptr);
117 unterminated_comment(int c_lineno, char *c_line, char *c_cptr)
119 warnx("e - line %d of \"%s\", unmatched /*",
120 c_lineno, input_file_name);
121 print_pos(c_line, c_cptr);
127 unterminated_string(int s_lineno, char *s_line, char *s_cptr)
129 warnx("e - line %d of \"%s\", unterminated string",
130 s_lineno, input_file_name);
131 print_pos(s_line, s_cptr);
137 unterminated_text(int t_lineno, char *t_line, char *t_cptr)
139 warnx("e - line %d of \"%s\", unmatched %%{",
140 t_lineno, input_file_name);
141 print_pos(t_line, t_cptr);
147 unterminated_union(int u_lineno, char *u_line, char *u_cptr)
149 warnx("e - line %d of \"%s\", unterminated %%union declaration",
150 u_lineno, input_file_name);
151 print_pos(u_line, u_cptr);
157 over_unionized(char *u_cptr)
159 warnx("e - line %d of \"%s\", too many %%union declarations",
160 lineno, input_file_name);
161 print_pos(line, u_cptr);
167 illegal_tag(int t_lineno, char *t_line, char *t_cptr)
169 warnx("e - line %d of \"%s\", illegal tag", t_lineno, input_file_name);
170 print_pos(t_line, t_cptr);
176 illegal_character(char *c_cptr)
178 warnx("e - line %d of \"%s\", illegal character", lineno, input_file_name);
179 print_pos(line, c_cptr);
185 used_reserved(char *s)
187 warnx("e - line %d of \"%s\", illegal use of reserved symbol %s",
188 lineno, input_file_name, s);
194 tokenized_start(char *s)
196 warnx("e - line %d of \"%s\", the start symbol %s cannot be \
197 declared to be a token", lineno, input_file_name, s);
203 retyped_warning(char *s)
205 warnx("w - line %d of \"%s\", the type of %s has been redeclared",
206 lineno, input_file_name, s);
211 reprec_warning(char *s)
213 warnx("w - line %d of \"%s\", the precedence of %s has been redeclared",
214 lineno, input_file_name, s);
219 revalued_warning(char *s)
221 warnx("w - line %d of \"%s\", the value of %s has been redeclared",
222 lineno, input_file_name, s);
227 terminal_start(char *s)
229 warnx("e - line %d of \"%s\", the start symbol %s is a token",
230 lineno, input_file_name, s);
236 restarted_warning(void)
238 warnx("w - line %d of \"%s\", the start symbol has been redeclared",
239 lineno, input_file_name);
246 warnx("e - line %d of \"%s\", no grammar has been specified",
247 lineno, input_file_name);
253 terminal_lhs(int s_lineno)
255 warnx("e - line %d of \"%s\", a token appears on the lhs of a production",
256 s_lineno, input_file_name);
262 prec_redeclared(void)
264 warnx("w - line %d of \"%s\", conflicting %%prec specifiers",
265 lineno, input_file_name);
270 unterminated_action(int a_lineno, char *a_line, char *a_cptr)
272 warnx("e - line %d of \"%s\", unterminated action",
273 a_lineno, input_file_name);
274 print_pos(a_line, a_cptr);
280 dollar_warning(int a_lineno, int i)
282 warnx("w - line %d of \"%s\", $%d references beyond the \
283 end of the current rule", a_lineno, input_file_name, i);
288 dollar_error(int a_lineno, char *a_line, char *a_cptr)
290 warnx("e - line %d of \"%s\", illegal $-name", a_lineno, input_file_name);
291 print_pos(a_line, a_cptr);
299 warnx("e - line %d of \"%s\", $$ is untyped", lineno, input_file_name);
305 untyped_rhs(int i, char *s)
307 warnx("e - line %d of \"%s\", $%d (%s) is untyped",
308 lineno, input_file_name, i, s);
316 warnx("e - line %d of \"%s\", $%d is untyped", lineno, input_file_name, i);
322 default_action_warning(void)
324 warnx("w - line %d of \"%s\", the default action assigns an \
325 undefined value to $$", lineno, input_file_name);
330 undefined_goal(char *s)
332 warnx("e - the start symbol %s is undefined", s);
338 undefined_symbol_warning(char *s)
340 warnx("w - the symbol %s is undefined", s);