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
38 static char sccsid
[] = "@(#)error.c 5.3 (Berkeley) 6/1/90";
41 /* routines for printing error messages */
46 fatal (const char *msg
)
48 fprintf(stderr
, "%s: f - %s\n", myname
, msg
);
55 fprintf(stderr
, "%s: f - out of space\n", myname
);
60 open_error (const char *filename
)
62 fprintf(stderr
, "%s: f - cannot open \"%s\"\n", myname
, filename
);
69 fprintf(stderr
, "%s: e - line %d of \"%s\", unexpected end-of-file\n",
70 myname
, lineno
, input_file_name
);
75 print_pos (const char *st_line
, const char *st_cptr
)
79 if (st_line
== 0) return;
80 for (s
= st_line
; *s
!= '\n'; ++s
)
82 if (isprint(*s
) || *s
== '\t')
88 for (s
= st_line
; s
< st_cptr
; ++s
)
100 syntax_error (int st_lineno
, const char *st_line
, const char *st_cptr
)
102 fprintf(stderr
, "%s: e - line %d of \"%s\", syntax error\n",
103 myname
, st_lineno
, input_file_name
);
104 print_pos(st_line
, st_cptr
);
109 unterminated_comment (int c_lineno
, const char *c_line
, const char *c_cptr
)
111 fprintf(stderr
, "%s: e - line %d of \"%s\", unmatched /*\n",
112 myname
, c_lineno
, input_file_name
);
113 print_pos(c_line
, c_cptr
);
118 unterminated_string (int s_lineno
, const char *s_line
, const char *s_cptr
)
120 fprintf(stderr
, "%s: e - line %d of \"%s\", unterminated string\n",
121 myname
, s_lineno
, input_file_name
);
122 print_pos(s_line
, s_cptr
);
127 unterminated_text (int t_lineno
, const char *t_line
, const char *t_cptr
)
129 fprintf(stderr
, "%s: e - line %d of \"%s\", unmatched %%{\n",
130 myname
, t_lineno
, input_file_name
);
131 print_pos(t_line
, t_cptr
);
136 illegal_tag (int t_lineno
, const char *t_line
, const char *t_cptr
)
138 fprintf(stderr
, "%s: e - line %d of \"%s\", illegal tag\n",
139 myname
, t_lineno
, input_file_name
);
140 print_pos(t_line
, t_cptr
);
145 illegal_character (const char *c_cptr
)
147 fprintf(stderr
, "%s: e - line %d of \"%s\", illegal character\n",
148 myname
, lineno
, input_file_name
);
149 print_pos(line
, c_cptr
);
154 used_reserved (const char *s
)
156 fprintf(stderr
, "%s: e - line %d of \"%s\", illegal use of reserved symbol \
157 %s\n", myname
, lineno
, input_file_name
, s
);
162 tokenized_start (const char *s
)
164 fprintf(stderr
, "%s: e - line %d of \"%s\", the start symbol %s cannot be \
165 declared to be a token\n", myname
, lineno
, input_file_name
, s
);
170 retyped_warning (const char *s
)
172 fprintf(stderr
, "%s: w - line %d of \"%s\", the type of %s has been \
173 redeclared\n", myname
, lineno
, input_file_name
, s
);
177 reprec_warning (const char *s
)
179 fprintf(stderr
, "%s: w - line %d of \"%s\", the precedence of %s has been \
180 redeclared\n", myname
, lineno
, input_file_name
, s
);
184 revalued_warning (const char *s
)
186 fprintf(stderr
, "%s: w - line %d of \"%s\", the value of %s has been \
187 redeclared\n", myname
, lineno
, input_file_name
, s
);
191 terminal_start (const char *s
)
193 fprintf(stderr
, "%s: e - line %d of \"%s\", the start symbol %s is a \
194 token\n", myname
, lineno
, input_file_name
, s
);
199 restarted_warning (void)
201 fprintf(stderr
, "%s: w - line %d of \"%s\", the start symbol has been \
202 redeclared\n", myname
, lineno
, input_file_name
);
208 fprintf(stderr
, "%s: e - line %d of \"%s\", no grammar has been \
209 specified\n", myname
, lineno
, input_file_name
);
214 terminal_lhs (int s_lineno
)
216 fprintf(stderr
, "%s: e - line %d of \"%s\", a token appears on the lhs \
217 of a production\n", myname
, s_lineno
, input_file_name
);
222 prec_redeclared (void)
224 fprintf(stderr
, "%s: w - line %d of \"%s\", conflicting %%prec \
225 specifiers\n", myname
, lineno
, input_file_name
);
229 unterminated_action (int a_lineno
, const char *a_line
, const char *a_cptr
)
231 fprintf(stderr
, "%s: e - line %d of \"%s\", unterminated action\n",
232 myname
, a_lineno
, input_file_name
);
233 print_pos(a_line
, a_cptr
);
238 dollar_warning (int a_lineno
, int i
)
240 fprintf(stderr
, "%s: w - line %d of \"%s\", $%d references beyond the \
241 end of the current rule\n", myname
, a_lineno
, input_file_name
, i
);
245 dollar_error (int a_lineno
, const char *a_line
, char *a_cptr
)
247 fprintf(stderr
, "%s: e - line %d of \"%s\", illegal $-name\n",
248 myname
, a_lineno
, input_file_name
);
249 print_pos(a_line
, a_cptr
);
256 fprintf(stderr
, "%s: w - line %d of \"%s\", $$ is untyped\n",
257 myname
, lineno
, input_file_name
);
262 untyped_rhs (int i
, const char *s
)
264 fprintf(stderr
, "%s: w - line %d of \"%s\", $%d (%s) is untyped\n",
265 myname
, lineno
, input_file_name
, i
, s
);
272 fprintf(stderr
, "%s: e - line %d of \"%s\", $%d is untyped\n",
273 myname
, lineno
, input_file_name
, i
);
278 default_action_warning (void)
280 fprintf(stderr
, "%s: w - line %d of \"%s\", the default action assigns an \
281 undefined value to $$\n", myname
, lineno
, input_file_name
);
285 undefined_goal (const char *s
)
287 fprintf(stderr
, "%s: e - the start symbol %s is undefined\n", myname
, s
);
292 undefined_symbol_warning (const char *s
)
294 fprintf(stderr
, "%s: w - the symbol %s is undefined\n", myname
, s
);