3 yyrcsid
[] = "$FreeBSD: src/usr.bin/yacc/skeleton.c,v 1.28 2000/01/17 02:04:06 bde Exp $";
11 #define yyclearin (yychar=(YYEMPTY))
12 #define yyerrok (yyerrflag=0)
13 #define YYRECOVERING() (yyerrflag!=0)
14 static int yygrowstack();
18 #include "../config.h"
25 #include "interpret.h"
30 #include <X11/Intrinsic.h>
33 #include "../util/VMSparam.h"
36 #include <sys/param.h>
44 /* Macros to add error processing to AddOp and AddSym calls */
45 #define ADD_OP(op) if (!AddOp(op, &ErrMsg)) return 1
46 #define ADD_SYM(sym) if (!AddSym(sym, &ErrMsg)) return 1
47 #define ADD_IMMED(val) if (!AddImmediate(val, &ErrMsg)) return 1
48 #define ADD_BR_OFF(to) if (!AddBranchOffset(to, &ErrMsg)) return 1
49 #define SET_BR_OFF(from, to) *((int *)(from)) = ((Inst *)(to)) - ((Inst *)(from))
51 /* Max. length for a string constant (... there shouldn't be a maximum) */
52 #define MAX_STRING_CONST_LEN 5000
54 static const char CVSID
[] = "$Id: parse_noyacc.c,v 1.7 2003/05/15 07:33:00 edg Exp $";
55 static int yyerror(char *s
);
56 static int yylex(void);
58 static int follow(char expect
, int yes
, int no
);
59 static int follow2(char expect1
, int yes1
, char expect2
, int yes2
, int no
);
60 static int follow_non_whitespace(char expect
, int yes
, int no
);
61 static Symbol
*matchesActionRoutine(char **inPtr
);
65 extern Inst
*LoopStack
[]; /* addresses of break, cont stmts */
66 extern Inst
**LoopStackPtr
; /* to fill at the end of a loop */
86 #define IF_NO_ELSE 267
104 #define UNARY_MINUS 285
110 const short yylhs
[] = { -1,
111 0, 0, 0, 0, 13, 13, 13, 12, 12, 14,
112 14, 14, 14, 14, 16, 14, 14, 14, 14, 14,
113 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
114 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
115 15, 15, 15, 15, 15, 15, 10, 3, 3, 3,
116 1, 1, 1, 17, 17, 19, 19, 18, 18, 9,
117 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
118 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
119 20, 20, 20, 20, 20, 20, 20, 20, 20, 5,
120 4, 6, 2, 2, 7, 8, 11, 11,
122 const short yylen
[] = { 2,
123 2, 5, 4, 1, 5, 4, 1, 1, 2, 3,
124 6, 9, 6, 10, 0, 9, 3, 3, 4, 3,
125 3, 3, 3, 3, 3, 3, 3, 3, 5, 6,
126 6, 6, 6, 6, 6, 6, 6, 5, 5, 5,
127 5, 4, 2, 2, 2, 2, 1, 0, 1, 3,
128 0, 1, 3, 1, 2, 1, 4, 1, 4, 1,
129 1, 1, 1, 4, 3, 4, 3, 3, 3, 3,
130 3, 3, 2, 3, 3, 3, 3, 3, 3, 3,
131 3, 3, 3, 2, 2, 2, 2, 2, 3, 1,
132 1, 1, 0, 1, 1, 1, 0, 2,
134 const short yydefred
[] = { 0,
135 4, 0, 0, 0, 0, 90, 91, 0, 0, 0,
136 0, 0, 0, 97, 98, 0, 0, 0, 0, 8,
137 0, 0, 0, 44, 46, 0, 0, 97, 97, 61,
138 62, 0, 0, 0, 0, 0, 0, 97, 0, 0,
139 58, 0, 0, 0, 0, 0, 0, 0, 0, 0,
140 0, 0, 0, 0, 0, 0, 9, 97, 0, 0,
141 0, 0, 0, 0, 0, 0, 86, 88, 0, 0,
142 0, 85, 87, 0, 0, 97, 0, 96, 95, 0,
143 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
144 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
145 3, 0, 0, 0, 49, 0, 0, 0, 0, 0,
146 0, 0, 0, 0, 0, 42, 0, 97, 0, 65,
147 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
148 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
149 0, 0, 2, 0, 0, 0, 97, 0, 0, 0,
150 64, 66, 0, 0, 0, 0, 0, 0, 50, 0,
151 0, 0, 0, 0, 0, 0, 0, 0, 38, 39,
152 97, 0, 7, 15, 0, 13, 0, 0, 0, 0,
153 0, 0, 0, 0, 0, 92, 97, 97, 0, 97,
154 0, 0, 0, 97, 0, 97, 12, 16, 0, 0,
157 const short yydgoto
[] = { 2,
158 61, 63, 104, 16, 17, 187, 96, 97, 156, 18,
159 3, 19, 172, 173, 21, 188, 62, 42, 22, 40,
161 const short yysindex
[] = { -215,
162 0, 0, 718, -33, 21, 0, 0, 35, 44, 176,
163 -191, -182, -178, 0, 0, 62, 68, 412, 1139, 0,
164 80, 13, 380, 0, 0, 380, 380, 0, 0, 0,
165 0, 3, 380, 380, -146, -144, 380, 0, 504, -32,
166 0, 28, 0, 33, 0, 38, 222, -122, 380, 380,
167 380, 380, 380, 380, 380, 380, 0, 0, 380, 380,
168 14, 380, 92, -32, 137, 137, 0, 0, 380, -91,
169 -91, 0, 0, 301, 137, 0, -32, 0, 0, 380,
170 380, 380, 380, 380, 380, 380, 380, 380, 380, 380,
171 380, 380, 380, 380, 380, 380, 380, 380, 380, 380,
172 0, 1121, 11, -26, 0, 110, 380, 380, 380, 380,
173 380, 380, 380, 137, -40, 0, 380, 0, 84, 0,
174 137, 1271, 1285, -5, -5, -5, -5, -5, -5, -5,
175 -3, -3, -91, -91, -91, -91, -30, 1253, 1216, -19,
176 -17, -15, 0, 380, 380, -65, 0, 698, 380, 879,
177 0, 0, 0, 0, 0, 111, -32, 109, 0, 879,
178 380, 380, 380, 380, 380, 380, 380, 380, 0, 0,
179 0, -79, 0, 0, -65, 0, 380, 380, 380, 380,
180 380, 380, 380, 380, 923, 0, 0, 0, 105, 0,
181 1131, 879, 879, 0, 137, 0, 0, 0, 879, 137,
184 const short yyrindex
[] = { 954,
185 0, 0, 0, -34, 0, 0, 0, 0, 0, 0,
186 0, 0, 0, 0, 0, 0, 0, 0, 185, 0,
187 0, 0, 0, 0, 0, 128, 146, 0, 0, 0,
188 0, 117, 0, 0, 0, 0, 0, 0, 0, 91,
189 0, 0, 6, 0, 25, 0, 0, -13, 146, 0,
190 0, 0, 0, 0, 0, 0, 0, 0, -14, 52,
191 0, -22, 0, 41, 1, 9, 0, 0, 128, 160,
192 368, 0, 0, 0, 17, 0, 1181, 0, 0, 0,
193 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
194 0, 0, 0, 0, -14, 0, 0, -14, -14, -14,
195 0, 0, -34, 0, 0, 0, 77, 79, 104, 112,
196 133, 134, 147, 48, 0, 0, 0, 0, 0, 0,
197 56, 1035, 993, 665, 741, 781, 826, 872, 917, 950,
198 574, 620, 413, 453, 489, 529, 0, 1078, 464, 0,
199 0, 0, 0, 0, 136, 0, 0, 118, -18, 0,
200 0, 0, 26, 39, 50, 0, 171, 0, 0, 0,
201 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
202 0, 103, 0, 0, 138, 0, 170, 329, 497, 506,
203 542, 551, 552, 565, 0, 0, 0, 0, 0, 0,
204 0, 0, 0, 0, 64, 0, 0, 0, 0, 95,
207 const short yygindex
[] = { 0,
208 420, -46, 40, 0, 0, 0, 0, 0, 0, 0,
209 1331, -45, -87, 5, -36, 0, 1296, 0, 8, 1543,
211 #define YYTABLESIZE 1727
212 const short yytable
[] = { 95,
213 17, 102, 106, 117, 93, 81, 26, 20, 18, 91,
214 89, 105, 90, 117, 92, 43, 20, 146, 52, 44,
215 46, 52, 53, 57, 117, 53, 117, 23, 117, 51,
216 48, 93, 145, 93, 45, 29, 91, 89, 91, 90,
217 1, 92, 69, 92, 28, 48, 43, 10, 40, 43,
218 26, 20, 148, 29, 116, 19, 56, 117, 95, 41,
219 27, 21, 152, 6, 43, 45, 29, 41, 45, 29,
220 52, 23, 176, 153, 53, 154, 43, 155, 51, 40,
221 45, 94, 40, 45, 29, 95, 22, 95, 23, 58,
222 41, 80, 21, 41, 5, 21, 56, 40, 158, 94,
223 54, 48, 11, 59, 197, 198, 57, 49, 41, 159,
224 21, 201, 72, 24, 73, 56, 59, 22, 98, 23,
225 22, 25, 23, 99, 151, 17, 63, 117, 100, 57,
226 54, 54, 118, 18, 54, 22, 103, 23, 105, 191,
227 57, 20, 26, 27, 24, 194, 15, 24, 146, 54,
228 147, 174, 25, 63, 63, 25, 28, 63, 63, 63,
229 63, 63, 24, 63, 11, 12, 13, 175, 51, 73,
230 25, 51, 10, 26, 27, 63, 26, 27, 48, 30,
231 19, 48, 186, 54, 1, 38, 93, 28, 6, 20,
232 28, 26, 27, 4, 93, 57, 73, 73, 94, 73,
233 73, 73, 73, 73, 73, 28, 73, 63, 57, 63,
234 30, 60, 0, 30, 189, 37, 0, 0, 73, 5,
235 33, 11, 12, 13, 0, 0, 0, 11, 30, 0,
236 0, 15, 0, 47, 47, 47, 47, 47, 47, 47,
237 63, 0, 0, 78, 79, 82, 83, 84, 85, 86,
238 87, 88, 73, 0, 24, 25, 0, 94, 0, 17,
239 17, 17, 17, 17, 17, 17, 17, 18, 18, 18,
240 18, 18, 18, 18, 18, 20, 20, 20, 20, 20,
241 20, 20, 20, 73, 94, 0, 94, 17, 17, 17,
242 67, 68, 0, 0, 144, 18, 18, 18, 24, 25,
243 0, 0, 0, 20, 20, 20, 10, 10, 10, 10,
244 10, 10, 10, 10, 19, 19, 19, 19, 19, 19,
245 19, 19, 6, 6, 6, 6, 6, 6, 6, 6,
246 0, 0, 0, 0, 10, 10, 10, 0, 31, 0,
247 37, 120, 19, 19, 19, 33, 101, 54, 54, 54,
248 6, 6, 6, 5, 5, 5, 5, 5, 5, 5,
249 5, 11, 11, 11, 0, 11, 11, 11, 11, 31,
250 0, 0, 31, 63, 63, 63, 54, 84, 54, 54,
251 0, 5, 5, 5, 0, 0, 0, 31, 0, 11,
252 11, 11, 63, 63, 63, 63, 63, 63, 63, 63,
253 63, 0, 63, 0, 84, 84, 63, 84, 84, 84,
254 84, 84, 84, 0, 84, 0, 73, 73, 73, 37,
255 0, 0, 69, 0, 33, 0, 84, 0, 0, 0,
256 0, 0, 30, 31, 32, 73, 73, 73, 73, 73,
257 73, 73, 73, 73, 0, 73, 0, 73, 73, 69,
258 69, 0, 69, 69, 69, 69, 69, 69, 0, 69,
259 84, 34, 70, 35, 36, 0, 0, 0, 0, 0,
260 0, 69, 0, 83, 0, 0, 0, 0, 115, 0,
261 4, 5, 6, 0, 7, 8, 9, 10, 119, 70,
262 70, 84, 70, 70, 70, 70, 70, 70, 71, 70,
263 0, 0, 0, 83, 83, 69, 32, 83, 11, 12,
264 13, 70, 0, 76, 137, 33, 0, 140, 141, 142,
265 0, 0, 83, 0, 0, 71, 71, 0, 71, 71,
266 71, 71, 71, 71, 0, 71, 69, 32, 72, 0,
267 32, 0, 0, 37, 0, 70, 33, 71, 33, 33,
268 0, 34, 0, 0, 0, 32, 83, 30, 31, 32,
269 35, 36, 0, 0, 33, 72, 72, 0, 72, 72,
270 72, 72, 72, 72, 37, 72, 70, 0, 0, 0,
271 0, 71, 34, 67, 0, 34, 34, 72, 35, 36,
272 0, 35, 36, 0, 35, 36, 0, 0, 0, 0,
273 34, 0, 0, 0, 0, 37, 0, 0, 37, 35,
274 36, 67, 71, 67, 67, 0, 67, 67, 67, 0,
275 0, 72, 0, 37, 84, 84, 84, 0, 0, 68,
276 0, 0, 67, 0, 0, 0, 30, 31, 32, 0,
277 0, 0, 0, 84, 84, 84, 84, 84, 84, 84,
278 84, 84, 72, 84, 0, 84, 84, 68, 0, 68,
279 68, 0, 68, 68, 68, 34, 67, 35, 36, 69,
280 69, 69, 0, 0, 74, 0, 0, 0, 68, 50,
281 51, 52, 53, 54, 55, 56, 0, 0, 69, 69,
282 69, 69, 69, 69, 69, 69, 69, 67, 69, 0,
283 69, 69, 74, 0, 74, 74, 0, 0, 74, 70,
284 70, 70, 68, 0, 0, 0, 0, 0, 0, 0,
285 83, 83, 83, 74, 0, 0, 0, 15, 70, 70,
286 70, 70, 70, 70, 70, 70, 70, 0, 70, 83,
287 70, 70, 0, 68, 0, 71, 71, 71, 0, 83,
288 75, 83, 83, 0, 0, 0, 0, 74, 161, 0,
289 30, 31, 32, 0, 71, 71, 71, 71, 71, 71,
290 71, 71, 71, 0, 71, 0, 71, 71, 75, 0,
291 75, 75, 0, 0, 75, 72, 72, 72, 74, 34,
292 76, 35, 36, 0, 0, 0, 0, 0, 0, 75,
293 0, 0, 0, 0, 72, 72, 72, 72, 72, 72,
294 72, 72, 72, 0, 72, 0, 72, 72, 76, 0,
295 76, 76, 0, 0, 76, 0, 0, 0, 0, 0,
296 67, 67, 67, 75, 0, 77, 0, 0, 0, 76,
297 14, 0, 0, 0, 0, 0, 0, 0, 0, 67,
298 67, 67, 67, 67, 67, 67, 67, 67, 0, 67,
299 0, 67, 67, 77, 75, 77, 77, 0, 0, 77,
300 0, 0, 0, 76, 0, 0, 68, 68, 68, 0,
301 0, 78, 0, 0, 77, 0, 0, 0, 15, 0,
302 0, 0, 0, 0, 0, 68, 68, 68, 68, 68,
303 68, 68, 68, 68, 76, 68, 0, 68, 68, 78,
304 0, 78, 78, 0, 0, 78, 0, 0, 77, 0,
305 0, 74, 74, 74, 0, 0, 79, 0, 0, 0,
306 78, 0, 15, 0, 0, 0, 0, 0, 0, 0,
307 74, 74, 74, 74, 74, 74, 74, 74, 74, 77,
308 74, 0, 74, 74, 79, 0, 79, 79, 0, 89,
309 79, 0, 0, 97, 78, 162, 163, 164, 165, 166,
310 167, 168, 0, 0, 0, 79, 4, 5, 6, 0,
311 7, 8, 9, 10, 0, 169, 170, 89, 0, 89,
312 89, 0, 0, 89, 0, 78, 0, 75, 75, 75,
313 0, 171, 80, 0, 11, 12, 13, 0, 89, 79,
314 0, 0, 0, 0, 0, 0, 75, 75, 75, 75,
315 75, 75, 75, 75, 75, 0, 75, 0, 75, 75,
316 80, 0, 80, 80, 0, 0, 80, 76, 76, 76,
317 79, 0, 89, 0, 81, 0, 0, 190, 0, 0,
318 0, 80, 0, 0, 0, 0, 76, 76, 76, 76,
319 76, 76, 76, 76, 76, 0, 76, 0, 76, 76,
320 0, 0, 0, 89, 81, 81, 97, 0, 81, 0,
321 0, 0, 77, 77, 77, 80, 0, 82, 0, 0,
322 0, 0, 0, 81, 0, 0, 0, 0, 0, 0,
323 0, 77, 77, 77, 77, 77, 77, 77, 77, 77,
324 0, 77, 0, 77, 77, 0, 80, 82, 82, 0,
325 0, 82, 0, 0, 0, 0, 0, 81, 78, 78,
326 78, 0, 0, 0, 0, 0, 82, 4, 5, 6,
327 0, 7, 8, 9, 10, 0, 0, 78, 78, 78,
328 78, 78, 78, 78, 78, 78, 0, 78, 81, 78,
329 78, 0, 0, 0, 0, 11, 12, 13, 0, 0,
330 82, 0, 0, 79, 79, 79, 0, 0, 0, 0,
331 0, 4, 5, 6, 0, 7, 8, 9, 10, 0,
332 55, 0, 79, 79, 79, 79, 79, 79, 79, 79,
333 79, 0, 79, 0, 79, 79, 89, 89, 89, 11,
334 12, 13, 97, 97, 97, 0, 97, 97, 97, 97,
335 55, 55, 0, 0, 55, 89, 89, 89, 89, 89,
336 89, 89, 89, 89, 0, 89, 0, 89, 89, 55,
337 97, 97, 97, 0, 0, 143, 0, 0, 0, 80,
338 80, 80, 93, 81, 0, 196, 0, 91, 89, 0,
339 90, 0, 92, 0, 0, 0, 0, 0, 80, 80,
340 0, 0, 0, 55, 0, 0, 0, 0, 80, 0,
341 80, 80, 0, 0, 0, 0, 0, 0, 0, 93,
342 81, 81, 81, 81, 91, 89, 0, 90, 0, 92,
343 0, 0, 0, 0, 0, 39, 95, 93, 81, 0,
344 81, 81, 91, 89, 0, 90, 0, 92, 60, 0,
345 81, 93, 81, 81, 0, 0, 91, 89, 0, 90,
346 0, 92, 74, 0, 82, 82, 82, 0, 0, 80,
347 0, 0, 0, 95, 47, 107, 108, 109, 110, 111,
348 112, 113, 0, 82, 82, 0, 0, 0, 65, 66,
349 0, 95, 0, 82, 0, 82, 82, 0, 75, 0,
350 0, 0, 0, 0, 0, 95, 80, 0, 0, 4,
351 5, 6, 0, 7, 8, 9, 10, 0, 114, 4,
352 5, 6, 0, 7, 8, 9, 10, 4, 5, 6,
353 0, 7, 8, 9, 10, 0, 121, 11, 12, 13,
354 0, 0, 149, 0, 0, 0, 0, 11, 12, 13,
355 0, 0, 0, 0, 0, 11, 12, 13, 0, 0,
356 0, 0, 0, 0, 0, 0, 0, 55, 55, 55,
357 0, 0, 0, 0, 0, 0, 0, 0, 150, 0,
358 0, 0, 0, 0, 0, 0, 177, 178, 179, 180,
359 181, 182, 183, 184, 0, 0, 55, 0, 55, 55,
360 0, 0, 0, 0, 0, 0, 0, 160, 0, 0,
361 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
362 0, 0, 79, 82, 83, 84, 85, 86, 87, 88,
363 0, 185, 0, 0, 0, 94, 0, 0, 0, 0,
364 0, 0, 0, 0, 0, 0, 0, 192, 193, 0,
365 195, 0, 0, 0, 199, 0, 200, 0, 0, 0,
366 82, 83, 84, 85, 86, 87, 88, 0, 0, 0,
367 0, 0, 94, 0, 0, 0, 0, 0, 82, 83,
368 84, 85, 86, 87, 88, 0, 0, 0, 0, 0,
369 94, 0, 82, 83, 84, 85, 86, 87, 88, 64,
370 0, 0, 0, 0, 94, 70, 71, 0, 0, 0,
371 0, 77, 0, 0, 0, 0, 0, 0, 0, 0,
372 0, 64, 0, 0, 0, 0, 0, 0, 0, 0,
373 0, 0, 77, 0, 77, 0, 0, 0, 0, 0,
374 0, 0, 0, 0, 0, 0, 77, 0, 0, 0,
375 0, 0, 122, 123, 124, 125, 126, 127, 128, 129,
376 130, 131, 132, 133, 134, 135, 136, 0, 138, 139,
377 0, 0, 0, 0, 0, 0, 0, 0, 0, 77,
378 77, 77, 77, 77, 77, 77, 0, 0, 0, 0,
379 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
380 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
381 0, 0, 0, 0, 0, 0, 157, 64, 0, 0,
382 0, 77, 0, 0, 0, 0, 0, 0, 0, 0,
383 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
384 0, 0, 0, 0, 0, 0, 0, 0, 0, 77,
385 77, 77, 77, 77, 77, 77, 77,
387 const short yycheck
[] = { 91,
388 0, 47, 49, 44, 37, 38, 40, 3, 0, 42,
389 43, 48, 45, 44, 47, 10, 0, 44, 41, 12,
390 13, 44, 41, 19, 44, 44, 44, 61, 44, 44,
391 44, 37, 59, 37, 10, 10, 42, 43, 42, 45,
392 256, 47, 40, 47, 10, 59, 41, 0, 10, 44,
393 40, 47, 93, 10, 41, 0, 91, 44, 91, 10,
394 40, 10, 93, 0, 59, 41, 41, 259, 44, 44,
395 93, 61, 160, 93, 93, 93, 259, 93, 93, 41,
396 259, 41, 44, 59, 59, 91, 10, 91, 10, 10,
397 41, 124, 41, 44, 0, 44, 91, 59, 145, 59,
398 10, 40, 0, 91, 192, 193, 102, 40, 59, 146,
399 59, 199, 259, 10, 259, 91, 91, 41, 91, 41,
400 44, 10, 44, 91, 41, 125, 10, 44, 91, 91,
401 40, 41, 41, 125, 44, 59, 259, 59, 175, 185,
402 91, 125, 10, 10, 41, 41, 10, 44, 44, 59,
403 41, 41, 41, 37, 38, 44, 10, 41, 42, 43,
404 44, 45, 59, 47, 287, 288, 289, 59, 41, 10,
405 59, 44, 125, 41, 41, 59, 44, 44, 41, 10,
406 125, 44, 262, 93, 0, 10, 41, 41, 125, 185,
407 44, 59, 59, 259, 59, 191, 37, 38, 290, 40,
408 41, 42, 43, 44, 45, 59, 47, 91, 91, 93,
409 41, 41, -1, 44, 175, 40, -1, -1, 59, 125,
410 45, 287, 288, 289, -1, -1, -1, 125, 59, -1,
411 -1, 10, -1, 268, 269, 270, 271, 272, 273, 274,
412 124, -1, -1, 276, 277, 278, 279, 280, 281, 282,
413 283, 284, 93, -1, 288, 289, -1, 290, -1, 259,
414 260, 261, 262, 263, 264, 265, 266, 259, 260, 261,
415 262, 263, 264, 265, 266, 259, 260, 261, 262, 263,
416 264, 265, 266, 124, 290, -1, 290, 287, 288, 289,
417 288, 289, -1, -1, 284, 287, 288, 289, 288, 289,
418 -1, -1, -1, 287, 288, 289, 259, 260, 261, 262,
419 263, 264, 265, 266, 259, 260, 261, 262, 263, 264,
420 265, 266, 259, 260, 261, 262, 263, 264, 265, 266,
421 -1, -1, -1, -1, 287, 288, 289, -1, 10, -1,
422 40, 41, 287, 288, 289, 45, 125, 257, 258, 259,
423 287, 288, 289, 259, 260, 261, 262, 263, 264, 265,
424 266, 259, 260, 261, -1, 263, 264, 265, 266, 41,
425 -1, -1, 44, 257, 258, 259, 286, 10, 288, 289,
426 -1, 287, 288, 289, -1, -1, -1, 59, -1, 287,
427 288, 289, 276, 277, 278, 279, 280, 281, 282, 283,
428 284, -1, 286, -1, 37, 38, 290, 40, 41, 42,
429 43, 44, 45, -1, 47, -1, 257, 258, 259, 40,
430 -1, -1, 10, -1, 45, -1, 59, -1, -1, -1,
431 -1, -1, 257, 258, 259, 276, 277, 278, 279, 280,
432 281, 282, 283, 284, -1, 286, -1, 288, 289, 37,
433 38, -1, 40, 41, 42, 43, 44, 45, -1, 47,
434 93, 286, 10, 288, 289, -1, -1, -1, -1, -1,
435 -1, 59, -1, 10, -1, -1, -1, -1, 59, -1,
436 259, 260, 261, -1, 263, 264, 265, 266, 69, 37,
437 38, 124, 40, 41, 42, 43, 44, 45, 10, 47,
438 -1, -1, -1, 40, 41, 93, 10, 44, 287, 288,
439 289, 59, -1, 10, 95, 10, -1, 98, 99, 100,
440 -1, -1, 59, -1, -1, 37, 38, -1, 40, 41,
441 42, 43, 44, 45, -1, 47, 124, 41, 10, -1,
442 44, -1, -1, 40, -1, 93, 41, 59, 45, 44,
443 -1, 10, -1, -1, -1, 59, 93, 257, 258, 259,
444 10, 10, -1, -1, 59, 37, 38, -1, 40, 41,
445 42, 43, 44, 45, 10, 47, 124, -1, -1, -1,
446 -1, 93, 41, 10, -1, 44, 286, 59, 288, 289,
447 -1, 41, 41, -1, 44, 44, -1, -1, -1, -1,
448 59, -1, -1, -1, -1, 41, -1, -1, 44, 59,
449 59, 38, 124, 40, 41, -1, 43, 44, 45, -1,
450 -1, 93, -1, 59, 257, 258, 259, -1, -1, 10,
451 -1, -1, 59, -1, -1, -1, 257, 258, 259, -1,
452 -1, -1, -1, 276, 277, 278, 279, 280, 281, 282,
453 283, 284, 124, 286, -1, 288, 289, 38, -1, 40,
454 41, -1, 43, 44, 45, 286, 93, 288, 289, 257,
455 258, 259, -1, -1, 10, -1, -1, -1, 59, 268,
456 269, 270, 271, 272, 273, 274, -1, -1, 276, 277,
457 278, 279, 280, 281, 282, 283, 284, 124, 286, -1,
458 288, 289, 38, -1, 40, 41, -1, -1, 44, 257,
459 258, 259, 93, -1, -1, -1, -1, -1, -1, -1,
460 257, 258, 259, 59, -1, -1, -1, 10, 276, 277,
461 278, 279, 280, 281, 282, 283, 284, -1, 286, 276,
462 288, 289, -1, 124, -1, 257, 258, 259, -1, 286,
463 10, 288, 289, -1, -1, -1, -1, 93, 61, -1,
464 257, 258, 259, -1, 276, 277, 278, 279, 280, 281,
465 282, 283, 284, -1, 286, -1, 288, 289, 38, -1,
466 40, 41, -1, -1, 44, 257, 258, 259, 124, 286,
467 10, 288, 289, -1, -1, -1, -1, -1, -1, 59,
468 -1, -1, -1, -1, 276, 277, 278, 279, 280, 281,
469 282, 283, 284, -1, 286, -1, 288, 289, 38, -1,
470 40, 41, -1, -1, 44, -1, -1, -1, -1, -1,
471 257, 258, 259, 93, -1, 10, -1, -1, -1, 59,
472 123, -1, -1, -1, -1, -1, -1, -1, -1, 276,
473 277, 278, 279, 280, 281, 282, 283, 284, -1, 286,
474 -1, 288, 289, 38, 124, 40, 41, -1, -1, 44,
475 -1, -1, -1, 93, -1, -1, 257, 258, 259, -1,
476 -1, 10, -1, -1, 59, -1, -1, -1, 10, -1,
477 -1, -1, -1, -1, -1, 276, 277, 278, 279, 280,
478 281, 282, 283, 284, 124, 286, -1, 288, 289, 38,
479 -1, 40, 41, -1, -1, 44, -1, -1, 93, -1,
480 -1, 257, 258, 259, -1, -1, 10, -1, -1, -1,
481 59, -1, 10, -1, -1, -1, -1, -1, -1, -1,
482 276, 277, 278, 279, 280, 281, 282, 283, 284, 124,
483 286, -1, 288, 289, 38, -1, 40, 41, -1, 10,
484 44, -1, -1, 10, 93, 268, 269, 270, 271, 272,
485 273, 274, -1, -1, -1, 59, 259, 260, 261, -1,
486 263, 264, 265, 266, -1, 288, 289, 38, -1, 40,
487 41, -1, -1, 44, -1, 124, -1, 257, 258, 259,
488 -1, 123, 10, -1, 287, 288, 289, -1, 59, 93,
489 -1, -1, -1, -1, -1, -1, 276, 277, 278, 279,
490 280, 281, 282, 283, 284, -1, 286, -1, 288, 289,
491 38, -1, 40, 41, -1, -1, 44, 257, 258, 259,
492 124, -1, 93, -1, 10, -1, -1, 125, -1, -1,
493 -1, 59, -1, -1, -1, -1, 276, 277, 278, 279,
494 280, 281, 282, 283, 284, -1, 286, -1, 288, 289,
495 -1, -1, -1, 124, 40, 41, 123, -1, 44, -1,
496 -1, -1, 257, 258, 259, 93, -1, 10, -1, -1,
497 -1, -1, -1, 59, -1, -1, -1, -1, -1, -1,
498 -1, 276, 277, 278, 279, 280, 281, 282, 283, 284,
499 -1, 286, -1, 288, 289, -1, 124, 40, 41, -1,
500 -1, 44, -1, -1, -1, -1, -1, 93, 257, 258,
501 259, -1, -1, -1, -1, -1, 59, 259, 260, 261,
502 -1, 263, 264, 265, 266, -1, -1, 276, 277, 278,
503 279, 280, 281, 282, 283, 284, -1, 286, 124, 288,
504 289, -1, -1, -1, -1, 287, 288, 289, -1, -1,
505 93, -1, -1, 257, 258, 259, -1, -1, -1, -1,
506 -1, 259, 260, 261, -1, 263, 264, 265, 266, -1,
507 10, -1, 276, 277, 278, 279, 280, 281, 282, 283,
508 284, -1, 286, -1, 288, 289, 257, 258, 259, 287,
509 288, 289, 259, 260, 261, -1, 263, 264, 265, 266,
510 40, 41, -1, -1, 44, 276, 277, 278, 279, 280,
511 281, 282, 283, 284, -1, 286, -1, 288, 289, 59,
512 287, 288, 289, -1, -1, 125, -1, -1, -1, 257,
513 258, 259, 37, 38, -1, 125, -1, 42, 43, -1,
514 45, -1, 47, -1, -1, -1, -1, -1, 276, 277,
515 -1, -1, -1, 93, -1, -1, -1, -1, 286, -1,
516 288, 289, -1, -1, -1, -1, -1, -1, -1, 37,
517 38, 257, 258, 259, 42, 43, -1, 45, -1, 47,
518 -1, -1, -1, -1, -1, 10, 91, 37, 38, -1,
519 276, 277, 42, 43, -1, 45, -1, 47, 23, -1,
520 286, 37, 288, 289, -1, -1, 42, 43, -1, 45,
521 -1, 47, 37, -1, 257, 258, 259, -1, -1, 124,
522 -1, -1, -1, 91, 14, 50, 51, 52, 53, 54,
523 55, 56, -1, 276, 277, -1, -1, -1, 28, 29,
524 -1, 91, -1, 286, -1, 288, 289, -1, 38, -1,
525 -1, -1, -1, -1, -1, 91, 124, -1, -1, 259,
526 260, 261, -1, 263, 264, 265, 266, -1, 58, 259,
527 260, 261, -1, 263, 264, 265, 266, 259, 260, 261,
528 -1, 263, 264, 265, 266, -1, 76, 287, 288, 289,
529 -1, -1, 117, -1, -1, -1, -1, 287, 288, 289,
530 -1, -1, -1, -1, -1, 287, 288, 289, -1, -1,
531 -1, -1, -1, -1, -1, -1, -1, 257, 258, 259,
532 -1, -1, -1, -1, -1, -1, -1, -1, 118, -1,
533 -1, -1, -1, -1, -1, -1, 161, 162, 163, 164,
534 165, 166, 167, 168, -1, -1, 286, -1, 288, 289,
535 -1, -1, -1, -1, -1, -1, -1, 147, -1, -1,
536 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
537 -1, -1, 277, 278, 279, 280, 281, 282, 283, 284,
538 -1, 171, -1, -1, -1, 290, -1, -1, -1, -1,
539 -1, -1, -1, -1, -1, -1, -1, 187, 188, -1,
540 190, -1, -1, -1, 194, -1, 196, -1, -1, -1,
541 278, 279, 280, 281, 282, 283, 284, -1, -1, -1,
542 -1, -1, 290, -1, -1, -1, -1, -1, 278, 279,
543 280, 281, 282, 283, 284, -1, -1, -1, -1, -1,
544 290, -1, 278, 279, 280, 281, 282, 283, 284, 27,
545 -1, -1, -1, -1, 290, 33, 34, -1, -1, -1,
546 -1, 39, -1, -1, -1, -1, -1, -1, -1, -1,
547 -1, 49, -1, -1, -1, -1, -1, -1, -1, -1,
548 -1, -1, 60, -1, 62, -1, -1, -1, -1, -1,
549 -1, -1, -1, -1, -1, -1, 74, -1, -1, -1,
550 -1, -1, 80, 81, 82, 83, 84, 85, 86, 87,
551 88, 89, 90, 91, 92, 93, 94, -1, 96, 97,
552 -1, -1, -1, -1, -1, -1, -1, -1, -1, 107,
553 108, 109, 110, 111, 112, 113, -1, -1, -1, -1,
554 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
555 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
556 -1, -1, -1, -1, -1, -1, 144, 145, -1, -1,
557 -1, 149, -1, -1, -1, -1, -1, -1, -1, -1,
558 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
559 -1, -1, -1, -1, -1, -1, -1, -1, -1, 177,
560 178, 179, 180, 181, 182, 183, 184,
566 #define YYMAXTOKEN 290
568 const char * const yyname
[] = {
569 "end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
570 0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'","','","'-'",0,"'/'",0,0,0,0,0,
571 0,0,0,0,0,0,"';'",0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
572 0,0,"'['",0,"']'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
573 "'{'","'|'","'}'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
574 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
575 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
576 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"NUMBER","STRING","SYMBOL","IF","WHILE",
577 "ELSE","FOR","BREAK","CONTINUE","RETURN","IF_NO_ELSE","ADDEQ","SUBEQ","MULEQ",
578 "DIVEQ","MODEQ","ANDEQ","OREQ","CONCAT","OR","AND","GT","GE","LT","LE","EQ",
579 "NE","IN","UNARY_MINUS","NOT","DELETE","INCR","DECR","POW",
581 const char * const yyrule
[] = {
583 "program : blank stmts",
584 "program : blank '{' blank stmts '}'",
585 "program : blank '{' blank '}'",
587 "block : '{' blank stmts '}' blank",
588 "block : '{' blank '}' blank",
591 "stmts : stmts stmt",
592 "stmt : simpstmt '\\n' blank",
593 "stmt : IF '(' cond ')' blank block",
594 "stmt : IF '(' cond ')' blank block else blank block",
595 "stmt : while '(' cond ')' blank block",
596 "stmt : for '(' comastmts ';' cond ';' comastmts ')' blank block",
598 "stmt : for '(' SYMBOL IN arrayexpr ')' $$1 blank block",
599 "stmt : BREAK '\\n' blank",
600 "stmt : CONTINUE '\\n' blank",
601 "stmt : RETURN expr '\\n' blank",
602 "stmt : RETURN '\\n' blank",
603 "simpstmt : SYMBOL '=' expr",
604 "simpstmt : evalsym ADDEQ expr",
605 "simpstmt : evalsym SUBEQ expr",
606 "simpstmt : evalsym MULEQ expr",
607 "simpstmt : evalsym DIVEQ expr",
608 "simpstmt : evalsym MODEQ expr",
609 "simpstmt : evalsym ANDEQ expr",
610 "simpstmt : evalsym OREQ expr",
611 "simpstmt : DELETE arraylv '[' arglist ']'",
612 "simpstmt : initarraylv '[' arglist ']' '=' expr",
613 "simpstmt : initarraylv '[' arglist ']' ADDEQ expr",
614 "simpstmt : initarraylv '[' arglist ']' SUBEQ expr",
615 "simpstmt : initarraylv '[' arglist ']' MULEQ expr",
616 "simpstmt : initarraylv '[' arglist ']' DIVEQ expr",
617 "simpstmt : initarraylv '[' arglist ']' MODEQ expr",
618 "simpstmt : initarraylv '[' arglist ']' ANDEQ expr",
619 "simpstmt : initarraylv '[' arglist ']' OREQ expr",
620 "simpstmt : initarraylv '[' arglist ']' INCR",
621 "simpstmt : initarraylv '[' arglist ']' DECR",
622 "simpstmt : INCR initarraylv '[' arglist ']'",
623 "simpstmt : DECR initarraylv '[' arglist ']'",
624 "simpstmt : SYMBOL '(' arglist ')'",
625 "simpstmt : INCR SYMBOL",
626 "simpstmt : SYMBOL INCR",
627 "simpstmt : DECR SYMBOL",
628 "simpstmt : SYMBOL DECR",
631 "comastmts : simpstmt",
632 "comastmts : comastmts ',' simpstmt",
635 "arglist : arglist ',' expr",
637 "expr : expr numexpr",
638 "initarraylv : SYMBOL",
639 "initarraylv : initarraylv '[' arglist ']'",
641 "arraylv : arraylv '[' arglist ']'",
642 "arrayexpr : numexpr",
646 "numexpr : SYMBOL '(' arglist ')'",
647 "numexpr : '(' expr ')'",
648 "numexpr : numexpr '[' arglist ']'",
649 "numexpr : numexpr '+' numexpr",
650 "numexpr : numexpr '-' numexpr",
651 "numexpr : numexpr '*' numexpr",
652 "numexpr : numexpr '/' numexpr",
653 "numexpr : numexpr '%' numexpr",
654 "numexpr : numexpr POW numexpr",
655 "numexpr : '-' numexpr",
656 "numexpr : numexpr GT numexpr",
657 "numexpr : numexpr GE numexpr",
658 "numexpr : numexpr LT numexpr",
659 "numexpr : numexpr LE numexpr",
660 "numexpr : numexpr EQ numexpr",
661 "numexpr : numexpr NE numexpr",
662 "numexpr : numexpr '&' numexpr",
663 "numexpr : numexpr '|' numexpr",
664 "numexpr : numexpr and numexpr",
665 "numexpr : numexpr or numexpr",
666 "numexpr : NOT numexpr",
667 "numexpr : INCR SYMBOL",
668 "numexpr : SYMBOL INCR",
669 "numexpr : DECR SYMBOL",
670 "numexpr : SYMBOL DECR",
671 "numexpr : numexpr IN numexpr",
680 "blank : blank '\\n'",
688 #define YYMAXDEPTH YYSTACKSIZE
691 #define YYSTACKSIZE YYMAXDEPTH
693 #define YYSTACKSIZE 10000
694 #define YYMAXDEPTH 10000
697 #define YYINITSTACKSIZE 200
711 /* User Subroutines Section */
715 ** Parse a null terminated string and create a program from it (this is the
716 ** parser entry point). The program created by this routine can be
717 ** executed using ExecuteProgram. Returns program on success, or NULL
718 ** on failure. If the command failed, the error message is returned
719 ** as a pointer to a static string in msg, and the length of the string up
720 ** to where parsing failed in stoppedAt.
722 Program
*ParseMacro(char *expr
, char **msg
, char **stoppedAt
)
726 BeginCreatingProgram();
728 /* call yyparse to parse the string and check for success. If the parse
729 failed, return the error message and string index (the grammar aborts
730 parsing at the first error) */
735 FreeProgram(FinishCreatingProgram());
739 /* get the newly created program */
740 prog
= FinishCreatingProgram();
742 /* parse succeeded */
749 static int yylex(void)
753 static DataValue value
= {NO_TAG
, {0}};
754 static char escape
[] = "\\\"ntbrfav";
755 static char replace
[] = "\\\"\n\t\b\r\f\a\v";
757 /* skip whitespace, backslash-newline combinations, and comments, which are
758 all considered whitespace */
760 if (*InPtr
== '\\' && *(InPtr
+ 1) == '\n')
762 else if (*InPtr
== ' ' || *InPtr
== '\t')
764 else if (*InPtr
== '#')
765 while (*InPtr
!= '\n' && *InPtr
!= '\0') {
766 /* Comments stop at escaped newlines */
767 if (*InPtr
== '\\' && *(InPtr
+ 1) == '\n') {
776 /* return end of input at the end of the string */
777 if (*InPtr
== '\0') {
781 /* process number tokens */
782 if (isdigit((unsigned char)*InPtr
)) { /* number */
784 sscanf(InPtr
, "%d%n", &value
.val
.n
, &len
);
785 sprintf(name
, "const %d", value
.val
.n
);
788 if ((yylval
.sym
=LookupSymbol(name
)) == NULL
)
789 yylval
.sym
= InstallSymbol(name
, CONST_SYM
, value
);
793 /* process symbol tokens. "define" is a special case not handled
794 by this parser, considered end of input. Another special case
795 is action routine names which are allowed to contain '-' despite
796 the ambiguity, handled in matchesActionRoutine. */
797 if (isalpha((unsigned char)*InPtr
) || *InPtr
== '$') {
798 if ((s
=matchesActionRoutine(&InPtr
)) == NULL
) {
799 char symName
[MAX_SYM_LEN
+1], *p
= symName
;
801 while (isalnum((unsigned char)*InPtr
) || *InPtr
=='_') {
802 if (p
>= symName
+ MAX_SYM_LEN
)
808 if (!strcmp(symName
, "while")) return WHILE
;
809 if (!strcmp(symName
, "if")) return IF
;
810 if (!strcmp(symName
, "else")) return ELSE
;
811 if (!strcmp(symName
, "for")) return FOR
;
812 if (!strcmp(symName
, "break")) return BREAK
;
813 if (!strcmp(symName
, "continue")) return CONTINUE
;
814 if (!strcmp(symName
, "return")) return RETURN
;
815 if (!strcmp(symName
, "in")) return IN
;
816 if (!strcmp(symName
, "delete") && follow_non_whitespace('(', SYMBOL
, DELETE
) == DELETE
) return DELETE
;
817 if (!strcmp(symName
, "define")) {
821 if ((s
=LookupSymbol(symName
)) == NULL
) {
822 s
= InstallSymbol(symName
, symName
[0]=='$' ?
823 (isdigit((unsigned char)symName
[1]) ?
824 ARG_SYM
: GLOBAL_SYM
) : LOCAL_SYM
, value
);
825 s
->value
.tag
= NO_TAG
;
832 /* process quoted strings w/ embedded escape sequences */
833 if (*InPtr
== '\"') {
834 char string
[MAX_STRING_CONST_LEN
], *p
= string
;
836 while (*InPtr
!= '\0' && *InPtr
!= '\"' && *InPtr
!= '\n') {
837 if (p
>= string
+ MAX_STRING_CONST_LEN
) {
841 if (*InPtr
== '\\') {
843 if (*InPtr
== '\n') {
847 for (i
=0; escape
[i
]!='\0'; i
++) {
848 if (escape
[i
] == '\0') {
851 } else if (escape
[i
] == *InPtr
) {
862 yylval
.sym
= InstallStringConstSymbol(string
);
866 /* process remaining two character tokens or return single char as token */
868 case '>': return follow('=', GE
, GT
);
869 case '<': return follow('=', LE
, LT
);
870 case '=': return follow('=', EQ
, '=');
871 case '!': return follow('=', NE
, NOT
);
872 case '+': return follow2('+', INCR
, '=', ADDEQ
, '+');
873 case '-': return follow2('-', DECR
, '=', SUBEQ
, '-');
874 case '|': return follow2('|', OR
, '=', OREQ
, '|');
875 case '&': return follow2('&', AND
, '=', ANDEQ
, '&');
876 case '*': return follow2('*', POW
, '=', MULEQ
, '*');
877 case '/': return follow('=', DIVEQ
, '/');
878 case '%': return follow('=', MODEQ
, '%');
879 case '^': return POW
;
880 default: return *(InPtr
-1);
885 ** look ahead for >=, etc.
887 static int follow(char expect
, int yes
, int no
)
889 if (*InPtr
++ == expect
)
894 static int follow2(char expect1
, int yes1
, char expect2
, int yes2
, int no
)
896 char next
= *InPtr
++;
905 static int follow_non_whitespace(char expect
, int yes
, int no
)
907 char *localInPtr
= InPtr
;
910 if (*localInPtr
== ' ' || *localInPtr
== '\t') {
913 else if (*localInPtr
== '\\' && *(localInPtr
+ 1) == '\n') {
916 else if (*localInPtr
== expect
) {
926 ** Look (way) ahead for hyphenated routine names which begin at inPtr. A
927 ** hyphenated name is allowed if it is pre-defined in the global symbol
928 ** table. If a matching name exists, returns the symbol, and update "inPtr".
930 ** I know this is horrible language design, but existing nedit action routine
931 ** names contain hyphens. Handling them here in the lexical analysis process
932 ** is much easier than trying to deal with it in the parser itself. (sorry)
934 static Symbol
*matchesActionRoutine(char **inPtr
)
938 char symbolName
[MAX_SYM_LEN
+1];
942 for (c
= *inPtr
; isalnum((unsigned char)*c
) || *c
=='_' ||
943 ( *c
=='-' && isalnum((unsigned char)(*(c
+1)))); c
++) {
951 s
= LookupSymbol(symbolName
);
958 ** Called by yacc to report errors (just stores for returning when
959 ** parsing is aborted. The error token action is to immediate abort
960 ** parsing, so this message is immediately reported to the caller
963 static int yyerror(char *s
)
969 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
970 static int yygrowstack()
976 if ((newsize
= yystacksize
) == 0)
977 newsize
= YYINITSTACKSIZE
;
978 else if (newsize
>= YYMAXDEPTH
)
980 else if ((newsize
*= 2) > YYMAXDEPTH
)
981 newsize
= YYMAXDEPTH
;
983 newss
= yyss
? (short *)realloc(yyss
, newsize
* sizeof *newss
) :
984 (short *)malloc(newsize
* sizeof *newss
);
989 newvs
= yyvs
? (YYSTYPE
*)realloc(yyvs
, newsize
* sizeof *newvs
) :
990 (YYSTYPE
*)malloc(newsize
* sizeof *newvs
);
995 yystacksize
= newsize
;
996 yysslim
= yyss
+ newsize
- 1;
1000 #define YYABORT goto yyabort
1001 #define YYREJECT goto yyabort
1002 #define YYACCEPT goto yyaccept
1003 #define YYERROR goto yyerrlab
1005 #ifndef YYPARSE_PARAM
1006 #if defined(__cplusplus) || __STDC__
1007 #define YYPARSE_PARAM_ARG void
1008 #define YYPARSE_PARAM_DECL
1009 #else /* ! ANSI-C/C++ */
1010 #define YYPARSE_PARAM_ARG
1011 #define YYPARSE_PARAM_DECL
1012 #endif /* ANSI-C/C++ */
1013 #else /* YYPARSE_PARAM */
1014 #ifndef YYPARSE_PARAM_TYPE
1015 #define YYPARSE_PARAM_TYPE void *
1017 #if defined(__cplusplus) || __STDC__
1018 #define YYPARSE_PARAM_ARG YYPARSE_PARAM_TYPE YYPARSE_PARAM
1019 #define YYPARSE_PARAM_DECL
1020 #else /* ! ANSI-C/C++ */
1021 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
1022 #define YYPARSE_PARAM_DECL YYPARSE_PARAM_TYPE YYPARSE_PARAM;
1023 #endif /* ANSI-C/C++ */
1024 #endif /* ! YYPARSE_PARAM */
1027 yyparse (YYPARSE_PARAM_ARG
)
1030 register int yym
, yyn
, yystate
;
1032 register const char *yys
;
1034 if ((yys
= getenv("YYDEBUG")))
1037 if (yyn
>= '0' && yyn
<= '9')
1038 yydebug
= yyn
- '0';
1046 if (yyss
== NULL
&& yygrowstack()) goto yyoverflow
;
1049 *yyssp
= yystate
= 0;
1052 if ((yyn
= yydefred
[yystate
])) goto yyreduce
;
1055 if ((yychar
= yylex()) < 0) yychar
= 0;
1060 if (yychar
<= YYMAXTOKEN
) yys
= yyname
[yychar
];
1061 if (!yys
) yys
= "illegal-symbol";
1062 printf("%sdebug: state %d, reading %d (%s)\n",
1063 YYPREFIX
, yystate
, yychar
, yys
);
1067 if ((yyn
= yysindex
[yystate
]) && (yyn
+= yychar
) >= 0 &&
1068 yyn
<= YYTABLESIZE
&& yycheck
[yyn
] == yychar
)
1072 printf("%sdebug: state %d, shifting to state %d\n",
1073 YYPREFIX
, yystate
, yytable
[yyn
]);
1075 if (yyssp
>= yysslim
&& yygrowstack())
1079 *++yyssp
= yystate
= yytable
[yyn
];
1082 if (yyerrflag
> 0) --yyerrflag
;
1085 if ((yyn
= yyrindex
[yystate
]) && (yyn
+= yychar
) >= 0 &&
1086 yyn
<= YYTABLESIZE
&& yycheck
[yyn
] == yychar
)
1091 if (yyerrflag
) goto yyinrecovery
;
1092 #if defined(lint) || defined(__GNUC__)
1096 yyerror("syntax error");
1097 #if defined(lint) || defined(__GNUC__)
1108 if ((yyn
= yysindex
[*yyssp
]) && (yyn
+= YYERRCODE
) >= 0 &&
1109 yyn
<= YYTABLESIZE
&& yycheck
[yyn
] == YYERRCODE
)
1113 printf("%sdebug: state %d, error recovery shifting\
1114 to state %d\n", YYPREFIX
, *yyssp
, yytable
[yyn
]);
1116 if (yyssp
>= yysslim
&& yygrowstack())
1120 *++yyssp
= yystate
= yytable
[yyn
];
1128 printf("%sdebug: error recovery discarding state %d\n",
1131 if (yyssp
<= yyss
) goto yyabort
;
1139 if (yychar
== 0) goto yyabort
;
1144 if (yychar
<= YYMAXTOKEN
) yys
= yyname
[yychar
];
1145 if (!yys
) yys
= "illegal-symbol";
1146 printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
1147 YYPREFIX
, yystate
, yychar
, yys
);
1156 printf("%sdebug: state %d, reducing by rule %d (%s)\n",
1157 YYPREFIX
, yystate
, yyn
, yyrule
[yyn
]);
1160 yyval
= yyvsp
[1-yym
];
1166 ADD_OP(OP_RETURN_NO_VAL
); return 0;
1172 ADD_OP(OP_RETURN_NO_VAL
); return 0;
1178 ADD_OP(OP_RETURN_NO_VAL
); return 0;
1190 SET_BR_OFF(yyvsp
[-3].inst
, GetPC());
1196 SET_BR_OFF(yyvsp
[-6].inst
, (yyvsp
[-2].inst
+1)); SET_BR_OFF(yyvsp
[-2].inst
, GetPC());
1202 ADD_OP(OP_BRANCH
); ADD_BR_OFF(yyvsp
[-5].inst
);
1203 SET_BR_OFF(yyvsp
[-3].inst
, GetPC()); FillLoopAddrs(GetPC(), yyvsp
[-5].inst
);
1209 FillLoopAddrs(GetPC()+2+(yyvsp
[-3].inst
-(yyvsp
[-5].inst
+1)), GetPC());
1210 SwapCode(yyvsp
[-5].inst
+1, yyvsp
[-3].inst
, GetPC());
1211 ADD_OP(OP_BRANCH
); ADD_BR_OFF(yyvsp
[-7].inst
); SET_BR_OFF(yyvsp
[-5].inst
, GetPC());
1217 Symbol
*iterSym
= InstallIteratorSymbol();
1218 ADD_OP(OP_BEGIN_ARRAY_ITER
); ADD_SYM(iterSym
);
1219 ADD_OP(OP_ARRAY_ITER
); ADD_SYM(yyvsp
[-3].sym
); ADD_SYM(iterSym
); ADD_BR_OFF(0);
1225 ADD_OP(OP_BRANCH
); ADD_BR_OFF(yyvsp
[-4].inst
+2);
1226 SET_BR_OFF(yyvsp
[-4].inst
+5, GetPC());
1227 FillLoopAddrs(GetPC(), yyvsp
[-4].inst
+2);
1233 ADD_OP(OP_BRANCH
); ADD_BR_OFF(0);
1234 if (AddBreakAddr(GetPC()-1)) {
1235 yyerror("break outside loop"); YYERROR
;
1242 ADD_OP(OP_BRANCH
); ADD_BR_OFF(0);
1243 if (AddContinueAddr(GetPC()-1)) {
1244 yyerror("continue outside loop"); YYERROR
;
1257 ADD_OP(OP_RETURN_NO_VAL
);
1263 ADD_OP(OP_ASSIGN
); ADD_SYM(yyvsp
[-2].sym
);
1269 ADD_OP(OP_ADD
); ADD_OP(OP_ASSIGN
); ADD_SYM(yyvsp
[-2].sym
);
1275 ADD_OP(OP_SUB
); ADD_OP(OP_ASSIGN
); ADD_SYM(yyvsp
[-2].sym
);
1281 ADD_OP(OP_MUL
); ADD_OP(OP_ASSIGN
); ADD_SYM(yyvsp
[-2].sym
);
1287 ADD_OP(OP_DIV
); ADD_OP(OP_ASSIGN
); ADD_SYM(yyvsp
[-2].sym
);
1293 ADD_OP(OP_MOD
); ADD_OP(OP_ASSIGN
); ADD_SYM(yyvsp
[-2].sym
);
1299 ADD_OP(OP_BIT_AND
); ADD_OP(OP_ASSIGN
); ADD_SYM(yyvsp
[-2].sym
);
1305 ADD_OP(OP_BIT_OR
); ADD_OP(OP_ASSIGN
); ADD_SYM(yyvsp
[-2].sym
);
1311 ADD_OP(OP_ARRAY_DELETE
); ADD_IMMED((void *)yyvsp
[-1].nArgs
);
1317 ADD_OP(OP_ARRAY_ASSIGN
); ADD_IMMED((void *)yyvsp
[-3].nArgs
);
1323 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP
); ADD_IMMED((void *)1); ADD_IMMED((void *)yyvsp
[-3].nArgs
);
1325 ADD_OP(OP_ARRAY_ASSIGN
); ADD_IMMED((void *)yyvsp
[-3].nArgs
);
1331 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP
); ADD_IMMED((void *)1); ADD_IMMED((void *)yyvsp
[-3].nArgs
);
1333 ADD_OP(OP_ARRAY_ASSIGN
); ADD_IMMED((void *)yyvsp
[-3].nArgs
);
1339 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP
); ADD_IMMED((void *)1); ADD_IMMED((void *)yyvsp
[-3].nArgs
);
1341 ADD_OP(OP_ARRAY_ASSIGN
); ADD_IMMED((void *)yyvsp
[-3].nArgs
);
1347 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP
); ADD_IMMED((void *)1); ADD_IMMED((void *)yyvsp
[-3].nArgs
);
1349 ADD_OP(OP_ARRAY_ASSIGN
); ADD_IMMED((void *)yyvsp
[-3].nArgs
);
1355 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP
); ADD_IMMED((void *)1); ADD_IMMED((void *)yyvsp
[-3].nArgs
);
1357 ADD_OP(OP_ARRAY_ASSIGN
); ADD_IMMED((void *)yyvsp
[-3].nArgs
);
1363 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP
); ADD_IMMED((void *)1); ADD_IMMED((void *)yyvsp
[-3].nArgs
);
1365 ADD_OP(OP_ARRAY_ASSIGN
); ADD_IMMED((void *)yyvsp
[-3].nArgs
);
1371 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP
); ADD_IMMED((void *)1); ADD_IMMED((void *)yyvsp
[-3].nArgs
);
1373 ADD_OP(OP_ARRAY_ASSIGN
); ADD_IMMED((void *)yyvsp
[-3].nArgs
);
1379 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP
); ADD_IMMED((void *)0); ADD_IMMED((void *)yyvsp
[-2].nArgs
);
1381 ADD_OP(OP_ARRAY_ASSIGN
); ADD_IMMED((void *)yyvsp
[-2].nArgs
);
1387 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP
); ADD_IMMED((void *)0); ADD_IMMED((void *)yyvsp
[-2].nArgs
);
1389 ADD_OP(OP_ARRAY_ASSIGN
); ADD_IMMED((void *)yyvsp
[-2].nArgs
);
1395 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP
); ADD_IMMED((void *)0); ADD_IMMED((void *)yyvsp
[-1].nArgs
);
1397 ADD_OP(OP_ARRAY_ASSIGN
); ADD_IMMED((void *)yyvsp
[-1].nArgs
);
1403 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP
); ADD_IMMED((void *)0); ADD_IMMED((void *)yyvsp
[-1].nArgs
);
1405 ADD_OP(OP_ARRAY_ASSIGN
); ADD_IMMED((void *)yyvsp
[-1].nArgs
);
1411 ADD_OP(OP_SUBR_CALL
);
1412 ADD_SYM(PromoteToGlobal(yyvsp
[-3].sym
)); ADD_IMMED((void *)yyvsp
[-1].nArgs
);
1418 ADD_OP(OP_PUSH_SYM
); ADD_SYM(yyvsp
[0].sym
); ADD_OP(OP_INCR
);
1419 ADD_OP(OP_ASSIGN
); ADD_SYM(yyvsp
[0].sym
);
1425 ADD_OP(OP_PUSH_SYM
); ADD_SYM(yyvsp
[-1].sym
); ADD_OP(OP_INCR
);
1426 ADD_OP(OP_ASSIGN
); ADD_SYM(yyvsp
[-1].sym
);
1432 ADD_OP(OP_PUSH_SYM
); ADD_SYM(yyvsp
[0].sym
); ADD_OP(OP_DECR
);
1433 ADD_OP(OP_ASSIGN
); ADD_SYM(yyvsp
[0].sym
);
1439 ADD_OP(OP_PUSH_SYM
); ADD_SYM(yyvsp
[-1].sym
); ADD_OP(OP_DECR
);
1440 ADD_OP(OP_ASSIGN
); ADD_SYM(yyvsp
[-1].sym
);
1446 yyval
.sym
= yyvsp
[0].sym
; ADD_OP(OP_PUSH_SYM
); ADD_SYM(yyvsp
[0].sym
);
1452 yyval
.inst
= GetPC();
1458 yyval
.inst
= GetPC();
1464 yyval
.inst
= GetPC();
1482 yyval
.nArgs
= yyvsp
[-2].nArgs
+ 1;
1494 ADD_OP(OP_PUSH_ARRAY_SYM
); ADD_SYM(yyvsp
[0].sym
); ADD_IMMED((void *)1);
1500 ADD_OP(OP_ARRAY_REF
); ADD_IMMED((void *)yyvsp
[-1].nArgs
);
1506 ADD_OP(OP_PUSH_ARRAY_SYM
); ADD_SYM(yyvsp
[0].sym
); ADD_IMMED((void *)0);
1512 ADD_OP(OP_ARRAY_REF
); ADD_IMMED((void *)yyvsp
[-1].nArgs
);
1518 yyval
.inst
= GetPC();
1524 ADD_OP(OP_PUSH_SYM
); ADD_SYM(yyvsp
[0].sym
);
1530 ADD_OP(OP_PUSH_SYM
); ADD_SYM(yyvsp
[0].sym
);
1536 ADD_OP(OP_PUSH_SYM
); ADD_SYM(yyvsp
[0].sym
);
1542 ADD_OP(OP_SUBR_CALL
);
1543 ADD_SYM(PromoteToGlobal(yyvsp
[-3].sym
)); ADD_IMMED((void *)yyvsp
[-1].nArgs
);
1544 ADD_OP(OP_FETCH_RET_VAL
);
1550 ADD_OP(OP_ARRAY_REF
); ADD_IMMED((void *)yyvsp
[-1].nArgs
);
1646 ADD_OP(OP_AND
); SET_BR_OFF(yyvsp
[-1].inst
, GetPC());
1652 ADD_OP(OP_OR
); SET_BR_OFF(yyvsp
[-1].inst
, GetPC());
1664 ADD_OP(OP_PUSH_SYM
); ADD_SYM(yyvsp
[0].sym
); ADD_OP(OP_INCR
);
1665 ADD_OP(OP_DUP
); ADD_OP(OP_ASSIGN
); ADD_SYM(yyvsp
[0].sym
);
1671 ADD_OP(OP_PUSH_SYM
); ADD_SYM(yyvsp
[-1].sym
); ADD_OP(OP_DUP
);
1672 ADD_OP(OP_INCR
); ADD_OP(OP_ASSIGN
); ADD_SYM(yyvsp
[-1].sym
);
1678 ADD_OP(OP_PUSH_SYM
); ADD_SYM(yyvsp
[0].sym
); ADD_OP(OP_DECR
);
1679 ADD_OP(OP_DUP
); ADD_OP(OP_ASSIGN
); ADD_SYM(yyvsp
[0].sym
);
1685 ADD_OP(OP_PUSH_SYM
); ADD_SYM(yyvsp
[-1].sym
); ADD_OP(OP_DUP
);
1686 ADD_OP(OP_DECR
); ADD_OP(OP_ASSIGN
); ADD_SYM(yyvsp
[-1].sym
);
1692 ADD_OP(OP_IN_ARRAY
);
1698 yyval
.inst
= GetPC(); StartLoopAddrList();
1704 StartLoopAddrList(); yyval
.inst
= GetPC();
1710 ADD_OP(OP_BRANCH
); yyval
.inst
= GetPC(); ADD_BR_OFF(0);
1716 ADD_OP(OP_BRANCH_NEVER
); yyval
.inst
= GetPC(); ADD_BR_OFF(0);
1722 ADD_OP(OP_BRANCH_FALSE
); yyval
.inst
= GetPC(); ADD_BR_OFF(0);
1728 ADD_OP(OP_DUP
); ADD_OP(OP_BRANCH_FALSE
); yyval
.inst
= GetPC();
1735 ADD_OP(OP_DUP
); ADD_OP(OP_BRANCH_TRUE
); yyval
.inst
= GetPC();
1739 #line 1736 "y.tab.c"
1745 if (yystate
== 0 && yym
== 0)
1749 printf("%sdebug: after reduction, shifting from state 0 to\
1750 state %d\n", YYPREFIX
, YYFINAL
);
1757 if ((yychar
= yylex()) < 0) yychar
= 0;
1762 if (yychar
<= YYMAXTOKEN
) yys
= yyname
[yychar
];
1763 if (!yys
) yys
= "illegal-symbol";
1764 printf("%sdebug: state %d, reading %d (%s)\n",
1765 YYPREFIX
, YYFINAL
, yychar
, yys
);
1769 if (yychar
== 0) goto yyaccept
;
1772 if ((yyn
= yygindex
[yym
]) && (yyn
+= yystate
) >= 0 &&
1773 yyn
<= YYTABLESIZE
&& yycheck
[yyn
] == yystate
)
1774 yystate
= yytable
[yyn
];
1776 yystate
= yydgoto
[yym
];
1779 printf("%sdebug: after reduction, shifting from state %d \
1780 to state %d\n", YYPREFIX
, *yyssp
, yystate
);
1782 if (yyssp
>= yysslim
&& yygrowstack())
1790 yyerror("yacc stack overflow");