don't bother resolving onbld python module deps
[unleashed.git] / bin / yacc / error.c
blobeed83b53675f7f67f61020425a064037387d8aa6
1 /* $OpenBSD: error.c,v 1.14 2014/03/08 01:05:39 tedu Exp $ */
2 /* $NetBSD: error.c,v 1.4 1996/03/19 03:21:32 jtc Exp $ */
4 /*
5 * Copyright (c) 1989 The Regents of the University of California.
6 * All rights reserved.
8 * This code is derived from software contributed to Berkeley by
9 * Robert Paul Corbett.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
36 /* routines for printing error messages */
38 #include "defs.h"
41 void
42 fatal(char *msg)
44 fprintf(stderr, "%s: %s\n", input_file_name, msg);
45 done(2);
49 void
50 no_space(void)
52 fprintf(stderr, "%s: yacc is out of space\n", input_file_name);
53 done(2);
57 void
58 open_error(char *filename)
60 fprintf(stderr, "%s: cannot open source file %s\n",
61 input_file_name, filename);
62 done(2);
65 void
66 open_write_error(char *filename)
68 fprintf(stderr, "%s: cannot open target file %s for writing\n",
69 input_file_name, filename);
70 done(2);
73 void
74 unexpected_EOF(void)
76 fprintf(stderr, "%s:%d: unexpected end-of-file\n",
77 input_file_name, lineno);
78 done(1);
82 void
83 print_pos(char *st_line, char *st_cptr)
85 char *s;
87 if (st_line == 0)
88 return;
89 for (s = st_line; *s != '\n'; ++s) {
90 if (isprint((unsigned char)*s) || *s == '\t')
91 putc(*s, stderr);
92 else
93 putc('?', stderr);
95 putc('\n', stderr);
96 for (s = st_line; s < st_cptr; ++s) {
97 if (*s == '\t')
98 putc('\t', stderr);
99 else
100 putc(' ', stderr);
102 putc('^', stderr);
103 putc('\n', stderr);
106 void
107 syntax_error(int st_lineno, char *st_line, char *st_cptr)
109 fprintf(stderr, "%s:%d: syntax error\n",
110 input_file_name, st_lineno);
111 print_pos(st_line, st_cptr);
112 done(1);
115 void
116 unterminated_comment(int c_lineno, char *c_line, char *c_cptr)
118 fprintf(stderr, "%s:%d: unmatched /*\n",
119 input_file_name, c_lineno);
120 print_pos(c_line, c_cptr);
121 done(1);
124 void
125 unterminated_string(int s_lineno, char *s_line, char *s_cptr)
127 fprintf(stderr, "%s:%d:, unterminated string\n",
128 input_file_name, s_lineno);
129 print_pos(s_line, s_cptr);
130 done(1);
133 void
134 unterminated_text(int t_lineno, char *t_line, char *t_cptr)
136 fprintf(stderr, "%s:%d: unmatched %%{\n",
137 input_file_name, t_lineno);
138 print_pos(t_line, t_cptr);
139 done(1);
142 void
143 unterminated_union(int u_lineno, char *u_line, char *u_cptr)
145 fprintf(stderr, "%s:%d: unterminated %%union declaration\n",
146 input_file_name, u_lineno);
147 print_pos(u_line, u_cptr);
148 done(1);
151 void
152 over_unionized(char *u_cptr)
154 fprintf(stderr, "%s:%d: too many %%union declarations\n",
155 input_file_name, lineno);
156 print_pos(line, u_cptr);
157 done(1);
160 void
161 illegal_tag(int t_lineno, char *t_line, char *t_cptr)
163 fprintf(stderr, "%s:%d: illegal tag\n",
164 input_file_name, t_lineno);
165 print_pos(t_line, t_cptr);
166 done(1);
170 void
171 illegal_character(char *c_cptr)
173 fprintf(stderr, "%s:%d: illegal character\n",
174 input_file_name, lineno);
175 print_pos(line, c_cptr);
176 done(1);
180 void
181 used_reserved(char *s)
183 fprintf(stderr, "%s:%d: illegal use of reserved symbol %s\n",
184 input_file_name, lineno, s);
185 done(1);
188 void
189 tokenized_start(char *s)
191 fprintf(stderr, "%s:%d: the start symbol %s cannot be declared to be a token\n",
192 input_file_name, lineno, s);
193 done(1);
196 void
197 retyped_warning(char *s)
199 fprintf(stderr, "%s:%d: the type of %s has been redeclared\n",
200 input_file_name, lineno, s);
203 void
204 reprec_warning(char *s)
206 fprintf(stderr, "%s:%d: the precedence of %s has been redeclared\n",
207 input_file_name, lineno, s);
210 void
211 revalued_warning(char *s)
213 fprintf(stderr, "%s:%d: the value of %s has been redeclared\n",
214 input_file_name, lineno, s);
217 void
218 terminal_start(char *s)
220 fprintf(stderr, "%s:%d: the start symbol %s is a token\n",
221 input_file_name, lineno, s);
222 done(1);
225 void
226 restarted_warning(void)
228 fprintf(stderr, "%s:%d: the start symbol has been redeclared\n",
229 input_file_name, lineno);
232 void
233 no_grammar(void)
235 fprintf(stderr, "%s:%d: no grammar has been specified\n",
236 input_file_name, lineno);
237 done(1);
240 void
241 terminal_lhs(int s_lineno)
243 fprintf(stderr, "%s:%d: a token appears on the lhs of a production\n",
244 input_file_name, s_lineno);
245 done(1);
248 void
249 prec_redeclared(void)
251 fprintf(stderr, "%s:%d: conflicting %%prec specifiers\n",
252 input_file_name, lineno);
255 void
256 unterminated_action(int a_lineno, char *a_line, char *a_cptr)
258 fprintf(stderr, "%s:%d: unterminated action\n",
259 input_file_name, a_lineno);
260 print_pos(a_line, a_cptr);
261 done(1);
264 void
265 dollar_warning(int a_lineno, int i)
267 fprintf(stderr, "%s:%d: $%d references beyond the end of the current rule\n",
268 input_file_name, a_lineno, i);
271 void
272 dollar_error(int a_lineno, char *a_line, char *a_cptr)
274 fprintf(stderr, "%s:%d: illegal $-name\n",
275 input_file_name, a_lineno);
276 print_pos(a_line, a_cptr);
277 done(1);
281 void
282 untyped_lhs(void)
284 fprintf(stderr, "%s:%d: $$ is untyped\n",
285 input_file_name, lineno);
286 done(1);
289 void
290 untyped_rhs(int i, char *s)
292 fprintf(stderr, "%s:%d: $%d (%s) is untyped\n",
293 input_file_name, lineno, i, s);
294 done(1);
297 void
298 unknown_rhs(int i)
300 fprintf(stderr, "%s:%d: $%d is untyped\n",
301 input_file_name, lineno, i);
302 done(1);
305 void
306 default_action_warning(void)
308 fprintf(stderr, "%s:%d: the default action assigns an undefined value to $$\n",
309 input_file_name, lineno);
312 void
313 undefined_goal(char *s)
315 fprintf(stderr, "%s: the start symbol %s is undefined\n", input_file_name, s);
316 done(1);
319 void
320 undefined_symbol_warning(char *s)
322 fprintf(stderr, "%s: the symbol %s is undefined\n", input_file_name, s);