Fix our use of $em_tab_dist after it was changed to 0 for 'turned of'.
[nedit.git] / source / parse_noyacc.c
bloba9b3dfd8d4c1b91eabea8d40cfa9b92353c565b2
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) ((from)->value) = ((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.10 2007/01/12 16:19:35 tringali 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[] = "\\\"ntbrfave";
782 #ifdef EBCDIC_CHARSET
783 static char replace[] = "\\\"\n\t\b\r\f\a\v\x27"; /* EBCDIC escape */
784 #else
785 static char replace[] = "\\\"\n\t\b\r\f\a\v\x1B"; /* ASCII escape */
786 #endif
788 /* skip whitespace, backslash-newline combinations, and comments, which are
789 all considered whitespace */
790 for (;;) {
791 if (*InPtr == '\\' && *(InPtr + 1) == '\n')
792 InPtr += 2;
793 else if (*InPtr == ' ' || *InPtr == '\t')
794 InPtr++;
795 else if (*InPtr == '#')
796 while (*InPtr != '\n' && *InPtr != '\0') {
797 /* Comments stop at escaped newlines */
798 if (*InPtr == '\\' && *(InPtr + 1) == '\n') {
799 InPtr += 2;
800 break;
802 InPtr++;
803 } else
804 break;
808 /* return end of input at the end of the string */
809 if (*InPtr == '\0') {
810 return 0;
813 /* process number tokens */
814 if (isdigit((unsigned char)*InPtr)) { /* number */
815 char name[28];
816 sscanf(InPtr, "%d%n", &value.val.n, &len);
817 sprintf(name, "const %d", value.val.n);
818 InPtr += len;
819 value.tag = INT_TAG;
820 if ((yylval.sym=LookupSymbol(name)) == NULL)
821 yylval.sym = InstallSymbol(name, CONST_SYM, value);
822 return NUMBER;
825 /* process symbol tokens. "define" is a special case not handled
826 by this parser, considered end of input. Another special case
827 is action routine names which are allowed to contain '-' despite
828 the ambiguity, handled in matchesActionRoutine. */
829 if (isalpha((unsigned char)*InPtr) || *InPtr == '$') {
830 if ((s=matchesActionRoutine(&InPtr)) == NULL) {
831 char symName[MAX_SYM_LEN+1], *p = symName;
832 *p++ = *InPtr++;
833 while (isalnum((unsigned char)*InPtr) || *InPtr=='_') {
834 if (p >= symName + MAX_SYM_LEN)
835 InPtr++;
836 else
837 *p++ = *InPtr++;
839 *p = '\0';
840 if (!strcmp(symName, "while")) return WHILE;
841 if (!strcmp(symName, "if")) return IF;
842 if (!strcmp(symName, "else")) return ELSE;
843 if (!strcmp(symName, "for")) return FOR;
844 if (!strcmp(symName, "break")) return BREAK;
845 if (!strcmp(symName, "continue")) return CONTINUE;
846 if (!strcmp(symName, "return")) return RETURN;
847 if (!strcmp(symName, "in")) return IN;
848 if (!strcmp(symName, "$args")) return ARG_LOOKUP;
849 if (!strcmp(symName, "delete") && follow_non_whitespace('(', SYMBOL, DELETE) == DELETE) return DELETE;
850 if (!strcmp(symName, "define")) {
851 InPtr -= 6;
852 return 0;
854 if ((s=LookupSymbol(symName)) == NULL) {
855 s = InstallSymbol(symName, symName[0]=='$' ?
856 (((symName[1] > '0' && symName[1] <= '9') && symName[2] == 0) ?
857 ARG_SYM : GLOBAL_SYM) : LOCAL_SYM, value);
858 s->value.tag = NO_TAG;
861 yylval.sym = s;
862 return SYMBOL;
865 /* Process quoted strings with embedded escape sequences:
866 For backslashes we recognise hexadecimal values with initial 'x' such
867 as "\x1B"; octal value (upto 3 oct digits with a possible leading zero)
868 such as "\33", "\033" or "\0033", and the C escapes: \", \', \n, \t, \b,
869 \r, \f, \a, \v, and the added \e for the escape character, as for REs.
870 Disallow hex/octal zero values (NUL): instead ignore the introductory
871 backslash, eg "\x0xyz" becomes "x0xyz" and "\0000hello" becomes
872 "0000hello". */
874 if (*InPtr == '\"') {
875 char string[MAX_STRING_CONST_LEN], *p = string;
876 char *backslash;
877 InPtr++;
878 while (*InPtr != '\0' && *InPtr != '\"' && *InPtr != '\n') {
879 if (p >= string + MAX_STRING_CONST_LEN) {
880 InPtr++;
881 continue;
883 if (*InPtr == '\\') {
884 backslash = InPtr;
885 InPtr++;
886 if (*InPtr == '\n') {
887 InPtr++;
888 continue;
890 if (*InPtr == 'x') {
891 /* a hex introducer */
892 int hexValue = 0;
893 const char *hexDigits = "0123456789abcdef";
894 const char *hexD;
895 InPtr++;
896 if (*InPtr == '\0' ||
897 (hexD = strchr(hexDigits, tolower(*InPtr))) == NULL) {
898 *p++ = 'x';
900 else {
901 hexValue = hexD - hexDigits;
902 InPtr++;
903 /* now do we have another digit? only accept one more */
904 if (*InPtr != '\0' &&
905 (hexD = strchr(hexDigits,tolower(*InPtr))) != NULL){
906 hexValue = hexD - hexDigits + (hexValue << 4);
907 InPtr++;
909 if (hexValue != 0) {
910 *p++ = (char)hexValue;
912 else {
913 InPtr = backslash + 1; /* just skip the backslash */
916 continue;
918 /* the RE documentation requires \0 as the octal introducer;
919 here you can start with any octal digit, but you are only
920 allowed up to three (or four if the first is '0'). */
921 if ('0' <= *InPtr && *InPtr <= '7') {
922 if (*InPtr == '0') {
923 InPtr++; /* octal introducer: don't count this digit */
925 if ('0' <= *InPtr && *InPtr <= '7') {
926 /* treat as octal - first digit */
927 char octD = *InPtr++;
928 int octValue = octD - '0';
929 if ('0' <= *InPtr && *InPtr <= '7') {
930 /* second digit */
931 octD = *InPtr++;
932 octValue = (octValue << 3) + octD - '0';
933 /* now do we have another digit? can we add it?
934 if value is going to be too big for char (greater
935 than 0377), stop converting now before adding the
936 third digit */
937 if ('0' <= *InPtr && *InPtr <= '7' &&
938 octValue <= 037) {
939 /* third digit is acceptable */
940 octD = *InPtr++;
941 octValue = (octValue << 3) + octD - '0';
944 if (octValue != 0) {
945 *p++ = (char)octValue;
947 else {
948 InPtr = backslash + 1; /* just skip the backslash */
951 else { /* \0 followed by non-digits: go back to 0 */
952 InPtr = backslash + 1; /* just skip the backslash */
954 continue;
956 for (i=0; escape[i]!='\0'; i++) {
957 if (escape[i] == *InPtr) {
958 *p++ = replace[i];
959 InPtr++;
960 break;
963 /* if we get here, we didn't recognise the character after
964 the backslash: just copy it next time round the loop */
966 else {
967 *p++= *InPtr++;
970 *p = '\0';
971 InPtr++;
972 yylval.sym = InstallStringConstSymbol(string);
973 return STRING;
976 /* process remaining two character tokens or return single char as token */
977 switch(*InPtr++) {
978 case '>': return follow('=', GE, GT);
979 case '<': return follow('=', LE, LT);
980 case '=': return follow('=', EQ, '=');
981 case '!': return follow('=', NE, NOT);
982 case '+': return follow2('+', INCR, '=', ADDEQ, '+');
983 case '-': return follow2('-', DECR, '=', SUBEQ, '-');
984 case '|': return follow2('|', OR, '=', OREQ, '|');
985 case '&': return follow2('&', AND, '=', ANDEQ, '&');
986 case '*': return follow2('*', POW, '=', MULEQ, '*');
987 case '/': return follow('=', DIVEQ, '/');
988 case '%': return follow('=', MODEQ, '%');
989 case '^': return POW;
990 default: return *(InPtr-1);
995 ** look ahead for >=, etc.
997 static int follow(char expect, int yes, int no)
999 if (*InPtr++ == expect)
1000 return yes;
1001 InPtr--;
1002 return no;
1004 static int follow2(char expect1, int yes1, char expect2, int yes2, int no)
1006 char next = *InPtr++;
1007 if (next == expect1)
1008 return yes1;
1009 if (next == expect2)
1010 return yes2;
1011 InPtr--;
1012 return no;
1015 static int follow_non_whitespace(char expect, int yes, int no)
1017 char *localInPtr = InPtr;
1019 while (1) {
1020 if (*localInPtr == ' ' || *localInPtr == '\t') {
1021 ++localInPtr;
1023 else if (*localInPtr == '\\' && *(localInPtr + 1) == '\n') {
1024 localInPtr += 2;
1026 else if (*localInPtr == expect) {
1027 return(yes);
1029 else {
1030 return(no);
1036 ** Look (way) ahead for hyphenated routine names which begin at inPtr. A
1037 ** hyphenated name is allowed if it is pre-defined in the global symbol
1038 ** table. If a matching name exists, returns the symbol, and update "inPtr".
1040 ** I know this is horrible language design, but existing nedit action routine
1041 ** names contain hyphens. Handling them here in the lexical analysis process
1042 ** is much easier than trying to deal with it in the parser itself. (sorry)
1044 static Symbol *matchesActionRoutine(char **inPtr)
1046 char *c, *symPtr;
1047 int hasDash = False;
1048 char symbolName[MAX_SYM_LEN+1];
1049 Symbol *s;
1051 symPtr = symbolName;
1052 for (c = *inPtr; isalnum((unsigned char)*c) || *c=='_' ||
1053 ( *c=='-' && isalnum((unsigned char)(*(c+1)))); c++) {
1054 if (*c == '-')
1055 hasDash = True;
1056 *symPtr++ = *c;
1058 if (!hasDash)
1059 return NULL;
1060 *symPtr = '\0';
1061 s = LookupSymbol(symbolName);
1062 if (s != NULL)
1063 *inPtr = c;
1064 return s;
1068 ** Called by yacc to report errors (just stores for returning when
1069 ** parsing is aborted. The error token action is to immediate abort
1070 ** parsing, so this message is immediately reported to the caller
1071 ** of ParseExpr)
1073 static int yyerror(char *s)
1075 ErrMsg = s;
1076 return 0;
1078 #line 1079 "y.tab.c"
1079 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
1080 static int yygrowstack()
1082 int newsize, i;
1083 short *newss;
1084 YYSTYPE *newvs;
1086 if ((newsize = yystacksize) == 0)
1087 newsize = YYINITSTACKSIZE;
1088 else if (newsize >= YYMAXDEPTH)
1089 return -1;
1090 else if ((newsize *= 2) > YYMAXDEPTH)
1091 newsize = YYMAXDEPTH;
1092 i = yyssp - yyss;
1093 newss = yyss ? (short *)realloc(yyss, newsize * sizeof *newss) :
1094 (short *)malloc(newsize * sizeof *newss);
1095 if (newss == NULL)
1096 return -1;
1097 yyss = newss;
1098 yyssp = newss + i;
1099 newvs = yyvs ? (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs) :
1100 (YYSTYPE *)malloc(newsize * sizeof *newvs);
1101 if (newvs == NULL)
1102 return -1;
1103 yyvs = newvs;
1104 yyvsp = newvs + i;
1105 yystacksize = newsize;
1106 yysslim = yyss + newsize - 1;
1107 return 0;
1110 #define YYABORT goto yyabort
1111 #define YYREJECT goto yyabort
1112 #define YYACCEPT goto yyaccept
1113 #define YYERROR goto yyerrlab
1115 #ifndef YYPARSE_PARAM
1116 #if defined(__cplusplus) || __STDC__
1117 #define YYPARSE_PARAM_ARG void
1118 #define YYPARSE_PARAM_DECL
1119 #else /* ! ANSI-C/C++ */
1120 #define YYPARSE_PARAM_ARG
1121 #define YYPARSE_PARAM_DECL
1122 #endif /* ANSI-C/C++ */
1123 #else /* YYPARSE_PARAM */
1124 #ifndef YYPARSE_PARAM_TYPE
1125 #define YYPARSE_PARAM_TYPE void *
1126 #endif
1127 #if defined(__cplusplus) || __STDC__
1128 #define YYPARSE_PARAM_ARG YYPARSE_PARAM_TYPE YYPARSE_PARAM
1129 #define YYPARSE_PARAM_DECL
1130 #else /* ! ANSI-C/C++ */
1131 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
1132 #define YYPARSE_PARAM_DECL YYPARSE_PARAM_TYPE YYPARSE_PARAM;
1133 #endif /* ANSI-C/C++ */
1134 #endif /* ! YYPARSE_PARAM */
1137 yyparse (YYPARSE_PARAM_ARG)
1138 YYPARSE_PARAM_DECL
1140 register int yym, yyn, yystate;
1141 #if YYDEBUG
1142 register const char *yys;
1144 if ((yys = getenv("YYDEBUG")))
1146 yyn = *yys;
1147 if (yyn >= '0' && yyn <= '9')
1148 yydebug = yyn - '0';
1150 #endif
1152 yynerrs = 0;
1153 yyerrflag = 0;
1154 yychar = (-1);
1156 if (yyss == NULL && yygrowstack()) goto yyoverflow;
1157 yyssp = yyss;
1158 yyvsp = yyvs;
1159 *yyssp = yystate = 0;
1161 yyloop:
1162 if ((yyn = yydefred[yystate])) goto yyreduce;
1163 if (yychar < 0)
1165 if ((yychar = yylex()) < 0) yychar = 0;
1166 #if YYDEBUG
1167 if (yydebug)
1169 yys = 0;
1170 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
1171 if (!yys) yys = "illegal-symbol";
1172 printf("%sdebug: state %d, reading %d (%s)\n",
1173 YYPREFIX, yystate, yychar, yys);
1175 #endif
1177 if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
1178 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
1180 #if YYDEBUG
1181 if (yydebug)
1182 printf("%sdebug: state %d, shifting to state %d\n",
1183 YYPREFIX, yystate, yytable[yyn]);
1184 #endif
1185 if (yyssp >= yysslim && yygrowstack())
1187 goto yyoverflow;
1189 *++yyssp = yystate = yytable[yyn];
1190 *++yyvsp = yylval;
1191 yychar = (-1);
1192 if (yyerrflag > 0) --yyerrflag;
1193 goto yyloop;
1195 if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
1196 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
1198 yyn = yytable[yyn];
1199 goto yyreduce;
1201 if (yyerrflag) goto yyinrecovery;
1202 #if defined(lint) || defined(__GNUC__)
1203 goto yynewerror;
1204 #endif
1205 yynewerror:
1206 yyerror("syntax error");
1207 #if defined(lint) || defined(__GNUC__)
1208 goto yyerrlab;
1209 #endif
1210 yyerrlab:
1211 ++yynerrs;
1212 yyinrecovery:
1213 if (yyerrflag < 3)
1215 yyerrflag = 3;
1216 for (;;)
1218 if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
1219 yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
1221 #if YYDEBUG
1222 if (yydebug)
1223 printf("%sdebug: state %d, error recovery shifting\
1224 to state %d\n", YYPREFIX, *yyssp, yytable[yyn]);
1225 #endif
1226 if (yyssp >= yysslim && yygrowstack())
1228 goto yyoverflow;
1230 *++yyssp = yystate = yytable[yyn];
1231 *++yyvsp = yylval;
1232 goto yyloop;
1234 else
1236 #if YYDEBUG
1237 if (yydebug)
1238 printf("%sdebug: error recovery discarding state %d\n",
1239 YYPREFIX, *yyssp);
1240 #endif
1241 if (yyssp <= yyss) goto yyabort;
1242 --yyssp;
1243 --yyvsp;
1247 else
1249 if (yychar == 0) goto yyabort;
1250 #if YYDEBUG
1251 if (yydebug)
1253 yys = 0;
1254 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
1255 if (!yys) yys = "illegal-symbol";
1256 printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
1257 YYPREFIX, yystate, yychar, yys);
1259 #endif
1260 yychar = (-1);
1261 goto yyloop;
1263 yyreduce:
1264 #if YYDEBUG
1265 if (yydebug)
1266 printf("%sdebug: state %d, reducing by rule %d (%s)\n",
1267 YYPREFIX, yystate, yyn, yyrule[yyn]);
1268 #endif
1269 yym = yylen[yyn];
1270 yyval = yyvsp[1-yym];
1271 switch (yyn)
1273 case 1:
1274 #line 91 "parse.y"
1276 ADD_OP(OP_RETURN_NO_VAL); return 0;
1278 break;
1279 case 2:
1280 #line 94 "parse.y"
1282 ADD_OP(OP_RETURN_NO_VAL); return 0;
1284 break;
1285 case 3:
1286 #line 97 "parse.y"
1288 ADD_OP(OP_RETURN_NO_VAL); return 0;
1290 break;
1291 case 4:
1292 #line 100 "parse.y"
1294 return 1;
1296 break;
1297 case 11:
1298 #line 112 "parse.y"
1300 SET_BR_OFF(yyvsp[-3].inst, GetPC());
1302 break;
1303 case 12:
1304 #line 115 "parse.y"
1306 SET_BR_OFF(yyvsp[-6].inst, (yyvsp[-2].inst+1)); SET_BR_OFF(yyvsp[-2].inst, GetPC());
1308 break;
1309 case 13:
1310 #line 118 "parse.y"
1312 ADD_OP(OP_BRANCH); ADD_BR_OFF(yyvsp[-5].inst);
1313 SET_BR_OFF(yyvsp[-3].inst, GetPC()); FillLoopAddrs(GetPC(), yyvsp[-5].inst);
1315 break;
1316 case 14:
1317 #line 122 "parse.y"
1319 FillLoopAddrs(GetPC()+2+(yyvsp[-3].inst-(yyvsp[-5].inst+1)), GetPC());
1320 SwapCode(yyvsp[-5].inst+1, yyvsp[-3].inst, GetPC());
1321 ADD_OP(OP_BRANCH); ADD_BR_OFF(yyvsp[-7].inst); SET_BR_OFF(yyvsp[-5].inst, GetPC());
1323 break;
1324 case 15:
1325 #line 127 "parse.y"
1327 Symbol *iterSym = InstallIteratorSymbol();
1328 ADD_OP(OP_BEGIN_ARRAY_ITER); ADD_SYM(iterSym);
1329 ADD_OP(OP_ARRAY_ITER); ADD_SYM(yyvsp[-3].sym); ADD_SYM(iterSym); ADD_BR_OFF(0);
1331 break;
1332 case 16:
1333 #line 132 "parse.y"
1335 ADD_OP(OP_BRANCH); ADD_BR_OFF(yyvsp[-4].inst+2);
1336 SET_BR_OFF(yyvsp[-4].inst+5, GetPC());
1337 FillLoopAddrs(GetPC(), yyvsp[-4].inst+2);
1339 break;
1340 case 17:
1341 #line 137 "parse.y"
1343 ADD_OP(OP_BRANCH); ADD_BR_OFF(0);
1344 if (AddBreakAddr(GetPC()-1)) {
1345 yyerror("break outside loop"); YYERROR;
1348 break;
1349 case 18:
1350 #line 143 "parse.y"
1352 ADD_OP(OP_BRANCH); ADD_BR_OFF(0);
1353 if (AddContinueAddr(GetPC()-1)) {
1354 yyerror("continue outside loop"); YYERROR;
1357 break;
1358 case 19:
1359 #line 149 "parse.y"
1361 ADD_OP(OP_RETURN);
1363 break;
1364 case 20:
1365 #line 152 "parse.y"
1367 ADD_OP(OP_RETURN_NO_VAL);
1369 break;
1370 case 21:
1371 #line 156 "parse.y"
1373 ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-2].sym);
1375 break;
1376 case 22:
1377 #line 159 "parse.y"
1379 ADD_OP(OP_ADD); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-2].sym);
1381 break;
1382 case 23:
1383 #line 162 "parse.y"
1385 ADD_OP(OP_SUB); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-2].sym);
1387 break;
1388 case 24:
1389 #line 165 "parse.y"
1391 ADD_OP(OP_MUL); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-2].sym);
1393 break;
1394 case 25:
1395 #line 168 "parse.y"
1397 ADD_OP(OP_DIV); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-2].sym);
1399 break;
1400 case 26:
1401 #line 171 "parse.y"
1403 ADD_OP(OP_MOD); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-2].sym);
1405 break;
1406 case 27:
1407 #line 174 "parse.y"
1409 ADD_OP(OP_BIT_AND); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-2].sym);
1411 break;
1412 case 28:
1413 #line 177 "parse.y"
1415 ADD_OP(OP_BIT_OR); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-2].sym);
1417 break;
1418 case 29:
1419 #line 180 "parse.y"
1421 ADD_OP(OP_ARRAY_DELETE); ADD_IMMED(yyvsp[-1].nArgs);
1423 break;
1424 case 30:
1425 #line 183 "parse.y"
1427 ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED(yyvsp[-3].nArgs);
1429 break;
1430 case 31:
1431 #line 186 "parse.y"
1433 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(1); ADD_IMMED(yyvsp[-3].nArgs);
1434 ADD_OP(OP_ADD);
1435 ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED(yyvsp[-3].nArgs);
1437 break;
1438 case 32:
1439 #line 191 "parse.y"
1441 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(1); ADD_IMMED(yyvsp[-3].nArgs);
1442 ADD_OP(OP_SUB);
1443 ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED(yyvsp[-3].nArgs);
1445 break;
1446 case 33:
1447 #line 196 "parse.y"
1449 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(1); ADD_IMMED(yyvsp[-3].nArgs);
1450 ADD_OP(OP_MUL);
1451 ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED(yyvsp[-3].nArgs);
1453 break;
1454 case 34:
1455 #line 201 "parse.y"
1457 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(1); ADD_IMMED(yyvsp[-3].nArgs);
1458 ADD_OP(OP_DIV);
1459 ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED(yyvsp[-3].nArgs);
1461 break;
1462 case 35:
1463 #line 206 "parse.y"
1465 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(1); ADD_IMMED(yyvsp[-3].nArgs);
1466 ADD_OP(OP_MOD);
1467 ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED(yyvsp[-3].nArgs);
1469 break;
1470 case 36:
1471 #line 211 "parse.y"
1473 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(1); ADD_IMMED(yyvsp[-3].nArgs);
1474 ADD_OP(OP_BIT_AND);
1475 ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED(yyvsp[-3].nArgs);
1477 break;
1478 case 37:
1479 #line 216 "parse.y"
1481 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(1); ADD_IMMED(yyvsp[-3].nArgs);
1482 ADD_OP(OP_BIT_OR);
1483 ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED(yyvsp[-3].nArgs);
1485 break;
1486 case 38:
1487 #line 221 "parse.y"
1489 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(0); ADD_IMMED(yyvsp[-2].nArgs);
1490 ADD_OP(OP_INCR);
1491 ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED(yyvsp[-2].nArgs);
1493 break;
1494 case 39:
1495 #line 226 "parse.y"
1497 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(0); ADD_IMMED(yyvsp[-2].nArgs);
1498 ADD_OP(OP_DECR);
1499 ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED(yyvsp[-2].nArgs);
1501 break;
1502 case 40:
1503 #line 231 "parse.y"
1505 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(0); ADD_IMMED(yyvsp[-1].nArgs);
1506 ADD_OP(OP_INCR);
1507 ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED(yyvsp[-1].nArgs);
1509 break;
1510 case 41:
1511 #line 236 "parse.y"
1513 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(0); ADD_IMMED(yyvsp[-1].nArgs);
1514 ADD_OP(OP_DECR);
1515 ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED(yyvsp[-1].nArgs);
1517 break;
1518 case 42:
1519 #line 241 "parse.y"
1521 ADD_OP(OP_SUBR_CALL);
1522 ADD_SYM(PromoteToGlobal(yyvsp[-3].sym)); ADD_IMMED(yyvsp[-1].nArgs);
1524 break;
1525 case 43:
1526 #line 245 "parse.y"
1528 ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[0].sym); ADD_OP(OP_INCR);
1529 ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[0].sym);
1531 break;
1532 case 44:
1533 #line 249 "parse.y"
1535 ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[-1].sym); ADD_OP(OP_INCR);
1536 ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-1].sym);
1538 break;
1539 case 45:
1540 #line 253 "parse.y"
1542 ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[0].sym); ADD_OP(OP_DECR);
1543 ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[0].sym);
1545 break;
1546 case 46:
1547 #line 257 "parse.y"
1549 ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[-1].sym); ADD_OP(OP_DECR);
1550 ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-1].sym);
1552 break;
1553 case 47:
1554 #line 262 "parse.y"
1556 yyval.sym = yyvsp[0].sym; ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[0].sym);
1558 break;
1559 case 48:
1560 #line 266 "parse.y"
1562 yyval.inst = GetPC();
1564 break;
1565 case 49:
1566 #line 269 "parse.y"
1568 yyval.inst = GetPC();
1570 break;
1571 case 50:
1572 #line 272 "parse.y"
1574 yyval.inst = GetPC();
1576 break;
1577 case 51:
1578 #line 276 "parse.y"
1580 yyval.nArgs = 0;
1582 break;
1583 case 52:
1584 #line 279 "parse.y"
1586 yyval.nArgs = 1;
1588 break;
1589 case 53:
1590 #line 282 "parse.y"
1592 yyval.nArgs = yyvsp[-2].nArgs + 1;
1594 break;
1595 case 55:
1596 #line 287 "parse.y"
1598 ADD_OP(OP_CONCAT);
1600 break;
1601 case 56:
1602 #line 291 "parse.y"
1604 ADD_OP(OP_PUSH_ARRAY_SYM); ADD_SYM(yyvsp[0].sym); ADD_IMMED(1);
1606 break;
1607 case 57:
1608 #line 294 "parse.y"
1610 ADD_OP(OP_ARRAY_REF); ADD_IMMED(yyvsp[-1].nArgs);
1612 break;
1613 case 58:
1614 #line 298 "parse.y"
1616 ADD_OP(OP_PUSH_ARRAY_SYM); ADD_SYM(yyvsp[0].sym); ADD_IMMED(0);
1618 break;
1619 case 59:
1620 #line 301 "parse.y"
1622 ADD_OP(OP_ARRAY_REF); ADD_IMMED(yyvsp[-1].nArgs);
1624 break;
1625 case 60:
1626 #line 305 "parse.y"
1628 yyval.inst = GetPC();
1630 break;
1631 case 61:
1632 #line 309 "parse.y"
1634 ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[0].sym);
1636 break;
1637 case 62:
1638 #line 312 "parse.y"
1640 ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[0].sym);
1642 break;
1643 case 63:
1644 #line 315 "parse.y"
1646 ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[0].sym);
1648 break;
1649 case 64:
1650 #line 318 "parse.y"
1652 ADD_OP(OP_SUBR_CALL);
1653 ADD_SYM(PromoteToGlobal(yyvsp[-3].sym)); ADD_IMMED(yyvsp[-1].nArgs);
1654 ADD_OP(OP_FETCH_RET_VAL);
1656 break;
1657 case 66:
1658 #line 324 "parse.y"
1660 ADD_OP(OP_PUSH_ARG);
1662 break;
1663 case 67:
1664 #line 327 "parse.y"
1666 ADD_OP(OP_PUSH_ARG_COUNT);
1668 break;
1669 case 68:
1670 #line 330 "parse.y"
1672 ADD_OP(OP_PUSH_ARG_ARRAY);
1674 break;
1675 case 69:
1676 #line 333 "parse.y"
1678 ADD_OP(OP_ARRAY_REF); ADD_IMMED(yyvsp[-1].nArgs);
1680 break;
1681 case 70:
1682 #line 336 "parse.y"
1684 ADD_OP(OP_ADD);
1686 break;
1687 case 71:
1688 #line 339 "parse.y"
1690 ADD_OP(OP_SUB);
1692 break;
1693 case 72:
1694 #line 342 "parse.y"
1696 ADD_OP(OP_MUL);
1698 break;
1699 case 73:
1700 #line 345 "parse.y"
1702 ADD_OP(OP_DIV);
1704 break;
1705 case 74:
1706 #line 348 "parse.y"
1708 ADD_OP(OP_MOD);
1710 break;
1711 case 75:
1712 #line 351 "parse.y"
1714 ADD_OP(OP_POWER);
1716 break;
1717 case 76:
1718 #line 354 "parse.y"
1720 ADD_OP(OP_NEGATE);
1722 break;
1723 case 77:
1724 #line 357 "parse.y"
1726 ADD_OP(OP_GT);
1728 break;
1729 case 78:
1730 #line 360 "parse.y"
1732 ADD_OP(OP_GE);
1734 break;
1735 case 79:
1736 #line 363 "parse.y"
1738 ADD_OP(OP_LT);
1740 break;
1741 case 80:
1742 #line 366 "parse.y"
1744 ADD_OP(OP_LE);
1746 break;
1747 case 81:
1748 #line 369 "parse.y"
1750 ADD_OP(OP_EQ);
1752 break;
1753 case 82:
1754 #line 372 "parse.y"
1756 ADD_OP(OP_NE);
1758 break;
1759 case 83:
1760 #line 375 "parse.y"
1762 ADD_OP(OP_BIT_AND);
1764 break;
1765 case 84:
1766 #line 378 "parse.y"
1768 ADD_OP(OP_BIT_OR);
1770 break;
1771 case 85:
1772 #line 381 "parse.y"
1774 ADD_OP(OP_AND); SET_BR_OFF(yyvsp[-1].inst, GetPC());
1776 break;
1777 case 86:
1778 #line 384 "parse.y"
1780 ADD_OP(OP_OR); SET_BR_OFF(yyvsp[-1].inst, GetPC());
1782 break;
1783 case 87:
1784 #line 387 "parse.y"
1786 ADD_OP(OP_NOT);
1788 break;
1789 case 88:
1790 #line 390 "parse.y"
1792 ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[0].sym); ADD_OP(OP_INCR);
1793 ADD_OP(OP_DUP); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[0].sym);
1795 break;
1796 case 89:
1797 #line 394 "parse.y"
1799 ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[-1].sym); ADD_OP(OP_DUP);
1800 ADD_OP(OP_INCR); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-1].sym);
1802 break;
1803 case 90:
1804 #line 398 "parse.y"
1806 ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[0].sym); ADD_OP(OP_DECR);
1807 ADD_OP(OP_DUP); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[0].sym);
1809 break;
1810 case 91:
1811 #line 402 "parse.y"
1813 ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[-1].sym); ADD_OP(OP_DUP);
1814 ADD_OP(OP_DECR); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-1].sym);
1816 break;
1817 case 92:
1818 #line 406 "parse.y"
1820 ADD_OP(OP_IN_ARRAY);
1822 break;
1823 case 93:
1824 #line 410 "parse.y"
1826 yyval.inst = GetPC(); StartLoopAddrList();
1828 break;
1829 case 94:
1830 #line 414 "parse.y"
1832 StartLoopAddrList(); yyval.inst = GetPC();
1834 break;
1835 case 95:
1836 #line 418 "parse.y"
1838 ADD_OP(OP_BRANCH); yyval.inst = GetPC(); ADD_BR_OFF(0);
1840 break;
1841 case 96:
1842 #line 422 "parse.y"
1844 ADD_OP(OP_BRANCH_NEVER); yyval.inst = GetPC(); ADD_BR_OFF(0);
1846 break;
1847 case 97:
1848 #line 425 "parse.y"
1850 ADD_OP(OP_BRANCH_FALSE); yyval.inst = GetPC(); ADD_BR_OFF(0);
1852 break;
1853 case 98:
1854 #line 429 "parse.y"
1856 ADD_OP(OP_DUP); ADD_OP(OP_BRANCH_FALSE); yyval.inst = GetPC();
1857 ADD_BR_OFF(0);
1859 break;
1860 case 99:
1861 #line 434 "parse.y"
1863 ADD_OP(OP_DUP); ADD_OP(OP_BRANCH_TRUE); yyval.inst = GetPC();
1864 ADD_BR_OFF(0);
1866 break;
1867 #line 1868 "y.tab.c"
1869 yyssp -= yym;
1870 yystate = *yyssp;
1871 yyvsp -= yym;
1872 yym = yylhs[yyn];
1873 if (yystate == 0 && yym == 0)
1875 #if YYDEBUG
1876 if (yydebug)
1877 printf("%sdebug: after reduction, shifting from state 0 to\
1878 state %d\n", YYPREFIX, YYFINAL);
1879 #endif
1880 yystate = YYFINAL;
1881 *++yyssp = YYFINAL;
1882 *++yyvsp = yyval;
1883 if (yychar < 0)
1885 if ((yychar = yylex()) < 0) yychar = 0;
1886 #if YYDEBUG
1887 if (yydebug)
1889 yys = 0;
1890 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
1891 if (!yys) yys = "illegal-symbol";
1892 printf("%sdebug: state %d, reading %d (%s)\n",
1893 YYPREFIX, YYFINAL, yychar, yys);
1895 #endif
1897 if (yychar == 0) goto yyaccept;
1898 goto yyloop;
1900 if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
1901 yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
1902 yystate = yytable[yyn];
1903 else
1904 yystate = yydgoto[yym];
1905 #if YYDEBUG
1906 if (yydebug)
1907 printf("%sdebug: after reduction, shifting from state %d \
1908 to state %d\n", YYPREFIX, *yyssp, yystate);
1909 #endif
1910 if (yyssp >= yysslim && yygrowstack())
1912 goto yyoverflow;
1914 *++yyssp = yystate;
1915 *++yyvsp = yyval;
1916 goto yyloop;
1917 yyoverflow:
1918 yyerror("yacc stack overflow");
1919 yyabort:
1920 return (1);
1921 yyaccept:
1922 return (0);