Added missing shell/macroMenuValid initializations.
[nedit.git] / source / parse_noyacc.c
blobffc3ea5c5428cf4d9e94187ee0bc20451e17f82f
1 #ifndef lint
2 static char const
3 yyrcsid[] = "$FreeBSD: src/usr.bin/yacc/skeleton.c,v 1.28 2000/01/17 02:04:06 bde Exp $";
4 #endif
5 #include <stdlib.h>
6 #define YYBYACC 1
7 #define YYMAJOR 1
8 #define YYMINOR 9
9 #define YYLEX yylex()
10 #define YYEMPTY -1
11 #define yyclearin (yychar=(YYEMPTY))
12 #define yyerrok (yyerrflag=0)
13 #define YYRECOVERING() (yyerrflag!=0)
14 static int yygrowstack();
15 #define YYPREFIX "yy"
16 #line 3 "parse.y"
17 #ifdef HAVE_CONFIG_H
18 #include "../config.h"
19 #endif
21 #include "parse.h"
22 #include "textBuf.h"
23 #include "nedit.h"
24 #include "rbTree.h"
25 #include "interpret.h"
27 #include <stdlib.h>
28 #include <string.h>
29 #include <stdio.h>
30 #include <ctype.h>
31 #include <X11/Intrinsic.h>
32 #include <Xm/Xm.h>
33 #ifdef VMS
34 #include "../util/VMSparam.h"
35 #else
36 #ifndef __MVS__
37 #include <sys/param.h>
38 #endif
39 #endif /*VMS*/
41 #ifdef HAVE_DEBUG_H
42 #include "../debug.h"
43 #endif
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);
58 int yyparse(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);
64 static char *ErrMsg;
65 static char *InPtr;
66 extern Inst *LoopStack[]; /* addresses of break, cont stmts */
67 extern Inst **LoopStackPtr; /* to fill at the end of a loop */
69 #line 57 "parse.y"
70 typedef union {
71 Symbol *sym;
72 Inst *inst;
73 int nArgs;
74 } YYSTYPE;
75 #line 76 "y.tab.c"
76 #define YYERRCODE 256
77 #define NUMBER 257
78 #define STRING 258
79 #define SYMBOL 259
80 #define DELETE 260
81 #define ARG_LOOKUP 261
82 #define IF 262
83 #define WHILE 263
84 #define ELSE 264
85 #define FOR 265
86 #define BREAK 266
87 #define CONTINUE 267
88 #define RETURN 268
89 #define IF_NO_ELSE 269
90 #define ADDEQ 270
91 #define SUBEQ 271
92 #define MULEQ 272
93 #define DIVEQ 273
94 #define MODEQ 274
95 #define ANDEQ 275
96 #define OREQ 276
97 #define CONCAT 277
98 #define OR 278
99 #define AND 279
100 #define GT 280
101 #define GE 281
102 #define LT 282
103 #define LE 283
104 #define EQ 284
105 #define NE 285
106 #define IN 286
107 #define UNARY_MINUS 287
108 #define NOT 288
109 #define INCR 289
110 #define DECR 290
111 #define POW 291
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,
209 0, 0, 0, 0, 105, 0,
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,
584 189,
586 #define YYFINAL 2
587 #ifndef YYDEBUG
588 #define YYDEBUG 0
589 #endif
590 #define YYMAXTOKEN 291
591 #if YYDEBUG
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[] = {
606 "$accept : program",
607 "program : blank stmts",
608 "program : blank '{' blank stmts '}'",
609 "program : blank '{' blank '}'",
610 "program : error",
611 "block : '{' blank stmts '}' blank",
612 "block : '{' blank '}' blank",
613 "block : stmt",
614 "stmts : stmt",
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",
621 "$$1 :",
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",
653 "evalsym : SYMBOL",
654 "comastmts :",
655 "comastmts : simpstmt",
656 "comastmts : comastmts ',' simpstmt",
657 "arglist :",
658 "arglist : expr",
659 "arglist : arglist ',' expr",
660 "expr : numexpr",
661 "expr : expr numexpr",
662 "initarraylv : SYMBOL",
663 "initarraylv : initarraylv '[' arglist ']'",
664 "arraylv : SYMBOL",
665 "arraylv : arraylv '[' arglist ']'",
666 "arrayexpr : numexpr",
667 "numexpr : NUMBER",
668 "numexpr : STRING",
669 "numexpr : SYMBOL",
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",
699 "while : WHILE",
700 "for : FOR",
701 "else : ELSE",
702 "cond :",
703 "cond : numexpr",
704 "and : AND",
705 "or : OR",
706 "blank :",
707 "blank : blank '\\n'",
709 #endif
710 #if YYDEBUG
711 #include <stdio.h>
712 #endif
713 #ifdef YYSTACKSIZE
714 #undef YYMAXDEPTH
715 #define YYMAXDEPTH YYSTACKSIZE
716 #else
717 #ifdef YYMAXDEPTH
718 #define YYSTACKSIZE YYMAXDEPTH
719 #else
720 #define YYSTACKSIZE 10000
721 #define YYMAXDEPTH 10000
722 #endif
723 #endif
724 #define YYINITSTACKSIZE 200
725 int yydebug;
726 int yynerrs;
727 int yyerrflag;
728 int yychar;
729 short *yyssp;
730 YYSTYPE *yyvsp;
731 YYSTYPE yyval;
732 YYSTYPE yylval;
733 short *yyss;
734 short *yysslim;
735 YYSTYPE *yyvs;
736 int yystacksize;
737 #line 443 "parse.y"
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)
751 Program *prog;
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) */
758 InPtr = expr;
759 if (yyparse()) {
760 *msg = ErrMsg;
761 *stoppedAt = InPtr;
762 FreeProgram(FinishCreatingProgram());
763 return NULL;
766 /* get the newly created program */
767 prog = FinishCreatingProgram();
769 /* parse succeeded */
770 *msg = "";
771 *stoppedAt = InPtr;
772 return prog;
776 static int yylex(void)
778 int i, len;
779 Symbol *s;
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 */
786 for (;;) {
787 if (*InPtr == '\\' && *(InPtr + 1) == '\n')
788 InPtr += 2;
789 else if (*InPtr == ' ' || *InPtr == '\t')
790 InPtr++;
791 else if (*InPtr == '#')
792 while (*InPtr != '\n' && *InPtr != '\0') {
793 /* Comments stop at escaped newlines */
794 if (*InPtr == '\\' && *(InPtr + 1) == '\n') {
795 InPtr += 2;
796 break;
798 InPtr++;
799 } else
800 break;
804 /* return end of input at the end of the string */
805 if (*InPtr == '\0') {
806 return 0;
809 /* process number tokens */
810 if (isdigit((unsigned char)*InPtr)) { /* number */
811 char name[28];
812 sscanf(InPtr, "%d%n", &value.val.n, &len);
813 sprintf(name, "const %d", value.val.n);
814 InPtr += len;
815 value.tag = INT_TAG;
816 if ((yylval.sym=LookupSymbol(name)) == NULL)
817 yylval.sym = InstallSymbol(name, CONST_SYM, value);
818 return NUMBER;
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;
828 *p++ = *InPtr++;
829 while (isalnum((unsigned char)*InPtr) || *InPtr=='_') {
830 if (p >= symName + MAX_SYM_LEN)
831 InPtr++;
832 else
833 *p++ = *InPtr++;
835 *p = '\0';
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")) {
847 InPtr -= 6;
848 return 0;
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;
857 yylval.sym = s;
858 return SYMBOL;
861 /* process quoted strings w/ embedded escape sequences */
862 if (*InPtr == '\"') {
863 char string[MAX_STRING_CONST_LEN], *p = string;
864 InPtr++;
865 while (*InPtr != '\0' && *InPtr != '\"' && *InPtr != '\n') {
866 if (p >= string + MAX_STRING_CONST_LEN) {
867 InPtr++;
868 continue;
870 if (*InPtr == '\\') {
871 InPtr++;
872 if (*InPtr == '\n') {
873 InPtr++;
874 continue;
876 for (i=0; escape[i]!='\0'; i++) {
877 if (escape[i] == '\0') {
878 *p++= *InPtr++;
879 break;
880 } else if (escape[i] == *InPtr) {
881 *p++ = replace[i];
882 InPtr++;
883 break;
886 } else
887 *p++= *InPtr++;
889 *p = '\0';
890 InPtr++;
891 yylval.sym = InstallStringConstSymbol(string);
892 return STRING;
895 /* process remaining two character tokens or return single char as token */
896 switch(*InPtr++) {
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)
919 return yes;
920 InPtr--;
921 return no;
923 static int follow2(char expect1, int yes1, char expect2, int yes2, int no)
925 char next = *InPtr++;
926 if (next == expect1)
927 return yes1;
928 if (next == expect2)
929 return yes2;
930 InPtr--;
931 return no;
934 static int follow_non_whitespace(char expect, int yes, int no)
936 char *localInPtr = InPtr;
938 while (1) {
939 if (*localInPtr == ' ' || *localInPtr == '\t') {
940 ++localInPtr;
942 else if (*localInPtr == '\\' && *(localInPtr + 1) == '\n') {
943 localInPtr += 2;
945 else if (*localInPtr == expect) {
946 return(yes);
948 else {
949 return(no);
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)
965 char *c, *symPtr;
966 int hasDash = False;
967 char symbolName[MAX_SYM_LEN+1];
968 Symbol *s;
970 symPtr = symbolName;
971 for (c = *inPtr; isalnum((unsigned char)*c) || *c=='_' ||
972 ( *c=='-' && isalnum((unsigned char)(*(c+1)))); c++) {
973 if (*c == '-')
974 hasDash = True;
975 *symPtr++ = *c;
977 if (!hasDash)
978 return NULL;
979 *symPtr = '\0';
980 s = LookupSymbol(symbolName);
981 if (s != NULL)
982 *inPtr = c;
983 return s;
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
990 ** of ParseExpr)
992 static int yyerror(char *s)
994 ErrMsg = s;
995 return 0;
997 #line 998 "y.tab.c"
998 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
999 static int yygrowstack()
1001 int newsize, i;
1002 short *newss;
1003 YYSTYPE *newvs;
1005 if ((newsize = yystacksize) == 0)
1006 newsize = YYINITSTACKSIZE;
1007 else if (newsize >= YYMAXDEPTH)
1008 return -1;
1009 else if ((newsize *= 2) > YYMAXDEPTH)
1010 newsize = YYMAXDEPTH;
1011 i = yyssp - yyss;
1012 newss = yyss ? (short *)realloc(yyss, newsize * sizeof *newss) :
1013 (short *)malloc(newsize * sizeof *newss);
1014 if (newss == NULL)
1015 return -1;
1016 yyss = newss;
1017 yyssp = newss + i;
1018 newvs = yyvs ? (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs) :
1019 (YYSTYPE *)malloc(newsize * sizeof *newvs);
1020 if (newvs == NULL)
1021 return -1;
1022 yyvs = newvs;
1023 yyvsp = newvs + i;
1024 yystacksize = newsize;
1025 yysslim = yyss + newsize - 1;
1026 return 0;
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 *
1045 #endif
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)
1057 YYPARSE_PARAM_DECL
1059 register int yym, yyn, yystate;
1060 #if YYDEBUG
1061 register const char *yys;
1063 if ((yys = getenv("YYDEBUG")))
1065 yyn = *yys;
1066 if (yyn >= '0' && yyn <= '9')
1067 yydebug = yyn - '0';
1069 #endif
1071 yynerrs = 0;
1072 yyerrflag = 0;
1073 yychar = (-1);
1075 if (yyss == NULL && yygrowstack()) goto yyoverflow;
1076 yyssp = yyss;
1077 yyvsp = yyvs;
1078 *yyssp = yystate = 0;
1080 yyloop:
1081 if ((yyn = yydefred[yystate])) goto yyreduce;
1082 if (yychar < 0)
1084 if ((yychar = yylex()) < 0) yychar = 0;
1085 #if YYDEBUG
1086 if (yydebug)
1088 yys = 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);
1094 #endif
1096 if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
1097 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
1099 #if YYDEBUG
1100 if (yydebug)
1101 printf("%sdebug: state %d, shifting to state %d\n",
1102 YYPREFIX, yystate, yytable[yyn]);
1103 #endif
1104 if (yyssp >= yysslim && yygrowstack())
1106 goto yyoverflow;
1108 *++yyssp = yystate = yytable[yyn];
1109 *++yyvsp = yylval;
1110 yychar = (-1);
1111 if (yyerrflag > 0) --yyerrflag;
1112 goto yyloop;
1114 if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
1115 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
1117 yyn = yytable[yyn];
1118 goto yyreduce;
1120 if (yyerrflag) goto yyinrecovery;
1121 #if defined(lint) || defined(__GNUC__)
1122 goto yynewerror;
1123 #endif
1124 yynewerror:
1125 yyerror("syntax error");
1126 #if defined(lint) || defined(__GNUC__)
1127 goto yyerrlab;
1128 #endif
1129 yyerrlab:
1130 ++yynerrs;
1131 yyinrecovery:
1132 if (yyerrflag < 3)
1134 yyerrflag = 3;
1135 for (;;)
1137 if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
1138 yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
1140 #if YYDEBUG
1141 if (yydebug)
1142 printf("%sdebug: state %d, error recovery shifting\
1143 to state %d\n", YYPREFIX, *yyssp, yytable[yyn]);
1144 #endif
1145 if (yyssp >= yysslim && yygrowstack())
1147 goto yyoverflow;
1149 *++yyssp = yystate = yytable[yyn];
1150 *++yyvsp = yylval;
1151 goto yyloop;
1153 else
1155 #if YYDEBUG
1156 if (yydebug)
1157 printf("%sdebug: error recovery discarding state %d\n",
1158 YYPREFIX, *yyssp);
1159 #endif
1160 if (yyssp <= yyss) goto yyabort;
1161 --yyssp;
1162 --yyvsp;
1166 else
1168 if (yychar == 0) goto yyabort;
1169 #if YYDEBUG
1170 if (yydebug)
1172 yys = 0;
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);
1178 #endif
1179 yychar = (-1);
1180 goto yyloop;
1182 yyreduce:
1183 #if YYDEBUG
1184 if (yydebug)
1185 printf("%sdebug: state %d, reducing by rule %d (%s)\n",
1186 YYPREFIX, yystate, yyn, yyrule[yyn]);
1187 #endif
1188 yym = yylen[yyn];
1189 yyval = yyvsp[1-yym];
1190 switch (yyn)
1192 case 1:
1193 #line 91 "parse.y"
1195 ADD_OP(OP_RETURN_NO_VAL); return 0;
1197 break;
1198 case 2:
1199 #line 94 "parse.y"
1201 ADD_OP(OP_RETURN_NO_VAL); return 0;
1203 break;
1204 case 3:
1205 #line 97 "parse.y"
1207 ADD_OP(OP_RETURN_NO_VAL); return 0;
1209 break;
1210 case 4:
1211 #line 100 "parse.y"
1213 return 1;
1215 break;
1216 case 11:
1217 #line 112 "parse.y"
1219 SET_BR_OFF(yyvsp[-3].inst, GetPC());
1221 break;
1222 case 12:
1223 #line 115 "parse.y"
1225 SET_BR_OFF(yyvsp[-6].inst, (yyvsp[-2].inst+1)); SET_BR_OFF(yyvsp[-2].inst, GetPC());
1227 break;
1228 case 13:
1229 #line 118 "parse.y"
1231 ADD_OP(OP_BRANCH); ADD_BR_OFF(yyvsp[-5].inst);
1232 SET_BR_OFF(yyvsp[-3].inst, GetPC()); FillLoopAddrs(GetPC(), yyvsp[-5].inst);
1234 break;
1235 case 14:
1236 #line 122 "parse.y"
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());
1242 break;
1243 case 15:
1244 #line 127 "parse.y"
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);
1250 break;
1251 case 16:
1252 #line 132 "parse.y"
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);
1258 break;
1259 case 17:
1260 #line 137 "parse.y"
1262 ADD_OP(OP_BRANCH); ADD_BR_OFF(0);
1263 if (AddBreakAddr(GetPC()-1)) {
1264 yyerror("break outside loop"); YYERROR;
1267 break;
1268 case 18:
1269 #line 143 "parse.y"
1271 ADD_OP(OP_BRANCH); ADD_BR_OFF(0);
1272 if (AddContinueAddr(GetPC()-1)) {
1273 yyerror("continue outside loop"); YYERROR;
1276 break;
1277 case 19:
1278 #line 149 "parse.y"
1280 ADD_OP(OP_RETURN);
1282 break;
1283 case 20:
1284 #line 152 "parse.y"
1286 ADD_OP(OP_RETURN_NO_VAL);
1288 break;
1289 case 21:
1290 #line 156 "parse.y"
1292 ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-2].sym);
1294 break;
1295 case 22:
1296 #line 159 "parse.y"
1298 ADD_OP(OP_ADD); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-2].sym);
1300 break;
1301 case 23:
1302 #line 162 "parse.y"
1304 ADD_OP(OP_SUB); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-2].sym);
1306 break;
1307 case 24:
1308 #line 165 "parse.y"
1310 ADD_OP(OP_MUL); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-2].sym);
1312 break;
1313 case 25:
1314 #line 168 "parse.y"
1316 ADD_OP(OP_DIV); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-2].sym);
1318 break;
1319 case 26:
1320 #line 171 "parse.y"
1322 ADD_OP(OP_MOD); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-2].sym);
1324 break;
1325 case 27:
1326 #line 174 "parse.y"
1328 ADD_OP(OP_BIT_AND); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-2].sym);
1330 break;
1331 case 28:
1332 #line 177 "parse.y"
1334 ADD_OP(OP_BIT_OR); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-2].sym);
1336 break;
1337 case 29:
1338 #line 180 "parse.y"
1340 ADD_OP(OP_ARRAY_DELETE); ADD_IMMED((void *)yyvsp[-1].nArgs);
1342 break;
1343 case 30:
1344 #line 183 "parse.y"
1346 ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED((void *)yyvsp[-3].nArgs);
1348 break;
1349 case 31:
1350 #line 186 "parse.y"
1352 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED((void *)1); ADD_IMMED((void *)yyvsp[-3].nArgs);
1353 ADD_OP(OP_ADD);
1354 ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED((void *)yyvsp[-3].nArgs);
1356 break;
1357 case 32:
1358 #line 191 "parse.y"
1360 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED((void *)1); ADD_IMMED((void *)yyvsp[-3].nArgs);
1361 ADD_OP(OP_SUB);
1362 ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED((void *)yyvsp[-3].nArgs);
1364 break;
1365 case 33:
1366 #line 196 "parse.y"
1368 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED((void *)1); ADD_IMMED((void *)yyvsp[-3].nArgs);
1369 ADD_OP(OP_MUL);
1370 ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED((void *)yyvsp[-3].nArgs);
1372 break;
1373 case 34:
1374 #line 201 "parse.y"
1376 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED((void *)1); ADD_IMMED((void *)yyvsp[-3].nArgs);
1377 ADD_OP(OP_DIV);
1378 ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED((void *)yyvsp[-3].nArgs);
1380 break;
1381 case 35:
1382 #line 206 "parse.y"
1384 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED((void *)1); ADD_IMMED((void *)yyvsp[-3].nArgs);
1385 ADD_OP(OP_MOD);
1386 ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED((void *)yyvsp[-3].nArgs);
1388 break;
1389 case 36:
1390 #line 211 "parse.y"
1392 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED((void *)1); ADD_IMMED((void *)yyvsp[-3].nArgs);
1393 ADD_OP(OP_BIT_AND);
1394 ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED((void *)yyvsp[-3].nArgs);
1396 break;
1397 case 37:
1398 #line 216 "parse.y"
1400 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED((void *)1); ADD_IMMED((void *)yyvsp[-3].nArgs);
1401 ADD_OP(OP_BIT_OR);
1402 ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED((void *)yyvsp[-3].nArgs);
1404 break;
1405 case 38:
1406 #line 221 "parse.y"
1408 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED((void *)0); ADD_IMMED((void *)yyvsp[-2].nArgs);
1409 ADD_OP(OP_INCR);
1410 ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED((void *)yyvsp[-2].nArgs);
1412 break;
1413 case 39:
1414 #line 226 "parse.y"
1416 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED((void *)0); ADD_IMMED((void *)yyvsp[-2].nArgs);
1417 ADD_OP(OP_DECR);
1418 ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED((void *)yyvsp[-2].nArgs);
1420 break;
1421 case 40:
1422 #line 231 "parse.y"
1424 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED((void *)0); ADD_IMMED((void *)yyvsp[-1].nArgs);
1425 ADD_OP(OP_INCR);
1426 ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED((void *)yyvsp[-1].nArgs);
1428 break;
1429 case 41:
1430 #line 236 "parse.y"
1432 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED((void *)0); ADD_IMMED((void *)yyvsp[-1].nArgs);
1433 ADD_OP(OP_DECR);
1434 ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED((void *)yyvsp[-1].nArgs);
1436 break;
1437 case 42:
1438 #line 241 "parse.y"
1440 ADD_OP(OP_SUBR_CALL);
1441 ADD_SYM(PromoteToGlobal(yyvsp[-3].sym)); ADD_IMMED((void *)yyvsp[-1].nArgs);
1443 break;
1444 case 43:
1445 #line 245 "parse.y"
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);
1450 break;
1451 case 44:
1452 #line 249 "parse.y"
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);
1457 break;
1458 case 45:
1459 #line 253 "parse.y"
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);
1464 break;
1465 case 46:
1466 #line 257 "parse.y"
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);
1471 break;
1472 case 47:
1473 #line 262 "parse.y"
1475 yyval.sym = yyvsp[0].sym; ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[0].sym);
1477 break;
1478 case 48:
1479 #line 266 "parse.y"
1481 yyval.inst = GetPC();
1483 break;
1484 case 49:
1485 #line 269 "parse.y"
1487 yyval.inst = GetPC();
1489 break;
1490 case 50:
1491 #line 272 "parse.y"
1493 yyval.inst = GetPC();
1495 break;
1496 case 51:
1497 #line 276 "parse.y"
1499 yyval.nArgs = 0;
1501 break;
1502 case 52:
1503 #line 279 "parse.y"
1505 yyval.nArgs = 1;
1507 break;
1508 case 53:
1509 #line 282 "parse.y"
1511 yyval.nArgs = yyvsp[-2].nArgs + 1;
1513 break;
1514 case 55:
1515 #line 287 "parse.y"
1517 ADD_OP(OP_CONCAT);
1519 break;
1520 case 56:
1521 #line 291 "parse.y"
1523 ADD_OP(OP_PUSH_ARRAY_SYM); ADD_SYM(yyvsp[0].sym); ADD_IMMED((void *)1);
1525 break;
1526 case 57:
1527 #line 294 "parse.y"
1529 ADD_OP(OP_ARRAY_REF); ADD_IMMED((void *)yyvsp[-1].nArgs);
1531 break;
1532 case 58:
1533 #line 298 "parse.y"
1535 ADD_OP(OP_PUSH_ARRAY_SYM); ADD_SYM(yyvsp[0].sym); ADD_IMMED((void *)0);
1537 break;
1538 case 59:
1539 #line 301 "parse.y"
1541 ADD_OP(OP_ARRAY_REF); ADD_IMMED((void *)yyvsp[-1].nArgs);
1543 break;
1544 case 60:
1545 #line 305 "parse.y"
1547 yyval.inst = GetPC();
1549 break;
1550 case 61:
1551 #line 309 "parse.y"
1553 ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[0].sym);
1555 break;
1556 case 62:
1557 #line 312 "parse.y"
1559 ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[0].sym);
1561 break;
1562 case 63:
1563 #line 315 "parse.y"
1565 ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[0].sym);
1567 break;
1568 case 64:
1569 #line 318 "parse.y"
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);
1575 break;
1576 case 66:
1577 #line 324 "parse.y"
1579 ADD_OP(OP_PUSH_ARG);
1581 break;
1582 case 67:
1583 #line 327 "parse.y"
1585 ADD_OP(OP_PUSH_ARG_COUNT);
1587 break;
1588 case 68:
1589 #line 330 "parse.y"
1591 ADD_OP(OP_PUSH_ARG_ARRAY);
1593 break;
1594 case 69:
1595 #line 333 "parse.y"
1597 ADD_OP(OP_ARRAY_REF); ADD_IMMED((void *)yyvsp[-1].nArgs);
1599 break;
1600 case 70:
1601 #line 336 "parse.y"
1603 ADD_OP(OP_ADD);
1605 break;
1606 case 71:
1607 #line 339 "parse.y"
1609 ADD_OP(OP_SUB);
1611 break;
1612 case 72:
1613 #line 342 "parse.y"
1615 ADD_OP(OP_MUL);
1617 break;
1618 case 73:
1619 #line 345 "parse.y"
1621 ADD_OP(OP_DIV);
1623 break;
1624 case 74:
1625 #line 348 "parse.y"
1627 ADD_OP(OP_MOD);
1629 break;
1630 case 75:
1631 #line 351 "parse.y"
1633 ADD_OP(OP_POWER);
1635 break;
1636 case 76:
1637 #line 354 "parse.y"
1639 ADD_OP(OP_NEGATE);
1641 break;
1642 case 77:
1643 #line 357 "parse.y"
1645 ADD_OP(OP_GT);
1647 break;
1648 case 78:
1649 #line 360 "parse.y"
1651 ADD_OP(OP_GE);
1653 break;
1654 case 79:
1655 #line 363 "parse.y"
1657 ADD_OP(OP_LT);
1659 break;
1660 case 80:
1661 #line 366 "parse.y"
1663 ADD_OP(OP_LE);
1665 break;
1666 case 81:
1667 #line 369 "parse.y"
1669 ADD_OP(OP_EQ);
1671 break;
1672 case 82:
1673 #line 372 "parse.y"
1675 ADD_OP(OP_NE);
1677 break;
1678 case 83:
1679 #line 375 "parse.y"
1681 ADD_OP(OP_BIT_AND);
1683 break;
1684 case 84:
1685 #line 378 "parse.y"
1687 ADD_OP(OP_BIT_OR);
1689 break;
1690 case 85:
1691 #line 381 "parse.y"
1693 ADD_OP(OP_AND); SET_BR_OFF(yyvsp[-1].inst, GetPC());
1695 break;
1696 case 86:
1697 #line 384 "parse.y"
1699 ADD_OP(OP_OR); SET_BR_OFF(yyvsp[-1].inst, GetPC());
1701 break;
1702 case 87:
1703 #line 387 "parse.y"
1705 ADD_OP(OP_NOT);
1707 break;
1708 case 88:
1709 #line 390 "parse.y"
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);
1714 break;
1715 case 89:
1716 #line 394 "parse.y"
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);
1721 break;
1722 case 90:
1723 #line 398 "parse.y"
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);
1728 break;
1729 case 91:
1730 #line 402 "parse.y"
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);
1735 break;
1736 case 92:
1737 #line 406 "parse.y"
1739 ADD_OP(OP_IN_ARRAY);
1741 break;
1742 case 93:
1743 #line 410 "parse.y"
1745 yyval.inst = GetPC(); StartLoopAddrList();
1747 break;
1748 case 94:
1749 #line 414 "parse.y"
1751 StartLoopAddrList(); yyval.inst = GetPC();
1753 break;
1754 case 95:
1755 #line 418 "parse.y"
1757 ADD_OP(OP_BRANCH); yyval.inst = GetPC(); ADD_BR_OFF(0);
1759 break;
1760 case 96:
1761 #line 422 "parse.y"
1763 ADD_OP(OP_BRANCH_NEVER); yyval.inst = GetPC(); ADD_BR_OFF(0);
1765 break;
1766 case 97:
1767 #line 425 "parse.y"
1769 ADD_OP(OP_BRANCH_FALSE); yyval.inst = GetPC(); ADD_BR_OFF(0);
1771 break;
1772 case 98:
1773 #line 429 "parse.y"
1775 ADD_OP(OP_DUP); ADD_OP(OP_BRANCH_FALSE); yyval.inst = GetPC();
1776 ADD_BR_OFF(0);
1778 break;
1779 case 99:
1780 #line 434 "parse.y"
1782 ADD_OP(OP_DUP); ADD_OP(OP_BRANCH_TRUE); yyval.inst = GetPC();
1783 ADD_BR_OFF(0);
1785 break;
1786 #line 1787 "y.tab.c"
1788 yyssp -= yym;
1789 yystate = *yyssp;
1790 yyvsp -= yym;
1791 yym = yylhs[yyn];
1792 if (yystate == 0 && yym == 0)
1794 #if YYDEBUG
1795 if (yydebug)
1796 printf("%sdebug: after reduction, shifting from state 0 to\
1797 state %d\n", YYPREFIX, YYFINAL);
1798 #endif
1799 yystate = YYFINAL;
1800 *++yyssp = YYFINAL;
1801 *++yyvsp = yyval;
1802 if (yychar < 0)
1804 if ((yychar = yylex()) < 0) yychar = 0;
1805 #if YYDEBUG
1806 if (yydebug)
1808 yys = 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);
1814 #endif
1816 if (yychar == 0) goto yyaccept;
1817 goto yyloop;
1819 if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
1820 yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
1821 yystate = yytable[yyn];
1822 else
1823 yystate = yydgoto[yym];
1824 #if YYDEBUG
1825 if (yydebug)
1826 printf("%sdebug: after reduction, shifting from state %d \
1827 to state %d\n", YYPREFIX, *yyssp, yystate);
1828 #endif
1829 if (yyssp >= yysslim && yygrowstack())
1831 goto yyoverflow;
1833 *++yyssp = yystate;
1834 *++yyvsp = yyval;
1835 goto yyloop;
1836 yyoverflow:
1837 yyerror("yacc stack overflow");
1838 yyabort:
1839 return (1);
1840 yyaccept:
1841 return (0);