Workaround for OpenMotif radio button bug (SF #678198).
[nedit.git] / source / parse_noyacc.c
blob3f3bfe98bf81f0da49244deb2d810a505f9abc34
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 <string.h>
28 #include <stdio.h>
29 #include <ctype.h>
30 #include <X11/Intrinsic.h>
31 #include <Xm/Xm.h>
32 #ifdef VMS
33 #include "../util/VMSparam.h"
34 #else
35 #ifndef __MVS__
36 #include <sys/param.h>
37 #endif
38 #endif /*VMS*/
40 #ifdef HAVE_DEBUG_H
41 #include "../debug.h"
42 #endif
44 /* Macros to add error processing to AddOp and AddSym calls */
45 #define ADD_OP(op) if (!AddOp(op, &ErrMsg)) return 1
46 #define ADD_SYM(sym) if (!AddSym(sym, &ErrMsg)) return 1
47 #define ADD_IMMED(val) if (!AddImmediate(val, &ErrMsg)) return 1
48 #define ADD_BR_OFF(to) if (!AddBranchOffset(to, &ErrMsg)) return 1
49 #define SET_BR_OFF(from, to) *((int *)(from)) = ((Inst *)(to)) - ((Inst *)(from))
51 /* Max. length for a string constant (... there shouldn't be a maximum) */
52 #define MAX_STRING_CONST_LEN 5000
54 static const char CVSID[] = "$Id: parse_noyacc.c,v 1.7 2003/05/15 07:33:00 edg Exp $";
55 static int yyerror(char *s);
56 static int yylex(void);
57 int yyparse(void);
58 static int follow(char expect, int yes, int no);
59 static int follow2(char expect1, int yes1, char expect2, int yes2, int no);
60 static int follow_non_whitespace(char expect, int yes, int no);
61 static Symbol *matchesActionRoutine(char **inPtr);
63 static char *ErrMsg;
64 static char *InPtr;
65 extern Inst *LoopStack[]; /* addresses of break, cont stmts */
66 extern Inst **LoopStackPtr; /* to fill at the end of a loop */
68 #line 56 "parse.y"
69 typedef union {
70 Symbol *sym;
71 Inst *inst;
72 int nArgs;
73 } YYSTYPE;
74 #line 75 "y.tab.c"
75 #define YYERRCODE 256
76 #define NUMBER 257
77 #define STRING 258
78 #define SYMBOL 259
79 #define IF 260
80 #define WHILE 261
81 #define ELSE 262
82 #define FOR 263
83 #define BREAK 264
84 #define CONTINUE 265
85 #define RETURN 266
86 #define IF_NO_ELSE 267
87 #define ADDEQ 268
88 #define SUBEQ 269
89 #define MULEQ 270
90 #define DIVEQ 271
91 #define MODEQ 272
92 #define ANDEQ 273
93 #define OREQ 274
94 #define CONCAT 275
95 #define OR 276
96 #define AND 277
97 #define GT 278
98 #define GE 279
99 #define LT 280
100 #define LE 281
101 #define EQ 282
102 #define NE 283
103 #define IN 284
104 #define UNARY_MINUS 285
105 #define NOT 286
106 #define DELETE 287
107 #define INCR 288
108 #define DECR 289
109 #define POW 290
110 const short yylhs[] = { -1,
111 0, 0, 0, 0, 13, 13, 13, 12, 12, 14,
112 14, 14, 14, 14, 16, 14, 14, 14, 14, 14,
113 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
114 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
115 15, 15, 15, 15, 15, 15, 10, 3, 3, 3,
116 1, 1, 1, 17, 17, 19, 19, 18, 18, 9,
117 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
118 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
119 20, 20, 20, 20, 20, 20, 20, 20, 20, 5,
120 4, 6, 2, 2, 7, 8, 11, 11,
122 const short yylen[] = { 2,
123 2, 5, 4, 1, 5, 4, 1, 1, 2, 3,
124 6, 9, 6, 10, 0, 9, 3, 3, 4, 3,
125 3, 3, 3, 3, 3, 3, 3, 3, 5, 6,
126 6, 6, 6, 6, 6, 6, 6, 5, 5, 5,
127 5, 4, 2, 2, 2, 2, 1, 0, 1, 3,
128 0, 1, 3, 1, 2, 1, 4, 1, 4, 1,
129 1, 1, 1, 4, 3, 4, 3, 3, 3, 3,
130 3, 3, 2, 3, 3, 3, 3, 3, 3, 3,
131 3, 3, 3, 2, 2, 2, 2, 2, 3, 1,
132 1, 1, 0, 1, 1, 1, 0, 2,
134 const short yydefred[] = { 0,
135 4, 0, 0, 0, 0, 90, 91, 0, 0, 0,
136 0, 0, 0, 97, 98, 0, 0, 0, 0, 8,
137 0, 0, 0, 44, 46, 0, 0, 97, 97, 61,
138 62, 0, 0, 0, 0, 0, 0, 97, 0, 0,
139 58, 0, 0, 0, 0, 0, 0, 0, 0, 0,
140 0, 0, 0, 0, 0, 0, 9, 97, 0, 0,
141 0, 0, 0, 0, 0, 0, 86, 88, 0, 0,
142 0, 85, 87, 0, 0, 97, 0, 96, 95, 0,
143 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
144 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
145 3, 0, 0, 0, 49, 0, 0, 0, 0, 0,
146 0, 0, 0, 0, 0, 42, 0, 97, 0, 65,
147 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
148 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
149 0, 0, 2, 0, 0, 0, 97, 0, 0, 0,
150 64, 66, 0, 0, 0, 0, 0, 0, 50, 0,
151 0, 0, 0, 0, 0, 0, 0, 0, 38, 39,
152 97, 0, 7, 15, 0, 13, 0, 0, 0, 0,
153 0, 0, 0, 0, 0, 92, 97, 97, 0, 97,
154 0, 0, 0, 97, 0, 97, 12, 16, 0, 0,
157 const short yydgoto[] = { 2,
158 61, 63, 104, 16, 17, 187, 96, 97, 156, 18,
159 3, 19, 172, 173, 21, 188, 62, 42, 22, 40,
161 const short yysindex[] = { -215,
162 0, 0, 718, -33, 21, 0, 0, 35, 44, 176,
163 -191, -182, -178, 0, 0, 62, 68, 412, 1139, 0,
164 80, 13, 380, 0, 0, 380, 380, 0, 0, 0,
165 0, 3, 380, 380, -146, -144, 380, 0, 504, -32,
166 0, 28, 0, 33, 0, 38, 222, -122, 380, 380,
167 380, 380, 380, 380, 380, 380, 0, 0, 380, 380,
168 14, 380, 92, -32, 137, 137, 0, 0, 380, -91,
169 -91, 0, 0, 301, 137, 0, -32, 0, 0, 380,
170 380, 380, 380, 380, 380, 380, 380, 380, 380, 380,
171 380, 380, 380, 380, 380, 380, 380, 380, 380, 380,
172 0, 1121, 11, -26, 0, 110, 380, 380, 380, 380,
173 380, 380, 380, 137, -40, 0, 380, 0, 84, 0,
174 137, 1271, 1285, -5, -5, -5, -5, -5, -5, -5,
175 -3, -3, -91, -91, -91, -91, -30, 1253, 1216, -19,
176 -17, -15, 0, 380, 380, -65, 0, 698, 380, 879,
177 0, 0, 0, 0, 0, 111, -32, 109, 0, 879,
178 380, 380, 380, 380, 380, 380, 380, 380, 0, 0,
179 0, -79, 0, 0, -65, 0, 380, 380, 380, 380,
180 380, 380, 380, 380, 923, 0, 0, 0, 105, 0,
181 1131, 879, 879, 0, 137, 0, 0, 0, 879, 137,
184 const short yyrindex[] = { 954,
185 0, 0, 0, -34, 0, 0, 0, 0, 0, 0,
186 0, 0, 0, 0, 0, 0, 0, 0, 185, 0,
187 0, 0, 0, 0, 0, 128, 146, 0, 0, 0,
188 0, 117, 0, 0, 0, 0, 0, 0, 0, 91,
189 0, 0, 6, 0, 25, 0, 0, -13, 146, 0,
190 0, 0, 0, 0, 0, 0, 0, 0, -14, 52,
191 0, -22, 0, 41, 1, 9, 0, 0, 128, 160,
192 368, 0, 0, 0, 17, 0, 1181, 0, 0, 0,
193 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
194 0, 0, 0, 0, -14, 0, 0, -14, -14, -14,
195 0, 0, -34, 0, 0, 0, 77, 79, 104, 112,
196 133, 134, 147, 48, 0, 0, 0, 0, 0, 0,
197 56, 1035, 993, 665, 741, 781, 826, 872, 917, 950,
198 574, 620, 413, 453, 489, 529, 0, 1078, 464, 0,
199 0, 0, 0, 0, 136, 0, 0, 118, -18, 0,
200 0, 0, 26, 39, 50, 0, 171, 0, 0, 0,
201 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
202 0, 103, 0, 0, 138, 0, 170, 329, 497, 506,
203 542, 551, 552, 565, 0, 0, 0, 0, 0, 0,
204 0, 0, 0, 0, 64, 0, 0, 0, 0, 95,
207 const short yygindex[] = { 0,
208 420, -46, 40, 0, 0, 0, 0, 0, 0, 0,
209 1331, -45, -87, 5, -36, 0, 1296, 0, 8, 1543,
211 #define YYTABLESIZE 1727
212 const short yytable[] = { 95,
213 17, 102, 106, 117, 93, 81, 26, 20, 18, 91,
214 89, 105, 90, 117, 92, 43, 20, 146, 52, 44,
215 46, 52, 53, 57, 117, 53, 117, 23, 117, 51,
216 48, 93, 145, 93, 45, 29, 91, 89, 91, 90,
217 1, 92, 69, 92, 28, 48, 43, 10, 40, 43,
218 26, 20, 148, 29, 116, 19, 56, 117, 95, 41,
219 27, 21, 152, 6, 43, 45, 29, 41, 45, 29,
220 52, 23, 176, 153, 53, 154, 43, 155, 51, 40,
221 45, 94, 40, 45, 29, 95, 22, 95, 23, 58,
222 41, 80, 21, 41, 5, 21, 56, 40, 158, 94,
223 54, 48, 11, 59, 197, 198, 57, 49, 41, 159,
224 21, 201, 72, 24, 73, 56, 59, 22, 98, 23,
225 22, 25, 23, 99, 151, 17, 63, 117, 100, 57,
226 54, 54, 118, 18, 54, 22, 103, 23, 105, 191,
227 57, 20, 26, 27, 24, 194, 15, 24, 146, 54,
228 147, 174, 25, 63, 63, 25, 28, 63, 63, 63,
229 63, 63, 24, 63, 11, 12, 13, 175, 51, 73,
230 25, 51, 10, 26, 27, 63, 26, 27, 48, 30,
231 19, 48, 186, 54, 1, 38, 93, 28, 6, 20,
232 28, 26, 27, 4, 93, 57, 73, 73, 94, 73,
233 73, 73, 73, 73, 73, 28, 73, 63, 57, 63,
234 30, 60, 0, 30, 189, 37, 0, 0, 73, 5,
235 33, 11, 12, 13, 0, 0, 0, 11, 30, 0,
236 0, 15, 0, 47, 47, 47, 47, 47, 47, 47,
237 63, 0, 0, 78, 79, 82, 83, 84, 85, 86,
238 87, 88, 73, 0, 24, 25, 0, 94, 0, 17,
239 17, 17, 17, 17, 17, 17, 17, 18, 18, 18,
240 18, 18, 18, 18, 18, 20, 20, 20, 20, 20,
241 20, 20, 20, 73, 94, 0, 94, 17, 17, 17,
242 67, 68, 0, 0, 144, 18, 18, 18, 24, 25,
243 0, 0, 0, 20, 20, 20, 10, 10, 10, 10,
244 10, 10, 10, 10, 19, 19, 19, 19, 19, 19,
245 19, 19, 6, 6, 6, 6, 6, 6, 6, 6,
246 0, 0, 0, 0, 10, 10, 10, 0, 31, 0,
247 37, 120, 19, 19, 19, 33, 101, 54, 54, 54,
248 6, 6, 6, 5, 5, 5, 5, 5, 5, 5,
249 5, 11, 11, 11, 0, 11, 11, 11, 11, 31,
250 0, 0, 31, 63, 63, 63, 54, 84, 54, 54,
251 0, 5, 5, 5, 0, 0, 0, 31, 0, 11,
252 11, 11, 63, 63, 63, 63, 63, 63, 63, 63,
253 63, 0, 63, 0, 84, 84, 63, 84, 84, 84,
254 84, 84, 84, 0, 84, 0, 73, 73, 73, 37,
255 0, 0, 69, 0, 33, 0, 84, 0, 0, 0,
256 0, 0, 30, 31, 32, 73, 73, 73, 73, 73,
257 73, 73, 73, 73, 0, 73, 0, 73, 73, 69,
258 69, 0, 69, 69, 69, 69, 69, 69, 0, 69,
259 84, 34, 70, 35, 36, 0, 0, 0, 0, 0,
260 0, 69, 0, 83, 0, 0, 0, 0, 115, 0,
261 4, 5, 6, 0, 7, 8, 9, 10, 119, 70,
262 70, 84, 70, 70, 70, 70, 70, 70, 71, 70,
263 0, 0, 0, 83, 83, 69, 32, 83, 11, 12,
264 13, 70, 0, 76, 137, 33, 0, 140, 141, 142,
265 0, 0, 83, 0, 0, 71, 71, 0, 71, 71,
266 71, 71, 71, 71, 0, 71, 69, 32, 72, 0,
267 32, 0, 0, 37, 0, 70, 33, 71, 33, 33,
268 0, 34, 0, 0, 0, 32, 83, 30, 31, 32,
269 35, 36, 0, 0, 33, 72, 72, 0, 72, 72,
270 72, 72, 72, 72, 37, 72, 70, 0, 0, 0,
271 0, 71, 34, 67, 0, 34, 34, 72, 35, 36,
272 0, 35, 36, 0, 35, 36, 0, 0, 0, 0,
273 34, 0, 0, 0, 0, 37, 0, 0, 37, 35,
274 36, 67, 71, 67, 67, 0, 67, 67, 67, 0,
275 0, 72, 0, 37, 84, 84, 84, 0, 0, 68,
276 0, 0, 67, 0, 0, 0, 30, 31, 32, 0,
277 0, 0, 0, 84, 84, 84, 84, 84, 84, 84,
278 84, 84, 72, 84, 0, 84, 84, 68, 0, 68,
279 68, 0, 68, 68, 68, 34, 67, 35, 36, 69,
280 69, 69, 0, 0, 74, 0, 0, 0, 68, 50,
281 51, 52, 53, 54, 55, 56, 0, 0, 69, 69,
282 69, 69, 69, 69, 69, 69, 69, 67, 69, 0,
283 69, 69, 74, 0, 74, 74, 0, 0, 74, 70,
284 70, 70, 68, 0, 0, 0, 0, 0, 0, 0,
285 83, 83, 83, 74, 0, 0, 0, 15, 70, 70,
286 70, 70, 70, 70, 70, 70, 70, 0, 70, 83,
287 70, 70, 0, 68, 0, 71, 71, 71, 0, 83,
288 75, 83, 83, 0, 0, 0, 0, 74, 161, 0,
289 30, 31, 32, 0, 71, 71, 71, 71, 71, 71,
290 71, 71, 71, 0, 71, 0, 71, 71, 75, 0,
291 75, 75, 0, 0, 75, 72, 72, 72, 74, 34,
292 76, 35, 36, 0, 0, 0, 0, 0, 0, 75,
293 0, 0, 0, 0, 72, 72, 72, 72, 72, 72,
294 72, 72, 72, 0, 72, 0, 72, 72, 76, 0,
295 76, 76, 0, 0, 76, 0, 0, 0, 0, 0,
296 67, 67, 67, 75, 0, 77, 0, 0, 0, 76,
297 14, 0, 0, 0, 0, 0, 0, 0, 0, 67,
298 67, 67, 67, 67, 67, 67, 67, 67, 0, 67,
299 0, 67, 67, 77, 75, 77, 77, 0, 0, 77,
300 0, 0, 0, 76, 0, 0, 68, 68, 68, 0,
301 0, 78, 0, 0, 77, 0, 0, 0, 15, 0,
302 0, 0, 0, 0, 0, 68, 68, 68, 68, 68,
303 68, 68, 68, 68, 76, 68, 0, 68, 68, 78,
304 0, 78, 78, 0, 0, 78, 0, 0, 77, 0,
305 0, 74, 74, 74, 0, 0, 79, 0, 0, 0,
306 78, 0, 15, 0, 0, 0, 0, 0, 0, 0,
307 74, 74, 74, 74, 74, 74, 74, 74, 74, 77,
308 74, 0, 74, 74, 79, 0, 79, 79, 0, 89,
309 79, 0, 0, 97, 78, 162, 163, 164, 165, 166,
310 167, 168, 0, 0, 0, 79, 4, 5, 6, 0,
311 7, 8, 9, 10, 0, 169, 170, 89, 0, 89,
312 89, 0, 0, 89, 0, 78, 0, 75, 75, 75,
313 0, 171, 80, 0, 11, 12, 13, 0, 89, 79,
314 0, 0, 0, 0, 0, 0, 75, 75, 75, 75,
315 75, 75, 75, 75, 75, 0, 75, 0, 75, 75,
316 80, 0, 80, 80, 0, 0, 80, 76, 76, 76,
317 79, 0, 89, 0, 81, 0, 0, 190, 0, 0,
318 0, 80, 0, 0, 0, 0, 76, 76, 76, 76,
319 76, 76, 76, 76, 76, 0, 76, 0, 76, 76,
320 0, 0, 0, 89, 81, 81, 97, 0, 81, 0,
321 0, 0, 77, 77, 77, 80, 0, 82, 0, 0,
322 0, 0, 0, 81, 0, 0, 0, 0, 0, 0,
323 0, 77, 77, 77, 77, 77, 77, 77, 77, 77,
324 0, 77, 0, 77, 77, 0, 80, 82, 82, 0,
325 0, 82, 0, 0, 0, 0, 0, 81, 78, 78,
326 78, 0, 0, 0, 0, 0, 82, 4, 5, 6,
327 0, 7, 8, 9, 10, 0, 0, 78, 78, 78,
328 78, 78, 78, 78, 78, 78, 0, 78, 81, 78,
329 78, 0, 0, 0, 0, 11, 12, 13, 0, 0,
330 82, 0, 0, 79, 79, 79, 0, 0, 0, 0,
331 0, 4, 5, 6, 0, 7, 8, 9, 10, 0,
332 55, 0, 79, 79, 79, 79, 79, 79, 79, 79,
333 79, 0, 79, 0, 79, 79, 89, 89, 89, 11,
334 12, 13, 97, 97, 97, 0, 97, 97, 97, 97,
335 55, 55, 0, 0, 55, 89, 89, 89, 89, 89,
336 89, 89, 89, 89, 0, 89, 0, 89, 89, 55,
337 97, 97, 97, 0, 0, 143, 0, 0, 0, 80,
338 80, 80, 93, 81, 0, 196, 0, 91, 89, 0,
339 90, 0, 92, 0, 0, 0, 0, 0, 80, 80,
340 0, 0, 0, 55, 0, 0, 0, 0, 80, 0,
341 80, 80, 0, 0, 0, 0, 0, 0, 0, 93,
342 81, 81, 81, 81, 91, 89, 0, 90, 0, 92,
343 0, 0, 0, 0, 0, 39, 95, 93, 81, 0,
344 81, 81, 91, 89, 0, 90, 0, 92, 60, 0,
345 81, 93, 81, 81, 0, 0, 91, 89, 0, 90,
346 0, 92, 74, 0, 82, 82, 82, 0, 0, 80,
347 0, 0, 0, 95, 47, 107, 108, 109, 110, 111,
348 112, 113, 0, 82, 82, 0, 0, 0, 65, 66,
349 0, 95, 0, 82, 0, 82, 82, 0, 75, 0,
350 0, 0, 0, 0, 0, 95, 80, 0, 0, 4,
351 5, 6, 0, 7, 8, 9, 10, 0, 114, 4,
352 5, 6, 0, 7, 8, 9, 10, 4, 5, 6,
353 0, 7, 8, 9, 10, 0, 121, 11, 12, 13,
354 0, 0, 149, 0, 0, 0, 0, 11, 12, 13,
355 0, 0, 0, 0, 0, 11, 12, 13, 0, 0,
356 0, 0, 0, 0, 0, 0, 0, 55, 55, 55,
357 0, 0, 0, 0, 0, 0, 0, 0, 150, 0,
358 0, 0, 0, 0, 0, 0, 177, 178, 179, 180,
359 181, 182, 183, 184, 0, 0, 55, 0, 55, 55,
360 0, 0, 0, 0, 0, 0, 0, 160, 0, 0,
361 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
362 0, 0, 79, 82, 83, 84, 85, 86, 87, 88,
363 0, 185, 0, 0, 0, 94, 0, 0, 0, 0,
364 0, 0, 0, 0, 0, 0, 0, 192, 193, 0,
365 195, 0, 0, 0, 199, 0, 200, 0, 0, 0,
366 82, 83, 84, 85, 86, 87, 88, 0, 0, 0,
367 0, 0, 94, 0, 0, 0, 0, 0, 82, 83,
368 84, 85, 86, 87, 88, 0, 0, 0, 0, 0,
369 94, 0, 82, 83, 84, 85, 86, 87, 88, 64,
370 0, 0, 0, 0, 94, 70, 71, 0, 0, 0,
371 0, 77, 0, 0, 0, 0, 0, 0, 0, 0,
372 0, 64, 0, 0, 0, 0, 0, 0, 0, 0,
373 0, 0, 77, 0, 77, 0, 0, 0, 0, 0,
374 0, 0, 0, 0, 0, 0, 77, 0, 0, 0,
375 0, 0, 122, 123, 124, 125, 126, 127, 128, 129,
376 130, 131, 132, 133, 134, 135, 136, 0, 138, 139,
377 0, 0, 0, 0, 0, 0, 0, 0, 0, 77,
378 77, 77, 77, 77, 77, 77, 0, 0, 0, 0,
379 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
380 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
381 0, 0, 0, 0, 0, 0, 157, 64, 0, 0,
382 0, 77, 0, 0, 0, 0, 0, 0, 0, 0,
383 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
384 0, 0, 0, 0, 0, 0, 0, 0, 0, 77,
385 77, 77, 77, 77, 77, 77, 77,
387 const short yycheck[] = { 91,
388 0, 47, 49, 44, 37, 38, 40, 3, 0, 42,
389 43, 48, 45, 44, 47, 10, 0, 44, 41, 12,
390 13, 44, 41, 19, 44, 44, 44, 61, 44, 44,
391 44, 37, 59, 37, 10, 10, 42, 43, 42, 45,
392 256, 47, 40, 47, 10, 59, 41, 0, 10, 44,
393 40, 47, 93, 10, 41, 0, 91, 44, 91, 10,
394 40, 10, 93, 0, 59, 41, 41, 259, 44, 44,
395 93, 61, 160, 93, 93, 93, 259, 93, 93, 41,
396 259, 41, 44, 59, 59, 91, 10, 91, 10, 10,
397 41, 124, 41, 44, 0, 44, 91, 59, 145, 59,
398 10, 40, 0, 91, 192, 193, 102, 40, 59, 146,
399 59, 199, 259, 10, 259, 91, 91, 41, 91, 41,
400 44, 10, 44, 91, 41, 125, 10, 44, 91, 91,
401 40, 41, 41, 125, 44, 59, 259, 59, 175, 185,
402 91, 125, 10, 10, 41, 41, 10, 44, 44, 59,
403 41, 41, 41, 37, 38, 44, 10, 41, 42, 43,
404 44, 45, 59, 47, 287, 288, 289, 59, 41, 10,
405 59, 44, 125, 41, 41, 59, 44, 44, 41, 10,
406 125, 44, 262, 93, 0, 10, 41, 41, 125, 185,
407 44, 59, 59, 259, 59, 191, 37, 38, 290, 40,
408 41, 42, 43, 44, 45, 59, 47, 91, 91, 93,
409 41, 41, -1, 44, 175, 40, -1, -1, 59, 125,
410 45, 287, 288, 289, -1, -1, -1, 125, 59, -1,
411 -1, 10, -1, 268, 269, 270, 271, 272, 273, 274,
412 124, -1, -1, 276, 277, 278, 279, 280, 281, 282,
413 283, 284, 93, -1, 288, 289, -1, 290, -1, 259,
414 260, 261, 262, 263, 264, 265, 266, 259, 260, 261,
415 262, 263, 264, 265, 266, 259, 260, 261, 262, 263,
416 264, 265, 266, 124, 290, -1, 290, 287, 288, 289,
417 288, 289, -1, -1, 284, 287, 288, 289, 288, 289,
418 -1, -1, -1, 287, 288, 289, 259, 260, 261, 262,
419 263, 264, 265, 266, 259, 260, 261, 262, 263, 264,
420 265, 266, 259, 260, 261, 262, 263, 264, 265, 266,
421 -1, -1, -1, -1, 287, 288, 289, -1, 10, -1,
422 40, 41, 287, 288, 289, 45, 125, 257, 258, 259,
423 287, 288, 289, 259, 260, 261, 262, 263, 264, 265,
424 266, 259, 260, 261, -1, 263, 264, 265, 266, 41,
425 -1, -1, 44, 257, 258, 259, 286, 10, 288, 289,
426 -1, 287, 288, 289, -1, -1, -1, 59, -1, 287,
427 288, 289, 276, 277, 278, 279, 280, 281, 282, 283,
428 284, -1, 286, -1, 37, 38, 290, 40, 41, 42,
429 43, 44, 45, -1, 47, -1, 257, 258, 259, 40,
430 -1, -1, 10, -1, 45, -1, 59, -1, -1, -1,
431 -1, -1, 257, 258, 259, 276, 277, 278, 279, 280,
432 281, 282, 283, 284, -1, 286, -1, 288, 289, 37,
433 38, -1, 40, 41, 42, 43, 44, 45, -1, 47,
434 93, 286, 10, 288, 289, -1, -1, -1, -1, -1,
435 -1, 59, -1, 10, -1, -1, -1, -1, 59, -1,
436 259, 260, 261, -1, 263, 264, 265, 266, 69, 37,
437 38, 124, 40, 41, 42, 43, 44, 45, 10, 47,
438 -1, -1, -1, 40, 41, 93, 10, 44, 287, 288,
439 289, 59, -1, 10, 95, 10, -1, 98, 99, 100,
440 -1, -1, 59, -1, -1, 37, 38, -1, 40, 41,
441 42, 43, 44, 45, -1, 47, 124, 41, 10, -1,
442 44, -1, -1, 40, -1, 93, 41, 59, 45, 44,
443 -1, 10, -1, -1, -1, 59, 93, 257, 258, 259,
444 10, 10, -1, -1, 59, 37, 38, -1, 40, 41,
445 42, 43, 44, 45, 10, 47, 124, -1, -1, -1,
446 -1, 93, 41, 10, -1, 44, 286, 59, 288, 289,
447 -1, 41, 41, -1, 44, 44, -1, -1, -1, -1,
448 59, -1, -1, -1, -1, 41, -1, -1, 44, 59,
449 59, 38, 124, 40, 41, -1, 43, 44, 45, -1,
450 -1, 93, -1, 59, 257, 258, 259, -1, -1, 10,
451 -1, -1, 59, -1, -1, -1, 257, 258, 259, -1,
452 -1, -1, -1, 276, 277, 278, 279, 280, 281, 282,
453 283, 284, 124, 286, -1, 288, 289, 38, -1, 40,
454 41, -1, 43, 44, 45, 286, 93, 288, 289, 257,
455 258, 259, -1, -1, 10, -1, -1, -1, 59, 268,
456 269, 270, 271, 272, 273, 274, -1, -1, 276, 277,
457 278, 279, 280, 281, 282, 283, 284, 124, 286, -1,
458 288, 289, 38, -1, 40, 41, -1, -1, 44, 257,
459 258, 259, 93, -1, -1, -1, -1, -1, -1, -1,
460 257, 258, 259, 59, -1, -1, -1, 10, 276, 277,
461 278, 279, 280, 281, 282, 283, 284, -1, 286, 276,
462 288, 289, -1, 124, -1, 257, 258, 259, -1, 286,
463 10, 288, 289, -1, -1, -1, -1, 93, 61, -1,
464 257, 258, 259, -1, 276, 277, 278, 279, 280, 281,
465 282, 283, 284, -1, 286, -1, 288, 289, 38, -1,
466 40, 41, -1, -1, 44, 257, 258, 259, 124, 286,
467 10, 288, 289, -1, -1, -1, -1, -1, -1, 59,
468 -1, -1, -1, -1, 276, 277, 278, 279, 280, 281,
469 282, 283, 284, -1, 286, -1, 288, 289, 38, -1,
470 40, 41, -1, -1, 44, -1, -1, -1, -1, -1,
471 257, 258, 259, 93, -1, 10, -1, -1, -1, 59,
472 123, -1, -1, -1, -1, -1, -1, -1, -1, 276,
473 277, 278, 279, 280, 281, 282, 283, 284, -1, 286,
474 -1, 288, 289, 38, 124, 40, 41, -1, -1, 44,
475 -1, -1, -1, 93, -1, -1, 257, 258, 259, -1,
476 -1, 10, -1, -1, 59, -1, -1, -1, 10, -1,
477 -1, -1, -1, -1, -1, 276, 277, 278, 279, 280,
478 281, 282, 283, 284, 124, 286, -1, 288, 289, 38,
479 -1, 40, 41, -1, -1, 44, -1, -1, 93, -1,
480 -1, 257, 258, 259, -1, -1, 10, -1, -1, -1,
481 59, -1, 10, -1, -1, -1, -1, -1, -1, -1,
482 276, 277, 278, 279, 280, 281, 282, 283, 284, 124,
483 286, -1, 288, 289, 38, -1, 40, 41, -1, 10,
484 44, -1, -1, 10, 93, 268, 269, 270, 271, 272,
485 273, 274, -1, -1, -1, 59, 259, 260, 261, -1,
486 263, 264, 265, 266, -1, 288, 289, 38, -1, 40,
487 41, -1, -1, 44, -1, 124, -1, 257, 258, 259,
488 -1, 123, 10, -1, 287, 288, 289, -1, 59, 93,
489 -1, -1, -1, -1, -1, -1, 276, 277, 278, 279,
490 280, 281, 282, 283, 284, -1, 286, -1, 288, 289,
491 38, -1, 40, 41, -1, -1, 44, 257, 258, 259,
492 124, -1, 93, -1, 10, -1, -1, 125, -1, -1,
493 -1, 59, -1, -1, -1, -1, 276, 277, 278, 279,
494 280, 281, 282, 283, 284, -1, 286, -1, 288, 289,
495 -1, -1, -1, 124, 40, 41, 123, -1, 44, -1,
496 -1, -1, 257, 258, 259, 93, -1, 10, -1, -1,
497 -1, -1, -1, 59, -1, -1, -1, -1, -1, -1,
498 -1, 276, 277, 278, 279, 280, 281, 282, 283, 284,
499 -1, 286, -1, 288, 289, -1, 124, 40, 41, -1,
500 -1, 44, -1, -1, -1, -1, -1, 93, 257, 258,
501 259, -1, -1, -1, -1, -1, 59, 259, 260, 261,
502 -1, 263, 264, 265, 266, -1, -1, 276, 277, 278,
503 279, 280, 281, 282, 283, 284, -1, 286, 124, 288,
504 289, -1, -1, -1, -1, 287, 288, 289, -1, -1,
505 93, -1, -1, 257, 258, 259, -1, -1, -1, -1,
506 -1, 259, 260, 261, -1, 263, 264, 265, 266, -1,
507 10, -1, 276, 277, 278, 279, 280, 281, 282, 283,
508 284, -1, 286, -1, 288, 289, 257, 258, 259, 287,
509 288, 289, 259, 260, 261, -1, 263, 264, 265, 266,
510 40, 41, -1, -1, 44, 276, 277, 278, 279, 280,
511 281, 282, 283, 284, -1, 286, -1, 288, 289, 59,
512 287, 288, 289, -1, -1, 125, -1, -1, -1, 257,
513 258, 259, 37, 38, -1, 125, -1, 42, 43, -1,
514 45, -1, 47, -1, -1, -1, -1, -1, 276, 277,
515 -1, -1, -1, 93, -1, -1, -1, -1, 286, -1,
516 288, 289, -1, -1, -1, -1, -1, -1, -1, 37,
517 38, 257, 258, 259, 42, 43, -1, 45, -1, 47,
518 -1, -1, -1, -1, -1, 10, 91, 37, 38, -1,
519 276, 277, 42, 43, -1, 45, -1, 47, 23, -1,
520 286, 37, 288, 289, -1, -1, 42, 43, -1, 45,
521 -1, 47, 37, -1, 257, 258, 259, -1, -1, 124,
522 -1, -1, -1, 91, 14, 50, 51, 52, 53, 54,
523 55, 56, -1, 276, 277, -1, -1, -1, 28, 29,
524 -1, 91, -1, 286, -1, 288, 289, -1, 38, -1,
525 -1, -1, -1, -1, -1, 91, 124, -1, -1, 259,
526 260, 261, -1, 263, 264, 265, 266, -1, 58, 259,
527 260, 261, -1, 263, 264, 265, 266, 259, 260, 261,
528 -1, 263, 264, 265, 266, -1, 76, 287, 288, 289,
529 -1, -1, 117, -1, -1, -1, -1, 287, 288, 289,
530 -1, -1, -1, -1, -1, 287, 288, 289, -1, -1,
531 -1, -1, -1, -1, -1, -1, -1, 257, 258, 259,
532 -1, -1, -1, -1, -1, -1, -1, -1, 118, -1,
533 -1, -1, -1, -1, -1, -1, 161, 162, 163, 164,
534 165, 166, 167, 168, -1, -1, 286, -1, 288, 289,
535 -1, -1, -1, -1, -1, -1, -1, 147, -1, -1,
536 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
537 -1, -1, 277, 278, 279, 280, 281, 282, 283, 284,
538 -1, 171, -1, -1, -1, 290, -1, -1, -1, -1,
539 -1, -1, -1, -1, -1, -1, -1, 187, 188, -1,
540 190, -1, -1, -1, 194, -1, 196, -1, -1, -1,
541 278, 279, 280, 281, 282, 283, 284, -1, -1, -1,
542 -1, -1, 290, -1, -1, -1, -1, -1, 278, 279,
543 280, 281, 282, 283, 284, -1, -1, -1, -1, -1,
544 290, -1, 278, 279, 280, 281, 282, 283, 284, 27,
545 -1, -1, -1, -1, 290, 33, 34, -1, -1, -1,
546 -1, 39, -1, -1, -1, -1, -1, -1, -1, -1,
547 -1, 49, -1, -1, -1, -1, -1, -1, -1, -1,
548 -1, -1, 60, -1, 62, -1, -1, -1, -1, -1,
549 -1, -1, -1, -1, -1, -1, 74, -1, -1, -1,
550 -1, -1, 80, 81, 82, 83, 84, 85, 86, 87,
551 88, 89, 90, 91, 92, 93, 94, -1, 96, 97,
552 -1, -1, -1, -1, -1, -1, -1, -1, -1, 107,
553 108, 109, 110, 111, 112, 113, -1, -1, -1, -1,
554 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
555 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
556 -1, -1, -1, -1, -1, -1, 144, 145, -1, -1,
557 -1, 149, -1, -1, -1, -1, -1, -1, -1, -1,
558 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
559 -1, -1, -1, -1, -1, -1, -1, -1, -1, 177,
560 178, 179, 180, 181, 182, 183, 184,
562 #define YYFINAL 2
563 #ifndef YYDEBUG
564 #define YYDEBUG 0
565 #endif
566 #define YYMAXTOKEN 290
567 #if YYDEBUG
568 const char * const yyname[] = {
569 "end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
570 0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'","','","'-'",0,"'/'",0,0,0,0,0,
571 0,0,0,0,0,0,"';'",0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
572 0,0,"'['",0,"']'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
573 "'{'","'|'","'}'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
574 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
575 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
576 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"NUMBER","STRING","SYMBOL","IF","WHILE",
577 "ELSE","FOR","BREAK","CONTINUE","RETURN","IF_NO_ELSE","ADDEQ","SUBEQ","MULEQ",
578 "DIVEQ","MODEQ","ANDEQ","OREQ","CONCAT","OR","AND","GT","GE","LT","LE","EQ",
579 "NE","IN","UNARY_MINUS","NOT","DELETE","INCR","DECR","POW",
581 const char * const yyrule[] = {
582 "$accept : program",
583 "program : blank stmts",
584 "program : blank '{' blank stmts '}'",
585 "program : blank '{' blank '}'",
586 "program : error",
587 "block : '{' blank stmts '}' blank",
588 "block : '{' blank '}' blank",
589 "block : stmt",
590 "stmts : stmt",
591 "stmts : stmts stmt",
592 "stmt : simpstmt '\\n' blank",
593 "stmt : IF '(' cond ')' blank block",
594 "stmt : IF '(' cond ')' blank block else blank block",
595 "stmt : while '(' cond ')' blank block",
596 "stmt : for '(' comastmts ';' cond ';' comastmts ')' blank block",
597 "$$1 :",
598 "stmt : for '(' SYMBOL IN arrayexpr ')' $$1 blank block",
599 "stmt : BREAK '\\n' blank",
600 "stmt : CONTINUE '\\n' blank",
601 "stmt : RETURN expr '\\n' blank",
602 "stmt : RETURN '\\n' blank",
603 "simpstmt : SYMBOL '=' expr",
604 "simpstmt : evalsym ADDEQ expr",
605 "simpstmt : evalsym SUBEQ expr",
606 "simpstmt : evalsym MULEQ expr",
607 "simpstmt : evalsym DIVEQ expr",
608 "simpstmt : evalsym MODEQ expr",
609 "simpstmt : evalsym ANDEQ expr",
610 "simpstmt : evalsym OREQ expr",
611 "simpstmt : DELETE arraylv '[' arglist ']'",
612 "simpstmt : initarraylv '[' arglist ']' '=' expr",
613 "simpstmt : initarraylv '[' arglist ']' ADDEQ expr",
614 "simpstmt : initarraylv '[' arglist ']' SUBEQ expr",
615 "simpstmt : initarraylv '[' arglist ']' MULEQ expr",
616 "simpstmt : initarraylv '[' arglist ']' DIVEQ expr",
617 "simpstmt : initarraylv '[' arglist ']' MODEQ expr",
618 "simpstmt : initarraylv '[' arglist ']' ANDEQ expr",
619 "simpstmt : initarraylv '[' arglist ']' OREQ expr",
620 "simpstmt : initarraylv '[' arglist ']' INCR",
621 "simpstmt : initarraylv '[' arglist ']' DECR",
622 "simpstmt : INCR initarraylv '[' arglist ']'",
623 "simpstmt : DECR initarraylv '[' arglist ']'",
624 "simpstmt : SYMBOL '(' arglist ')'",
625 "simpstmt : INCR SYMBOL",
626 "simpstmt : SYMBOL INCR",
627 "simpstmt : DECR SYMBOL",
628 "simpstmt : SYMBOL DECR",
629 "evalsym : SYMBOL",
630 "comastmts :",
631 "comastmts : simpstmt",
632 "comastmts : comastmts ',' simpstmt",
633 "arglist :",
634 "arglist : expr",
635 "arglist : arglist ',' expr",
636 "expr : numexpr",
637 "expr : expr numexpr",
638 "initarraylv : SYMBOL",
639 "initarraylv : initarraylv '[' arglist ']'",
640 "arraylv : SYMBOL",
641 "arraylv : arraylv '[' arglist ']'",
642 "arrayexpr : numexpr",
643 "numexpr : NUMBER",
644 "numexpr : STRING",
645 "numexpr : SYMBOL",
646 "numexpr : SYMBOL '(' arglist ')'",
647 "numexpr : '(' expr ')'",
648 "numexpr : numexpr '[' arglist ']'",
649 "numexpr : numexpr '+' numexpr",
650 "numexpr : numexpr '-' numexpr",
651 "numexpr : numexpr '*' numexpr",
652 "numexpr : numexpr '/' numexpr",
653 "numexpr : numexpr '%' numexpr",
654 "numexpr : numexpr POW numexpr",
655 "numexpr : '-' numexpr",
656 "numexpr : numexpr GT numexpr",
657 "numexpr : numexpr GE numexpr",
658 "numexpr : numexpr LT numexpr",
659 "numexpr : numexpr LE numexpr",
660 "numexpr : numexpr EQ numexpr",
661 "numexpr : numexpr NE numexpr",
662 "numexpr : numexpr '&' numexpr",
663 "numexpr : numexpr '|' numexpr",
664 "numexpr : numexpr and numexpr",
665 "numexpr : numexpr or numexpr",
666 "numexpr : NOT numexpr",
667 "numexpr : INCR SYMBOL",
668 "numexpr : SYMBOL INCR",
669 "numexpr : DECR SYMBOL",
670 "numexpr : SYMBOL DECR",
671 "numexpr : numexpr IN numexpr",
672 "while : WHILE",
673 "for : FOR",
674 "else : ELSE",
675 "cond :",
676 "cond : numexpr",
677 "and : AND",
678 "or : OR",
679 "blank :",
680 "blank : blank '\\n'",
682 #endif
683 #if YYDEBUG
684 #include <stdio.h>
685 #endif
686 #ifdef YYSTACKSIZE
687 #undef YYMAXDEPTH
688 #define YYMAXDEPTH YYSTACKSIZE
689 #else
690 #ifdef YYMAXDEPTH
691 #define YYSTACKSIZE YYMAXDEPTH
692 #else
693 #define YYSTACKSIZE 10000
694 #define YYMAXDEPTH 10000
695 #endif
696 #endif
697 #define YYINITSTACKSIZE 200
698 int yydebug;
699 int yynerrs;
700 int yyerrflag;
701 int yychar;
702 short *yyssp;
703 YYSTYPE *yyvsp;
704 YYSTYPE yyval;
705 YYSTYPE yylval;
706 short *yyss;
707 short *yysslim;
708 YYSTYPE *yyvs;
709 int yystacksize;
710 #line 432 "parse.y"
711 /* User Subroutines Section */
715 ** Parse a null terminated string and create a program from it (this is the
716 ** parser entry point). The program created by this routine can be
717 ** executed using ExecuteProgram. Returns program on success, or NULL
718 ** on failure. If the command failed, the error message is returned
719 ** as a pointer to a static string in msg, and the length of the string up
720 ** to where parsing failed in stoppedAt.
722 Program *ParseMacro(char *expr, char **msg, char **stoppedAt)
724 Program *prog;
726 BeginCreatingProgram();
728 /* call yyparse to parse the string and check for success. If the parse
729 failed, return the error message and string index (the grammar aborts
730 parsing at the first error) */
731 InPtr = expr;
732 if (yyparse()) {
733 *msg = ErrMsg;
734 *stoppedAt = InPtr;
735 FreeProgram(FinishCreatingProgram());
736 return NULL;
739 /* get the newly created program */
740 prog = FinishCreatingProgram();
742 /* parse succeeded */
743 *msg = "";
744 *stoppedAt = InPtr;
745 return prog;
749 static int yylex(void)
751 int i, len;
752 Symbol *s;
753 static DataValue value = {NO_TAG, {0}};
754 static char escape[] = "\\\"ntbrfav";
755 static char replace[] = "\\\"\n\t\b\r\f\a\v";
757 /* skip whitespace, backslash-newline combinations, and comments, which are
758 all considered whitespace */
759 for (;;) {
760 if (*InPtr == '\\' && *(InPtr + 1) == '\n')
761 InPtr += 2;
762 else if (*InPtr == ' ' || *InPtr == '\t')
763 InPtr++;
764 else if (*InPtr == '#')
765 while (*InPtr != '\n' && *InPtr != '\0') {
766 /* Comments stop at escaped newlines */
767 if (*InPtr == '\\' && *(InPtr + 1) == '\n') {
768 InPtr += 2;
769 break;
771 InPtr++;
772 } else
773 break;
776 /* return end of input at the end of the string */
777 if (*InPtr == '\0') {
778 return 0;
781 /* process number tokens */
782 if (isdigit((unsigned char)*InPtr)) { /* number */
783 char name[28];
784 sscanf(InPtr, "%d%n", &value.val.n, &len);
785 sprintf(name, "const %d", value.val.n);
786 InPtr += len;
787 value.tag = INT_TAG;
788 if ((yylval.sym=LookupSymbol(name)) == NULL)
789 yylval.sym = InstallSymbol(name, CONST_SYM, value);
790 return NUMBER;
793 /* process symbol tokens. "define" is a special case not handled
794 by this parser, considered end of input. Another special case
795 is action routine names which are allowed to contain '-' despite
796 the ambiguity, handled in matchesActionRoutine. */
797 if (isalpha((unsigned char)*InPtr) || *InPtr == '$') {
798 if ((s=matchesActionRoutine(&InPtr)) == NULL) {
799 char symName[MAX_SYM_LEN+1], *p = symName;
800 *p++ = *InPtr++;
801 while (isalnum((unsigned char)*InPtr) || *InPtr=='_') {
802 if (p >= symName + MAX_SYM_LEN)
803 InPtr++;
804 else
805 *p++ = *InPtr++;
807 *p = '\0';
808 if (!strcmp(symName, "while")) return WHILE;
809 if (!strcmp(symName, "if")) return IF;
810 if (!strcmp(symName, "else")) return ELSE;
811 if (!strcmp(symName, "for")) return FOR;
812 if (!strcmp(symName, "break")) return BREAK;
813 if (!strcmp(symName, "continue")) return CONTINUE;
814 if (!strcmp(symName, "return")) return RETURN;
815 if (!strcmp(symName, "in")) return IN;
816 if (!strcmp(symName, "delete") && follow_non_whitespace('(', SYMBOL, DELETE) == DELETE) return DELETE;
817 if (!strcmp(symName, "define")) {
818 InPtr -= 6;
819 return 0;
821 if ((s=LookupSymbol(symName)) == NULL) {
822 s = InstallSymbol(symName, symName[0]=='$' ?
823 (isdigit((unsigned char)symName[1]) ?
824 ARG_SYM : GLOBAL_SYM) : LOCAL_SYM, value);
825 s->value.tag = NO_TAG;
828 yylval.sym = s;
829 return SYMBOL;
832 /* process quoted strings w/ embedded escape sequences */
833 if (*InPtr == '\"') {
834 char string[MAX_STRING_CONST_LEN], *p = string;
835 InPtr++;
836 while (*InPtr != '\0' && *InPtr != '\"' && *InPtr != '\n') {
837 if (p >= string + MAX_STRING_CONST_LEN) {
838 InPtr++;
839 continue;
841 if (*InPtr == '\\') {
842 InPtr++;
843 if (*InPtr == '\n') {
844 InPtr++;
845 continue;
847 for (i=0; escape[i]!='\0'; i++) {
848 if (escape[i] == '\0') {
849 *p++= *InPtr++;
850 break;
851 } else if (escape[i] == *InPtr) {
852 *p++ = replace[i];
853 InPtr++;
854 break;
857 } else
858 *p++= *InPtr++;
860 *p = '\0';
861 InPtr++;
862 yylval.sym = InstallStringConstSymbol(string);
863 return STRING;
866 /* process remaining two character tokens or return single char as token */
867 switch(*InPtr++) {
868 case '>': return follow('=', GE, GT);
869 case '<': return follow('=', LE, LT);
870 case '=': return follow('=', EQ, '=');
871 case '!': return follow('=', NE, NOT);
872 case '+': return follow2('+', INCR, '=', ADDEQ, '+');
873 case '-': return follow2('-', DECR, '=', SUBEQ, '-');
874 case '|': return follow2('|', OR, '=', OREQ, '|');
875 case '&': return follow2('&', AND, '=', ANDEQ, '&');
876 case '*': return follow2('*', POW, '=', MULEQ, '*');
877 case '/': return follow('=', DIVEQ, '/');
878 case '%': return follow('=', MODEQ, '%');
879 case '^': return POW;
880 default: return *(InPtr-1);
885 ** look ahead for >=, etc.
887 static int follow(char expect, int yes, int no)
889 if (*InPtr++ == expect)
890 return yes;
891 InPtr--;
892 return no;
894 static int follow2(char expect1, int yes1, char expect2, int yes2, int no)
896 char next = *InPtr++;
897 if (next == expect1)
898 return yes1;
899 if (next == expect2)
900 return yes2;
901 InPtr--;
902 return no;
905 static int follow_non_whitespace(char expect, int yes, int no)
907 char *localInPtr = InPtr;
909 while (1) {
910 if (*localInPtr == ' ' || *localInPtr == '\t') {
911 ++localInPtr;
913 else if (*localInPtr == '\\' && *(localInPtr + 1) == '\n') {
914 localInPtr += 2;
916 else if (*localInPtr == expect) {
917 return(yes);
919 else {
920 return(no);
926 ** Look (way) ahead for hyphenated routine names which begin at inPtr. A
927 ** hyphenated name is allowed if it is pre-defined in the global symbol
928 ** table. If a matching name exists, returns the symbol, and update "inPtr".
930 ** I know this is horrible language design, but existing nedit action routine
931 ** names contain hyphens. Handling them here in the lexical analysis process
932 ** is much easier than trying to deal with it in the parser itself. (sorry)
934 static Symbol *matchesActionRoutine(char **inPtr)
936 char *c, *symPtr;
937 int hasDash = False;
938 char symbolName[MAX_SYM_LEN+1];
939 Symbol *s;
941 symPtr = symbolName;
942 for (c = *inPtr; isalnum((unsigned char)*c) || *c=='_' ||
943 ( *c=='-' && isalnum((unsigned char)(*(c+1)))); c++) {
944 if (*c == '-')
945 hasDash = True;
946 *symPtr++ = *c;
948 if (!hasDash)
949 return NULL;
950 *symPtr = '\0';
951 s = LookupSymbol(symbolName);
952 if (s != NULL)
953 *inPtr = c;
954 return s;
958 ** Called by yacc to report errors (just stores for returning when
959 ** parsing is aborted. The error token action is to immediate abort
960 ** parsing, so this message is immediately reported to the caller
961 ** of ParseExpr)
963 static int yyerror(char *s)
965 ErrMsg = s;
966 return 0;
968 #line 965 "y.tab.c"
969 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
970 static int yygrowstack()
972 int newsize, i;
973 short *newss;
974 YYSTYPE *newvs;
976 if ((newsize = yystacksize) == 0)
977 newsize = YYINITSTACKSIZE;
978 else if (newsize >= YYMAXDEPTH)
979 return -1;
980 else if ((newsize *= 2) > YYMAXDEPTH)
981 newsize = YYMAXDEPTH;
982 i = yyssp - yyss;
983 newss = yyss ? (short *)realloc(yyss, newsize * sizeof *newss) :
984 (short *)malloc(newsize * sizeof *newss);
985 if (newss == NULL)
986 return -1;
987 yyss = newss;
988 yyssp = newss + i;
989 newvs = yyvs ? (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs) :
990 (YYSTYPE *)malloc(newsize * sizeof *newvs);
991 if (newvs == NULL)
992 return -1;
993 yyvs = newvs;
994 yyvsp = newvs + i;
995 yystacksize = newsize;
996 yysslim = yyss + newsize - 1;
997 return 0;
1000 #define YYABORT goto yyabort
1001 #define YYREJECT goto yyabort
1002 #define YYACCEPT goto yyaccept
1003 #define YYERROR goto yyerrlab
1005 #ifndef YYPARSE_PARAM
1006 #if defined(__cplusplus) || __STDC__
1007 #define YYPARSE_PARAM_ARG void
1008 #define YYPARSE_PARAM_DECL
1009 #else /* ! ANSI-C/C++ */
1010 #define YYPARSE_PARAM_ARG
1011 #define YYPARSE_PARAM_DECL
1012 #endif /* ANSI-C/C++ */
1013 #else /* YYPARSE_PARAM */
1014 #ifndef YYPARSE_PARAM_TYPE
1015 #define YYPARSE_PARAM_TYPE void *
1016 #endif
1017 #if defined(__cplusplus) || __STDC__
1018 #define YYPARSE_PARAM_ARG YYPARSE_PARAM_TYPE YYPARSE_PARAM
1019 #define YYPARSE_PARAM_DECL
1020 #else /* ! ANSI-C/C++ */
1021 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
1022 #define YYPARSE_PARAM_DECL YYPARSE_PARAM_TYPE YYPARSE_PARAM;
1023 #endif /* ANSI-C/C++ */
1024 #endif /* ! YYPARSE_PARAM */
1027 yyparse (YYPARSE_PARAM_ARG)
1028 YYPARSE_PARAM_DECL
1030 register int yym, yyn, yystate;
1031 #if YYDEBUG
1032 register const char *yys;
1034 if ((yys = getenv("YYDEBUG")))
1036 yyn = *yys;
1037 if (yyn >= '0' && yyn <= '9')
1038 yydebug = yyn - '0';
1040 #endif
1042 yynerrs = 0;
1043 yyerrflag = 0;
1044 yychar = (-1);
1046 if (yyss == NULL && yygrowstack()) goto yyoverflow;
1047 yyssp = yyss;
1048 yyvsp = yyvs;
1049 *yyssp = yystate = 0;
1051 yyloop:
1052 if ((yyn = yydefred[yystate])) goto yyreduce;
1053 if (yychar < 0)
1055 if ((yychar = yylex()) < 0) yychar = 0;
1056 #if YYDEBUG
1057 if (yydebug)
1059 yys = 0;
1060 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
1061 if (!yys) yys = "illegal-symbol";
1062 printf("%sdebug: state %d, reading %d (%s)\n",
1063 YYPREFIX, yystate, yychar, yys);
1065 #endif
1067 if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
1068 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
1070 #if YYDEBUG
1071 if (yydebug)
1072 printf("%sdebug: state %d, shifting to state %d\n",
1073 YYPREFIX, yystate, yytable[yyn]);
1074 #endif
1075 if (yyssp >= yysslim && yygrowstack())
1077 goto yyoverflow;
1079 *++yyssp = yystate = yytable[yyn];
1080 *++yyvsp = yylval;
1081 yychar = (-1);
1082 if (yyerrflag > 0) --yyerrflag;
1083 goto yyloop;
1085 if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
1086 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
1088 yyn = yytable[yyn];
1089 goto yyreduce;
1091 if (yyerrflag) goto yyinrecovery;
1092 #if defined(lint) || defined(__GNUC__)
1093 goto yynewerror;
1094 #endif
1095 yynewerror:
1096 yyerror("syntax error");
1097 #if defined(lint) || defined(__GNUC__)
1098 goto yyerrlab;
1099 #endif
1100 yyerrlab:
1101 ++yynerrs;
1102 yyinrecovery:
1103 if (yyerrflag < 3)
1105 yyerrflag = 3;
1106 for (;;)
1108 if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
1109 yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
1111 #if YYDEBUG
1112 if (yydebug)
1113 printf("%sdebug: state %d, error recovery shifting\
1114 to state %d\n", YYPREFIX, *yyssp, yytable[yyn]);
1115 #endif
1116 if (yyssp >= yysslim && yygrowstack())
1118 goto yyoverflow;
1120 *++yyssp = yystate = yytable[yyn];
1121 *++yyvsp = yylval;
1122 goto yyloop;
1124 else
1126 #if YYDEBUG
1127 if (yydebug)
1128 printf("%sdebug: error recovery discarding state %d\n",
1129 YYPREFIX, *yyssp);
1130 #endif
1131 if (yyssp <= yyss) goto yyabort;
1132 --yyssp;
1133 --yyvsp;
1137 else
1139 if (yychar == 0) goto yyabort;
1140 #if YYDEBUG
1141 if (yydebug)
1143 yys = 0;
1144 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
1145 if (!yys) yys = "illegal-symbol";
1146 printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
1147 YYPREFIX, yystate, yychar, yys);
1149 #endif
1150 yychar = (-1);
1151 goto yyloop;
1153 yyreduce:
1154 #if YYDEBUG
1155 if (yydebug)
1156 printf("%sdebug: state %d, reducing by rule %d (%s)\n",
1157 YYPREFIX, yystate, yyn, yyrule[yyn]);
1158 #endif
1159 yym = yylen[yyn];
1160 yyval = yyvsp[1-yym];
1161 switch (yyn)
1163 case 1:
1164 #line 89 "parse.y"
1166 ADD_OP(OP_RETURN_NO_VAL); return 0;
1168 break;
1169 case 2:
1170 #line 92 "parse.y"
1172 ADD_OP(OP_RETURN_NO_VAL); return 0;
1174 break;
1175 case 3:
1176 #line 95 "parse.y"
1178 ADD_OP(OP_RETURN_NO_VAL); return 0;
1180 break;
1181 case 4:
1182 #line 98 "parse.y"
1184 return 1;
1186 break;
1187 case 11:
1188 #line 110 "parse.y"
1190 SET_BR_OFF(yyvsp[-3].inst, GetPC());
1192 break;
1193 case 12:
1194 #line 113 "parse.y"
1196 SET_BR_OFF(yyvsp[-6].inst, (yyvsp[-2].inst+1)); SET_BR_OFF(yyvsp[-2].inst, GetPC());
1198 break;
1199 case 13:
1200 #line 116 "parse.y"
1202 ADD_OP(OP_BRANCH); ADD_BR_OFF(yyvsp[-5].inst);
1203 SET_BR_OFF(yyvsp[-3].inst, GetPC()); FillLoopAddrs(GetPC(), yyvsp[-5].inst);
1205 break;
1206 case 14:
1207 #line 120 "parse.y"
1209 FillLoopAddrs(GetPC()+2+(yyvsp[-3].inst-(yyvsp[-5].inst+1)), GetPC());
1210 SwapCode(yyvsp[-5].inst+1, yyvsp[-3].inst, GetPC());
1211 ADD_OP(OP_BRANCH); ADD_BR_OFF(yyvsp[-7].inst); SET_BR_OFF(yyvsp[-5].inst, GetPC());
1213 break;
1214 case 15:
1215 #line 125 "parse.y"
1217 Symbol *iterSym = InstallIteratorSymbol();
1218 ADD_OP(OP_BEGIN_ARRAY_ITER); ADD_SYM(iterSym);
1219 ADD_OP(OP_ARRAY_ITER); ADD_SYM(yyvsp[-3].sym); ADD_SYM(iterSym); ADD_BR_OFF(0);
1221 break;
1222 case 16:
1223 #line 130 "parse.y"
1225 ADD_OP(OP_BRANCH); ADD_BR_OFF(yyvsp[-4].inst+2);
1226 SET_BR_OFF(yyvsp[-4].inst+5, GetPC());
1227 FillLoopAddrs(GetPC(), yyvsp[-4].inst+2);
1229 break;
1230 case 17:
1231 #line 135 "parse.y"
1233 ADD_OP(OP_BRANCH); ADD_BR_OFF(0);
1234 if (AddBreakAddr(GetPC()-1)) {
1235 yyerror("break outside loop"); YYERROR;
1238 break;
1239 case 18:
1240 #line 141 "parse.y"
1242 ADD_OP(OP_BRANCH); ADD_BR_OFF(0);
1243 if (AddContinueAddr(GetPC()-1)) {
1244 yyerror("continue outside loop"); YYERROR;
1247 break;
1248 case 19:
1249 #line 147 "parse.y"
1251 ADD_OP(OP_RETURN);
1253 break;
1254 case 20:
1255 #line 150 "parse.y"
1257 ADD_OP(OP_RETURN_NO_VAL);
1259 break;
1260 case 21:
1261 #line 154 "parse.y"
1263 ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-2].sym);
1265 break;
1266 case 22:
1267 #line 157 "parse.y"
1269 ADD_OP(OP_ADD); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-2].sym);
1271 break;
1272 case 23:
1273 #line 160 "parse.y"
1275 ADD_OP(OP_SUB); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-2].sym);
1277 break;
1278 case 24:
1279 #line 163 "parse.y"
1281 ADD_OP(OP_MUL); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-2].sym);
1283 break;
1284 case 25:
1285 #line 166 "parse.y"
1287 ADD_OP(OP_DIV); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-2].sym);
1289 break;
1290 case 26:
1291 #line 169 "parse.y"
1293 ADD_OP(OP_MOD); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-2].sym);
1295 break;
1296 case 27:
1297 #line 172 "parse.y"
1299 ADD_OP(OP_BIT_AND); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-2].sym);
1301 break;
1302 case 28:
1303 #line 175 "parse.y"
1305 ADD_OP(OP_BIT_OR); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-2].sym);
1307 break;
1308 case 29:
1309 #line 178 "parse.y"
1311 ADD_OP(OP_ARRAY_DELETE); ADD_IMMED((void *)yyvsp[-1].nArgs);
1313 break;
1314 case 30:
1315 #line 181 "parse.y"
1317 ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED((void *)yyvsp[-3].nArgs);
1319 break;
1320 case 31:
1321 #line 184 "parse.y"
1323 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED((void *)1); ADD_IMMED((void *)yyvsp[-3].nArgs);
1324 ADD_OP(OP_ADD);
1325 ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED((void *)yyvsp[-3].nArgs);
1327 break;
1328 case 32:
1329 #line 189 "parse.y"
1331 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED((void *)1); ADD_IMMED((void *)yyvsp[-3].nArgs);
1332 ADD_OP(OP_SUB);
1333 ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED((void *)yyvsp[-3].nArgs);
1335 break;
1336 case 33:
1337 #line 194 "parse.y"
1339 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED((void *)1); ADD_IMMED((void *)yyvsp[-3].nArgs);
1340 ADD_OP(OP_MUL);
1341 ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED((void *)yyvsp[-3].nArgs);
1343 break;
1344 case 34:
1345 #line 199 "parse.y"
1347 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED((void *)1); ADD_IMMED((void *)yyvsp[-3].nArgs);
1348 ADD_OP(OP_DIV);
1349 ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED((void *)yyvsp[-3].nArgs);
1351 break;
1352 case 35:
1353 #line 204 "parse.y"
1355 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED((void *)1); ADD_IMMED((void *)yyvsp[-3].nArgs);
1356 ADD_OP(OP_MOD);
1357 ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED((void *)yyvsp[-3].nArgs);
1359 break;
1360 case 36:
1361 #line 209 "parse.y"
1363 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED((void *)1); ADD_IMMED((void *)yyvsp[-3].nArgs);
1364 ADD_OP(OP_BIT_AND);
1365 ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED((void *)yyvsp[-3].nArgs);
1367 break;
1368 case 37:
1369 #line 214 "parse.y"
1371 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED((void *)1); ADD_IMMED((void *)yyvsp[-3].nArgs);
1372 ADD_OP(OP_BIT_OR);
1373 ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED((void *)yyvsp[-3].nArgs);
1375 break;
1376 case 38:
1377 #line 219 "parse.y"
1379 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED((void *)0); ADD_IMMED((void *)yyvsp[-2].nArgs);
1380 ADD_OP(OP_INCR);
1381 ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED((void *)yyvsp[-2].nArgs);
1383 break;
1384 case 39:
1385 #line 224 "parse.y"
1387 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED((void *)0); ADD_IMMED((void *)yyvsp[-2].nArgs);
1388 ADD_OP(OP_DECR);
1389 ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED((void *)yyvsp[-2].nArgs);
1391 break;
1392 case 40:
1393 #line 229 "parse.y"
1395 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED((void *)0); ADD_IMMED((void *)yyvsp[-1].nArgs);
1396 ADD_OP(OP_INCR);
1397 ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED((void *)yyvsp[-1].nArgs);
1399 break;
1400 case 41:
1401 #line 234 "parse.y"
1403 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED((void *)0); ADD_IMMED((void *)yyvsp[-1].nArgs);
1404 ADD_OP(OP_DECR);
1405 ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED((void *)yyvsp[-1].nArgs);
1407 break;
1408 case 42:
1409 #line 239 "parse.y"
1411 ADD_OP(OP_SUBR_CALL);
1412 ADD_SYM(PromoteToGlobal(yyvsp[-3].sym)); ADD_IMMED((void *)yyvsp[-1].nArgs);
1414 break;
1415 case 43:
1416 #line 243 "parse.y"
1418 ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[0].sym); ADD_OP(OP_INCR);
1419 ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[0].sym);
1421 break;
1422 case 44:
1423 #line 247 "parse.y"
1425 ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[-1].sym); ADD_OP(OP_INCR);
1426 ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-1].sym);
1428 break;
1429 case 45:
1430 #line 251 "parse.y"
1432 ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[0].sym); ADD_OP(OP_DECR);
1433 ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[0].sym);
1435 break;
1436 case 46:
1437 #line 255 "parse.y"
1439 ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[-1].sym); ADD_OP(OP_DECR);
1440 ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-1].sym);
1442 break;
1443 case 47:
1444 #line 260 "parse.y"
1446 yyval.sym = yyvsp[0].sym; ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[0].sym);
1448 break;
1449 case 48:
1450 #line 264 "parse.y"
1452 yyval.inst = GetPC();
1454 break;
1455 case 49:
1456 #line 267 "parse.y"
1458 yyval.inst = GetPC();
1460 break;
1461 case 50:
1462 #line 270 "parse.y"
1464 yyval.inst = GetPC();
1466 break;
1467 case 51:
1468 #line 274 "parse.y"
1470 yyval.nArgs = 0;
1472 break;
1473 case 52:
1474 #line 277 "parse.y"
1476 yyval.nArgs = 1;
1478 break;
1479 case 53:
1480 #line 280 "parse.y"
1482 yyval.nArgs = yyvsp[-2].nArgs + 1;
1484 break;
1485 case 55:
1486 #line 285 "parse.y"
1488 ADD_OP(OP_CONCAT);
1490 break;
1491 case 56:
1492 #line 289 "parse.y"
1494 ADD_OP(OP_PUSH_ARRAY_SYM); ADD_SYM(yyvsp[0].sym); ADD_IMMED((void *)1);
1496 break;
1497 case 57:
1498 #line 292 "parse.y"
1500 ADD_OP(OP_ARRAY_REF); ADD_IMMED((void *)yyvsp[-1].nArgs);
1502 break;
1503 case 58:
1504 #line 296 "parse.y"
1506 ADD_OP(OP_PUSH_ARRAY_SYM); ADD_SYM(yyvsp[0].sym); ADD_IMMED((void *)0);
1508 break;
1509 case 59:
1510 #line 299 "parse.y"
1512 ADD_OP(OP_ARRAY_REF); ADD_IMMED((void *)yyvsp[-1].nArgs);
1514 break;
1515 case 60:
1516 #line 303 "parse.y"
1518 yyval.inst = GetPC();
1520 break;
1521 case 61:
1522 #line 307 "parse.y"
1524 ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[0].sym);
1526 break;
1527 case 62:
1528 #line 310 "parse.y"
1530 ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[0].sym);
1532 break;
1533 case 63:
1534 #line 313 "parse.y"
1536 ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[0].sym);
1538 break;
1539 case 64:
1540 #line 316 "parse.y"
1542 ADD_OP(OP_SUBR_CALL);
1543 ADD_SYM(PromoteToGlobal(yyvsp[-3].sym)); ADD_IMMED((void *)yyvsp[-1].nArgs);
1544 ADD_OP(OP_FETCH_RET_VAL);
1546 break;
1547 case 66:
1548 #line 322 "parse.y"
1550 ADD_OP(OP_ARRAY_REF); ADD_IMMED((void *)yyvsp[-1].nArgs);
1552 break;
1553 case 67:
1554 #line 325 "parse.y"
1556 ADD_OP(OP_ADD);
1558 break;
1559 case 68:
1560 #line 328 "parse.y"
1562 ADD_OP(OP_SUB);
1564 break;
1565 case 69:
1566 #line 331 "parse.y"
1568 ADD_OP(OP_MUL);
1570 break;
1571 case 70:
1572 #line 334 "parse.y"
1574 ADD_OP(OP_DIV);
1576 break;
1577 case 71:
1578 #line 337 "parse.y"
1580 ADD_OP(OP_MOD);
1582 break;
1583 case 72:
1584 #line 340 "parse.y"
1586 ADD_OP(OP_POWER);
1588 break;
1589 case 73:
1590 #line 343 "parse.y"
1592 ADD_OP(OP_NEGATE);
1594 break;
1595 case 74:
1596 #line 346 "parse.y"
1598 ADD_OP(OP_GT);
1600 break;
1601 case 75:
1602 #line 349 "parse.y"
1604 ADD_OP(OP_GE);
1606 break;
1607 case 76:
1608 #line 352 "parse.y"
1610 ADD_OP(OP_LT);
1612 break;
1613 case 77:
1614 #line 355 "parse.y"
1616 ADD_OP(OP_LE);
1618 break;
1619 case 78:
1620 #line 358 "parse.y"
1622 ADD_OP(OP_EQ);
1624 break;
1625 case 79:
1626 #line 361 "parse.y"
1628 ADD_OP(OP_NE);
1630 break;
1631 case 80:
1632 #line 364 "parse.y"
1634 ADD_OP(OP_BIT_AND);
1636 break;
1637 case 81:
1638 #line 367 "parse.y"
1640 ADD_OP(OP_BIT_OR);
1642 break;
1643 case 82:
1644 #line 370 "parse.y"
1646 ADD_OP(OP_AND); SET_BR_OFF(yyvsp[-1].inst, GetPC());
1648 break;
1649 case 83:
1650 #line 373 "parse.y"
1652 ADD_OP(OP_OR); SET_BR_OFF(yyvsp[-1].inst, GetPC());
1654 break;
1655 case 84:
1656 #line 376 "parse.y"
1658 ADD_OP(OP_NOT);
1660 break;
1661 case 85:
1662 #line 379 "parse.y"
1664 ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[0].sym); ADD_OP(OP_INCR);
1665 ADD_OP(OP_DUP); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[0].sym);
1667 break;
1668 case 86:
1669 #line 383 "parse.y"
1671 ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[-1].sym); ADD_OP(OP_DUP);
1672 ADD_OP(OP_INCR); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-1].sym);
1674 break;
1675 case 87:
1676 #line 387 "parse.y"
1678 ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[0].sym); ADD_OP(OP_DECR);
1679 ADD_OP(OP_DUP); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[0].sym);
1681 break;
1682 case 88:
1683 #line 391 "parse.y"
1685 ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[-1].sym); ADD_OP(OP_DUP);
1686 ADD_OP(OP_DECR); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-1].sym);
1688 break;
1689 case 89:
1690 #line 395 "parse.y"
1692 ADD_OP(OP_IN_ARRAY);
1694 break;
1695 case 90:
1696 #line 399 "parse.y"
1698 yyval.inst = GetPC(); StartLoopAddrList();
1700 break;
1701 case 91:
1702 #line 403 "parse.y"
1704 StartLoopAddrList(); yyval.inst = GetPC();
1706 break;
1707 case 92:
1708 #line 407 "parse.y"
1710 ADD_OP(OP_BRANCH); yyval.inst = GetPC(); ADD_BR_OFF(0);
1712 break;
1713 case 93:
1714 #line 411 "parse.y"
1716 ADD_OP(OP_BRANCH_NEVER); yyval.inst = GetPC(); ADD_BR_OFF(0);
1718 break;
1719 case 94:
1720 #line 414 "parse.y"
1722 ADD_OP(OP_BRANCH_FALSE); yyval.inst = GetPC(); ADD_BR_OFF(0);
1724 break;
1725 case 95:
1726 #line 418 "parse.y"
1728 ADD_OP(OP_DUP); ADD_OP(OP_BRANCH_FALSE); yyval.inst = GetPC();
1729 ADD_BR_OFF(0);
1731 break;
1732 case 96:
1733 #line 423 "parse.y"
1735 ADD_OP(OP_DUP); ADD_OP(OP_BRANCH_TRUE); yyval.inst = GetPC();
1736 ADD_BR_OFF(0);
1738 break;
1739 #line 1736 "y.tab.c"
1741 yyssp -= yym;
1742 yystate = *yyssp;
1743 yyvsp -= yym;
1744 yym = yylhs[yyn];
1745 if (yystate == 0 && yym == 0)
1747 #if YYDEBUG
1748 if (yydebug)
1749 printf("%sdebug: after reduction, shifting from state 0 to\
1750 state %d\n", YYPREFIX, YYFINAL);
1751 #endif
1752 yystate = YYFINAL;
1753 *++yyssp = YYFINAL;
1754 *++yyvsp = yyval;
1755 if (yychar < 0)
1757 if ((yychar = yylex()) < 0) yychar = 0;
1758 #if YYDEBUG
1759 if (yydebug)
1761 yys = 0;
1762 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
1763 if (!yys) yys = "illegal-symbol";
1764 printf("%sdebug: state %d, reading %d (%s)\n",
1765 YYPREFIX, YYFINAL, yychar, yys);
1767 #endif
1769 if (yychar == 0) goto yyaccept;
1770 goto yyloop;
1772 if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
1773 yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
1774 yystate = yytable[yyn];
1775 else
1776 yystate = yydgoto[yym];
1777 #if YYDEBUG
1778 if (yydebug)
1779 printf("%sdebug: after reduction, shifting from state %d \
1780 to state %d\n", YYPREFIX, *yyssp, yystate);
1781 #endif
1782 if (yyssp >= yysslim && yygrowstack())
1784 goto yyoverflow;
1786 *++yyssp = yystate;
1787 *++yyvsp = yyval;
1788 goto yyloop;
1789 yyoverflow:
1790 yyerror("yacc stack overflow");
1791 yyabort:
1792 return (1);
1793 yyaccept:
1794 return (0);