1 /* $NetBSD: error.c,v 1.10 2015/01/04 01:34:20 christos Exp $ */
6 __RCSID("$NetBSD: error.c,v 1.10 2015/01/04 01:34:20 christos Exp $");
7 /* Id: error.c,v 1.11 2014/04/07 22:22:49 tom Exp */
9 /* routines for printing error messages */
12 fatal(const char *msg
)
14 fprintf(stderr
, "%s: f - %s\n", myname
, msg
);
21 fprintf(stderr
, "%s: f - out of space\n", myname
);
26 open_error(const char *filename
)
28 fprintf(stderr
, "%s: f - cannot open \"%s\"\n", myname
, filename
);
35 fprintf(stderr
, "%s: e - line %d of \"%s\", missing '}'\n",
36 myname
, lineno
, input_file_name
);
43 fprintf(stderr
, "%s: e - line %d of \"%s\", unexpected end-of-file\n",
44 myname
, lineno
, input_file_name
);
49 print_pos(const char *st_line
, const char *st_cptr
)
55 for (s
= st_line
; *s
!= '\n'; ++s
)
57 if (isprint(UCH(*s
)) || *s
== '\t')
63 for (s
= st_line
; s
< st_cptr
; ++s
)
75 syntax_error(int st_lineno
, char *st_line
, char *st_cptr
)
77 fprintf(stderr
, "%s: e - line %d of \"%s\", syntax error\n",
78 myname
, st_lineno
, input_file_name
);
79 print_pos(st_line
, st_cptr
);
84 unterminated_comment(const struct ainfo
*a
)
86 fprintf(stderr
, "%s: e - line %d of \"%s\", unmatched /*\n",
87 myname
, a
->a_lineno
, input_file_name
);
88 print_pos(a
->a_line
, a
->a_cptr
);
93 unterminated_string(const struct ainfo
*a
)
95 fprintf(stderr
, "%s: e - line %d of \"%s\", unterminated string\n",
96 myname
, a
->a_lineno
, input_file_name
);
97 print_pos(a
->a_line
, a
->a_cptr
);
102 unterminated_text(const struct ainfo
*a
)
104 fprintf(stderr
, "%s: e - line %d of \"%s\", unmatched %%{\n",
105 myname
, a
->a_lineno
, input_file_name
);
106 print_pos(a
->a_line
, a
->a_cptr
);
111 unterminated_union(const struct ainfo
*a
)
113 fprintf(stderr
, "%s: e - line %d of \"%s\", unterminated %%union \
114 declaration\n", myname
, a
->a_lineno
, input_file_name
);
115 print_pos(a
->a_line
, a
->a_cptr
);
120 over_unionized(char *u_cptr
)
122 fprintf(stderr
, "%s: e - line %d of \"%s\", too many %%union \
123 declarations\n", myname
, lineno
, input_file_name
);
124 print_pos(line
, u_cptr
);
129 illegal_tag(int t_lineno
, char *t_line
, char *t_cptr
)
131 fprintf(stderr
, "%s: e - line %d of \"%s\", illegal tag\n",
132 myname
, t_lineno
, input_file_name
);
133 print_pos(t_line
, t_cptr
);
138 illegal_character(char *c_cptr
)
140 fprintf(stderr
, "%s: e - line %d of \"%s\", illegal character\n",
141 myname
, lineno
, input_file_name
);
142 print_pos(line
, c_cptr
);
147 used_reserved(char *s
)
150 "%s: e - line %d of \"%s\", illegal use of reserved symbol \
151 %s\n", myname
, lineno
, input_file_name
, s
);
156 tokenized_start(char *s
)
159 "%s: e - line %d of \"%s\", the start symbol %s cannot be \
160 declared to be a token\n", myname
, lineno
, input_file_name
, s
);
165 retyped_warning(char *s
)
167 fprintf(stderr
, "%s: w - line %d of \"%s\", the type of %s has been \
168 redeclared\n", myname
, lineno
, input_file_name
, s
);
172 reprec_warning(char *s
)
175 "%s: w - line %d of \"%s\", the precedence of %s has been \
176 redeclared\n", myname
, lineno
, input_file_name
, s
);
180 revalued_warning(char *s
)
182 fprintf(stderr
, "%s: w - line %d of \"%s\", the value of %s has been \
183 redeclared\n", myname
, lineno
, input_file_name
, s
);
187 terminal_start(char *s
)
189 fprintf(stderr
, "%s: e - line %d of \"%s\", the start symbol %s is a \
190 token\n", myname
, lineno
, input_file_name
, s
);
195 restarted_warning(void)
197 fprintf(stderr
, "%s: w - line %d of \"%s\", the start symbol has been \
198 redeclared\n", myname
, lineno
, input_file_name
);
204 fprintf(stderr
, "%s: e - line %d of \"%s\", no grammar has been \
205 specified\n", myname
, lineno
, input_file_name
);
210 terminal_lhs(int s_lineno
)
212 fprintf(stderr
, "%s: e - line %d of \"%s\", a token appears on the lhs \
213 of a production\n", myname
, s_lineno
, input_file_name
);
218 prec_redeclared(void)
220 fprintf(stderr
, "%s: w - line %d of \"%s\", conflicting %%prec \
221 specifiers\n", myname
, lineno
, input_file_name
);
225 unterminated_action(const struct ainfo
*a
)
227 fprintf(stderr
, "%s: e - line %d of \"%s\", unterminated action\n",
228 myname
, a
->a_lineno
, input_file_name
);
229 print_pos(a
->a_line
, a
->a_cptr
);
234 dollar_warning(int a_lineno
, int i
)
236 fprintf(stderr
, "%s: w - line %d of \"%s\", $%d references beyond the \
237 end of the current rule\n", myname
, a_lineno
, input_file_name
, i
);
241 dollar_error(int a_lineno
, char *a_line
, char *a_cptr
)
243 fprintf(stderr
, "%s: e - line %d of \"%s\", illegal $-name\n",
244 myname
, a_lineno
, input_file_name
);
245 print_pos(a_line
, a_cptr
);
252 fprintf(stderr
, "%s: e - line %d of \"%s\", $$ is untyped\n",
253 myname
, lineno
, input_file_name
);
258 untyped_rhs(int i
, char *s
)
260 fprintf(stderr
, "%s: e - line %d of \"%s\", $%d (%s) is untyped\n",
261 myname
, lineno
, input_file_name
, i
, s
);
268 fprintf(stderr
, "%s: e - line %d of \"%s\", $%d is untyped\n",
269 myname
, lineno
, input_file_name
, i
);
274 default_action_warning(void)
277 "%s: w - line %d of \"%s\", the default action assigns an \
278 undefined value to $$\n", myname
, lineno
, input_file_name
);
282 undefined_goal(char *s
)
284 fprintf(stderr
, "%s: e - the start symbol %s is undefined\n", myname
, s
);
289 undefined_symbol_warning(char *s
)
291 fprintf(stderr
, "%s: w - the symbol %s is undefined\n", myname
, s
);
294 #if ! defined(YYBTYACC)
296 unsupported_flag_warning(const char *flag
, const char *details
)
298 fprintf(stderr
, "%s: w - %s flag unsupported, %s\n",
299 myname
, flag
, details
);
303 #if defined(YYBTYACC)
305 at_warning(int a_lineno
, int i
)
307 fprintf(stderr
, "%s: w - line %d of \"%s\", @%d references beyond the \
308 end of the current rule\n", myname
, a_lineno
, input_file_name
, i
);
312 at_error(int a_lineno
, char *a_line
, char *a_cptr
)
315 "%s: e - line %d of \"%s\", illegal @$ or @N reference\n",
316 myname
, a_lineno
, input_file_name
);
317 print_pos(a_line
, a_cptr
);
322 unterminated_arglist(const struct ainfo
*a
)
325 "%s: e - line %d of \"%s\", unterminated argument list\n",
326 myname
, a
->a_lineno
, input_file_name
);
327 print_pos(a
->a_line
, a
->a_cptr
);
332 arg_number_disagree_warning(int a_lineno
, char *a_name
)
334 fprintf(stderr
, "%s: w - line %d of \"%s\", number of arguments of %s "
335 "doesn't agree with previous declaration\n",
336 myname
, a_lineno
, input_file_name
, a_name
);
342 fprintf(stderr
, "%s: e - line %d of \"%s\", bad formal argument list\n",
343 myname
, lineno
, input_file_name
);
344 print_pos(line
, cptr
);
349 arg_type_disagree_warning(int a_lineno
, int i
, char *a_name
)
351 fprintf(stderr
, "%s: w - line %d of \"%s\", type of argument %d "
352 "to %s doesn't agree with previous declaration\n",
353 myname
, a_lineno
, input_file_name
, i
, a_name
);
357 unknown_arg_warning(int d_lineno
, const char *dlr_opt
, const char *d_arg
, const char
358 *d_line
, const char *d_cptr
)
360 fprintf(stderr
, "%s: w - line %d of \"%s\", unknown argument %s%s\n",
361 myname
, d_lineno
, input_file_name
, dlr_opt
, d_arg
);
362 print_pos(d_line
, d_cptr
);
366 untyped_arg_warning(int a_lineno
, const char *dlr_opt
, const char *a_name
)
368 fprintf(stderr
, "%s: w - line %d of \"%s\", untyped argument %s%s\n",
369 myname
, a_lineno
, input_file_name
, dlr_opt
, a_name
);
373 wrong_number_args_warning(const char *which
, const char *a_name
)
376 "%s: w - line %d of \"%s\", wrong number of %sarguments for %s\n",
377 myname
, lineno
, input_file_name
, which
, a_name
);
378 print_pos(line
, cptr
);
382 wrong_type_for_arg_warning(int i
, char *a_name
)
385 "%s: w - line %d of \"%s\", wrong type for default argument %d to %s\n",
386 myname
, lineno
, input_file_name
, i
, a_name
);
387 print_pos(line
, cptr
);
391 start_requires_args(char *a_name
)
394 "%s: w - line %d of \"%s\", start symbol %s requires arguments\n",
395 myname
, 0, input_file_name
, a_name
);
400 destructor_redeclared_warning(const struct ainfo
*a
)
402 fprintf(stderr
, "%s: w - line %d of \"%s\", destructor redeclared\n",
403 myname
, a
->a_lineno
, input_file_name
);
404 print_pos(a
->a_line
, a
->a_cptr
);