dhclient: Log a warning instead of bailing upon "illegal" options
[dragonfly.git] / contrib / byacc / error.c
bloba042aec71e73e203911aa31fd319dfa6695a69c1
1 /* $Id: error.c,v 1.11 2014/04/07 22:22:49 tom Exp $ */
3 /* routines for printing error messages */
5 #include "defs.h"
7 void
8 fatal(const char *msg)
10 fprintf(stderr, "%s: f - %s\n", myname, msg);
11 done(2);
14 void
15 no_space(void)
17 fprintf(stderr, "%s: f - out of space\n", myname);
18 done(2);
21 void
22 open_error(const char *filename)
24 fprintf(stderr, "%s: f - cannot open \"%s\"\n", myname, filename);
25 done(2);
28 void
29 missing_brace(void)
31 fprintf(stderr, "%s: e - line %d of \"%s\", missing '}'\n",
32 myname, lineno, input_file_name);
33 done(1);
36 void
37 unexpected_EOF(void)
39 fprintf(stderr, "%s: e - line %d of \"%s\", unexpected end-of-file\n",
40 myname, lineno, input_file_name);
41 done(1);
44 static void
45 print_pos(const char *st_line, const char *st_cptr)
47 const char *s;
49 if (st_line == 0)
50 return;
51 for (s = st_line; *s != '\n'; ++s)
53 if (isprint(UCH(*s)) || *s == '\t')
54 putc(*s, stderr);
55 else
56 putc('?', stderr);
58 putc('\n', stderr);
59 for (s = st_line; s < st_cptr; ++s)
61 if (*s == '\t')
62 putc('\t', stderr);
63 else
64 putc(' ', stderr);
66 putc('^', stderr);
67 putc('\n', stderr);
70 void
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);
76 done(1);
79 void
80 unterminated_comment(int c_lineno, char *c_line, char *c_cptr)
82 fprintf(stderr, "%s: e - line %d of \"%s\", unmatched /*\n",
83 myname, c_lineno, input_file_name);
84 print_pos(c_line, c_cptr);
85 done(1);
88 void
89 unterminated_string(int s_lineno, char *s_line, char *s_cptr)
91 fprintf(stderr, "%s: e - line %d of \"%s\", unterminated string\n",
92 myname, s_lineno, input_file_name);
93 print_pos(s_line, s_cptr);
94 done(1);
97 void
98 unterminated_text(int t_lineno, char *t_line, char *t_cptr)
100 fprintf(stderr, "%s: e - line %d of \"%s\", unmatched %%{\n",
101 myname, t_lineno, input_file_name);
102 print_pos(t_line, t_cptr);
103 done(1);
106 void
107 unterminated_union(int u_lineno, char *u_line, char *u_cptr)
109 fprintf(stderr, "%s: e - line %d of \"%s\", unterminated %%union \
110 declaration\n", myname, u_lineno, input_file_name);
111 print_pos(u_line, u_cptr);
112 done(1);
115 void
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);
121 done(1);
124 void
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);
130 done(1);
133 void
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);
139 done(1);
142 void
143 used_reserved(char *s)
145 fprintf(stderr,
146 "%s: e - line %d of \"%s\", illegal use of reserved symbol \
147 %s\n", myname, lineno, input_file_name, s);
148 done(1);
151 void
152 tokenized_start(char *s)
154 fprintf(stderr,
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);
157 done(1);
160 void
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);
167 void
168 reprec_warning(char *s)
170 fprintf(stderr,
171 "%s: w - line %d of \"%s\", the precedence of %s has been \
172 redeclared\n", myname, lineno, input_file_name, s);
175 void
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);
182 void
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);
187 done(1);
190 void
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);
197 void
198 no_grammar(void)
200 fprintf(stderr, "%s: e - line %d of \"%s\", no grammar has been \
201 specified\n", myname, lineno, input_file_name);
202 done(1);
205 void
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);
210 done(1);
213 void
214 prec_redeclared(void)
216 fprintf(stderr, "%s: w - line %d of \"%s\", conflicting %%prec \
217 specifiers\n", myname, lineno, input_file_name);
220 void
221 unterminated_action(int a_lineno, char *a_line, char *a_cptr)
223 fprintf(stderr, "%s: e - line %d of \"%s\", unterminated action\n",
224 myname, a_lineno, input_file_name);
225 print_pos(a_line, a_cptr);
226 done(1);
229 void
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);
236 void
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);
242 done(1);
245 void
246 untyped_lhs(void)
248 fprintf(stderr, "%s: e - line %d of \"%s\", $$ is untyped\n",
249 myname, lineno, input_file_name);
250 done(1);
253 void
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);
258 done(1);
261 void
262 unknown_rhs(int i)
264 fprintf(stderr, "%s: e - line %d of \"%s\", $%d is untyped\n",
265 myname, lineno, input_file_name, i);
266 done(1);
269 void
270 default_action_warning(void)
272 fprintf(stderr,
273 "%s: w - line %d of \"%s\", the default action assigns an \
274 undefined value to $$\n", myname, lineno, input_file_name);
277 void
278 undefined_goal(char *s)
280 fprintf(stderr, "%s: e - the start symbol %s is undefined\n", myname, s);
281 done(1);
284 void
285 undefined_symbol_warning(char *s)
287 fprintf(stderr, "%s: w - the symbol %s is undefined\n", myname, s);
290 #if ! defined(YYBTYACC)
291 void
292 unsupported_flag_warning(const char *flag, const char *details)
294 fprintf(stderr, "%s: w - %s flag unsupported, %s\n",
295 myname, flag, details);
297 #endif
299 #if defined(YYBTYACC)
300 void
301 at_warning(int a_lineno, int i)
303 fprintf(stderr, "%s: w - line %d of \"%s\", @%d references beyond the \
304 end of the current rule\n", myname, a_lineno, input_file_name, i);
307 void
308 at_error(int a_lineno, char *a_line, char *a_cptr)
310 fprintf(stderr,
311 "%s: e - line %d of \"%s\", illegal @$ or @N reference\n",
312 myname, a_lineno, input_file_name);
313 print_pos(a_line, a_cptr);
314 done(1);
317 void
318 unterminated_arglist(int a_lineno, char *a_line, char *a_cptr)
320 fprintf(stderr,
321 "%s: e - line %d of \"%s\", unterminated argument list\n",
322 myname, a_lineno, input_file_name);
323 print_pos(a_line, a_cptr);
324 done(1);
327 void
328 arg_number_disagree_warning(int a_lineno, char *a_name)
330 fprintf(stderr, "%s: w - line %d of \"%s\", number of arguments of %s "
331 "doesn't agree with previous declaration\n",
332 myname, a_lineno, input_file_name, a_name);
335 void
336 bad_formals(void)
338 fprintf(stderr, "%s: e - line %d of \"%s\", bad formal argument list\n",
339 myname, lineno, input_file_name);
340 print_pos(line, cptr);
341 done(1);
344 void
345 arg_type_disagree_warning(int a_lineno, int i, char *a_name)
347 fprintf(stderr, "%s: w - line %d of \"%s\", type of argument %d "
348 "to %s doesn't agree with previous declaration\n",
349 myname, a_lineno, input_file_name, i, a_name);
352 void
353 unknown_arg_warning(int d_lineno, const char *dlr_opt, const char *d_arg, const char
354 *d_line, const char *d_cptr)
356 fprintf(stderr, "%s: w - line %d of \"%s\", unknown argument %s%s\n",
357 myname, d_lineno, input_file_name, dlr_opt, d_arg);
358 print_pos(d_line, d_cptr);
361 void
362 untyped_arg_warning(int a_lineno, const char *dlr_opt, const char *a_name)
364 fprintf(stderr, "%s: w - line %d of \"%s\", untyped argument %s%s\n",
365 myname, a_lineno, input_file_name, dlr_opt, a_name);
368 void
369 wrong_number_args_warning(const char *which, const char *a_name)
371 fprintf(stderr,
372 "%s: w - line %d of \"%s\", wrong number of %sarguments for %s\n",
373 myname, lineno, input_file_name, which, a_name);
374 print_pos(line, cptr);
377 void
378 wrong_type_for_arg_warning(int i, char *a_name)
380 fprintf(stderr,
381 "%s: w - line %d of \"%s\", wrong type for default argument %d to %s\n",
382 myname, lineno, input_file_name, i, a_name);
383 print_pos(line, cptr);
386 void
387 start_requires_args(char *a_name)
389 fprintf(stderr,
390 "%s: w - line %d of \"%s\", start symbol %s requires arguments\n",
391 myname, 0, input_file_name, a_name);
395 void
396 destructor_redeclared_warning(int a_lineno, char *a_line, char *a_cptr)
398 fprintf(stderr, "%s: w - line %d of \"%s\", destructor redeclared\n",
399 myname, a_lineno, input_file_name);
400 print_pos(a_line, a_cptr);
402 #endif