Expand PMF_FN_* macros.
[netbsd-mini2440.git] / external / bsd / byacc / dist / error.c
blob9744f791981cf482df6f0a46b3a5ffd57c15c110
1 /* $NetBSD: error.c,v 1.2 2009/10/29 00:56:19 christos Exp $ */
2 /* Id: error.c,v 1.6 2008/11/24 21:30:35 tom Exp */
4 #include "defs.h"
6 #include <sys/cdefs.h>
7 __RCSID("$NetBSD: error.c,v 1.2 2009/10/29 00:56:19 christos Exp $");
10 /* routines for printing error messages */
12 __dead void
13 fatal(const char *msg)
15 fprintf(stderr, "%s: f - %s\n", myname, msg);
16 done(2);
19 __dead void
20 no_space(void)
22 fprintf(stderr, "%s: f - out of space\n", myname);
23 done(2);
26 __dead void
27 open_error(const char *filename)
29 fprintf(stderr, "%s: f - cannot open \"%s\"\n", myname, filename);
30 done(2);
33 void
34 unexpected_EOF(void)
36 fprintf(stderr, "%s: e - line %d of \"%s\", unexpected end-of-file\n",
37 myname, lineno, input_file_name);
38 done(1);
41 void
42 print_pos(char *st_line, char *st_cptr)
44 char *s;
46 if (st_line == 0)
47 return;
48 for (s = st_line; *s != '\n'; ++s)
50 if (isprint((unsigned char)*s) || *s == '\t')
51 putc(*s, stderr);
52 else
53 putc('?', stderr);
55 putc('\n', stderr);
56 for (s = st_line; s < st_cptr; ++s)
58 if (*s == '\t')
59 putc('\t', stderr);
60 else
61 putc(' ', stderr);
63 putc('^', stderr);
64 putc('\n', stderr);
67 __dead void
68 syntax_error(int st_lineno, char *st_line, char *st_cptr)
70 fprintf(stderr, "%s: e - line %d of \"%s\", syntax error\n",
71 myname, st_lineno, input_file_name);
72 print_pos(st_line, st_cptr);
73 done(1);
76 __dead void
77 unterminated_comment(int c_lineno, char *c_line, char *c_cptr)
79 fprintf(stderr, "%s: e - line %d of \"%s\", unmatched /*\n",
80 myname, c_lineno, input_file_name);
81 print_pos(c_line, c_cptr);
82 done(1);
85 __dead void
86 unterminated_string(int s_lineno, char *s_line, char *s_cptr)
88 fprintf(stderr, "%s: e - line %d of \"%s\", unterminated string\n",
89 myname, s_lineno, input_file_name);
90 print_pos(s_line, s_cptr);
91 done(1);
94 __dead void
95 unterminated_text(int t_lineno, char *t_line, char *t_cptr)
97 fprintf(stderr, "%s: e - line %d of \"%s\", unmatched %%{\n",
98 myname, t_lineno, input_file_name);
99 print_pos(t_line, t_cptr);
100 done(1);
103 __dead void
104 unterminated_union(int u_lineno, char *u_line, char *u_cptr)
106 fprintf(stderr, "%s: e - line %d of \"%s\", unterminated %%union \
107 declaration\n", myname, u_lineno, input_file_name);
108 print_pos(u_line, u_cptr);
109 done(1);
112 __dead void
113 over_unionized(char *u_cptr)
115 fprintf(stderr, "%s: e - line %d of \"%s\", too many %%union \
116 declarations\n", myname, lineno, input_file_name);
117 print_pos(line, u_cptr);
118 done(1);
121 __dead void
122 illegal_tag(int t_lineno, char *t_line, char *t_cptr)
124 fprintf(stderr, "%s: e - line %d of \"%s\", illegal tag\n",
125 myname, t_lineno, input_file_name);
126 print_pos(t_line, t_cptr);
127 done(1);
130 __dead void
131 illegal_character(char *c_cptr)
133 fprintf(stderr, "%s: e - line %d of \"%s\", illegal character\n",
134 myname, lineno, input_file_name);
135 print_pos(line, c_cptr);
136 done(1);
139 __dead void
140 used_reserved(char *s)
142 fprintf(stderr,
143 "%s: e - line %d of \"%s\", illegal use of reserved symbol \
144 %s\n", myname, lineno, input_file_name, s);
145 done(1);
148 __dead void
149 tokenized_start(char *s)
151 fprintf(stderr,
152 "%s: e - line %d of \"%s\", the start symbol %s cannot be \
153 declared to be a token\n", myname, lineno, input_file_name, s);
154 done(1);
157 void
158 retyped_warning(char *s)
160 fprintf(stderr, "%s: w - line %d of \"%s\", the type of %s has been \
161 redeclared\n", myname, lineno, input_file_name, s);
164 void
165 reprec_warning(char *s)
167 fprintf(stderr,
168 "%s: w - line %d of \"%s\", the precedence of %s has been \
169 redeclared\n", myname, lineno, input_file_name, s);
172 void
173 revalued_warning(char *s)
175 fprintf(stderr, "%s: w - line %d of \"%s\", the value of %s has been \
176 redeclared\n", myname, lineno, input_file_name, s);
179 void
180 terminal_start(char *s)
182 fprintf(stderr, "%s: e - line %d of \"%s\", the start symbol %s is a \
183 token\n", myname, lineno, input_file_name, s);
184 done(1);
187 void
188 restarted_warning(void)
190 fprintf(stderr, "%s: w - line %d of \"%s\", the start symbol has been \
191 redeclared\n", myname, lineno, input_file_name);
194 void
195 no_grammar(void)
197 fprintf(stderr, "%s: e - line %d of \"%s\", no grammar has been \
198 specified\n", myname, lineno, input_file_name);
199 done(1);
202 void
203 terminal_lhs(int s_lineno)
205 fprintf(stderr, "%s: e - line %d of \"%s\", a token appears on the lhs \
206 of a production\n", myname, s_lineno, input_file_name);
207 done(1);
210 void
211 prec_redeclared(void)
213 fprintf(stderr, "%s: w - line %d of \"%s\", conflicting %%prec \
214 specifiers\n", myname, lineno, input_file_name);
217 void
218 unterminated_action(int a_lineno, char *a_line, char *a_cptr)
220 fprintf(stderr, "%s: e - line %d of \"%s\", unterminated action\n",
221 myname, a_lineno, input_file_name);
222 print_pos(a_line, a_cptr);
223 done(1);
226 void
227 dollar_warning(int a_lineno, int i)
229 fprintf(stderr, "%s: w - line %d of \"%s\", $%d references beyond the \
230 end of the current rule\n", myname, a_lineno, input_file_name, i);
233 __dead void
234 dollar_error(int a_lineno, char *a_line, char *a_cptr)
236 fprintf(stderr, "%s: e - line %d of \"%s\", illegal $-name\n",
237 myname, a_lineno, input_file_name);
238 print_pos(a_line, a_cptr);
239 done(1);
242 __dead void
243 untyped_lhs(void)
245 fprintf(stderr, "%s: e - line %d of \"%s\", $$ is untyped\n",
246 myname, lineno, input_file_name);
247 done(1);
250 __dead void
251 untyped_rhs(int i, char *s)
253 fprintf(stderr, "%s: e - line %d of \"%s\", $%d (%s) is untyped\n",
254 myname, lineno, input_file_name, i, s);
255 done(1);
258 __dead void
259 unknown_rhs(int i)
261 fprintf(stderr, "%s: e - line %d of \"%s\", $%d is untyped\n",
262 myname, lineno, input_file_name, i);
263 done(1);
266 void
267 default_action_warning(void)
269 fprintf(stderr,
270 "%s: w - line %d of \"%s\", the default action assigns an \
271 undefined value to $$\n", myname, lineno, input_file_name);
274 void
275 undefined_goal(char *s)
277 fprintf(stderr, "%s: e - the start symbol %s is undefined\n", myname, s);
278 done(1);
281 void
282 undefined_symbol_warning(char *s)
284 fprintf(stderr, "%s: w - the symbol %s is undefined\n", myname, s);