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