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