1 /* $Id: error.c,v 1.14 2016/12/02 18:35:55 tom Exp $ */
3 /* routines for printing error messages */
10 fprintf(stderr
, "%s: f - %s\n", myname
, msg
);
17 fprintf(stderr
, "%s: f - out of space\n", myname
);
22 open_error(const char *filename
)
24 fprintf(stderr
, "%s: f - cannot open \"%s\"\n", myname
, filename
);
31 fprintf(stderr
, "%s: e - line %d of \"%s\", missing '}'\n",
32 myname
, lineno
, input_file_name
);
39 fprintf(stderr
, "%s: e - line %d of \"%s\", unexpected end-of-file\n",
40 myname
, lineno
, input_file_name
);
45 print_pos(const char *st_line
, const char *st_cptr
)
51 for (s
= st_line
; *s
!= '\n'; ++s
)
53 if (isprint(UCH(*s
)) || *s
== '\t')
59 for (s
= st_line
; s
< st_cptr
; ++s
)
71 syntax_error(int st_lineno
, char *st_line
, char *st_cptr
)
73 fprintf(stderr
, "%s: e - line %d of \"%s\", syntax error\n",
74 myname
, st_lineno
, input_file_name
);
75 print_pos(st_line
, st_cptr
);
80 unterminated_comment(const struct ainfo
*a
)
82 fprintf(stderr
, "%s: e - line %d of \"%s\", unmatched /*\n",
83 myname
, a
->a_lineno
, input_file_name
);
84 print_pos(a
->a_line
, a
->a_cptr
);
89 unterminated_string(const struct ainfo
*a
)
91 fprintf(stderr
, "%s: e - line %d of \"%s\", unterminated string\n",
92 myname
, a
->a_lineno
, input_file_name
);
93 print_pos(a
->a_line
, a
->a_cptr
);
98 unterminated_text(const struct ainfo
*a
)
100 fprintf(stderr
, "%s: e - line %d of \"%s\", unmatched %%{\n",
101 myname
, a
->a_lineno
, input_file_name
);
102 print_pos(a
->a_line
, a
->a_cptr
);
107 unterminated_union(const struct ainfo
*a
)
109 fprintf(stderr
, "%s: e - line %d of \"%s\", unterminated %%union \
110 declaration\n", myname
, a
->a_lineno
, input_file_name
);
111 print_pos(a
->a_line
, a
->a_cptr
);
116 over_unionized(char *u_cptr
)
118 fprintf(stderr
, "%s: e - line %d of \"%s\", too many %%union \
119 declarations\n", myname
, lineno
, input_file_name
);
120 print_pos(line
, u_cptr
);
125 illegal_tag(int t_lineno
, char *t_line
, char *t_cptr
)
127 fprintf(stderr
, "%s: e - line %d of \"%s\", illegal tag\n",
128 myname
, t_lineno
, input_file_name
);
129 print_pos(t_line
, t_cptr
);
134 illegal_character(char *c_cptr
)
136 fprintf(stderr
, "%s: e - line %d of \"%s\", illegal character\n",
137 myname
, lineno
, input_file_name
);
138 print_pos(line
, c_cptr
);
143 used_reserved(char *s
)
146 "%s: e - line %d of \"%s\", illegal use of reserved symbol \
147 %s\n", myname
, lineno
, input_file_name
, s
);
152 tokenized_start(char *s
)
155 "%s: e - line %d of \"%s\", the start symbol %s cannot be \
156 declared to be a token\n", myname
, lineno
, input_file_name
, s
);
161 retyped_warning(char *s
)
163 fprintf(stderr
, "%s: w - line %d of \"%s\", the type of %s has been \
164 redeclared\n", myname
, lineno
, input_file_name
, s
);
168 reprec_warning(char *s
)
171 "%s: w - line %d of \"%s\", the precedence of %s has been \
172 redeclared\n", myname
, lineno
, input_file_name
, s
);
176 revalued_warning(char *s
)
178 fprintf(stderr
, "%s: w - line %d of \"%s\", the value of %s has been \
179 redeclared\n", myname
, lineno
, input_file_name
, s
);
183 terminal_start(char *s
)
185 fprintf(stderr
, "%s: e - line %d of \"%s\", the start symbol %s is a \
186 token\n", myname
, lineno
, input_file_name
, s
);
191 restarted_warning(void)
193 fprintf(stderr
, "%s: w - line %d of \"%s\", the start symbol has been \
194 redeclared\n", myname
, lineno
, input_file_name
);
200 fprintf(stderr
, "%s: e - line %d of \"%s\", no grammar has been \
201 specified\n", myname
, lineno
, input_file_name
);
206 terminal_lhs(int s_lineno
)
208 fprintf(stderr
, "%s: e - line %d of \"%s\", a token appears on the lhs \
209 of a production\n", myname
, s_lineno
, input_file_name
);
214 prec_redeclared(void)
216 fprintf(stderr
, "%s: w - line %d of \"%s\", conflicting %%prec \
217 specifiers\n", myname
, lineno
, input_file_name
);
221 unterminated_action(const struct ainfo
*a
)
223 fprintf(stderr
, "%s: e - line %d of \"%s\", unterminated action\n",
224 myname
, a
->a_lineno
, input_file_name
);
225 print_pos(a
->a_line
, a
->a_cptr
);
230 dollar_warning(int a_lineno
, int i
)
232 fprintf(stderr
, "%s: w - line %d of \"%s\", $%d references beyond the \
233 end of the current rule\n", myname
, a_lineno
, input_file_name
, i
);
237 dollar_error(int a_lineno
, char *a_line
, char *a_cptr
)
239 fprintf(stderr
, "%s: e - line %d of \"%s\", illegal $-name\n",
240 myname
, a_lineno
, input_file_name
);
241 print_pos(a_line
, a_cptr
);
248 fprintf(stderr
, "%s: e - line %d of \"%s\", $$ is untyped\n",
249 myname
, lineno
, input_file_name
);
254 untyped_rhs(int i
, char *s
)
256 fprintf(stderr
, "%s: e - line %d of \"%s\", $%d (%s) is untyped\n",
257 myname
, lineno
, input_file_name
, i
, s
);
264 fprintf(stderr
, "%s: e - line %d of \"%s\", $%d is untyped\n",
265 myname
, lineno
, input_file_name
, i
);
270 default_action_warning(char *s
)
273 "%s: w - line %d of \"%s\", the default action for %s assigns an \
274 undefined value to $$\n",
275 myname
, lineno
, input_file_name
, s
);
279 undefined_goal(char *s
)
281 fprintf(stderr
, "%s: e - the start symbol %s is undefined\n", myname
, s
);
286 undefined_symbol_warning(char *s
)
288 fprintf(stderr
, "%s: w - the symbol %s is undefined\n", myname
, s
);
291 #if ! defined(YYBTYACC)
293 unsupported_flag_warning(const char *flag
, const char *details
)
295 fprintf(stderr
, "%s: w - %s flag unsupported, %s\n",
296 myname
, flag
, details
);
300 #if defined(YYBTYACC)
302 at_warning(int a_lineno
, int i
)
304 fprintf(stderr
, "%s: w - line %d of \"%s\", @%d references beyond the \
305 end of the current rule\n", myname
, a_lineno
, input_file_name
, i
);
309 at_error(int a_lineno
, char *a_line
, char *a_cptr
)
312 "%s: e - line %d of \"%s\", illegal @$ or @N reference\n",
313 myname
, a_lineno
, input_file_name
);
314 print_pos(a_line
, a_cptr
);
319 unterminated_arglist(const struct ainfo
*a
)
322 "%s: e - line %d of \"%s\", unterminated argument list\n",
323 myname
, a
->a_lineno
, input_file_name
);
324 print_pos(a
->a_line
, a
->a_cptr
);
329 arg_number_disagree_warning(int a_lineno
, char *a_name
)
331 fprintf(stderr
, "%s: w - line %d of \"%s\", number of arguments of %s "
332 "doesn't agree with previous declaration\n",
333 myname
, a_lineno
, input_file_name
, a_name
);
339 fprintf(stderr
, "%s: e - line %d of \"%s\", bad formal argument list\n",
340 myname
, lineno
, input_file_name
);
341 print_pos(line
, cptr
);
346 arg_type_disagree_warning(int a_lineno
, int i
, char *a_name
)
348 fprintf(stderr
, "%s: w - line %d of \"%s\", type of argument %d "
349 "to %s doesn't agree with previous declaration\n",
350 myname
, a_lineno
, input_file_name
, i
, a_name
);
354 unknown_arg_warning(int d_lineno
, const char *dlr_opt
, const char *d_arg
, const char
355 *d_line
, const char *d_cptr
)
357 fprintf(stderr
, "%s: w - line %d of \"%s\", unknown argument %s%s\n",
358 myname
, d_lineno
, input_file_name
, dlr_opt
, d_arg
);
359 print_pos(d_line
, d_cptr
);
363 untyped_arg_warning(int a_lineno
, const char *dlr_opt
, const char *a_name
)
365 fprintf(stderr
, "%s: w - line %d of \"%s\", untyped argument %s%s\n",
366 myname
, a_lineno
, input_file_name
, dlr_opt
, a_name
);
370 wrong_number_args_warning(const char *which
, const char *a_name
)
373 "%s: w - line %d of \"%s\", wrong number of %sarguments for %s\n",
374 myname
, lineno
, input_file_name
, which
, a_name
);
375 print_pos(line
, cptr
);
379 wrong_type_for_arg_warning(int i
, char *a_name
)
382 "%s: w - line %d of \"%s\", wrong type for default argument %d to %s\n",
383 myname
, lineno
, input_file_name
, i
, a_name
);
384 print_pos(line
, cptr
);
388 start_requires_args(char *a_name
)
391 "%s: w - line %d of \"%s\", start symbol %s requires arguments\n",
392 myname
, 0, input_file_name
, a_name
);
397 destructor_redeclared_warning(const struct ainfo
*a
)
399 fprintf(stderr
, "%s: w - line %d of \"%s\", destructor redeclared\n",
400 myname
, a
->a_lineno
, input_file_name
);
401 print_pos(a
->a_line
, a
->a_cptr
);