UNIXworkcode

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 20 21 #include "parse.h" 22 #include "textBuf.h" 23 #include "nedit.h" 24 #include "../util/rbTree.h" 25 #include "interpret.h" 26 27 #include <stdlib.h> 28 #include <string.h> 29 #include <stdio.h> 30 #include <ctype.h> 31 #include <X11/Intrinsic.h> 32 #include <Xm/Xm.h> 33 #ifdef VMS 34 #include "../util/VMSparam.h" 35 #else 36 #ifndef __MVS__ 37 #include <sys/param.h> 38 #endif 39 #endif /*VMS*/ 40 41 #ifdef HAVE_DEBUG_H 42 #include "../debug.h" 43 #endif 44 45 /* Macros to add error processing to AddOp and AddSym calls */ 46 #define ADD_OP(op) if (!AddOp(op, &ErrMsg)) return 1 47 #define ADD_SYM(sym) if (!AddSym(sym, &ErrMsg)) return 1 48 #define ADD_IMMED(val) if (!AddImmediate(val, &ErrMsg)) return 1 49 #define ADD_BR_OFF(to) if (!AddBranchOffset(to, &ErrMsg)) return 1 50 #define SET_BR_OFF(from, to) ((from)->value) = ((Inst *)(to)) - ((Inst *)(from)) 51 52 /* Max. length for a string constant (... there shouldn't be a maximum) */ 53 #define MAX_STRING_CONST_LEN 5000 54 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); 62 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 */ 67 68 #line 57 "parse.y" 69 typedef union { 70 Symbol *sym; 71 Inst *inst; 72 int nArgs; 73 } YYSTYPE; 74 #line 76 "y.tab.c" 75 #define YYERRCODE 256 76 #define NUMBER 257 77 #define STRING 258 78 #define SYMBOL 259 79 #define DELETE 260 80 #define ARG_LOOKUP 261 81 #define IF 262 82 #define WHILE 263 83 #define ELSE 264 84 #define FOR 265 85 #define BREAK 266 86 #define CONTINUE 267 87 #define RETURN 268 88 #define IF_NO_ELSE 269 89 #define ADDEQ 270 90 #define SUBEQ 271 91 #define MULEQ 272 92 #define DIVEQ 273 93 #define MODEQ 274 94 #define ANDEQ 275 95 #define OREQ 276 96 #define CONCAT 277 97 #define OR 278 98 #define AND 279 99 #define GT 280 100 #define GE 281 101 #define LT 282 102 #define LE 283 103 #define EQ 284 104 #define NE 285 105 #define IN 286 106 #define UNARY_MINUS 287 107 #define NOT 288 108 #define INCR 289 109 #define DECR 290 110 #define POW 291 111 const short yylhs[] = { -1, 112 0, 0, 0, 0, 13, 13, 13, 12, 12, 14, 113 14, 14, 14, 14, 16, 14, 14, 14, 14, 14, 114 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 115 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 116 15, 15, 15, 15, 15, 15, 10, 3, 3, 3, 117 1, 1, 1, 17, 17, 19, 19, 18, 18, 9, 118 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 119 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 120 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 121 20, 20, 5, 4, 6, 2, 2, 7, 8, 11, 122 11, 123 }; 124 const short yylen[] = { 2, 125 2, 5, 4, 1, 5, 4, 1, 1, 2, 3, 126 6, 9, 6, 10, 0, 9, 3, 3, 4, 3, 127 3, 3, 3, 3, 3, 3, 3, 3, 5, 6, 128 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 129 5, 4, 2, 2, 2, 2, 1, 0, 1, 3, 130 0, 1, 3, 1, 2, 1, 4, 1, 4, 1, 131 1, 1, 1, 4, 3, 4, 3, 1, 4, 3, 132 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 133 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 134 2, 3, 1, 1, 1, 0, 1, 1, 1, 0, 135 2, 136 }; 137 const short yydefred[] = { 0, 138 4, 0, 0, 0, 0, 0, 93, 94, 0, 0, 139 0, 0, 0, 100, 101, 0, 0, 0, 0, 8, 140 0, 0, 0, 44, 46, 0, 58, 0, 0, 100, 141 100, 61, 62, 0, 0, 0, 0, 0, 0, 0, 142 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 143 0, 0, 0, 0, 0, 0, 0, 9, 100, 0, 144 0, 0, 0, 0, 0, 0, 0, 0, 89, 91, 145 0, 0, 0, 0, 88, 90, 0, 0, 100, 0, 146 99, 98, 0, 0, 0, 0, 0, 0, 0, 0, 147 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 148 0, 0, 3, 0, 0, 0, 49, 0, 0, 0, 149 0, 0, 0, 0, 0, 0, 0, 42, 0, 0, 150 100, 0, 67, 0, 65, 0, 0, 0, 0, 0, 151 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 153 100, 0, 0, 0, 0, 64, 66, 69, 0, 0, 154 0, 0, 0, 50, 0, 0, 0, 0, 0, 0, 155 0, 0, 0, 38, 39, 100, 0, 7, 15, 0, 156 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 157 95, 100, 100, 0, 100, 0, 0, 0, 100, 0, 158 100, 12, 16, 0, 0, 14, 159 }; 160 const short yydgoto[] = { 2, 161 62, 65, 106, 16, 17, 192, 99, 100, 161, 18, 162 3, 19, 177, 178, 21, 193, 63, 28, 22, 43, 163 }; 164 const short yysindex[] = { -242, 165 0, 0, 221, 6, -243, -15, 0, 0, 32, 42, 166 603, -209, -204, 0, 0, 54, 58, 768, 1179, 0, 167 77, 22, 843, 0, 0, 843, 0, 38, 843, 0, 168 0, 0, 0, 8, 44, 843, 843, -150, -142, 843, 169 0, 747, 1368, 0, 46, 0, 49, 369, 101, 843, 170 843, 843, 843, 843, 843, 843, 843, 0, 0, 843, 171 843, -26, 843, 843, 82, 1368, 121, 121, 0, 0, 172 843, 975, -87, -87, 0, 0, 837, 121, 0, 1368, 173 0, 0, 843, 843, 843, 843, 843, 843, 843, 843, 174 843, 843, 843, 843, 843, 843, 843, 843, 843, 843, 175 843, 843, 0, 328, -31, -27, 0, 104, 843, 843, 176 843, 843, 843, 843, 843, 121, -22, 0, 843, -21, 177 0, -17, 0, -35, 0, 121, 65, 163, -9, -9, 178 -9, -9, -9, -9, -9, 2, 2, -87, -87, -87, 179 -87, -7, 23, 1250, 39, 40, 0, 843, 843, 504, 180 0, 624, 843, 0, 292, 0, 0, 0, 0, 0, 181 110, 1368, 94, 0, 292, 843, 843, 843, 843, 843, 182 843, 843, 843, 0, 0, 0, -110, 0, 0, 504, 183 0, 843, 843, 843, 843, 843, 843, 843, 843, 665, 184 0, 0, 0, 55, 0, 464, 292, 292, 0, 121, 185 0, 0, 0, 292, 121, 0, 186 }; 187 const short yyrindex[] = { 700, 188 0, 0, 0, -91, 0, 0, 0, 0, 0, 0, 189 0, 0, 0, 0, 0, 0, 0, 0, 155, 0, 190 0, 0, 0, 0, 0, 56, 0, 0, 116, 0, 191 0, 0, 0, 383, 128, 0, 0, 0, 0, 0, 192 0, 0, 179, 10, 0, 108, 0, 0, -18, 116, 193 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, 194 47, 0, -1, 51, 0, -28, 1, 11, 0, 0, 195 56, 0, 419, 455, 0, 0, 0, 21, 0, 431, 196 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 197 0, 0, 0, 0, 0, 0, 0, 51, 0, 0, 198 51, 51, 0, 0, -91, 0, 0, 0, 75, 80, 199 117, 481, 503, 568, 611, 53, 0, 0, 0, 0, 200 0, 0, 0, 0, 0, 63, 1342, 1337, 899, 934, 201 969, 1197, 1232, 1267, 1302, 827, 863, 491, 527, 563, 202 791, 0, 1377, 877, 0, 0, 0, 0, 127, 0, 203 0, 69, 18, 118, 0, 0, 0, 0, 391, 539, 204 0, 122, 0, 0, 0, 0, 0, 0, 0, 0, 205 0, 0, 0, 0, 0, 0, 115, 0, 0, 81, 206 0, 613, 755, 815, 875, 932, 936, 940, 942, 0, 207 0, 0, 0, 0, 0, 0, 0, 0, 0, 73, 208 0, 0, 0, 0, 105, 0, 209 }; 210 const short yygindex[] = { 0, 211 444, -45, -16, 0, 0, 0, 0, 0, 0, 0, 212 1272, -42, 37, 26, -30, 0, 24, 0, 129, 1632, 213 }; 214 #define YYTABLESIZE 1821 215 const short yytable[] = { 56, 216 17, 96, 84, 98, 108, 104, 94, 92, 26, 93, 217 18, 95, 97, 1, 118, 27, 150, 119, 107, 43, 218 20, 119, 119, 156, 29, 48, 119, 96, 20, 23, 219 97, 149, 94, 92, 42, 93, 119, 95, 96, 52, 220 48, 30, 52, 94, 58, 26, 61, 71, 95, 44, 221 43, 31, 10, 43, 46, 98, 21, 157, 53, 96, 222 84, 53, 19, 77, 94, 92, 23, 93, 43, 95, 223 152, 154, 6, 20, 109, 110, 111, 112, 113, 114, 224 115, 98, 119, 119, 22, 158, 59, 21, 83, 23, 225 21, 52, 98, 49, 51, 199, 51, 50, 150, 51, 226 56, 96, 84, 163, 5, 21, 94, 92, 75, 93, 227 53, 95, 60, 98, 11, 22, 76, 45, 22, 164, 228 23, 48, 121, 23, 48, 17, 24, 29, 64, 58, 229 15, 159, 160, 22, 72, 18, 101, 68, 23, 102, 230 45, 47, 153, 51, 151, 20, 83, 196, 45, 107, 231 179, 45, 180, 191, 1, 98, 96, 24, 29, 57, 232 24, 29, 60, 194, 68, 68, 45, 68, 68, 68, 233 68, 68, 68, 0, 68, 24, 29, 10, 47, 47, 234 47, 47, 47, 47, 47, 96, 68, 19, 54, 182, 235 183, 184, 185, 186, 187, 188, 189, 6, 56, 96, 236 0, 181, 0, 97, 94, 92, 0, 93, 59, 95, 237 0, 0, 0, 0, 0, 20, 0, 0, 54, 54, 238 68, 58, 54, 0, 0, 0, 0, 0, 0, 5, 239 15, 0, 0, 202, 203, 0, 0, 54, 0, 11, 240 206, 0, 81, 82, 85, 86, 87, 88, 89, 90, 241 91, 68, 0, 98, 148, 97, 0, 24, 25, 17, 242 17, 0, 17, 17, 17, 17, 17, 17, 17, 18, 243 18, 54, 18, 18, 18, 18, 18, 18, 18, 20, 244 20, 97, 20, 20, 20, 20, 20, 20, 20, 17, 245 17, 0, 97, 0, 24, 25, 69, 70, 0, 18, 246 18, 15, 85, 86, 87, 88, 89, 90, 91, 20, 247 20, 10, 10, 97, 10, 10, 10, 10, 10, 10, 248 10, 19, 19, 0, 19, 19, 19, 19, 19, 19, 249 19, 6, 6, 0, 6, 6, 6, 6, 6, 6, 250 6, 10, 10, 14, 85, 86, 87, 88, 89, 90, 251 91, 19, 19, 0, 0, 97, 0, 0, 0, 105, 252 5, 6, 6, 5, 5, 0, 5, 5, 5, 5, 253 5, 5, 5, 11, 11, 0, 11, 11, 15, 11, 254 11, 11, 11, 0, 68, 68, 68, 0, 68, 12, 255 13, 0, 63, 5, 5, 0, 0, 0, 0, 0, 256 40, 0, 0, 11, 11, 68, 68, 68, 68, 68, 257 68, 68, 68, 68, 176, 68, 68, 68, 68, 63, 258 63, 0, 0, 63, 63, 63, 63, 63, 76, 63, 259 0, 40, 0, 0, 40, 54, 54, 54, 0, 54, 260 55, 63, 85, 86, 87, 88, 89, 90, 91, 40, 261 0, 0, 147, 97, 0, 76, 76, 0, 76, 76, 262 76, 76, 76, 76, 87, 76, 54, 54, 54, 0, 263 55, 55, 0, 63, 55, 63, 0, 76, 0, 4, 264 5, 57, 6, 7, 0, 8, 9, 10, 11, 55, 265 25, 87, 87, 103, 87, 87, 87, 87, 87, 87, 266 72, 87, 0, 117, 0, 0, 63, 120, 0, 12, 267 13, 76, 26, 87, 122, 0, 0, 0, 0, 0, 268 0, 25, 0, 55, 25, 0, 0, 72, 72, 0, 269 72, 72, 72, 72, 72, 72, 73, 72, 0, 25, 270 0, 142, 76, 26, 145, 146, 26, 87, 41, 72, 271 4, 5, 0, 6, 7, 0, 8, 9, 10, 11, 272 0, 26, 0, 73, 73, 0, 73, 73, 73, 73, 273 73, 73, 74, 73, 0, 0, 0, 27, 87, 41, 274 12, 13, 41, 72, 0, 73, 4, 5, 201, 6, 275 7, 0, 8, 9, 10, 11, 0, 41, 0, 74, 276 74, 0, 74, 74, 74, 74, 74, 74, 27, 74, 277 0, 27, 41, 0, 72, 0, 12, 13, 0, 73, 278 28, 74, 30, 0, 0, 0, 27, 4, 5, 57, 279 6, 7, 0, 8, 9, 10, 11, 0, 0, 63, 280 63, 63, 40, 63, 0, 0, 0, 36, 0, 0, 281 73, 28, 0, 30, 28, 74, 30, 12, 13, 0, 282 63, 63, 63, 63, 63, 63, 63, 63, 63, 28, 283 63, 30, 0, 63, 15, 76, 76, 76, 0, 76, 284 0, 0, 0, 0, 166, 0, 74, 55, 55, 55, 285 0, 55, 0, 0, 0, 0, 76, 76, 76, 76, 286 76, 76, 76, 76, 76, 0, 76, 76, 76, 100, 287 0, 87, 87, 87, 0, 87, 0, 0, 55, 55, 288 55, 0, 4, 5, 0, 6, 7, 0, 8, 9, 289 10, 11, 87, 87, 87, 87, 87, 87, 87, 87, 290 87, 0, 87, 87, 87, 0, 0, 72, 72, 72, 291 0, 72, 12, 13, 0, 0, 79, 0, 0, 0, 292 0, 0, 4, 5, 31, 0, 0, 0, 72, 72, 293 72, 72, 72, 72, 72, 72, 72, 0, 72, 72, 294 72, 0, 0, 73, 73, 73, 40, 73, 0, 195, 295 0, 36, 12, 13, 0, 31, 0, 0, 31, 0, 296 75, 0, 0, 0, 73, 73, 73, 73, 73, 73, 297 73, 73, 73, 31, 73, 73, 73, 0, 0, 74, 298 74, 74, 100, 74, 32, 0, 0, 75, 75, 0, 299 75, 75, 75, 75, 75, 75, 70, 75, 0, 0, 300 74, 74, 74, 74, 74, 74, 74, 74, 74, 75, 301 74, 74, 74, 0, 0, 32, 0, 0, 32, 32, 302 33, 34, 0, 35, 70, 0, 70, 70, 0, 70, 303 70, 70, 71, 32, 0, 0, 40, 125, 0, 0, 304 0, 36, 40, 75, 33, 70, 86, 36, 0, 0, 305 37, 38, 39, 167, 168, 169, 170, 171, 172, 173, 306 71, 0, 71, 71, 0, 71, 71, 71, 77, 0, 307 0, 0, 174, 175, 75, 33, 86, 86, 33, 70, 308 86, 71, 0, 4, 5, 0, 6, 7, 0, 8, 309 9, 10, 11, 33, 0, 86, 77, 0, 77, 77, 310 0, 34, 77, 78, 0, 35, 0, 0, 0, 36, 311 70, 37, 0, 12, 13, 71, 0, 77, 100, 100, 312 0, 100, 100, 0, 100, 100, 100, 100, 0, 86, 313 0, 78, 34, 78, 78, 34, 35, 78, 79, 35, 314 36, 0, 37, 36, 0, 37, 71, 0, 100, 100, 315 34, 77, 78, 0, 35, 0, 0, 0, 36, 0, 316 37, 0, 0, 32, 33, 34, 79, 35, 79, 79, 317 0, 0, 79, 0, 40, 0, 0, 0, 0, 36, 318 0, 0, 77, 0, 0, 0, 78, 79, 0, 0, 319 0, 0, 0, 0, 37, 38, 39, 51, 52, 53, 320 54, 55, 56, 57, 0, 0, 0, 75, 75, 75, 321 0, 75, 0, 0, 0, 0, 0, 78, 0, 0, 322 0, 79, 0, 0, 0, 0, 0, 123, 75, 75, 323 75, 75, 75, 75, 75, 75, 75, 0, 75, 75, 324 75, 0, 0, 70, 70, 70, 0, 70, 0, 0, 325 0, 0, 79, 32, 33, 34, 0, 35, 0, 32, 326 33, 34, 0, 35, 70, 70, 70, 70, 70, 70, 327 70, 70, 70, 0, 70, 70, 70, 0, 0, 71, 328 71, 71, 0, 71, 37, 38, 39, 0, 0, 0, 329 37, 38, 39, 86, 86, 86, 0, 86, 0, 0, 330 71, 71, 71, 71, 71, 71, 71, 71, 71, 0, 331 71, 71, 71, 0, 86, 77, 77, 77, 0, 77, 332 0, 0, 0, 0, 86, 86, 86, 0, 0, 0, 333 0, 0, 0, 0, 0, 0, 77, 77, 77, 77, 334 77, 77, 77, 77, 77, 0, 77, 77, 77, 0, 335 78, 78, 78, 0, 78, 0, 0, 0, 0, 0, 336 0, 0, 0, 0, 0, 0, 80, 0, 0, 0, 337 0, 78, 78, 78, 78, 78, 78, 78, 78, 78, 338 0, 78, 78, 78, 0, 79, 79, 79, 0, 79, 339 0, 32, 33, 34, 80, 35, 80, 80, 0, 0, 340 80, 81, 0, 0, 0, 0, 79, 79, 79, 79, 341 79, 79, 79, 79, 79, 80, 79, 79, 79, 0, 342 0, 0, 37, 38, 39, 0, 0, 0, 0, 81, 343 0, 81, 81, 0, 0, 81, 82, 0, 0, 0, 344 0, 0, 0, 0, 0, 48, 96, 84, 0, 80, 345 81, 94, 92, 0, 93, 0, 95, 0, 0, 0, 346 0, 67, 68, 0, 82, 0, 82, 82, 0, 0, 347 82, 92, 78, 0, 0, 0, 0, 0, 0, 0, 348 80, 0, 0, 0, 81, 82, 0, 0, 0, 0, 349 116, 0, 0, 0, 0, 0, 0, 0, 0, 92, 350 98, 92, 92, 0, 0, 92, 83, 0, 0, 0, 351 126, 84, 0, 0, 0, 81, 0, 0, 0, 82, 352 92, 0, 0, 0, 0, 0, 0, 0, 0, 0, 353 0, 0, 0, 83, 83, 0, 83, 83, 0, 0, 354 83, 84, 84, 0, 0, 84, 85, 0, 0, 0, 355 82, 0, 155, 0, 92, 83, 0, 0, 0, 0, 356 84, 0, 0, 0, 96, 84, 0, 0, 0, 94, 357 92, 0, 93, 0, 95, 0, 85, 85, 0, 0, 358 85, 0, 165, 0, 0, 92, 0, 0, 0, 83, 359 0, 0, 0, 0, 84, 85, 0, 4, 5, 0, 360 6, 7, 0, 8, 9, 10, 11, 190, 0, 0, 361 0, 0, 0, 80, 80, 80, 0, 80, 98, 0, 362 83, 0, 0, 197, 198, 84, 200, 12, 13, 85, 363 204, 0, 205, 0, 80, 80, 80, 80, 80, 80, 364 80, 80, 80, 0, 80, 80, 80, 0, 81, 81, 365 81, 83, 81, 0, 0, 0, 0, 0, 0, 0, 366 0, 0, 0, 0, 0, 0, 0, 0, 0, 81, 367 81, 81, 81, 81, 81, 81, 81, 81, 0, 81, 368 81, 81, 0, 82, 82, 82, 0, 82, 82, 85, 369 86, 87, 88, 89, 90, 91, 0, 0, 0, 0, 370 97, 0, 0, 0, 82, 82, 82, 82, 82, 82, 371 82, 82, 82, 0, 82, 82, 82, 0, 92, 92, 372 92, 0, 92, 0, 0, 0, 0, 0, 0, 0, 373 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 374 92, 92, 92, 92, 92, 92, 92, 92, 0, 92, 375 92, 92, 0, 83, 83, 83, 0, 83, 84, 84, 376 84, 0, 84, 0, 0, 0, 0, 0, 0, 0, 377 0, 0, 0, 0, 83, 83, 0, 0, 0, 84, 378 84, 0, 0, 0, 83, 83, 83, 0, 0, 84, 379 84, 84, 0, 85, 85, 85, 0, 85, 0, 0, 380 0, 0, 0, 0, 0, 81, 82, 85, 86, 87, 381 88, 89, 90, 91, 85, 85, 0, 0, 97, 0, 382 66, 0, 0, 0, 85, 85, 85, 73, 74, 0, 383 0, 0, 0, 80, 0, 0, 0, 0, 0, 0, 384 0, 66, 0, 0, 0, 0, 0, 0, 0, 0, 385 0, 0, 80, 0, 80, 0, 0, 0, 0, 0, 386 0, 0, 0, 124, 0, 0, 0, 0, 80, 0, 387 0, 0, 0, 0, 127, 128, 129, 130, 131, 132, 388 133, 134, 135, 136, 137, 138, 139, 140, 141, 0, 389 143, 144, 0, 0, 0, 0, 0, 0, 0, 0, 390 80, 80, 80, 80, 80, 80, 80, 0, 0, 0, 391 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 392 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 393 0, 0, 0, 0, 0, 0, 0, 0, 0, 162, 394 66, 0, 0, 0, 80, 0, 0, 0, 0, 0, 395 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 396 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 397 0, 0, 0, 80, 80, 80, 80, 80, 80, 80, 398 80, 399 }; 400 const short yycheck[] = { 91, 401 0, 37, 38, 91, 50, 48, 42, 43, 40, 45, 402 0, 47, 41, 256, 41, 259, 44, 44, 49, 10, 403 0, 44, 44, 41, 40, 44, 44, 37, 3, 61, 404 59, 59, 42, 43, 11, 45, 44, 47, 37, 41, 405 59, 10, 44, 42, 19, 40, 23, 40, 47, 259, 406 41, 10, 0, 44, 259, 91, 10, 93, 41, 37, 407 38, 44, 0, 40, 42, 43, 61, 45, 59, 47, 408 93, 93, 0, 48, 51, 52, 53, 54, 55, 56, 409 57, 91, 44, 44, 10, 93, 10, 41, 124, 10, 410 44, 93, 91, 40, 44, 41, 41, 40, 44, 44, 411 91, 37, 38, 149, 0, 59, 42, 43, 259, 45, 412 93, 47, 91, 91, 0, 41, 259, 10, 44, 150, 413 41, 41, 41, 44, 44, 125, 10, 10, 91, 104, 414 10, 93, 93, 59, 91, 125, 91, 10, 59, 91, 415 12, 13, 119, 93, 41, 125, 124, 190, 41, 180, 416 41, 44, 59, 264, 0, 91, 41, 41, 41, 91, 417 44, 44, 41, 180, 37, 38, 59, 40, 41, 42, 418 43, 44, 45, -1, 47, 59, 59, 125, 270, 271, 419 272, 273, 274, 275, 276, 59, 59, 125, 10, 166, 420 167, 168, 169, 170, 171, 172, 173, 125, 91, 37, 421 -1, 165, -1, 291, 42, 43, -1, 45, 91, 47, 422 -1, -1, -1, -1, -1, 190, -1, -1, 40, 41, 423 93, 196, 44, -1, -1, -1, -1, -1, -1, 125, 424 10, -1, -1, 197, 198, -1, -1, 59, -1, 125, 425 204, -1, 278, 279, 280, 281, 282, 283, 284, 285, 426 286, 124, -1, 91, 286, 291, -1, 289, 290, 259, 427 260, -1, 262, 263, 264, 265, 266, 267, 268, 259, 428 260, 93, 262, 263, 264, 265, 266, 267, 268, 259, 429 260, 291, 262, 263, 264, 265, 266, 267, 268, 289, 430 290, -1, 291, -1, 289, 290, 289, 290, -1, 289, 431 290, 10, 280, 281, 282, 283, 284, 285, 286, 289, 432 290, 259, 260, 291, 262, 263, 264, 265, 266, 267, 433 268, 259, 260, -1, 262, 263, 264, 265, 266, 267, 434 268, 259, 260, -1, 262, 263, 264, 265, 266, 267, 435 268, 289, 290, 123, 280, 281, 282, 283, 284, 285, 436 286, 289, 290, -1, -1, 291, -1, -1, -1, 259, 437 260, 289, 290, 259, 260, -1, 262, 263, 264, 265, 438 266, 267, 268, 259, 260, -1, 262, 263, 10, 265, 439 266, 267, 268, -1, 257, 258, 259, -1, 261, 289, 440 290, -1, 10, 289, 290, -1, -1, -1, -1, -1, 441 10, -1, -1, 289, 290, 278, 279, 280, 281, 282, 442 283, 284, 285, 286, 123, 288, 289, 290, 291, 37, 443 38, -1, -1, 41, 42, 43, 44, 45, 10, 47, 444 -1, 41, -1, -1, 44, 257, 258, 259, -1, 261, 445 10, 59, 280, 281, 282, 283, 284, 285, 286, 59, 446 -1, -1, 125, 291, -1, 37, 38, -1, 40, 41, 447 42, 43, 44, 45, 10, 47, 288, 289, 290, -1, 448 40, 41, -1, 91, 44, 93, -1, 59, -1, 259, 449 260, 91, 262, 263, -1, 265, 266, 267, 268, 59, 450 10, 37, 38, 125, 40, 41, 42, 43, 44, 45, 451 10, 47, -1, 60, -1, -1, 124, 64, -1, 289, 452 290, 93, 10, 59, 71, -1, -1, -1, -1, -1, 453 -1, 41, -1, 93, 44, -1, -1, 37, 38, -1, 454 40, 41, 42, 43, 44, 45, 10, 47, -1, 59, 455 -1, 98, 124, 41, 101, 102, 44, 93, 10, 59, 456 259, 260, -1, 262, 263, -1, 265, 266, 267, 268, 457 -1, 59, -1, 37, 38, -1, 40, 41, 42, 43, 458 44, 45, 10, 47, -1, -1, -1, 10, 124, 41, 459 289, 290, 44, 93, -1, 59, 259, 260, 125, 262, 460 263, -1, 265, 266, 267, 268, -1, 59, -1, 37, 461 38, -1, 40, 41, 42, 43, 44, 45, 41, 47, 462 -1, 44, 10, -1, 124, -1, 289, 290, -1, 93, 463 10, 59, 10, -1, -1, -1, 59, 259, 260, 91, 464 262, 263, -1, 265, 266, 267, 268, -1, -1, 257, 465 258, 259, 40, 261, -1, -1, -1, 45, -1, -1, 466 124, 41, -1, 41, 44, 93, 44, 289, 290, -1, 467 278, 279, 280, 281, 282, 283, 284, 285, 286, 59, 468 288, 59, -1, 291, 10, 257, 258, 259, -1, 261, 469 -1, -1, -1, -1, 61, -1, 124, 257, 258, 259, 470 -1, 261, -1, -1, -1, -1, 278, 279, 280, 281, 471 282, 283, 284, 285, 286, -1, 288, 289, 290, 10, 472 -1, 257, 258, 259, -1, 261, -1, -1, 288, 289, 473 290, -1, 259, 260, -1, 262, 263, -1, 265, 266, 474 267, 268, 278, 279, 280, 281, 282, 283, 284, 285, 475 286, -1, 288, 289, 290, -1, -1, 257, 258, 259, 476 -1, 261, 289, 290, -1, -1, 10, -1, -1, -1, 477 -1, -1, 259, 260, 10, -1, -1, -1, 278, 279, 478 280, 281, 282, 283, 284, 285, 286, -1, 288, 289, 479 290, -1, -1, 257, 258, 259, 40, 261, -1, 125, 480 -1, 45, 289, 290, -1, 41, -1, -1, 44, -1, 481 10, -1, -1, -1, 278, 279, 280, 281, 282, 283, 482 284, 285, 286, 59, 288, 289, 290, -1, -1, 257, 483 258, 259, 123, 261, 10, -1, -1, 37, 38, -1, 484 40, 41, 42, 43, 44, 45, 10, 47, -1, -1, 485 278, 279, 280, 281, 282, 283, 284, 285, 286, 59, 486 288, 289, 290, -1, -1, 41, -1, -1, 44, 257, 487 258, 259, -1, 261, 38, -1, 40, 41, -1, 43, 488 44, 45, 10, 59, -1, -1, 40, 41, -1, -1, 489 -1, 45, 40, 93, 10, 59, 10, 45, -1, -1, 490 288, 289, 290, 270, 271, 272, 273, 274, 275, 276, 491 38, -1, 40, 41, -1, 43, 44, 45, 10, -1, 492 -1, -1, 289, 290, 124, 41, 40, 41, 44, 93, 493 44, 59, -1, 259, 260, -1, 262, 263, -1, 265, 494 266, 267, 268, 59, -1, 59, 38, -1, 40, 41, 495 -1, 10, 44, 10, -1, 10, -1, -1, -1, 10, 496 124, 10, -1, 289, 290, 93, -1, 59, 259, 260, 497 -1, 262, 263, -1, 265, 266, 267, 268, -1, 93, 498 -1, 38, 41, 40, 41, 44, 41, 44, 10, 44, 499 41, -1, 41, 44, -1, 44, 124, -1, 289, 290, 500 59, 93, 59, -1, 59, -1, -1, -1, 59, -1, 501 59, -1, -1, 257, 258, 259, 38, 261, 40, 41, 502 -1, -1, 44, -1, 40, -1, -1, -1, -1, 45, 503 -1, -1, 124, -1, -1, -1, 93, 59, -1, -1, 504 -1, -1, -1, -1, 288, 289, 290, 270, 271, 272, 505 273, 274, 275, 276, -1, -1, -1, 257, 258, 259, 506 -1, 261, -1, -1, -1, -1, -1, 124, -1, -1, 507 -1, 93, -1, -1, -1, -1, -1, 93, 278, 279, 508 280, 281, 282, 283, 284, 285, 286, -1, 288, 289, 509 290, -1, -1, 257, 258, 259, -1, 261, -1, -1, 510 -1, -1, 124, 257, 258, 259, -1, 261, -1, 257, 511 258, 259, -1, 261, 278, 279, 280, 281, 282, 283, 512 284, 285, 286, -1, 288, 289, 290, -1, -1, 257, 513 258, 259, -1, 261, 288, 289, 290, -1, -1, -1, 514 288, 289, 290, 257, 258, 259, -1, 261, -1, -1, 515 278, 279, 280, 281, 282, 283, 284, 285, 286, -1, 516 288, 289, 290, -1, 278, 257, 258, 259, -1, 261, 517 -1, -1, -1, -1, 288, 289, 290, -1, -1, -1, 518 -1, -1, -1, -1, -1, -1, 278, 279, 280, 281, 519 282, 283, 284, 285, 286, -1, 288, 289, 290, -1, 520 257, 258, 259, -1, 261, -1, -1, -1, -1, -1, 521 -1, -1, -1, -1, -1, -1, 10, -1, -1, -1, 522 -1, 278, 279, 280, 281, 282, 283, 284, 285, 286, 523 -1, 288, 289, 290, -1, 257, 258, 259, -1, 261, 524 -1, 257, 258, 259, 38, 261, 40, 41, -1, -1, 525 44, 10, -1, -1, -1, -1, 278, 279, 280, 281, 526 282, 283, 284, 285, 286, 59, 288, 289, 290, -1, 527 -1, -1, 288, 289, 290, -1, -1, -1, -1, 38, 528 -1, 40, 41, -1, -1, 44, 10, -1, -1, -1, 529 -1, -1, -1, -1, -1, 14, 37, 38, -1, 93, 530 59, 42, 43, -1, 45, -1, 47, -1, -1, -1, 531 -1, 30, 31, -1, 38, -1, 40, 41, -1, -1, 532 44, 10, 41, -1, -1, -1, -1, -1, -1, -1, 533 124, -1, -1, -1, 93, 59, -1, -1, -1, -1, 534 59, -1, -1, -1, -1, -1, -1, -1, -1, 38, 535 91, 40, 41, -1, -1, 44, 10, -1, -1, -1, 536 79, 10, -1, -1, -1, 124, -1, -1, -1, 93, 537 59, -1, -1, -1, -1, -1, -1, -1, -1, -1, 538 -1, -1, -1, 124, 38, -1, 40, 41, -1, -1, 539 44, 40, 41, -1, -1, 44, 10, -1, -1, -1, 540 124, -1, 121, -1, 93, 59, -1, -1, -1, -1, 541 59, -1, -1, -1, 37, 38, -1, -1, -1, 42, 542 43, -1, 45, -1, 47, -1, 40, 41, -1, -1, 543 44, -1, 151, -1, -1, 124, -1, -1, -1, 93, 544 -1, -1, -1, -1, 93, 59, -1, 259, 260, -1, 545 262, 263, -1, 265, 266, 267, 268, 176, -1, -1, 546 -1, -1, -1, 257, 258, 259, -1, 261, 91, -1, 547 124, -1, -1, 192, 193, 124, 195, 289, 290, 93, 548 199, -1, 201, -1, 278, 279, 280, 281, 282, 283, 549 284, 285, 286, -1, 288, 289, 290, -1, 257, 258, 550 259, 124, 261, -1, -1, -1, -1, -1, -1, -1, 551 -1, -1, -1, -1, -1, -1, -1, -1, -1, 278, 552 279, 280, 281, 282, 283, 284, 285, 286, -1, 288, 553 289, 290, -1, 257, 258, 259, -1, 261, 279, 280, 554 281, 282, 283, 284, 285, 286, -1, -1, -1, -1, 555 291, -1, -1, -1, 278, 279, 280, 281, 282, 283, 556 284, 285, 286, -1, 288, 289, 290, -1, 257, 258, 557 259, -1, 261, -1, -1, -1, -1, -1, -1, -1, 558 -1, -1, -1, -1, -1, -1, -1, -1, -1, 278, 559 279, 280, 281, 282, 283, 284, 285, 286, -1, 288, 560 289, 290, -1, 257, 258, 259, -1, 261, 257, 258, 561 259, -1, 261, -1, -1, -1, -1, -1, -1, -1, 562 -1, -1, -1, -1, 278, 279, -1, -1, -1, 278, 563 279, -1, -1, -1, 288, 289, 290, -1, -1, 288, 564 289, 290, -1, 257, 258, 259, -1, 261, -1, -1, 565 -1, -1, -1, -1, -1, 278, 279, 280, 281, 282, 566 283, 284, 285, 286, 278, 279, -1, -1, 291, -1, 567 29, -1, -1, -1, 288, 289, 290, 36, 37, -1, 568 -1, -1, -1, 42, -1, -1, -1, -1, -1, -1, 569 -1, 50, -1, -1, -1, -1, -1, -1, -1, -1, 570 -1, -1, 61, -1, 63, -1, -1, -1, -1, -1, 571 -1, -1, -1, 72, -1, -1, -1, -1, 77, -1, 572 -1, -1, -1, -1, 83, 84, 85, 86, 87, 88, 573 89, 90, 91, 92, 93, 94, 95, 96, 97, -1, 574 99, 100, -1, -1, -1, -1, -1, -1, -1, -1, 575 109, 110, 111, 112, 113, 114, 115, -1, -1, -1, 576 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 577 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 578 -1, -1, -1, -1, -1, -1, -1, -1, -1, 148, 579 149, -1, -1, -1, 153, -1, -1, -1, -1, -1, 580 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 581 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 582 -1, -1, -1, 182, 183, 184, 185, 186, 187, 188, 583 189, 584 }; 585 #define YYFINAL 2 586 #ifndef YYDEBUG 587 #define YYDEBUG 0 588 #endif 589 #define YYMAXTOKEN 291 590 #if YYDEBUG 591 const char * const yyname[] = { 592 "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, 593 0,0,0,0,0,0,"''%''","''&''",0,"''(''","'')''","''*''","''+''","'',''","''-''",0,"''/''",0,0,0,0,0, 594 0,0,0,0,0,0,"'';''",0,"''=''",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 595 0,0,"''[''",0,"'']''",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 596 "''{''","''|''","''}''",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 597 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 598 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 599 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"NUMBER","STRING","SYMBOL","DELETE", 600 "ARG_LOOKUP","IF","WHILE","ELSE","FOR","BREAK","CONTINUE","RETURN","IF_NO_ELSE", 601 "ADDEQ","SUBEQ","MULEQ","DIVEQ","MODEQ","ANDEQ","OREQ","CONCAT","OR","AND","GT", 602 "GE","LT","LE","EQ","NE","IN","UNARY_MINUS","NOT","INCR","DECR","POW", 603 }; 604 const char * const yyrule[] = { 605 "$accept : program", 606 "program : blank stmts", 607 "program : blank ''{'' blank stmts ''}''", 608 "program : blank ''{'' blank ''}''", 609 "program : error", 610 "block : ''{'' blank stmts ''}'' blank", 611 "block : ''{'' blank ''}'' blank", 612 "block : stmt", 613 "stmts : stmt", 614 "stmts : stmts stmt", 615 "stmt : simpstmt ''\\n'' blank", 616 "stmt : IF ''('' cond '')'' blank block", 617 "stmt : IF ''('' cond '')'' blank block else blank block", 618 "stmt : while ''('' cond '')'' blank block", 619 "stmt : for ''('' comastmts '';'' cond '';'' comastmts '')'' blank block", 620 "$$1 :", 621 "stmt : for ''('' SYMBOL IN arrayexpr '')'' $$1 blank block", 622 "stmt : BREAK ''\\n'' blank", 623 "stmt : CONTINUE ''\\n'' blank", 624 "stmt : RETURN expr ''\\n'' blank", 625 "stmt : RETURN ''\\n'' blank", 626 "simpstmt : SYMBOL ''='' expr", 627 "simpstmt : evalsym ADDEQ expr", 628 "simpstmt : evalsym SUBEQ expr", 629 "simpstmt : evalsym MULEQ expr", 630 "simpstmt : evalsym DIVEQ expr", 631 "simpstmt : evalsym MODEQ expr", 632 "simpstmt : evalsym ANDEQ expr", 633 "simpstmt : evalsym OREQ expr", 634 "simpstmt : DELETE arraylv ''['' arglist '']''", 635 "simpstmt : initarraylv ''['' arglist '']'' ''='' expr", 636 "simpstmt : initarraylv ''['' arglist '']'' ADDEQ expr", 637 "simpstmt : initarraylv ''['' arglist '']'' SUBEQ expr", 638 "simpstmt : initarraylv ''['' arglist '']'' MULEQ expr", 639 "simpstmt : initarraylv ''['' arglist '']'' DIVEQ expr", 640 "simpstmt : initarraylv ''['' arglist '']'' MODEQ expr", 641 "simpstmt : initarraylv ''['' arglist '']'' ANDEQ expr", 642 "simpstmt : initarraylv ''['' arglist '']'' OREQ expr", 643 "simpstmt : initarraylv ''['' arglist '']'' INCR", 644 "simpstmt : initarraylv ''['' arglist '']'' DECR", 645 "simpstmt : INCR initarraylv ''['' arglist '']''", 646 "simpstmt : DECR initarraylv ''['' arglist '']''", 647 "simpstmt : SYMBOL ''('' arglist '')''", 648 "simpstmt : INCR SYMBOL", 649 "simpstmt : SYMBOL INCR", 650 "simpstmt : DECR SYMBOL", 651 "simpstmt : SYMBOL DECR", 652 "evalsym : SYMBOL", 653 "comastmts :", 654 "comastmts : simpstmt", 655 "comastmts : comastmts '','' simpstmt", 656 "arglist :", 657 "arglist : expr", 658 "arglist : arglist '','' expr", 659 "expr : numexpr", 660 "expr : expr numexpr", 661 "initarraylv : SYMBOL", 662 "initarraylv : initarraylv ''['' arglist '']''", 663 "arraylv : SYMBOL", 664 "arraylv : arraylv ''['' arglist '']''", 665 "arrayexpr : numexpr", 666 "numexpr : NUMBER", 667 "numexpr : STRING", 668 "numexpr : SYMBOL", 669 "numexpr : SYMBOL ''('' arglist '')''", 670 "numexpr : ''('' expr '')''", 671 "numexpr : ARG_LOOKUP ''['' numexpr '']''", 672 "numexpr : ARG_LOOKUP ''['' '']''", 673 "numexpr : ARG_LOOKUP", 674 "numexpr : numexpr ''['' arglist '']''", 675 "numexpr : numexpr ''+'' numexpr", 676 "numexpr : numexpr ''-'' numexpr", 677 "numexpr : numexpr ''*'' numexpr", 678 "numexpr : numexpr ''/'' numexpr", 679 "numexpr : numexpr ''%'' numexpr", 680 "numexpr : numexpr POW numexpr", 681 "numexpr : ''-'' numexpr", 682 "numexpr : numexpr GT numexpr", 683 "numexpr : numexpr GE numexpr", 684 "numexpr : numexpr LT numexpr", 685 "numexpr : numexpr LE numexpr", 686 "numexpr : numexpr EQ numexpr", 687 "numexpr : numexpr NE numexpr", 688 "numexpr : numexpr ''&'' numexpr", 689 "numexpr : numexpr ''|'' numexpr", 690 "numexpr : numexpr and numexpr", 691 "numexpr : numexpr or numexpr", 692 "numexpr : NOT numexpr", 693 "numexpr : INCR SYMBOL", 694 "numexpr : SYMBOL INCR", 695 "numexpr : DECR SYMBOL", 696 "numexpr : SYMBOL DECR", 697 "numexpr : numexpr IN numexpr", 698 "while : WHILE", 699 "for : FOR", 700 "else : ELSE", 701 "cond :", 702 "cond : numexpr", 703 "and : AND", 704 "or : OR", 705 "blank :", 706 "blank : blank ''\\n''", 707 }; 708 #endif 709 #if YYDEBUG 710 #include <stdio.h> 711 #endif 712 #ifdef YYSTACKSIZE 713 #undef YYMAXDEPTH 714 #define YYMAXDEPTH YYSTACKSIZE 715 #else 716 #ifdef YYMAXDEPTH 717 #define YYSTACKSIZE YYMAXDEPTH 718 #else 719 #define YYSTACKSIZE 10000 720 #define YYMAXDEPTH 10000 721 #endif 722 #endif 723 #define YYINITSTACKSIZE 200 724 int yydebug; 725 int yynerrs; 726 int yyerrflag; 727 int yychar; 728 short *yyssp; 729 YYSTYPE *yyvsp; 730 YYSTYPE yyval; 731 YYSTYPE yylval; 732 short *yyss; 733 short *yysslim; 734 YYSTYPE *yyvs; 735 int yystacksize; 736 #line 443 "parse.y" 737 /* User Subroutines Section */ 738 739 740 /* 741 ** Parse a null terminated string and create a program from it (this is the 742 ** parser entry point). The program created by this routine can be 743 ** executed using ExecuteProgram. Returns program on success, or NULL 744 ** on failure. If the command failed, the error message is returned 745 ** as a pointer to a static string in msg, and the length of the string up 746 ** to where parsing failed in stoppedAt. 747 */ 748 Program *ParseMacro(char *expr, char **msg, char **stoppedAt) 749 { 750 Program *prog; 751 752 BeginCreatingProgram(); 753 754 /* call yyparse to parse the string and check for success. If the parse 755 failed, return the error message and string index (the grammar aborts 756 parsing at the first error) */ 757 InPtr = expr; 758 if (yyparse()) { 759 *msg = ErrMsg; 760 *stoppedAt = InPtr; 761 FreeProgram(FinishCreatingProgram()); 762 return NULL; 763 } 764 765 /* get the newly created program */ 766 prog = FinishCreatingProgram(); 767 768 /* parse succeeded */ 769 *msg = ""; 770 *stoppedAt = InPtr; 771 return prog; 772 } 773 774 775 static int yylex(void) 776 { 777 int i, len; 778 Symbol *s; 779 static DataValue value = {NO_TAG, {0}}; 780 static char escape[] = "\\\"ntbrfave"; 781 #ifdef EBCDIC_CHARSET 782 static char replace[] = "\\\"\n\t\b\r\f\a\v\x27"; /* EBCDIC escape */ 783 #else 784 static char replace[] = "\\\"\n\t\b\r\f\a\v\x1B"; /* ASCII escape */ 785 #endif 786 787 /* skip whitespace, backslash-newline combinations, and comments, which are 788 all considered whitespace */ 789 for (;;) { 790 if (*InPtr == '\\' && *(InPtr + 1) == '\n') 791 InPtr += 2; 792 else if (*InPtr == ' ' || *InPtr == '\t') 793 InPtr++; 794 else if (*InPtr == '#') 795 while (*InPtr != '\n' && *InPtr != '\0') { 796 /* Comments stop at escaped newlines */ 797 if (*InPtr == '\\' && *(InPtr + 1) == '\n') { 798 InPtr += 2; 799 break; 800 } 801 InPtr++; 802 } else 803 break; 804 } 805 806 807 /* return end of input at the end of the string */ 808 if (*InPtr == '\0') { 809 return 0; 810 } 811 812 /* process number tokens */ 813 if (isdigit((unsigned char)*InPtr)) { /* number */ 814 char name[28]; 815 sscanf(InPtr, "%d%n", &value.val.n, &len); 816 sprintf(name, "const %d", value.val.n); 817 InPtr += len; 818 value.tag = INT_TAG; 819 if ((yylval.sym=LookupSymbol(name)) == NULL) 820 yylval.sym = InstallSymbol(name, CONST_SYM, value); 821 return NUMBER; 822 } 823 824 /* process symbol tokens. "define" is a special case not handled 825 by this parser, considered end of input. Another special case 826 is action routine names which are allowed to contain '-' despite 827 the ambiguity, handled in matchesActionRoutine. */ 828 if (isalpha((unsigned char)*InPtr) || *InPtr == '$') { 829 if ((s=matchesActionRoutine(&InPtr)) == NULL) { 830 char symName[MAX_SYM_LEN+1], *p = symName; 831 *p++ = *InPtr++; 832 while (isalnum((unsigned char)*InPtr) || *InPtr=='_') { 833 if (p >= symName + MAX_SYM_LEN) 834 InPtr++; 835 else 836 *p++ = *InPtr++; 837 } 838 *p = '\0'; 839 if (!strcmp(symName, "while")) return WHILE; 840 if (!strcmp(symName, "if")) return IF; 841 if (!strcmp(symName, "else")) return ELSE; 842 if (!strcmp(symName, "for")) return FOR; 843 if (!strcmp(symName, "break")) return BREAK; 844 if (!strcmp(symName, "continue")) return CONTINUE; 845 if (!strcmp(symName, "return")) return RETURN; 846 if (!strcmp(symName, "in")) return IN; 847 if (!strcmp(symName, "$args")) return ARG_LOOKUP; 848 if (!strcmp(symName, "delete") && follow_non_whitespace('(', SYMBOL, DELETE) == DELETE) return DELETE; 849 if (!strcmp(symName, "define")) { 850 InPtr -= 6; 851 return 0; 852 } 853 if ((s=LookupSymbol(symName)) == NULL) { 854 s = InstallSymbol(symName, symName[0]=='$' ? 855 (((symName[1] > '0' && symName[1] <= '9') && symName[2] == 0) ? 856 ARG_SYM : GLOBAL_SYM) : LOCAL_SYM, value); 857 s->value.tag = NO_TAG; 858 } 859 } 860 yylval.sym = s; 861 return SYMBOL; 862 } 863 864 /* Process quoted strings with embedded escape sequences: 865 For backslashes we recognise hexadecimal values with initial 'x' such 866 as "\x1B"; octal value (upto 3 oct digits with a possible leading zero) 867 such as "\33", "\033" or "\0033", and the C escapes: \", \', \n, \t, \b, 868 \r, \f, \a, \v, and the added \e for the escape character, as for REs. 869 Disallow hex/octal zero values (NUL): instead ignore the introductory 870 backslash, eg "\x0xyz" becomes "x0xyz" and "\0000hello" becomes 871 "0000hello". */ 872 873 if (*InPtr == '\"') { 874 char string[MAX_STRING_CONST_LEN], *p = string; 875 char *backslash; 876 InPtr++; 877 while (*InPtr != '\0' && *InPtr != '\"' && *InPtr != '\n') { 878 if (p >= string + MAX_STRING_CONST_LEN) { 879 InPtr++; 880 continue; 881 } 882 if (*InPtr == '\\') { 883 backslash = InPtr; 884 InPtr++; 885 if (*InPtr == '\n') { 886 InPtr++; 887 continue; 888 } 889 if (*InPtr == 'x') { 890 /* a hex introducer */ 891 int hexValue = 0; 892 const char *hexDigits = "0123456789abcdef"; 893 const char *hexD; 894 InPtr++; 895 if (*InPtr == '\0' || 896 (hexD = strchr(hexDigits, tolower(*InPtr))) == NULL) { 897 *p++ = 'x'; 898 } 899 else { 900 hexValue = hexD - hexDigits; 901 InPtr++; 902 /* now do we have another digit? only accept one more */ 903 if (*InPtr != '\0' && 904 (hexD = strchr(hexDigits,tolower(*InPtr))) != NULL){ 905 hexValue = hexD - hexDigits + (hexValue << 4); 906 InPtr++; 907 } 908 if (hexValue != 0) { 909 *p++ = (char)hexValue; 910 } 911 else { 912 InPtr = backslash + 1; /* just skip the backslash */ 913 } 914 } 915 continue; 916 } 917 /* the RE documentation requires \0 as the octal introducer; 918 here you can start with any octal digit, but you are only 919 allowed up to three (or four if the first is '0'). */ 920 if ('0' <= *InPtr && *InPtr <= '7') { 921 if (*InPtr == '0') { 922 InPtr++; /* octal introducer: don't count this digit */ 923 } 924 if ('0' <= *InPtr && *InPtr <= '7') { 925 /* treat as octal - first digit */ 926 char octD = *InPtr++; 927 int octValue = octD - '0'; 928 if ('0' <= *InPtr && *InPtr <= '7') { 929 /* second digit */ 930 octD = *InPtr++; 931 octValue = (octValue << 3) + octD - '0'; 932 /* now do we have another digit? can we add it? 933 if value is going to be too big for char (greater 934 than 0377), stop converting now before adding the 935 third digit */ 936 if ('0' <= *InPtr && *InPtr <= '7' && 937 octValue <= 037) { 938 /* third digit is acceptable */ 939 octD = *InPtr++; 940 octValue = (octValue << 3) + octD - '0'; 941 } 942 } 943 if (octValue != 0) { 944 *p++ = (char)octValue; 945 } 946 else { 947 InPtr = backslash + 1; /* just skip the backslash */ 948 } 949 } 950 else { /* \0 followed by non-digits: go back to 0 */ 951 InPtr = backslash + 1; /* just skip the backslash */ 952 } 953 continue; 954 } 955 for (i=0; escape[i]!='\0'; i++) { 956 if (escape[i] == *InPtr) { 957 *p++ = replace[i]; 958 InPtr++; 959 break; 960 } 961 } 962 /* if we get here, we didn't recognise the character after 963 the backslash: just copy it next time round the loop */ 964 } 965 else { 966 *p++= *InPtr++; 967 } 968 } 969 *p = '\0'; 970 InPtr++; 971 yylval.sym = InstallStringConstSymbol(string); 972 return STRING; 973 } 974 975 /* process remaining two character tokens or return single char as token */ 976 switch(*InPtr++) { 977 case '>': return follow('=', GE, GT); 978 case '<': return follow('=', LE, LT); 979 case '=': return follow('=', EQ, '='); 980 case '!': return follow('=', NE, NOT); 981 case '+': return follow2('+', INCR, '=', ADDEQ, '+'); 982 case '-': return follow2('-', DECR, '=', SUBEQ, '-'); 983 case '|': return follow2('|', OR, '=', OREQ, '|'); 984 case '&': return follow2('&', AND, '=', ANDEQ, '&'); 985 case '*': return follow2('*', POW, '=', MULEQ, '*'); 986 case '/': return follow('=', DIVEQ, '/'); 987 case '%': return follow('=', MODEQ, '%'); 988 case '^': return POW; 989 default: return *(InPtr-1); 990 } 991 } 992 993 /* 994 ** look ahead for >=, etc. 995 */ 996 static int follow(char expect, int yes, int no) 997 { 998 if (*InPtr++ == expect) 999 return yes; 1000 InPtr--; 1001 return no; 1002 } 1003 static int follow2(char expect1, int yes1, char expect2, int yes2, int no) 1004 { 1005 char next = *InPtr++; 1006 if (next == expect1) 1007 return yes1; 1008 if (next == expect2) 1009 return yes2; 1010 InPtr--; 1011 return no; 1012 } 1013 1014 static int follow_non_whitespace(char expect, int yes, int no) 1015 { 1016 char *localInPtr = InPtr; 1017 1018 while (1) { 1019 if (*localInPtr == ' ' || *localInPtr == '\t') { 1020 ++localInPtr; 1021 } 1022 else if (*localInPtr == '\\' && *(localInPtr + 1) == '\n') { 1023 localInPtr += 2; 1024 } 1025 else if (*localInPtr == expect) { 1026 return(yes); 1027 } 1028 else { 1029 return(no); 1030 } 1031 } 1032 } 1033 1034 /* 1035 ** Look (way) ahead for hyphenated routine names which begin at inPtr. A 1036 ** hyphenated name is allowed if it is pre-defined in the global symbol 1037 ** table. If a matching name exists, returns the symbol, and update "inPtr". 1038 ** 1039 ** I know this is horrible language design, but existing nedit action routine 1040 ** names contain hyphens. Handling them here in the lexical analysis process 1041 ** is much easier than trying to deal with it in the parser itself. (sorry) 1042 */ 1043 static Symbol *matchesActionRoutine(char **inPtr) 1044 { 1045 char *c, *symPtr; 1046 int hasDash = False; 1047 char symbolName[MAX_SYM_LEN+1]; 1048 Symbol *s; 1049 1050 symPtr = symbolName; 1051 for (c = *inPtr; isalnum((unsigned char)*c) || *c=='_' || 1052 ( *c=='-' && isalnum((unsigned char)(*(c+1)))); c++) { 1053 if (*c == '-') 1054 hasDash = True; 1055 *symPtr++ = *c; 1056 } 1057 if (!hasDash) 1058 return NULL; 1059 *symPtr = '\0'; 1060 s = LookupSymbol(symbolName); 1061 if (s != NULL) 1062 *inPtr = c; 1063 return s; 1064 } 1065 1066 /* 1067 ** Called by yacc to report errors (just stores for returning when 1068 ** parsing is aborted. The error token action is to immediate abort 1069 ** parsing, so this message is immediately reported to the caller 1070 ** of ParseExpr) 1071 */ 1072 static int yyerror(char *s) 1073 { 1074 ErrMsg = s; 1075 return 0; 1076 } 1077 #line 1079 "y.tab.c" 1078 /* allocate initial stack or double stack size, up to YYMAXDEPTH */ 1079 static int yygrowstack() 1080 { 1081 int newsize, i; 1082 short *newss; 1083 YYSTYPE *newvs; 1084 1085 if ((newsize = yystacksize) == 0) 1086 newsize = YYINITSTACKSIZE; 1087 else if (newsize >= YYMAXDEPTH) 1088 return -1; 1089 else if ((newsize *= 2) > YYMAXDEPTH) 1090 newsize = YYMAXDEPTH; 1091 i = yyssp - yyss; 1092 newss = yyss ? (short *)realloc(yyss, newsize * sizeof *newss) : 1093 (short *)malloc(newsize * sizeof *newss); 1094 if (newss == NULL) 1095 return -1; 1096 yyss = newss; 1097 yyssp = newss + i; 1098 newvs = yyvs ? (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs) : 1099 (YYSTYPE *)malloc(newsize * sizeof *newvs); 1100 if (newvs == NULL) 1101 return -1; 1102 yyvs = newvs; 1103 yyvsp = newvs + i; 1104 yystacksize = newsize; 1105 yysslim = yyss + newsize - 1; 1106 return 0; 1107 } 1108 1109 #define YYABORT goto yyabort 1110 #define YYREJECT goto yyabort 1111 #define YYACCEPT goto yyaccept 1112 #define YYERROR goto yyerrlab 1113 1114 #ifndef YYPARSE_PARAM 1115 #if defined(__cplusplus) || __STDC__ 1116 #define YYPARSE_PARAM_ARG void 1117 #define YYPARSE_PARAM_DECL 1118 #else /* ! ANSI-C/C++ */ 1119 #define YYPARSE_PARAM_ARG 1120 #define YYPARSE_PARAM_DECL 1121 #endif /* ANSI-C/C++ */ 1122 #else /* YYPARSE_PARAM */ 1123 #ifndef YYPARSE_PARAM_TYPE 1124 #define YYPARSE_PARAM_TYPE void * 1125 #endif 1126 #if defined(__cplusplus) || __STDC__ 1127 #define YYPARSE_PARAM_ARG YYPARSE_PARAM_TYPE YYPARSE_PARAM 1128 #define YYPARSE_PARAM_DECL 1129 #else /* ! ANSI-C/C++ */ 1130 #define YYPARSE_PARAM_ARG YYPARSE_PARAM 1131 #define YYPARSE_PARAM_DECL YYPARSE_PARAM_TYPE YYPARSE_PARAM; 1132 #endif /* ANSI-C/C++ */ 1133 #endif /* ! YYPARSE_PARAM */ 1134 1135 int 1136 yyparse (YYPARSE_PARAM_ARG) 1137 YYPARSE_PARAM_DECL 1138 { 1139 register int yym, yyn, yystate; 1140 #if YYDEBUG 1141 register const char *yys; 1142 1143 if ((yys = getenv("YYDEBUG"))) 1144 { 1145 yyn = *yys; 1146 if (yyn >= '0' && yyn <= '9') 1147 yydebug = yyn - '0'; 1148 } 1149 #endif 1150 1151 yynerrs = 0; 1152 yyerrflag = 0; 1153 yychar = (-1); 1154 1155 if (yyss == NULL && yygrowstack()) goto yyoverflow; 1156 yyssp = yyss; 1157 yyvsp = yyvs; 1158 *yyssp = yystate = 0; 1159 1160 yyloop: 1161 if ((yyn = yydefred[yystate])) goto yyreduce; 1162 if (yychar < 0) 1163 { 1164 if ((yychar = yylex()) < 0) yychar = 0; 1165 #if YYDEBUG 1166 if (yydebug) 1167 { 1168 yys = 0; 1169 if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; 1170 if (!yys) yys = "illegal-symbol"; 1171 printf("%sdebug: state %d, reading %d (%s)\n", 1172 YYPREFIX, yystate, yychar, yys); 1173 } 1174 #endif 1175 } 1176 if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && 1177 yyn <= YYTABLESIZE && yycheck[yyn] == yychar) 1178 { 1179 #if YYDEBUG 1180 if (yydebug) 1181 printf("%sdebug: state %d, shifting to state %d\n", 1182 YYPREFIX, yystate, yytable[yyn]); 1183 #endif 1184 if (yyssp >= yysslim && yygrowstack()) 1185 { 1186 goto yyoverflow; 1187 } 1188 *++yyssp = yystate = yytable[yyn]; 1189 *++yyvsp = yylval; 1190 yychar = (-1); 1191 if (yyerrflag > 0) --yyerrflag; 1192 goto yyloop; 1193 } 1194 if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && 1195 yyn <= YYTABLESIZE && yycheck[yyn] == yychar) 1196 { 1197 yyn = yytable[yyn]; 1198 goto yyreduce; 1199 } 1200 if (yyerrflag) goto yyinrecovery; 1201 #if defined(lint) || defined(__GNUC__) 1202 goto yynewerror; 1203 #endif 1204 yynewerror: 1205 yyerror("syntax error"); 1206 #if defined(lint) || defined(__GNUC__) 1207 goto yyerrlab; 1208 #endif 1209 yyerrlab: 1210 ++yynerrs; 1211 yyinrecovery: 1212 if (yyerrflag < 3) 1213 { 1214 yyerrflag = 3; 1215 for (;;) 1216 { 1217 if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 && 1218 yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) 1219 { 1220 #if YYDEBUG 1221 if (yydebug) 1222 printf("%sdebug: state %d, error recovery shifting\ 1223 to state %d\n", YYPREFIX, *yyssp, yytable[yyn]); 1224 #endif 1225 if (yyssp >= yysslim && yygrowstack()) 1226 { 1227 goto yyoverflow; 1228 } 1229 *++yyssp = yystate = yytable[yyn]; 1230 *++yyvsp = yylval; 1231 goto yyloop; 1232 } 1233 else 1234 { 1235 #if YYDEBUG 1236 if (yydebug) 1237 printf("%sdebug: error recovery discarding state %d\n", 1238 YYPREFIX, *yyssp); 1239 #endif 1240 if (yyssp <= yyss) goto yyabort; 1241 --yyssp; 1242 --yyvsp; 1243 } 1244 } 1245 } 1246 else 1247 { 1248 if (yychar == 0) goto yyabort; 1249 #if YYDEBUG 1250 if (yydebug) 1251 { 1252 yys = 0; 1253 if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; 1254 if (!yys) yys = "illegal-symbol"; 1255 printf("%sdebug: state %d, error recovery discards token %d (%s)\n", 1256 YYPREFIX, yystate, yychar, yys); 1257 } 1258 #endif 1259 yychar = (-1); 1260 goto yyloop; 1261 } 1262 yyreduce: 1263 #if YYDEBUG 1264 if (yydebug) 1265 printf("%sdebug: state %d, reducing by rule %d (%s)\n", 1266 YYPREFIX, yystate, yyn, yyrule[yyn]); 1267 #endif 1268 yym = yylen[yyn]; 1269 yyval = yyvsp[1-yym]; 1270 switch (yyn) 1271 { 1272 case 1: 1273 #line 91 "parse.y" 1274 { 1275 ADD_OP(OP_RETURN_NO_VAL); return 0; 1276 } 1277 break; 1278 case 2: 1279 #line 94 "parse.y" 1280 { 1281 ADD_OP(OP_RETURN_NO_VAL); return 0; 1282 } 1283 break; 1284 case 3: 1285 #line 97 "parse.y" 1286 { 1287 ADD_OP(OP_RETURN_NO_VAL); return 0; 1288 } 1289 break; 1290 case 4: 1291 #line 100 "parse.y" 1292 { 1293 return 1; 1294 } 1295 break; 1296 case 11: 1297 #line 112 "parse.y" 1298 { 1299 SET_BR_OFF(yyvsp[-3].inst, GetPC()); 1300 } 1301 break; 1302 case 12: 1303 #line 115 "parse.y" 1304 { 1305 SET_BR_OFF(yyvsp[-6].inst, (yyvsp[-2].inst+1)); SET_BR_OFF(yyvsp[-2].inst, GetPC()); 1306 } 1307 break; 1308 case 13: 1309 #line 118 "parse.y" 1310 { 1311 ADD_OP(OP_BRANCH); ADD_BR_OFF(yyvsp[-5].inst); 1312 SET_BR_OFF(yyvsp[-3].inst, GetPC()); FillLoopAddrs(GetPC(), yyvsp[-5].inst); 1313 } 1314 break; 1315 case 14: 1316 #line 122 "parse.y" 1317 { 1318 FillLoopAddrs(GetPC()+2+(yyvsp[-3].inst-(yyvsp[-5].inst+1)), GetPC()); 1319 SwapCode(yyvsp[-5].inst+1, yyvsp[-3].inst, GetPC()); 1320 ADD_OP(OP_BRANCH); ADD_BR_OFF(yyvsp[-7].inst); SET_BR_OFF(yyvsp[-5].inst, GetPC()); 1321 } 1322 break; 1323 case 15: 1324 #line 127 "parse.y" 1325 { 1326 Symbol *iterSym = InstallIteratorSymbol(); 1327 ADD_OP(OP_BEGIN_ARRAY_ITER); ADD_SYM(iterSym); 1328 ADD_OP(OP_ARRAY_ITER); ADD_SYM(yyvsp[-3].sym); ADD_SYM(iterSym); ADD_BR_OFF(0); 1329 } 1330 break; 1331 case 16: 1332 #line 132 "parse.y" 1333 { 1334 ADD_OP(OP_BRANCH); ADD_BR_OFF(yyvsp[-4].inst+2); 1335 SET_BR_OFF(yyvsp[-4].inst+5, GetPC()); 1336 FillLoopAddrs(GetPC(), yyvsp[-4].inst+2); 1337 } 1338 break; 1339 case 17: 1340 #line 137 "parse.y" 1341 { 1342 ADD_OP(OP_BRANCH); ADD_BR_OFF(0); 1343 if (AddBreakAddr(GetPC()-1)) { 1344 yyerror("break outside loop"); YYERROR; 1345 } 1346 } 1347 break; 1348 case 18: 1349 #line 143 "parse.y" 1350 { 1351 ADD_OP(OP_BRANCH); ADD_BR_OFF(0); 1352 if (AddContinueAddr(GetPC()-1)) { 1353 yyerror("continue outside loop"); YYERROR; 1354 } 1355 } 1356 break; 1357 case 19: 1358 #line 149 "parse.y" 1359 { 1360 ADD_OP(OP_RETURN); 1361 } 1362 break; 1363 case 20: 1364 #line 152 "parse.y" 1365 { 1366 ADD_OP(OP_RETURN_NO_VAL); 1367 } 1368 break; 1369 case 21: 1370 #line 156 "parse.y" 1371 { 1372 ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-2].sym); 1373 } 1374 break; 1375 case 22: 1376 #line 159 "parse.y" 1377 { 1378 ADD_OP(OP_ADD); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-2].sym); 1379 } 1380 break; 1381 case 23: 1382 #line 162 "parse.y" 1383 { 1384 ADD_OP(OP_SUB); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-2].sym); 1385 } 1386 break; 1387 case 24: 1388 #line 165 "parse.y" 1389 { 1390 ADD_OP(OP_MUL); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-2].sym); 1391 } 1392 break; 1393 case 25: 1394 #line 168 "parse.y" 1395 { 1396 ADD_OP(OP_DIV); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-2].sym); 1397 } 1398 break; 1399 case 26: 1400 #line 171 "parse.y" 1401 { 1402 ADD_OP(OP_MOD); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-2].sym); 1403 } 1404 break; 1405 case 27: 1406 #line 174 "parse.y" 1407 { 1408 ADD_OP(OP_BIT_AND); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-2].sym); 1409 } 1410 break; 1411 case 28: 1412 #line 177 "parse.y" 1413 { 1414 ADD_OP(OP_BIT_OR); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-2].sym); 1415 } 1416 break; 1417 case 29: 1418 #line 180 "parse.y" 1419 { 1420 ADD_OP(OP_ARRAY_DELETE); ADD_IMMED(yyvsp[-1].nArgs); 1421 } 1422 break; 1423 case 30: 1424 #line 183 "parse.y" 1425 { 1426 ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED(yyvsp[-3].nArgs); 1427 } 1428 break; 1429 case 31: 1430 #line 186 "parse.y" 1431 { 1432 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(1); ADD_IMMED(yyvsp[-3].nArgs); 1433 ADD_OP(OP_ADD); 1434 ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED(yyvsp[-3].nArgs); 1435 } 1436 break; 1437 case 32: 1438 #line 191 "parse.y" 1439 { 1440 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(1); ADD_IMMED(yyvsp[-3].nArgs); 1441 ADD_OP(OP_SUB); 1442 ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED(yyvsp[-3].nArgs); 1443 } 1444 break; 1445 case 33: 1446 #line 196 "parse.y" 1447 { 1448 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(1); ADD_IMMED(yyvsp[-3].nArgs); 1449 ADD_OP(OP_MUL); 1450 ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED(yyvsp[-3].nArgs); 1451 } 1452 break; 1453 case 34: 1454 #line 201 "parse.y" 1455 { 1456 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(1); ADD_IMMED(yyvsp[-3].nArgs); 1457 ADD_OP(OP_DIV); 1458 ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED(yyvsp[-3].nArgs); 1459 } 1460 break; 1461 case 35: 1462 #line 206 "parse.y" 1463 { 1464 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(1); ADD_IMMED(yyvsp[-3].nArgs); 1465 ADD_OP(OP_MOD); 1466 ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED(yyvsp[-3].nArgs); 1467 } 1468 break; 1469 case 36: 1470 #line 211 "parse.y" 1471 { 1472 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(1); ADD_IMMED(yyvsp[-3].nArgs); 1473 ADD_OP(OP_BIT_AND); 1474 ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED(yyvsp[-3].nArgs); 1475 } 1476 break; 1477 case 37: 1478 #line 216 "parse.y" 1479 { 1480 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(1); ADD_IMMED(yyvsp[-3].nArgs); 1481 ADD_OP(OP_BIT_OR); 1482 ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED(yyvsp[-3].nArgs); 1483 } 1484 break; 1485 case 38: 1486 #line 221 "parse.y" 1487 { 1488 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(0); ADD_IMMED(yyvsp[-2].nArgs); 1489 ADD_OP(OP_INCR); 1490 ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED(yyvsp[-2].nArgs); 1491 } 1492 break; 1493 case 39: 1494 #line 226 "parse.y" 1495 { 1496 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(0); ADD_IMMED(yyvsp[-2].nArgs); 1497 ADD_OP(OP_DECR); 1498 ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED(yyvsp[-2].nArgs); 1499 } 1500 break; 1501 case 40: 1502 #line 231 "parse.y" 1503 { 1504 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(0); ADD_IMMED(yyvsp[-1].nArgs); 1505 ADD_OP(OP_INCR); 1506 ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED(yyvsp[-1].nArgs); 1507 } 1508 break; 1509 case 41: 1510 #line 236 "parse.y" 1511 { 1512 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(0); ADD_IMMED(yyvsp[-1].nArgs); 1513 ADD_OP(OP_DECR); 1514 ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED(yyvsp[-1].nArgs); 1515 } 1516 break; 1517 case 42: 1518 #line 241 "parse.y" 1519 { 1520 ADD_OP(OP_SUBR_CALL); 1521 ADD_SYM(PromoteToGlobal(yyvsp[-3].sym)); ADD_IMMED(yyvsp[-1].nArgs); 1522 } 1523 break; 1524 case 43: 1525 #line 245 "parse.y" 1526 { 1527 ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[0].sym); ADD_OP(OP_INCR); 1528 ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[0].sym); 1529 } 1530 break; 1531 case 44: 1532 #line 249 "parse.y" 1533 { 1534 ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[-1].sym); ADD_OP(OP_INCR); 1535 ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-1].sym); 1536 } 1537 break; 1538 case 45: 1539 #line 253 "parse.y" 1540 { 1541 ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[0].sym); ADD_OP(OP_DECR); 1542 ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[0].sym); 1543 } 1544 break; 1545 case 46: 1546 #line 257 "parse.y" 1547 { 1548 ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[-1].sym); ADD_OP(OP_DECR); 1549 ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-1].sym); 1550 } 1551 break; 1552 case 47: 1553 #line 262 "parse.y" 1554 { 1555 yyval.sym = yyvsp[0].sym; ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[0].sym); 1556 } 1557 break; 1558 case 48: 1559 #line 266 "parse.y" 1560 { 1561 yyval.inst = GetPC(); 1562 } 1563 break; 1564 case 49: 1565 #line 269 "parse.y" 1566 { 1567 yyval.inst = GetPC(); 1568 } 1569 break; 1570 case 50: 1571 #line 272 "parse.y" 1572 { 1573 yyval.inst = GetPC(); 1574 } 1575 break; 1576 case 51: 1577 #line 276 "parse.y" 1578 { 1579 yyval.nArgs = 0; 1580 } 1581 break; 1582 case 52: 1583 #line 279 "parse.y" 1584 { 1585 yyval.nArgs = 1; 1586 } 1587 break; 1588 case 53: 1589 #line 282 "parse.y" 1590 { 1591 yyval.nArgs = yyvsp[-2].nArgs + 1; 1592 } 1593 break; 1594 case 55: 1595 #line 287 "parse.y" 1596 { 1597 ADD_OP(OP_CONCAT); 1598 } 1599 break; 1600 case 56: 1601 #line 291 "parse.y" 1602 { 1603 ADD_OP(OP_PUSH_ARRAY_SYM); ADD_SYM(yyvsp[0].sym); ADD_IMMED(1); 1604 } 1605 break; 1606 case 57: 1607 #line 294 "parse.y" 1608 { 1609 ADD_OP(OP_ARRAY_REF); ADD_IMMED(yyvsp[-1].nArgs); 1610 } 1611 break; 1612 case 58: 1613 #line 298 "parse.y" 1614 { 1615 ADD_OP(OP_PUSH_ARRAY_SYM); ADD_SYM(yyvsp[0].sym); ADD_IMMED(0); 1616 } 1617 break; 1618 case 59: 1619 #line 301 "parse.y" 1620 { 1621 ADD_OP(OP_ARRAY_REF); ADD_IMMED(yyvsp[-1].nArgs); 1622 } 1623 break; 1624 case 60: 1625 #line 305 "parse.y" 1626 { 1627 yyval.inst = GetPC(); 1628 } 1629 break; 1630 case 61: 1631 #line 309 "parse.y" 1632 { 1633 ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[0].sym); 1634 } 1635 break; 1636 case 62: 1637 #line 312 "parse.y" 1638 { 1639 ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[0].sym); 1640 } 1641 break; 1642 case 63: 1643 #line 315 "parse.y" 1644 { 1645 ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[0].sym); 1646 } 1647 break; 1648 case 64: 1649 #line 318 "parse.y" 1650 { 1651 ADD_OP(OP_SUBR_CALL); 1652 ADD_SYM(PromoteToGlobal(yyvsp[-3].sym)); ADD_IMMED(yyvsp[-1].nArgs); 1653 ADD_OP(OP_FETCH_RET_VAL); 1654 } 1655 break; 1656 case 66: 1657 #line 324 "parse.y" 1658 { 1659 ADD_OP(OP_PUSH_ARG); 1660 } 1661 break; 1662 case 67: 1663 #line 327 "parse.y" 1664 { 1665 ADD_OP(OP_PUSH_ARG_COUNT); 1666 } 1667 break; 1668 case 68: 1669 #line 330 "parse.y" 1670 { 1671 ADD_OP(OP_PUSH_ARG_ARRAY); 1672 } 1673 break; 1674 case 69: 1675 #line 333 "parse.y" 1676 { 1677 ADD_OP(OP_ARRAY_REF); ADD_IMMED(yyvsp[-1].nArgs); 1678 } 1679 break; 1680 case 70: 1681 #line 336 "parse.y" 1682 { 1683 ADD_OP(OP_ADD); 1684 } 1685 break; 1686 case 71: 1687 #line 339 "parse.y" 1688 { 1689 ADD_OP(OP_SUB); 1690 } 1691 break; 1692 case 72: 1693 #line 342 "parse.y" 1694 { 1695 ADD_OP(OP_MUL); 1696 } 1697 break; 1698 case 73: 1699 #line 345 "parse.y" 1700 { 1701 ADD_OP(OP_DIV); 1702 } 1703 break; 1704 case 74: 1705 #line 348 "parse.y" 1706 { 1707 ADD_OP(OP_MOD); 1708 } 1709 break; 1710 case 75: 1711 #line 351 "parse.y" 1712 { 1713 ADD_OP(OP_POWER); 1714 } 1715 break; 1716 case 76: 1717 #line 354 "parse.y" 1718 { 1719 ADD_OP(OP_NEGATE); 1720 } 1721 break; 1722 case 77: 1723 #line 357 "parse.y" 1724 { 1725 ADD_OP(OP_GT); 1726 } 1727 break; 1728 case 78: 1729 #line 360 "parse.y" 1730 { 1731 ADD_OP(OP_GE); 1732 } 1733 break; 1734 case 79: 1735 #line 363 "parse.y" 1736 { 1737 ADD_OP(OP_LT); 1738 } 1739 break; 1740 case 80: 1741 #line 366 "parse.y" 1742 { 1743 ADD_OP(OP_LE); 1744 } 1745 break; 1746 case 81: 1747 #line 369 "parse.y" 1748 { 1749 ADD_OP(OP_EQ); 1750 } 1751 break; 1752 case 82: 1753 #line 372 "parse.y" 1754 { 1755 ADD_OP(OP_NE); 1756 } 1757 break; 1758 case 83: 1759 #line 375 "parse.y" 1760 { 1761 ADD_OP(OP_BIT_AND); 1762 } 1763 break; 1764 case 84: 1765 #line 378 "parse.y" 1766 { 1767 ADD_OP(OP_BIT_OR); 1768 } 1769 break; 1770 case 85: 1771 #line 381 "parse.y" 1772 { 1773 ADD_OP(OP_AND); SET_BR_OFF(yyvsp[-1].inst, GetPC()); 1774 } 1775 break; 1776 case 86: 1777 #line 384 "parse.y" 1778 { 1779 ADD_OP(OP_OR); SET_BR_OFF(yyvsp[-1].inst, GetPC()); 1780 } 1781 break; 1782 case 87: 1783 #line 387 "parse.y" 1784 { 1785 ADD_OP(OP_NOT); 1786 } 1787 break; 1788 case 88: 1789 #line 390 "parse.y" 1790 { 1791 ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[0].sym); ADD_OP(OP_INCR); 1792 ADD_OP(OP_DUP); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[0].sym); 1793 } 1794 break; 1795 case 89: 1796 #line 394 "parse.y" 1797 { 1798 ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[-1].sym); ADD_OP(OP_DUP); 1799 ADD_OP(OP_INCR); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-1].sym); 1800 } 1801 break; 1802 case 90: 1803 #line 398 "parse.y" 1804 { 1805 ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[0].sym); ADD_OP(OP_DECR); 1806 ADD_OP(OP_DUP); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[0].sym); 1807 } 1808 break; 1809 case 91: 1810 #line 402 "parse.y" 1811 { 1812 ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[-1].sym); ADD_OP(OP_DUP); 1813 ADD_OP(OP_DECR); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-1].sym); 1814 } 1815 break; 1816 case 92: 1817 #line 406 "parse.y" 1818 { 1819 ADD_OP(OP_IN_ARRAY); 1820 } 1821 break; 1822 case 93: 1823 #line 410 "parse.y" 1824 { 1825 yyval.inst = GetPC(); StartLoopAddrList(); 1826 } 1827 break; 1828 case 94: 1829 #line 414 "parse.y" 1830 { 1831 StartLoopAddrList(); yyval.inst = GetPC(); 1832 } 1833 break; 1834 case 95: 1835 #line 418 "parse.y" 1836 { 1837 ADD_OP(OP_BRANCH); yyval.inst = GetPC(); ADD_BR_OFF(0); 1838 } 1839 break; 1840 case 96: 1841 #line 422 "parse.y" 1842 { 1843 ADD_OP(OP_BRANCH_NEVER); yyval.inst = GetPC(); ADD_BR_OFF(0); 1844 } 1845 break; 1846 case 97: 1847 #line 425 "parse.y" 1848 { 1849 ADD_OP(OP_BRANCH_FALSE); yyval.inst = GetPC(); ADD_BR_OFF(0); 1850 } 1851 break; 1852 case 98: 1853 #line 429 "parse.y" 1854 { 1855 ADD_OP(OP_DUP); ADD_OP(OP_BRANCH_FALSE); yyval.inst = GetPC(); 1856 ADD_BR_OFF(0); 1857 } 1858 break; 1859 case 99: 1860 #line 434 "parse.y" 1861 { 1862 ADD_OP(OP_DUP); ADD_OP(OP_BRANCH_TRUE); yyval.inst = GetPC(); 1863 ADD_BR_OFF(0); 1864 } 1865 break; 1866 #line 1868 "y.tab.c" 1867 } 1868 yyssp -= yym; 1869 yystate = *yyssp; 1870 yyvsp -= yym; 1871 yym = yylhs[yyn]; 1872 if (yystate == 0 && yym == 0) 1873 { 1874 #if YYDEBUG 1875 if (yydebug) 1876 printf("%sdebug: after reduction, shifting from state 0 to\ 1877 state %d\n", YYPREFIX, YYFINAL); 1878 #endif 1879 yystate = YYFINAL; 1880 *++yyssp = YYFINAL; 1881 *++yyvsp = yyval; 1882 if (yychar < 0) 1883 { 1884 if ((yychar = yylex()) < 0) yychar = 0; 1885 #if YYDEBUG 1886 if (yydebug) 1887 { 1888 yys = 0; 1889 if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; 1890 if (!yys) yys = "illegal-symbol"; 1891 printf("%sdebug: state %d, reading %d (%s)\n", 1892 YYPREFIX, YYFINAL, yychar, yys); 1893 } 1894 #endif 1895 } 1896 if (yychar == 0) goto yyaccept; 1897 goto yyloop; 1898 } 1899 if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && 1900 yyn <= YYTABLESIZE && yycheck[yyn] == yystate) 1901 yystate = yytable[yyn]; 1902 else 1903 yystate = yydgoto[yym]; 1904 #if YYDEBUG 1905 if (yydebug) 1906 printf("%sdebug: after reduction, shifting from state %d \ 1907 to state %d\n", YYPREFIX, *yyssp, yystate); 1908 #endif 1909 if (yyssp >= yysslim && yygrowstack()) 1910 { 1911 goto yyoverflow; 1912 } 1913 *++yyssp = yystate; 1914 *++yyvsp = yyval; 1915 goto yyloop; 1916 yyoverflow: 1917 yyerror("yacc stack overflow"); 1918 yyabort: 1919 return (1); 1920 yyaccept: 1921 return (0); 1922 } 1923