Revive upgrade message to 5.4 file format
[nedit.git] / source / parse_noyacc.c
blob57454974ad09744482fd666da209119bde095939
2 # line 3 "parse.y"
3 #include <string.h>
4 #include <stdio.h>
5 #include <ctype.h>
6 #include <X11/Intrinsic.h>
7 #include <Xm/Xm.h>
8 #ifdef VMS
9 #include "../util/VMSparam.h"
10 #else
11 #ifndef __MVS__
12 #include <sys/param.h>
13 #endif
14 #endif /*VMS*/
16 #include "textBuf.h"
17 #include "nedit.h"
18 #include "interpret.h"
19 #include "parse.h"
21 /* Macros to add error processing to AddOp and AddSym calls */
22 #define ADD_OP(op) if (!AddOp(op, &ErrMsg)) return 1
23 #define ADD_SYM(sym) if (!AddSym(sym, &ErrMsg)) return 1
24 #define ADD_IMMED(val) if (!AddImmediate(val, &ErrMsg)) return 1
25 #define ADD_BR_OFF(to) if (!AddBranchOffset(to, &ErrMsg)) return 1
26 #define SET_BR_OFF(from, to) *((int *)(from)) = ((Inst *)(to)) - ((Inst *)(from))
28 /* Max. length for a string constant (... there shouldn't be a maximum) */
29 #define MAX_STRING_CONST_LEN 5000
31 static const char CVSID[] = "$Id: parse_noyacc.c,v 1.3 2002/07/11 21:18:10 slobasso Exp $";
32 static int yyerror(char *s);
33 static int yylex(void);
34 int yyparse(void);
35 static int follow(char expect, int yes, int no);
36 static int follow2(char expect1, int yes1, char expect2, int yes2, int no);
37 static int follow_non_whitespace(char expect, int yes, int no);
38 static Symbol *matchesActionRoutine(char **inPtr);
40 static char *ErrMsg;
41 static char *InPtr;
42 extern Inst *LoopStack[]; /* addresses of break, cont stmts */
43 extern Inst **LoopStackPtr; /* to fill at the end of a loop */
46 # line 48 "parse.y"
47 typedef union {
48 Symbol *sym;
49 Inst *inst;
50 int nArgs;
51 } YYSTYPE;
52 # define NUMBER 257
53 # define STRING 258
54 # define SYMBOL 259
55 # define IF 260
56 # define WHILE 261
57 # define ELSE 262
58 # define FOR 263
59 # define BREAK 264
60 # define CONTINUE 265
61 # define RETURN 266
62 # define IF_NO_ELSE 267
63 # define ADDEQ 268
64 # define SUBEQ 269
65 # define MULEQ 270
66 # define DIVEQ 271
67 # define MODEQ 272
68 # define ANDEQ 273
69 # define OREQ 274
70 # define CONCAT 275
71 # define OR 276
72 # define AND 277
73 # define GT 278
74 # define GE 279
75 # define LT 280
76 # define LE 281
77 # define EQ 282
78 # define NE 283
79 # define IN 284
80 # define UNARY_MINUS 285
81 # define NOT 286
82 # define DELETE 287
83 # define INCR 288
84 # define DECR 289
85 # define POW 290
86 #define yyclearin yychar = -1
87 #define yyerrok yyerrflag = 0
88 extern int yychar;
89 extern int yyerrflag;
90 #ifndef YYMAXDEPTH
91 #define YYMAXDEPTH 150
92 #endif
93 YYSTYPE yylval, yyval;
94 typedef int yytabelem;
95 # define YYERRCODE 256
97 # line 256 "parse.y"
98 /* User Subroutines Section */
102 ** Parse a null terminated string and create a program from it (this is the
103 ** parser entry point). The program created by this routine can be
104 ** executed using ExecuteProgram. Returns program on success, or NULL
105 ** on failure. If the command failed, the error message is returned
106 ** as a pointer to a static string in msg, and the length of the string up
107 ** to where parsing failed in stoppedAt.
109 Program *ParseMacro(char *expr, char **msg, char **stoppedAt)
111 Program *prog;
113 BeginCreatingProgram();
115 /* call yyparse to parse the string and check for success. If the parse
116 failed, return the error message and string index (the grammar aborts
117 parsing at the first error) */
118 InPtr = expr;
119 if (yyparse()) {
120 *msg = ErrMsg;
121 *stoppedAt = InPtr;
122 FreeProgram(FinishCreatingProgram());
123 return NULL;
126 /* get the newly created program */
127 prog = FinishCreatingProgram();
129 /* parse succeeded */
130 *msg = "";
131 *stoppedAt = InPtr;
132 return prog;
136 static int yylex(void)
138 int i, len;
139 Symbol *s;
140 static int stringConstIndex = 0;
141 static DataValue value = {0, {0}};
142 static char escape[] = "\\\"ntbrfav";
143 static char replace[] = "\\\"\n\t\b\r\f\a\v";
145 /* skip whitespace and backslash-newline combinations which are
146 also considered whitespace */
147 for (;;) {
148 if (*InPtr == '\\' && *(InPtr + 1) == '\n')
149 InPtr += 2;
150 else if (*InPtr == ' ' || *InPtr == '\t')
151 InPtr++;
152 else
153 break;
156 /* skip comments */
157 if (*InPtr == '#')
158 while (*InPtr != '\n' && *InPtr != '\0') InPtr++;
160 /* return end of input at the end of the string */
161 if (*InPtr == '\0') {
162 return 0;
165 /* process number tokens */
166 if (isdigit((unsigned char)*InPtr)) { /* number */
167 char name[28];
168 sscanf(InPtr, "%d%n", &value.val.n, &len);
169 sprintf(name, "const %d", value.val.n);
170 InPtr += len;
171 value.tag = INT_TAG;
172 if ((yylval.sym=LookupSymbol(name)) == NULL)
173 yylval.sym = InstallSymbol(name, CONST_SYM, value);
174 return NUMBER;
177 /* process symbol tokens. "define" is a special case not handled
178 by this parser, considered end of input. Another special case
179 is action routine names which are allowed to contain '-' despite
180 the ambiguity, handled in matchesActionRoutine. */
181 if (isalpha((unsigned char)*InPtr) || *InPtr == '$') {
182 if ((s=matchesActionRoutine(&InPtr)) == NULL) {
183 char symName[MAX_SYM_LEN+1], *p = symName;
184 *p++ = *InPtr++;
185 while (isalnum((unsigned char)*InPtr) || *InPtr=='_') {
186 if (p >= symName + MAX_SYM_LEN)
187 InPtr++;
188 else
189 *p++ = *InPtr++;
191 *p = '\0';
192 if (!strcmp(symName, "while")) return WHILE;
193 if (!strcmp(symName, "if")) return IF;
194 if (!strcmp(symName, "else")) return ELSE;
195 if (!strcmp(symName, "for")) return FOR;
196 if (!strcmp(symName, "break")) return BREAK;
197 if (!strcmp(symName, "continue")) return CONTINUE;
198 if (!strcmp(symName, "return")) return RETURN;
199 if (!strcmp(symName, "in")) return IN;
200 if (!strcmp(symName, "delete") && follow_non_whitespace('(', SYMBOL, DELETE) == DELETE) return DELETE;
201 if (!strcmp(symName, "define")) {
202 InPtr -= 6;
203 return 0;
205 if ((s=LookupSymbol(symName)) == NULL) {
206 s = InstallSymbol(symName, symName[0]=='$' ?
207 (isdigit((unsigned char)symName[1]) ?
208 ARG_SYM : GLOBAL_SYM) : LOCAL_SYM, value);
209 s->value.tag = NO_TAG;
212 yylval.sym = s;
213 return SYMBOL;
216 /* process quoted strings w/ embedded escape sequences */
217 if (*InPtr == '\"') {
218 char string[MAX_STRING_CONST_LEN], *p = string;
219 char stringName[25];
220 InPtr++;
221 while (*InPtr != '\0' && *InPtr != '\"' && *InPtr != '\n') {
222 if (p >= string + MAX_STRING_CONST_LEN) {
223 InPtr++;
224 continue;
226 if (*InPtr == '\\') {
227 InPtr++;
228 if (*InPtr == '\n') {
229 InPtr++;
230 continue;
232 for (i=0; escape[i]!='\0'; i++) {
233 if (escape[i] == '\0') {
234 *p++= *InPtr++;
235 break;
236 } else if (escape[i] == *InPtr) {
237 *p++ = replace[i];
238 InPtr++;
239 break;
242 } else
243 *p++= *InPtr++;
245 *p = '\0';
246 InPtr++;
247 if ((yylval.sym = LookupStringConstSymbol(string)) == NULL) {
248 value.val.str = AllocString(p-string+1);
249 strcpy(value.val.str, string);
250 value.tag = STRING_TAG;
251 sprintf(stringName, "string #%d", stringConstIndex++);
252 yylval.sym = InstallSymbol(stringName, CONST_SYM, value);
254 return STRING;
257 /* process remaining two character tokens or return single char as token */
258 switch(*InPtr++) {
259 case '>': return follow('=', GE, GT);
260 case '<': return follow('=', LE, LT);
261 case '=': return follow('=', EQ, '=');
262 case '!': return follow('=', NE, NOT);
263 case '+': return follow2('+', INCR, '=', ADDEQ, '+');
264 case '-': return follow2('-', DECR, '=', SUBEQ, '-');
265 case '|': return follow2('|', OR, '=', OREQ, '|');
266 case '&': return follow2('&', AND, '=', ANDEQ, '&');
267 case '*': return follow2('*', POW, '=', MULEQ, '*');
268 case '/': return follow('=', DIVEQ, '/');
269 case '%': return follow('=', MODEQ, '%');
270 case '^': return POW;
271 default: return *(InPtr-1);
276 ** look ahead for >=, etc.
278 static int follow(char expect, int yes, int no)
280 if (*InPtr++ == expect)
281 return yes;
282 InPtr--;
283 return no;
285 static int follow2(char expect1, int yes1, char expect2, int yes2, int no)
287 char next = *InPtr++;
288 if (next == expect1)
289 return yes1;
290 if (next == expect2)
291 return yes2;
292 InPtr--;
293 return no;
296 static int follow_non_whitespace(char expect, int yes, int no)
298 char *localInPtr = InPtr;
300 while (1) {
301 if (*localInPtr == ' ' || *localInPtr == '\t') {
302 ++localInPtr;
304 else if (*localInPtr == '\\' && *(localInPtr + 1) == '\n') {
305 localInPtr += 2;
307 else if (*localInPtr == expect) {
308 return(yes);
310 else {
311 return(no);
317 ** Look (way) ahead for hyphenated routine names which begin at inPtr. A
318 ** hyphenated name is allowed if it is pre-defined in the global symbol
319 ** table. If a matching name exists, returns the symbol, and update "inPtr".
321 ** I know this is horrible language design, but existing nedit action routine
322 ** names contain hyphens. Handling them here in the lexical analysis process
323 ** is much easier than trying to deal with it in the parser itself. (sorry)
325 static Symbol *matchesActionRoutine(char **inPtr)
327 char *c, *symPtr;
328 int hasDash = False;
329 char symbolName[MAX_SYM_LEN+1];
330 Symbol *s;
332 symPtr = symbolName;
333 for (c = *inPtr; isalnum((unsigned char)*c) || *c=='_' ||
334 ( *c=='-' && isalnum((unsigned char)(*(c+1)))); c++) {
335 if (*c == '-')
336 hasDash = True;
337 *symPtr++ = *c;
339 if (!hasDash)
340 return NULL;
341 *symPtr = '\0';
342 s = LookupSymbol(symbolName);
343 if (s != NULL)
344 *inPtr = c;
345 return s;
349 ** Called by yacc to report errors (just stores for returning when
350 ** parsing is aborted. The error token action is to immediate abort
351 ** parsing, so this message is immediately reported to the caller
352 ** of ParseExpr)
354 static int yyerror(char *s)
356 ErrMsg = s;
357 return 0;
359 static const yytabelem yyexca[] ={
360 -1, 1,
361 0, -1,
362 -2, 0,
363 -1, 137,
364 269, 33,
365 270, 35,
366 271, 37,
367 272, 39,
368 273, 41,
369 274, 43,
370 -2, 31,
372 # define YYNPROD 97
373 # define YYLAST 652
374 static const yytabelem yyact[]={
376 75, 83, 190, 70, 171, 73, 71, 170, 72, 169,
377 74, 168, 110, 167, 75, 83, 36, 136, 166, 73,
378 71, 37, 72, 165, 74, 173, 75, 75, 83, 145,
379 97, 73, 73, 71, 96, 72, 74, 74, 55, 54,
380 75, 83, 15, 53, 3, 73, 71, 8, 72, 4,
381 74, 62, 109, 75, 70, 43, 63, 148, 73, 71,
382 6, 72, 138, 74, 138, 162, 138, 114, 70, 6,
383 17, 18, 19, 56, 163, 64, 41, 6, 112, 111,
384 70, 70, 113, 59, 17, 18, 19, 84, 27, 26,
385 155, 15, 9, 20, 70, 21, 12, 13, 14, 187,
386 25, 84, 114, 6, 67, 29, 42, 70, 6, 147,
387 61, 157, 138, 146, 84, 137, 99, 75, 90, 17,
388 18, 19, 73, 71, 31, 72, 139, 74, 154, 138,
389 28, 24, 153, 152, 36, 151, 15, 9, 20, 37,
390 21, 12, 13, 14, 150, 149, 15, 9, 20, 43,
391 21, 12, 13, 14, 36, 176, 1, 16, 36, 37,
392 101, 86, 144, 37, 17, 18, 19, 85, 172, 10,
393 41, 70, 11, 159, 17, 18, 19, 46, 47, 48,
394 49, 50, 51, 52, 186, 0, 0, 117, 0, 0,
395 0, 0, 57, 160, 0, 0, 7, 143, 22, 0,
396 42, 0, 76, 0, 0, 0, 158, 135, 0, 0,
397 64, 0, 0, 0, 175, 0, 0, 7, 0, 0,
398 0, 5, 0, 0, 185, 0, 140, 0, 0, 0,
399 0, 0, 0, 33, 34, 35, 0, 0, 0, 89,
400 88, 77, 78, 79, 80, 81, 82, 87, 0, 0,
401 22, 0, 0, 76, 88, 77, 78, 79, 80, 81,
402 82, 87, 38, 0, 39, 40, 0, 76, 77, 78,
403 79, 80, 81, 82, 87, 0, 0, 0, 0, 76,
404 76, 77, 78, 79, 80, 81, 82, 87, 0, 0,
405 0, 0, 0, 76, 77, 78, 79, 80, 81, 82,
406 87, 0, 0, 44, 45, 0, 76, 0, 0, 15,
407 9, 20, 0, 21, 12, 13, 14, 0, 15, 9,
408 20, 0, 21, 12, 13, 14, 15, 9, 20, 0,
409 21, 12, 13, 14, 0, 0, 0, 17, 18, 19,
410 0, 0, 0, 0, 0, 0, 17, 18, 19, 161,
411 0, 33, 34, 35, 17, 18, 19, 15, 9, 20,
412 0, 21, 12, 13, 14, 0, 91, 92, 7, 0,
413 76, 33, 34, 35, 0, 33, 34, 35, 0, 22,
414 38, 0, 39, 40, 32, 17, 18, 19, 0, 0,
415 0, 189, 0, 115, 0, 193, 0, 44, 45, 195,
416 38, 0, 39, 40, 38, 0, 39, 40, 0, 0,
417 60, 60, 2, 0, 0, 68, 0, 0, 23, 0,
418 0, 0, 94, 95, 0, 0, 0, 0, 0, 0,
419 0, 0, 0, 0, 0, 0, 0, 58, 0, 0,
420 0, 65, 66, 0, 69, 0, 0, 0, 0, 0,
421 0, 0, 0, 0, 0, 0, 118, 119, 120, 121,
422 122, 123, 124, 125, 126, 127, 128, 129, 130, 131,
423 132, 133, 134, 0, 0, 0, 0, 0, 68, 100,
424 116, 0, 0, 68, 0, 68, 0, 68, 68, 68,
425 68, 68, 68, 68, 30, 0, 0, 0, 60, 0,
426 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
427 0, 0, 0, 0, 0, 0, 93, 0, 0, 0,
428 0, 98, 0, 0, 141, 142, 102, 103, 104, 105,
429 106, 107, 108, 0, 0, 0, 0, 0, 0, 0,
430 0, 68, 0, 0, 0, 0, 0, 0, 0, 68,
431 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
432 0, 0, 68, 68, 68, 68, 68, 68, 68, 0,
433 0, 0, 174, 0, 0, 0, 0, 0, 0, 0,
434 0, 0, 0, 0, 0, 184, 0, 0, 0, 188,
435 0, 0, 0, 0, 0, 0, 0, 0, 0, 191,
436 192, 0, 0, 194, 0, 0, 0, 0, 0, 0,
437 0, 0, 0, 0, 0, 0, 0, 0, 156, 0,
438 0, 0, 0, 0, 0, 0, 0, 0, 164, 0,
439 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
440 0, 0, 0, 0, 0, 177, 178, 179, 180, 181,
441 182, 183 };
442 static const yytabelem yypact[]={
444 -212, -1000, 98, -1000, -168, -1000, -1000, -1000, 121, 60,
445 49, 48, 120, 95, 114, 15, -91, -216, -220, -221,
446 -1000, -1000, -1000, 67, -1000, 118, 118, -203, -1000, -1000,
447 94, -1000, -37, -1000, -1000, 78, 118, 118, 118, -225,
448 -229, 118, 118, 118, -1000, -1000, 118, 118, 118, 118,
449 118, 118, 118, -39, -1000, -1000, -113, -1000, 93, 38,
450 -37, 37, 23, 109, -1000, 93, 93, -1000, -37, 93,
451 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
452 118, 118, 118, 118, 118, 118, 118, 118, -1000, -1000,
453 118, -1000, -1000, -24, -88, -88, -1000, -1000, 118, 22,
454 118, 85, 118, 118, 118, 118, 118, 118, 118, 118,
455 -1000, -1000, -1000, 118, -217, -230, 93, 20, -11, -11,
456 -88, -88, -88, -88, 80, 80, 80, 80, 80, 80,
457 16, 3, -10, -23, 80, 68, -1000, -4, 118, -1000,
458 18, 50, 50, 6, -1000, 33, -1000, -1000, 118, -245,
459 -251, -257, -260, -263, -266, -270, 118, -1000, -237, -1000,
460 -1000, -1000, -217, -1000, 118, 118, 118, 118, 118, 118,
461 118, 118, -1000, -1000, 59, 58, -1000, 118, 118, 118,
462 118, 118, 118, 118, 50, -123, -1000, -1000, 50, -1000,
463 -1000, 93, 50, -1000, 93, -1000 };
464 static const yytabelem yypgo[]={
466 0, 116, 83, 51, 172, 169, 168, 167, 161, 157,
467 156, 412, 49, 206, 193, 47, 155, 479, 145, 144,
468 135, 133, 132, 128, 90, 384 };
469 static const yytabelem yyr1[]={
471 0, 10, 10, 10, 10, 13, 13, 13, 12, 12,
472 14, 14, 14, 14, 14, 16, 14, 14, 14, 14,
473 14, 15, 15, 15, 15, 15, 15, 15, 15, 15,
474 15, 18, 15, 19, 15, 20, 15, 21, 15, 22,
475 15, 23, 15, 24, 15, 15, 15, 15, 15, 15,
476 9, 3, 3, 3, 1, 1, 1, 17, 17, 25,
477 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
478 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
479 25, 25, 25, 25, 25, 25, 25, 25, 5, 4,
480 6, 2, 2, 7, 8, 11, 11 };
481 static const yytabelem yyr2[]={
483 0, 5, 11, 9, 3, 10, 8, 2, 2, 4,
484 6, 13, 19, 13, 21, 1, 19, 7, 7, 9,
485 7, 7, 7, 7, 7, 7, 7, 7, 7, 11,
486 13, 1, 15, 1, 15, 1, 15, 1, 15, 1,
487 15, 1, 15, 1, 15, 9, 5, 5, 5, 5,
488 3, 1, 3, 7, 1, 3, 7, 2, 5, 3,
489 3, 3, 9, 6, 9, 7, 7, 7, 7, 7,
490 7, 5, 7, 7, 7, 7, 7, 7, 7, 7,
491 7, 7, 5, 5, 5, 5, 5, 7, 3, 3,
492 3, 1, 3, 3, 3, 0, 4 };
493 static const yytabelem yychk[]={
495 -1000, -10, -11, 256, -12, 123, 10, -14, -15, 260,
496 -5, -4, 264, 265, 266, 259, -9, 287, 288, 289,
497 261, 263, -14, -11, 10, 40, 40, 40, 10, 10,
498 -17, 10, -25, 257, 258, 259, 40, 45, 286, 288,
499 289, 61, 91, 40, 288, 289, 268, 269, 270, 271,
500 272, 273, 274, 259, 259, 259, -12, 125, -11, -2,
501 -25, -2, -3, 259, -15, -11, -11, 10, -25, -11,
502 91, 43, 45, 42, 47, 37, 290, 278, 279, 280,
503 281, 282, 283, 38, 124, -7, -8, 284, 277, 276,
504 40, 288, 289, -17, -25, -25, 259, 259, -17, -1,
505 -17, -1, -17, -17, -17, -17, -17, -17, -17, 91,
506 125, 41, 41, 59, 44, 284, -11, -1, -25, -25,
507 -25, -25, -25, -25, -25, -25, -25, -25, -25, -25,
508 -25, -25, -25, -25, -25, -1, 41, 93, 44, 41,
509 -1, -11, -11, -2, -15, 259, 93, 41, 61, -18,
510 -19, -20, -21, -22, -23, -24, -17, 93, -13, 123,
511 -14, -13, 59, 41, -17, 268, 269, 270, 271, 272,
512 273, 274, -6, 262, -11, -3, -16, -17, -17, -17,
513 -17, -17, -17, -17, -11, -12, 125, 41, -11, -13,
514 125, -11, -11, -13, -11, -13 };
515 static const yytabelem yydef[]={
517 95, -2, 0, 4, 1, 95, 96, 8, 0, 0,
518 0, 0, 0, 0, 0, 50, 0, 0, 0, 0,
519 88, 89, 9, 0, 95, 91, 91, 51, 95, 95,
520 0, 95, 57, 59, 60, 61, 0, 0, 0, 0,
521 0, 0, 54, 54, 47, 49, 0, 0, 0, 0,
522 0, 0, 0, 0, 46, 48, 0, 3, 10, 0,
523 92, 0, 0, 50, 52, 17, 18, 95, 58, 20,
524 54, 0, 0, 0, 0, 0, 0, 0, 0, 0,
525 0, 0, 0, 0, 0, 0, 0, 0, 93, 94,
526 54, 84, 86, 0, 71, 82, 83, 85, 21, 0,
527 55, 0, 22, 23, 24, 25, 26, 27, 28, 54,
528 2, 95, 95, 91, 0, 0, 19, 0, 65, 66,
529 67, 68, 69, 70, 72, 73, 74, 75, 76, 77,
530 78, 79, 80, 81, 87, 0, 63, -2, 0, 45,
531 0, 0, 0, 0, 53, 0, 64, 62, 0, 0,
532 0, 0, 0, 0, 0, 0, 56, 29, 11, 95,
533 7, 13, 51, 15, 30, 0, 0, 0, 0, 0,
534 0, 0, 95, 90, 0, 0, 95, 32, 34, 36,
535 38, 40, 42, 44, 0, 0, 95, 95, 0, 12,
536 95, 6, 0, 16, 5, 14 };
537 typedef struct { char *t_name; int t_val; } yytoktype;
538 #ifndef YYDEBUG
539 # define YYDEBUG 0 /* don't allow debugging */
540 #endif
542 #if YYDEBUG
544 yytoktype yytoks[] =
546 "NUMBER", 257,
547 "STRING", 258,
548 "SYMBOL", 259,
549 "IF", 260,
550 "WHILE", 261,
551 "ELSE", 262,
552 "FOR", 263,
553 "BREAK", 264,
554 "CONTINUE", 265,
555 "RETURN", 266,
556 "IF_NO_ELSE", 267,
557 "=", 61,
558 "ADDEQ", 268,
559 "SUBEQ", 269,
560 "MULEQ", 270,
561 "DIVEQ", 271,
562 "MODEQ", 272,
563 "ANDEQ", 273,
564 "OREQ", 274,
565 "CONCAT", 275,
566 "OR", 276,
567 "AND", 277,
568 "|", 124,
569 "&", 38,
570 "GT", 278,
571 "GE", 279,
572 "LT", 280,
573 "LE", 281,
574 "EQ", 282,
575 "NE", 283,
576 "IN", 284,
577 "+", 43,
578 "-", 45,
579 "*", 42,
580 "/", 47,
581 "%", 37,
582 "UNARY_MINUS", 285,
583 "NOT", 286,
584 "DELETE", 287,
585 "INCR", 288,
586 "DECR", 289,
587 "POW", 290,
588 "[", 91,
589 "(", 40,
590 "-unknown-", -1 /* ends search */
593 char * yyreds[] =
595 "-no such reduction-",
596 "program : blank stmts",
597 "program : blank '{' blank stmts '}'",
598 "program : blank '{' blank '}'",
599 "program : error",
600 "block : '{' blank stmts '}' blank",
601 "block : '{' blank '}' blank",
602 "block : stmt",
603 "stmts : stmt",
604 "stmts : stmts stmt",
605 "stmt : simpstmt '\n' blank",
606 "stmt : IF '(' cond ')' blank block",
607 "stmt : IF '(' cond ')' blank block else blank block",
608 "stmt : while '(' cond ')' blank block",
609 "stmt : for '(' comastmts ';' cond ';' comastmts ')' blank block",
610 "stmt : for '(' SYMBOL IN SYMBOL ')'",
611 "stmt : for '(' SYMBOL IN SYMBOL ')' blank block",
612 "stmt : BREAK '\n' blank",
613 "stmt : CONTINUE '\n' blank",
614 "stmt : RETURN expr '\n' blank",
615 "stmt : RETURN '\n' blank",
616 "simpstmt : SYMBOL '=' expr",
617 "simpstmt : evalsym ADDEQ expr",
618 "simpstmt : evalsym SUBEQ expr",
619 "simpstmt : evalsym MULEQ expr",
620 "simpstmt : evalsym DIVEQ expr",
621 "simpstmt : evalsym MODEQ expr",
622 "simpstmt : evalsym ANDEQ expr",
623 "simpstmt : evalsym OREQ expr",
624 "simpstmt : DELETE SYMBOL '[' arglist ']'",
625 "simpstmt : SYMBOL '[' arglist ']' '=' expr",
626 "simpstmt : SYMBOL '[' arglist ']'",
627 "simpstmt : SYMBOL '[' arglist ']' ADDEQ expr",
628 "simpstmt : SYMBOL '[' arglist ']'",
629 "simpstmt : SYMBOL '[' arglist ']' SUBEQ expr",
630 "simpstmt : SYMBOL '[' arglist ']'",
631 "simpstmt : SYMBOL '[' arglist ']' MULEQ expr",
632 "simpstmt : SYMBOL '[' arglist ']'",
633 "simpstmt : SYMBOL '[' arglist ']' DIVEQ expr",
634 "simpstmt : SYMBOL '[' arglist ']'",
635 "simpstmt : SYMBOL '[' arglist ']' MODEQ expr",
636 "simpstmt : SYMBOL '[' arglist ']'",
637 "simpstmt : SYMBOL '[' arglist ']' ANDEQ expr",
638 "simpstmt : SYMBOL '[' arglist ']'",
639 "simpstmt : SYMBOL '[' arglist ']' OREQ expr",
640 "simpstmt : SYMBOL '(' arglist ')'",
641 "simpstmt : INCR SYMBOL",
642 "simpstmt : SYMBOL INCR",
643 "simpstmt : DECR SYMBOL",
644 "simpstmt : SYMBOL DECR",
645 "evalsym : SYMBOL",
646 "comastmts : /* empty */",
647 "comastmts : simpstmt",
648 "comastmts : comastmts ',' simpstmt",
649 "arglist : /* empty */",
650 "arglist : expr",
651 "arglist : arglist ',' expr",
652 "expr : numexpr",
653 "expr : expr numexpr",
654 "numexpr : NUMBER",
655 "numexpr : STRING",
656 "numexpr : SYMBOL",
657 "numexpr : SYMBOL '(' arglist ')'",
658 "numexpr : '(' expr ')'",
659 "numexpr : numexpr '[' arglist ']'",
660 "numexpr : numexpr '+' numexpr",
661 "numexpr : numexpr '-' numexpr",
662 "numexpr : numexpr '*' numexpr",
663 "numexpr : numexpr '/' numexpr",
664 "numexpr : numexpr '%' numexpr",
665 "numexpr : numexpr POW numexpr",
666 "numexpr : '-' numexpr",
667 "numexpr : numexpr GT numexpr",
668 "numexpr : numexpr GE numexpr",
669 "numexpr : numexpr LT numexpr",
670 "numexpr : numexpr LE numexpr",
671 "numexpr : numexpr EQ numexpr",
672 "numexpr : numexpr NE numexpr",
673 "numexpr : numexpr '&' numexpr",
674 "numexpr : numexpr '|' numexpr",
675 "numexpr : numexpr and numexpr",
676 "numexpr : numexpr or numexpr",
677 "numexpr : NOT numexpr",
678 "numexpr : INCR SYMBOL",
679 "numexpr : SYMBOL INCR",
680 "numexpr : DECR SYMBOL",
681 "numexpr : SYMBOL DECR",
682 "numexpr : numexpr IN numexpr",
683 "while : WHILE",
684 "for : FOR",
685 "else : ELSE",
686 "cond : /* empty */",
687 "cond : numexpr",
688 "and : AND",
689 "or : OR",
690 "blank : /* empty */",
691 "blank : blank '\n'",
693 #endif /* YYDEBUG */
695 * (c) Copyright 1990, OPEN SOFTWARE FOUNDATION, INC.
696 * ALL RIGHTS RESERVED
699 * OSF/1 Release 1.0
701 /* @(#)yaccpar 1.3 com/cmd/lang/yacc,3.1, 9/7/89 18:46:37 */
703 ** Skeleton parser driver for yacc output
707 ** yacc user known macros and defines
709 #ifdef YYSPLIT
710 # define YYERROR return(-2)
711 #else
712 # define YYERROR goto yyerrlab
713 #endif
715 #define YYACCEPT return(0)
716 #define YYABORT return(1)
717 #define YYBACKUP( newtoken, newvalue )\
719 if ( yychar >= 0 || ( yyr2[ yytmp ] >> 1 ) != 1 )\
721 yyerror( "syntax error - cannot backup" );\
722 goto yyerrlab;\
724 yychar = newtoken;\
725 yystate = *yyps;\
726 yylval = newvalue;\
727 goto yynewstate;\
729 #define YYRECOVERING() (!!yyerrflag)
730 #ifndef YYDEBUG
731 # define YYDEBUG 1 /* make debugging available */
732 #endif
735 ** user known globals
737 int yydebug; /* set to 1 to get debugging */
740 ** driver internal defines
742 #define YYFLAG (-1000)
744 #ifdef YYSPLIT
745 # define YYSCODE { \
746 extern int (*yyf[])(); \
747 register int yyret; \
748 if (yyf[yytmp]) \
749 if ((yyret=(*yyf[yytmp])()) == -2) \
750 goto yyerrlab; \
751 else if (yyret>=0) return(yyret); \
753 #endif
756 ** local variables used by the parser
757 * these should be static in order to support
758 * multiple parsers in a single executable program. POSIX 1003.2-1993
760 static YYSTYPE yyv[ YYMAXDEPTH ]; /* value stack */
761 static int yys[ YYMAXDEPTH ]; /* state stack */
763 static YYSTYPE *yypv; /* top of value stack */
764 static YYSTYPE *yypvt; /* top of value stack for $vars */
765 static int *yyps; /* top of state stack */
767 static int yystate; /* current state */
768 static int yytmp; /* extra var (lasts between blocks) */
771 ** global variables used by the parser - renamed as a result of -p
773 int yynerrs; /* number of errors */
774 int yyerrflag; /* error recovery flag */
775 int yychar; /* current input token number */
778 ** yyparse - return 0 if worked, 1 if syntax error not recovered from
781 yyparse()
784 ** Initialize externals - yyparse may be called more than once
786 yypv = &yyv[-1];
787 yyps = &yys[-1];
788 yystate = 0;
789 yytmp = 0;
790 yynerrs = 0;
791 yyerrflag = 0;
792 yychar = -1;
794 goto yystack;
796 register YYSTYPE *yy_pv; /* top of value stack */
797 register int *yy_ps; /* top of state stack */
798 register int yy_state; /* current state */
799 register int yy_n; /* internal state number info */
802 ** get globals into registers.
803 ** branch to here only if YYBACKUP was called.
805 yynewstate:
806 yy_pv = yypv;
807 yy_ps = yyps;
808 yy_state = yystate;
809 goto yy_newstate;
812 ** get globals into registers.
813 ** either we just started, or we just finished a reduction
815 yystack:
816 yy_pv = yypv;
817 yy_ps = yyps;
818 yy_state = yystate;
821 ** top of for (;;) loop while no reductions done
823 yy_stack:
825 ** put a state and value onto the stacks
827 #if YYDEBUG
829 ** if debugging, look up token value in list of value vs.
830 ** name pairs. 0 and negative (-1) are special values.
831 ** Note: linear search is used since time is not a real
832 ** consideration while debugging.
834 if ( yydebug )
836 register int yy_i;
838 printf( "State %d, token ", yy_state );
839 if ( yychar == 0 )
840 printf( "end-of-file\n" );
841 else if ( yychar < 0 )
842 printf( "-none-\n" );
843 else
845 for ( yy_i = 0; yytoks[yy_i].t_val >= 0;
846 yy_i++ )
848 if ( yytoks[yy_i].t_val == yychar )
849 break;
851 printf( "%s\n", yytoks[yy_i].t_name );
854 #endif /* YYDEBUG */
855 if ( ++yy_ps >= &yys[ YYMAXDEPTH ] ) /* room on stack? */
857 yyerror( "yacc stack overflow" );
858 YYABORT;
860 *yy_ps = yy_state;
861 *++yy_pv = yyval;
864 ** we have a new state - find out what to do
866 yy_newstate:
867 if ( ( yy_n = yypact[ yy_state ] ) <= YYFLAG )
868 goto yydefault; /* simple state */
869 #if YYDEBUG
871 ** if debugging, need to mark whether new token grabbed
873 yytmp = yychar < 0;
874 #endif
875 if ( ( yychar < 0 ) && ( ( yychar = yylex() ) < 0 ) )
876 yychar = 0; /* reached EOF */
877 #if YYDEBUG
878 if ( yydebug && yytmp )
880 register int yy_i;
882 printf( "Received token " );
883 if ( yychar == 0 )
884 printf( "end-of-file\n" );
885 else if ( yychar < 0 )
886 printf( "-none-\n" );
887 else
889 for ( yy_i = 0; yytoks[yy_i].t_val >= 0;
890 yy_i++ )
892 if ( yytoks[yy_i].t_val == yychar )
893 break;
895 printf( "%s\n", yytoks[yy_i].t_name );
898 #endif /* YYDEBUG */
899 if ( ( ( yy_n += yychar ) < 0 ) || ( yy_n >= YYLAST ) )
900 goto yydefault;
901 if ( yychk[ yy_n = yyact[ yy_n ] ] == yychar ) /*valid shift*/
903 yychar = -1;
904 yyval = yylval;
905 yy_state = yy_n;
906 if ( yyerrflag > 0 )
907 yyerrflag--;
908 goto yy_stack;
911 yydefault:
912 if ( ( yy_n = yydef[ yy_state ] ) == -2 )
914 #if YYDEBUG
915 yytmp = yychar < 0;
916 #endif
917 if ( ( yychar < 0 ) && ( ( yychar = yylex() ) < 0 ) )
918 yychar = 0; /* reached EOF */
919 #if YYDEBUG
920 if ( yydebug && yytmp )
922 register int yy_i;
924 printf( "Received token " );
925 if ( yychar == 0 )
926 printf( "end-of-file\n" );
927 else if ( yychar < 0 )
928 printf( "-none-\n" );
929 else
931 for ( yy_i = 0;
932 yytoks[yy_i].t_val >= 0;
933 yy_i++ )
935 if ( yytoks[yy_i].t_val
936 == yychar )
938 break;
941 printf( "%s\n", yytoks[yy_i].t_name );
944 #endif /* YYDEBUG */
946 ** look through exception table
949 register const int *yyxi = yyexca;
951 while ( ( *yyxi != -1 ) ||
952 ( yyxi[1] != yy_state ) )
954 yyxi += 2;
956 while ( ( *(yyxi += 2) >= 0 ) &&
957 ( *yyxi != yychar ) )
959 if ( ( yy_n = yyxi[1] ) < 0 )
960 YYACCEPT;
965 ** check for syntax error
967 if ( yy_n == 0 ) /* have an error */
969 /* no worry about speed here! */
970 switch ( yyerrflag )
972 case 0: /* new error */
973 yyerror( "syntax error" );
974 goto skip_init;
975 yyerrlab:
977 ** get globals into registers.
978 ** we have a user generated syntax type error
980 yy_pv = yypv;
981 yy_ps = yyps;
982 yy_state = yystate;
983 yynerrs++;
984 skip_init:
985 case 1:
986 case 2: /* incompletely recovered error */
987 /* try again... */
988 yyerrflag = 3;
990 ** find state where "error" is a legal
991 ** shift action
993 while ( yy_ps >= yys )
995 yy_n = yypact[ *yy_ps ] + YYERRCODE;
996 if ( yy_n >= 0 && yy_n < YYLAST &&
997 yychk[yyact[yy_n]] == YYERRCODE) {
999 ** simulate shift of "error"
1001 yy_state = yyact[ yy_n ];
1002 goto yy_stack;
1005 ** current state has no shift on
1006 ** "error", pop stack
1008 #if YYDEBUG
1009 # define _POP_ "Error recovery pops state %d, uncovers state %d\n"
1010 if ( yydebug )
1011 printf( _POP_, *yy_ps,
1012 yy_ps[-1] );
1013 # undef _POP_
1014 #endif
1015 yy_ps--;
1016 yy_pv--;
1019 ** there is no state on stack with "error" as
1020 ** a valid shift. give up.
1022 YYABORT;
1023 case 3: /* no shift yet; eat a token */
1024 #if YYDEBUG
1026 ** if debugging, look up token in list of
1027 ** pairs. 0 and negative shouldn't occur,
1028 ** but since timing doesn't matter when
1029 ** debugging, it doesn't hurt to leave the
1030 ** tests here.
1032 if ( yydebug )
1034 register int yy_i;
1036 printf( "Error recovery discards " );
1037 if ( yychar == 0 )
1038 printf( "token end-of-file\n" );
1039 else if ( yychar < 0 )
1040 printf( "token -none-\n" );
1041 else
1043 for ( yy_i = 0;
1044 yytoks[yy_i].t_val >= 0;
1045 yy_i++ )
1047 if ( yytoks[yy_i].t_val
1048 == yychar )
1050 break;
1053 printf( "token %s\n",
1054 yytoks[yy_i].t_name );
1057 #endif /* YYDEBUG */
1058 if ( yychar == 0 ) /* reached EOF. quit */
1059 YYABORT;
1060 yychar = -1;
1061 goto yy_newstate;
1063 }/* end if ( yy_n == 0 ) */
1065 ** reduction by production yy_n
1066 ** put stack tops, etc. so things right after switch
1068 #if YYDEBUG
1070 ** if debugging, print the string that is the user's
1071 ** specification of the reduction which is just about
1072 ** to be done.
1074 if ( yydebug )
1075 printf( "Reduce by (%d) \"%s\"\n",
1076 yy_n, yyreds[ yy_n ] );
1077 #endif
1078 yytmp = yy_n; /* value to switch over */
1079 yypvt = yy_pv; /* $vars top of value stack */
1081 ** Look in goto table for next state
1082 ** Sorry about using yy_state here as temporary
1083 ** register variable, but why not, if it works...
1084 ** If yyr2[ yy_n ] doesn't have the low order bit
1085 ** set, then there is no action to be done for
1086 ** this reduction. So, no saving & unsaving of
1087 ** registers done. The only difference between the
1088 ** code just after the if and the body of the if is
1089 ** the goto yy_stack in the body. This way the test
1090 ** can be made before the choice of what to do is needed.
1093 /* length of production doubled with extra bit */
1094 register int yy_len = yyr2[ yy_n ];
1096 if ( !( yy_len & 01 ) )
1098 yy_len >>= 1;
1099 yyval = ( yy_pv -= yy_len )[1]; /* $$ = $1 */
1100 yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] +
1101 *( yy_ps -= yy_len ) + 1;
1102 if ( yy_state >= YYLAST ||
1103 yychk[ yy_state =
1104 yyact[ yy_state ] ] != -yy_n )
1106 yy_state = yyact[ yypgo[ yy_n ] ];
1108 goto yy_stack;
1110 yy_len >>= 1;
1111 yyval = ( yy_pv -= yy_len )[1]; /* $$ = $1 */
1112 yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] +
1113 *( yy_ps -= yy_len ) + 1;
1114 if ( yy_state >= YYLAST ||
1115 yychk[ yy_state = yyact[ yy_state ] ] != -yy_n )
1117 yy_state = yyact[ yypgo[ yy_n ] ];
1120 /* save until reenter driver code */
1121 yystate = yy_state;
1122 yyps = yy_ps;
1123 yypv = yy_pv;
1126 ** code supplied by user is placed in this switch
1129 switch(yytmp){
1131 case 1:
1132 # line 81 "parse.y"
1133 { ADD_OP(OP_RETURN_NO_VAL); return 0; } /*NOTREACHED*/ break;
1134 case 2:
1135 # line 82 "parse.y"
1136 { ADD_OP(OP_RETURN_NO_VAL); return 0; } /*NOTREACHED*/ break;
1137 case 3:
1138 # line 83 "parse.y"
1139 { ADD_OP(OP_RETURN_NO_VAL); return 0; } /*NOTREACHED*/ break;
1140 case 4:
1141 # line 84 "parse.y"
1142 { return 1; } /*NOTREACHED*/ break;
1143 case 11:
1144 # line 95 "parse.y"
1145 { SET_BR_OFF(yypvt[-3].inst, GetPC()); } /*NOTREACHED*/ break;
1146 case 12:
1147 # line 97 "parse.y"
1148 { SET_BR_OFF(yypvt[-6].inst, (yypvt[-2].inst+1)); SET_BR_OFF(yypvt[-2].inst, GetPC()); } /*NOTREACHED*/ break;
1149 case 13:
1150 # line 98 "parse.y"
1151 { ADD_OP(OP_BRANCH); ADD_BR_OFF(yypvt[-5].inst);
1152 SET_BR_OFF(yypvt[-3].inst, GetPC()); FillLoopAddrs(GetPC(), yypvt[-5].inst); } /*NOTREACHED*/ break;
1153 case 14:
1154 # line 101 "parse.y"
1155 { FillLoopAddrs(GetPC()+2+(yypvt[-3].inst-(yypvt[-5].inst+1)), GetPC());
1156 SwapCode(yypvt[-5].inst+1, yypvt[-3].inst, GetPC());
1157 ADD_OP(OP_BRANCH); ADD_BR_OFF(yypvt[-7].inst); SET_BR_OFF(yypvt[-5].inst, GetPC()); } /*NOTREACHED*/ break;
1158 case 15:
1159 # line 105 "parse.y"
1160 { Symbol *iterSym = InstallIteratorSymbol();
1161 ADD_OP(OP_BEGIN_ARRAY_ITER); ADD_SYM(yypvt[-1].sym); ADD_SYM(iterSym);
1162 ADD_OP(OP_ARRAY_ITER); ADD_SYM(yypvt[-3].sym); ADD_SYM(iterSym);
1163 ADD_BR_OFF(0); } /*NOTREACHED*/ break;
1164 case 16:
1165 # line 110 "parse.y"
1166 { FillLoopAddrs(GetPC()+2, GetPC());
1167 ADD_OP(OP_BRANCH); ADD_BR_OFF(yypvt[-8].inst+3);
1168 SET_BR_OFF(yypvt[-8].inst+6, GetPC());} /*NOTREACHED*/ break;
1169 case 17:
1170 # line 114 "parse.y"
1171 { ADD_OP(OP_BRANCH); ADD_BR_OFF(0); if(AddBreakAddr(GetPC()-1)) { yyerror("break outside loop"); YYERROR; } } /*NOTREACHED*/ break;
1172 case 18:
1173 # line 116 "parse.y"
1174 { ADD_OP(OP_BRANCH); ADD_BR_OFF(0); if(AddContinueAddr(GetPC()-1)) { yyerror("continue outside loop"); YYERROR; } } /*NOTREACHED*/ break;
1175 case 19:
1176 # line 117 "parse.y"
1177 { ADD_OP(OP_RETURN); } /*NOTREACHED*/ break;
1178 case 20:
1179 # line 118 "parse.y"
1180 { ADD_OP(OP_RETURN_NO_VAL); } /*NOTREACHED*/ break;
1181 case 21:
1182 # line 120 "parse.y"
1183 { ADD_OP(OP_ASSIGN); ADD_SYM(yypvt[-2].sym); } /*NOTREACHED*/ break;
1184 case 22:
1185 # line 121 "parse.y"
1186 { ADD_OP(OP_ADD); ADD_OP(OP_ASSIGN); ADD_SYM(yypvt[-2].sym); } /*NOTREACHED*/ break;
1187 case 23:
1188 # line 122 "parse.y"
1189 { ADD_OP(OP_SUB); ADD_OP(OP_ASSIGN); ADD_SYM(yypvt[-2].sym); } /*NOTREACHED*/ break;
1190 case 24:
1191 # line 123 "parse.y"
1192 { ADD_OP(OP_MUL); ADD_OP(OP_ASSIGN); ADD_SYM(yypvt[-2].sym); } /*NOTREACHED*/ break;
1193 case 25:
1194 # line 124 "parse.y"
1195 { ADD_OP(OP_DIV); ADD_OP(OP_ASSIGN); ADD_SYM(yypvt[-2].sym); } /*NOTREACHED*/ break;
1196 case 26:
1197 # line 125 "parse.y"
1198 { ADD_OP(OP_MOD); ADD_OP(OP_ASSIGN); ADD_SYM(yypvt[-2].sym); } /*NOTREACHED*/ break;
1199 case 27:
1200 # line 126 "parse.y"
1201 { ADD_OP(OP_BIT_AND); ADD_OP(OP_ASSIGN);
1202 ADD_SYM(yypvt[-2].sym); } /*NOTREACHED*/ break;
1203 case 28:
1204 # line 128 "parse.y"
1205 { ADD_OP(OP_BIT_OR); ADD_OP(OP_ASSIGN);
1206 ADD_SYM(yypvt[-2].sym); } /*NOTREACHED*/ break;
1207 case 29:
1208 # line 131 "parse.y"
1209 { ADD_OP(OP_ARRAY_DELETE); ADD_SYM(yypvt[-3].sym); ADD_IMMED((void *)yypvt[-1].nArgs); } /*NOTREACHED*/ break;
1210 case 30:
1211 # line 133 "parse.y"
1212 { ADD_OP(OP_ARRAY_ASSIGN); ADD_SYM(yypvt[-5].sym); ADD_IMMED((void *)yypvt[-3].nArgs); } /*NOTREACHED*/ break;
1213 case 31:
1214 # line 134 "parse.y"
1215 { ADD_OP(OP_PUSH_SYM);
1216 ADD_SYM(yypvt[-3].sym); ADD_OP(OP_ARRAY_REF); ADD_IMMED((void *)yypvt[-1].nArgs); } /*NOTREACHED*/ break;
1217 case 32:
1218 # line 137 "parse.y"
1219 { ADD_OP(OP_ADD); ADD_OP(OP_ARRAY_ASSIGN); ADD_SYM(yypvt[-6].sym);
1220 ADD_IMMED((void *)yypvt[-4].nArgs);} /*NOTREACHED*/ break;
1221 case 33:
1222 # line 139 "parse.y"
1223 { ADD_OP(OP_PUSH_SYM); ADD_SYM(yypvt[-3].sym);
1224 ADD_OP(OP_ARRAY_REF); ADD_IMMED((void *)yypvt[-1].nArgs); } /*NOTREACHED*/ break;
1225 case 34:
1226 # line 142 "parse.y"
1227 { ADD_OP(OP_SUB); ADD_OP(OP_ARRAY_ASSIGN); ADD_SYM(yypvt[-6].sym);
1228 ADD_IMMED((void *)yypvt[-4].nArgs); } /*NOTREACHED*/ break;
1229 case 35:
1230 # line 145 "parse.y"
1231 { ADD_OP(OP_PUSH_SYM); ADD_SYM(yypvt[-3].sym); ADD_OP(OP_ARRAY_REF);
1232 ADD_IMMED((void *)yypvt[-1].nArgs); } /*NOTREACHED*/ break;
1233 case 36:
1234 # line 148 "parse.y"
1235 { ADD_OP(OP_MUL); ADD_OP(OP_ARRAY_ASSIGN); ADD_SYM(yypvt[-6].sym);
1236 ADD_IMMED((void *)yypvt[-4].nArgs); } /*NOTREACHED*/ break;
1237 case 37:
1238 # line 151 "parse.y"
1239 { ADD_OP(OP_PUSH_SYM); ADD_SYM(yypvt[-3].sym); ADD_OP(OP_ARRAY_REF);
1240 ADD_IMMED((void *)yypvt[-1].nArgs); } /*NOTREACHED*/ break;
1241 case 38:
1242 # line 154 "parse.y"
1243 { ADD_OP(OP_DIV); ADD_OP(OP_ARRAY_ASSIGN); ADD_SYM(yypvt[-6].sym);
1244 ADD_IMMED((void *)yypvt[-4].nArgs); } /*NOTREACHED*/ break;
1245 case 39:
1246 # line 157 "parse.y"
1247 { ADD_OP(OP_PUSH_SYM); ADD_SYM(yypvt[-3].sym); ADD_OP(OP_ARRAY_REF);
1248 ADD_IMMED((void *)yypvt[-1].nArgs); } /*NOTREACHED*/ break;
1249 case 40:
1250 # line 160 "parse.y"
1251 { ADD_OP(OP_MOD); ADD_OP(OP_ARRAY_ASSIGN); ADD_SYM(yypvt[-6].sym);
1252 ADD_IMMED((void *)yypvt[-4].nArgs); } /*NOTREACHED*/ break;
1253 case 41:
1254 # line 163 "parse.y"
1255 { ADD_OP(OP_PUSH_SYM); ADD_SYM(yypvt[-3].sym); ADD_OP(OP_ARRAY_REF);
1256 ADD_IMMED((void *)yypvt[-1].nArgs); } /*NOTREACHED*/ break;
1257 case 42:
1258 # line 166 "parse.y"
1259 { ADD_OP(OP_BIT_AND); ADD_OP(OP_ARRAY_ASSIGN);
1260 ADD_SYM(yypvt[-6].sym); ADD_IMMED((void *)yypvt[-4].nArgs); } /*NOTREACHED*/ break;
1261 case 43:
1262 # line 169 "parse.y"
1263 { ADD_OP(OP_PUSH_SYM); ADD_SYM(yypvt[-3].sym); ADD_OP(OP_ARRAY_REF);
1264 ADD_IMMED((void *)yypvt[-1].nArgs); } /*NOTREACHED*/ break;
1265 case 44:
1266 # line 172 "parse.y"
1267 { ADD_OP(OP_BIT_OR); ADD_OP(OP_ARRAY_ASSIGN);
1268 ADD_SYM(yypvt[-6].sym); ADD_IMMED((void *)yypvt[-4].nArgs); } /*NOTREACHED*/ break;
1269 case 45:
1270 # line 174 "parse.y"
1271 { ADD_OP(OP_SUBR_CALL);
1272 ADD_SYM(PromoteToGlobal(yypvt[-3].sym)); ADD_IMMED((void *)yypvt[-1].nArgs); } /*NOTREACHED*/ break;
1273 case 46:
1274 # line 176 "parse.y"
1275 { ADD_OP(OP_PUSH_SYM); ADD_SYM(yypvt[-0].sym); ADD_OP(OP_INCR);
1276 ADD_OP(OP_ASSIGN); ADD_SYM(yypvt[-0].sym); } /*NOTREACHED*/ break;
1277 case 47:
1278 # line 178 "parse.y"
1279 { ADD_OP(OP_PUSH_SYM); ADD_SYM(yypvt[-1].sym); ADD_OP(OP_INCR);
1280 ADD_OP(OP_ASSIGN); ADD_SYM(yypvt[-1].sym); } /*NOTREACHED*/ break;
1281 case 48:
1282 # line 180 "parse.y"
1283 { ADD_OP(OP_PUSH_SYM); ADD_SYM(yypvt[-0].sym); ADD_OP(OP_DECR);
1284 ADD_OP(OP_ASSIGN); ADD_SYM(yypvt[-0].sym); } /*NOTREACHED*/ break;
1285 case 49:
1286 # line 182 "parse.y"
1287 { ADD_OP(OP_PUSH_SYM); ADD_SYM(yypvt[-1].sym); ADD_OP(OP_DECR);
1288 ADD_OP(OP_ASSIGN); ADD_SYM(yypvt[-1].sym); } /*NOTREACHED*/ break;
1289 case 50:
1290 # line 185 "parse.y"
1291 { yyval.sym = yypvt[-0].sym; ADD_OP(OP_PUSH_SYM); ADD_SYM(yypvt[-0].sym); } /*NOTREACHED*/ break;
1292 case 51:
1293 # line 187 "parse.y"
1294 { yyval.inst = GetPC(); } /*NOTREACHED*/ break;
1295 case 52:
1296 # line 188 "parse.y"
1297 { yyval.inst = GetPC(); } /*NOTREACHED*/ break;
1298 case 53:
1299 # line 189 "parse.y"
1300 { yyval.inst = GetPC(); } /*NOTREACHED*/ break;
1301 case 54:
1302 # line 191 "parse.y"
1303 { yyval.nArgs = 0;} /*NOTREACHED*/ break;
1304 case 55:
1305 # line 192 "parse.y"
1306 { yyval.nArgs = 1; } /*NOTREACHED*/ break;
1307 case 56:
1308 # line 193 "parse.y"
1309 { yyval.nArgs = yypvt[-2].nArgs + 1; } /*NOTREACHED*/ break;
1310 case 58:
1311 # line 196 "parse.y"
1312 { ADD_OP(OP_CONCAT); } /*NOTREACHED*/ break;
1313 case 59:
1314 # line 198 "parse.y"
1315 { ADD_OP(OP_PUSH_SYM); ADD_SYM(yypvt[-0].sym); } /*NOTREACHED*/ break;
1316 case 60:
1317 # line 199 "parse.y"
1318 { ADD_OP(OP_PUSH_SYM); ADD_SYM(yypvt[-0].sym); } /*NOTREACHED*/ break;
1319 case 61:
1320 # line 200 "parse.y"
1321 { ADD_OP(OP_PUSH_SYM); ADD_SYM(yypvt[-0].sym); } /*NOTREACHED*/ break;
1322 case 62:
1323 # line 201 "parse.y"
1324 { ADD_OP(OP_SUBR_CALL);
1325 ADD_SYM(PromoteToGlobal(yypvt[-3].sym)); ADD_IMMED((void *)yypvt[-1].nArgs);
1326 ADD_OP(OP_FETCH_RET_VAL);} /*NOTREACHED*/ break;
1327 case 64:
1328 # line 206 "parse.y"
1329 { ADD_OP(OP_ARRAY_REF); ADD_IMMED((void *)yypvt[-1].nArgs); } /*NOTREACHED*/ break;
1330 case 65:
1331 # line 207 "parse.y"
1332 { ADD_OP(OP_ADD); } /*NOTREACHED*/ break;
1333 case 66:
1334 # line 208 "parse.y"
1335 { ADD_OP(OP_SUB); } /*NOTREACHED*/ break;
1336 case 67:
1337 # line 209 "parse.y"
1338 { ADD_OP(OP_MUL); } /*NOTREACHED*/ break;
1339 case 68:
1340 # line 210 "parse.y"
1341 { ADD_OP(OP_DIV); } /*NOTREACHED*/ break;
1342 case 69:
1343 # line 211 "parse.y"
1344 { ADD_OP(OP_MOD); } /*NOTREACHED*/ break;
1345 case 70:
1346 # line 212 "parse.y"
1347 { ADD_OP(OP_POWER); } /*NOTREACHED*/ break;
1348 case 71:
1349 # line 213 "parse.y"
1350 { ADD_OP(OP_NEGATE); } /*NOTREACHED*/ break;
1351 case 72:
1352 # line 214 "parse.y"
1353 { ADD_OP(OP_GT); } /*NOTREACHED*/ break;
1354 case 73:
1355 # line 215 "parse.y"
1356 { ADD_OP(OP_GE); } /*NOTREACHED*/ break;
1357 case 74:
1358 # line 216 "parse.y"
1359 { ADD_OP(OP_LT); } /*NOTREACHED*/ break;
1360 case 75:
1361 # line 217 "parse.y"
1362 { ADD_OP(OP_LE); } /*NOTREACHED*/ break;
1363 case 76:
1364 # line 218 "parse.y"
1365 { ADD_OP(OP_EQ); } /*NOTREACHED*/ break;
1366 case 77:
1367 # line 219 "parse.y"
1368 { ADD_OP(OP_NE); } /*NOTREACHED*/ break;
1369 case 78:
1370 # line 220 "parse.y"
1371 { ADD_OP(OP_BIT_AND); } /*NOTREACHED*/ break;
1372 case 79:
1373 # line 221 "parse.y"
1374 { ADD_OP(OP_BIT_OR); } /*NOTREACHED*/ break;
1375 case 80:
1376 # line 223 "parse.y"
1377 { ADD_OP(OP_AND); SET_BR_OFF(yypvt[-1].inst, GetPC()); } /*NOTREACHED*/ break;
1378 case 81:
1379 # line 225 "parse.y"
1380 { ADD_OP(OP_OR); SET_BR_OFF(yypvt[-1].inst, GetPC()); } /*NOTREACHED*/ break;
1381 case 82:
1382 # line 226 "parse.y"
1383 { ADD_OP(OP_NOT); } /*NOTREACHED*/ break;
1384 case 83:
1385 # line 227 "parse.y"
1386 { ADD_OP(OP_PUSH_SYM); ADD_SYM(yypvt[-0].sym); ADD_OP(OP_INCR);
1387 ADD_OP(OP_DUP); ADD_OP(OP_ASSIGN); ADD_SYM(yypvt[-0].sym); } /*NOTREACHED*/ break;
1388 case 84:
1389 # line 229 "parse.y"
1390 { ADD_OP(OP_PUSH_SYM); ADD_SYM(yypvt[-1].sym); ADD_OP(OP_DUP);
1391 ADD_OP(OP_INCR); ADD_OP(OP_ASSIGN); ADD_SYM(yypvt[-1].sym); } /*NOTREACHED*/ break;
1392 case 85:
1393 # line 231 "parse.y"
1394 { ADD_OP(OP_PUSH_SYM); ADD_SYM(yypvt[-0].sym); ADD_OP(OP_DECR);
1395 ADD_OP(OP_DUP); ADD_OP(OP_ASSIGN); ADD_SYM(yypvt[-0].sym); } /*NOTREACHED*/ break;
1396 case 86:
1397 # line 233 "parse.y"
1398 { ADD_OP(OP_PUSH_SYM); ADD_SYM(yypvt[-1].sym); ADD_OP(OP_DUP);
1399 ADD_OP(OP_DECR); ADD_OP(OP_ASSIGN); ADD_SYM(yypvt[-1].sym); } /*NOTREACHED*/ break;
1400 case 87:
1401 # line 235 "parse.y"
1402 { ADD_OP(OP_IN_ARRAY); } /*NOTREACHED*/ break;
1403 case 88:
1404 # line 237 "parse.y"
1405 { yyval.inst = GetPC(); StartLoopAddrList(); } /*NOTREACHED*/ break;
1406 case 89:
1407 # line 239 "parse.y"
1408 { StartLoopAddrList(); yyval.inst = GetPC(); } /*NOTREACHED*/ break;
1409 case 90:
1410 # line 241 "parse.y"
1411 { ADD_OP(OP_BRANCH); yyval.inst = GetPC(); ADD_BR_OFF(0); } /*NOTREACHED*/ break;
1412 case 91:
1413 # line 243 "parse.y"
1414 { ADD_OP(OP_BRANCH_NEVER); yyval.inst = GetPC(); ADD_BR_OFF(0); } /*NOTREACHED*/ break;
1415 case 92:
1416 # line 244 "parse.y"
1417 { ADD_OP(OP_BRANCH_FALSE); yyval.inst = GetPC(); ADD_BR_OFF(0); } /*NOTREACHED*/ break;
1418 case 93:
1419 # line 246 "parse.y"
1420 { ADD_OP(OP_DUP); ADD_OP(OP_BRANCH_FALSE); yyval.inst = GetPC();
1421 ADD_BR_OFF(0); } /*NOTREACHED*/ break;
1422 case 94:
1423 # line 249 "parse.y"
1424 { ADD_OP(OP_DUP); ADD_OP(OP_BRANCH_TRUE); yyval.inst = GetPC();
1425 ADD_BR_OFF(0); } /*NOTREACHED*/ break;
1429 goto yystack; /* reset registers in driver code */