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