vm: merge i386 and arm pagetable code
[minix.git] / external / bsd / byacc / dist / error.c
blob3751a3693c461efd2fd2e5be6b6daf2f28d3ab1c
1 /* $NetBSD: error.c,v 1.7 2011/09/10 21:29:04 christos Exp $ */
2 /* Id: error.c,v 1.9 2011/09/05 23:27:43 tom Exp */
4 #include "defs.h"
6 #include <sys/cdefs.h>
7 __RCSID("$NetBSD: error.c,v 1.7 2011/09/10 21:29:04 christos Exp $");
9 /* routines for printing error messages */
11 __dead void
12 fatal(const char *msg)
14 fprintf(stderr, "%s: f - %s\n", myname, msg);
15 done(2);
18 __dead void
19 no_space(void)
21 fprintf(stderr, "%s: f - out of space\n", myname);
22 done(2);
25 __dead void
26 open_error(const char *filename)
28 fprintf(stderr, "%s: f - cannot open \"%s\"\n", myname, filename);
29 done(2);
32 void
33 missing_brace(void)
35 fprintf(stderr, "%s: e - line %d of \"%s\", missing '}'\n",
36 myname, lineno, input_file_name);
37 done(1);
40 void
41 unexpected_EOF(void)
43 fprintf(stderr, "%s: e - line %d of \"%s\", unexpected end-of-file\n",
44 myname, lineno, input_file_name);
45 done(1);
48 static void
49 print_pos(char *st_line, char *st_cptr)
51 char *s;
53 if (st_line == 0)
54 return;
55 for (s = st_line; *s != '\n'; ++s)
57 if (isprint(UCH(*s)) || *s == '\t')
58 putc(*s, stderr);
59 else
60 putc('?', stderr);
62 putc('\n', stderr);
63 for (s = st_line; s < st_cptr; ++s)
65 if (*s == '\t')
66 putc('\t', stderr);
67 else
68 putc(' ', stderr);
70 putc('^', stderr);
71 putc('\n', stderr);
74 __dead void
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);
80 done(1);
83 __dead void
84 unterminated_comment(int c_lineno, char *c_line, char *c_cptr)
86 fprintf(stderr, "%s: e - line %d of \"%s\", unmatched /*\n",
87 myname, c_lineno, input_file_name);
88 print_pos(c_line, c_cptr);
89 done(1);
92 __dead void
93 unterminated_string(int s_lineno, char *s_line, char *s_cptr)
95 fprintf(stderr, "%s: e - line %d of \"%s\", unterminated string\n",
96 myname, s_lineno, input_file_name);
97 print_pos(s_line, s_cptr);
98 done(1);
101 __dead void
102 unterminated_text(int t_lineno, char *t_line, char *t_cptr)
104 fprintf(stderr, "%s: e - line %d of \"%s\", unmatched %%{\n",
105 myname, t_lineno, input_file_name);
106 print_pos(t_line, t_cptr);
107 done(1);
110 __dead void
111 unterminated_union(int u_lineno, char *u_line, char *u_cptr)
113 fprintf(stderr, "%s: e - line %d of \"%s\", unterminated %%union \
114 declaration\n", myname, u_lineno, input_file_name);
115 print_pos(u_line, u_cptr);
116 done(1);
119 __dead void
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);
125 done(1);
128 __dead void
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);
134 done(1);
137 __dead void
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);
143 done(1);
146 __dead void
147 used_reserved(char *s)
149 fprintf(stderr,
150 "%s: e - line %d of \"%s\", illegal use of reserved symbol \
151 %s\n", myname, lineno, input_file_name, s);
152 done(1);
155 __dead void
156 tokenized_start(char *s)
158 fprintf(stderr,
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);
161 done(1);
164 void
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);
171 void
172 reprec_warning(char *s)
174 fprintf(stderr,
175 "%s: w - line %d of \"%s\", the precedence of %s has been \
176 redeclared\n", myname, lineno, input_file_name, s);
179 void
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);
186 void
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);
191 done(1);
194 void
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);
201 void
202 no_grammar(void)
204 fprintf(stderr, "%s: e - line %d of \"%s\", no grammar has been \
205 specified\n", myname, lineno, input_file_name);
206 done(1);
209 void
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);
214 done(1);
217 void
218 prec_redeclared(void)
220 fprintf(stderr, "%s: w - line %d of \"%s\", conflicting %%prec \
221 specifiers\n", myname, lineno, input_file_name);
224 void
225 unterminated_action(int a_lineno, char *a_line, char *a_cptr)
227 fprintf(stderr, "%s: e - line %d of \"%s\", unterminated action\n",
228 myname, a_lineno, input_file_name);
229 print_pos(a_line, a_cptr);
230 done(1);
233 void
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);
240 __dead void
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);
246 done(1);
249 __dead void
250 untyped_lhs(void)
252 fprintf(stderr, "%s: e - line %d of \"%s\", $$ is untyped\n",
253 myname, lineno, input_file_name);
254 done(1);
257 __dead void
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);
262 done(1);
265 __dead void
266 unknown_rhs(int i)
268 fprintf(stderr, "%s: e - line %d of \"%s\", $%d is untyped\n",
269 myname, lineno, input_file_name, i);
270 done(1);
273 void
274 default_action_warning(void)
276 fprintf(stderr,
277 "%s: w - line %d of \"%s\", the default action assigns an \
278 undefined value to $$\n", myname, lineno, input_file_name);
281 void
282 undefined_goal(char *s)
284 fprintf(stderr, "%s: e - the start symbol %s is undefined\n", myname, s);
285 done(1);
288 void
289 undefined_symbol_warning(char *s)
291 fprintf(stderr, "%s: w - the symbol %s is undefined\n", myname, s);