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