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