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