[insert project logo here (125x200px max)] Navigator Mailinglists Please report any errors or ommissions you find to our `Help' mailinglist, or post a message in the Forums. Copyright and Licensing Information Snap is (c) Jonathan T. Moore, 1999-2002 and licensed under the GNU General Public License (GPL). All other parts of Splash are (c) Willem de Bruijn, 2002-2003 and licensed under the BSD Open Source License. All sourcecode is made publicly available. Acknowledgement Splash and the Splash website are hosted by SourceForge.net |
Splash - DocumentationSNMP Plus a Lightweight API for SNAP Handlingsnap-1.1-wjdb/utils/snapparse.cGo to the documentation of this file.00001 /* A Bison parser, made from snapparse.y 00002 by GNU bison 1.35. */ 00003 00004 #define YYBISON 1 /* Identify Bison output. */ 00005 00006 # define T_INTV 257 00007 # define T_ADDRV 258 00008 # define T_STRV 259 00009 # define T_EXCV 260 00010 # define T_FLOATV 261 00011 # define T_MAIN 262 00012 # define T_EXIT 263 00013 # define T_PUSH 264 00014 # define T_POP 265 00015 # define T_POPI 266 00016 # define T_PULL 267 00017 # define T_EQ 268 00018 # define T_EQI 269 00019 # define T_PAJ 270 00020 # define T_TPAJ 271 00021 # define T_BEZ 272 00022 # define T_BNE 273 00023 # define T_STORE 274 00024 # define T_JI 275 00025 # define T_NEQ 276 00026 # define T_NEQI 277 00027 # define T_ADD 278 00028 # define T_ADDI 279 00029 # define T_SUB 280 00030 # define T_SUBI 281 00031 # define T_MULT 282 00032 # define T_MULTI 283 00033 # define T_DIV 284 00034 # define T_DIVI 285 00035 # define T_MOD 286 00036 # define T_MODI 287 00037 # define T_NEG 288 00038 # define T_NOT 289 00039 # define T_LNOT 290 00040 # define T_AND 291 00041 # define T_ANDI 292 00042 # define T_OR 293 00043 # define T_ORI 294 00044 # define T_LSHL 295 00045 # define T_LSHLI 296 00046 # define T_RSHL 297 00047 # define T_RSHLI 298 00048 # define T_RSHA 299 00049 # define T_RSHAI 300 00050 # define T_SNET 301 00051 # define T_SNETI 302 00052 # define T_BCAST 303 00053 # define T_BCASTI 304 00054 # define T_ISX 305 00055 # define T_GETRB 306 00056 # define T_GETSRC 307 00057 # define T_GETDST 308 00058 # define T_GETSPT 309 00059 # define T_HERE 310 00060 # define T_ISHERE 311 00061 # define T_ROUTE 312 00062 # define T_RTDEV 313 00063 # define T_SEND 314 00064 # define T_HOP 315 00065 # define T_FORW 316 00066 # define T_FORWTO 317 00067 # define T_DEMUX 318 00068 # define T_DEMUXI 319 00069 # define T_PRINT 320 00070 # define T_GETLD 321 00071 # define T_SETXH 322 00072 # define T_RAISEX 323 00073 # define T_PLUS 324 00074 # define T_MINUS 325 00075 # define T_LABEL 326 00076 # define T_LABELV 327 00077 # define T_PC 328 00078 # define T_MKTUP 329 00079 # define T_LEN 330 00080 # define T_NTH 331 00081 # define T_ISTUP 332 00082 # define T_LPAREN 333 00083 # define T_RPAREN 334 00084 # define T_COMMA 335 00085 # define T_SVCV 336 00086 # define T_CALLS 337 00087 # define T_GT 338 00088 # define T_GEQ 339 00089 # define T_LT 340 00090 # define T_LEQ 341 00091 # define T_GTI 342 00092 # define T_GEQI 343 00093 # define T_LTI 344 00094 # define T_LEQI 345 00095 # define T_DATA 346 00096 # define T_DFORW 347 00097 # define T_DFORWTO 348 00098 # define T_DSEND 349 00099 # define T_STACKEMPTY 350 00100 # define T_STACKCOUNT 351 00101 # define T_PULLSTACK 352 00102 00103 #line 1 "snapparse.y" 00104 00105 /* snap-1.0. Copyright (C) 2000 by Jonathan T. Moore and Michael Hicks. 00106 * 00107 * snapparse.y : yacc parser for SNAP assembly language 00108 * 00109 * $Id: snapparse.c,v 1.3 2003/04/16 11:29:35 wdebruij Exp $ 00110 */ 00111 00112 #include "../lib/config.h" 00113 #include <errno.h> 00114 #include <string.h> 00115 #include <stdio.h> 00116 #include <stdlib.h> 00117 #include <assert.h> 00118 #include <netinet/in.h> 00119 #include "../lib/bytecode.h" 00120 #include "../lib/dyncheck.h" 00121 #include "../lib/packet.h" 00122 #include "../lib/io.h" 00123 #include "../lib/memalloc.h" 00124 #include "labels.h" 00125 #include "../lib/d_printf.h" 00126 #include "../lib/list.h" 00127 00128 extern packet_t *p; 00129 00130 #define CHECK_CODE_OVERFLOW(p) \ 00131 if ((p)->pc >= (p)->code_max) { \ 00132 fprintf(stderr,"%s:%d: code overflow\n", \ 00133 __FILE__,__LINE__); \ 00134 fflush(stderr); \ 00135 exit(1); \ 00136 } 00137 00138 int newho(buffer_t *b,char *file,int line); 00139 int newtup(list_t *vlist, char *file, int line); 00140 00141 #ifdef SMALL_INSTRS 00142 OPCODE_T refine_op(OPCODE_T op, TAG_T vtag); 00143 #endif 00144 00145 void yyerror(char *s); 00146 00147 /* literal values from the lexer */ 00148 extern int value_int; 00149 extern uint32 value_addr; 00150 extern buffer_t value_str; 00151 extern int value_exc; 00152 extern float32 value_float; 00153 00154 extern int noop; 00155 00156 static char *label = NULL; 00157 00158 00159 #line 56 "snapparse.y" 00160 #ifndef YYSTYPE 00161 typedef union { 00162 void *ptr; 00163 int integer; 00164 } yystype; 00165 # define YYSTYPE yystype 00166 # define YYSTYPE_IS_TRIVIAL 1 00167 #endif 00168 #ifndef YYDEBUG 00169 # define YYDEBUG 0 00170 #endif 00171 00172 00173 00174 #define YYFINAL 117 00175 #define YYFLAG -32768 00176 #define YYNTBASE 99 00177 00178 /* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */ 00179 #define YYTRANSLATE(x) ((unsigned)(x) <= 352 ? yytranslate[x] : 109) 00180 00181 /* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */ 00182 static const char yytranslate[] = 00183 { 00184 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 00185 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 00186 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 00187 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 00188 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 00189 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 00190 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 00191 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 00192 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 00193 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 00194 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 00195 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 00196 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 00197 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 00198 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 00199 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 00200 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 00201 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 00202 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 00203 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 00204 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 00205 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 00206 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 00207 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 00208 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 00209 2, 2, 2, 2, 2, 2, 1, 3, 4, 5, 00210 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 00211 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 00212 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 00213 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 00214 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 00215 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 00216 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 00217 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 00218 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 00219 96, 97, 98 00220 }; 00221 00222 #if YYDEBUG 00223 static const short yyprhs[] = 00224 { 00225 0, 0, 3, 4, 6, 9, 12, 15, 18, 20, 00226 22, 25, 27, 29, 31, 33, 35, 37, 39, 41, 00227 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 00228 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 00229 83, 85, 87, 89, 91, 93, 95, 97, 99, 101, 00230 103, 105, 107, 109, 111, 113, 115, 117, 119, 121, 00231 123, 125, 127, 129, 131, 133, 135, 137, 139, 141, 00232 143, 145, 147, 149, 151, 153, 155, 157, 159, 161, 00233 163, 165, 167, 169, 171, 173, 175, 177, 179, 181, 00234 183, 185, 187, 189, 191, 193, 195, 197, 201, 205, 00235 207, 211, 215, 217, 219 00236 }; 00237 static const short yyrhs[] = 00238 { 00239 100, 99, 0, 0, 101, 0, 102, 108, 0, 103, 00240 4, 0, 104, 5, 0, 105, 106, 0, 8, 0, 00241 72, 0, 92, 106, 0, 9, 0, 11, 0, 14, 00242 0, 22, 0, 24, 0, 26, 0, 28, 0, 30, 00243 0, 32, 0, 34, 0, 35, 0, 36, 0, 37, 00244 0, 39, 0, 41, 0, 43, 0, 45, 0, 51, 00245 0, 52, 0, 53, 0, 54, 0, 55, 0, 67, 00246 0, 68, 0, 69, 0, 56, 0, 57, 0, 58, 00247 0, 59, 0, 60, 0, 61, 0, 62, 0, 63, 00248 0, 64, 0, 66, 0, 76, 0, 78, 0, 47, 00249 0, 49, 0, 84, 0, 85, 0, 86, 0, 87, 00250 0, 95, 0, 93, 0, 94, 0, 96, 0, 97, 00251 0, 98, 0, 13, 0, 20, 0, 16, 0, 17, 00252 0, 18, 0, 19, 0, 12, 0, 33, 0, 38, 00253 0, 40, 0, 42, 0, 44, 0, 46, 0, 21, 00254 0, 75, 0, 77, 0, 50, 0, 65, 0, 48, 00255 0, 82, 0, 83, 0, 10, 0, 15, 0, 23, 00256 0, 25, 0, 27, 0, 29, 0, 31, 0, 88, 00257 0, 89, 0, 90, 0, 91, 0, 108, 0, 4, 00258 0, 7, 0, 5, 0, 6, 0, 79, 107, 80, 00259 0, 106, 81, 107, 0, 106, 0, 108, 70, 108, 00260 0, 108, 71, 108, 0, 74, 0, 3, 0, 73, 00261 0 00262 }; 00263 00264 #endif 00265 00266 #if YYDEBUG 00267 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ 00268 static const short yyrline[] = 00269 { 00270 0, 87, 88, 91, 96, 112, 127, 134, 152, 153, 00271 154, 170, 171, 172, 173, 174, 175, 176, 177, 178, 00272 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 00273 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 00274 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 00275 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 00276 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 00277 231, 232, 233, 234, 235, 236, 239, 240, 241, 244, 00278 245, 248, 249, 250, 251, 252, 253, 254, 255, 256, 00279 257, 258, 261, 273, 288, 303, 311, 324, 335, 337, 00280 340, 341, 342, 343, 344 00281 }; 00282 #endif 00283 00284 00285 #if (YYDEBUG) || defined YYERROR_VERBOSE 00286 00287 /* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */ 00288 static const char *const yytname[] = 00289 { 00290 "$", "error", "$undefined.", "T_INTV", "T_ADDRV", "T_STRV", "T_EXCV", 00291 "T_FLOATV", "T_MAIN", "T_EXIT", "T_PUSH", "T_POP", "T_POPI", "T_PULL", 00292 "T_EQ", "T_EQI", "T_PAJ", "T_TPAJ", "T_BEZ", "T_BNE", "T_STORE", "T_JI", 00293 "T_NEQ", "T_NEQI", "T_ADD", "T_ADDI", "T_SUB", "T_SUBI", "T_MULT", 00294 "T_MULTI", "T_DIV", "T_DIVI", "T_MOD", "T_MODI", "T_NEG", "T_NOT", 00295 "T_LNOT", "T_AND", "T_ANDI", "T_OR", "T_ORI", "T_LSHL", "T_LSHLI", 00296 "T_RSHL", "T_RSHLI", "T_RSHA", "T_RSHAI", "T_SNET", "T_SNETI", 00297 "T_BCAST", "T_BCASTI", "T_ISX", "T_GETRB", "T_GETSRC", "T_GETDST", 00298 "T_GETSPT", "T_HERE", "T_ISHERE", "T_ROUTE", "T_RTDEV", "T_SEND", 00299 "T_HOP", "T_FORW", "T_FORWTO", "T_DEMUX", "T_DEMUXI", "T_PRINT", 00300 "T_GETLD", "T_SETXH", "T_RAISEX", "T_PLUS", "T_MINUS", "T_LABEL", 00301 "T_LABELV", "T_PC", "T_MKTUP", "T_LEN", "T_NTH", "T_ISTUP", "T_LPAREN", 00302 "T_RPAREN", "T_COMMA", "T_SVCV", "T_CALLS", "T_GT", "T_GEQ", "T_LT", 00303 "T_LEQ", "T_GTI", "T_GEQI", "T_LTI", "T_LEQI", "T_DATA", "T_DFORW", 00304 "T_DFORWTO", "T_DSEND", "T_STACKEMPTY", "T_STACKCOUNT", "T_PULLSTACK", 00305 "instrs", "instr", "op0", "opint", "opaddr", "opstr", "op1", "value", 00306 "value_list", "int_expr", 0 00307 }; 00308 #endif 00309 00310 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ 00311 static const short yyr1[] = 00312 { 00313 0, 99, 99, 100, 100, 100, 100, 100, 100, 100, 00314 100, 101, 101, 101, 101, 101, 101, 101, 101, 101, 00315 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 00316 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 00317 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 00318 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 00319 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 00320 102, 102, 102, 102, 102, 102, 103, 103, 103, 104, 00321 104, 105, 105, 105, 105, 105, 105, 105, 105, 105, 00322 105, 105, 106, 106, 106, 106, 106, 106, 107, 107, 00323 108, 108, 108, 108, 108 00324 }; 00325 00326 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ 00327 static const short yyr2[] = 00328 { 00329 0, 2, 0, 1, 2, 2, 2, 2, 1, 1, 00330 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 00331 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 00332 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 00333 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 00334 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 00335 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 00336 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 00337 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 00338 1, 1, 1, 1, 1, 1, 1, 3, 3, 1, 00339 3, 3, 1, 1, 1 00340 }; 00341 00342 /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE 00343 doesn't specify something else to do. Zero means the default is an 00344 error. */ 00345 static const short yydefact[] = 00346 { 00347 2, 8, 11, 81, 12, 66, 60, 13, 82, 62, 00348 63, 64, 65, 61, 73, 14, 83, 15, 84, 16, 00349 85, 17, 86, 18, 87, 19, 67, 20, 21, 22, 00350 23, 68, 24, 69, 25, 70, 26, 71, 27, 72, 00351 48, 78, 49, 76, 28, 29, 30, 31, 32, 36, 00352 37, 38, 39, 40, 41, 42, 43, 44, 77, 45, 00353 33, 34, 35, 9, 74, 46, 75, 47, 79, 80, 00354 50, 51, 52, 53, 88, 89, 90, 91, 0, 55, 00355 56, 54, 57, 58, 59, 2, 3, 0, 0, 0, 00356 0, 103, 93, 95, 96, 94, 104, 102, 0, 10, 00357 92, 1, 4, 5, 6, 7, 99, 0, 0, 0, 00358 0, 97, 100, 101, 98, 0, 0, 0 00359 }; 00360 00361 static const short yydefgoto[] = 00362 { 00363 101, 85, 86, 87, 88, 89, 90, 106, 107, 100 00364 }; 00365 00366 static const short yypact[] = 00367 { 00368 -8,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 00369 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 00370 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 00371 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 00372 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 00373 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 00374 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 00375 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 88,-32768, 00376 -32768,-32768,-32768,-32768,-32768, -8,-32768, 59, 67, 58, 00377 88,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 88,-32768, 00378 -5,-32768, -5,-32768,-32768,-32768, -9, -7, 59, 59, 00379 88,-32768,-32768,-32768,-32768, 98, 99,-32768 00380 }; 00381 00382 static const short yypgoto[] = 00383 { 00384 100,-32768,-32768,-32768,-32768,-32768,-32768, 19, -6, 9 00385 }; 00386 00387 00388 #define YYLAST 167 00389 00390 00391 static const short yytable[] = 00392 { 00393 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 00394 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 00395 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 00396 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 00397 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 00398 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 00399 61, 62, 91, 104, 63, 108, 109, 64, 65, 66, 00400 67, 103, 110, 111, 68, 69, 70, 71, 72, 73, 00401 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 00402 84, 91, 92, 93, 94, 95, 102, 99, 116, 117, 00403 115, 0, 0, 0, 114, 0, 0, 0, 0, 105, 00404 0, 0, 0, 0, 0, 0, 0, 112, 113, 0, 00405 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 00406 0, 0, 96, 97, 0, 0, 0, 0, 0, 0, 00407 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 00408 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 00409 0, 96, 97, 0, 0, 0, 0, 98 00410 }; 00411 00412 static const short yycheck[] = 00413 { 00414 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 00415 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 00416 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 00417 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 00418 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 00419 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 00420 68, 69, 3, 5, 72, 70, 71, 75, 76, 77, 00421 78, 4, 81, 80, 82, 83, 84, 85, 86, 87, 00422 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 00423 98, 3, 4, 5, 6, 7, 87, 78, 0, 0, 00424 0, -1, -1, -1, 110, -1, -1, -1, -1, 90, 00425 -1, -1, -1, -1, -1, -1, -1, 108, 109, -1, 00426 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 00427 -1, -1, 73, 74, -1, -1, -1, -1, -1, -1, 00428 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 00429 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 00430 -1, 73, 74, -1, -1, -1, -1, 79 00431 }; 00432 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ 00433 #line 3 "/usr/share/bison/bison.simple" 00434 00435 /* Skeleton output parser for bison, 00436 00437 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software 00438 Foundation, Inc. 00439 00440 This program is free software; you can redistribute it and/or modify 00441 it under the terms of the GNU General Public License as published by 00442 the Free Software Foundation; either version 2, or (at your option) 00443 any later version. 00444 00445 This program is distributed in the hope that it will be useful, 00446 but WITHOUT ANY WARRANTY; without even the implied warranty of 00447 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00448 GNU General Public License for more details. 00449 00450 You should have received a copy of the GNU General Public License 00451 along with this program; if not, write to the Free Software 00452 Foundation, Inc., 59 Temple Place - Suite 330, 00453 Boston, MA 02111-1307, USA. */ 00454 00455 /* As a special exception, when this file is copied by Bison into a 00456 Bison output file, you may use that output file without restriction. 00457 This special exception was added by the Free Software Foundation 00458 in version 1.24 of Bison. */ 00459 00460 /* This is the parser code that is written into each bison parser when 00461 the %semantic_parser declaration is not specified in the grammar. 00462 It was written by Richard Stallman by simplifying the hairy parser 00463 used when %semantic_parser is specified. */ 00464 00465 /* All symbols defined below should begin with yy or YY, to avoid 00466 infringing on user name space. This should be done even for local 00467 variables, as they might otherwise be expanded by user macros. 00468 There are some unavoidable exceptions within include files to 00469 define necessary library symbols; they are noted "INFRINGES ON 00470 USER NAME SPACE" below. */ 00471 00472 #if ! defined (yyoverflow) || defined (YYERROR_VERBOSE) 00473 00474 /* The parser invokes alloca or malloc; define the necessary symbols. */ 00475 00476 # if YYSTACK_USE_ALLOCA 00477 # define YYSTACK_ALLOC alloca 00478 # else 00479 # ifndef YYSTACK_USE_ALLOCA 00480 # if defined (alloca) || defined (_ALLOCA_H) 00481 # define YYSTACK_ALLOC alloca 00482 # else 00483 # ifdef __GNUC__ 00484 # define YYSTACK_ALLOC __builtin_alloca 00485 # endif 00486 # endif 00487 # endif 00488 # endif 00489 00490 # ifdef YYSTACK_ALLOC 00491 /* Pacify GCC's `empty if-body' warning. */ 00492 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) 00493 # else 00494 # if defined (__STDC__) || defined (__cplusplus) 00495 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ 00496 # define YYSIZE_T size_t 00497 # endif 00498 # define YYSTACK_ALLOC malloc 00499 # define YYSTACK_FREE free 00500 # endif 00501 #endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */ 00502 00503 00504 #if (! defined (yyoverflow) \ 00505 && (! defined (__cplusplus) \ 00506 || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) 00507 00508 /* A type that is properly aligned for any stack member. */ 00509 union yyalloc 00510 { 00511 short yyss; 00512 YYSTYPE yyvs; 00513 # if YYLSP_NEEDED 00514 YYLTYPE yyls; 00515 # endif 00516 }; 00517 00518 /* The size of the maximum gap between one aligned stack and the next. */ 00519 # define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1) 00520 00521 /* The size of an array large to enough to hold all stacks, each with 00522 N elements. */ 00523 # if YYLSP_NEEDED 00524 # define YYSTACK_BYTES(N) \ 00525 ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ 00526 + 2 * YYSTACK_GAP_MAX) 00527 # else 00528 # define YYSTACK_BYTES(N) \ 00529 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ 00530 + YYSTACK_GAP_MAX) 00531 # endif 00532 00533 /* Copy COUNT objects from FROM to TO. The source and destination do 00534 not overlap. */ 00535 # ifndef YYCOPY 00536 # if 1 < __GNUC__ 00537 # define YYCOPY(To, From, Count) \ 00538 __builtin_memcpy (To, From, (Count) * sizeof (*(From))) 00539 # else 00540 # define YYCOPY(To, From, Count) \ 00541 do \ 00542 { \ 00543 register YYSIZE_T yyi; \ 00544 for (yyi = 0; yyi < (Count); yyi++) \ 00545 (To)[yyi] = (From)[yyi]; \ 00546 } \ 00547 while (0) 00548 # endif 00549 # endif 00550 00551 /* Relocate STACK from its old location to the new one. The 00552 local variables YYSIZE and YYSTACKSIZE give the old and new number of 00553 elements in the stack, and YYPTR gives the new location of the 00554 stack. Advance YYPTR to a properly aligned location for the next 00555 stack. */ 00556 # define YYSTACK_RELOCATE(Stack) \ 00557 do \ 00558 { \ 00559 YYSIZE_T yynewbytes; \ 00560 YYCOPY (&yyptr->Stack, Stack, yysize); \ 00561 Stack = &yyptr->Stack; \ 00562 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX; \ 00563 yyptr += yynewbytes / sizeof (*yyptr); \ 00564 } \ 00565 while (0) 00566 00567 #endif 00568 00569 00570 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) 00571 # define YYSIZE_T __SIZE_TYPE__ 00572 #endif 00573 #if ! defined (YYSIZE_T) && defined (size_t) 00574 # define YYSIZE_T size_t 00575 #endif 00576 #if ! defined (YYSIZE_T) 00577 # if defined (__STDC__) || defined (__cplusplus) 00578 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ 00579 # define YYSIZE_T size_t 00580 # endif 00581 #endif 00582 #if ! defined (YYSIZE_T) 00583 # define YYSIZE_T unsigned int 00584 #endif 00585 00586 #define yyerrok (yyerrstatus = 0) 00587 #define yyclearin (yychar = YYEMPTY) 00588 #define YYEMPTY -2 00589 #define YYEOF 0 00590 #define YYACCEPT goto yyacceptlab 00591 #define YYABORT goto yyabortlab 00592 #define YYERROR goto yyerrlab1 00593 /* Like YYERROR except do call yyerror. This remains here temporarily 00594 to ease the transition to the new meaning of YYERROR, for GCC. 00595 Once GCC version 2 has supplanted version 1, this can go. */ 00596 #define YYFAIL goto yyerrlab 00597 #define YYRECOVERING() (!!yyerrstatus) 00598 #define YYBACKUP(Token, Value) \ 00599 do \ 00600 if (yychar == YYEMPTY && yylen == 1) \ 00601 { \ 00602 yychar = (Token); \ 00603 yylval = (Value); \ 00604 yychar1 = YYTRANSLATE (yychar); \ 00605 YYPOPSTACK; \ 00606 goto yybackup; \ 00607 } \ 00608 else \ 00609 { \ 00610 yyerror ("syntax error: cannot back up"); \ 00611 YYERROR; \ 00612 } \ 00613 while (0) 00614 00615 #define YYTERROR 1 00616 #define YYERRCODE 256 00617 00618 00619 /* YYLLOC_DEFAULT -- Compute the default location (before the actions 00620 are run). 00621 00622 When YYLLOC_DEFAULT is run, CURRENT is set the location of the 00623 first token. By default, to implement support for ranges, extend 00624 its range to the last symbol. */ 00625 00626 #ifndef YYLLOC_DEFAULT 00627 # define YYLLOC_DEFAULT(Current, Rhs, N) \ 00628 Current.last_line = Rhs[N].last_line; \ 00629 Current.last_column = Rhs[N].last_column; 00630 #endif 00631 00632 00633 /* YYLEX -- calling `yylex' with the right arguments. */ 00634 00635 #if YYPURE 00636 # if YYLSP_NEEDED 00637 # ifdef YYLEX_PARAM 00638 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM) 00639 # else 00640 # define YYLEX yylex (&yylval, &yylloc) 00641 # endif 00642 # else /* !YYLSP_NEEDED */ 00643 # ifdef YYLEX_PARAM 00644 # define YYLEX yylex (&yylval, YYLEX_PARAM) 00645 # else 00646 # define YYLEX yylex (&yylval) 00647 # endif 00648 # endif /* !YYLSP_NEEDED */ 00649 #else /* !YYPURE */ 00650 # define YYLEX yylex () 00651 #endif /* !YYPURE */ 00652 00653 00654 /* Enable debugging if requested. */ 00655 #if YYDEBUG 00656 00657 # ifndef YYFPRINTF 00658 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */ 00659 # define YYFPRINTF fprintf 00660 # endif 00661 00662 # define YYDPRINTF(Args) \ 00663 do { \ 00664 if (yydebug) \ 00665 YYFPRINTF Args; \ 00666 } while (0) 00667 /* Nonzero means print parse trace. It is left uninitialized so that 00668 multiple parsers can coexist. */ 00669 int yydebug; 00670 #else /* !YYDEBUG */ 00671 # define YYDPRINTF(Args) 00672 #endif /* !YYDEBUG */ 00673 00674 /* YYINITDEPTH -- initial size of the parser's stacks. */ 00675 #ifndef YYINITDEPTH 00676 # define YYINITDEPTH 200 00677 #endif 00678 00679 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only 00680 if the built-in stack extension method is used). 00681 00682 Do not make this value too large; the results are undefined if 00683 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) 00684 evaluated with infinite-precision integer arithmetic. */ 00685 00686 #if YYMAXDEPTH == 0 00687 # undef YYMAXDEPTH 00688 #endif 00689 00690 #ifndef YYMAXDEPTH 00691 # define YYMAXDEPTH 10000 00692 #endif 00693 00694 #ifdef YYERROR_VERBOSE 00695 00696 # ifndef yystrlen 00697 # if defined (__GLIBC__) && defined (_STRING_H) 00698 # define yystrlen strlen 00699 # else 00700 /* Return the length of YYSTR. */ 00701 static YYSIZE_T 00702 # if defined (__STDC__) || defined (__cplusplus) 00703 yystrlen (const char *yystr) 00704 # else 00705 yystrlen (yystr) 00706 const char *yystr; 00707 # endif 00708 { 00709 register const char *yys = yystr; 00710 00711 while (*yys++ != '\0') 00712 continue; 00713 00714 return yys - yystr - 1; 00715 } 00716 # endif 00717 # endif 00718 00719 # ifndef yystpcpy 00720 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) 00721 # define yystpcpy stpcpy 00722 # else 00723 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in 00724 YYDEST. */ 00725 static char * 00726 # if defined (__STDC__) || defined (__cplusplus) 00727 yystpcpy (char *yydest, const char *yysrc) 00728 # else 00729 yystpcpy (yydest, yysrc) 00730 char *yydest; 00731 const char *yysrc; 00732 # endif 00733 { 00734 register char *yyd = yydest; 00735 register const char *yys = yysrc; 00736 00737 while ((*yyd++ = *yys++) != '\0') 00738 continue; 00739 00740 return yyd - 1; 00741 } 00742 # endif 00743 # endif 00744 #endif 00745 00746 #line 315 "/usr/share/bison/bison.simple" 00747 00748 00749 /* The user can define YYPARSE_PARAM as the name of an argument to be passed 00750 into yyparse. The argument should have type void *. 00751 It should actually point to an object. 00752 Grammar actions can access the variable by casting it 00753 to the proper pointer type. */ 00754 00755 #ifdef YYPARSE_PARAM 00756 # if defined (__STDC__) || defined (__cplusplus) 00757 # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM 00758 # define YYPARSE_PARAM_DECL 00759 # else 00760 # define YYPARSE_PARAM_ARG YYPARSE_PARAM 00761 # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; 00762 # endif 00763 #else /* !YYPARSE_PARAM */ 00764 # define YYPARSE_PARAM_ARG 00765 # define YYPARSE_PARAM_DECL 00766 #endif /* !YYPARSE_PARAM */ 00767 00768 /* Prevent warning if -Wstrict-prototypes. */ 00769 #ifdef __GNUC__ 00770 # ifdef YYPARSE_PARAM 00771 int yyparse (void *); 00772 # else 00773 int yyparse (void); 00774 # endif 00775 #endif 00776 00777 /* YY_DECL_VARIABLES -- depending whether we use a pure parser, 00778 variables are global, or local to YYPARSE. */ 00779 00780 #define YY_DECL_NON_LSP_VARIABLES \ 00781 /* The lookahead symbol. */ \ 00782 int yychar; \ 00783 \ 00784 /* The semantic value of the lookahead symbol. */ \ 00785 YYSTYPE yylval; \ 00786 \ 00787 /* Number of parse errors so far. */ \ 00788 int yynerrs; 00789 00790 #if YYLSP_NEEDED 00791 # define YY_DECL_VARIABLES \ 00792 YY_DECL_NON_LSP_VARIABLES \ 00793 \ 00794 /* Location data for the lookahead symbol. */ \ 00795 YYLTYPE yylloc; 00796 #else 00797 # define YY_DECL_VARIABLES \ 00798 YY_DECL_NON_LSP_VARIABLES 00799 #endif 00800 00801 00802 /* If nonreentrant, generate the variables here. */ 00803 00804 #if !YYPURE 00805 YY_DECL_VARIABLES 00806 #endif /* !YYPURE */ 00807 00808 int 00809 yyparse (YYPARSE_PARAM_ARG) 00810 YYPARSE_PARAM_DECL 00811 { 00812 /* If reentrant, generate the variables here. */ 00813 #if YYPURE 00814 YY_DECL_VARIABLES 00815 #endif /* !YYPURE */ 00816 00817 register int yystate; 00818 register int yyn; 00819 int yyresult; 00820 /* Number of tokens to shift before error messages enabled. */ 00821 int yyerrstatus; 00822 /* Lookahead token as an internal (translated) token number. */ 00823 int yychar1 = 0; 00824 00825 /* Three stacks and their tools: 00826 `yyss': related to states, 00827 `yyvs': related to semantic values, 00828 `yyls': related to locations. 00829 00830 Refer to the stacks thru separate pointers, to allow yyoverflow 00831 to reallocate them elsewhere. */ 00832 00833 /* The state stack. */ 00834 short yyssa[YYINITDEPTH]; 00835 short *yyss = yyssa; 00836 register short *yyssp; 00837 00838 /* The semantic value stack. */ 00839 YYSTYPE yyvsa[YYINITDEPTH]; 00840 YYSTYPE *yyvs = yyvsa; 00841 register YYSTYPE *yyvsp; 00842 00843 #if YYLSP_NEEDED 00844 /* The location stack. */ 00845 YYLTYPE yylsa[YYINITDEPTH]; 00846 YYLTYPE *yyls = yylsa; 00847 YYLTYPE *yylsp; 00848 #endif 00849 00850 #if YYLSP_NEEDED 00851 # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) 00852 #else 00853 # define YYPOPSTACK (yyvsp--, yyssp--) 00854 #endif 00855 00856 YYSIZE_T yystacksize = YYINITDEPTH; 00857 00858 00859 /* The variables used to return semantic value and location from the 00860 action routines. */ 00861 YYSTYPE yyval; 00862 #if YYLSP_NEEDED 00863 YYLTYPE yyloc; 00864 #endif 00865 00866 /* When reducing, the number of symbols on the RHS of the reduced 00867 rule. */ 00868 int yylen; 00869 00870 YYDPRINTF ((stderr, "Starting parse\n")); 00871 00872 yystate = 0; 00873 yyerrstatus = 0; 00874 yynerrs = 0; 00875 yychar = YYEMPTY; /* Cause a token to be read. */ 00876 00877 /* Initialize stack pointers. 00878 Waste one element of value and location stack 00879 so that they stay on the same level as the state stack. 00880 The wasted elements are never initialized. */ 00881 00882 yyssp = yyss; 00883 yyvsp = yyvs; 00884 #if YYLSP_NEEDED 00885 yylsp = yyls; 00886 #endif 00887 goto yysetstate; 00888 00889 /*------------------------------------------------------------. 00890 | yynewstate -- Push a new state, which is found in yystate. | 00891 `------------------------------------------------------------*/ 00892 yynewstate: 00893 /* In all cases, when you get here, the value and location stacks 00894 have just been pushed. so pushing a state here evens the stacks. 00895 */ 00896 yyssp++; 00897 00898 yysetstate: 00899 *yyssp = yystate; 00900 00901 if (yyssp >= yyss + yystacksize - 1) 00902 { 00903 /* Get the current used size of the three stacks, in elements. */ 00904 YYSIZE_T yysize = yyssp - yyss + 1; 00905 00906 #ifdef yyoverflow 00907 { 00908 /* Give user a chance to reallocate the stack. Use copies of 00909 these so that the &'s don't force the real ones into 00910 memory. */ 00911 YYSTYPE *yyvs1 = yyvs; 00912 short *yyss1 = yyss; 00913 00914 /* Each stack pointer address is followed by the size of the 00915 data in use in that stack, in bytes. */ 00916 # if YYLSP_NEEDED 00917 YYLTYPE *yyls1 = yyls; 00918 /* This used to be a conditional around just the two extra args, 00919 but that might be undefined if yyoverflow is a macro. */ 00920 yyoverflow ("parser stack overflow", 00921 &yyss1, yysize * sizeof (*yyssp), 00922 &yyvs1, yysize * sizeof (*yyvsp), 00923 &yyls1, yysize * sizeof (*yylsp), 00924 &yystacksize); 00925 yyls = yyls1; 00926 # else 00927 yyoverflow ("parser stack overflow", 00928 &yyss1, yysize * sizeof (*yyssp), 00929 &yyvs1, yysize * sizeof (*yyvsp), 00930 &yystacksize); 00931 # endif 00932 yyss = yyss1; 00933 yyvs = yyvs1; 00934 } 00935 #else /* no yyoverflow */ 00936 # ifndef YYSTACK_RELOCATE 00937 goto yyoverflowlab; 00938 # else 00939 /* Extend the stack our own way. */ 00940 if (yystacksize >= YYMAXDEPTH) 00941 goto yyoverflowlab; 00942 yystacksize *= 2; 00943 if (yystacksize > YYMAXDEPTH) 00944 yystacksize = YYMAXDEPTH; 00945 00946 { 00947 short *yyss1 = yyss; 00948 union yyalloc *yyptr = 00949 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); 00950 if (! yyptr) 00951 goto yyoverflowlab; 00952 YYSTACK_RELOCATE (yyss); 00953 YYSTACK_RELOCATE (yyvs); 00954 # if YYLSP_NEEDED 00955 YYSTACK_RELOCATE (yyls); 00956 # endif 00957 # undef YYSTACK_RELOCATE 00958 if (yyss1 != yyssa) 00959 YYSTACK_FREE (yyss1); 00960 } 00961 # endif 00962 #endif /* no yyoverflow */ 00963 00964 yyssp = yyss + yysize - 1; 00965 yyvsp = yyvs + yysize - 1; 00966 #if YYLSP_NEEDED 00967 yylsp = yyls + yysize - 1; 00968 #endif 00969 00970 YYDPRINTF ((stderr, "Stack size increased to %lu\n", 00971 (unsigned long int) yystacksize)); 00972 00973 if (yyssp >= yyss + yystacksize - 1) 00974 YYABORT; 00975 } 00976 00977 YYDPRINTF ((stderr, "Entering state %d\n", yystate)); 00978 00979 goto yybackup; 00980 00981 00982 /*-----------. 00983 | yybackup. | 00984 `-----------*/ 00985 yybackup: 00986 00987 /* Do appropriate processing given the current state. */ 00988 /* Read a lookahead token if we need one and don't already have one. */ 00989 /* yyresume: */ 00990 00991 /* First try to decide what to do without reference to lookahead token. */ 00992 00993 yyn = yypact[yystate]; 00994 if (yyn == YYFLAG) 00995 goto yydefault; 00996 00997 /* Not known => get a lookahead token if don't already have one. */ 00998 00999 /* yychar is either YYEMPTY or YYEOF 01000 or a valid token in external form. */ 01001 01002 if (yychar == YYEMPTY) 01003 { 01004 YYDPRINTF ((stderr, "Reading a token: ")); 01005 yychar = YYLEX; 01006 } 01007 01008 /* Convert token to internal form (in yychar1) for indexing tables with */ 01009 01010 if (yychar <= 0) /* This means end of input. */ 01011 { 01012 yychar1 = 0; 01013 yychar = YYEOF; /* Don't call YYLEX any more */ 01014 01015 YYDPRINTF ((stderr, "Now at end of input.\n")); 01016 } 01017 else 01018 { 01019 yychar1 = YYTRANSLATE (yychar); 01020 01021 #if YYDEBUG 01022 /* We have to keep this `#if YYDEBUG', since we use variables 01023 which are defined only if `YYDEBUG' is set. */ 01024 if (yydebug) 01025 { 01026 YYFPRINTF (stderr, "Next token is %d (%s", 01027 yychar, yytname[yychar1]); 01028 /* Give the individual parser a way to print the precise 01029 meaning of a token, for further debugging info. */ 01030 # ifdef YYPRINT 01031 YYPRINT (stderr, yychar, yylval); 01032 # endif 01033 YYFPRINTF (stderr, ")\n"); 01034 } 01035 #endif 01036 } 01037 01038 yyn += yychar1; 01039 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) 01040 goto yydefault; 01041 01042 yyn = yytable[yyn]; 01043 01044 /* yyn is what to do for this token type in this state. 01045 Negative => reduce, -yyn is rule number. 01046 Positive => shift, yyn is new state. 01047 New state is final state => don't bother to shift, 01048 just return success. 01049 0, or most negative number => error. */ 01050 01051 if (yyn < 0) 01052 { 01053 if (yyn == YYFLAG) 01054 goto yyerrlab; 01055 yyn = -yyn; 01056 goto yyreduce; 01057 } 01058 else if (yyn == 0) 01059 goto yyerrlab; 01060 01061 if (yyn == YYFINAL) 01062 YYACCEPT; 01063 01064 /* Shift the lookahead token. */ 01065 YYDPRINTF ((stderr, "Shifting token %d (%s), ", 01066 yychar, yytname[yychar1])); 01067 01068 /* Discard the token being shifted unless it is eof. */ 01069 if (yychar != YYEOF) 01070 yychar = YYEMPTY; 01071 01072 *++yyvsp = yylval; 01073 #if YYLSP_NEEDED 01074 *++yylsp = yylloc; 01075 #endif 01076 01077 /* Count tokens shifted since error; after three, turn off error 01078 status. */ 01079 if (yyerrstatus) 01080 yyerrstatus--; 01081 01082 yystate = yyn; 01083 goto yynewstate; 01084 01085 01086 /*-----------------------------------------------------------. 01087 | yydefault -- do the default action for the current state. | 01088 `-----------------------------------------------------------*/ 01089 yydefault: 01090 yyn = yydefact[yystate]; 01091 if (yyn == 0) 01092 goto yyerrlab; 01093 goto yyreduce; 01094 01095 01096 /*-----------------------------. 01097 | yyreduce -- Do a reduction. | 01098 `-----------------------------*/ 01099 yyreduce: 01100 /* yyn is the number of a rule to reduce with. */ 01101 yylen = yyr2[yyn]; 01102 01103 /* If YYLEN is nonzero, implement the default value of the action: 01104 `$$ = $1'. 01105 01106 Otherwise, the following line sets YYVAL to the semantic value of 01107 the lookahead token. This behavior is undocumented and Bison 01108 users should not rely upon it. Assigning to YYVAL 01109 unconditionally makes the parser a bit smaller, and it avoids a 01110 GCC warning that YYVAL may be used uninitialized. */ 01111 yyval = yyvsp[1-yylen]; 01112 01113 #if YYLSP_NEEDED 01114 /* Similarly for the default location. Let the user run additional 01115 commands if for instance locations are ranges. */ 01116 yyloc = yylsp[1-yylen]; 01117 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); 01118 #endif 01119 01120 #if YYDEBUG 01121 /* We have to keep this `#if YYDEBUG', since we use variables which 01122 are defined only if `YYDEBUG' is set. */ 01123 if (yydebug) 01124 { 01125 int yyi; 01126 01127 YYFPRINTF (stderr, "Reducing via rule %d (line %d), ", 01128 yyn, yyrline[yyn]); 01129 01130 /* Print the symbols being reduced, and their result. */ 01131 for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++) 01132 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]); 01133 YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]); 01134 } 01135 #endif 01136 01137 switch (yyn) { 01138 01139 case 1: 01140 #line 87 "snapparse.y" 01141 { yyval.integer = yyvsp[0].integer; } 01142 break; 01143 case 2: 01144 #line 88 "snapparse.y" 01145 { yyval.integer = 0; } 01146 break; 01147 case 3: 01148 #line 91 "snapparse.y" 01149 { CHECK_CODE_OVERFLOW(p); 01150 SET_OP(*p->pc,yyvsp[0].integer); 01151 p->pc++; 01152 noop++; 01153 } 01154 break; 01155 case 4: 01156 #line 96 "snapparse.y" 01157 { CHECK_CODE_OVERFLOW(p); 01158 if ((yyvsp[0].integer > MAX_VINT) || (yyvsp[0].integer < MIN_VINT)) { 01159 fprintf(stderr, 01160 "%s:%d: int literal %d out of bounds (%d,%d)\n", 01161 __FILE__,__LINE__,yyvsp[0].integer,MIN_VINT,MAX_VINT); 01162 fflush(stderr); 01163 exit(1); 01164 } 01165 if (label != NULL) { 01166 register_label_use(label,p->pc); 01167 label = NULL; 01168 } 01169 SET_OP(*p->pc,yyvsp[-1].integer); 01170 SET_LIT(*p->pc,INTV,yyvsp[0].integer); 01171 p->pc++; 01172 } 01173 break; 01174 case 5: 01175 #line 112 "snapparse.y" 01176 { 01177 #ifdef ADDR_IN_HEAP 01178 buffer_t b = 01179 { sizeof(value_addr), (char *)&value_addr }; 01180 int offs = newho(&b,__FILE__,__LINE__); 01181 #endif 01182 CHECK_CODE_OVERFLOW(p); 01183 SET_OP(*p->pc,yyvsp[-1].integer); 01184 #ifdef ADDR_IN_HEAP 01185 SET_LIT(*p->pc,ADDRV,offs); 01186 #else 01187 SET_LIT(*p->pc,ADDRV,value_addr); 01188 #endif 01189 p->pc++; 01190 } 01191 break; 01192 case 6: 01193 #line 127 "snapparse.y" 01194 { int offs = newho(&value_str,__FILE__,__LINE__); 01195 free(value_str.s); 01196 CHECK_CODE_OVERFLOW(p); 01197 SET_OP(*p->pc,yyvsp[-1].integer); 01198 SET_LIT(*p->pc,STRV,offs); 01199 p->pc++; 01200 } 01201 break; 01202 case 7: 01203 #line 134 "snapparse.y" 01204 { value_t *v = (value_t *)yyvsp[0].ptr; 01205 int lit; 01206 CHECK_CODE_OVERFLOW(p); 01207 if (label != NULL) { 01208 register_label_use(label,p->pc); 01209 label = NULL; 01210 } 01211 #ifndef SMALL_INSTRS 01212 SET_OP(*p->pc,yyvsp[-1].integer); 01213 #else 01214 { OPCODE_T op = refine_op(yyvsp[-1].integer, GET_TAG(*v)); 01215 SET_OP(*p->pc,op); } 01216 #endif 01217 lit = GET_INT(*v); /* assumes the same as 01218 GET_* */ 01219 SET_LIT(*p->pc,GET_TAG(*v),lit); 01220 p->pc++; 01221 } 01222 break; 01223 case 8: 01224 #line 152 "snapparse.y" 01225 { p->hdr->entry_point = htons(p->pc - p->code_min); } 01226 break; 01227 case 9: 01228 #line 153 "snapparse.y" 01229 { register_label_def(value_str.s,p->pc); } 01230 break; 01231 case 10: 01232 #line 154 "snapparse.y" 01233 { value_t *v = (value_t *)yyvsp[0].ptr; 01234 if (p->sp >= p->stack_max) { 01235 fprintf(stderr,"%s:%d: stack overflow\n", 01236 __FILE__,__LINE__); 01237 fflush(stderr); 01238 exit(1); 01239 } 01240 if (label != NULL) { 01241 register_label_use(label,p->sp); 01242 label = NULL; 01243 } 01244 COPY_VAL(*p->sp,*v); 01245 p->sp++; 01246 } 01247 break; 01248 case 11: 01249 #line 170 "snapparse.y" 01250 { yyval.integer = (int)EXIT; } 01251 break; 01252 case 12: 01253 #line 171 "snapparse.y" 01254 { yyval.integer = (int)POP; } 01255 break; 01256 case 13: 01257 #line 172 "snapparse.y" 01258 { yyval.integer = (int)EQ; } 01259 break; 01260 case 14: 01261 #line 173 "snapparse.y" 01262 { yyval.integer = (int)NEQ; } 01263 break; 01264 case 15: 01265 #line 174 "snapparse.y" 01266 { yyval.integer = (int)ADD; } 01267 break; 01268 case 16: 01269 #line 175 "snapparse.y" 01270 { yyval.integer = (int)SUB; } 01271 break; 01272 case 17: 01273 #line 176 "snapparse.y" 01274 { yyval.integer = (int)MULT; } 01275 break; 01276 case 18: 01277 #line 177 "snapparse.y" 01278 { yyval.integer = (int)DIV; } 01279 break; 01280 case 19: 01281 #line 178 "snapparse.y" 01282 { yyval.integer = (int)MOD; } 01283 break; 01284 case 20: 01285 #line 179 "snapparse.y" 01286 { yyval.integer = (int)NEG; } 01287 break; 01288 case 21: 01289 #line 180 "snapparse.y" 01290 { yyval.integer = (int)NOT; } 01291 break; 01292 case 22: 01293 #line 181 "snapparse.y" 01294 { yyval.integer = (int)LNOT; } 01295 break; 01296 case 23: 01297 #line 182 "snapparse.y" 01298 { yyval.integer = (int)AND; } 01299 break; 01300 case 24: 01301 #line 183 "snapparse.y" 01302 { yyval.integer = (int)OR; } 01303 break; 01304 case 25: 01305 #line 184 "snapparse.y" 01306 { yyval.integer = (int)LSHL; } 01307 break; 01308 case 26: 01309 #line 185 "snapparse.y" 01310 { yyval.integer = (int)RSHL; } 01311 break; 01312 case 27: 01313 #line 186 "snapparse.y" 01314 { yyval.integer = (int)RSHA; } 01315 break; 01316 case 28: 01317 #line 187 "snapparse.y" 01318 { yyval.integer = (int)ISX; } 01319 break; 01320 case 29: 01321 #line 188 "snapparse.y" 01322 { yyval.integer = (int)GETRB; } 01323 break; 01324 case 30: 01325 #line 189 "snapparse.y" 01326 { yyval.integer = (int)GETSRC; } 01327 break; 01328 case 31: 01329 #line 190 "snapparse.y" 01330 { yyval.integer = (int)GETDST; } 01331 break; 01332 case 32: 01333 #line 191 "snapparse.y" 01334 { yyval.integer = (int)GETSPT; } 01335 break; 01336 case 33: 01337 #line 192 "snapparse.y" 01338 { yyval.integer = (int)GETLD; } 01339 break; 01340 case 34: 01341 #line 193 "snapparse.y" 01342 { yyval.integer = (int)SETXH; } 01343 break; 01344 case 35: 01345 #line 194 "snapparse.y" 01346 { yyval.integer = (int)RAISEX; } 01347 break; 01348 case 36: 01349 #line 195 "snapparse.y" 01350 { yyval.integer = (int)HERE; } 01351 break; 01352 case 37: 01353 #line 196 "snapparse.y" 01354 { yyval.integer = (int)ISHERE; } 01355 break; 01356 case 38: 01357 #line 197 "snapparse.y" 01358 { yyval.integer = (int)ROUTE; } 01359 break; 01360 case 39: 01361 #line 198 "snapparse.y" 01362 { yyval.integer = (int)RTDEV; } 01363 break; 01364 case 40: 01365 #line 199 "snapparse.y" 01366 { yyval.integer = (int)SEND; } 01367 break; 01368 case 41: 01369 #line 200 "snapparse.y" 01370 { yyval.integer = (int)HOP; } 01371 break; 01372 case 42: 01373 #line 201 "snapparse.y" 01374 { yyval.integer = (int)FORW; } 01375 break; 01376 case 43: 01377 #line 202 "snapparse.y" 01378 { yyval.integer = (int)FORWTO; } 01379 break; 01380 case 44: 01381 #line 203 "snapparse.y" 01382 { yyval.integer = (int)DEMUX; } 01383 break; 01384 case 45: 01385 #line 204 "snapparse.y" 01386 { yyval.integer = (int)PRINT; } 01387 break; 01388 case 46: 01389 #line 205 "snapparse.y" 01390 { yyval.integer = (int)LEN; } 01391 break; 01392 case 47: 01393 #line 206 "snapparse.y" 01394 { yyval.integer = (int)ISTUP; } 01395 break; 01396 case 48: 01397 #line 207 "snapparse.y" 01398 { yyval.integer = (int)SNET; } 01399 break; 01400 case 49: 01401 #line 208 "snapparse.y" 01402 { yyval.integer = (int)BCAST; } 01403 break; 01404 case 50: 01405 #line 209 "snapparse.y" 01406 { yyval.integer = (int)GT; } 01407 break; 01408 case 51: 01409 #line 210 "snapparse.y" 01410 { yyval.integer = (int)GEQ; } 01411 break; 01412 case 52: 01413 #line 211 "snapparse.y" 01414 { yyval.integer = (int)LT; } 01415 break; 01416 case 53: 01417 #line 212 "snapparse.y" 01418 { yyval.integer = (int)LEQ; } 01419 break; 01420 case 54: 01421 #line 213 "snapparse.y" 01422 { yyval.integer = (int)DSEND; } 01423 break; 01424 case 55: 01425 #line 214 "snapparse.y" 01426 { yyval.integer = (int)DFORW; } 01427 break; 01428 case 56: 01429 #line 215 "snapparse.y" 01430 { yyval.integer = (int)DFORWTO; } 01431 break; 01432 case 57: 01433 #line 216 "snapparse.y" 01434 { yyval.integer = (int)STACKEMPTY; } 01435 break; 01436 case 58: 01437 #line 217 "snapparse.y" 01438 { yyval.integer = (int)STACKCOUNT; } 01439 break; 01440 case 59: 01441 #line 218 "snapparse.y" 01442 { yyval.integer = (int)PULLSTACK; } 01443 break; 01444 case 60: 01445 #line 221 "snapparse.y" 01446 { yyval.integer = (int)PULL; } 01447 break; 01448 case 61: 01449 #line 222 "snapparse.y" 01450 { yyval.integer = (int)STORE; } 01451 break; 01452 case 62: 01453 #line 223 "snapparse.y" 01454 { yyval.integer = (int)PAJ; } 01455 break; 01456 case 63: 01457 #line 224 "snapparse.y" 01458 { yyval.integer = (int)TPAJ; } 01459 break; 01460 case 64: 01461 #line 225 "snapparse.y" 01462 { yyval.integer = (int)BEZ; } 01463 break; 01464 case 65: 01465 #line 226 "snapparse.y" 01466 { yyval.integer = (int)BNE; } 01467 break; 01468 case 66: 01469 #line 227 "snapparse.y" 01470 { yyval.integer = (int)POPI; } 01471 break; 01472 case 67: 01473 #line 228 "snapparse.y" 01474 { yyval.integer = (int)MODI; } 01475 break; 01476 case 68: 01477 #line 229 "snapparse.y" 01478 { yyval.integer = (int)ANDI; } 01479 break; 01480 case 69: 01481 #line 230 "snapparse.y" 01482 { yyval.integer = (int)ORI; } 01483 break; 01484 case 70: 01485 #line 231 "snapparse.y" 01486 { yyval.integer = (int)LSHLI; } 01487 break; 01488 case 71: 01489 #line 232 "snapparse.y" 01490 { yyval.integer = (int)RSHLI; } 01491 break; 01492 case 72: 01493 #line 233 "snapparse.y" 01494 { yyval.integer = (int)RSHAI; } 01495 break; 01496 case 73: 01497 #line 234 "snapparse.y" 01498 { yyval.integer = (int)JI; } 01499 break; 01500 case 74: 01501 #line 235 "snapparse.y" 01502 { yyval.integer = (int)MKTUP; } 01503 break; 01504 case 75: 01505 #line 236 "snapparse.y" 01506 { yyval.integer = (int)NTH; } 01507 break; 01508 case 76: 01509 #line 239 "snapparse.y" 01510 { yyval.integer = (int)BCASTI; } 01511 break; 01512 case 77: 01513 #line 240 "snapparse.y" 01514 { yyval.integer = (int)DEMUXI; } 01515 break; 01516 case 78: 01517 #line 241 "snapparse.y" 01518 { yyval.integer = (int)SNETI; } 01519 break; 01520 case 79: 01521 #line 244 "snapparse.y" 01522 { yyval.integer = (int)SVCV; } 01523 break; 01524 case 80: 01525 #line 245 "snapparse.y" 01526 { yyval.integer = (int)CALLS; } 01527 break; 01528 case 81: 01529 #line 248 "snapparse.y" 01530 { yyval.integer = (int)PUSH; } 01531 break; 01532 case 82: 01533 #line 249 "snapparse.y" 01534 { yyval.integer = (int)EQI; } 01535 break; 01536 case 83: 01537 #line 250 "snapparse.y" 01538 { yyval.integer = (int)NEQI; } 01539 break; 01540 case 84: 01541 #line 251 "snapparse.y" 01542 { yyval.integer = (int)ADDI; } 01543 break; 01544 case 85: 01545 #line 252 "snapparse.y" 01546 { yyval.integer = (int)SUBI; } 01547 break; 01548 case 86: 01549 #line 253 "snapparse.y" 01550 { yyval.integer = (int)MULTI; } 01551 break; 01552 case 87: 01553 #line 254 "snapparse.y" 01554 { yyval.integer = (int)DIVI; } 01555 break; 01556 case 88: 01557 #line 255 "snapparse.y" 01558 { yyval.integer = (int)GTI; } 01559 break; 01560 case 89: 01561 #line 256 "snapparse.y" 01562 { yyval.integer = (int)GEQI; } 01563 break; 01564 case 90: 01565 #line 257 "snapparse.y" 01566 { yyval.integer = (int)LTI; } 01567 break; 01568 case 91: 01569 #line 258 "snapparse.y" 01570 { yyval.integer = (int)LEQI; } 01571 break; 01572 case 92: 01573 #line 261 "snapparse.y" 01574 { value_t *_v; memalloc(_v,value_t *,sizeof(value_t)); 01575 if ((yyvsp[0].integer > MAX_VINT) || (yyvsp[0].integer < MIN_VINT)) { 01576 fprintf(stderr, 01577 "%s:%d: int literal %d out of bounds (%d,%d)\n", 01578 __FILE__,__LINE__,yyvsp[0].integer,MIN_VINT,MAX_VINT); 01579 fflush(stderr); 01580 exit(1); 01581 } 01582 SET_TAG(*_v,INTV); 01583 SET_INT(*_v,yyvsp[0].integer); 01584 yyval.ptr = (void *)_v; 01585 } 01586 break; 01587 case 93: 01588 #line 273 "snapparse.y" 01589 { value_t *_v; 01590 #ifdef ADDR_IN_HEAP 01591 buffer_t b = 01592 { sizeof(value_addr), (char *)&value_addr }; 01593 int offs = newho(&b,__FILE__,__LINE__); 01594 #endif 01595 memalloc(_v,value_t *,sizeof(value_t)); 01596 SET_TAG(*_v,ADDRV); 01597 #ifndef ADDR_IN_HEAP 01598 SET_ADDR(*_v,value_addr,0 /* dummy arg */); 01599 #else 01600 SET_OFFS(*_v,offs); 01601 #endif 01602 yyval.ptr = (void *)_v; 01603 } 01604 break; 01605 case 94: 01606 #line 288 "snapparse.y" 01607 { value_t *_v; 01608 #ifdef ADDR_IN_HEAP 01609 buffer_t b = 01610 { sizeof(value_float), (char *)&value_float }; 01611 int offs = newho(&b,__FILE__,__LINE__); 01612 #endif 01613 memalloc(_v,value_t *,sizeof(value_t)); 01614 SET_TAG(*_v,FLOATV); 01615 #ifndef ADDR_IN_HEAP 01616 SET_FLOAT(*_v,value_float,0 /* dummy arg */); 01617 #else 01618 SET_OFFS(*_v,offs); 01619 #endif 01620 yyval.ptr = (void *)_v; 01621 } 01622 break; 01623 case 95: 01624 #line 303 "snapparse.y" 01625 { value_t *_v; 01626 int offs = newho(&value_str,__FILE__,__LINE__); 01627 /* free(value_str.s); */ 01628 memalloc(_v,value_t *,sizeof(value_t)); 01629 SET_TAG(*_v,STRV); 01630 SET_OFFS(*_v,offs); 01631 yyval.ptr = (void *)_v; 01632 } 01633 break; 01634 case 96: 01635 #line 311 "snapparse.y" 01636 { value_t *_v; 01637 if ((value_exc > MAX_VINT) || (value_exc < 0)) { 01638 fprintf(stderr, 01639 "%s:%d: int literal %d out of bounds (%d,%d)\n", 01640 __FILE__,__LINE__,value_exc,0,MAX_VINT); 01641 fflush(stderr); 01642 exit(1); 01643 } 01644 memalloc(_v,value_t *,sizeof(value_t)); 01645 SET_TAG(*_v,EXCV); 01646 SET_INT(*_v,value_exc); 01647 yyval.ptr = (void *)_v; 01648 } 01649 break; 01650 case 97: 01651 #line 325 "snapparse.y" 01652 { value_t *_v; 01653 int offs = newtup((list_t *)yyvsp[-1].ptr,__FILE__,__LINE__); 01654 free_list(yyvsp[-1].ptr); 01655 memalloc(_v,value_t *,sizeof(value_t)); 01656 SET_TAG(*_v,TUPLEV); 01657 SET_OFFS(*_v,offs); 01658 yyval.ptr = (void *)_v; 01659 } 01660 break; 01661 case 98: 01662 #line 336 "snapparse.y" 01663 { yyval.ptr = (void *)cons(yyvsp[-2].ptr,(list_t *)yyvsp[0].ptr); } 01664 break; 01665 case 99: 01666 #line 337 "snapparse.y" 01667 { yyval.ptr = (void *)cons(yyvsp[0].ptr,(list_t *)0); } 01668 break; 01669 case 100: 01670 #line 340 "snapparse.y" 01671 { yyval.integer = yyvsp[-2].integer + yyvsp[0].integer; } 01672 break; 01673 case 101: 01674 #line 341 "snapparse.y" 01675 { yyval.integer = yyvsp[-2].integer - yyvsp[0].integer; } 01676 break; 01677 case 102: 01678 #line 342 "snapparse.y" 01679 { yyval.integer = p->pc - p->code_min; } 01680 break; 01681 case 103: 01682 #line 343 "snapparse.y" 01683 { yyval.integer = value_int; } 01684 break; 01685 case 104: 01686 #line 344 "snapparse.y" 01687 { yyval.integer = 0; label = value_str.s; } 01688 break; 01689 } 01690 01691 #line 705 "/usr/share/bison/bison.simple" 01692 01693 01694 yyvsp -= yylen; 01695 yyssp -= yylen; 01696 #if YYLSP_NEEDED 01697 yylsp -= yylen; 01698 #endif 01699 01700 #if YYDEBUG 01701 if (yydebug) 01702 { 01703 short *yyssp1 = yyss - 1; 01704 YYFPRINTF (stderr, "state stack now"); 01705 while (yyssp1 != yyssp) 01706 YYFPRINTF (stderr, " %d", *++yyssp1); 01707 YYFPRINTF (stderr, "\n"); 01708 } 01709 #endif 01710 01711 *++yyvsp = yyval; 01712 #if YYLSP_NEEDED 01713 *++yylsp = yyloc; 01714 #endif 01715 01716 /* Now `shift' the result of the reduction. Determine what state 01717 that goes to, based on the state we popped back to and the rule 01718 number reduced by. */ 01719 01720 yyn = yyr1[yyn]; 01721 01722 yystate = yypgoto[yyn - YYNTBASE] + *yyssp; 01723 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) 01724 yystate = yytable[yystate]; 01725 else 01726 yystate = yydefgoto[yyn - YYNTBASE]; 01727 01728 goto yynewstate; 01729 01730 01731 /*------------------------------------. 01732 | yyerrlab -- here on detecting error | 01733 `------------------------------------*/ 01734 yyerrlab: 01735 /* If not already recovering from an error, report this error. */ 01736 if (!yyerrstatus) 01737 { 01738 ++yynerrs; 01739 01740 #ifdef YYERROR_VERBOSE 01741 yyn = yypact[yystate]; 01742 01743 if (yyn > YYFLAG && yyn < YYLAST) 01744 { 01745 YYSIZE_T yysize = 0; 01746 char *yymsg; 01747 int yyx, yycount; 01748 01749 yycount = 0; 01750 /* Start YYX at -YYN if negative to avoid negative indexes in 01751 YYCHECK. */ 01752 for (yyx = yyn < 0 ? -yyn : 0; 01753 yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) 01754 if (yycheck[yyx + yyn] == yyx) 01755 yysize += yystrlen (yytname[yyx]) + 15, yycount++; 01756 yysize += yystrlen ("parse error, unexpected ") + 1; 01757 yysize += yystrlen (yytname[YYTRANSLATE (yychar)]); 01758 yymsg = (char *) YYSTACK_ALLOC (yysize); 01759 if (yymsg != 0) 01760 { 01761 char *yyp = yystpcpy (yymsg, "parse error, unexpected "); 01762 yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]); 01763 01764 if (yycount < 5) 01765 { 01766 yycount = 0; 01767 for (yyx = yyn < 0 ? -yyn : 0; 01768 yyx < (int) (sizeof (yytname) / sizeof (char *)); 01769 yyx++) 01770 if (yycheck[yyx + yyn] == yyx) 01771 { 01772 const char *yyq = ! yycount ? ", expecting " : " or "; 01773 yyp = yystpcpy (yyp, yyq); 01774 yyp = yystpcpy (yyp, yytname[yyx]); 01775 yycount++; 01776 } 01777 } 01778 yyerror (yymsg); 01779 YYSTACK_FREE (yymsg); 01780 } 01781 else 01782 yyerror ("parse error; also virtual memory exhausted"); 01783 } 01784 else 01785 #endif /* defined (YYERROR_VERBOSE) */ 01786 yyerror ("parse error"); 01787 } 01788 goto yyerrlab1; 01789 01790 01791 /*--------------------------------------------------. 01792 | yyerrlab1 -- error raised explicitly by an action | 01793 `--------------------------------------------------*/ 01794 yyerrlab1: 01795 if (yyerrstatus == 3) 01796 { 01797 /* If just tried and failed to reuse lookahead token after an 01798 error, discard it. */ 01799 01800 /* return failure if at end of input */ 01801 if (yychar == YYEOF) 01802 YYABORT; 01803 YYDPRINTF ((stderr, "Discarding token %d (%s).\n", 01804 yychar, yytname[yychar1])); 01805 yychar = YYEMPTY; 01806 } 01807 01808 /* Else will try to reuse lookahead token after shifting the error 01809 token. */ 01810 01811 yyerrstatus = 3; /* Each real token shifted decrements this */ 01812 01813 goto yyerrhandle; 01814 01815 01816 /*-------------------------------------------------------------------. 01817 | yyerrdefault -- current state does not do anything special for the | 01818 | error token. | 01819 `-------------------------------------------------------------------*/ 01820 yyerrdefault: 01821 #if 0 01822 /* This is wrong; only states that explicitly want error tokens 01823 should shift them. */ 01824 01825 /* If its default is to accept any token, ok. Otherwise pop it. */ 01826 yyn = yydefact[yystate]; 01827 if (yyn) 01828 goto yydefault; 01829 #endif 01830 01831 01832 /*---------------------------------------------------------------. 01833 | yyerrpop -- pop the current state because it cannot handle the | 01834 | error token | 01835 `---------------------------------------------------------------*/ 01836 yyerrpop: 01837 if (yyssp == yyss) 01838 YYABORT; 01839 yyvsp--; 01840 yystate = *--yyssp; 01841 #if YYLSP_NEEDED 01842 yylsp--; 01843 #endif 01844 01845 #if YYDEBUG 01846 if (yydebug) 01847 { 01848 short *yyssp1 = yyss - 1; 01849 YYFPRINTF (stderr, "Error: state stack now"); 01850 while (yyssp1 != yyssp) 01851 YYFPRINTF (stderr, " %d", *++yyssp1); 01852 YYFPRINTF (stderr, "\n"); 01853 } 01854 #endif 01855 01856 /*--------------. 01857 | yyerrhandle. | 01858 `--------------*/ 01859 yyerrhandle: 01860 yyn = yypact[yystate]; 01861 if (yyn == YYFLAG) 01862 goto yyerrdefault; 01863 01864 yyn += YYTERROR; 01865 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) 01866 goto yyerrdefault; 01867 01868 yyn = yytable[yyn]; 01869 if (yyn < 0) 01870 { 01871 if (yyn == YYFLAG) 01872 goto yyerrpop; 01873 yyn = -yyn; 01874 goto yyreduce; 01875 } 01876 else if (yyn == 0) 01877 goto yyerrpop; 01878 01879 if (yyn == YYFINAL) 01880 YYACCEPT; 01881 01882 YYDPRINTF ((stderr, "Shifting error token, ")); 01883 01884 *++yyvsp = yylval; 01885 #if YYLSP_NEEDED 01886 *++yylsp = yylloc; 01887 #endif 01888 01889 yystate = yyn; 01890 goto yynewstate; 01891 01892 01893 /*-------------------------------------. 01894 | yyacceptlab -- YYACCEPT comes here. | 01895 `-------------------------------------*/ 01896 yyacceptlab: 01897 yyresult = 0; 01898 goto yyreturn; 01899 01900 /*-----------------------------------. 01901 | yyabortlab -- YYABORT comes here. | 01902 `-----------------------------------*/ 01903 yyabortlab: 01904 yyresult = 1; 01905 goto yyreturn; 01906 01907 /*---------------------------------------------. 01908 | yyoverflowab -- parser overflow comes here. | 01909 `---------------------------------------------*/ 01910 yyoverflowlab: 01911 yyerror ("parser stack overflow"); 01912 yyresult = 2; 01913 /* Fall through. */ 01914 01915 yyreturn: 01916 #ifndef yyoverflow 01917 if (yyss != yyssa) 01918 YYSTACK_FREE (yyss); 01919 #endif 01920 return yyresult; 01921 } 01922 #line 347 "snapparse.y" 01923 01924 int newho(buffer_t *b,char *file,int line) { 01925 int sizeb = sizeof(heap_obj) + b->lenb; 01926 int offs; 01927 heap_obj *ho; 01928 01929 if ((sizeb & 0x3) != 0) { 01930 sizeb = (sizeb & ~0x3) + 4; 01931 } 01932 if (((p->h_alloc_ptr + sizeb) > p->heap_max) || 01933 (b->lenb > MAX_HEAPOBJ_SZ)) { 01934 fprintf(stderr,"%s:%d: heap alloc failed\n",file,line); 01935 fflush(stderr); 01936 exit(1); 01937 } 01938 ho = (heap_obj *)(p->h_alloc_ptr); 01939 offs = p->h_alloc_ptr - p->heap_min; 01940 01941 d_printf(150,"%s:%d: alloc %d-string at @%#x, offs = %d\n", 01942 __FILE__,__LINE__, b->lenb, p->h_alloc_ptr, offs); 01943 01944 p->h_alloc_ptr = p->h_alloc_ptr + sizeb; 01945 bzero(ho,sizeb); 01946 ho->len = b->lenb; 01947 ho->flag = 0; 01948 memcpy((char *)(&(ho->s)),b->s,b->lenb); 01949 return(offs); 01950 } 01951 01952 int newtup(list_t *list,char *file,int line) { 01953 int len = length_list(list); 01954 int lenb = len * sizeof(value_t); 01955 int sizeb = sizeof(heap_obj) + lenb; 01956 int offs; 01957 heap_obj *ho; 01958 value_t *varr; 01959 list_t *iter; 01960 01961 assert ((sizeb & 0x3) == 0); 01962 if (((p->h_alloc_ptr + sizeb) > p->heap_max) || 01963 (lenb > MAX_HEAPOBJ_SZ)) { 01964 fprintf(stderr,"%s:%d: heap alloc failed\n",file,line); 01965 fflush(stderr); 01966 exit(1); 01967 } 01968 ho = (heap_obj *)(p->h_alloc_ptr); 01969 offs = p->h_alloc_ptr - p->heap_min; 01970 01971 d_printf(150,"%s:%d: alloc %d-tuple at @%#x, offs = %d\n", 01972 __FILE__,__LINE__, lenb / sizeof(value_t), 01973 p->h_alloc_ptr, offs); 01974 01975 p->h_alloc_ptr = p->h_alloc_ptr + sizeb; 01976 bzero(ho,sizeb); 01977 ho->len = lenb; 01978 ho->flag = 1; 01979 01980 varr = (value_t *)ho->s; 01981 for (iter = list; iter != NULL; iter = iter->next, varr++) { 01982 *varr = *((value_t *)iter->v); 01983 } 01984 return(offs); 01985 } 01986 01987 #ifdef SMALL_INSTRS 01988 OPCODE_T refine_op(OPCODE_T op, TAG_T vtag) { 01989 switch (op) { 01990 case PUSH: 01991 switch (vtag) { 01992 case INTV: 01993 op = PINT; 01994 break; 01995 case ADDRV: 01996 op = PADDR; 01997 break; 01998 case STRV: 01999 op = PSTR; 02000 break; 02001 case EXCV: 02002 op = PEXC; 02003 break; 02004 case TUPLEV: 02005 op = PTUP; 02006 break; 02007 case FLOATV: 02008 op = PFLT; 02009 break; 02010 default: 02011 fprintf(stderr,"%s:%d: invalid tag %d\n",__FILE__,__LINE__,vtag); 02012 exit(1); 02013 } 02014 break; 02015 case EQI: 02016 switch (vtag) { 02017 case INTV: 02018 op = EQINT; 02019 break; 02020 case ADDRV: 02021 op = EQADR; 02022 break; 02023 case STRV: 02024 op = EQSTR; 02025 break; 02026 case EXCV: 02027 op = EQEXC; 02028 break; 02029 case TUPLEV: 02030 op = EQTUP; 02031 break; 02032 case FLOATV: 02033 op = EQFLT; 02034 break; 02035 default: 02036 fprintf(stderr,"%s:%d: invalid tag %d\n",__FILE__,__LINE__,vtag); 02037 exit(1); 02038 } 02039 break; 02040 case NEQI: 02041 switch (vtag) { 02042 case INTV: 02043 op = NQINT; 02044 break; 02045 case ADDRV: 02046 op = NQADR; 02047 break; 02048 case STRV: 02049 op = NQSTR; 02050 break; 02051 case EXCV: 02052 op = NQEXC; 02053 break; 02054 case TUPLEV: 02055 op = NQTUP; 02056 break; 02057 case FLOATV: 02058 op = NQFLT; 02059 break; 02060 default: 02061 fprintf(stderr,"%s:%d: invalid tag %d\n",__FILE__,__LINE__,vtag); 02062 exit(1); 02063 } 02064 break; 02065 case ADDI: 02066 switch (vtag) { 02067 case INTV: 02068 break; 02069 case FLOATV: 02070 op = FADDI; 02071 break; 02072 default: 02073 fprintf(stderr,"%s:%d: invalid tag %d for ADDI\n", 02074 __FILE__,__LINE__,vtag); 02075 break; 02076 } 02077 break; 02078 case SUBI: 02079 switch (vtag) { 02080 case INTV: 02081 break; 02082 case FLOATV: 02083 op = FSUBI; 02084 break; 02085 default: 02086 fprintf(stderr,"%s:%d: invalid tag %d for SUBI\n", 02087 __FILE__,__LINE__,vtag); 02088 break; 02089 } 02090 break; 02091 case MULTI: 02092 switch (vtag) { 02093 case INTV: 02094 break; 02095 case FLOATV: 02096 op = FMULI; 02097 break; 02098 default: 02099 fprintf(stderr,"%s:%d: invalid tag %d for MULTI\n", 02100 __FILE__,__LINE__,vtag); 02101 break; 02102 } 02103 break; 02104 case DIVI: 02105 switch (vtag) { 02106 case INTV: 02107 break; 02108 case FLOATV: 02109 op = FDIVI; 02110 break; 02111 default: 02112 fprintf(stderr,"%s:%d: invalid tag %d for DIVI\n", 02113 __FILE__,__LINE__,vtag); 02114 break; 02115 } 02116 break; 02117 case GTI: 02118 switch (vtag) { 02119 case INTV: 02120 break; 02121 case FLOATV: 02122 op = FGTI; 02123 break; 02124 default: 02125 fprintf(stderr,"%s:%d: invalid tag %d for GTI\n", 02126 __FILE__,__LINE__,vtag); 02127 break; 02128 } 02129 break; 02130 case GEQI: 02131 switch (vtag) { 02132 case INTV: 02133 break; 02134 case FLOATV: 02135 op = FGEQI; 02136 break; 02137 default: 02138 fprintf(stderr,"%s:%d: invalid tag %d for GEQI\n", 02139 __FILE__,__LINE__,vtag); 02140 break; 02141 } 02142 break; 02143 case LTI: 02144 switch (vtag) { 02145 case INTV: 02146 break; 02147 case FLOATV: 02148 op = FLTI; 02149 break; 02150 default: 02151 fprintf(stderr,"%s:%d: invalid tag %d for LTI\n", 02152 __FILE__,__LINE__,vtag); 02153 break; 02154 } 02155 break; 02156 case LEQI: 02157 switch (vtag) { 02158 case INTV: 02159 break; 02160 case FLOATV: 02161 op = FLEQI; 02162 break; 02163 default: 02164 fprintf(stderr,"%s:%d: invalid tag %d for LEQI\n", 02165 __FILE__,__LINE__,vtag); 02166 break; 02167 } 02168 break; 02169 default: 02170 fprintf(stderr,"%s:%d: invalid opcode %d\n",__FILE__,__LINE__,op); 02171 exit(1); 02172 } 02173 return op; 02174 } 02175 #endif 02176 02177 void yyerror(char *s) { 02178 fprintf(stderr,s); 02179 } |