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