Commit | Line | Data |
---|---|---|
0da4719d PK |
1 | static char *sccsid = "@(#)yyerror.c 1.1 (Berkeley) %G%"; |
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 | /* | |
20 | * Yerror prints an error | |
21 | * message and then returns | |
22 | * NIL for the tree if needed. | |
23 | * The error is flagged on the | |
24 | * current line which is printed | |
25 | * if the listing is turned off. | |
26 | #ifdef PXP | |
27 | * | |
28 | * As is obvious from the fooling around | |
29 | * with fout below, the Pascal system should | |
30 | * be changed to use the new library "lS". | |
31 | #endif | |
32 | */ | |
33 | yerror(s, a1, a2, a3, a4, a5) | |
34 | char *s; | |
35 | { | |
36 | #ifdef PI | |
37 | char buf[256]; | |
38 | #endif | |
39 | register int i, j; | |
40 | static yySerrs; | |
41 | #ifdef PXP | |
42 | /* | |
43 | int ofout; | |
44 | */ | |
45 | #endif | |
46 | ||
47 | if (errpfx == 'w' && opt('w') != 0) | |
48 | return; | |
49 | #ifdef PXP | |
50 | /* | |
51 | flush(); | |
52 | ofout = fout[0]; | |
53 | fout[0] = errout; | |
54 | */ | |
55 | #endif | |
56 | yyResume = 0; | |
57 | #ifdef PI | |
58 | geterr(s, buf); | |
59 | s = buf; | |
60 | #endif | |
61 | yysync(); | |
62 | putc(errpfx, stderr); | |
63 | putc(' ', stderr); | |
64 | for (i = 3; i < yyecol; i++) | |
65 | putc('-', stderr); | |
66 | fprintf(stderr, "^--- "); | |
67 | /* | |
68 | if (yyecol > 60) | |
69 | printf("\n\t"); | |
70 | */ | |
71 | fprintf(stderr, s, a1, a2, a3, a4, a5); | |
72 | putc('\n', stderr); | |
73 | if (errpfx == 'E') | |
74 | #ifdef PI | |
75 | eflg++, cgenflg++; | |
76 | #endif | |
77 | #ifdef PXP | |
78 | eflg++; | |
79 | #endif | |
80 | errpfx = 'E'; | |
81 | yySerrs++; | |
82 | if (yySerrs >= MAXSYNERR) { | |
83 | yySerrs = 0; | |
84 | yerror("Too many syntax errors - QUIT"); | |
85 | pexit(ERRS); | |
86 | } | |
87 | #ifdef PXP | |
88 | /* | |
89 | flush(); | |
90 | fout[0] = ofout; | |
91 | */ | |
92 | return (0); | |
93 | #endif | |
94 | } | |
95 | ||
96 | /* | |
97 | * A bracketing error message | |
98 | */ | |
99 | brerror(where, what) | |
100 | int where; | |
101 | char *what; | |
102 | { | |
103 | ||
104 | if (where == 0) { | |
105 | line = yyeline; | |
106 | setpfx(' '); | |
107 | error("End matched %s on line %d", what, where); | |
108 | return; | |
109 | } | |
110 | if (where < 0) | |
111 | where = -where; | |
112 | yerror("Inserted keyword end matching %s on line %d", what, where); | |
113 | } |