source: trunk/minix/commands/byacc/error.c@ 9

Last change on this file since 9 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 5.9 KB
Line 
1/* routines for printing error messages */
2
3#include "defs.h"
4
5
6fatal(msg)
7char *msg;
8{
9 fprintf(stderr, "%s: f - %s\n", myname, msg);
10 done(2);
11}
12
13
14no_space()
15{
16 fprintf(stderr, "%s: f - out of space\n", myname);
17 done(2);
18}
19
20
21open_error(filename)
22char *filename;
23{
24 fprintf(stderr, "%s: f - cannot open \"%s\"\n", myname, filename);
25 done(2);
26}
27
28
29unexpected_EOF()
30{
31 fprintf(stderr, "%s: e - line %d of \"%s\", unexpected end-of-file\n",
32 myname, lineno, input_file_name);
33 done(1);
34}
35
36
37print_pos(st_line, st_cptr)
38char *st_line;
39char *st_cptr;
40{
41 register char *s;
42
43 if (st_line == 0) return;
44 for (s = st_line; *s != '\n'; ++s)
45 {
46 if (isprint(*s) || *s == '\t')
47 putc(*s, stderr);
48 else
49 putc('?', stderr);
50 }
51 putc('\n', stderr);
52 for (s = st_line; s < st_cptr; ++s)
53 {
54 if (*s == '\t')
55 putc('\t', stderr);
56 else
57 putc(' ', stderr);
58 }
59 putc('^', stderr);
60 putc('\n', stderr);
61}
62
63
64syntax_error(st_lineno, st_line, st_cptr)
65int st_lineno;
66char *st_line;
67char *st_cptr;
68{
69 fprintf(stderr, "%s: e - line %d of \"%s\", syntax error\n",
70 myname, st_lineno, input_file_name);
71 print_pos(st_line, st_cptr);
72 done(1);
73}
74
75
76unterminated_comment(c_lineno, c_line, c_cptr)
77int c_lineno;
78char *c_line;
79char *c_cptr;
80{
81 fprintf(stderr, "%s: e - line %d of \"%s\", unmatched /*\n",
82 myname, c_lineno, input_file_name);
83 print_pos(c_line, c_cptr);
84 done(1);
85}
86
87
88unterminated_string(s_lineno, s_line, s_cptr)
89int s_lineno;
90char *s_line;
91char *s_cptr;
92{
93 fprintf(stderr, "%s: e - line %d of \"%s\", unterminated string\n",
94 myname, s_lineno, input_file_name);
95 print_pos(s_line, s_cptr);
96 done(1);
97}
98
99
100unterminated_text(t_lineno, t_line, t_cptr)
101int t_lineno;
102char *t_line;
103char *t_cptr;
104{
105 fprintf(stderr, "%s: e - line %d of \"%s\", unmatched %%{\n",
106 myname, t_lineno, input_file_name);
107 print_pos(t_line, t_cptr);
108 done(1);
109}
110
111
112unterminated_union(u_lineno, u_line, u_cptr)
113int u_lineno;
114char *u_line;
115char *u_cptr;
116{
117 fprintf(stderr, "%s: e - line %d of \"%s\", unterminated %%union \
118declaration\n", myname, u_lineno, input_file_name);
119 print_pos(u_line, u_cptr);
120 done(1);
121}
122
123
124over_unionized(u_cptr)
125char *u_cptr;
126{
127 fprintf(stderr, "%s: e - line %d of \"%s\", too many %%union \
128declarations\n", myname, lineno, input_file_name);
129 print_pos(line, u_cptr);
130 done(1);
131}
132
133
134illegal_tag(t_lineno, t_line, t_cptr)
135int t_lineno;
136char *t_line;
137char *t_cptr;
138{
139 fprintf(stderr, "%s: e - line %d of \"%s\", illegal tag\n",
140 myname, t_lineno, input_file_name);
141 print_pos(t_line, t_cptr);
142 done(1);
143}
144
145
146illegal_character(c_cptr)
147char *c_cptr;
148{
149 fprintf(stderr, "%s: e - line %d of \"%s\", illegal character\n",
150 myname, lineno, input_file_name);
151 print_pos(line, c_cptr);
152 done(1);
153}
154
155
156used_reserved(s)
157char *s;
158{
159 fprintf(stderr, "%s: e - line %d of \"%s\", illegal use of reserved symbol \
160%s\n", myname, lineno, input_file_name, s);
161 done(1);
162}
163
164
165tokenized_start(s)
166char *s;
167{
168 fprintf(stderr, "%s: e - line %d of \"%s\", the start symbol %s cannot be \
169declared to be a token\n", myname, lineno, input_file_name, s);
170 done(1);
171}
172
173
174retyped_warning(s)
175char *s;
176{
177 fprintf(stderr, "%s: w - line %d of \"%s\", the type of %s has been \
178redeclared\n", myname, lineno, input_file_name, s);
179}
180
181
182reprec_warning(s)
183char *s;
184{
185 fprintf(stderr, "%s: w - line %d of \"%s\", the precedence of %s has been \
186redeclared\n", myname, lineno, input_file_name, s);
187}
188
189
190revalued_warning(s)
191char *s;
192{
193 fprintf(stderr, "%s: w - line %d of \"%s\", the value of %s has been \
194redeclared\n", myname, lineno, input_file_name, s);
195}
196
197
198terminal_start(s)
199char *s;
200{
201 fprintf(stderr, "%s: e - line %d of \"%s\", the start symbol %s is a \
202token\n", myname, lineno, input_file_name, s);
203 done(1);
204}
205
206
207restarted_warning()
208{
209 fprintf(stderr, "%s: w - line %d of \"%s\", the start symbol has been \
210redeclared\n", myname, lineno, input_file_name);
211}
212
213
214no_grammar()
215{
216 fprintf(stderr, "%s: e - line %d of \"%s\", no grammar has been \
217specified\n", myname, lineno, input_file_name);
218 done(1);
219}
220
221
222terminal_lhs(s_lineno)
223int s_lineno;
224{
225 fprintf(stderr, "%s: e - line %d of \"%s\", a token appears on the lhs \
226of a production\n", myname, s_lineno, input_file_name);
227 done(1);
228}
229
230
231prec_redeclared()
232{
233 fprintf(stderr, "%s: w - line %d of \"%s\", conflicting %%prec \
234specifiers\n", myname, lineno, input_file_name);
235}
236
237
238unterminated_action(a_lineno, a_line, a_cptr)
239int a_lineno;
240char *a_line;
241char *a_cptr;
242{
243 fprintf(stderr, "%s: e - line %d of \"%s\", unterminated action\n",
244 myname, a_lineno, input_file_name);
245 print_pos(a_line, a_cptr);
246 done(1);
247}
248
249
250dollar_warning(a_lineno, i)
251int a_lineno;
252int i;
253{
254 fprintf(stderr, "%s: w - line %d of \"%s\", $%d references beyond the \
255end of the current rule\n", myname, a_lineno, input_file_name, i);
256}
257
258
259dollar_error(a_lineno, a_line, a_cptr)
260int a_lineno;
261char *a_line;
262char *a_cptr;
263{
264 fprintf(stderr, "%s: e - line %d of \"%s\", illegal $-name\n",
265 myname, a_lineno, input_file_name);
266 print_pos(a_line, a_cptr);
267 done(1);
268}
269
270
271untyped_lhs()
272{
273 fprintf(stderr, "%s: e - line %d of \"%s\", $$ is untyped\n",
274 myname, lineno, input_file_name);
275 done(1);
276}
277
278
279untyped_rhs(i, s)
280int i;
281char *s;
282{
283 fprintf(stderr, "%s: e - line %d of \"%s\", $%d (%s) is untyped\n",
284 myname, lineno, input_file_name, i, s);
285 done(1);
286}
287
288
289unknown_rhs(i)
290int i;
291{
292 fprintf(stderr, "%s: e - line %d of \"%s\", $%d is untyped\n",
293 myname, lineno, input_file_name, i);
294 done(1);
295}
296
297
298default_action_warning()
299{
300 fprintf(stderr, "%s: w - line %d of \"%s\", the default action assigns an \
301undefined value to $$\n", myname, lineno, input_file_name);
302}
303
304
305undefined_goal(s)
306char *s;
307{
308 fprintf(stderr, "%s: e - the start symbol %s is undefined\n", myname, s);
309 done(1);
310}
311
312
313undefined_symbol_warning(s)
314char *s;
315{
316 fprintf(stderr, "%s: w - the symbol %s is undefined\n", myname, s);
317}
Note: See TracBrowser for help on using the repository browser.