1 /* original parser id follows */ 2 /* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ 3 /* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ 4 5 #define YYBYACC 1 6 #define YYMAJOR 1 7 #define YYMINOR 9 8 #define YYCHECK "yyyymmdd" 9 10 #define YYEMPTY (-1) 11 #define yyclearin (yychar = YYEMPTY) 12 #define yyerrok (yyerrflag = 0) 13 #define YYRECOVERING() (yyerrflag != 0) 14 #define YYENOMEM (-2) 15 #define YYEOF 0 16 #undef YYBTYACC 17 #define YYBTYACC 1 18 #define YYDEBUGSTR (yytrial ? YYPREFIX "debug(trial)" : YYPREFIX "debug") 19 20 #ifndef yyparse 21 #define yyparse demo_parse 22 #endif /* yyparse */ 23 24 #ifndef yylex 25 #define yylex demo_lex 26 #endif /* yylex */ 27 28 #ifndef yyerror 29 #define yyerror demo_error 30 #endif /* yyerror */ 31 32 #ifndef yychar 33 #define yychar demo_char 34 #endif /* yychar */ 35 36 #ifndef yyval 37 #define yyval demo_val 38 #endif /* yyval */ 39 40 #ifndef yylval 41 #define yylval demo_lval 42 #endif /* yylval */ 43 44 #ifndef yydebug 45 #define yydebug demo_debug 46 #endif /* yydebug */ 47 48 #ifndef yynerrs 49 #define yynerrs demo_nerrs 50 #endif /* yynerrs */ 51 52 #ifndef yyerrflag 53 #define yyerrflag demo_errflag 54 #endif /* yyerrflag */ 55 56 #ifndef yylhs 57 #define yylhs demo_lhs 58 #endif /* yylhs */ 59 60 #ifndef yylen 61 #define yylen demo_len 62 #endif /* yylen */ 63 64 #ifndef yydefred 65 #define yydefred demo_defred 66 #endif /* yydefred */ 67 68 #ifndef yystos 69 #define yystos demo_stos 70 #endif /* yystos */ 71 72 #ifndef yydgoto 73 #define yydgoto demo_dgoto 74 #endif /* yydgoto */ 75 76 #ifndef yysindex 77 #define yysindex demo_sindex 78 #endif /* yysindex */ 79 80 #ifndef yyrindex 81 #define yyrindex demo_rindex 82 #endif /* yyrindex */ 83 84 #ifndef yygindex 85 #define yygindex demo_gindex 86 #endif /* yygindex */ 87 88 #ifndef yytable 89 #define yytable demo_table 90 #endif /* yytable */ 91 92 #ifndef yycheck 93 #define yycheck demo_check 94 #endif /* yycheck */ 95 96 #ifndef yyname 97 #define yyname demo_name 98 #endif /* yyname */ 99 100 #ifndef yyrule 101 #define yyrule demo_rule 102 #endif /* yyrule */ 103 104 #ifndef yyloc 105 #define yyloc demo_loc 106 #endif /* yyloc */ 107 108 #ifndef yylloc 109 #define yylloc demo_lloc 110 #endif /* yylloc */ 111 112 #if YYBTYACC 113 114 #ifndef yycindex 115 #define yycindex demo_cindex 116 #endif /* yycindex */ 117 118 #ifndef yyctable 119 #define yyctable demo_ctable 120 #endif /* yyctable */ 121 122 #endif /* YYBTYACC */ 123 124 #define YYPREFIX "demo_" 125 126 #define YYPURE 0 127 128 #line 15 "btyacc_demo.y" 129 /* dummy types just for compile check */ 130 typedef int Code; 131 typedef int Decl_List; 132 typedef int Expr; 133 typedef int Expr_List; 134 typedef int Scope; 135 typedef int Type; 136 enum Operator { ADD, SUB, MUL, MOD, DIV, DEREF }; 137 138 typedef unsigned char bool; 139 typedef struct Decl { 140 Scope *scope; 141 Type *type; 142 bool (*istype)(void); 143 } Decl; 144 145 #include "btyacc_demo.tab.h" 146 #include <stdlib.h> 147 #include <stdio.h> 148 #ifdef YYSTYPE 149 #undef YYSTYPE_IS_DECLARED 150 #define YYSTYPE_IS_DECLARED 1 151 #endif 152 #ifndef YYSTYPE_IS_DECLARED 153 #define YYSTYPE_IS_DECLARED 1 154 #line 36 "btyacc_demo.y" 155 typedef union { 156 Scope *scope; 157 Expr *expr; 158 Expr_List *elist; 159 Type *type; 160 Decl *decl; 161 Decl_List *dlist; 162 Code *code; 163 char *id; 164 } YYSTYPE; 165 #endif /* !YYSTYPE_IS_DECLARED */ 166 #line 167 "btyacc_demo.tab.c" 167 168 #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED 169 /* Default: YYLTYPE is the text position type. */ 170 typedef struct YYLTYPE 171 { 172 int first_line; 173 int first_column; 174 int last_line; 175 int last_column; 176 unsigned source; 177 } YYLTYPE; 178 #define YYLTYPE_IS_DECLARED 1 179 #endif 180 #define YYRHSLOC(rhs, k) ((rhs)[k]) 181 182 /* compatibility with bison */ 183 #ifdef YYPARSE_PARAM 184 /* compatibility with FreeBSD */ 185 # ifdef YYPARSE_PARAM_TYPE 186 # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) 187 # else 188 # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) 189 # endif 190 #else 191 # define YYPARSE_DECL() yyparse(void) 192 #endif 193 194 /* Parameters sent to lex. */ 195 #ifdef YYLEX_PARAM 196 # define YYLEX_DECL() yylex(void *YYLEX_PARAM) 197 # define YYLEX yylex(YYLEX_PARAM) 198 #else 199 # define YYLEX_DECL() yylex(void) 200 # define YYLEX yylex() 201 #endif 202 203 /* Parameters sent to yyerror. */ 204 #ifndef YYERROR_DECL 205 #define YYERROR_DECL() yyerror(YYLTYPE *loc, const char *s) 206 #endif 207 #ifndef YYERROR_CALL 208 #define YYERROR_CALL(msg) yyerror(&yylloc, msg) 209 #endif 210 211 #ifndef YYDESTRUCT_DECL 212 #define YYDESTRUCT_DECL() yydestruct(const char *msg, int psymb, YYSTYPE *val, YYLTYPE *loc) 213 #endif 214 #ifndef YYDESTRUCT_CALL 215 #define YYDESTRUCT_CALL(msg, psymb, val, loc) yydestruct(msg, psymb, val, loc) 216 #endif 217 218 extern int YYPARSE_DECL(); 219 220 #define PREFIX 257 221 #define POSTFIX 258 222 #define ID 259 223 #define CONSTANT 260 224 #define EXTERN 261 225 #define REGISTER 262 226 #define STATIC 263 227 #define CONST 264 228 #define VOLATILE 265 229 #define IF 266 230 #define THEN 267 231 #define ELSE 268 232 #define CLCL 269 233 #define YYERRCODE 256 234 typedef short YYINT; 235 static const YYINT demo_lhs[] = { -1, 236 15, 15, 15, 12, 18, 0, 4, 19, 4, 2, 237 20, 2, 10, 10, 13, 13, 11, 11, 11, 11, 238 11, 14, 14, 21, 22, 3, 3, 8, 8, 23, 239 24, 8, 8, 8, 8, 16, 16, 17, 17, 9, 240 1, 1, 1, 1, 1, 1, 1, 1, 5, 5, 241 25, 26, 5, 5, 27, 5, 6, 6, 7, 242 }; 243 static const YYINT demo_len[] = { 2, 244 0, 1, 3, 2, 0, 2, 0, 0, 3, 3, 245 0, 4, 1, 3, 0, 2, 1, 1, 1, 1, 246 1, 1, 1, 0, 0, 5, 1, 0, 1, 0, 247 0, 5, 5, 5, 6, 0, 1, 4, 1, 2, 248 4, 4, 4, 4, 4, 3, 1, 1, 1, 2, 249 0, 0, 11, 8, 0, 2, 0, 3, 4, 250 }; 251 static const YYINT demo_defred[] = { 5, 252 0, 7, 0, 0, 19, 20, 21, 22, 23, 2, 253 9, 0, 13, 18, 17, 0, 15, 30, 29, 0, 254 0, 0, 0, 0, 31, 10, 24, 24, 24, 0, 255 14, 3, 16, 25, 0, 25, 0, 0, 8, 12, 256 0, 0, 0, 39, 0, 0, 0, 8, 47, 48, 257 0, 57, 0, 32, 0, 0, 15, 30, 0, 30, 258 30, 30, 30, 30, 34, 0, 0, 0, 46, 0, 259 0, 0, 0, 0, 59, 0, 38, 0, 0, 43, 260 45, 44, 0, 0, 49, 58, 0, 30, 50, 56, 261 0, 0, 0, 51, 0, 0, 52, 0, 53, 262 }; 263 #if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) 264 static const YYINT demo_stos[] = { 0, 265 271, 289, 275, 290, 261, 262, 263, 264, 265, 269, 266 273, 281, 282, 283, 285, 286, 42, 40, 259, 274, 267 279, 290, 259, 284, 294, 59, 44, 40, 91, 291, 268 282, 269, 285, 292, 295, 292, 292, 292, 123, 278, 269 293, 279, 293, 280, 281, 287, 288, 42, 259, 260, 270 272, 290, 279, 41, 279, 279, 41, 44, 290, 43, 271 45, 42, 47, 37, 93, 277, 284, 294, 272, 294, 272 294, 294, 294, 294, 125, 290, 280, 272, 272, 272, 273 272, 272, 266, 272, 273, 276, 298, 40, 59, 278, 274 294, 272, 41, 267, 296, 276, 268, 297, 276, 275 }; 276 #endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ 277 static const YYINT demo_dgoto[] = { 1, 278 84, 85, 20, 3, 86, 66, 40, 21, 44, 12, 279 13, 14, 24, 15, 16, 46, 47, 2, 22, 30, 280 34, 41, 25, 35, 95, 98, 87, 281 }; 282 static const YYINT demo_sindex[] = { 0, 283 0, 0, 0, -103, 0, 0, 0, 0, 0, 0, 284 0, -31, 0, 0, 0, -238, 0, 0, 0, 4, 285 -36, -103, 0, -133, 0, 0, 0, 0, 0, -94, 286 0, 0, 0, 0, -40, 0, -103, -33, 0, 0, 287 -40, -25, -40, 0, -31, 8, 15, 0, 0, 0, 288 -2, 0, -36, 0, -36, -36, 0, 0, -33, 0, 289 0, 0, 0, 0, 0, -92, -133, -103, 0, -33, 290 -33, -33, -33, -33, 0, -8, 0, 23, 23, 0, 291 0, 0, 11, 75, 0, 0, -94, 0, 0, 0, 292 -33, 96, -194, 0, -8, 0, 0, -8, 0, 293 }; 294 static const YYINT demo_rindex[] = { 0, 295 0, 0, 1, -181, 0, 0, 0, 0, 0, 0, 296 0, 17, 0, 0, 0, 0, 0, 0, 0, 0, 297 -39, -181, 12, -34, 0, 0, 0, 0, 0, 0, 298 0, 0, 0, 0, -5, 0, -11, 0, 0, 0, 299 -17, 0, 28, 0, -41, 0, 47, 0, 0, 0, 300 0, 0, -13, 0, 18, 70, 0, 0, 0, 0, 301 0, 0, 0, 0, 0, -19, -27, -181, 0, 0, 302 0, 0, 0, 0, 0, -29, 0, 56, 64, 0, 303 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 304 0, 0, 0, 0, -29, -30, 0, -29, 0, 305 }; 306 #if YYBTYACC 307 static const YYINT demo_cindex[] = { 0, 308 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 309 0, -22, 0, 0, 0, 0, 0, 0, 0, 0, 310 0, 0, -179, 0, 0, 0, 0, 0, 0, 0, 311 0, 0, 0, 0, 52, 0, 0, 0, 0, 0, 312 58, 0, 62, 0, -21, 0, 0, 0, 0, 0, 313 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 314 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 315 0, 0, 0, 0, 0, -146, 0, 0, 0, 0, 316 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 317 0, 0, 0, 0, -143, -147, 0, -134, 0, 318 }; 319 #endif 320 static const YYINT demo_gindex[] = { 0, 321 9, 143, 0, 0, 50, 0, 63, 101, 83, 7, 322 130, 0, 98, 2, 0, 0, 0, 0, 19, 0, 323 10, 117, 66, 0, 0, 0, 0, 324 }; 325 #define YYTABLESIZE 286 326 static const YYINT demo_table[] = { 28, 327 6, 17, 28, 28, 27, 24, 24, 24, 48, 24, 328 17, 54, 35, 35, 28, 54, 35, 0, 0, 27, 329 23, 4, 8, 28, 24, 33, 28, 33, 39, 36, 330 33, 35, 75, 48, 64, 28, 36, 37, 38, 62, 331 60, 28, 61, 45, 63, 33, 51, 27, 57, 28, 332 88, 4, 4, 4, 29, 4, 24, 52, 58, 64, 333 28, 26, 26, 35, 62, 29, 59, 69, 33, 63, 334 4, 28, 94, 28, 45, 28, 26, 1, 78, 79, 335 80, 81, 82, 11, 76, 28, 28, 37, 24, 6, 336 65, 0, 54, 55, 54, 35, 41, 0, 41, 92, 337 41, 0, 4, 8, 42, 28, 42, 28, 42, 33, 338 40, 64, 9, 40, 41, 9, 62, 60, 28, 61, 339 12, 63, 42, 68, 9, 70, 71, 72, 73, 74, 340 8, 9, 64, 89, 4, 42, 93, 62, 60, 28, 341 61, 53, 63, 55, 96, 56, 11, 99, 41, 90, 342 77, 31, 43, 91, 67, 0, 42, 5, 6, 7, 343 8, 9, 0, 0, 0, 10, 0, 0, 0, 0, 344 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 345 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 346 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 347 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 348 0, 0, 0, 0, 0, 0, 0, 0, 19, 8, 349 8, 8, 8, 8, 24, 49, 50, 8, 54, 54, 350 54, 54, 54, 54, 54, 54, 3, 3, 54, 8, 351 8, 8, 8, 8, 8, 8, 8, 1, 0, 8, 352 0, 50, 5, 6, 7, 8, 9, 83, 0, 8, 353 10, 8, 8, 8, 8, 8, 0, 0, 0, 8, 354 4, 0, 4, 4, 4, 4, 4, 8, 8, 8, 355 8, 8, 0, 0, 0, 8, 356 }; 357 static const YYINT demo_check[] = { 41, 358 0, 42, 44, 40, 44, 40, 41, 42, 42, 44, 359 42, 42, 40, 41, 40, 41, 44, 40, 40, 59, 360 259, 3, 42, 41, 59, 24, 44, 41, 123, 41, 361 44, 59, 125, 42, 37, 41, 27, 28, 29, 42, 362 43, 59, 45, 37, 47, 59, 38, 44, 41, 91, 363 40, 40, 41, 42, 91, 44, 91, 39, 44, 37, 364 44, 44, 59, 91, 42, 91, 48, 59, 67, 47, 365 59, 44, 267, 91, 68, 59, 59, 259, 70, 71, 366 72, 73, 74, 123, 66, 91, 59, 41, 123, 269, 367 93, 40, 123, 123, 125, 123, 41, 40, 43, 91, 368 45, 40, 91, 123, 41, 123, 43, 91, 45, 123, 369 41, 37, 259, 44, 59, 259, 42, 43, 91, 45, 370 268, 47, 59, 58, 259, 60, 61, 62, 63, 64, 371 264, 265, 37, 59, 123, 35, 41, 42, 43, 123, 372 45, 41, 47, 43, 95, 45, 4, 98, 93, 87, 373 68, 22, 36, 88, 57, -1, 93, 261, 262, 263, 374 264, 265, -1, -1, -1, 269, -1, -1, -1, -1, 375 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 376 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 377 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 378 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 379 -1, -1, -1, -1, -1, -1, -1, -1, 259, 261, 380 262, 263, 264, 265, 259, 259, 260, 269, 259, 260, 381 261, 262, 263, 264, 265, 266, 259, 259, 269, 259, 382 260, 261, 262, 263, 264, 265, 266, 259, -1, 269, 383 -1, 260, 261, 262, 263, 264, 265, 266, -1, 259, 384 269, 261, 262, 263, 264, 265, -1, -1, -1, 269, 385 259, -1, 261, 262, 263, 264, 265, 261, 262, 263, 386 264, 265, -1, -1, -1, 269, 387 }; 388 #if YYBTYACC 389 static const YYINT demo_ctable[] = { 18, 390 28, -1, 19, 8, -1, 32, 4, -1, 49, 1, 391 -1, 97, 54, -1, -1, -1, -1, -1, -1, -1, 392 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 393 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 394 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 395 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 396 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 397 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 398 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 399 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 400 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 401 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 402 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 403 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 404 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 405 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 406 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 407 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 408 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 409 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 410 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 411 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 412 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 413 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 414 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 415 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 416 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 417 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 418 -1, -1, -1, -1, -1, 419 }; 420 #endif 421 #define YYFINAL 1 422 #ifndef YYDEBUG 423 #define YYDEBUG 0 424 #endif 425 #define YYMAXTOKEN 269 426 #define YYUNDFTOKEN 299 427 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) 428 #if YYDEBUG 429 static const char *const demo_name[] = { 430 431 "$end",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, 432 "'%'",0,0,"'('","')'","'*'","'+'","','","'-'","'.'","'/'",0,0,0,0,0,0,0,0,0,0,0, 433 "';'",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, 434 "']'",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, 435 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, 436 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, 437 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, 438 0,0,0,0,0,0,0,0,0,"error","PREFIX","POSTFIX","ID","CONSTANT","EXTERN", 439 "REGISTER","STATIC","CONST","VOLATILE","IF","THEN","ELSE","CLCL","$accept", 440 "input","expr","decl","declarator_list","decl_list","statement", 441 "statement_list","block_statement","declarator","formal_arg","decl_specs", 442 "decl_spec","typename","cv_quals","cv_qual","opt_scope","formal_arg_list", 443 "nonempty_formal_arg_list","$$1","$$2","$$3","$$4","$$5","$$6","$$7","$$8", 444 "$$9","$$10","illegal-symbol", 445 }; 446 static const char *const demo_rule[] = { 447 "$accept : input", 448 "opt_scope :", 449 "opt_scope : CLCL", 450 "opt_scope : opt_scope ID CLCL", 451 "typename : opt_scope ID", 452 "$$1 :", 453 "input : $$1 decl_list", 454 "decl_list :", 455 "$$2 :", 456 "decl_list : decl_list $$2 decl", 457 "decl : decl_specs declarator_list ';'", 458 "$$3 :", 459 "decl : decl_specs declarator $$3 block_statement", 460 "decl_specs : decl_spec", 461 "decl_specs : decl_specs $$2 decl_spec", 462 "cv_quals :", 463 "cv_quals : cv_quals cv_qual", 464 "decl_spec : cv_qual", 465 "decl_spec : typename", 466 "decl_spec : EXTERN", 467 "decl_spec : REGISTER", 468 "decl_spec : STATIC", 469 "cv_qual : CONST", 470 "cv_qual : VOLATILE", 471 "$$4 :", 472 "$$5 :", 473 "declarator_list : declarator_list ',' $$4 $$5 declarator", 474 "declarator_list : declarator", 475 "declarator :", 476 "declarator : ID", 477 "$$6 :", 478 "$$7 :", 479 "declarator : '(' $$6 $$7 declarator ')'", 480 "declarator : '*' cv_quals $$4 $$5 declarator", 481 "declarator : declarator '[' $$4 expr ']'", 482 "declarator : declarator '(' $$4 formal_arg_list ')' cv_quals", 483 "formal_arg_list :", 484 "formal_arg_list : nonempty_formal_arg_list", 485 "nonempty_formal_arg_list : nonempty_formal_arg_list ',' $$6 formal_arg", 486 "nonempty_formal_arg_list : formal_arg", 487 "formal_arg : decl_specs declarator", 488 "expr : expr '+' $$6 expr", 489 "expr : expr '-' $$6 expr", 490 "expr : expr '*' $$6 expr", 491 "expr : expr '%' $$6 expr", 492 "expr : expr '/' $$6 expr", 493 "expr : '*' $$2 expr", 494 "expr : ID", 495 "expr : CONSTANT", 496 "statement : decl", 497 "statement : expr ';'", 498 "$$8 :", 499 "$$9 :", 500 "statement : IF '(' $$6 expr ')' THEN $$8 statement ELSE $$9 statement", 501 "statement : IF '(' $$6 expr ')' THEN $$8 statement", 502 "$$10 :", 503 "statement : $$10 block_statement", 504 "statement_list :", 505 "statement_list : statement_list $$2 statement", 506 "block_statement : '{' $$2 statement_list '}'", 507 508 }; 509 #endif 510 511 int yydebug; 512 int yynerrs; 513 514 int yyerrflag; 515 int yychar; 516 YYSTYPE yyval; 517 YYSTYPE yylval; 518 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 519 YYLTYPE yyloc; /* position returned by actions */ 520 YYLTYPE yylloc; /* position from the lexer */ 521 #endif 522 523 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 524 #ifndef YYLLOC_DEFAULT 525 #define YYLLOC_DEFAULT(loc, rhs, n) \ 526 do \ 527 { \ 528 if (n == 0) \ 529 { \ 530 (loc).first_line = ((rhs)[-1]).last_line; \ 531 (loc).first_column = ((rhs)[-1]).last_column; \ 532 (loc).last_line = ((rhs)[-1]).last_line; \ 533 (loc).last_column = ((rhs)[-1]).last_column; \ 534 } \ 535 else \ 536 { \ 537 (loc).first_line = ((rhs)[ 0 ]).first_line; \ 538 (loc).first_column = ((rhs)[ 0 ]).first_column; \ 539 (loc).last_line = ((rhs)[n-1]).last_line; \ 540 (loc).last_column = ((rhs)[n-1]).last_column; \ 541 } \ 542 } while (0) 543 #endif /* YYLLOC_DEFAULT */ 544 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 545 #if YYBTYACC 546 547 #ifndef YYLVQUEUEGROWTH 548 #define YYLVQUEUEGROWTH 32 549 #endif 550 #endif /* YYBTYACC */ 551 552 /* define the initial stack-sizes */ 553 #ifdef YYSTACKSIZE 554 #undef YYMAXDEPTH 555 #define YYMAXDEPTH YYSTACKSIZE 556 #else 557 #ifdef YYMAXDEPTH 558 #define YYSTACKSIZE YYMAXDEPTH 559 #else 560 #define YYSTACKSIZE 10000 561 #define YYMAXDEPTH 10000 562 #endif 563 #endif 564 565 #ifndef YYINITSTACKSIZE 566 #define YYINITSTACKSIZE 200 567 #endif 568 569 typedef struct { 570 unsigned stacksize; 571 YYINT *s_base; 572 YYINT *s_mark; 573 YYINT *s_last; 574 YYSTYPE *l_base; 575 YYSTYPE *l_mark; 576 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 577 YYLTYPE *p_base; 578 YYLTYPE *p_mark; 579 #endif 580 } YYSTACKDATA; 581 #if YYBTYACC 582 583 struct YYParseState_s 584 { 585 struct YYParseState_s *save; /* Previously saved parser state */ 586 YYSTACKDATA yystack; /* saved parser stack */ 587 int state; /* saved parser state */ 588 int errflag; /* saved error recovery status */ 589 int lexeme; /* saved index of the conflict lexeme in the lexical queue */ 590 YYINT ctry; /* saved index in yyctable[] for this conflict */ 591 }; 592 typedef struct YYParseState_s YYParseState; 593 #endif /* YYBTYACC */ 594 /* variables for the parser stack */ 595 static YYSTACKDATA yystack; 596 #if YYBTYACC 597 598 /* Current parser state */ 599 static YYParseState *yyps = 0; 600 601 /* yypath != NULL: do the full parse, starting at *yypath parser state. */ 602 static YYParseState *yypath = 0; 603 604 /* Base of the lexical value queue */ 605 static YYSTYPE *yylvals = 0; 606 607 /* Current position at lexical value queue */ 608 static YYSTYPE *yylvp = 0; 609 610 /* End position of lexical value queue */ 611 static YYSTYPE *yylve = 0; 612 613 /* The last allocated position at the lexical value queue */ 614 static YYSTYPE *yylvlim = 0; 615 616 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 617 /* Base of the lexical position queue */ 618 static YYLTYPE *yylpsns = 0; 619 620 /* Current position at lexical position queue */ 621 static YYLTYPE *yylpp = 0; 622 623 /* End position of lexical position queue */ 624 static YYLTYPE *yylpe = 0; 625 626 /* The last allocated position at the lexical position queue */ 627 static YYLTYPE *yylplim = 0; 628 #endif 629 630 /* Current position at lexical token queue */ 631 static YYINT *yylexp = 0; 632 633 static YYINT *yylexemes = 0; 634 #endif /* YYBTYACC */ 635 #line 200 "btyacc_demo.y" 636 637 extern int YYLEX_DECL(); 638 extern void YYERROR_DECL(); 639 640 extern Scope *global_scope; 641 642 extern Decl * lookup(Scope *scope, char *id); 643 extern Scope * new_scope(Scope *outer_scope); 644 extern Scope * start_fn_def(Scope *scope, Decl *fn_decl); 645 extern void finish_fn_def(Decl *fn_decl, Code *block); 646 extern Type * type_combine(Type *specs, Type *spec); 647 extern Type * bare_extern(void); 648 extern Type * bare_register(void); 649 extern Type * bare_static(void); 650 extern Type * bare_const(void); 651 extern Type * bare_volatile(void); 652 extern Decl * declare(Scope *scope, char *id, Type *type); 653 extern Decl * make_pointer(Decl *decl, Type *type); 654 extern Decl * make_array(Type *type, Expr *expr); 655 extern Decl * build_function(Decl *decl, Decl_List *dlist, Type *type); 656 extern Decl_List * append_dlist(Decl_List *dlist, Decl *decl); 657 extern Decl_List * build_dlist(Decl *decl); 658 extern Expr * build_expr(Expr *left, enum Operator op, Expr *right); 659 extern Expr * var_expr(Scope *scope, char *id); 660 extern Code * build_expr_code(Expr *expr); 661 extern Code * build_if(Expr *cond_expr, Code *then_stmt, Code *else_stmt); 662 extern Code * code_append(Code *stmt_list, Code *stmt); 663 #line 664 "btyacc_demo.tab.c" 664 665 /* Release memory associated with symbol. */ 666 #if ! defined YYDESTRUCT_IS_DECLARED 667 static void 668 YYDESTRUCT_DECL() 669 { 670 switch (psymb) 671 { 672 case 43: 673 #line 83 "btyacc_demo.y" 674 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", 675 msg, 676 (*loc).first_line, (*loc).first_column, 677 (*loc).last_line, (*loc).last_column); 678 /* in this example, we don't know what to do here */ } 679 break; 680 #line 681 "btyacc_demo.tab.c" 681 case 45: 682 #line 83 "btyacc_demo.y" 683 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", 684 msg, 685 (*loc).first_line, (*loc).first_column, 686 (*loc).last_line, (*loc).last_column); 687 /* in this example, we don't know what to do here */ } 688 break; 689 #line 690 "btyacc_demo.tab.c" 690 case 42: 691 #line 83 "btyacc_demo.y" 692 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", 693 msg, 694 (*loc).first_line, (*loc).first_column, 695 (*loc).last_line, (*loc).last_column); 696 /* in this example, we don't know what to do here */ } 697 break; 698 #line 699 "btyacc_demo.tab.c" 699 case 47: 700 #line 83 "btyacc_demo.y" 701 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", 702 msg, 703 (*loc).first_line, (*loc).first_column, 704 (*loc).last_line, (*loc).last_column); 705 /* in this example, we don't know what to do here */ } 706 break; 707 #line 708 "btyacc_demo.tab.c" 708 case 37: 709 #line 83 "btyacc_demo.y" 710 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", 711 msg, 712 (*loc).first_line, (*loc).first_column, 713 (*loc).last_line, (*loc).last_column); 714 /* in this example, we don't know what to do here */ } 715 break; 716 #line 717 "btyacc_demo.tab.c" 717 case 257: 718 #line 83 "btyacc_demo.y" 719 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", 720 msg, 721 (*loc).first_line, (*loc).first_column, 722 (*loc).last_line, (*loc).last_column); 723 /* in this example, we don't know what to do here */ } 724 break; 725 #line 726 "btyacc_demo.tab.c" 726 case 258: 727 #line 83 "btyacc_demo.y" 728 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", 729 msg, 730 (*loc).first_line, (*loc).first_column, 731 (*loc).last_line, (*loc).last_column); 732 /* in this example, we don't know what to do here */ } 733 break; 734 #line 735 "btyacc_demo.tab.c" 735 case 40: 736 #line 83 "btyacc_demo.y" 737 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", 738 msg, 739 (*loc).first_line, (*loc).first_column, 740 (*loc).last_line, (*loc).last_column); 741 /* in this example, we don't know what to do here */ } 742 break; 743 #line 744 "btyacc_demo.tab.c" 744 case 91: 745 #line 83 "btyacc_demo.y" 746 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", 747 msg, 748 (*loc).first_line, (*loc).first_column, 749 (*loc).last_line, (*loc).last_column); 750 /* in this example, we don't know what to do here */ } 751 break; 752 #line 753 "btyacc_demo.tab.c" 753 case 46: 754 #line 83 "btyacc_demo.y" 755 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", 756 msg, 757 (*loc).first_line, (*loc).first_column, 758 (*loc).last_line, (*loc).last_column); 759 /* in this example, we don't know what to do here */ } 760 break; 761 #line 762 "btyacc_demo.tab.c" 762 case 259: 763 #line 78 "btyacc_demo.y" 764 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n", 765 msg, 766 (*loc).first_line, (*loc).first_column, 767 (*loc).last_line, (*loc).last_column); 768 free((*val).id); } 769 break; 770 #line 771 "btyacc_demo.tab.c" 771 case 260: 772 #line 78 "btyacc_demo.y" 773 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n", 774 msg, 775 (*loc).first_line, (*loc).first_column, 776 (*loc).last_line, (*loc).last_column); 777 free((*val).expr); } 778 break; 779 #line 780 "btyacc_demo.tab.c" 780 case 261: 781 #line 83 "btyacc_demo.y" 782 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", 783 msg, 784 (*loc).first_line, (*loc).first_column, 785 (*loc).last_line, (*loc).last_column); 786 /* in this example, we don't know what to do here */ } 787 break; 788 #line 789 "btyacc_demo.tab.c" 789 case 262: 790 #line 83 "btyacc_demo.y" 791 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", 792 msg, 793 (*loc).first_line, (*loc).first_column, 794 (*loc).last_line, (*loc).last_column); 795 /* in this example, we don't know what to do here */ } 796 break; 797 #line 798 "btyacc_demo.tab.c" 798 case 263: 799 #line 83 "btyacc_demo.y" 800 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", 801 msg, 802 (*loc).first_line, (*loc).first_column, 803 (*loc).last_line, (*loc).last_column); 804 /* in this example, we don't know what to do here */ } 805 break; 806 #line 807 "btyacc_demo.tab.c" 807 case 264: 808 #line 83 "btyacc_demo.y" 809 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", 810 msg, 811 (*loc).first_line, (*loc).first_column, 812 (*loc).last_line, (*loc).last_column); 813 /* in this example, we don't know what to do here */ } 814 break; 815 #line 816 "btyacc_demo.tab.c" 816 case 265: 817 #line 83 "btyacc_demo.y" 818 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", 819 msg, 820 (*loc).first_line, (*loc).first_column, 821 (*loc).last_line, (*loc).last_column); 822 /* in this example, we don't know what to do here */ } 823 break; 824 #line 825 "btyacc_demo.tab.c" 825 case 266: 826 #line 83 "btyacc_demo.y" 827 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", 828 msg, 829 (*loc).first_line, (*loc).first_column, 830 (*loc).last_line, (*loc).last_column); 831 /* in this example, we don't know what to do here */ } 832 break; 833 #line 834 "btyacc_demo.tab.c" 834 case 267: 835 #line 83 "btyacc_demo.y" 836 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", 837 msg, 838 (*loc).first_line, (*loc).first_column, 839 (*loc).last_line, (*loc).last_column); 840 /* in this example, we don't know what to do here */ } 841 break; 842 #line 843 "btyacc_demo.tab.c" 843 case 268: 844 #line 83 "btyacc_demo.y" 845 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", 846 msg, 847 (*loc).first_line, (*loc).first_column, 848 (*loc).last_line, (*loc).last_column); 849 /* in this example, we don't know what to do here */ } 850 break; 851 #line 852 "btyacc_demo.tab.c" 852 case 269: 853 #line 83 "btyacc_demo.y" 854 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", 855 msg, 856 (*loc).first_line, (*loc).first_column, 857 (*loc).last_line, (*loc).last_column); 858 /* in this example, we don't know what to do here */ } 859 break; 860 #line 861 "btyacc_demo.tab.c" 861 case 59: 862 #line 83 "btyacc_demo.y" 863 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", 864 msg, 865 (*loc).first_line, (*loc).first_column, 866 (*loc).last_line, (*loc).last_column); 867 /* in this example, we don't know what to do here */ } 868 break; 869 #line 870 "btyacc_demo.tab.c" 870 case 44: 871 #line 83 "btyacc_demo.y" 872 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", 873 msg, 874 (*loc).first_line, (*loc).first_column, 875 (*loc).last_line, (*loc).last_column); 876 /* in this example, we don't know what to do here */ } 877 break; 878 #line 879 "btyacc_demo.tab.c" 879 case 41: 880 #line 83 "btyacc_demo.y" 881 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", 882 msg, 883 (*loc).first_line, (*loc).first_column, 884 (*loc).last_line, (*loc).last_column); 885 /* in this example, we don't know what to do here */ } 886 break; 887 #line 888 "btyacc_demo.tab.c" 888 case 93: 889 #line 83 "btyacc_demo.y" 890 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", 891 msg, 892 (*loc).first_line, (*loc).first_column, 893 (*loc).last_line, (*loc).last_column); 894 /* in this example, we don't know what to do here */ } 895 break; 896 #line 897 "btyacc_demo.tab.c" 897 case 123: 898 #line 83 "btyacc_demo.y" 899 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", 900 msg, 901 (*loc).first_line, (*loc).first_column, 902 (*loc).last_line, (*loc).last_column); 903 /* in this example, we don't know what to do here */ } 904 break; 905 #line 906 "btyacc_demo.tab.c" 906 case 125: 907 #line 83 "btyacc_demo.y" 908 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", 909 msg, 910 (*loc).first_line, (*loc).first_column, 911 (*loc).last_line, (*loc).last_column); 912 /* in this example, we don't know what to do here */ } 913 break; 914 #line 915 "btyacc_demo.tab.c" 915 case 270: 916 #line 83 "btyacc_demo.y" 917 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", 918 msg, 919 (*loc).first_line, (*loc).first_column, 920 (*loc).last_line, (*loc).last_column); 921 /* in this example, we don't know what to do here */ } 922 break; 923 #line 924 "btyacc_demo.tab.c" 924 case 271: 925 #line 83 "btyacc_demo.y" 926 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", 927 msg, 928 (*loc).first_line, (*loc).first_column, 929 (*loc).last_line, (*loc).last_column); 930 /* in this example, we don't know what to do here */ } 931 break; 932 #line 933 "btyacc_demo.tab.c" 933 case 272: 934 #line 78 "btyacc_demo.y" 935 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n", 936 msg, 937 (*loc).first_line, (*loc).first_column, 938 (*loc).last_line, (*loc).last_column); 939 free((*val).expr); } 940 break; 941 #line 942 "btyacc_demo.tab.c" 942 case 273: 943 #line 67 "btyacc_demo.y" 944 { /* 'msg' is a 'char *' indicating the context of destructor invocation*/ 945 printf("%s accessed by symbol \"decl\" (case s.b. 273) @ position[%d,%d..%d,%d]\n", 946 msg, 947 (*loc).first_line, (*loc).first_column, 948 (*loc).last_line, (*loc).last_column); 949 free((*val).decl->scope); free((*val).decl->type); } 950 break; 951 #line 952 "btyacc_demo.tab.c" 952 case 274: 953 #line 83 "btyacc_demo.y" 954 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", 955 msg, 956 (*loc).first_line, (*loc).first_column, 957 (*loc).last_line, (*loc).last_column); 958 /* in this example, we don't know what to do here */ } 959 break; 960 #line 961 "btyacc_demo.tab.c" 961 case 275: 962 #line 83 "btyacc_demo.y" 963 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", 964 msg, 965 (*loc).first_line, (*loc).first_column, 966 (*loc).last_line, (*loc).last_column); 967 /* in this example, we don't know what to do here */ } 968 break; 969 #line 970 "btyacc_demo.tab.c" 970 case 276: 971 #line 78 "btyacc_demo.y" 972 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n", 973 msg, 974 (*loc).first_line, (*loc).first_column, 975 (*loc).last_line, (*loc).last_column); 976 free((*val).code); } 977 break; 978 #line 979 "btyacc_demo.tab.c" 979 case 277: 980 #line 78 "btyacc_demo.y" 981 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n", 982 msg, 983 (*loc).first_line, (*loc).first_column, 984 (*loc).last_line, (*loc).last_column); 985 free((*val).code); } 986 break; 987 #line 988 "btyacc_demo.tab.c" 988 case 278: 989 #line 78 "btyacc_demo.y" 990 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n", 991 msg, 992 (*loc).first_line, (*loc).first_column, 993 (*loc).last_line, (*loc).last_column); 994 free((*val).code); } 995 break; 996 #line 997 "btyacc_demo.tab.c" 997 case 279: 998 #line 73 "btyacc_demo.y" 999 { printf("%s accessed by symbol with type <decl> (case s.b. 279 & 280) @ position[%d,%d..%d,%d]\n", 1000 msg, 1001 (*loc).first_line, (*loc).first_column, 1002 (*loc).last_line, (*loc).last_column); 1003 free((*val).decl); } 1004 break; 1005 #line 1006 "btyacc_demo.tab.c" 1006 case 280: 1007 #line 73 "btyacc_demo.y" 1008 { printf("%s accessed by symbol with type <decl> (case s.b. 279 & 280) @ position[%d,%d..%d,%d]\n", 1009 msg, 1010 (*loc).first_line, (*loc).first_column, 1011 (*loc).last_line, (*loc).last_column); 1012 free((*val).decl); } 1013 break; 1014 #line 1015 "btyacc_demo.tab.c" 1015 case 281: 1016 #line 78 "btyacc_demo.y" 1017 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n", 1018 msg, 1019 (*loc).first_line, (*loc).first_column, 1020 (*loc).last_line, (*loc).last_column); 1021 free((*val).type); } 1022 break; 1023 #line 1024 "btyacc_demo.tab.c" 1024 case 282: 1025 #line 78 "btyacc_demo.y" 1026 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n", 1027 msg, 1028 (*loc).first_line, (*loc).first_column, 1029 (*loc).last_line, (*loc).last_column); 1030 free((*val).type); } 1031 break; 1032 #line 1033 "btyacc_demo.tab.c" 1033 case 283: 1034 #line 78 "btyacc_demo.y" 1035 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n", 1036 msg, 1037 (*loc).first_line, (*loc).first_column, 1038 (*loc).last_line, (*loc).last_column); 1039 free((*val).type); } 1040 break; 1041 #line 1042 "btyacc_demo.tab.c" 1042 case 284: 1043 #line 78 "btyacc_demo.y" 1044 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n", 1045 msg, 1046 (*loc).first_line, (*loc).first_column, 1047 (*loc).last_line, (*loc).last_column); 1048 free((*val).type); } 1049 break; 1050 #line 1051 "btyacc_demo.tab.c" 1051 case 285: 1052 #line 78 "btyacc_demo.y" 1053 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n", 1054 msg, 1055 (*loc).first_line, (*loc).first_column, 1056 (*loc).last_line, (*loc).last_column); 1057 free((*val).type); } 1058 break; 1059 #line 1060 "btyacc_demo.tab.c" 1060 case 286: 1061 #line 78 "btyacc_demo.y" 1062 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n", 1063 msg, 1064 (*loc).first_line, (*loc).first_column, 1065 (*loc).last_line, (*loc).last_column); 1066 free((*val).scope); } 1067 break; 1068 #line 1069 "btyacc_demo.tab.c" 1069 case 287: 1070 #line 78 "btyacc_demo.y" 1071 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n", 1072 msg, 1073 (*loc).first_line, (*loc).first_column, 1074 (*loc).last_line, (*loc).last_column); 1075 free((*val).dlist); } 1076 break; 1077 #line 1078 "btyacc_demo.tab.c" 1078 case 288: 1079 #line 78 "btyacc_demo.y" 1080 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n", 1081 msg, 1082 (*loc).first_line, (*loc).first_column, 1083 (*loc).last_line, (*loc).last_column); 1084 free((*val).dlist); } 1085 break; 1086 #line 1087 "btyacc_demo.tab.c" 1087 case 289: 1088 #line 78 "btyacc_demo.y" 1089 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n", 1090 msg, 1091 (*loc).first_line, (*loc).first_column, 1092 (*loc).last_line, (*loc).last_column); 1093 free((*val).scope); } 1094 break; 1095 #line 1096 "btyacc_demo.tab.c" 1096 case 290: 1097 #line 78 "btyacc_demo.y" 1098 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n", 1099 msg, 1100 (*loc).first_line, (*loc).first_column, 1101 (*loc).last_line, (*loc).last_column); 1102 free((*val).scope); } 1103 break; 1104 #line 1105 "btyacc_demo.tab.c" 1105 case 291: 1106 #line 78 "btyacc_demo.y" 1107 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n", 1108 msg, 1109 (*loc).first_line, (*loc).first_column, 1110 (*loc).last_line, (*loc).last_column); 1111 free((*val).scope); } 1112 break; 1113 #line 1114 "btyacc_demo.tab.c" 1114 case 292: 1115 #line 78 "btyacc_demo.y" 1116 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n", 1117 msg, 1118 (*loc).first_line, (*loc).first_column, 1119 (*loc).last_line, (*loc).last_column); 1120 free((*val).scope); } 1121 break; 1122 #line 1123 "btyacc_demo.tab.c" 1123 case 293: 1124 #line 78 "btyacc_demo.y" 1125 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n", 1126 msg, 1127 (*loc).first_line, (*loc).first_column, 1128 (*loc).last_line, (*loc).last_column); 1129 free((*val).type); } 1130 break; 1131 #line 1132 "btyacc_demo.tab.c" 1132 case 294: 1133 #line 78 "btyacc_demo.y" 1134 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n", 1135 msg, 1136 (*loc).first_line, (*loc).first_column, 1137 (*loc).last_line, (*loc).last_column); 1138 free((*val).scope); } 1139 break; 1140 #line 1141 "btyacc_demo.tab.c" 1141 case 295: 1142 #line 78 "btyacc_demo.y" 1143 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n", 1144 msg, 1145 (*loc).first_line, (*loc).first_column, 1146 (*loc).last_line, (*loc).last_column); 1147 free((*val).type); } 1148 break; 1149 #line 1150 "btyacc_demo.tab.c" 1150 case 296: 1151 #line 78 "btyacc_demo.y" 1152 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n", 1153 msg, 1154 (*loc).first_line, (*loc).first_column, 1155 (*loc).last_line, (*loc).last_column); 1156 free((*val).scope); } 1157 break; 1158 #line 1159 "btyacc_demo.tab.c" 1159 case 297: 1160 #line 78 "btyacc_demo.y" 1161 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n", 1162 msg, 1163 (*loc).first_line, (*loc).first_column, 1164 (*loc).last_line, (*loc).last_column); 1165 free((*val).scope); } 1166 break; 1167 #line 1168 "btyacc_demo.tab.c" 1168 case 298: 1169 #line 78 "btyacc_demo.y" 1170 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n", 1171 msg, 1172 (*loc).first_line, (*loc).first_column, 1173 (*loc).last_line, (*loc).last_column); 1174 free((*val).scope); } 1175 break; 1176 #line 1177 "btyacc_demo.tab.c" 1177 } 1178 } 1179 #define YYDESTRUCT_IS_DECLARED 1 1180 #endif 1181 1182 /* For use in generated program */ 1183 #define yydepth (int)(yystack.s_mark - yystack.s_base) 1184 #if YYBTYACC 1185 #define yytrial (yyps->save) 1186 #endif /* YYBTYACC */ 1187 1188 #if YYDEBUG 1189 #include <stdio.h> /* needed for printf */ 1190 #endif 1191 1192 #include <stdlib.h> /* needed for malloc, etc */ 1193 #include <string.h> /* needed for memset */ 1194 1195 /* allocate initial stack or double stack size, up to YYMAXDEPTH */ 1196 static int yygrowstack(YYSTACKDATA *data) 1197 { 1198 int i; 1199 unsigned newsize; 1200 YYINT *newss; 1201 YYSTYPE *newvs; 1202 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1203 YYLTYPE *newps; 1204 #endif 1205 1206 if ((newsize = data->stacksize) == 0) 1207 newsize = YYINITSTACKSIZE; 1208 else if (newsize >= YYMAXDEPTH) 1209 return YYENOMEM; 1210 else if ((newsize *= 2) > YYMAXDEPTH) 1211 newsize = YYMAXDEPTH; 1212 1213 i = (int) (data->s_mark - data->s_base); 1214 newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); 1215 if (newss == 0) 1216 return YYENOMEM; 1217 1218 data->s_base = newss; 1219 data->s_mark = newss + i; 1220 1221 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); 1222 if (newvs == 0) 1223 return YYENOMEM; 1224 1225 data->l_base = newvs; 1226 data->l_mark = newvs + i; 1227 1228 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1229 newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); 1230 if (newps == 0) 1231 return YYENOMEM; 1232 1233 data->p_base = newps; 1234 data->p_mark = newps + i; 1235 #endif 1236 1237 data->stacksize = newsize; 1238 data->s_last = data->s_base + newsize - 1; 1239 1240 #if YYDEBUG 1241 if (yydebug) 1242 fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); 1243 #endif 1244 return 0; 1245 } 1246 1247 #if YYPURE || defined(YY_NO_LEAKS) 1248 static void yyfreestack(YYSTACKDATA *data) 1249 { 1250 free(data->s_base); 1251 free(data->l_base); 1252 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1253 free(data->p_base); 1254 #endif 1255 memset(data, 0, sizeof(*data)); 1256 } 1257 #else 1258 #define yyfreestack(data) /* nothing */ 1259 #endif /* YYPURE || defined(YY_NO_LEAKS) */ 1260 #if YYBTYACC 1261 1262 static YYParseState * 1263 yyNewState(unsigned size) 1264 { 1265 YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); 1266 if (p == NULL) return NULL; 1267 1268 p->yystack.stacksize = size; 1269 if (size == 0) 1270 { 1271 p->yystack.s_base = NULL; 1272 p->yystack.l_base = NULL; 1273 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1274 p->yystack.p_base = NULL; 1275 #endif 1276 return p; 1277 } 1278 p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); 1279 if (p->yystack.s_base == NULL) return NULL; 1280 p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); 1281 if (p->yystack.l_base == NULL) return NULL; 1282 memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); 1283 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1284 p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); 1285 if (p->yystack.p_base == NULL) return NULL; 1286 memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); 1287 #endif 1288 1289 return p; 1290 } 1291 1292 static void 1293 yyFreeState(YYParseState *p) 1294 { 1295 yyfreestack(&p->yystack); 1296 free(p); 1297 } 1298 #endif /* YYBTYACC */ 1299 1300 #define YYABORT goto yyabort 1301 #define YYREJECT goto yyabort 1302 #define YYACCEPT goto yyaccept 1303 #define YYERROR goto yyerrlab 1304 #if YYBTYACC 1305 #define YYVALID do { if (yyps->save) goto yyvalid; } while(0) 1306 #define YYVALID_NESTED do { if (yyps->save && \ 1307 yyps->save->save == 0) goto yyvalid; } while(0) 1308 #endif /* YYBTYACC */ 1309 1310 int 1311 YYPARSE_DECL() 1312 { 1313 int yym, yyn, yystate, yyresult; 1314 #if YYBTYACC 1315 int yynewerrflag; 1316 YYParseState *yyerrctx = NULL; 1317 #endif /* YYBTYACC */ 1318 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1319 YYLTYPE yyerror_loc_range[2]; /* position of error start & end */ 1320 #endif 1321 #if YYDEBUG 1322 const char *yys; 1323 1324 if ((yys = getenv("YYDEBUG")) != 0) 1325 { 1326 yyn = *yys; 1327 if (yyn >= '0' && yyn <= '9') 1328 yydebug = yyn - '0'; 1329 } 1330 if (yydebug) 1331 fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); 1332 #endif 1333 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1334 memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); 1335 #endif 1336 1337 #if YYBTYACC 1338 yyps = yyNewState(0); if (yyps == 0) goto yyenomem; 1339 yyps->save = 0; 1340 #endif /* YYBTYACC */ 1341 yym = 0; 1342 yyn = 0; 1343 yynerrs = 0; 1344 yyerrflag = 0; 1345 yychar = YYEMPTY; 1346 yystate = 0; 1347 1348 #if YYPURE 1349 memset(&yystack, 0, sizeof(yystack)); 1350 #endif 1351 1352 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 1353 yystack.s_mark = yystack.s_base; 1354 yystack.l_mark = yystack.l_base; 1355 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1356 yystack.p_mark = yystack.p_base; 1357 #endif 1358 yystate = 0; 1359 *yystack.s_mark = 0; 1360 1361 yyloop: 1362 if ((yyn = yydefred[yystate]) != 0) goto yyreduce; 1363 if (yychar < 0) 1364 { 1365 #if YYBTYACC 1366 do { 1367 if (yylvp < yylve) 1368 { 1369 /* we're currently re-reading tokens */ 1370 yylval = *yylvp++; 1371 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1372 yylloc = *yylpp++; 1373 #endif 1374 yychar = *yylexp++; 1375 break; 1376 } 1377 if (yyps->save) 1378 { 1379 /* in trial mode; save scanner results for future parse attempts */ 1380 if (yylvp == yylvlim) 1381 { /* Enlarge lexical value queue */ 1382 size_t p = (size_t) (yylvp - yylvals); 1383 size_t s = (size_t) (yylvlim - yylvals); 1384 1385 s += YYLVQUEUEGROWTH; 1386 if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; 1387 if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; 1388 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1389 if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; 1390 #endif 1391 yylvp = yylve = yylvals + p; 1392 yylvlim = yylvals + s; 1393 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1394 yylpp = yylpe = yylpsns + p; 1395 yylplim = yylpsns + s; 1396 #endif 1397 yylexp = yylexemes + p; 1398 } 1399 *yylexp = (YYINT) YYLEX; 1400 *yylvp++ = yylval; 1401 yylve++; 1402 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1403 *yylpp++ = yylloc; 1404 yylpe++; 1405 #endif 1406 yychar = *yylexp++; 1407 break; 1408 } 1409 /* normal operation, no conflict encountered */ 1410 #endif /* YYBTYACC */ 1411 yychar = YYLEX; 1412 #if YYBTYACC 1413 } while (0); 1414 #endif /* YYBTYACC */ 1415 if (yychar < 0) yychar = YYEOF; 1416 #if YYDEBUG 1417 if (yydebug) 1418 { 1419 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; 1420 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", 1421 YYDEBUGSTR, yydepth, yystate, yychar, yys); 1422 #ifdef YYSTYPE_TOSTRING 1423 #if YYBTYACC 1424 if (!yytrial) 1425 #endif /* YYBTYACC */ 1426 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); 1427 #endif 1428 fputc('\n', stderr); 1429 } 1430 #endif 1431 } 1432 #if YYBTYACC 1433 1434 /* Do we have a conflict? */ 1435 if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && 1436 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) 1437 { 1438 YYINT ctry; 1439 1440 if (yypath) 1441 { 1442 YYParseState *save; 1443 #if YYDEBUG 1444 if (yydebug) 1445 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", 1446 YYDEBUGSTR, yydepth, yystate); 1447 #endif 1448 /* Switch to the next conflict context */ 1449 save = yypath; 1450 yypath = save->save; 1451 save->save = NULL; 1452 ctry = save->ctry; 1453 if (save->state != yystate) YYABORT; 1454 yyFreeState(save); 1455 1456 } 1457 else 1458 { 1459 1460 /* Unresolved conflict - start/continue trial parse */ 1461 YYParseState *save; 1462 #if YYDEBUG 1463 if (yydebug) 1464 { 1465 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); 1466 if (yyps->save) 1467 fputs("ALREADY in conflict, continuing trial parse.\n", stderr); 1468 else 1469 fputs("Starting trial parse.\n", stderr); 1470 } 1471 #endif 1472 save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); 1473 if (save == NULL) goto yyenomem; 1474 save->save = yyps->save; 1475 save->state = yystate; 1476 save->errflag = yyerrflag; 1477 save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); 1478 memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); 1479 save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); 1480 memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 1481 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1482 save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); 1483 memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 1484 #endif 1485 ctry = yytable[yyn]; 1486 if (yyctable[ctry] == -1) 1487 { 1488 #if YYDEBUG 1489 if (yydebug && yychar >= YYEOF) 1490 fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); 1491 #endif 1492 ctry++; 1493 } 1494 save->ctry = ctry; 1495 if (yyps->save == NULL) 1496 { 1497 /* If this is a first conflict in the stack, start saving lexemes */ 1498 if (!yylexemes) 1499 { 1500 yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); 1501 if (yylexemes == NULL) goto yyenomem; 1502 yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); 1503 if (yylvals == NULL) goto yyenomem; 1504 yylvlim = yylvals + YYLVQUEUEGROWTH; 1505 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1506 yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); 1507 if (yylpsns == NULL) goto yyenomem; 1508 yylplim = yylpsns + YYLVQUEUEGROWTH; 1509 #endif 1510 } 1511 if (yylvp == yylve) 1512 { 1513 yylvp = yylve = yylvals; 1514 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1515 yylpp = yylpe = yylpsns; 1516 #endif 1517 yylexp = yylexemes; 1518 if (yychar >= YYEOF) 1519 { 1520 *yylve++ = yylval; 1521 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1522 *yylpe++ = yylloc; 1523 #endif 1524 *yylexp = (YYINT) yychar; 1525 yychar = YYEMPTY; 1526 } 1527 } 1528 } 1529 if (yychar >= YYEOF) 1530 { 1531 yylvp--; 1532 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1533 yylpp--; 1534 #endif 1535 yylexp--; 1536 yychar = YYEMPTY; 1537 } 1538 save->lexeme = (int) (yylvp - yylvals); 1539 yyps->save = save; 1540 } 1541 if (yytable[yyn] == ctry) 1542 { 1543 #if YYDEBUG 1544 if (yydebug) 1545 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", 1546 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); 1547 #endif 1548 if (yychar < 0) 1549 { 1550 yylvp++; 1551 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1552 yylpp++; 1553 #endif 1554 yylexp++; 1555 } 1556 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) 1557 goto yyoverflow; 1558 yystate = yyctable[ctry]; 1559 *++yystack.s_mark = (YYINT) yystate; 1560 *++yystack.l_mark = yylval; 1561 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1562 *++yystack.p_mark = yylloc; 1563 #endif 1564 yychar = YYEMPTY; 1565 if (yyerrflag > 0) --yyerrflag; 1566 goto yyloop; 1567 } 1568 else 1569 { 1570 yyn = yyctable[ctry]; 1571 goto yyreduce; 1572 } 1573 } /* End of code dealing with conflicts */ 1574 #endif /* YYBTYACC */ 1575 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && 1576 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) 1577 { 1578 #if YYDEBUG 1579 if (yydebug) 1580 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", 1581 YYDEBUGSTR, yydepth, yystate, yytable[yyn]); 1582 #endif 1583 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 1584 yystate = yytable[yyn]; 1585 *++yystack.s_mark = yytable[yyn]; 1586 *++yystack.l_mark = yylval; 1587 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1588 *++yystack.p_mark = yylloc; 1589 #endif 1590 yychar = YYEMPTY; 1591 if (yyerrflag > 0) --yyerrflag; 1592 goto yyloop; 1593 } 1594 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && 1595 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) 1596 { 1597 yyn = yytable[yyn]; 1598 goto yyreduce; 1599 } 1600 if (yyerrflag != 0) goto yyinrecovery; 1601 #if YYBTYACC 1602 1603 yynewerrflag = 1; 1604 goto yyerrhandler; 1605 goto yyerrlab; /* redundant goto avoids 'unused label' warning */ 1606 1607 yyerrlab: 1608 /* explicit YYERROR from an action -- pop the rhs of the rule reduced 1609 * before looking for error recovery */ 1610 yystack.s_mark -= yym; 1611 yystate = *yystack.s_mark; 1612 yystack.l_mark -= yym; 1613 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1614 yystack.p_mark -= yym; 1615 #endif 1616 1617 yynewerrflag = 0; 1618 yyerrhandler: 1619 while (yyps->save) 1620 { 1621 int ctry; 1622 YYParseState *save = yyps->save; 1623 #if YYDEBUG 1624 if (yydebug) 1625 fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", 1626 YYDEBUGSTR, yydepth, yystate, yyps->save->state, 1627 (int)(yylvp - yylvals - yyps->save->lexeme)); 1628 #endif 1629 /* Memorize most forward-looking error state in case it's really an error. */ 1630 if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) 1631 { 1632 /* Free old saved error context state */ 1633 if (yyerrctx) yyFreeState(yyerrctx); 1634 /* Create and fill out new saved error context state */ 1635 yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); 1636 if (yyerrctx == NULL) goto yyenomem; 1637 yyerrctx->save = yyps->save; 1638 yyerrctx->state = yystate; 1639 yyerrctx->errflag = yyerrflag; 1640 yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); 1641 memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); 1642 yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); 1643 memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 1644 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1645 yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); 1646 memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 1647 #endif 1648 yyerrctx->lexeme = (int) (yylvp - yylvals); 1649 } 1650 yylvp = yylvals + save->lexeme; 1651 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1652 yylpp = yylpsns + save->lexeme; 1653 #endif 1654 yylexp = yylexemes + save->lexeme; 1655 yychar = YYEMPTY; 1656 yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); 1657 memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); 1658 yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); 1659 memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 1660 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1661 yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); 1662 memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 1663 #endif 1664 ctry = ++save->ctry; 1665 yystate = save->state; 1666 /* We tried shift, try reduce now */ 1667 if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; 1668 yyps->save = save->save; 1669 save->save = NULL; 1670 yyFreeState(save); 1671 1672 /* Nothing left on the stack -- error */ 1673 if (!yyps->save) 1674 { 1675 #if YYDEBUG 1676 if (yydebug) 1677 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", 1678 YYPREFIX, yydepth); 1679 #endif 1680 /* Restore state as it was in the most forward-advanced error */ 1681 yylvp = yylvals + yyerrctx->lexeme; 1682 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1683 yylpp = yylpsns + yyerrctx->lexeme; 1684 #endif 1685 yylexp = yylexemes + yyerrctx->lexeme; 1686 yychar = yylexp[-1]; 1687 yylval = yylvp[-1]; 1688 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1689 yylloc = yylpp[-1]; 1690 #endif 1691 yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); 1692 memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); 1693 yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); 1694 memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 1695 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1696 yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); 1697 memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 1698 #endif 1699 yystate = yyerrctx->state; 1700 yyFreeState(yyerrctx); 1701 yyerrctx = NULL; 1702 } 1703 yynewerrflag = 1; 1704 } 1705 if (yynewerrflag == 0) goto yyinrecovery; 1706 #endif /* YYBTYACC */ 1707 1708 YYERROR_CALL("syntax error"); 1709 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1710 yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ 1711 #endif 1712 1713 #if !YYBTYACC 1714 goto yyerrlab; /* redundant goto avoids 'unused label' warning */ 1715 yyerrlab: 1716 #endif 1717 ++yynerrs; 1718 1719 yyinrecovery: 1720 if (yyerrflag < 3) 1721 { 1722 yyerrflag = 3; 1723 for (;;) 1724 { 1725 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && 1726 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) 1727 { 1728 #if YYDEBUG 1729 if (yydebug) 1730 fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", 1731 YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); 1732 #endif 1733 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 1734 yystate = yytable[yyn]; 1735 *++yystack.s_mark = yytable[yyn]; 1736 *++yystack.l_mark = yylval; 1737 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1738 /* lookahead position is error end position */ 1739 yyerror_loc_range[1] = yylloc; 1740 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ 1741 *++yystack.p_mark = yyloc; 1742 #endif 1743 goto yyloop; 1744 } 1745 else 1746 { 1747 #if YYDEBUG 1748 if (yydebug) 1749 fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", 1750 YYDEBUGSTR, yydepth, *yystack.s_mark); 1751 #endif 1752 if (yystack.s_mark <= yystack.s_base) goto yyabort; 1753 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1754 /* the current TOS position is the error start position */ 1755 yyerror_loc_range[0] = *yystack.p_mark; 1756 #endif 1757 #if defined(YYDESTRUCT_CALL) 1758 #if YYBTYACC 1759 if (!yytrial) 1760 #endif /* YYBTYACC */ 1761 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1762 YYDESTRUCT_CALL("error: discarding state", 1763 yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); 1764 #else 1765 YYDESTRUCT_CALL("error: discarding state", 1766 yystos[*yystack.s_mark], yystack.l_mark); 1767 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 1768 #endif /* defined(YYDESTRUCT_CALL) */ 1769 --yystack.s_mark; 1770 --yystack.l_mark; 1771 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1772 --yystack.p_mark; 1773 #endif 1774 } 1775 } 1776 } 1777 else 1778 { 1779 if (yychar == YYEOF) goto yyabort; 1780 #if YYDEBUG 1781 if (yydebug) 1782 { 1783 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; 1784 fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", 1785 YYDEBUGSTR, yydepth, yystate, yychar, yys); 1786 } 1787 #endif 1788 #if defined(YYDESTRUCT_CALL) 1789 #if YYBTYACC 1790 if (!yytrial) 1791 #endif /* YYBTYACC */ 1792 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1793 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); 1794 #else 1795 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); 1796 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 1797 #endif /* defined(YYDESTRUCT_CALL) */ 1798 yychar = YYEMPTY; 1799 goto yyloop; 1800 } 1801 1802 yyreduce: 1803 yym = yylen[yyn]; 1804 #if YYDEBUG 1805 if (yydebug) 1806 { 1807 fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", 1808 YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); 1809 #ifdef YYSTYPE_TOSTRING 1810 #if YYBTYACC 1811 if (!yytrial) 1812 #endif /* YYBTYACC */ 1813 if (yym > 0) 1814 { 1815 int i; 1816 fputc('<', stderr); 1817 for (i = yym; i > 0; i--) 1818 { 1819 if (i != yym) fputs(", ", stderr); 1820 fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], 1821 yystack.l_mark[1-i]), stderr); 1822 } 1823 fputc('>', stderr); 1824 } 1825 #endif 1826 fputc('\n', stderr); 1827 } 1828 #endif 1829 if (yym > 0) 1830 yyval = yystack.l_mark[1-yym]; 1831 else 1832 memset(&yyval, 0, sizeof yyval); 1833 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1834 1835 /* Perform position reduction */ 1836 memset(&yyloc, 0, sizeof(yyloc)); 1837 #if YYBTYACC 1838 if (!yytrial) 1839 #endif /* YYBTYACC */ 1840 { 1841 YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); 1842 /* just in case YYERROR is invoked within the action, save 1843 the start of the rhs as the error start position */ 1844 yyerror_loc_range[0] = yystack.p_mark[1-yym]; 1845 } 1846 #endif 1847 1848 switch (yyn) 1849 { 1850 case 1: 1851 #line 93 "btyacc_demo.y" 1852 { yyval.scope = yystack.l_mark[0].scope; } 1853 break; 1854 case 2: 1855 #line 94 "btyacc_demo.y" 1856 { yyval.scope = global_scope; } 1857 break; 1858 case 3: 1859 #line 95 "btyacc_demo.y" 1860 { Decl *d = lookup(yystack.l_mark[-2].scope, yystack.l_mark[-1].id); 1861 if (!d || !d->scope) YYERROR; 1862 yyval.scope = d->scope; } 1863 break; 1864 case 4: 1865 #line 101 "btyacc_demo.y" 1866 { Decl *d = lookup(yystack.l_mark[-1].scope, yystack.l_mark[0].id); 1867 if (d == NULL || d->istype() == 0) YYERROR; 1868 yyval.type = d->type; } 1869 break; 1870 case 5: 1871 #line 106 "btyacc_demo.y" 1872 yyval.scope = global_scope = new_scope(0); 1873 break; 1874 case 8: 1875 #line 107 "btyacc_demo.y" 1876 yyval.scope = yystack.l_mark[-1].scope; 1877 break; 1878 case 10: 1879 #line 109 "btyacc_demo.y" 1880 {YYVALID;} 1881 break; 1882 case 11: 1883 #line 110 "btyacc_demo.y" 1884 yyval.scope = start_fn_def(yystack.l_mark[-2].scope, yystack.l_mark[0].decl); 1885 break; 1886 case 12: 1887 if (!yytrial) 1888 #line 111 "btyacc_demo.y" 1889 { /* demonstrate use of @$ & @N, although this is just the 1890 default computation and so is not necessary */ 1891 yyloc.first_line = yystack.p_mark[-3].first_line; 1892 yyloc.first_column = yystack.p_mark[-3].first_column; 1893 yyloc.last_line = yystack.p_mark[0].last_line; 1894 yyloc.last_column = yystack.p_mark[0].last_column; 1895 finish_fn_def(yystack.l_mark[-2].decl, yystack.l_mark[0].code); } 1896 break; 1897 case 13: 1898 #line 121 "btyacc_demo.y" 1899 { yyval.type = yystack.l_mark[0].type; } 1900 break; 1901 case 14: 1902 #line 122 "btyacc_demo.y" 1903 { yyval.type = type_combine(yystack.l_mark[-2].type, yystack.l_mark[0].type); } 1904 break; 1905 case 15: 1906 #line 125 "btyacc_demo.y" 1907 { yyval.type = 0; } 1908 break; 1909 case 16: 1910 #line 126 "btyacc_demo.y" 1911 { yyval.type = type_combine(yystack.l_mark[-1].type, yystack.l_mark[0].type); } 1912 break; 1913 case 17: 1914 #line 130 "btyacc_demo.y" 1915 { yyval.type = yystack.l_mark[0].type; } 1916 break; 1917 case 18: 1918 #line 131 "btyacc_demo.y" 1919 { yyval.type = yystack.l_mark[0].type; } 1920 break; 1921 case 19: 1922 #line 132 "btyacc_demo.y" 1923 { yyval.type = bare_extern(); } 1924 break; 1925 case 20: 1926 #line 133 "btyacc_demo.y" 1927 { yyval.type = bare_register(); } 1928 break; 1929 case 21: 1930 #line 134 "btyacc_demo.y" 1931 { yyval.type = bare_static(); } 1932 break; 1933 case 22: 1934 #line 138 "btyacc_demo.y" 1935 { yyval.type = bare_const(); } 1936 break; 1937 case 23: 1938 #line 139 "btyacc_demo.y" 1939 { yyval.type = bare_volatile(); } 1940 break; 1941 case 24: 1942 #line 143 "btyacc_demo.y" 1943 yyval.scope = yystack.l_mark[-3].scope; 1944 break; 1945 case 25: 1946 #line 143 "btyacc_demo.y" 1947 yyval.type = yystack.l_mark[-3].type; 1948 break; 1949 case 28: 1950 #line 148 "btyacc_demo.y" 1951 { if (!yystack.l_mark[0].type) YYERROR; } if (!yytrial) 1952 #line 149 "btyacc_demo.y" 1953 { yyval.decl = declare(yystack.l_mark[-1].scope, 0, yystack.l_mark[0].type); } 1954 break; 1955 case 29: 1956 if (!yytrial) 1957 #line 150 "btyacc_demo.y" 1958 { yyval.decl = declare(yystack.l_mark[-2].scope, yystack.l_mark[0].id, yystack.l_mark[-1].type); } 1959 break; 1960 case 30: 1961 #line 151 "btyacc_demo.y" 1962 yyval.scope = yystack.l_mark[-2].scope; 1963 break; 1964 case 31: 1965 #line 151 "btyacc_demo.y" 1966 yyval.type = yystack.l_mark[-2].type; 1967 break; 1968 case 32: 1969 if (!yytrial) 1970 #line 151 "btyacc_demo.y" 1971 { yyval.decl = yystack.l_mark[-1].decl; } 1972 break; 1973 case 33: 1974 if (!yytrial) 1975 #line 153 "btyacc_demo.y" 1976 { yyval.decl = make_pointer(yystack.l_mark[0].decl, yystack.l_mark[-3].type); } 1977 break; 1978 case 34: 1979 if (!yytrial) 1980 #line 155 "btyacc_demo.y" 1981 { yyval.decl = make_array(yystack.l_mark[-4].decl->type, yystack.l_mark[-1].expr); } 1982 break; 1983 case 35: 1984 if (!yytrial) 1985 #line 157 "btyacc_demo.y" 1986 { yyval.decl = build_function(yystack.l_mark[-5].decl, yystack.l_mark[-2].dlist, yystack.l_mark[0].type); } 1987 break; 1988 case 36: 1989 if (!yytrial) 1990 #line 160 "btyacc_demo.y" 1991 { yyval.dlist = 0; } 1992 break; 1993 case 37: 1994 if (!yytrial) 1995 #line 161 "btyacc_demo.y" 1996 { yyval.dlist = yystack.l_mark[0].dlist; } 1997 break; 1998 case 38: 1999 if (!yytrial) 2000 #line 164 "btyacc_demo.y" 2001 { yyval.dlist = append_dlist(yystack.l_mark[-3].dlist, yystack.l_mark[0].decl); } 2002 break; 2003 case 39: 2004 if (!yytrial) 2005 #line 165 "btyacc_demo.y" 2006 { yyval.dlist = build_dlist(yystack.l_mark[0].decl); } 2007 break; 2008 case 40: 2009 if (!yytrial) 2010 #line 168 "btyacc_demo.y" 2011 { yyval.decl = yystack.l_mark[0].decl; } 2012 break; 2013 case 41: 2014 if (!yytrial) 2015 #line 172 "btyacc_demo.y" 2016 { yyval.expr = build_expr(yystack.l_mark[-3].expr, ADD, yystack.l_mark[0].expr); } 2017 break; 2018 case 42: 2019 if (!yytrial) 2020 #line 173 "btyacc_demo.y" 2021 { yyval.expr = build_expr(yystack.l_mark[-3].expr, SUB, yystack.l_mark[0].expr); } 2022 break; 2023 case 43: 2024 if (!yytrial) 2025 #line 174 "btyacc_demo.y" 2026 { yyval.expr = build_expr(yystack.l_mark[-3].expr, MUL, yystack.l_mark[0].expr); } 2027 break; 2028 case 44: 2029 if (!yytrial) 2030 #line 175 "btyacc_demo.y" 2031 { yyval.expr = build_expr(yystack.l_mark[-3].expr, MOD, yystack.l_mark[0].expr); } 2032 break; 2033 case 45: 2034 if (!yytrial) 2035 #line 176 "btyacc_demo.y" 2036 { yyval.expr = build_expr(yystack.l_mark[-3].expr, DIV, yystack.l_mark[0].expr); } 2037 break; 2038 case 46: 2039 if (!yytrial) 2040 #line 177 "btyacc_demo.y" 2041 { yyval.expr = build_expr(0, DEREF, yystack.l_mark[0].expr); } 2042 break; 2043 case 47: 2044 if (!yytrial) 2045 #line 178 "btyacc_demo.y" 2046 { yyval.expr = var_expr(yystack.l_mark[-1].scope, yystack.l_mark[0].id); } 2047 break; 2048 case 48: 2049 if (!yytrial) 2050 #line 179 "btyacc_demo.y" 2051 { yyval.expr = yystack.l_mark[0].expr; } 2052 break; 2053 case 49: 2054 if (!yytrial) 2055 #line 183 "btyacc_demo.y" 2056 { yyval.code = 0; } 2057 break; 2058 case 50: 2059 #line 184 "btyacc_demo.y" 2060 {YYVALID;} if (!yytrial) 2061 #line 184 "btyacc_demo.y" 2062 { yyval.code = build_expr_code(yystack.l_mark[-1].expr); } 2063 break; 2064 case 51: 2065 #line 185 "btyacc_demo.y" 2066 yyval.scope = yystack.l_mark[-6].scope; 2067 break; 2068 case 52: 2069 #line 185 "btyacc_demo.y" 2070 yyval.scope = yystack.l_mark[-9].scope; 2071 break; 2072 case 53: 2073 #line 185 "btyacc_demo.y" 2074 {YYVALID;} if (!yytrial) 2075 #line 186 "btyacc_demo.y" 2076 { yyval.code = build_if(yystack.l_mark[-7].expr, yystack.l_mark[-3].code, yystack.l_mark[0].code); } 2077 break; 2078 case 54: 2079 #line 187 "btyacc_demo.y" 2080 {YYVALID;} if (!yytrial) 2081 #line 188 "btyacc_demo.y" 2082 { yyval.code = build_if(yystack.l_mark[-4].expr, yystack.l_mark[0].code, 0); } 2083 break; 2084 case 55: 2085 #line 189 "btyacc_demo.y" 2086 yyval.scope = new_scope(yystack.l_mark[0].scope); 2087 break; 2088 case 56: 2089 #line 189 "btyacc_demo.y" 2090 {YYVALID;} if (!yytrial) 2091 #line 189 "btyacc_demo.y" 2092 { yyval.code = yystack.l_mark[0].code; } 2093 break; 2094 case 57: 2095 if (!yytrial) 2096 #line 192 "btyacc_demo.y" 2097 { yyval.code = 0; } 2098 break; 2099 case 58: 2100 if (!yytrial) 2101 #line 193 "btyacc_demo.y" 2102 { yyval.code = code_append(yystack.l_mark[-2].code, yystack.l_mark[0].code); } 2103 break; 2104 case 59: 2105 if (!yytrial) 2106 #line 197 "btyacc_demo.y" 2107 { yyval.code = yystack.l_mark[-1].code; } 2108 break; 2109 #line 2110 "btyacc_demo.tab.c" 2110 default: 2111 break; 2112 } 2113 yystack.s_mark -= yym; 2114 yystate = *yystack.s_mark; 2115 yystack.l_mark -= yym; 2116 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 2117 yystack.p_mark -= yym; 2118 #endif 2119 yym = yylhs[yyn]; 2120 if (yystate == 0 && yym == 0) 2121 { 2122 #if YYDEBUG 2123 if (yydebug) 2124 { 2125 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); 2126 #ifdef YYSTYPE_TOSTRING 2127 #if YYBTYACC 2128 if (!yytrial) 2129 #endif /* YYBTYACC */ 2130 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); 2131 #endif 2132 fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); 2133 } 2134 #endif 2135 yystate = YYFINAL; 2136 *++yystack.s_mark = YYFINAL; 2137 *++yystack.l_mark = yyval; 2138 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 2139 *++yystack.p_mark = yyloc; 2140 #endif 2141 if (yychar < 0) 2142 { 2143 #if YYBTYACC 2144 do { 2145 if (yylvp < yylve) 2146 { 2147 /* we're currently re-reading tokens */ 2148 yylval = *yylvp++; 2149 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 2150 yylloc = *yylpp++; 2151 #endif 2152 yychar = *yylexp++; 2153 break; 2154 } 2155 if (yyps->save) 2156 { 2157 /* in trial mode; save scanner results for future parse attempts */ 2158 if (yylvp == yylvlim) 2159 { /* Enlarge lexical value queue */ 2160 size_t p = (size_t) (yylvp - yylvals); 2161 size_t s = (size_t) (yylvlim - yylvals); 2162 2163 s += YYLVQUEUEGROWTH; 2164 if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) 2165 goto yyenomem; 2166 if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) 2167 goto yyenomem; 2168 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 2169 if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) 2170 goto yyenomem; 2171 #endif 2172 yylvp = yylve = yylvals + p; 2173 yylvlim = yylvals + s; 2174 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 2175 yylpp = yylpe = yylpsns + p; 2176 yylplim = yylpsns + s; 2177 #endif 2178 yylexp = yylexemes + p; 2179 } 2180 *yylexp = (YYINT) YYLEX; 2181 *yylvp++ = yylval; 2182 yylve++; 2183 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 2184 *yylpp++ = yylloc; 2185 yylpe++; 2186 #endif 2187 yychar = *yylexp++; 2188 break; 2189 } 2190 /* normal operation, no conflict encountered */ 2191 #endif /* YYBTYACC */ 2192 yychar = YYLEX; 2193 #if YYBTYACC 2194 } while (0); 2195 #endif /* YYBTYACC */ 2196 if (yychar < 0) yychar = YYEOF; 2197 #if YYDEBUG 2198 if (yydebug) 2199 { 2200 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; 2201 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", 2202 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); 2203 } 2204 #endif 2205 } 2206 if (yychar == YYEOF) goto yyaccept; 2207 goto yyloop; 2208 } 2209 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && 2210 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) 2211 yystate = yytable[yyn]; 2212 else 2213 yystate = yydgoto[yym]; 2214 #if YYDEBUG 2215 if (yydebug) 2216 { 2217 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); 2218 #ifdef YYSTYPE_TOSTRING 2219 #if YYBTYACC 2220 if (!yytrial) 2221 #endif /* YYBTYACC */ 2222 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); 2223 #endif 2224 fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); 2225 } 2226 #endif 2227 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 2228 *++yystack.s_mark = (YYINT) yystate; 2229 *++yystack.l_mark = yyval; 2230 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 2231 *++yystack.p_mark = yyloc; 2232 #endif 2233 goto yyloop; 2234 #if YYBTYACC 2235 2236 /* Reduction declares that this path is valid. Set yypath and do a full parse */ 2237 yyvalid: 2238 if (yypath) YYABORT; 2239 while (yyps->save) 2240 { 2241 YYParseState *save = yyps->save; 2242 yyps->save = save->save; 2243 save->save = yypath; 2244 yypath = save; 2245 } 2246 #if YYDEBUG 2247 if (yydebug) 2248 fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", 2249 YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); 2250 #endif 2251 if (yyerrctx) 2252 { 2253 yyFreeState(yyerrctx); 2254 yyerrctx = NULL; 2255 } 2256 yylvp = yylvals + yypath->lexeme; 2257 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 2258 yylpp = yylpsns + yypath->lexeme; 2259 #endif 2260 yylexp = yylexemes + yypath->lexeme; 2261 yychar = YYEMPTY; 2262 yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); 2263 memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); 2264 yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); 2265 memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 2266 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 2267 yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); 2268 memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 2269 #endif 2270 yystate = yypath->state; 2271 goto yyloop; 2272 #endif /* YYBTYACC */ 2273 2274 yyoverflow: 2275 YYERROR_CALL("yacc stack overflow"); 2276 #if YYBTYACC 2277 goto yyabort_nomem; 2278 yyenomem: 2279 YYERROR_CALL("memory exhausted"); 2280 yyabort_nomem: 2281 #endif /* YYBTYACC */ 2282 yyresult = 2; 2283 goto yyreturn; 2284 2285 yyabort: 2286 yyresult = 1; 2287 goto yyreturn; 2288 2289 yyaccept: 2290 #if YYBTYACC 2291 if (yyps->save) goto yyvalid; 2292 #endif /* YYBTYACC */ 2293 yyresult = 0; 2294 2295 yyreturn: 2296 #if defined(YYDESTRUCT_CALL) 2297 if (yychar != YYEOF && yychar != YYEMPTY) 2298 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 2299 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); 2300 #else 2301 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); 2302 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 2303 2304 { 2305 YYSTYPE *pv; 2306 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 2307 YYLTYPE *pp; 2308 2309 for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) 2310 YYDESTRUCT_CALL("cleanup: discarding state", 2311 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); 2312 #else 2313 for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) 2314 YYDESTRUCT_CALL("cleanup: discarding state", 2315 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); 2316 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 2317 } 2318 #endif /* defined(YYDESTRUCT_CALL) */ 2319 2320 #if YYBTYACC 2321 if (yyerrctx) 2322 { 2323 yyFreeState(yyerrctx); 2324 yyerrctx = NULL; 2325 } 2326 while (yyps) 2327 { 2328 YYParseState *save = yyps; 2329 yyps = save->save; 2330 save->save = NULL; 2331 yyFreeState(save); 2332 } 2333 while (yypath) 2334 { 2335 YYParseState *save = yypath; 2336 yypath = save->save; 2337 save->save = NULL; 2338 yyFreeState(save); 2339 } 2340 #endif /* YYBTYACC */ 2341 yyfreestack(&yystack); 2342 return (yyresult); 2343 } 2344