|
|
1.1 root 1: # include <errors.h>
2: /*
3: ** YYERROR -- the routine which error routine yacc calls
4: **
5: ** Version:
6: ** @(#)yyerror.y 8.2 2/6/85
7: */
8:
9: yyerror(errmessage)
10: char *errmessage;
11: {
12: # ifdef xPTR1
13: tTfp(60, 6, "yyerror: an error from yacc itself\n");
14: # endif
15:
16: if (sequal(errmessage, "syntax error"))
17: par_error(SYMERR, WARN, 0);
18: else
19: par_error(YOVRFLOW, WARN, 0);
20: }
21:
22: /*
23: ** PAR_ERROR -- the error routine for the parser
24: **
25: ** Par_error sends its arguments to print_error(), the front-end
26: ** error processor. If result = FATAL then reset() is called,
27: ** otherwise, the error is assumed to be recoverable, and parsing
28: ** continues.
29: **
30: ** Parameters:
31: ** num -- the number of the error (2000 - 2999).
32: ** result -- if = FATAL then reset, otherwise return.
33: ** a, b, c -- arbitrary arguments to the error routine.
34: **
35: ** Returns:
36: ** if result is not FATAL
37: **
38: ** Requires:
39: ** print_error() -- of the monitor
40: **
41: ** Called By:
42: ** parser routines
43: ** scanner routines
44: **
45: ** Written:
46: ** 1979 (jiw)
47: ** 13 feb 1980 modified for monpar (jiw)
48: */
49:
50: par_error(num, result, a, b, c)
51: int num;
52: int result;
53: char *a, *b, *c;
54: {
55: char buff[30];
56: register char *buf;
57:
58: extern short yyerrflag;
59: extern int Err_current;
60: extern int Err_fnd;
61: extern int Opflag;
62: extern int yyline;
63:
64: resetp();
65:
66: buf = buff;
67:
68: # ifdef xPTR1
69: tTfp(60, 7, "par_error: %d, (fatal = %d), a, b, c.\n", num, result, a, b, c);
70: # endif
71:
72: yyerrflag = 3; /* tell yyparse that an error has been found */
73:
74: /*
75: ** if Err_current is true at this point,
76: ** it is the second error found in the statement.
77: ** Thus for the simple error recovery currently
78: ** used no other message should be printed.
79: */
80:
81: if (Err_current)
82: {
83: if (result != FATAL)
84: return;
85: else
86: {
87: # ifdef xPTR1
88: tTfp(60, 9, "par_error: a non recoverable error\n");
89: # endif
90:
91: endgo();
92:
93: error(0);
94: }
95: }
96:
97: # ifdef xPTR1
98: tTfp(60, 8, "par_error: first error.\n");
99: # endif
100:
101: Err_fnd += 1; /* check syntax of remainder */
102: Err_current = 1; /* error was found in this statement */
103:
104: if (num == SYMERR || num == NXTCMDERR)
105: {
106: /* syntax error */
107: a = buf;
108: b = 0;
109: switch (Lastok.toktyp)
110: {
111: case I2CONST:
112: itoa(*(short *)Lastok.tok, buf);
113: break;
114:
115: case I4CONST:
116: smove(locv(*(long *)Lastok.tok), buf);
117: break;
118:
119: case F4CONST:
120: ftoa(*(float *)Lastok.tok, buf, 10, 3, 'n');
121: break;
122:
123: case F8CONST:
124: ftoa(*(double *)Lastok.tok, buf, 10, 3, 'n');
125: break;
126:
127: case SCONST:
128: smove(Lastok.tok, buf);
129: break;
130:
131: case 0:
132: a = "EOF";
133: break;
134:
135: default:
136: syserr("bad Lastok format");
137: }
138: num += Opflag; /* choosing correct error */
139: }
140:
141: if (result != FATAL)
142: error(num, iocv(yyline), a, b, c, 0);
143: else
144: {
145: # ifdef xPTR1
146: tTfp(60, 9, "par_error: a non recoverable error\n");
147: # endif
148:
149: error(num, iocv(yyline), a, b, c, 0);
150: }
151: }
152: neederr(errnum)
153: int errnum;
154: {
155: par_error(errnum, WARN, 0);
156: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.