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"
31 #include <X11/Intrinsic.h>
34 #include "../util/VMSparam.h"
37 #include <sys/param.h>
45 /* Macros to add error processing to AddOp and AddSym calls */
46 #define ADD_OP(op) if (!AddOp(op, &ErrMsg)) return 1
47 #define ADD_SYM(sym) if (!AddSym(sym, &ErrMsg)) return 1
48 #define ADD_IMMED(val) if (!AddImmediate(val, &ErrMsg)) return 1
49 #define ADD_BR_OFF(to) if (!AddBranchOffset(to, &ErrMsg)) return 1
50 #define SET_BR_OFF(from, to) *((int *)(from)) = ((Inst *)(to)) - ((Inst *)(from))
52 /* Max. length for a string constant (... there shouldn't be a maximum) */
53 #define MAX_STRING_CONST_LEN 5000
55 static const char CVSID
[] = "$Id: parse_noyacc.c,v 1.8 2003/12/19 23:23:31 slobasso Exp $";
56 static int yyerror(char *s
);
57 static int yylex(void);
59 static int follow(char expect
, int yes
, int no
);
60 static int follow2(char expect1
, int yes1
, char expect2
, int yes2
, int no
);
61 static int follow_non_whitespace(char expect
, int yes
, int no
);
62 static Symbol
*matchesActionRoutine(char **inPtr
);
66 extern Inst
*LoopStack
[]; /* addresses of break, cont stmts */
67 extern Inst
**LoopStackPtr
; /* to fill at the end of a loop */
81 #define ARG_LOOKUP 261
89 #define IF_NO_ELSE 269
107 #define UNARY_MINUS 287
112 const short yylhs
[] = { -1,
113 0, 0, 0, 0, 13, 13, 13, 12, 12, 14,
114 14, 14, 14, 14, 16, 14, 14, 14, 14, 14,
115 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
116 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
117 15, 15, 15, 15, 15, 15, 10, 3, 3, 3,
118 1, 1, 1, 17, 17, 19, 19, 18, 18, 9,
119 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
120 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
121 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
122 20, 20, 5, 4, 6, 2, 2, 7, 8, 11,
125 const short yylen
[] = { 2,
126 2, 5, 4, 1, 5, 4, 1, 1, 2, 3,
127 6, 9, 6, 10, 0, 9, 3, 3, 4, 3,
128 3, 3, 3, 3, 3, 3, 3, 3, 5, 6,
129 6, 6, 6, 6, 6, 6, 6, 5, 5, 5,
130 5, 4, 2, 2, 2, 2, 1, 0, 1, 3,
131 0, 1, 3, 1, 2, 1, 4, 1, 4, 1,
132 1, 1, 1, 4, 3, 4, 3, 1, 4, 3,
133 3, 3, 3, 3, 3, 2, 3, 3, 3, 3,
134 3, 3, 3, 3, 3, 3, 2, 2, 2, 2,
135 2, 3, 1, 1, 1, 0, 1, 1, 1, 0,
138 const short yydefred
[] = { 0,
139 4, 0, 0, 0, 0, 0, 93, 94, 0, 0,
140 0, 0, 0, 100, 101, 0, 0, 0, 0, 8,
141 0, 0, 0, 44, 46, 0, 58, 0, 0, 100,
142 100, 61, 62, 0, 0, 0, 0, 0, 0, 0,
143 100, 0, 0, 0, 0, 0, 0, 0, 0, 0,
144 0, 0, 0, 0, 0, 0, 0, 9, 100, 0,
145 0, 0, 0, 0, 0, 0, 0, 0, 89, 91,
146 0, 0, 0, 0, 88, 90, 0, 0, 100, 0,
147 99, 98, 0, 0, 0, 0, 0, 0, 0, 0,
148 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
149 0, 0, 3, 0, 0, 0, 49, 0, 0, 0,
150 0, 0, 0, 0, 0, 0, 0, 42, 0, 0,
151 100, 0, 67, 0, 65, 0, 0, 0, 0, 0,
152 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
153 0, 0, 0, 0, 0, 0, 2, 0, 0, 0,
154 100, 0, 0, 0, 0, 64, 66, 69, 0, 0,
155 0, 0, 0, 50, 0, 0, 0, 0, 0, 0,
156 0, 0, 0, 38, 39, 100, 0, 7, 15, 0,
157 13, 0, 0, 0, 0, 0, 0, 0, 0, 0,
158 95, 100, 100, 0, 100, 0, 0, 0, 100, 0,
159 100, 12, 16, 0, 0, 14,
161 const short yydgoto
[] = { 2,
162 62, 65, 106, 16, 17, 192, 99, 100, 161, 18,
163 3, 19, 177, 178, 21, 193, 63, 28, 22, 43,
165 const short yysindex
[] = { -242,
166 0, 0, 221, 6, -243, -15, 0, 0, 32, 42,
167 603, -209, -204, 0, 0, 54, 58, 768, 1179, 0,
168 77, 22, 843, 0, 0, 843, 0, 38, 843, 0,
169 0, 0, 0, 8, 44, 843, 843, -150, -142, 843,
170 0, 747, 1368, 0, 46, 0, 49, 369, 101, 843,
171 843, 843, 843, 843, 843, 843, 843, 0, 0, 843,
172 843, -26, 843, 843, 82, 1368, 121, 121, 0, 0,
173 843, 975, -87, -87, 0, 0, 837, 121, 0, 1368,
174 0, 0, 843, 843, 843, 843, 843, 843, 843, 843,
175 843, 843, 843, 843, 843, 843, 843, 843, 843, 843,
176 843, 843, 0, 328, -31, -27, 0, 104, 843, 843,
177 843, 843, 843, 843, 843, 121, -22, 0, 843, -21,
178 0, -17, 0, -35, 0, 121, 65, 163, -9, -9,
179 -9, -9, -9, -9, -9, 2, 2, -87, -87, -87,
180 -87, -7, 23, 1250, 39, 40, 0, 843, 843, 504,
181 0, 624, 843, 0, 292, 0, 0, 0, 0, 0,
182 110, 1368, 94, 0, 292, 843, 843, 843, 843, 843,
183 843, 843, 843, 0, 0, 0, -110, 0, 0, 504,
184 0, 843, 843, 843, 843, 843, 843, 843, 843, 665,
185 0, 0, 0, 55, 0, 464, 292, 292, 0, 121,
186 0, 0, 0, 292, 121, 0,
188 const short yyrindex
[] = { 700,
189 0, 0, 0, -91, 0, 0, 0, 0, 0, 0,
190 0, 0, 0, 0, 0, 0, 0, 0, 155, 0,
191 0, 0, 0, 0, 0, 56, 0, 0, 116, 0,
192 0, 0, 0, 383, 128, 0, 0, 0, 0, 0,
193 0, 0, 179, 10, 0, 108, 0, 0, -18, 116,
194 0, 0, 0, 0, 0, 0, 0, 0, 0, 51,
195 47, 0, -1, 51, 0, -28, 1, 11, 0, 0,
196 56, 0, 419, 455, 0, 0, 0, 21, 0, 431,
197 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
198 0, 0, 0, 0, 0, 0, 0, 51, 0, 0,
199 51, 51, 0, 0, -91, 0, 0, 0, 75, 80,
200 117, 481, 503, 568, 611, 53, 0, 0, 0, 0,
201 0, 0, 0, 0, 0, 63, 1342, 1337, 899, 934,
202 969, 1197, 1232, 1267, 1302, 827, 863, 491, 527, 563,
203 791, 0, 1377, 877, 0, 0, 0, 0, 127, 0,
204 0, 69, 18, 118, 0, 0, 0, 0, 391, 539,
205 0, 122, 0, 0, 0, 0, 0, 0, 0, 0,
206 0, 0, 0, 0, 0, 0, 115, 0, 0, 81,
207 0, 613, 755, 815, 875, 932, 936, 940, 942, 0,
208 0, 0, 0, 0, 0, 0, 0, 0, 0, 73,
211 const short yygindex
[] = { 0,
212 444, -45, -16, 0, 0, 0, 0, 0, 0, 0,
213 1272, -42, 37, 26, -30, 0, 24, 0, 129, 1632,
215 #define YYTABLESIZE 1821
216 const short yytable
[] = { 56,
217 17, 96, 84, 98, 108, 104, 94, 92, 26, 93,
218 18, 95, 97, 1, 118, 27, 150, 119, 107, 43,
219 20, 119, 119, 156, 29, 48, 119, 96, 20, 23,
220 97, 149, 94, 92, 42, 93, 119, 95, 96, 52,
221 48, 30, 52, 94, 58, 26, 61, 71, 95, 44,
222 43, 31, 10, 43, 46, 98, 21, 157, 53, 96,
223 84, 53, 19, 77, 94, 92, 23, 93, 43, 95,
224 152, 154, 6, 20, 109, 110, 111, 112, 113, 114,
225 115, 98, 119, 119, 22, 158, 59, 21, 83, 23,
226 21, 52, 98, 49, 51, 199, 51, 50, 150, 51,
227 56, 96, 84, 163, 5, 21, 94, 92, 75, 93,
228 53, 95, 60, 98, 11, 22, 76, 45, 22, 164,
229 23, 48, 121, 23, 48, 17, 24, 29, 64, 58,
230 15, 159, 160, 22, 72, 18, 101, 68, 23, 102,
231 45, 47, 153, 51, 151, 20, 83, 196, 45, 107,
232 179, 45, 180, 191, 1, 98, 96, 24, 29, 57,
233 24, 29, 60, 194, 68, 68, 45, 68, 68, 68,
234 68, 68, 68, 0, 68, 24, 29, 10, 47, 47,
235 47, 47, 47, 47, 47, 96, 68, 19, 54, 182,
236 183, 184, 185, 186, 187, 188, 189, 6, 56, 96,
237 0, 181, 0, 97, 94, 92, 0, 93, 59, 95,
238 0, 0, 0, 0, 0, 20, 0, 0, 54, 54,
239 68, 58, 54, 0, 0, 0, 0, 0, 0, 5,
240 15, 0, 0, 202, 203, 0, 0, 54, 0, 11,
241 206, 0, 81, 82, 85, 86, 87, 88, 89, 90,
242 91, 68, 0, 98, 148, 97, 0, 24, 25, 17,
243 17, 0, 17, 17, 17, 17, 17, 17, 17, 18,
244 18, 54, 18, 18, 18, 18, 18, 18, 18, 20,
245 20, 97, 20, 20, 20, 20, 20, 20, 20, 17,
246 17, 0, 97, 0, 24, 25, 69, 70, 0, 18,
247 18, 15, 85, 86, 87, 88, 89, 90, 91, 20,
248 20, 10, 10, 97, 10, 10, 10, 10, 10, 10,
249 10, 19, 19, 0, 19, 19, 19, 19, 19, 19,
250 19, 6, 6, 0, 6, 6, 6, 6, 6, 6,
251 6, 10, 10, 14, 85, 86, 87, 88, 89, 90,
252 91, 19, 19, 0, 0, 97, 0, 0, 0, 105,
253 5, 6, 6, 5, 5, 0, 5, 5, 5, 5,
254 5, 5, 5, 11, 11, 0, 11, 11, 15, 11,
255 11, 11, 11, 0, 68, 68, 68, 0, 68, 12,
256 13, 0, 63, 5, 5, 0, 0, 0, 0, 0,
257 40, 0, 0, 11, 11, 68, 68, 68, 68, 68,
258 68, 68, 68, 68, 176, 68, 68, 68, 68, 63,
259 63, 0, 0, 63, 63, 63, 63, 63, 76, 63,
260 0, 40, 0, 0, 40, 54, 54, 54, 0, 54,
261 55, 63, 85, 86, 87, 88, 89, 90, 91, 40,
262 0, 0, 147, 97, 0, 76, 76, 0, 76, 76,
263 76, 76, 76, 76, 87, 76, 54, 54, 54, 0,
264 55, 55, 0, 63, 55, 63, 0, 76, 0, 4,
265 5, 57, 6, 7, 0, 8, 9, 10, 11, 55,
266 25, 87, 87, 103, 87, 87, 87, 87, 87, 87,
267 72, 87, 0, 117, 0, 0, 63, 120, 0, 12,
268 13, 76, 26, 87, 122, 0, 0, 0, 0, 0,
269 0, 25, 0, 55, 25, 0, 0, 72, 72, 0,
270 72, 72, 72, 72, 72, 72, 73, 72, 0, 25,
271 0, 142, 76, 26, 145, 146, 26, 87, 41, 72,
272 4, 5, 0, 6, 7, 0, 8, 9, 10, 11,
273 0, 26, 0, 73, 73, 0, 73, 73, 73, 73,
274 73, 73, 74, 73, 0, 0, 0, 27, 87, 41,
275 12, 13, 41, 72, 0, 73, 4, 5, 201, 6,
276 7, 0, 8, 9, 10, 11, 0, 41, 0, 74,
277 74, 0, 74, 74, 74, 74, 74, 74, 27, 74,
278 0, 27, 41, 0, 72, 0, 12, 13, 0, 73,
279 28, 74, 30, 0, 0, 0, 27, 4, 5, 57,
280 6, 7, 0, 8, 9, 10, 11, 0, 0, 63,
281 63, 63, 40, 63, 0, 0, 0, 36, 0, 0,
282 73, 28, 0, 30, 28, 74, 30, 12, 13, 0,
283 63, 63, 63, 63, 63, 63, 63, 63, 63, 28,
284 63, 30, 0, 63, 15, 76, 76, 76, 0, 76,
285 0, 0, 0, 0, 166, 0, 74, 55, 55, 55,
286 0, 55, 0, 0, 0, 0, 76, 76, 76, 76,
287 76, 76, 76, 76, 76, 0, 76, 76, 76, 100,
288 0, 87, 87, 87, 0, 87, 0, 0, 55, 55,
289 55, 0, 4, 5, 0, 6, 7, 0, 8, 9,
290 10, 11, 87, 87, 87, 87, 87, 87, 87, 87,
291 87, 0, 87, 87, 87, 0, 0, 72, 72, 72,
292 0, 72, 12, 13, 0, 0, 79, 0, 0, 0,
293 0, 0, 4, 5, 31, 0, 0, 0, 72, 72,
294 72, 72, 72, 72, 72, 72, 72, 0, 72, 72,
295 72, 0, 0, 73, 73, 73, 40, 73, 0, 195,
296 0, 36, 12, 13, 0, 31, 0, 0, 31, 0,
297 75, 0, 0, 0, 73, 73, 73, 73, 73, 73,
298 73, 73, 73, 31, 73, 73, 73, 0, 0, 74,
299 74, 74, 100, 74, 32, 0, 0, 75, 75, 0,
300 75, 75, 75, 75, 75, 75, 70, 75, 0, 0,
301 74, 74, 74, 74, 74, 74, 74, 74, 74, 75,
302 74, 74, 74, 0, 0, 32, 0, 0, 32, 32,
303 33, 34, 0, 35, 70, 0, 70, 70, 0, 70,
304 70, 70, 71, 32, 0, 0, 40, 125, 0, 0,
305 0, 36, 40, 75, 33, 70, 86, 36, 0, 0,
306 37, 38, 39, 167, 168, 169, 170, 171, 172, 173,
307 71, 0, 71, 71, 0, 71, 71, 71, 77, 0,
308 0, 0, 174, 175, 75, 33, 86, 86, 33, 70,
309 86, 71, 0, 4, 5, 0, 6, 7, 0, 8,
310 9, 10, 11, 33, 0, 86, 77, 0, 77, 77,
311 0, 34, 77, 78, 0, 35, 0, 0, 0, 36,
312 70, 37, 0, 12, 13, 71, 0, 77, 100, 100,
313 0, 100, 100, 0, 100, 100, 100, 100, 0, 86,
314 0, 78, 34, 78, 78, 34, 35, 78, 79, 35,
315 36, 0, 37, 36, 0, 37, 71, 0, 100, 100,
316 34, 77, 78, 0, 35, 0, 0, 0, 36, 0,
317 37, 0, 0, 32, 33, 34, 79, 35, 79, 79,
318 0, 0, 79, 0, 40, 0, 0, 0, 0, 36,
319 0, 0, 77, 0, 0, 0, 78, 79, 0, 0,
320 0, 0, 0, 0, 37, 38, 39, 51, 52, 53,
321 54, 55, 56, 57, 0, 0, 0, 75, 75, 75,
322 0, 75, 0, 0, 0, 0, 0, 78, 0, 0,
323 0, 79, 0, 0, 0, 0, 0, 123, 75, 75,
324 75, 75, 75, 75, 75, 75, 75, 0, 75, 75,
325 75, 0, 0, 70, 70, 70, 0, 70, 0, 0,
326 0, 0, 79, 32, 33, 34, 0, 35, 0, 32,
327 33, 34, 0, 35, 70, 70, 70, 70, 70, 70,
328 70, 70, 70, 0, 70, 70, 70, 0, 0, 71,
329 71, 71, 0, 71, 37, 38, 39, 0, 0, 0,
330 37, 38, 39, 86, 86, 86, 0, 86, 0, 0,
331 71, 71, 71, 71, 71, 71, 71, 71, 71, 0,
332 71, 71, 71, 0, 86, 77, 77, 77, 0, 77,
333 0, 0, 0, 0, 86, 86, 86, 0, 0, 0,
334 0, 0, 0, 0, 0, 0, 77, 77, 77, 77,
335 77, 77, 77, 77, 77, 0, 77, 77, 77, 0,
336 78, 78, 78, 0, 78, 0, 0, 0, 0, 0,
337 0, 0, 0, 0, 0, 0, 80, 0, 0, 0,
338 0, 78, 78, 78, 78, 78, 78, 78, 78, 78,
339 0, 78, 78, 78, 0, 79, 79, 79, 0, 79,
340 0, 32, 33, 34, 80, 35, 80, 80, 0, 0,
341 80, 81, 0, 0, 0, 0, 79, 79, 79, 79,
342 79, 79, 79, 79, 79, 80, 79, 79, 79, 0,
343 0, 0, 37, 38, 39, 0, 0, 0, 0, 81,
344 0, 81, 81, 0, 0, 81, 82, 0, 0, 0,
345 0, 0, 0, 0, 0, 48, 96, 84, 0, 80,
346 81, 94, 92, 0, 93, 0, 95, 0, 0, 0,
347 0, 67, 68, 0, 82, 0, 82, 82, 0, 0,
348 82, 92, 78, 0, 0, 0, 0, 0, 0, 0,
349 80, 0, 0, 0, 81, 82, 0, 0, 0, 0,
350 116, 0, 0, 0, 0, 0, 0, 0, 0, 92,
351 98, 92, 92, 0, 0, 92, 83, 0, 0, 0,
352 126, 84, 0, 0, 0, 81, 0, 0, 0, 82,
353 92, 0, 0, 0, 0, 0, 0, 0, 0, 0,
354 0, 0, 0, 83, 83, 0, 83, 83, 0, 0,
355 83, 84, 84, 0, 0, 84, 85, 0, 0, 0,
356 82, 0, 155, 0, 92, 83, 0, 0, 0, 0,
357 84, 0, 0, 0, 96, 84, 0, 0, 0, 94,
358 92, 0, 93, 0, 95, 0, 85, 85, 0, 0,
359 85, 0, 165, 0, 0, 92, 0, 0, 0, 83,
360 0, 0, 0, 0, 84, 85, 0, 4, 5, 0,
361 6, 7, 0, 8, 9, 10, 11, 190, 0, 0,
362 0, 0, 0, 80, 80, 80, 0, 80, 98, 0,
363 83, 0, 0, 197, 198, 84, 200, 12, 13, 85,
364 204, 0, 205, 0, 80, 80, 80, 80, 80, 80,
365 80, 80, 80, 0, 80, 80, 80, 0, 81, 81,
366 81, 83, 81, 0, 0, 0, 0, 0, 0, 0,
367 0, 0, 0, 0, 0, 0, 0, 0, 0, 81,
368 81, 81, 81, 81, 81, 81, 81, 81, 0, 81,
369 81, 81, 0, 82, 82, 82, 0, 82, 82, 85,
370 86, 87, 88, 89, 90, 91, 0, 0, 0, 0,
371 97, 0, 0, 0, 82, 82, 82, 82, 82, 82,
372 82, 82, 82, 0, 82, 82, 82, 0, 92, 92,
373 92, 0, 92, 0, 0, 0, 0, 0, 0, 0,
374 0, 0, 0, 0, 0, 0, 0, 0, 0, 92,
375 92, 92, 92, 92, 92, 92, 92, 92, 0, 92,
376 92, 92, 0, 83, 83, 83, 0, 83, 84, 84,
377 84, 0, 84, 0, 0, 0, 0, 0, 0, 0,
378 0, 0, 0, 0, 83, 83, 0, 0, 0, 84,
379 84, 0, 0, 0, 83, 83, 83, 0, 0, 84,
380 84, 84, 0, 85, 85, 85, 0, 85, 0, 0,
381 0, 0, 0, 0, 0, 81, 82, 85, 86, 87,
382 88, 89, 90, 91, 85, 85, 0, 0, 97, 0,
383 66, 0, 0, 0, 85, 85, 85, 73, 74, 0,
384 0, 0, 0, 80, 0, 0, 0, 0, 0, 0,
385 0, 66, 0, 0, 0, 0, 0, 0, 0, 0,
386 0, 0, 80, 0, 80, 0, 0, 0, 0, 0,
387 0, 0, 0, 124, 0, 0, 0, 0, 80, 0,
388 0, 0, 0, 0, 127, 128, 129, 130, 131, 132,
389 133, 134, 135, 136, 137, 138, 139, 140, 141, 0,
390 143, 144, 0, 0, 0, 0, 0, 0, 0, 0,
391 80, 80, 80, 80, 80, 80, 80, 0, 0, 0,
392 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
393 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
394 0, 0, 0, 0, 0, 0, 0, 0, 0, 162,
395 66, 0, 0, 0, 80, 0, 0, 0, 0, 0,
396 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
397 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
398 0, 0, 0, 80, 80, 80, 80, 80, 80, 80,
401 const short yycheck
[] = { 91,
402 0, 37, 38, 91, 50, 48, 42, 43, 40, 45,
403 0, 47, 41, 256, 41, 259, 44, 44, 49, 10,
404 0, 44, 44, 41, 40, 44, 44, 37, 3, 61,
405 59, 59, 42, 43, 11, 45, 44, 47, 37, 41,
406 59, 10, 44, 42, 19, 40, 23, 40, 47, 259,
407 41, 10, 0, 44, 259, 91, 10, 93, 41, 37,
408 38, 44, 0, 40, 42, 43, 61, 45, 59, 47,
409 93, 93, 0, 48, 51, 52, 53, 54, 55, 56,
410 57, 91, 44, 44, 10, 93, 10, 41, 124, 10,
411 44, 93, 91, 40, 44, 41, 41, 40, 44, 44,
412 91, 37, 38, 149, 0, 59, 42, 43, 259, 45,
413 93, 47, 91, 91, 0, 41, 259, 10, 44, 150,
414 41, 41, 41, 44, 44, 125, 10, 10, 91, 104,
415 10, 93, 93, 59, 91, 125, 91, 10, 59, 91,
416 12, 13, 119, 93, 41, 125, 124, 190, 41, 180,
417 41, 44, 59, 264, 0, 91, 41, 41, 41, 91,
418 44, 44, 41, 180, 37, 38, 59, 40, 41, 42,
419 43, 44, 45, -1, 47, 59, 59, 125, 270, 271,
420 272, 273, 274, 275, 276, 59, 59, 125, 10, 166,
421 167, 168, 169, 170, 171, 172, 173, 125, 91, 37,
422 -1, 165, -1, 291, 42, 43, -1, 45, 91, 47,
423 -1, -1, -1, -1, -1, 190, -1, -1, 40, 41,
424 93, 196, 44, -1, -1, -1, -1, -1, -1, 125,
425 10, -1, -1, 197, 198, -1, -1, 59, -1, 125,
426 204, -1, 278, 279, 280, 281, 282, 283, 284, 285,
427 286, 124, -1, 91, 286, 291, -1, 289, 290, 259,
428 260, -1, 262, 263, 264, 265, 266, 267, 268, 259,
429 260, 93, 262, 263, 264, 265, 266, 267, 268, 259,
430 260, 291, 262, 263, 264, 265, 266, 267, 268, 289,
431 290, -1, 291, -1, 289, 290, 289, 290, -1, 289,
432 290, 10, 280, 281, 282, 283, 284, 285, 286, 289,
433 290, 259, 260, 291, 262, 263, 264, 265, 266, 267,
434 268, 259, 260, -1, 262, 263, 264, 265, 266, 267,
435 268, 259, 260, -1, 262, 263, 264, 265, 266, 267,
436 268, 289, 290, 123, 280, 281, 282, 283, 284, 285,
437 286, 289, 290, -1, -1, 291, -1, -1, -1, 259,
438 260, 289, 290, 259, 260, -1, 262, 263, 264, 265,
439 266, 267, 268, 259, 260, -1, 262, 263, 10, 265,
440 266, 267, 268, -1, 257, 258, 259, -1, 261, 289,
441 290, -1, 10, 289, 290, -1, -1, -1, -1, -1,
442 10, -1, -1, 289, 290, 278, 279, 280, 281, 282,
443 283, 284, 285, 286, 123, 288, 289, 290, 291, 37,
444 38, -1, -1, 41, 42, 43, 44, 45, 10, 47,
445 -1, 41, -1, -1, 44, 257, 258, 259, -1, 261,
446 10, 59, 280, 281, 282, 283, 284, 285, 286, 59,
447 -1, -1, 125, 291, -1, 37, 38, -1, 40, 41,
448 42, 43, 44, 45, 10, 47, 288, 289, 290, -1,
449 40, 41, -1, 91, 44, 93, -1, 59, -1, 259,
450 260, 91, 262, 263, -1, 265, 266, 267, 268, 59,
451 10, 37, 38, 125, 40, 41, 42, 43, 44, 45,
452 10, 47, -1, 60, -1, -1, 124, 64, -1, 289,
453 290, 93, 10, 59, 71, -1, -1, -1, -1, -1,
454 -1, 41, -1, 93, 44, -1, -1, 37, 38, -1,
455 40, 41, 42, 43, 44, 45, 10, 47, -1, 59,
456 -1, 98, 124, 41, 101, 102, 44, 93, 10, 59,
457 259, 260, -1, 262, 263, -1, 265, 266, 267, 268,
458 -1, 59, -1, 37, 38, -1, 40, 41, 42, 43,
459 44, 45, 10, 47, -1, -1, -1, 10, 124, 41,
460 289, 290, 44, 93, -1, 59, 259, 260, 125, 262,
461 263, -1, 265, 266, 267, 268, -1, 59, -1, 37,
462 38, -1, 40, 41, 42, 43, 44, 45, 41, 47,
463 -1, 44, 10, -1, 124, -1, 289, 290, -1, 93,
464 10, 59, 10, -1, -1, -1, 59, 259, 260, 91,
465 262, 263, -1, 265, 266, 267, 268, -1, -1, 257,
466 258, 259, 40, 261, -1, -1, -1, 45, -1, -1,
467 124, 41, -1, 41, 44, 93, 44, 289, 290, -1,
468 278, 279, 280, 281, 282, 283, 284, 285, 286, 59,
469 288, 59, -1, 291, 10, 257, 258, 259, -1, 261,
470 -1, -1, -1, -1, 61, -1, 124, 257, 258, 259,
471 -1, 261, -1, -1, -1, -1, 278, 279, 280, 281,
472 282, 283, 284, 285, 286, -1, 288, 289, 290, 10,
473 -1, 257, 258, 259, -1, 261, -1, -1, 288, 289,
474 290, -1, 259, 260, -1, 262, 263, -1, 265, 266,
475 267, 268, 278, 279, 280, 281, 282, 283, 284, 285,
476 286, -1, 288, 289, 290, -1, -1, 257, 258, 259,
477 -1, 261, 289, 290, -1, -1, 10, -1, -1, -1,
478 -1, -1, 259, 260, 10, -1, -1, -1, 278, 279,
479 280, 281, 282, 283, 284, 285, 286, -1, 288, 289,
480 290, -1, -1, 257, 258, 259, 40, 261, -1, 125,
481 -1, 45, 289, 290, -1, 41, -1, -1, 44, -1,
482 10, -1, -1, -1, 278, 279, 280, 281, 282, 283,
483 284, 285, 286, 59, 288, 289, 290, -1, -1, 257,
484 258, 259, 123, 261, 10, -1, -1, 37, 38, -1,
485 40, 41, 42, 43, 44, 45, 10, 47, -1, -1,
486 278, 279, 280, 281, 282, 283, 284, 285, 286, 59,
487 288, 289, 290, -1, -1, 41, -1, -1, 44, 257,
488 258, 259, -1, 261, 38, -1, 40, 41, -1, 43,
489 44, 45, 10, 59, -1, -1, 40, 41, -1, -1,
490 -1, 45, 40, 93, 10, 59, 10, 45, -1, -1,
491 288, 289, 290, 270, 271, 272, 273, 274, 275, 276,
492 38, -1, 40, 41, -1, 43, 44, 45, 10, -1,
493 -1, -1, 289, 290, 124, 41, 40, 41, 44, 93,
494 44, 59, -1, 259, 260, -1, 262, 263, -1, 265,
495 266, 267, 268, 59, -1, 59, 38, -1, 40, 41,
496 -1, 10, 44, 10, -1, 10, -1, -1, -1, 10,
497 124, 10, -1, 289, 290, 93, -1, 59, 259, 260,
498 -1, 262, 263, -1, 265, 266, 267, 268, -1, 93,
499 -1, 38, 41, 40, 41, 44, 41, 44, 10, 44,
500 41, -1, 41, 44, -1, 44, 124, -1, 289, 290,
501 59, 93, 59, -1, 59, -1, -1, -1, 59, -1,
502 59, -1, -1, 257, 258, 259, 38, 261, 40, 41,
503 -1, -1, 44, -1, 40, -1, -1, -1, -1, 45,
504 -1, -1, 124, -1, -1, -1, 93, 59, -1, -1,
505 -1, -1, -1, -1, 288, 289, 290, 270, 271, 272,
506 273, 274, 275, 276, -1, -1, -1, 257, 258, 259,
507 -1, 261, -1, -1, -1, -1, -1, 124, -1, -1,
508 -1, 93, -1, -1, -1, -1, -1, 93, 278, 279,
509 280, 281, 282, 283, 284, 285, 286, -1, 288, 289,
510 290, -1, -1, 257, 258, 259, -1, 261, -1, -1,
511 -1, -1, 124, 257, 258, 259, -1, 261, -1, 257,
512 258, 259, -1, 261, 278, 279, 280, 281, 282, 283,
513 284, 285, 286, -1, 288, 289, 290, -1, -1, 257,
514 258, 259, -1, 261, 288, 289, 290, -1, -1, -1,
515 288, 289, 290, 257, 258, 259, -1, 261, -1, -1,
516 278, 279, 280, 281, 282, 283, 284, 285, 286, -1,
517 288, 289, 290, -1, 278, 257, 258, 259, -1, 261,
518 -1, -1, -1, -1, 288, 289, 290, -1, -1, -1,
519 -1, -1, -1, -1, -1, -1, 278, 279, 280, 281,
520 282, 283, 284, 285, 286, -1, 288, 289, 290, -1,
521 257, 258, 259, -1, 261, -1, -1, -1, -1, -1,
522 -1, -1, -1, -1, -1, -1, 10, -1, -1, -1,
523 -1, 278, 279, 280, 281, 282, 283, 284, 285, 286,
524 -1, 288, 289, 290, -1, 257, 258, 259, -1, 261,
525 -1, 257, 258, 259, 38, 261, 40, 41, -1, -1,
526 44, 10, -1, -1, -1, -1, 278, 279, 280, 281,
527 282, 283, 284, 285, 286, 59, 288, 289, 290, -1,
528 -1, -1, 288, 289, 290, -1, -1, -1, -1, 38,
529 -1, 40, 41, -1, -1, 44, 10, -1, -1, -1,
530 -1, -1, -1, -1, -1, 14, 37, 38, -1, 93,
531 59, 42, 43, -1, 45, -1, 47, -1, -1, -1,
532 -1, 30, 31, -1, 38, -1, 40, 41, -1, -1,
533 44, 10, 41, -1, -1, -1, -1, -1, -1, -1,
534 124, -1, -1, -1, 93, 59, -1, -1, -1, -1,
535 59, -1, -1, -1, -1, -1, -1, -1, -1, 38,
536 91, 40, 41, -1, -1, 44, 10, -1, -1, -1,
537 79, 10, -1, -1, -1, 124, -1, -1, -1, 93,
538 59, -1, -1, -1, -1, -1, -1, -1, -1, -1,
539 -1, -1, -1, 124, 38, -1, 40, 41, -1, -1,
540 44, 40, 41, -1, -1, 44, 10, -1, -1, -1,
541 124, -1, 121, -1, 93, 59, -1, -1, -1, -1,
542 59, -1, -1, -1, 37, 38, -1, -1, -1, 42,
543 43, -1, 45, -1, 47, -1, 40, 41, -1, -1,
544 44, -1, 151, -1, -1, 124, -1, -1, -1, 93,
545 -1, -1, -1, -1, 93, 59, -1, 259, 260, -1,
546 262, 263, -1, 265, 266, 267, 268, 176, -1, -1,
547 -1, -1, -1, 257, 258, 259, -1, 261, 91, -1,
548 124, -1, -1, 192, 193, 124, 195, 289, 290, 93,
549 199, -1, 201, -1, 278, 279, 280, 281, 282, 283,
550 284, 285, 286, -1, 288, 289, 290, -1, 257, 258,
551 259, 124, 261, -1, -1, -1, -1, -1, -1, -1,
552 -1, -1, -1, -1, -1, -1, -1, -1, -1, 278,
553 279, 280, 281, 282, 283, 284, 285, 286, -1, 288,
554 289, 290, -1, 257, 258, 259, -1, 261, 279, 280,
555 281, 282, 283, 284, 285, 286, -1, -1, -1, -1,
556 291, -1, -1, -1, 278, 279, 280, 281, 282, 283,
557 284, 285, 286, -1, 288, 289, 290, -1, 257, 258,
558 259, -1, 261, -1, -1, -1, -1, -1, -1, -1,
559 -1, -1, -1, -1, -1, -1, -1, -1, -1, 278,
560 279, 280, 281, 282, 283, 284, 285, 286, -1, 288,
561 289, 290, -1, 257, 258, 259, -1, 261, 257, 258,
562 259, -1, 261, -1, -1, -1, -1, -1, -1, -1,
563 -1, -1, -1, -1, 278, 279, -1, -1, -1, 278,
564 279, -1, -1, -1, 288, 289, 290, -1, -1, 288,
565 289, 290, -1, 257, 258, 259, -1, 261, -1, -1,
566 -1, -1, -1, -1, -1, 278, 279, 280, 281, 282,
567 283, 284, 285, 286, 278, 279, -1, -1, 291, -1,
568 29, -1, -1, -1, 288, 289, 290, 36, 37, -1,
569 -1, -1, -1, 42, -1, -1, -1, -1, -1, -1,
570 -1, 50, -1, -1, -1, -1, -1, -1, -1, -1,
571 -1, -1, 61, -1, 63, -1, -1, -1, -1, -1,
572 -1, -1, -1, 72, -1, -1, -1, -1, 77, -1,
573 -1, -1, -1, -1, 83, 84, 85, 86, 87, 88,
574 89, 90, 91, 92, 93, 94, 95, 96, 97, -1,
575 99, 100, -1, -1, -1, -1, -1, -1, -1, -1,
576 109, 110, 111, 112, 113, 114, 115, -1, -1, -1,
577 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
578 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
579 -1, -1, -1, -1, -1, -1, -1, -1, -1, 148,
580 149, -1, -1, -1, 153, -1, -1, -1, -1, -1,
581 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
582 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
583 -1, -1, -1, 182, 183, 184, 185, 186, 187, 188,
590 #define YYMAXTOKEN 291
592 const char * const yyname
[] = {
593 "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,
594 0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'","','","'-'",0,"'/'",0,0,0,0,0,
595 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,
596 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,
597 "'{'","'|'","'}'",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,
598 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,
599 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,
600 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"NUMBER","STRING","SYMBOL","DELETE",
601 "ARG_LOOKUP","IF","WHILE","ELSE","FOR","BREAK","CONTINUE","RETURN","IF_NO_ELSE",
602 "ADDEQ","SUBEQ","MULEQ","DIVEQ","MODEQ","ANDEQ","OREQ","CONCAT","OR","AND","GT",
603 "GE","LT","LE","EQ","NE","IN","UNARY_MINUS","NOT","INCR","DECR","POW",
605 const char * const yyrule
[] = {
607 "program : blank stmts",
608 "program : blank '{' blank stmts '}'",
609 "program : blank '{' blank '}'",
611 "block : '{' blank stmts '}' blank",
612 "block : '{' blank '}' blank",
615 "stmts : stmts stmt",
616 "stmt : simpstmt '\\n' blank",
617 "stmt : IF '(' cond ')' blank block",
618 "stmt : IF '(' cond ')' blank block else blank block",
619 "stmt : while '(' cond ')' blank block",
620 "stmt : for '(' comastmts ';' cond ';' comastmts ')' blank block",
622 "stmt : for '(' SYMBOL IN arrayexpr ')' $$1 blank block",
623 "stmt : BREAK '\\n' blank",
624 "stmt : CONTINUE '\\n' blank",
625 "stmt : RETURN expr '\\n' blank",
626 "stmt : RETURN '\\n' blank",
627 "simpstmt : SYMBOL '=' expr",
628 "simpstmt : evalsym ADDEQ expr",
629 "simpstmt : evalsym SUBEQ expr",
630 "simpstmt : evalsym MULEQ expr",
631 "simpstmt : evalsym DIVEQ expr",
632 "simpstmt : evalsym MODEQ expr",
633 "simpstmt : evalsym ANDEQ expr",
634 "simpstmt : evalsym OREQ expr",
635 "simpstmt : DELETE arraylv '[' arglist ']'",
636 "simpstmt : initarraylv '[' arglist ']' '=' expr",
637 "simpstmt : initarraylv '[' arglist ']' ADDEQ expr",
638 "simpstmt : initarraylv '[' arglist ']' SUBEQ expr",
639 "simpstmt : initarraylv '[' arglist ']' MULEQ expr",
640 "simpstmt : initarraylv '[' arglist ']' DIVEQ expr",
641 "simpstmt : initarraylv '[' arglist ']' MODEQ expr",
642 "simpstmt : initarraylv '[' arglist ']' ANDEQ expr",
643 "simpstmt : initarraylv '[' arglist ']' OREQ expr",
644 "simpstmt : initarraylv '[' arglist ']' INCR",
645 "simpstmt : initarraylv '[' arglist ']' DECR",
646 "simpstmt : INCR initarraylv '[' arglist ']'",
647 "simpstmt : DECR initarraylv '[' arglist ']'",
648 "simpstmt : SYMBOL '(' arglist ')'",
649 "simpstmt : INCR SYMBOL",
650 "simpstmt : SYMBOL INCR",
651 "simpstmt : DECR SYMBOL",
652 "simpstmt : SYMBOL DECR",
655 "comastmts : simpstmt",
656 "comastmts : comastmts ',' simpstmt",
659 "arglist : arglist ',' expr",
661 "expr : expr numexpr",
662 "initarraylv : SYMBOL",
663 "initarraylv : initarraylv '[' arglist ']'",
665 "arraylv : arraylv '[' arglist ']'",
666 "arrayexpr : numexpr",
670 "numexpr : SYMBOL '(' arglist ')'",
671 "numexpr : '(' expr ')'",
672 "numexpr : ARG_LOOKUP '[' numexpr ']'",
673 "numexpr : ARG_LOOKUP '[' ']'",
674 "numexpr : ARG_LOOKUP",
675 "numexpr : numexpr '[' arglist ']'",
676 "numexpr : numexpr '+' numexpr",
677 "numexpr : numexpr '-' numexpr",
678 "numexpr : numexpr '*' numexpr",
679 "numexpr : numexpr '/' numexpr",
680 "numexpr : numexpr '%' numexpr",
681 "numexpr : numexpr POW numexpr",
682 "numexpr : '-' numexpr",
683 "numexpr : numexpr GT numexpr",
684 "numexpr : numexpr GE numexpr",
685 "numexpr : numexpr LT numexpr",
686 "numexpr : numexpr LE numexpr",
687 "numexpr : numexpr EQ numexpr",
688 "numexpr : numexpr NE numexpr",
689 "numexpr : numexpr '&' numexpr",
690 "numexpr : numexpr '|' numexpr",
691 "numexpr : numexpr and numexpr",
692 "numexpr : numexpr or numexpr",
693 "numexpr : NOT numexpr",
694 "numexpr : INCR SYMBOL",
695 "numexpr : SYMBOL INCR",
696 "numexpr : DECR SYMBOL",
697 "numexpr : SYMBOL DECR",
698 "numexpr : numexpr IN numexpr",
707 "blank : blank '\\n'",
715 #define YYMAXDEPTH YYSTACKSIZE
718 #define YYSTACKSIZE YYMAXDEPTH
720 #define YYSTACKSIZE 10000
721 #define YYMAXDEPTH 10000
724 #define YYINITSTACKSIZE 200
738 /* User Subroutines Section */
742 ** Parse a null terminated string and create a program from it (this is the
743 ** parser entry point). The program created by this routine can be
744 ** executed using ExecuteProgram. Returns program on success, or NULL
745 ** on failure. If the command failed, the error message is returned
746 ** as a pointer to a static string in msg, and the length of the string up
747 ** to where parsing failed in stoppedAt.
749 Program
*ParseMacro(char *expr
, char **msg
, char **stoppedAt
)
753 BeginCreatingProgram();
755 /* call yyparse to parse the string and check for success. If the parse
756 failed, return the error message and string index (the grammar aborts
757 parsing at the first error) */
762 FreeProgram(FinishCreatingProgram());
766 /* get the newly created program */
767 prog
= FinishCreatingProgram();
769 /* parse succeeded */
776 static int yylex(void)
780 static DataValue value
= {NO_TAG
, {0}};
781 static char escape
[] = "\\\"ntbrfav";
782 static char replace
[] = "\\\"\n\t\b\r\f\a\v";
784 /* skip whitespace, backslash-newline combinations, and comments, which are
785 all considered whitespace */
787 if (*InPtr
== '\\' && *(InPtr
+ 1) == '\n')
789 else if (*InPtr
== ' ' || *InPtr
== '\t')
791 else if (*InPtr
== '#')
792 while (*InPtr
!= '\n' && *InPtr
!= '\0') {
793 /* Comments stop at escaped newlines */
794 if (*InPtr
== '\\' && *(InPtr
+ 1) == '\n') {
804 /* return end of input at the end of the string */
805 if (*InPtr
== '\0') {
809 /* process number tokens */
810 if (isdigit((unsigned char)*InPtr
)) { /* number */
812 sscanf(InPtr
, "%d%n", &value
.val
.n
, &len
);
813 sprintf(name
, "const %d", value
.val
.n
);
816 if ((yylval
.sym
=LookupSymbol(name
)) == NULL
)
817 yylval
.sym
= InstallSymbol(name
, CONST_SYM
, value
);
821 /* process symbol tokens. "define" is a special case not handled
822 by this parser, considered end of input. Another special case
823 is action routine names which are allowed to contain '-' despite
824 the ambiguity, handled in matchesActionRoutine. */
825 if (isalpha((unsigned char)*InPtr
) || *InPtr
== '$') {
826 if ((s
=matchesActionRoutine(&InPtr
)) == NULL
) {
827 char symName
[MAX_SYM_LEN
+1], *p
= symName
;
829 while (isalnum((unsigned char)*InPtr
) || *InPtr
=='_') {
830 if (p
>= symName
+ MAX_SYM_LEN
)
836 if (!strcmp(symName
, "while")) return WHILE
;
837 if (!strcmp(symName
, "if")) return IF
;
838 if (!strcmp(symName
, "else")) return ELSE
;
839 if (!strcmp(symName
, "for")) return FOR
;
840 if (!strcmp(symName
, "break")) return BREAK
;
841 if (!strcmp(symName
, "continue")) return CONTINUE
;
842 if (!strcmp(symName
, "return")) return RETURN
;
843 if (!strcmp(symName
, "in")) return IN
;
844 if (!strcmp(symName
, "$args")) return ARG_LOOKUP
;
845 if (!strcmp(symName
, "delete") && follow_non_whitespace('(', SYMBOL
, DELETE
) == DELETE
) return DELETE
;
846 if (!strcmp(symName
, "define")) {
850 if ((s
=LookupSymbol(symName
)) == NULL
) {
851 s
= InstallSymbol(symName
, symName
[0]=='$' ?
852 (((symName
[1] > '0' && symName
[1] <= '9') && symName
[2] == 0) ?
853 ARG_SYM
: GLOBAL_SYM
) : LOCAL_SYM
, value
);
854 s
->value
.tag
= NO_TAG
;
861 /* process quoted strings w/ embedded escape sequences */
862 if (*InPtr
== '\"') {
863 char string
[MAX_STRING_CONST_LEN
], *p
= string
;
865 while (*InPtr
!= '\0' && *InPtr
!= '\"' && *InPtr
!= '\n') {
866 if (p
>= string
+ MAX_STRING_CONST_LEN
) {
870 if (*InPtr
== '\\') {
872 if (*InPtr
== '\n') {
876 for (i
=0; escape
[i
]!='\0'; i
++) {
877 if (escape
[i
] == '\0') {
880 } else if (escape
[i
] == *InPtr
) {
891 yylval
.sym
= InstallStringConstSymbol(string
);
895 /* process remaining two character tokens or return single char as token */
897 case '>': return follow('=', GE
, GT
);
898 case '<': return follow('=', LE
, LT
);
899 case '=': return follow('=', EQ
, '=');
900 case '!': return follow('=', NE
, NOT
);
901 case '+': return follow2('+', INCR
, '=', ADDEQ
, '+');
902 case '-': return follow2('-', DECR
, '=', SUBEQ
, '-');
903 case '|': return follow2('|', OR
, '=', OREQ
, '|');
904 case '&': return follow2('&', AND
, '=', ANDEQ
, '&');
905 case '*': return follow2('*', POW
, '=', MULEQ
, '*');
906 case '/': return follow('=', DIVEQ
, '/');
907 case '%': return follow('=', MODEQ
, '%');
908 case '^': return POW
;
909 default: return *(InPtr
-1);
914 ** look ahead for >=, etc.
916 static int follow(char expect
, int yes
, int no
)
918 if (*InPtr
++ == expect
)
923 static int follow2(char expect1
, int yes1
, char expect2
, int yes2
, int no
)
925 char next
= *InPtr
++;
934 static int follow_non_whitespace(char expect
, int yes
, int no
)
936 char *localInPtr
= InPtr
;
939 if (*localInPtr
== ' ' || *localInPtr
== '\t') {
942 else if (*localInPtr
== '\\' && *(localInPtr
+ 1) == '\n') {
945 else if (*localInPtr
== expect
) {
955 ** Look (way) ahead for hyphenated routine names which begin at inPtr. A
956 ** hyphenated name is allowed if it is pre-defined in the global symbol
957 ** table. If a matching name exists, returns the symbol, and update "inPtr".
959 ** I know this is horrible language design, but existing nedit action routine
960 ** names contain hyphens. Handling them here in the lexical analysis process
961 ** is much easier than trying to deal with it in the parser itself. (sorry)
963 static Symbol
*matchesActionRoutine(char **inPtr
)
967 char symbolName
[MAX_SYM_LEN
+1];
971 for (c
= *inPtr
; isalnum((unsigned char)*c
) || *c
=='_' ||
972 ( *c
=='-' && isalnum((unsigned char)(*(c
+1)))); c
++) {
980 s
= LookupSymbol(symbolName
);
987 ** Called by yacc to report errors (just stores for returning when
988 ** parsing is aborted. The error token action is to immediate abort
989 ** parsing, so this message is immediately reported to the caller
992 static int yyerror(char *s
)
998 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
999 static int yygrowstack()
1005 if ((newsize
= yystacksize
) == 0)
1006 newsize
= YYINITSTACKSIZE
;
1007 else if (newsize
>= YYMAXDEPTH
)
1009 else if ((newsize
*= 2) > YYMAXDEPTH
)
1010 newsize
= YYMAXDEPTH
;
1012 newss
= yyss
? (short *)realloc(yyss
, newsize
* sizeof *newss
) :
1013 (short *)malloc(newsize
* sizeof *newss
);
1018 newvs
= yyvs
? (YYSTYPE
*)realloc(yyvs
, newsize
* sizeof *newvs
) :
1019 (YYSTYPE
*)malloc(newsize
* sizeof *newvs
);
1024 yystacksize
= newsize
;
1025 yysslim
= yyss
+ newsize
- 1;
1029 #define YYABORT goto yyabort
1030 #define YYREJECT goto yyabort
1031 #define YYACCEPT goto yyaccept
1032 #define YYERROR goto yyerrlab
1034 #ifndef YYPARSE_PARAM
1035 #if defined(__cplusplus) || __STDC__
1036 #define YYPARSE_PARAM_ARG void
1037 #define YYPARSE_PARAM_DECL
1038 #else /* ! ANSI-C/C++ */
1039 #define YYPARSE_PARAM_ARG
1040 #define YYPARSE_PARAM_DECL
1041 #endif /* ANSI-C/C++ */
1042 #else /* YYPARSE_PARAM */
1043 #ifndef YYPARSE_PARAM_TYPE
1044 #define YYPARSE_PARAM_TYPE void *
1046 #if defined(__cplusplus) || __STDC__
1047 #define YYPARSE_PARAM_ARG YYPARSE_PARAM_TYPE YYPARSE_PARAM
1048 #define YYPARSE_PARAM_DECL
1049 #else /* ! ANSI-C/C++ */
1050 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
1051 #define YYPARSE_PARAM_DECL YYPARSE_PARAM_TYPE YYPARSE_PARAM;
1052 #endif /* ANSI-C/C++ */
1053 #endif /* ! YYPARSE_PARAM */
1056 yyparse (YYPARSE_PARAM_ARG
)
1059 register int yym
, yyn
, yystate
;
1061 register const char *yys
;
1063 if ((yys
= getenv("YYDEBUG")))
1066 if (yyn
>= '0' && yyn
<= '9')
1067 yydebug
= yyn
- '0';
1075 if (yyss
== NULL
&& yygrowstack()) goto yyoverflow
;
1078 *yyssp
= yystate
= 0;
1081 if ((yyn
= yydefred
[yystate
])) goto yyreduce
;
1084 if ((yychar
= yylex()) < 0) yychar
= 0;
1089 if (yychar
<= YYMAXTOKEN
) yys
= yyname
[yychar
];
1090 if (!yys
) yys
= "illegal-symbol";
1091 printf("%sdebug: state %d, reading %d (%s)\n",
1092 YYPREFIX
, yystate
, yychar
, yys
);
1096 if ((yyn
= yysindex
[yystate
]) && (yyn
+= yychar
) >= 0 &&
1097 yyn
<= YYTABLESIZE
&& yycheck
[yyn
] == yychar
)
1101 printf("%sdebug: state %d, shifting to state %d\n",
1102 YYPREFIX
, yystate
, yytable
[yyn
]);
1104 if (yyssp
>= yysslim
&& yygrowstack())
1108 *++yyssp
= yystate
= yytable
[yyn
];
1111 if (yyerrflag
> 0) --yyerrflag
;
1114 if ((yyn
= yyrindex
[yystate
]) && (yyn
+= yychar
) >= 0 &&
1115 yyn
<= YYTABLESIZE
&& yycheck
[yyn
] == yychar
)
1120 if (yyerrflag
) goto yyinrecovery
;
1121 #if defined(lint) || defined(__GNUC__)
1125 yyerror("syntax error");
1126 #if defined(lint) || defined(__GNUC__)
1137 if ((yyn
= yysindex
[*yyssp
]) && (yyn
+= YYERRCODE
) >= 0 &&
1138 yyn
<= YYTABLESIZE
&& yycheck
[yyn
] == YYERRCODE
)
1142 printf("%sdebug: state %d, error recovery shifting\
1143 to state %d\n", YYPREFIX
, *yyssp
, yytable
[yyn
]);
1145 if (yyssp
>= yysslim
&& yygrowstack())
1149 *++yyssp
= yystate
= yytable
[yyn
];
1157 printf("%sdebug: error recovery discarding state %d\n",
1160 if (yyssp
<= yyss
) goto yyabort
;
1168 if (yychar
== 0) goto yyabort
;
1173 if (yychar
<= YYMAXTOKEN
) yys
= yyname
[yychar
];
1174 if (!yys
) yys
= "illegal-symbol";
1175 printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
1176 YYPREFIX
, yystate
, yychar
, yys
);
1185 printf("%sdebug: state %d, reducing by rule %d (%s)\n",
1186 YYPREFIX
, yystate
, yyn
, yyrule
[yyn
]);
1189 yyval
= yyvsp
[1-yym
];
1195 ADD_OP(OP_RETURN_NO_VAL
); return 0;
1201 ADD_OP(OP_RETURN_NO_VAL
); return 0;
1207 ADD_OP(OP_RETURN_NO_VAL
); return 0;
1219 SET_BR_OFF(yyvsp
[-3].inst
, GetPC());
1225 SET_BR_OFF(yyvsp
[-6].inst
, (yyvsp
[-2].inst
+1)); SET_BR_OFF(yyvsp
[-2].inst
, GetPC());
1231 ADD_OP(OP_BRANCH
); ADD_BR_OFF(yyvsp
[-5].inst
);
1232 SET_BR_OFF(yyvsp
[-3].inst
, GetPC()); FillLoopAddrs(GetPC(), yyvsp
[-5].inst
);
1238 FillLoopAddrs(GetPC()+2+(yyvsp
[-3].inst
-(yyvsp
[-5].inst
+1)), GetPC());
1239 SwapCode(yyvsp
[-5].inst
+1, yyvsp
[-3].inst
, GetPC());
1240 ADD_OP(OP_BRANCH
); ADD_BR_OFF(yyvsp
[-7].inst
); SET_BR_OFF(yyvsp
[-5].inst
, GetPC());
1246 Symbol
*iterSym
= InstallIteratorSymbol();
1247 ADD_OP(OP_BEGIN_ARRAY_ITER
); ADD_SYM(iterSym
);
1248 ADD_OP(OP_ARRAY_ITER
); ADD_SYM(yyvsp
[-3].sym
); ADD_SYM(iterSym
); ADD_BR_OFF(0);
1254 ADD_OP(OP_BRANCH
); ADD_BR_OFF(yyvsp
[-4].inst
+2);
1255 SET_BR_OFF(yyvsp
[-4].inst
+5, GetPC());
1256 FillLoopAddrs(GetPC(), yyvsp
[-4].inst
+2);
1262 ADD_OP(OP_BRANCH
); ADD_BR_OFF(0);
1263 if (AddBreakAddr(GetPC()-1)) {
1264 yyerror("break outside loop"); YYERROR
;
1271 ADD_OP(OP_BRANCH
); ADD_BR_OFF(0);
1272 if (AddContinueAddr(GetPC()-1)) {
1273 yyerror("continue outside loop"); YYERROR
;
1286 ADD_OP(OP_RETURN_NO_VAL
);
1292 ADD_OP(OP_ASSIGN
); ADD_SYM(yyvsp
[-2].sym
);
1298 ADD_OP(OP_ADD
); ADD_OP(OP_ASSIGN
); ADD_SYM(yyvsp
[-2].sym
);
1304 ADD_OP(OP_SUB
); ADD_OP(OP_ASSIGN
); ADD_SYM(yyvsp
[-2].sym
);
1310 ADD_OP(OP_MUL
); ADD_OP(OP_ASSIGN
); ADD_SYM(yyvsp
[-2].sym
);
1316 ADD_OP(OP_DIV
); ADD_OP(OP_ASSIGN
); ADD_SYM(yyvsp
[-2].sym
);
1322 ADD_OP(OP_MOD
); ADD_OP(OP_ASSIGN
); ADD_SYM(yyvsp
[-2].sym
);
1328 ADD_OP(OP_BIT_AND
); ADD_OP(OP_ASSIGN
); ADD_SYM(yyvsp
[-2].sym
);
1334 ADD_OP(OP_BIT_OR
); ADD_OP(OP_ASSIGN
); ADD_SYM(yyvsp
[-2].sym
);
1340 ADD_OP(OP_ARRAY_DELETE
); ADD_IMMED((void *)yyvsp
[-1].nArgs
);
1346 ADD_OP(OP_ARRAY_ASSIGN
); ADD_IMMED((void *)yyvsp
[-3].nArgs
);
1352 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP
); ADD_IMMED((void *)1); ADD_IMMED((void *)yyvsp
[-3].nArgs
);
1354 ADD_OP(OP_ARRAY_ASSIGN
); ADD_IMMED((void *)yyvsp
[-3].nArgs
);
1360 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP
); ADD_IMMED((void *)1); ADD_IMMED((void *)yyvsp
[-3].nArgs
);
1362 ADD_OP(OP_ARRAY_ASSIGN
); ADD_IMMED((void *)yyvsp
[-3].nArgs
);
1368 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP
); ADD_IMMED((void *)1); ADD_IMMED((void *)yyvsp
[-3].nArgs
);
1370 ADD_OP(OP_ARRAY_ASSIGN
); ADD_IMMED((void *)yyvsp
[-3].nArgs
);
1376 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP
); ADD_IMMED((void *)1); ADD_IMMED((void *)yyvsp
[-3].nArgs
);
1378 ADD_OP(OP_ARRAY_ASSIGN
); ADD_IMMED((void *)yyvsp
[-3].nArgs
);
1384 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP
); ADD_IMMED((void *)1); ADD_IMMED((void *)yyvsp
[-3].nArgs
);
1386 ADD_OP(OP_ARRAY_ASSIGN
); ADD_IMMED((void *)yyvsp
[-3].nArgs
);
1392 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP
); ADD_IMMED((void *)1); ADD_IMMED((void *)yyvsp
[-3].nArgs
);
1394 ADD_OP(OP_ARRAY_ASSIGN
); ADD_IMMED((void *)yyvsp
[-3].nArgs
);
1400 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP
); ADD_IMMED((void *)1); ADD_IMMED((void *)yyvsp
[-3].nArgs
);
1402 ADD_OP(OP_ARRAY_ASSIGN
); ADD_IMMED((void *)yyvsp
[-3].nArgs
);
1408 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP
); ADD_IMMED((void *)0); ADD_IMMED((void *)yyvsp
[-2].nArgs
);
1410 ADD_OP(OP_ARRAY_ASSIGN
); ADD_IMMED((void *)yyvsp
[-2].nArgs
);
1416 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP
); ADD_IMMED((void *)0); ADD_IMMED((void *)yyvsp
[-2].nArgs
);
1418 ADD_OP(OP_ARRAY_ASSIGN
); ADD_IMMED((void *)yyvsp
[-2].nArgs
);
1424 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP
); ADD_IMMED((void *)0); ADD_IMMED((void *)yyvsp
[-1].nArgs
);
1426 ADD_OP(OP_ARRAY_ASSIGN
); ADD_IMMED((void *)yyvsp
[-1].nArgs
);
1432 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP
); ADD_IMMED((void *)0); ADD_IMMED((void *)yyvsp
[-1].nArgs
);
1434 ADD_OP(OP_ARRAY_ASSIGN
); ADD_IMMED((void *)yyvsp
[-1].nArgs
);
1440 ADD_OP(OP_SUBR_CALL
);
1441 ADD_SYM(PromoteToGlobal(yyvsp
[-3].sym
)); ADD_IMMED((void *)yyvsp
[-1].nArgs
);
1447 ADD_OP(OP_PUSH_SYM
); ADD_SYM(yyvsp
[0].sym
); ADD_OP(OP_INCR
);
1448 ADD_OP(OP_ASSIGN
); ADD_SYM(yyvsp
[0].sym
);
1454 ADD_OP(OP_PUSH_SYM
); ADD_SYM(yyvsp
[-1].sym
); ADD_OP(OP_INCR
);
1455 ADD_OP(OP_ASSIGN
); ADD_SYM(yyvsp
[-1].sym
);
1461 ADD_OP(OP_PUSH_SYM
); ADD_SYM(yyvsp
[0].sym
); ADD_OP(OP_DECR
);
1462 ADD_OP(OP_ASSIGN
); ADD_SYM(yyvsp
[0].sym
);
1468 ADD_OP(OP_PUSH_SYM
); ADD_SYM(yyvsp
[-1].sym
); ADD_OP(OP_DECR
);
1469 ADD_OP(OP_ASSIGN
); ADD_SYM(yyvsp
[-1].sym
);
1475 yyval
.sym
= yyvsp
[0].sym
; ADD_OP(OP_PUSH_SYM
); ADD_SYM(yyvsp
[0].sym
);
1481 yyval
.inst
= GetPC();
1487 yyval
.inst
= GetPC();
1493 yyval
.inst
= GetPC();
1511 yyval
.nArgs
= yyvsp
[-2].nArgs
+ 1;
1523 ADD_OP(OP_PUSH_ARRAY_SYM
); ADD_SYM(yyvsp
[0].sym
); ADD_IMMED((void *)1);
1529 ADD_OP(OP_ARRAY_REF
); ADD_IMMED((void *)yyvsp
[-1].nArgs
);
1535 ADD_OP(OP_PUSH_ARRAY_SYM
); ADD_SYM(yyvsp
[0].sym
); ADD_IMMED((void *)0);
1541 ADD_OP(OP_ARRAY_REF
); ADD_IMMED((void *)yyvsp
[-1].nArgs
);
1547 yyval
.inst
= GetPC();
1553 ADD_OP(OP_PUSH_SYM
); ADD_SYM(yyvsp
[0].sym
);
1559 ADD_OP(OP_PUSH_SYM
); ADD_SYM(yyvsp
[0].sym
);
1565 ADD_OP(OP_PUSH_SYM
); ADD_SYM(yyvsp
[0].sym
);
1571 ADD_OP(OP_SUBR_CALL
);
1572 ADD_SYM(PromoteToGlobal(yyvsp
[-3].sym
)); ADD_IMMED((void *)yyvsp
[-1].nArgs
);
1573 ADD_OP(OP_FETCH_RET_VAL
);
1579 ADD_OP(OP_PUSH_ARG
);
1585 ADD_OP(OP_PUSH_ARG_COUNT
);
1591 ADD_OP(OP_PUSH_ARG_ARRAY
);
1597 ADD_OP(OP_ARRAY_REF
); ADD_IMMED((void *)yyvsp
[-1].nArgs
);
1693 ADD_OP(OP_AND
); SET_BR_OFF(yyvsp
[-1].inst
, GetPC());
1699 ADD_OP(OP_OR
); SET_BR_OFF(yyvsp
[-1].inst
, GetPC());
1711 ADD_OP(OP_PUSH_SYM
); ADD_SYM(yyvsp
[0].sym
); ADD_OP(OP_INCR
);
1712 ADD_OP(OP_DUP
); ADD_OP(OP_ASSIGN
); ADD_SYM(yyvsp
[0].sym
);
1718 ADD_OP(OP_PUSH_SYM
); ADD_SYM(yyvsp
[-1].sym
); ADD_OP(OP_DUP
);
1719 ADD_OP(OP_INCR
); ADD_OP(OP_ASSIGN
); ADD_SYM(yyvsp
[-1].sym
);
1725 ADD_OP(OP_PUSH_SYM
); ADD_SYM(yyvsp
[0].sym
); ADD_OP(OP_DECR
);
1726 ADD_OP(OP_DUP
); ADD_OP(OP_ASSIGN
); ADD_SYM(yyvsp
[0].sym
);
1732 ADD_OP(OP_PUSH_SYM
); ADD_SYM(yyvsp
[-1].sym
); ADD_OP(OP_DUP
);
1733 ADD_OP(OP_DECR
); ADD_OP(OP_ASSIGN
); ADD_SYM(yyvsp
[-1].sym
);
1739 ADD_OP(OP_IN_ARRAY
);
1745 yyval
.inst
= GetPC(); StartLoopAddrList();
1751 StartLoopAddrList(); yyval
.inst
= GetPC();
1757 ADD_OP(OP_BRANCH
); yyval
.inst
= GetPC(); ADD_BR_OFF(0);
1763 ADD_OP(OP_BRANCH_NEVER
); yyval
.inst
= GetPC(); ADD_BR_OFF(0);
1769 ADD_OP(OP_BRANCH_FALSE
); yyval
.inst
= GetPC(); ADD_BR_OFF(0);
1775 ADD_OP(OP_DUP
); ADD_OP(OP_BRANCH_FALSE
); yyval
.inst
= GetPC();
1782 ADD_OP(OP_DUP
); ADD_OP(OP_BRANCH_TRUE
); yyval
.inst
= GetPC();
1786 #line 1787 "y.tab.c"
1792 if (yystate
== 0 && yym
== 0)
1796 printf("%sdebug: after reduction, shifting from state 0 to\
1797 state %d\n", YYPREFIX
, YYFINAL
);
1804 if ((yychar
= yylex()) < 0) yychar
= 0;
1809 if (yychar
<= YYMAXTOKEN
) yys
= yyname
[yychar
];
1810 if (!yys
) yys
= "illegal-symbol";
1811 printf("%sdebug: state %d, reading %d (%s)\n",
1812 YYPREFIX
, YYFINAL
, yychar
, yys
);
1816 if (yychar
== 0) goto yyaccept
;
1819 if ((yyn
= yygindex
[yym
]) && (yyn
+= yystate
) >= 0 &&
1820 yyn
<= YYTABLESIZE
&& yycheck
[yyn
] == yystate
)
1821 yystate
= yytable
[yyn
];
1823 yystate
= yydgoto
[yym
];
1826 printf("%sdebug: after reduction, shifting from state %d \
1827 to state %d\n", YYPREFIX
, *yyssp
, yystate
);
1829 if (yyssp
>= yysslim
&& yygrowstack())
1837 yyerror("yacc stack overflow");