[9] | 1 | /* routines for printing error messages */
|
---|
| 2 |
|
---|
| 3 | #include "defs.h"
|
---|
| 4 |
|
---|
| 5 |
|
---|
| 6 | fatal(msg)
|
---|
| 7 | char *msg;
|
---|
| 8 | {
|
---|
| 9 | fprintf(stderr, "%s: f - %s\n", myname, msg);
|
---|
| 10 | done(2);
|
---|
| 11 | }
|
---|
| 12 |
|
---|
| 13 |
|
---|
| 14 | no_space()
|
---|
| 15 | {
|
---|
| 16 | fprintf(stderr, "%s: f - out of space\n", myname);
|
---|
| 17 | done(2);
|
---|
| 18 | }
|
---|
| 19 |
|
---|
| 20 |
|
---|
| 21 | open_error(filename)
|
---|
| 22 | char *filename;
|
---|
| 23 | {
|
---|
| 24 | fprintf(stderr, "%s: f - cannot open \"%s\"\n", myname, filename);
|
---|
| 25 | done(2);
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 |
|
---|
| 29 | unexpected_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 |
|
---|
| 37 | print_pos(st_line, st_cptr)
|
---|
| 38 | char *st_line;
|
---|
| 39 | char *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 |
|
---|
| 64 | syntax_error(st_lineno, st_line, st_cptr)
|
---|
| 65 | int st_lineno;
|
---|
| 66 | char *st_line;
|
---|
| 67 | char *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 |
|
---|
| 76 | unterminated_comment(c_lineno, c_line, c_cptr)
|
---|
| 77 | int c_lineno;
|
---|
| 78 | char *c_line;
|
---|
| 79 | char *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 |
|
---|
| 88 | unterminated_string(s_lineno, s_line, s_cptr)
|
---|
| 89 | int s_lineno;
|
---|
| 90 | char *s_line;
|
---|
| 91 | char *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 |
|
---|
| 100 | unterminated_text(t_lineno, t_line, t_cptr)
|
---|
| 101 | int t_lineno;
|
---|
| 102 | char *t_line;
|
---|
| 103 | char *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 |
|
---|
| 112 | unterminated_union(u_lineno, u_line, u_cptr)
|
---|
| 113 | int u_lineno;
|
---|
| 114 | char *u_line;
|
---|
| 115 | char *u_cptr;
|
---|
| 116 | {
|
---|
| 117 | fprintf(stderr, "%s: e - line %d of \"%s\", unterminated %%union \
|
---|
| 118 | declaration\n", myname, u_lineno, input_file_name);
|
---|
| 119 | print_pos(u_line, u_cptr);
|
---|
| 120 | done(1);
|
---|
| 121 | }
|
---|
| 122 |
|
---|
| 123 |
|
---|
| 124 | over_unionized(u_cptr)
|
---|
| 125 | char *u_cptr;
|
---|
| 126 | {
|
---|
| 127 | fprintf(stderr, "%s: e - line %d of \"%s\", too many %%union \
|
---|
| 128 | declarations\n", myname, lineno, input_file_name);
|
---|
| 129 | print_pos(line, u_cptr);
|
---|
| 130 | done(1);
|
---|
| 131 | }
|
---|
| 132 |
|
---|
| 133 |
|
---|
| 134 | illegal_tag(t_lineno, t_line, t_cptr)
|
---|
| 135 | int t_lineno;
|
---|
| 136 | char *t_line;
|
---|
| 137 | char *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 |
|
---|
| 146 | illegal_character(c_cptr)
|
---|
| 147 | char *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 |
|
---|
| 156 | used_reserved(s)
|
---|
| 157 | char *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 |
|
---|
| 165 | tokenized_start(s)
|
---|
| 166 | char *s;
|
---|
| 167 | {
|
---|
| 168 | fprintf(stderr, "%s: e - line %d of \"%s\", the start symbol %s cannot be \
|
---|
| 169 | declared to be a token\n", myname, lineno, input_file_name, s);
|
---|
| 170 | done(1);
|
---|
| 171 | }
|
---|
| 172 |
|
---|
| 173 |
|
---|
| 174 | retyped_warning(s)
|
---|
| 175 | char *s;
|
---|
| 176 | {
|
---|
| 177 | fprintf(stderr, "%s: w - line %d of \"%s\", the type of %s has been \
|
---|
| 178 | redeclared\n", myname, lineno, input_file_name, s);
|
---|
| 179 | }
|
---|
| 180 |
|
---|
| 181 |
|
---|
| 182 | reprec_warning(s)
|
---|
| 183 | char *s;
|
---|
| 184 | {
|
---|
| 185 | fprintf(stderr, "%s: w - line %d of \"%s\", the precedence of %s has been \
|
---|
| 186 | redeclared\n", myname, lineno, input_file_name, s);
|
---|
| 187 | }
|
---|
| 188 |
|
---|
| 189 |
|
---|
| 190 | revalued_warning(s)
|
---|
| 191 | char *s;
|
---|
| 192 | {
|
---|
| 193 | fprintf(stderr, "%s: w - line %d of \"%s\", the value of %s has been \
|
---|
| 194 | redeclared\n", myname, lineno, input_file_name, s);
|
---|
| 195 | }
|
---|
| 196 |
|
---|
| 197 |
|
---|
| 198 | terminal_start(s)
|
---|
| 199 | char *s;
|
---|
| 200 | {
|
---|
| 201 | fprintf(stderr, "%s: e - line %d of \"%s\", the start symbol %s is a \
|
---|
| 202 | token\n", myname, lineno, input_file_name, s);
|
---|
| 203 | done(1);
|
---|
| 204 | }
|
---|
| 205 |
|
---|
| 206 |
|
---|
| 207 | restarted_warning()
|
---|
| 208 | {
|
---|
| 209 | fprintf(stderr, "%s: w - line %d of \"%s\", the start symbol has been \
|
---|
| 210 | redeclared\n", myname, lineno, input_file_name);
|
---|
| 211 | }
|
---|
| 212 |
|
---|
| 213 |
|
---|
| 214 | no_grammar()
|
---|
| 215 | {
|
---|
| 216 | fprintf(stderr, "%s: e - line %d of \"%s\", no grammar has been \
|
---|
| 217 | specified\n", myname, lineno, input_file_name);
|
---|
| 218 | done(1);
|
---|
| 219 | }
|
---|
| 220 |
|
---|
| 221 |
|
---|
| 222 | terminal_lhs(s_lineno)
|
---|
| 223 | int s_lineno;
|
---|
| 224 | {
|
---|
| 225 | fprintf(stderr, "%s: e - line %d of \"%s\", a token appears on the lhs \
|
---|
| 226 | of a production\n", myname, s_lineno, input_file_name);
|
---|
| 227 | done(1);
|
---|
| 228 | }
|
---|
| 229 |
|
---|
| 230 |
|
---|
| 231 | prec_redeclared()
|
---|
| 232 | {
|
---|
| 233 | fprintf(stderr, "%s: w - line %d of \"%s\", conflicting %%prec \
|
---|
| 234 | specifiers\n", myname, lineno, input_file_name);
|
---|
| 235 | }
|
---|
| 236 |
|
---|
| 237 |
|
---|
| 238 | unterminated_action(a_lineno, a_line, a_cptr)
|
---|
| 239 | int a_lineno;
|
---|
| 240 | char *a_line;
|
---|
| 241 | char *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 |
|
---|
| 250 | dollar_warning(a_lineno, i)
|
---|
| 251 | int a_lineno;
|
---|
| 252 | int i;
|
---|
| 253 | {
|
---|
| 254 | fprintf(stderr, "%s: w - line %d of \"%s\", $%d references beyond the \
|
---|
| 255 | end of the current rule\n", myname, a_lineno, input_file_name, i);
|
---|
| 256 | }
|
---|
| 257 |
|
---|
| 258 |
|
---|
| 259 | dollar_error(a_lineno, a_line, a_cptr)
|
---|
| 260 | int a_lineno;
|
---|
| 261 | char *a_line;
|
---|
| 262 | char *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 |
|
---|
| 271 | untyped_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 |
|
---|
| 279 | untyped_rhs(i, s)
|
---|
| 280 | int i;
|
---|
| 281 | char *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 |
|
---|
| 289 | unknown_rhs(i)
|
---|
| 290 | int 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 |
|
---|
| 298 | default_action_warning()
|
---|
| 299 | {
|
---|
| 300 | fprintf(stderr, "%s: w - line %d of \"%s\", the default action assigns an \
|
---|
| 301 | undefined value to $$\n", myname, lineno, input_file_name);
|
---|
| 302 | }
|
---|
| 303 |
|
---|
| 304 |
|
---|
| 305 | undefined_goal(s)
|
---|
| 306 | char *s;
|
---|
| 307 | {
|
---|
| 308 | fprintf(stderr, "%s: e - the start symbol %s is undefined\n", myname, s);
|
---|
| 309 | done(1);
|
---|
| 310 | }
|
---|
| 311 |
|
---|
| 312 |
|
---|
| 313 | undefined_symbol_warning(s)
|
---|
| 314 | char *s;
|
---|
| 315 | {
|
---|
| 316 | fprintf(stderr, "%s: w - the symbol %s is undefined\n", myname, s);
|
---|
| 317 | }
|
---|