1: /* 2: * Copyright (c) 1980 Regents of the University of California. 3: * All rights reserved. The Berkeley software License Agreement 4: * specifies the terms and conditions for redistribution. 5: */ 6: 7: #ifndef lint 8: static char sccsid[] = "@(#)error.c 5.1 (Berkeley) 6/5/85"; 9: #endif not lint 10: 11: #include "whoami.h" 12: #include "0.h" 13: #ifndef PI1 14: #include "tree_ty.h" /* must be included for yy.h */ 15: #include "yy.h" 16: #endif 17: 18: char errpfx = 'E'; 19: extern int yyline; 20: /* 21: * Panic is called when impossible 22: * (supposedly, anyways) situations 23: * are encountered. 24: * Panic messages should be short 25: * as they do not go to the message 26: * file. 27: */ 28: panic(s) 29: char *s; 30: { 31: 32: #ifdef DEBUG 33: #ifdef PI1 34: printf("Snark (%s) line=%d\n", s, line); 35: abort(); 36: #else 37: printf("Snark (%s) line=%d, yyline=%d\n", s, line, yyline); 38: abort () ; /* die horribly */ 39: #endif 40: #endif 41: #ifdef PI1 42: Perror( "Snark in pi1", s); 43: #else 44: Perror( "Snark in pi", s); 45: #endif 46: pexit(DIED); 47: } 48: 49: /* 50: * Error is called for 51: * semantic errors and 52: * prints the error and 53: * a line number. 54: */ 55: 56: /*VARARGS1*/ 57: 58: error(a1, a2, a3, a4, a5) 59: register char *a1; 60: { 61: char errbuf[256]; /* was extern. why? ...pbk */ 62: register int i; 63: 64: if (errpfx == 'w' && opt('w') != 0) { 65: errpfx = 'E'; 66: return; 67: } 68: Enocascade = FALSE; 69: geterr((int) a1, errbuf); 70: a1 = errbuf; 71: if (line < 0) 72: line = -line; 73: #ifndef PI1 74: if (opt('l')) 75: yyoutline(); 76: #endif 77: yysetfile(filename); 78: if (errpfx == ' ') { 79: printf(" "); 80: for (i = line; i >= 10; i /= 10) 81: pchr( ' ' ); 82: printf("... "); 83: } else if (Enoline) 84: printf(" %c - ", errpfx); 85: else 86: printf("%c %d - ", errpfx, line); 87: printf(a1, a2, a3, a4, a5); 88: if (errpfx == 'E') 89: #ifndef PI0 90: eflg = TRUE, codeoff(); 91: #else 92: eflg = TRUE; 93: #endif 94: errpfx = 'E'; 95: if (Eholdnl) 96: Eholdnl = FALSE; 97: else 98: pchr( '\n' ); 99: } 100: 101: /*VARARGS1*/ 102: 103: cerror(a1, a2, a3, a4, a5) 104: char *a1; 105: { 106: 107: if (Enocascade) 108: return; 109: setpfx(' '); 110: error(a1, a2, a3, a4, a5); 111: } 112: 113: #ifdef PI1 114: 115: /*VARARGS*/ 116: 117: derror(a1, a2, a3, a4, a5) 118: char *a1, *a2, *a3, *a4, *a5; 119: { 120: 121: if (!holdderr) 122: error(a1, a2, a3, a4, a5); 123: errpfx = 'E'; 124: } 125: 126: char *lastname, printed, hadsome; 127: 128: /* 129: * this yysetfile for PI1 only. 130: * the real yysetfile is in yyput.c 131: */ 132: yysetfile(name) 133: char *name; 134: { 135: 136: if (lastname == name) 137: return; 138: printed =| 1; 139: gettime( name ); 140: printf("%s %s:\n" , myctime( &tvec ) , name ); 141: lastname = name; 142: } 143: #endif