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 1334 #if YYBTYACC 1335 yyps = yyNewState(0); if (yyps == 0) goto yyenomem; 1336 yyps->save = 0; 1337 #endif /* YYBTYACC */ 1338 yym = 0; 1339 yyn = 0; 1340 yynerrs = 0; 1341 yyerrflag = 0; 1342 yychar = YYEMPTY; 1343 yystate = 0; 1344 1345 #if YYPURE 1346 memset(&yystack, 0, sizeof(yystack)); 1347 #endif 1348 1349 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 1350 yystack.s_mark = yystack.s_base; 1351 yystack.l_mark = yystack.l_base; 1352 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1353 yystack.p_mark = yystack.p_base; 1354 #endif 1355 yystate = 0; 1356 *yystack.s_mark = 0; 1357 1358 yyloop: 1359 if ((yyn = yydefred[yystate]) != 0) goto yyreduce; 1360 if (yychar < 0) 1361 { 1362 #if YYBTYACC 1363 do { 1364 if (yylvp < yylve) 1365 { 1366 /* we're currently re-reading tokens */ 1367 yylval = *yylvp++; 1368 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1369 yylloc = *yylpp++; 1370 #endif 1371 yychar = *yylexp++; 1372 break; 1373 } 1374 if (yyps->save) 1375 { 1376 /* in trial mode; save scanner results for future parse attempts */ 1377 if (yylvp == yylvlim) 1378 { /* Enlarge lexical value queue */ 1379 size_t p = (size_t) (yylvp - yylvals); 1380 size_t s = (size_t) (yylvlim - yylvals); 1381 1382 s += YYLVQUEUEGROWTH; 1383 if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; 1384 if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; 1385 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1386 if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; 1387 #endif 1388 yylvp = yylve = yylvals + p; 1389 yylvlim = yylvals + s; 1390 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1391 yylpp = yylpe = yylpsns + p; 1392 yylplim = yylpsns + s; 1393 #endif 1394 yylexp = yylexemes + p; 1395 } 1396 *yylexp = (YYINT) YYLEX; 1397 *yylvp++ = yylval; 1398 yylve++; 1399 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1400 *yylpp++ = yylloc; 1401 yylpe++; 1402 #endif 1403 yychar = *yylexp++; 1404 break; 1405 } 1406 /* normal operation, no conflict encountered */ 1407 #endif /* YYBTYACC */ 1408 yychar = YYLEX; 1409 #if YYBTYACC 1410 } while (0); 1411 #endif /* YYBTYACC */ 1412 if (yychar < 0) yychar = YYEOF; 1413 #if YYDEBUG 1414 if (yydebug) 1415 { 1416 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; 1417 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", 1418 YYDEBUGSTR, yydepth, yystate, yychar, yys); 1419 #ifdef YYSTYPE_TOSTRING 1420 #if YYBTYACC 1421 if (!yytrial) 1422 #endif /* YYBTYACC */ 1423 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); 1424 #endif 1425 fputc('\n', stderr); 1426 } 1427 #endif 1428 } 1429 #if YYBTYACC 1430 1431 /* Do we have a conflict? */ 1432 if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && 1433 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) 1434 { 1435 YYINT ctry; 1436 1437 if (yypath) 1438 { 1439 YYParseState *save; 1440 #if YYDEBUG 1441 if (yydebug) 1442 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", 1443 YYDEBUGSTR, yydepth, yystate); 1444 #endif 1445 /* Switch to the next conflict context */ 1446 save = yypath; 1447 yypath = save->save; 1448 save->save = NULL; 1449 ctry = save->ctry; 1450 if (save->state != yystate) YYABORT; 1451 yyFreeState(save); 1452 1453 } 1454 else 1455 { 1456 1457 /* Unresolved conflict - start/continue trial parse */ 1458 YYParseState *save; 1459 #if YYDEBUG 1460 if (yydebug) 1461 { 1462 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); 1463 if (yyps->save) 1464 fputs("ALREADY in conflict, continuing trial parse.\n", stderr); 1465 else 1466 fputs("Starting trial parse.\n", stderr); 1467 } 1468 #endif 1469 save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); 1470 if (save == NULL) goto yyenomem; 1471 save->save = yyps->save; 1472 save->state = yystate; 1473 save->errflag = yyerrflag; 1474 save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); 1475 memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); 1476 save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); 1477 memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 1478 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1479 save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); 1480 memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 1481 #endif 1482 ctry = yytable[yyn]; 1483 if (yyctable[ctry] == -1) 1484 { 1485 #if YYDEBUG 1486 if (yydebug && yychar >= YYEOF) 1487 fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); 1488 #endif 1489 ctry++; 1490 } 1491 save->ctry = ctry; 1492 if (yyps->save == NULL) 1493 { 1494 /* If this is a first conflict in the stack, start saving lexemes */ 1495 if (!yylexemes) 1496 { 1497 yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); 1498 if (yylexemes == NULL) goto yyenomem; 1499 yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); 1500 if (yylvals == NULL) goto yyenomem; 1501 yylvlim = yylvals + YYLVQUEUEGROWTH; 1502 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1503 yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); 1504 if (yylpsns == NULL) goto yyenomem; 1505 yylplim = yylpsns + YYLVQUEUEGROWTH; 1506 #endif 1507 } 1508 if (yylvp == yylve) 1509 { 1510 yylvp = yylve = yylvals; 1511 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1512 yylpp = yylpe = yylpsns; 1513 #endif 1514 yylexp = yylexemes; 1515 if (yychar >= YYEOF) 1516 { 1517 *yylve++ = yylval; 1518 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1519 *yylpe++ = yylloc; 1520 #endif 1521 *yylexp = (YYINT) yychar; 1522 yychar = YYEMPTY; 1523 } 1524 } 1525 } 1526 if (yychar >= YYEOF) 1527 { 1528 yylvp--; 1529 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1530 yylpp--; 1531 #endif 1532 yylexp--; 1533 yychar = YYEMPTY; 1534 } 1535 save->lexeme = (int) (yylvp - yylvals); 1536 yyps->save = save; 1537 } 1538 if (yytable[yyn] == ctry) 1539 { 1540 #if YYDEBUG 1541 if (yydebug) 1542 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", 1543 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); 1544 #endif 1545 if (yychar < 0) 1546 { 1547 yylvp++; 1548 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1549 yylpp++; 1550 #endif 1551 yylexp++; 1552 } 1553 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) 1554 goto yyoverflow; 1555 yystate = yyctable[ctry]; 1556 *++yystack.s_mark = (YYINT) yystate; 1557 *++yystack.l_mark = yylval; 1558 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1559 *++yystack.p_mark = yylloc; 1560 #endif 1561 yychar = YYEMPTY; 1562 if (yyerrflag > 0) --yyerrflag; 1563 goto yyloop; 1564 } 1565 else 1566 { 1567 yyn = yyctable[ctry]; 1568 goto yyreduce; 1569 } 1570 } /* End of code dealing with conflicts */ 1571 #endif /* YYBTYACC */ 1572 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && 1573 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) 1574 { 1575 #if YYDEBUG 1576 if (yydebug) 1577 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", 1578 YYDEBUGSTR, yydepth, yystate, yytable[yyn]); 1579 #endif 1580 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 1581 yystate = yytable[yyn]; 1582 *++yystack.s_mark = yytable[yyn]; 1583 *++yystack.l_mark = yylval; 1584 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1585 *++yystack.p_mark = yylloc; 1586 #endif 1587 yychar = YYEMPTY; 1588 if (yyerrflag > 0) --yyerrflag; 1589 goto yyloop; 1590 } 1591 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && 1592 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) 1593 { 1594 yyn = yytable[yyn]; 1595 goto yyreduce; 1596 } 1597 if (yyerrflag != 0) goto yyinrecovery; 1598 #if YYBTYACC 1599 1600 yynewerrflag = 1; 1601 goto yyerrhandler; 1602 goto yyerrlab; /* redundant goto avoids 'unused label' warning */ 1603 1604 yyerrlab: 1605 /* explicit YYERROR from an action -- pop the rhs of the rule reduced 1606 * before looking for error recovery */ 1607 yystack.s_mark -= yym; 1608 yystate = *yystack.s_mark; 1609 yystack.l_mark -= yym; 1610 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1611 yystack.p_mark -= yym; 1612 #endif 1613 1614 yynewerrflag = 0; 1615 yyerrhandler: 1616 while (yyps->save) 1617 { 1618 int ctry; 1619 YYParseState *save = yyps->save; 1620 #if YYDEBUG 1621 if (yydebug) 1622 fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", 1623 YYDEBUGSTR, yydepth, yystate, yyps->save->state, 1624 (int)(yylvp - yylvals - yyps->save->lexeme)); 1625 #endif 1626 /* Memorize most forward-looking error state in case it's really an error. */ 1627 if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) 1628 { 1629 /* Free old saved error context state */ 1630 if (yyerrctx) yyFreeState(yyerrctx); 1631 /* Create and fill out new saved error context state */ 1632 yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); 1633 if (yyerrctx == NULL) goto yyenomem; 1634 yyerrctx->save = yyps->save; 1635 yyerrctx->state = yystate; 1636 yyerrctx->errflag = yyerrflag; 1637 yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); 1638 memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); 1639 yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); 1640 memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 1641 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1642 yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); 1643 memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 1644 #endif 1645 yyerrctx->lexeme = (int) (yylvp - yylvals); 1646 } 1647 yylvp = yylvals + save->lexeme; 1648 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1649 yylpp = yylpsns + save->lexeme; 1650 #endif 1651 yylexp = yylexemes + save->lexeme; 1652 yychar = YYEMPTY; 1653 yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); 1654 memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); 1655 yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); 1656 memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 1657 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1658 yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); 1659 memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 1660 #endif 1661 ctry = ++save->ctry; 1662 yystate = save->state; 1663 /* We tried shift, try reduce now */ 1664 if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; 1665 yyps->save = save->save; 1666 save->save = NULL; 1667 yyFreeState(save); 1668 1669 /* Nothing left on the stack -- error */ 1670 if (!yyps->save) 1671 { 1672 #if YYDEBUG 1673 if (yydebug) 1674 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", 1675 YYPREFIX, yydepth); 1676 #endif 1677 /* Restore state as it was in the most forward-advanced error */ 1678 yylvp = yylvals + yyerrctx->lexeme; 1679 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1680 yylpp = yylpsns + yyerrctx->lexeme; 1681 #endif 1682 yylexp = yylexemes + yyerrctx->lexeme; 1683 yychar = yylexp[-1]; 1684 yylval = yylvp[-1]; 1685 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1686 yylloc = yylpp[-1]; 1687 #endif 1688 yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); 1689 memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); 1690 yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); 1691 memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 1692 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1693 yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); 1694 memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 1695 #endif 1696 yystate = yyerrctx->state; 1697 yyFreeState(yyerrctx); 1698 yyerrctx = NULL; 1699 } 1700 yynewerrflag = 1; 1701 } 1702 if (yynewerrflag == 0) goto yyinrecovery; 1703 #endif /* YYBTYACC */ 1704 1705 YYERROR_CALL("syntax error"); 1706 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1707 yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ 1708 #endif 1709 1710 #if !YYBTYACC 1711 goto yyerrlab; /* redundant goto avoids 'unused label' warning */ 1712 yyerrlab: 1713 #endif 1714 ++yynerrs; 1715 1716 yyinrecovery: 1717 if (yyerrflag < 3) 1718 { 1719 yyerrflag = 3; 1720 for (;;) 1721 { 1722 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && 1723 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) 1724 { 1725 #if YYDEBUG 1726 if (yydebug) 1727 fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", 1728 YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); 1729 #endif 1730 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 1731 yystate = yytable[yyn]; 1732 *++yystack.s_mark = yytable[yyn]; 1733 *++yystack.l_mark = yylval; 1734 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1735 /* lookahead position is error end position */ 1736 yyerror_loc_range[1] = yylloc; 1737 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ 1738 *++yystack.p_mark = yyloc; 1739 #endif 1740 goto yyloop; 1741 } 1742 else 1743 { 1744 #if YYDEBUG 1745 if (yydebug) 1746 fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", 1747 YYDEBUGSTR, yydepth, *yystack.s_mark); 1748 #endif 1749 if (yystack.s_mark <= yystack.s_base) goto yyabort; 1750 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1751 /* the current TOS position is the error start position */ 1752 yyerror_loc_range[0] = *yystack.p_mark; 1753 #endif 1754 #if defined(YYDESTRUCT_CALL) 1755 #if YYBTYACC 1756 if (!yytrial) 1757 #endif /* YYBTYACC */ 1758 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1759 YYDESTRUCT_CALL("error: discarding state", 1760 yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); 1761 #else 1762 YYDESTRUCT_CALL("error: discarding state", 1763 yystos[*yystack.s_mark], yystack.l_mark); 1764 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 1765 #endif /* defined(YYDESTRUCT_CALL) */ 1766 --yystack.s_mark; 1767 --yystack.l_mark; 1768 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1769 --yystack.p_mark; 1770 #endif 1771 } 1772 } 1773 } 1774 else 1775 { 1776 if (yychar == YYEOF) goto yyabort; 1777 #if YYDEBUG 1778 if (yydebug) 1779 { 1780 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; 1781 fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", 1782 YYDEBUGSTR, yydepth, yystate, yychar, yys); 1783 } 1784 #endif 1785 #if defined(YYDESTRUCT_CALL) 1786 #if YYBTYACC 1787 if (!yytrial) 1788 #endif /* YYBTYACC */ 1789 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1790 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); 1791 #else 1792 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); 1793 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 1794 #endif /* defined(YYDESTRUCT_CALL) */ 1795 yychar = YYEMPTY; 1796 goto yyloop; 1797 } 1798 1799 yyreduce: 1800 yym = yylen[yyn]; 1801 #if YYDEBUG 1802 if (yydebug) 1803 { 1804 fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", 1805 YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); 1806 #ifdef YYSTYPE_TOSTRING 1807 #if YYBTYACC 1808 if (!yytrial) 1809 #endif /* YYBTYACC */ 1810 if (yym > 0) 1811 { 1812 int i; 1813 fputc('<', stderr); 1814 for (i = yym; i > 0; i--) 1815 { 1816 if (i != yym) fputs(", ", stderr); 1817 fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], 1818 yystack.l_mark[1-i]), stderr); 1819 } 1820 fputc('>', stderr); 1821 } 1822 #endif 1823 fputc('\n', stderr); 1824 } 1825 #endif 1826 if (yym > 0) 1827 yyval = yystack.l_mark[1-yym]; 1828 else 1829 memset(&yyval, 0, sizeof yyval); 1830 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1831 1832 /* Perform position reduction */ 1833 memset(&yyloc, 0, sizeof(yyloc)); 1834 #if YYBTYACC 1835 if (!yytrial) 1836 #endif /* YYBTYACC */ 1837 { 1838 YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); 1839 /* just in case YYERROR is invoked within the action, save 1840 the start of the rhs as the error start position */ 1841 yyerror_loc_range[0] = yystack.p_mark[1-yym]; 1842 } 1843 #endif 1844 1845 switch (yyn) 1846 { 1847 case 1: 1848 #line 93 "btyacc_demo.y" 1849 { yyval.scope = yystack.l_mark[0].scope; } 1850 break; 1851 case 2: 1852 #line 94 "btyacc_demo.y" 1853 { yyval.scope = global_scope; } 1854 break; 1855 case 3: 1856 #line 95 "btyacc_demo.y" 1857 { Decl *d = lookup(yystack.l_mark[-2].scope, yystack.l_mark[-1].id); 1858 if (!d || !d->scope) YYERROR; 1859 yyval.scope = d->scope; } 1860 break; 1861 case 4: 1862 #line 101 "btyacc_demo.y" 1863 { Decl *d = lookup(yystack.l_mark[-1].scope, yystack.l_mark[0].id); 1864 if (d == NULL || d->istype() == 0) YYERROR; 1865 yyval.type = d->type; } 1866 break; 1867 case 5: 1868 #line 106 "btyacc_demo.y" 1869 yyval.scope = global_scope = new_scope(0); 1870 break; 1871 case 8: 1872 #line 107 "btyacc_demo.y" 1873 yyval.scope = yystack.l_mark[-1].scope; 1874 break; 1875 case 10: 1876 #line 109 "btyacc_demo.y" 1877 {YYVALID;} 1878 break; 1879 case 11: 1880 #line 110 "btyacc_demo.y" 1881 yyval.scope = start_fn_def(yystack.l_mark[-2].scope, yystack.l_mark[0].decl); 1882 break; 1883 case 12: 1884 if (!yytrial) 1885 #line 111 "btyacc_demo.y" 1886 { /* demonstrate use of @$ & @N, although this is just the 1887 default computation and so is not necessary */ 1888 yyloc.first_line = yystack.p_mark[-3].first_line; 1889 yyloc.first_column = yystack.p_mark[-3].first_column; 1890 yyloc.last_line = yystack.p_mark[0].last_line; 1891 yyloc.last_column = yystack.p_mark[0].last_column; 1892 finish_fn_def(yystack.l_mark[-2].decl, yystack.l_mark[0].code); } 1893 break; 1894 case 13: 1895 #line 121 "btyacc_demo.y" 1896 { yyval.type = yystack.l_mark[0].type; } 1897 break; 1898 case 14: 1899 #line 122 "btyacc_demo.y" 1900 { yyval.type = type_combine(yystack.l_mark[-2].type, yystack.l_mark[0].type); } 1901 break; 1902 case 15: 1903 #line 125 "btyacc_demo.y" 1904 { yyval.type = 0; } 1905 break; 1906 case 16: 1907 #line 126 "btyacc_demo.y" 1908 { yyval.type = type_combine(yystack.l_mark[-1].type, yystack.l_mark[0].type); } 1909 break; 1910 case 17: 1911 #line 130 "btyacc_demo.y" 1912 { yyval.type = yystack.l_mark[0].type; } 1913 break; 1914 case 18: 1915 #line 131 "btyacc_demo.y" 1916 { yyval.type = yystack.l_mark[0].type; } 1917 break; 1918 case 19: 1919 #line 132 "btyacc_demo.y" 1920 { yyval.type = bare_extern(); } 1921 break; 1922 case 20: 1923 #line 133 "btyacc_demo.y" 1924 { yyval.type = bare_register(); } 1925 break; 1926 case 21: 1927 #line 134 "btyacc_demo.y" 1928 { yyval.type = bare_static(); } 1929 break; 1930 case 22: 1931 #line 138 "btyacc_demo.y" 1932 { yyval.type = bare_const(); } 1933 break; 1934 case 23: 1935 #line 139 "btyacc_demo.y" 1936 { yyval.type = bare_volatile(); } 1937 break; 1938 case 24: 1939 #line 143 "btyacc_demo.y" 1940 yyval.scope = yystack.l_mark[-3].scope; 1941 break; 1942 case 25: 1943 #line 143 "btyacc_demo.y" 1944 yyval.type = yystack.l_mark[-3].type; 1945 break; 1946 case 28: 1947 #line 148 "btyacc_demo.y" 1948 { if (!yystack.l_mark[0].type) YYERROR; } if (!yytrial) 1949 #line 149 "btyacc_demo.y" 1950 { yyval.decl = declare(yystack.l_mark[-1].scope, 0, yystack.l_mark[0].type); } 1951 break; 1952 case 29: 1953 if (!yytrial) 1954 #line 150 "btyacc_demo.y" 1955 { yyval.decl = declare(yystack.l_mark[-2].scope, yystack.l_mark[0].id, yystack.l_mark[-1].type); } 1956 break; 1957 case 30: 1958 #line 151 "btyacc_demo.y" 1959 yyval.scope = yystack.l_mark[-2].scope; 1960 break; 1961 case 31: 1962 #line 151 "btyacc_demo.y" 1963 yyval.type = yystack.l_mark[-2].type; 1964 break; 1965 case 32: 1966 if (!yytrial) 1967 #line 151 "btyacc_demo.y" 1968 { yyval.decl = yystack.l_mark[-1].decl; } 1969 break; 1970 case 33: 1971 if (!yytrial) 1972 #line 153 "btyacc_demo.y" 1973 { yyval.decl = make_pointer(yystack.l_mark[0].decl, yystack.l_mark[-3].type); } 1974 break; 1975 case 34: 1976 if (!yytrial) 1977 #line 155 "btyacc_demo.y" 1978 { yyval.decl = make_array(yystack.l_mark[-4].decl->type, yystack.l_mark[-1].expr); } 1979 break; 1980 case 35: 1981 if (!yytrial) 1982 #line 157 "btyacc_demo.y" 1983 { yyval.decl = build_function(yystack.l_mark[-5].decl, yystack.l_mark[-2].dlist, yystack.l_mark[0].type); } 1984 break; 1985 case 36: 1986 if (!yytrial) 1987 #line 160 "btyacc_demo.y" 1988 { yyval.dlist = 0; } 1989 break; 1990 case 37: 1991 if (!yytrial) 1992 #line 161 "btyacc_demo.y" 1993 { yyval.dlist = yystack.l_mark[0].dlist; } 1994 break; 1995 case 38: 1996 if (!yytrial) 1997 #line 164 "btyacc_demo.y" 1998 { yyval.dlist = append_dlist(yystack.l_mark[-3].dlist, yystack.l_mark[0].decl); } 1999 break; 2000 case 39: 2001 if (!yytrial) 2002 #line 165 "btyacc_demo.y" 2003 { yyval.dlist = build_dlist(yystack.l_mark[0].decl); } 2004 break; 2005 case 40: 2006 if (!yytrial) 2007 #line 168 "btyacc_demo.y" 2008 { yyval.decl = yystack.l_mark[0].decl; } 2009 break; 2010 case 41: 2011 if (!yytrial) 2012 #line 172 "btyacc_demo.y" 2013 { yyval.expr = build_expr(yystack.l_mark[-3].expr, ADD, yystack.l_mark[0].expr); } 2014 break; 2015 case 42: 2016 if (!yytrial) 2017 #line 173 "btyacc_demo.y" 2018 { yyval.expr = build_expr(yystack.l_mark[-3].expr, SUB, yystack.l_mark[0].expr); } 2019 break; 2020 case 43: 2021 if (!yytrial) 2022 #line 174 "btyacc_demo.y" 2023 { yyval.expr = build_expr(yystack.l_mark[-3].expr, MUL, yystack.l_mark[0].expr); } 2024 break; 2025 case 44: 2026 if (!yytrial) 2027 #line 175 "btyacc_demo.y" 2028 { yyval.expr = build_expr(yystack.l_mark[-3].expr, MOD, yystack.l_mark[0].expr); } 2029 break; 2030 case 45: 2031 if (!yytrial) 2032 #line 176 "btyacc_demo.y" 2033 { yyval.expr = build_expr(yystack.l_mark[-3].expr, DIV, yystack.l_mark[0].expr); } 2034 break; 2035 case 46: 2036 if (!yytrial) 2037 #line 177 "btyacc_demo.y" 2038 { yyval.expr = build_expr(0, DEREF, yystack.l_mark[0].expr); } 2039 break; 2040 case 47: 2041 if (!yytrial) 2042 #line 178 "btyacc_demo.y" 2043 { yyval.expr = var_expr(yystack.l_mark[-1].scope, yystack.l_mark[0].id); } 2044 break; 2045 case 48: 2046 if (!yytrial) 2047 #line 179 "btyacc_demo.y" 2048 { yyval.expr = yystack.l_mark[0].expr; } 2049 break; 2050 case 49: 2051 if (!yytrial) 2052 #line 183 "btyacc_demo.y" 2053 { yyval.code = 0; } 2054 break; 2055 case 50: 2056 #line 184 "btyacc_demo.y" 2057 {YYVALID;} if (!yytrial) 2058 #line 184 "btyacc_demo.y" 2059 { yyval.code = build_expr_code(yystack.l_mark[-1].expr); } 2060 break; 2061 case 51: 2062 #line 185 "btyacc_demo.y" 2063 yyval.scope = yystack.l_mark[-6].scope; 2064 break; 2065 case 52: 2066 #line 185 "btyacc_demo.y" 2067 yyval.scope = yystack.l_mark[-9].scope; 2068 break; 2069 case 53: 2070 #line 185 "btyacc_demo.y" 2071 {YYVALID;} if (!yytrial) 2072 #line 186 "btyacc_demo.y" 2073 { yyval.code = build_if(yystack.l_mark[-7].expr, yystack.l_mark[-3].code, yystack.l_mark[0].code); } 2074 break; 2075 case 54: 2076 #line 187 "btyacc_demo.y" 2077 {YYVALID;} if (!yytrial) 2078 #line 188 "btyacc_demo.y" 2079 { yyval.code = build_if(yystack.l_mark[-4].expr, yystack.l_mark[0].code, 0); } 2080 break; 2081 case 55: 2082 #line 189 "btyacc_demo.y" 2083 yyval.scope = new_scope(yystack.l_mark[0].scope); 2084 break; 2085 case 56: 2086 #line 189 "btyacc_demo.y" 2087 {YYVALID;} if (!yytrial) 2088 #line 189 "btyacc_demo.y" 2089 { yyval.code = yystack.l_mark[0].code; } 2090 break; 2091 case 57: 2092 if (!yytrial) 2093 #line 192 "btyacc_demo.y" 2094 { yyval.code = 0; } 2095 break; 2096 case 58: 2097 if (!yytrial) 2098 #line 193 "btyacc_demo.y" 2099 { yyval.code = code_append(yystack.l_mark[-2].code, yystack.l_mark[0].code); } 2100 break; 2101 case 59: 2102 if (!yytrial) 2103 #line 197 "btyacc_demo.y" 2104 { yyval.code = yystack.l_mark[-1].code; } 2105 break; 2106 #line 2107 "btyacc_demo.tab.c" 2107 default: 2108 break; 2109 } 2110 yystack.s_mark -= yym; 2111 yystate = *yystack.s_mark; 2112 yystack.l_mark -= yym; 2113 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 2114 yystack.p_mark -= yym; 2115 #endif 2116 yym = yylhs[yyn]; 2117 if (yystate == 0 && yym == 0) 2118 { 2119 #if YYDEBUG 2120 if (yydebug) 2121 { 2122 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); 2123 #ifdef YYSTYPE_TOSTRING 2124 #if YYBTYACC 2125 if (!yytrial) 2126 #endif /* YYBTYACC */ 2127 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); 2128 #endif 2129 fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); 2130 } 2131 #endif 2132 yystate = YYFINAL; 2133 *++yystack.s_mark = YYFINAL; 2134 *++yystack.l_mark = yyval; 2135 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 2136 *++yystack.p_mark = yyloc; 2137 #endif 2138 if (yychar < 0) 2139 { 2140 #if YYBTYACC 2141 do { 2142 if (yylvp < yylve) 2143 { 2144 /* we're currently re-reading tokens */ 2145 yylval = *yylvp++; 2146 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 2147 yylloc = *yylpp++; 2148 #endif 2149 yychar = *yylexp++; 2150 break; 2151 } 2152 if (yyps->save) 2153 { 2154 /* in trial mode; save scanner results for future parse attempts */ 2155 if (yylvp == yylvlim) 2156 { /* Enlarge lexical value queue */ 2157 size_t p = (size_t) (yylvp - yylvals); 2158 size_t s = (size_t) (yylvlim - yylvals); 2159 2160 s += YYLVQUEUEGROWTH; 2161 if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) 2162 goto yyenomem; 2163 if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) 2164 goto yyenomem; 2165 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 2166 if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) 2167 goto yyenomem; 2168 #endif 2169 yylvp = yylve = yylvals + p; 2170 yylvlim = yylvals + s; 2171 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 2172 yylpp = yylpe = yylpsns + p; 2173 yylplim = yylpsns + s; 2174 #endif 2175 yylexp = yylexemes + p; 2176 } 2177 *yylexp = (YYINT) YYLEX; 2178 *yylvp++ = yylval; 2179 yylve++; 2180 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 2181 *yylpp++ = yylloc; 2182 yylpe++; 2183 #endif 2184 yychar = *yylexp++; 2185 break; 2186 } 2187 /* normal operation, no conflict encountered */ 2188 #endif /* YYBTYACC */ 2189 yychar = YYLEX; 2190 #if YYBTYACC 2191 } while (0); 2192 #endif /* YYBTYACC */ 2193 if (yychar < 0) yychar = YYEOF; 2194 #if YYDEBUG 2195 if (yydebug) 2196 { 2197 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; 2198 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", 2199 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); 2200 } 2201 #endif 2202 } 2203 if (yychar == YYEOF) goto yyaccept; 2204 goto yyloop; 2205 } 2206 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && 2207 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) 2208 yystate = yytable[yyn]; 2209 else 2210 yystate = yydgoto[yym]; 2211 #if YYDEBUG 2212 if (yydebug) 2213 { 2214 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); 2215 #ifdef YYSTYPE_TOSTRING 2216 #if YYBTYACC 2217 if (!yytrial) 2218 #endif /* YYBTYACC */ 2219 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); 2220 #endif 2221 fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); 2222 } 2223 #endif 2224 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 2225 *++yystack.s_mark = (YYINT) yystate; 2226 *++yystack.l_mark = yyval; 2227 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 2228 *++yystack.p_mark = yyloc; 2229 #endif 2230 goto yyloop; 2231 #if YYBTYACC 2232 2233 /* Reduction declares that this path is valid. Set yypath and do a full parse */ 2234 yyvalid: 2235 if (yypath) YYABORT; 2236 while (yyps->save) 2237 { 2238 YYParseState *save = yyps->save; 2239 yyps->save = save->save; 2240 save->save = yypath; 2241 yypath = save; 2242 } 2243 #if YYDEBUG 2244 if (yydebug) 2245 fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", 2246 YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); 2247 #endif 2248 if (yyerrctx) 2249 { 2250 yyFreeState(yyerrctx); 2251 yyerrctx = NULL; 2252 } 2253 yylvp = yylvals + yypath->lexeme; 2254 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 2255 yylpp = yylpsns + yypath->lexeme; 2256 #endif 2257 yylexp = yylexemes + yypath->lexeme; 2258 yychar = YYEMPTY; 2259 yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); 2260 memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); 2261 yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); 2262 memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 2263 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 2264 yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); 2265 memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 2266 #endif 2267 yystate = yypath->state; 2268 goto yyloop; 2269 #endif /* YYBTYACC */ 2270 2271 yyoverflow: 2272 YYERROR_CALL("yacc stack overflow"); 2273 #if YYBTYACC 2274 goto yyabort_nomem; 2275 yyenomem: 2276 YYERROR_CALL("memory exhausted"); 2277 yyabort_nomem: 2278 #endif /* YYBTYACC */ 2279 yyresult = 2; 2280 goto yyreturn; 2281 2282 yyabort: 2283 yyresult = 1; 2284 goto yyreturn; 2285 2286 yyaccept: 2287 #if YYBTYACC 2288 if (yyps->save) goto yyvalid; 2289 #endif /* YYBTYACC */ 2290 yyresult = 0; 2291 2292 yyreturn: 2293 #if defined(YYDESTRUCT_CALL) 2294 if (yychar != YYEOF && yychar != YYEMPTY) 2295 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 2296 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); 2297 #else 2298 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); 2299 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 2300 2301 { 2302 YYSTYPE *pv; 2303 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 2304 YYLTYPE *pp; 2305 2306 for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) 2307 YYDESTRUCT_CALL("cleanup: discarding state", 2308 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); 2309 #else 2310 for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) 2311 YYDESTRUCT_CALL("cleanup: discarding state", 2312 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); 2313 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 2314 } 2315 #endif /* defined(YYDESTRUCT_CALL) */ 2316 2317 #if YYBTYACC 2318 if (yyerrctx) 2319 { 2320 yyFreeState(yyerrctx); 2321 yyerrctx = NULL; 2322 } 2323 while (yyps) 2324 { 2325 YYParseState *save = yyps; 2326 yyps = save->save; 2327 save->save = NULL; 2328 yyFreeState(save); 2329 } 2330 while (yypath) 2331 { 2332 YYParseState *save = yypath; 2333 yypath = save->save; 2334 save->save = NULL; 2335 yyFreeState(save); 2336 } 2337 #endif /* YYBTYACC */ 2338 yyfreestack(&yystack); 2339 return (yyresult); 2340 } 2341