1 static char *sccsid = "@(#)error.c 1.3 (Berkeley) 03/07/81"; 2 /* Copyright (c) 1979 Regents of the University of California */ 3 /* 4 * pi - Pascal interpreter code translator 5 * 6 * Charles Haley, Bill Joy UCB 7 * Version 1.2 January 1979 8 * 9 * 10 * pxp - Pascal execution profiler 11 * 12 * Bill Joy UCB 13 * Version 1.2 January 1979 14 */ 15 16 #include "0.h" 17 #include "yy.h" 18 19 #ifdef PXP 20 extern int yyline; 21 extern char errout; 22 #endif 23 24 char errpfx = 'E'; 25 extern int yyline; 26 /* 27 * Panic is called when impossible 28 * (supposedly, anyways) situations 29 * are encountered. 30 #ifdef PI 31 * Panic messages should be short 32 * as they do not go to the message 33 * file. 34 #endif 35 */ 36 panic(s) 37 char *s; 38 { 39 40 #ifdef DEBUG 41 fprintf(stderr, "Snark (%s) line=%d yyline=%d\n", s, line, yyline); 42 #endif 43 #ifdef PXP 44 Perror( "Snark in pxp", s); 45 #endif 46 #ifdef PI 47 Perror( "Snark in pi", s); 48 #endif 49 pexit(DIED); 50 } 51 52 extern char *errfile; 53 /* 54 * Error is called for 55 * semantic errors and 56 * prints the error and 57 * a line number. 58 */ 59 error(a1, a2, a3, a4) 60 { 61 #ifdef PI 62 char buf[256]; 63 register int i; 64 #endif 65 #ifdef PXP 66 /* 67 int ofout; 68 */ 69 #endif 70 71 if (errpfx == 'w' && opt('w') != 0) { 72 errpfx == 'E'; 73 return; 74 } 75 #ifdef PXP 76 /* 77 flush(); 78 ofout = fout[0]; 79 fout[0] = errout; 80 */ 81 #endif 82 #ifdef PI 83 Enocascade = 0; 84 geterr(a1, buf); 85 a1 = buf; 86 #endif 87 if (line < 0) 88 line = -line; 89 yySsync(); 90 yysetfile(filename); 91 #ifdef PI 92 if (errpfx == ' ') { 93 printf(" "); 94 for (i = line; i >= 10; i =/ 10) 95 putchar(' '); 96 printf("... "); 97 } else if (Enoline) 98 printf(" %c - ", errpfx); 99 else 100 #endif 101 fprintf(stderr, "%c %d - ", errpfx, line); 102 fprintf(stderr, a1, a2, a3, a4); 103 if (errpfx == 'E') 104 #ifdef PI 105 eflg++, cgenflg++; 106 #endif 107 #ifdef PXP 108 eflg++; 109 #endif 110 errpfx = 'E'; 111 #ifdef PI 112 if (Eholdnl) 113 Eholdnl = 0; 114 else 115 #endif 116 putc('\n', stderr); 117 #ifdef PXP 118 /* 119 flush(); 120 fout[0] = ofout; 121 */ 122 #endif 123 } 124 125 #ifdef PI 126 cerror(a1, a2, a3, a4) 127 { 128 129 if (Enocascade) 130 return; 131 setpfx(' '); 132 error(a1, a2, a3, a4); 133 } 134 #endif 135