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 */
49 fprintf(stderr
, "%s: f - %s\n", myname
, msg
);
56 fprintf(stderr
, "%s: f - out of space\n", myname
);
64 fprintf(stderr
, "%s: f - cannot open \"%s\"\n", myname
, filename
);
71 fprintf(stderr
, "%s: e - line %d of \"%s\", unexpected end-of-file\n",
72 myname
, lineno
, input_file_name
);
77 print_pos(st_line
, st_cptr
)
83 if (st_line
== 0) return;
84 for (s
= st_line
; *s
!= '\n'; ++s
)
86 if (isprint(*s
) || *s
== '\t')
92 for (s
= st_line
; s
< st_cptr
; ++s
)
104 syntax_error(st_lineno
, st_line
, 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
);
116 unterminated_comment(c_lineno
, c_line
, 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
);
128 unterminated_string(s_lineno
, s_line
, 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
);
140 unterminated_text(t_lineno
, t_line
, 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
);
152 illegal_tag(t_lineno
, t_line
, 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
);
164 illegal_character(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
);
177 fprintf(stderr
, "%s: e - line %d of \"%s\", illegal use of reserved symbol \
178 %s\n", myname
, lineno
, input_file_name
, 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
);
195 fprintf(stderr
, "%s: w - line %d of \"%s\", the type of %s has been \
196 redeclared\n", myname
, lineno
, input_file_name
, 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
);
211 fprintf(stderr
, "%s: w - line %d of \"%s\", the value of %s has been \
212 redeclared\n", myname
, lineno
, input_file_name
, 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
);
227 fprintf(stderr
, "%s: w - line %d of \"%s\", the start symbol has been \
228 redeclared\n", myname
, lineno
, input_file_name
);
234 fprintf(stderr
, "%s: e - line %d of \"%s\", no grammar has been \
235 specified\n", myname
, lineno
, input_file_name
);
240 terminal_lhs(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
);
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
)
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
);
268 dollar_warning(a_lineno
, 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
)
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
);
291 fprintf(stderr
, "%s: w - line %d of \"%s\", $$ is untyped\n",
292 myname
, lineno
, input_file_name
);
301 fprintf(stderr
, "%s: w - line %d of \"%s\", $%d (%s) is untyped\n",
302 myname
, lineno
, input_file_name
, i
, s
);
310 fprintf(stderr
, "%s: e - line %d of \"%s\", $%d is untyped\n",
311 myname
, lineno
, input_file_name
, i
);
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
);
326 fprintf(stderr
, "%s: e - the start symbol %s is undefined\n", myname
, s
);
331 undefined_symbol_warning(s
)
334 fprintf(stderr
, "%s: w - the symbol %s is undefined\n", myname
, s
);