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