1/* $NetBSD: calc_code_provides.tab.c,v 1.1.1.1 2021/02/20 20:30:11 christos Exp $ */ 2 3/* original parser id follows */ 4/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ 5/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ 6 7#define YYBYACC 1 8#define YYMAJOR 2 9#define YYMINOR 0 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 0 20#define YYDEBUGSTR YYPREFIX "debug" 21 22#ifndef yyparse 23#define yyparse calc_code_provides_parse 24#endif /* yyparse */ 25 26#ifndef yylex 27#define yylex calc_code_provides_lex 28#endif /* yylex */ 29 30#ifndef yyerror 31#define yyerror calc_code_provides_error 32#endif /* yyerror */ 33 34#ifndef yychar 35#define yychar calc_code_provides_char 36#endif /* yychar */ 37 38#ifndef yyval 39#define yyval calc_code_provides_val 40#endif /* yyval */ 41 42#ifndef yylval 43#define yylval calc_code_provides_lval 44#endif /* yylval */ 45 46#ifndef yydebug 47#define yydebug calc_code_provides_debug 48#endif /* yydebug */ 49 50#ifndef yynerrs 51#define yynerrs calc_code_provides_nerrs 52#endif /* yynerrs */ 53 54#ifndef yyerrflag 55#define yyerrflag calc_code_provides_errflag 56#endif /* yyerrflag */ 57 58#ifndef yylhs 59#define yylhs calc_code_provides_lhs 60#endif /* yylhs */ 61 62#ifndef yylen 63#define yylen calc_code_provides_len 64#endif /* yylen */ 65 66#ifndef yydefred 67#define yydefred calc_code_provides_defred 68#endif /* yydefred */ 69 70#ifndef yystos 71#define yystos calc_code_provides_stos 72#endif /* yystos */ 73 74#ifndef yydgoto 75#define yydgoto calc_code_provides_dgoto 76#endif /* yydgoto */ 77 78#ifndef yysindex 79#define yysindex calc_code_provides_sindex 80#endif /* yysindex */ 81 82#ifndef yyrindex 83#define yyrindex calc_code_provides_rindex 84#endif /* yyrindex */ 85 86#ifndef yygindex 87#define yygindex calc_code_provides_gindex 88#endif /* yygindex */ 89 90#ifndef yytable 91#define yytable calc_code_provides_table 92#endif /* yytable */ 93 94#ifndef yycheck 95#define yycheck calc_code_provides_check 96#endif /* yycheck */ 97 98#ifndef yyname 99#define yyname calc_code_provides_name 100#endif /* yyname */ 101 102#ifndef yyrule 103#define yyrule calc_code_provides_rule 104#endif /* yyrule */ 105 106#if YYBTYACC 107 108#ifndef yycindex 109#define yycindex calc_code_provides_cindex 110#endif /* yycindex */ 111 112#ifndef yyctable 113#define yyctable calc_code_provides_ctable 114#endif /* yyctable */ 115 116#endif /* YYBTYACC */ 117 118#define YYPREFIX "calc_code_provides_" 119 120#define YYPURE 0 121 122#line 5 "calc_code_provides.y" 123# include <stdio.h> 124# include <ctype.h> 125 126int regs[26]; 127int base; 128 129extern int yylex(void); 130static void yyerror(const char *s); 131 132#line 131 "calc_code_provides.tab.c" 133 134#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) 135/* Default: YYSTYPE is the semantic value type. */ 136typedef int YYSTYPE; 137# define YYSTYPE_IS_DECLARED 1 138#endif 139 140/* compatibility with bison */ 141#ifdef YYPARSE_PARAM 142/* compatibility with FreeBSD */ 143# ifdef YYPARSE_PARAM_TYPE 144# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) 145# else 146# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) 147# endif 148#else 149# define YYPARSE_DECL() yyparse(void) 150#endif 151 152/* Parameters sent to lex. */ 153#ifdef YYLEX_PARAM 154# define YYLEX_DECL() yylex(void *YYLEX_PARAM) 155# define YYLEX yylex(YYLEX_PARAM) 156#else 157# define YYLEX_DECL() yylex(void) 158# define YYLEX yylex() 159#endif 160 161/* Parameters sent to yyerror. */ 162#ifndef YYERROR_DECL 163#define YYERROR_DECL() yyerror(const char *s) 164#endif 165#ifndef YYERROR_CALL 166#define YYERROR_CALL(msg) yyerror(msg) 167#endif 168 169extern int YYPARSE_DECL(); 170 171#define DIGIT 257 172#define LETTER 258 173#define UMINUS 259 174#define YYERRCODE 256 175typedef short YYINT; 176static const YYINT calc_code_provides_lhs[] = { -1, 177 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, 178 2, 2, 2, 2, 2, 2, 3, 3, 179}; 180static const YYINT calc_code_provides_len[] = { 2, 181 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, 182 3, 3, 3, 2, 1, 1, 1, 2, 183}; 184static const YYINT calc_code_provides_defred[] = { 1, 185 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, 186 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, 187 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, 188 10, 11, 189}; 190#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) 191static const YYINT calc_code_provides_stos[] = { 0, 192 261, 256, 257, 258, 45, 40, 262, 263, 264, 10, 193 61, 258, 263, 263, 10, 124, 38, 43, 45, 42, 194 47, 37, 257, 263, 41, 263, 263, 263, 263, 263, 195 263, 263, 196}; 197#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ 198static const YYINT calc_code_provides_dgoto[] = { 1, 199 7, 8, 9, 200}; 201static const YYINT calc_code_provides_sindex[] = { 0, 202 -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, 203 -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, 204 -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, 205 0, 0, 206}; 207static const YYINT calc_code_provides_rindex[] = { 0, 208 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, 209 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 210 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, 211 0, 0, 212}; 213#if YYBTYACC 214static const YYINT calc_code_provides_cindex[] = { 0, 215 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 216 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 217 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 218 0, 0, 219}; 220#endif 221static const YYINT calc_code_provides_gindex[] = { 0, 222 0, 65, 0, 223}; 224#define YYTABLESIZE 220 225static const YYINT calc_code_provides_table[] = { 6, 226 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, 227 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, 228 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, 229 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, 230 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, 231 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, 232 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, 233 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, 234 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, 235 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, 236 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, 237 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, 238 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, 239 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, 240 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 241 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 242 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 243 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 244 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 245 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 246 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 247 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, 248}; 249static const YYINT calc_code_provides_check[] = { 40, 250 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, 251 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, 252 -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, 253 -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, 254 -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, 255 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, 256 -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, 257 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, 258 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, 259 -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, 260 -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, 261 -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, 262 -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, 263 -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, 264 -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, 265 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 266 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 267 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 268 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 269 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 270 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 271 -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, 272}; 273#if YYBTYACC 274static const YYINT calc_code_provides_ctable[] = { -1, 275 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 276 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 277 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 278 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 279 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 280 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 281 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 282 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 283 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 284 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 285 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 286 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 287 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 288 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 289 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 290 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 291 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 292 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 293 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 294 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 295 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 296 -1, -1, -1, -1, -1, -1, -1, -1, -1, 297}; 298#endif 299#define YYFINAL 1 300#ifndef YYDEBUG 301#define YYDEBUG 0 302#endif 303#define YYMAXTOKEN 259 304#define YYUNDFTOKEN 265 305#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) 306#if YYDEBUG 307static const char *const calc_code_provides_name[] = { 308 309"$end",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 3100,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0, 3110,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 3120,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,0,0,0, 3130,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 3140,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 3150,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 3160,0,"error","DIGIT","LETTER","UMINUS","$accept","list","stat","expr","number", 317"illegal-symbol", 318}; 319static const char *const calc_code_provides_rule[] = { 320"$accept : list", 321"list :", 322"list : list stat '\\n'", 323"list : list error '\\n'", 324"stat : expr", 325"stat : LETTER '=' expr", 326"expr : '(' expr ')'", 327"expr : expr '+' expr", 328"expr : expr '-' expr", 329"expr : expr '*' expr", 330"expr : expr '/' expr", 331"expr : expr '%' expr", 332"expr : expr '&' expr", 333"expr : expr '|' expr", 334"expr : '-' expr", 335"expr : LETTER", 336"expr : number", 337"number : DIGIT", 338"number : number DIGIT", 339 340}; 341#endif 342 343#if YYDEBUG 344int yydebug; 345#endif 346 347int yyerrflag; 348int yychar; 349YYSTYPE yyval; 350YYSTYPE yylval; 351int yynerrs; 352 353#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 354YYLTYPE yyloc; /* position returned by actions */ 355YYLTYPE yylloc; /* position from the lexer */ 356#endif 357 358#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 359#ifndef YYLLOC_DEFAULT 360#define YYLLOC_DEFAULT(loc, rhs, n) \ 361do \ 362{ \ 363 if (n == 0) \ 364 { \ 365 (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ 366 (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ 367 (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ 368 (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ 369 } \ 370 else \ 371 { \ 372 (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ 373 (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ 374 (loc).last_line = YYRHSLOC(rhs, n).last_line; \ 375 (loc).last_column = YYRHSLOC(rhs, n).last_column; \ 376 } \ 377} while (0) 378#endif /* YYLLOC_DEFAULT */ 379#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 380#if YYBTYACC 381 382#ifndef YYLVQUEUEGROWTH 383#define YYLVQUEUEGROWTH 32 384#endif 385#endif /* YYBTYACC */ 386 387/* define the initial stack-sizes */ 388#ifdef YYSTACKSIZE 389#undef YYMAXDEPTH 390#define YYMAXDEPTH YYSTACKSIZE 391#else 392#ifdef YYMAXDEPTH 393#define YYSTACKSIZE YYMAXDEPTH 394#else 395#define YYSTACKSIZE 10000 396#define YYMAXDEPTH 10000 397#endif 398#endif 399 400#ifndef YYINITSTACKSIZE 401#define YYINITSTACKSIZE 200 402#endif 403 404typedef struct { 405 unsigned stacksize; 406 YYINT *s_base; 407 YYINT *s_mark; 408 YYINT *s_last; 409 YYSTYPE *l_base; 410 YYSTYPE *l_mark; 411#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 412 YYLTYPE *p_base; 413 YYLTYPE *p_mark; 414#endif 415} YYSTACKDATA; 416#if YYBTYACC 417 418struct YYParseState_s 419{ 420 struct YYParseState_s *save; /* Previously saved parser state */ 421 YYSTACKDATA yystack; /* saved parser stack */ 422 int state; /* saved parser state */ 423 int errflag; /* saved error recovery status */ 424 int lexeme; /* saved index of the conflict lexeme in the lexical queue */ 425 YYINT ctry; /* saved index in yyctable[] for this conflict */ 426}; 427typedef struct YYParseState_s YYParseState; 428#endif /* YYBTYACC */ 429/* variables for the parser stack */ 430static YYSTACKDATA yystack; 431#if YYBTYACC 432 433/* Current parser state */ 434static YYParseState *yyps = 0; 435 436/* yypath != NULL: do the full parse, starting at *yypath parser state. */ 437static YYParseState *yypath = 0; 438 439/* Base of the lexical value queue */ 440static YYSTYPE *yylvals = 0; 441 442/* Current position at lexical value queue */ 443static YYSTYPE *yylvp = 0; 444 445/* End position of lexical value queue */ 446static YYSTYPE *yylve = 0; 447 448/* The last allocated position at the lexical value queue */ 449static YYSTYPE *yylvlim = 0; 450 451#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 452/* Base of the lexical position queue */ 453static YYLTYPE *yylpsns = 0; 454 455/* Current position at lexical position queue */ 456static YYLTYPE *yylpp = 0; 457 458/* End position of lexical position queue */ 459static YYLTYPE *yylpe = 0; 460 461/* The last allocated position at the lexical position queue */ 462static YYLTYPE *yylplim = 0; 463#endif 464 465/* Current position at lexical token queue */ 466static YYINT *yylexp = 0; 467 468static YYINT *yylexemes = 0; 469#endif /* YYBTYACC */ 470 471/* %code "provides" block start */ 472#line 1 "calc_code_provides.y" 473/* CODE-PROVIDES */ 474#line 2 "calc_code_provides.y" 475/* CODE-PROVIDES2 */ 476/* %code "provides" block end */ 477#line 476 "calc_code_provides.tab.c" 478#line 69 "calc_code_provides.y" 479 /* start of programs */ 480 481int 482main (void) 483{ 484 while(!feof(stdin)) { 485 yyparse(); 486 } 487 return 0; 488} 489 490static void 491yyerror(const char *s) 492{ 493 fprintf(stderr, "%s\n", s); 494} 495 496int 497yylex(void) 498{ 499 /* lexical analysis routine */ 500 /* returns LETTER for a lower case letter, yylval = 0 through 25 */ 501 /* return DIGIT for a digit, yylval = 0 through 9 */ 502 /* all other characters are returned immediately */ 503 504 int c; 505 506 while( (c=getchar()) == ' ' ) { /* skip blanks */ } 507 508 /* c is now nonblank */ 509 510 if( islower( c )) { 511 yylval = c - 'a'; 512 return ( LETTER ); 513 } 514 if( isdigit( c )) { 515 yylval = c - '0'; 516 return ( DIGIT ); 517 } 518 return( c ); 519} 520#line 519 "calc_code_provides.tab.c" 521 522/* For use in generated program */ 523#define yydepth (int)(yystack.s_mark - yystack.s_base) 524#if YYBTYACC 525#define yytrial (yyps->save) 526#endif /* YYBTYACC */ 527 528#if YYDEBUG 529#include <stdio.h> /* needed for printf */ 530#endif 531 532#include <stdlib.h> /* needed for malloc, etc */ 533#include <string.h> /* needed for memset */ 534 535/* allocate initial stack or double stack size, up to YYMAXDEPTH */ 536static int yygrowstack(YYSTACKDATA *data) 537{ 538 int i; 539 unsigned newsize; 540 YYINT *newss; 541 YYSTYPE *newvs; 542#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 543 YYLTYPE *newps; 544#endif 545 546 if ((newsize = data->stacksize) == 0) 547 newsize = YYINITSTACKSIZE; 548 else if (newsize >= YYMAXDEPTH) 549 return YYENOMEM; 550 else if ((newsize *= 2) > YYMAXDEPTH) 551 newsize = YYMAXDEPTH; 552 553 i = (int) (data->s_mark - data->s_base); 554 newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); 555 if (newss == 0) 556 return YYENOMEM; 557 558 data->s_base = newss; 559 data->s_mark = newss + i; 560 561 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); 562 if (newvs == 0) 563 return YYENOMEM; 564 565 data->l_base = newvs; 566 data->l_mark = newvs + i; 567 568#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 569 newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); 570 if (newps == 0) 571 return YYENOMEM; 572 573 data->p_base = newps; 574 data->p_mark = newps + i; 575#endif 576 577 data->stacksize = newsize; 578 data->s_last = data->s_base + newsize - 1; 579 580#if YYDEBUG 581 if (yydebug) 582 fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); 583#endif 584 return 0; 585} 586 587#if YYPURE || defined(YY_NO_LEAKS) 588static void yyfreestack(YYSTACKDATA *data) 589{ 590 free(data->s_base); 591 free(data->l_base); 592#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 593 free(data->p_base); 594#endif 595 memset(data, 0, sizeof(*data)); 596} 597#else 598#define yyfreestack(data) /* nothing */ 599#endif /* YYPURE || defined(YY_NO_LEAKS) */ 600#if YYBTYACC 601 602static YYParseState * 603yyNewState(unsigned size) 604{ 605 YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); 606 if (p == NULL) return NULL; 607 608 p->yystack.stacksize = size; 609 if (size == 0) 610 { 611 p->yystack.s_base = NULL; 612 p->yystack.l_base = NULL; 613#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 614 p->yystack.p_base = NULL; 615#endif 616 return p; 617 } 618 p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); 619 if (p->yystack.s_base == NULL) return NULL; 620 p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); 621 if (p->yystack.l_base == NULL) return NULL; 622 memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); 623#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 624 p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); 625 if (p->yystack.p_base == NULL) return NULL; 626 memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); 627#endif 628 629 return p; 630} 631 632static void 633yyFreeState(YYParseState *p) 634{ 635 yyfreestack(&p->yystack); 636 free(p); 637} 638#endif /* YYBTYACC */ 639 640#define YYABORT goto yyabort 641#define YYREJECT goto yyabort 642#define YYACCEPT goto yyaccept 643#define YYERROR goto yyerrlab 644#if YYBTYACC 645#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) 646#define YYVALID_NESTED do { if (yyps->save && \ 647 yyps->save->save == 0) goto yyvalid; } while(0) 648#endif /* YYBTYACC */ 649 650int 651YYPARSE_DECL() 652{ 653 int yym, yyn, yystate, yyresult; 654#if YYBTYACC 655 int yynewerrflag; 656 YYParseState *yyerrctx = NULL; 657#endif /* YYBTYACC */ 658#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 659 YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ 660#endif 661#if YYDEBUG 662 const char *yys; 663 664 if ((yys = getenv("YYDEBUG")) != 0) 665 { 666 yyn = *yys; 667 if (yyn >= '0' && yyn <= '9') 668 yydebug = yyn - '0'; 669 } 670 if (yydebug) 671 fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); 672#endif 673#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 674 memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); 675#endif 676 677#if YYBTYACC 678 yyps = yyNewState(0); if (yyps == 0) goto yyenomem; 679 yyps->save = 0; 680#endif /* YYBTYACC */ 681 yym = 0; 682 yyn = 0; 683 yynerrs = 0; 684 yyerrflag = 0; 685 yychar = YYEMPTY; 686 yystate = 0; 687 688#if YYPURE 689 memset(&yystack, 0, sizeof(yystack)); 690#endif 691 692 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 693 yystack.s_mark = yystack.s_base; 694 yystack.l_mark = yystack.l_base; 695#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 696 yystack.p_mark = yystack.p_base; 697#endif 698 yystate = 0; 699 *yystack.s_mark = 0; 700 701yyloop: 702 if ((yyn = yydefred[yystate]) != 0) goto yyreduce; 703 if (yychar < 0) 704 { 705#if YYBTYACC 706 do { 707 if (yylvp < yylve) 708 { 709 /* we're currently re-reading tokens */ 710 yylval = *yylvp++; 711#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 712 yylloc = *yylpp++; 713#endif 714 yychar = *yylexp++; 715 break; 716 } 717 if (yyps->save) 718 { 719 /* in trial mode; save scanner results for future parse attempts */ 720 if (yylvp == yylvlim) 721 { /* Enlarge lexical value queue */ 722 size_t p = (size_t) (yylvp - yylvals); 723 size_t s = (size_t) (yylvlim - yylvals); 724 725 s += YYLVQUEUEGROWTH; 726 if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; 727 if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; 728#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 729 if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; 730#endif 731 yylvp = yylve = yylvals + p; 732 yylvlim = yylvals + s; 733#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 734 yylpp = yylpe = yylpsns + p; 735 yylplim = yylpsns + s; 736#endif 737 yylexp = yylexemes + p; 738 } 739 *yylexp = (YYINT) YYLEX; 740 *yylvp++ = yylval; 741 yylve++; 742#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 743 *yylpp++ = yylloc; 744 yylpe++; 745#endif 746 yychar = *yylexp++; 747 break; 748 } 749 /* normal operation, no conflict encountered */ 750#endif /* YYBTYACC */ 751 yychar = YYLEX; 752#if YYBTYACC 753 } while (0); 754#endif /* YYBTYACC */ 755 if (yychar < 0) yychar = YYEOF; 756#if YYDEBUG 757 if (yydebug) 758 { 759 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; 760 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", 761 YYDEBUGSTR, yydepth, yystate, yychar, yys); 762#ifdef YYSTYPE_TOSTRING 763#if YYBTYACC 764 if (!yytrial) 765#endif /* YYBTYACC */ 766 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); 767#endif 768 fputc('\n', stderr); 769 } 770#endif 771 } 772#if YYBTYACC 773 774 /* Do we have a conflict? */ 775 if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && 776 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) 777 { 778 YYINT ctry; 779 780 if (yypath) 781 { 782 YYParseState *save; 783#if YYDEBUG 784 if (yydebug) 785 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", 786 YYDEBUGSTR, yydepth, yystate); 787#endif 788 /* Switch to the next conflict context */ 789 save = yypath; 790 yypath = save->save; 791 save->save = NULL; 792 ctry = save->ctry; 793 if (save->state != yystate) YYABORT; 794 yyFreeState(save); 795 796 } 797 else 798 { 799 800 /* Unresolved conflict - start/continue trial parse */ 801 YYParseState *save; 802#if YYDEBUG 803 if (yydebug) 804 { 805 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); 806 if (yyps->save) 807 fputs("ALREADY in conflict, continuing trial parse.\n", stderr); 808 else 809 fputs("Starting trial parse.\n", stderr); 810 } 811#endif 812 save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); 813 if (save == NULL) goto yyenomem; 814 save->save = yyps->save; 815 save->state = yystate; 816 save->errflag = yyerrflag; 817 save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); 818 memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); 819 save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); 820 memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 821#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 822 save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); 823 memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 824#endif 825 ctry = yytable[yyn]; 826 if (yyctable[ctry] == -1) 827 { 828#if YYDEBUG 829 if (yydebug && yychar >= YYEOF) 830 fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); 831#endif 832 ctry++; 833 } 834 save->ctry = ctry; 835 if (yyps->save == NULL) 836 { 837 /* If this is a first conflict in the stack, start saving lexemes */ 838 if (!yylexemes) 839 { 840 yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); 841 if (yylexemes == NULL) goto yyenomem; 842 yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); 843 if (yylvals == NULL) goto yyenomem; 844 yylvlim = yylvals + YYLVQUEUEGROWTH; 845#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 846 yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); 847 if (yylpsns == NULL) goto yyenomem; 848 yylplim = yylpsns + YYLVQUEUEGROWTH; 849#endif 850 } 851 if (yylvp == yylve) 852 { 853 yylvp = yylve = yylvals; 854#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 855 yylpp = yylpe = yylpsns; 856#endif 857 yylexp = yylexemes; 858 if (yychar >= YYEOF) 859 { 860 *yylve++ = yylval; 861#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 862 *yylpe++ = yylloc; 863#endif 864 *yylexp = (YYINT) yychar; 865 yychar = YYEMPTY; 866 } 867 } 868 } 869 if (yychar >= YYEOF) 870 { 871 yylvp--; 872#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 873 yylpp--; 874#endif 875 yylexp--; 876 yychar = YYEMPTY; 877 } 878 save->lexeme = (int) (yylvp - yylvals); 879 yyps->save = save; 880 } 881 if (yytable[yyn] == ctry) 882 { 883#if YYDEBUG 884 if (yydebug) 885 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", 886 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); 887#endif 888 if (yychar < 0) 889 { 890 yylvp++; 891#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 892 yylpp++; 893#endif 894 yylexp++; 895 } 896 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) 897 goto yyoverflow; 898 yystate = yyctable[ctry]; 899 *++yystack.s_mark = (YYINT) yystate; 900 *++yystack.l_mark = yylval; 901#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 902 *++yystack.p_mark = yylloc; 903#endif 904 yychar = YYEMPTY; 905 if (yyerrflag > 0) --yyerrflag; 906 goto yyloop; 907 } 908 else 909 { 910 yyn = yyctable[ctry]; 911 goto yyreduce; 912 } 913 } /* End of code dealing with conflicts */ 914#endif /* YYBTYACC */ 915 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && 916 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) 917 { 918#if YYDEBUG 919 if (yydebug) 920 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", 921 YYDEBUGSTR, yydepth, yystate, yytable[yyn]); 922#endif 923 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 924 yystate = yytable[yyn]; 925 *++yystack.s_mark = yytable[yyn]; 926 *++yystack.l_mark = yylval; 927#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 928 *++yystack.p_mark = yylloc; 929#endif 930 yychar = YYEMPTY; 931 if (yyerrflag > 0) --yyerrflag; 932 goto yyloop; 933 } 934 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && 935 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) 936 { 937 yyn = yytable[yyn]; 938 goto yyreduce; 939 } 940 if (yyerrflag != 0) goto yyinrecovery; 941#if YYBTYACC 942 943 yynewerrflag = 1; 944 goto yyerrhandler; 945 goto yyerrlab; /* redundant goto avoids 'unused label' warning */ 946 947yyerrlab: 948 /* explicit YYERROR from an action -- pop the rhs of the rule reduced 949 * before looking for error recovery */ 950 yystack.s_mark -= yym; 951 yystate = *yystack.s_mark; 952 yystack.l_mark -= yym; 953#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 954 yystack.p_mark -= yym; 955#endif 956 957 yynewerrflag = 0; 958yyerrhandler: 959 while (yyps->save) 960 { 961 int ctry; 962 YYParseState *save = yyps->save; 963#if YYDEBUG 964 if (yydebug) 965 fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", 966 YYDEBUGSTR, yydepth, yystate, yyps->save->state, 967 (int)(yylvp - yylvals - yyps->save->lexeme)); 968#endif 969 /* Memorize most forward-looking error state in case it's really an error. */ 970 if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) 971 { 972 /* Free old saved error context state */ 973 if (yyerrctx) yyFreeState(yyerrctx); 974 /* Create and fill out new saved error context state */ 975 yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); 976 if (yyerrctx == NULL) goto yyenomem; 977 yyerrctx->save = yyps->save; 978 yyerrctx->state = yystate; 979 yyerrctx->errflag = yyerrflag; 980 yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); 981 memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); 982 yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); 983 memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 984#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 985 yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); 986 memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 987#endif 988 yyerrctx->lexeme = (int) (yylvp - yylvals); 989 } 990 yylvp = yylvals + save->lexeme; 991#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 992 yylpp = yylpsns + save->lexeme; 993#endif 994 yylexp = yylexemes + save->lexeme; 995 yychar = YYEMPTY; 996 yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); 997 memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); 998 yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); 999 memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 1000#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1001 yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); 1002 memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 1003#endif 1004 ctry = ++save->ctry; 1005 yystate = save->state; 1006 /* We tried shift, try reduce now */ 1007 if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; 1008 yyps->save = save->save; 1009 save->save = NULL; 1010 yyFreeState(save); 1011 1012 /* Nothing left on the stack -- error */ 1013 if (!yyps->save) 1014 { 1015#if YYDEBUG 1016 if (yydebug) 1017 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", 1018 YYPREFIX, yydepth); 1019#endif 1020 /* Restore state as it was in the most forward-advanced error */ 1021 yylvp = yylvals + yyerrctx->lexeme; 1022#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1023 yylpp = yylpsns + yyerrctx->lexeme; 1024#endif 1025 yylexp = yylexemes + yyerrctx->lexeme; 1026 yychar = yylexp[-1]; 1027 yylval = yylvp[-1]; 1028#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1029 yylloc = yylpp[-1]; 1030#endif 1031 yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); 1032 memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); 1033 yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); 1034 memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 1035#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1036 yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); 1037 memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 1038#endif 1039 yystate = yyerrctx->state; 1040 yyFreeState(yyerrctx); 1041 yyerrctx = NULL; 1042 } 1043 yynewerrflag = 1; 1044 } 1045 if (yynewerrflag == 0) goto yyinrecovery; 1046#endif /* YYBTYACC */ 1047 1048 YYERROR_CALL("syntax error"); 1049#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1050 yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ 1051#endif 1052 1053#if !YYBTYACC 1054 goto yyerrlab; /* redundant goto avoids 'unused label' warning */ 1055yyerrlab: 1056#endif 1057 ++yynerrs; 1058 1059yyinrecovery: 1060 if (yyerrflag < 3) 1061 { 1062 yyerrflag = 3; 1063 for (;;) 1064 { 1065 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && 1066 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) 1067 { 1068#if YYDEBUG 1069 if (yydebug) 1070 fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", 1071 YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); 1072#endif 1073 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 1074 yystate = yytable[yyn]; 1075 *++yystack.s_mark = yytable[yyn]; 1076 *++yystack.l_mark = yylval; 1077#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1078 /* lookahead position is error end position */ 1079 yyerror_loc_range[2] = yylloc; 1080 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ 1081 *++yystack.p_mark = yyloc; 1082#endif 1083 goto yyloop; 1084 } 1085 else 1086 { 1087#if YYDEBUG 1088 if (yydebug) 1089 fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", 1090 YYDEBUGSTR, yydepth, *yystack.s_mark); 1091#endif 1092 if (yystack.s_mark <= yystack.s_base) goto yyabort; 1093#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1094 /* the current TOS position is the error start position */ 1095 yyerror_loc_range[1] = *yystack.p_mark; 1096#endif 1097#if defined(YYDESTRUCT_CALL) 1098#if YYBTYACC 1099 if (!yytrial) 1100#endif /* YYBTYACC */ 1101#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1102 YYDESTRUCT_CALL("error: discarding state", 1103 yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); 1104#else 1105 YYDESTRUCT_CALL("error: discarding state", 1106 yystos[*yystack.s_mark], yystack.l_mark); 1107#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 1108#endif /* defined(YYDESTRUCT_CALL) */ 1109 --yystack.s_mark; 1110 --yystack.l_mark; 1111#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1112 --yystack.p_mark; 1113#endif 1114 } 1115 } 1116 } 1117 else 1118 { 1119 if (yychar == YYEOF) goto yyabort; 1120#if YYDEBUG 1121 if (yydebug) 1122 { 1123 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; 1124 fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", 1125 YYDEBUGSTR, yydepth, yystate, yychar, yys); 1126 } 1127#endif 1128#if defined(YYDESTRUCT_CALL) 1129#if YYBTYACC 1130 if (!yytrial) 1131#endif /* YYBTYACC */ 1132#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1133 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); 1134#else 1135 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); 1136#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 1137#endif /* defined(YYDESTRUCT_CALL) */ 1138 yychar = YYEMPTY; 1139 goto yyloop; 1140 } 1141 1142yyreduce: 1143 yym = yylen[yyn]; 1144#if YYDEBUG 1145 if (yydebug) 1146 { 1147 fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", 1148 YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); 1149#ifdef YYSTYPE_TOSTRING 1150#if YYBTYACC 1151 if (!yytrial) 1152#endif /* YYBTYACC */ 1153 if (yym > 0) 1154 { 1155 int i; 1156 fputc('<', stderr); 1157 for (i = yym; i > 0; i--) 1158 { 1159 if (i != yym) fputs(", ", stderr); 1160 fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], 1161 yystack.l_mark[1-i]), stderr); 1162 } 1163 fputc('>', stderr); 1164 } 1165#endif 1166 fputc('\n', stderr); 1167 } 1168#endif 1169 if (yym > 0) 1170 yyval = yystack.l_mark[1-yym]; 1171 else 1172 memset(&yyval, 0, sizeof yyval); 1173#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1174 1175 /* Perform position reduction */ 1176 memset(&yyloc, 0, sizeof(yyloc)); 1177#if YYBTYACC 1178 if (!yytrial) 1179#endif /* YYBTYACC */ 1180 { 1181 YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); 1182 /* just in case YYERROR is invoked within the action, save 1183 the start of the rhs as the error start position */ 1184 yyerror_loc_range[1] = yystack.p_mark[1-yym]; 1185 } 1186#endif 1187 1188 switch (yyn) 1189 { 1190case 3: 1191#line 31 "calc_code_provides.y" 1192 { yyerrok ; } 1193break; 1194case 4: 1195#line 35 "calc_code_provides.y" 1196 { printf("%d\n",yystack.l_mark[0]);} 1197break; 1198case 5: 1199#line 37 "calc_code_provides.y" 1200 { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } 1201break; 1202case 6: 1203#line 41 "calc_code_provides.y" 1204 { yyval = yystack.l_mark[-1]; } 1205break; 1206case 7: 1207#line 43 "calc_code_provides.y" 1208 { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } 1209break; 1210case 8: 1211#line 45 "calc_code_provides.y" 1212 { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } 1213break; 1214case 9: 1215#line 47 "calc_code_provides.y" 1216 { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } 1217break; 1218case 10: 1219#line 49 "calc_code_provides.y" 1220 { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } 1221break; 1222case 11: 1223#line 51 "calc_code_provides.y" 1224 { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } 1225break; 1226case 12: 1227#line 53 "calc_code_provides.y" 1228 { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } 1229break; 1230case 13: 1231#line 55 "calc_code_provides.y" 1232 { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } 1233break; 1234case 14: 1235#line 57 "calc_code_provides.y" 1236 { yyval = - yystack.l_mark[0]; } 1237break; 1238case 15: 1239#line 59 "calc_code_provides.y" 1240 { yyval = regs[yystack.l_mark[0]]; } 1241break; 1242case 17: 1243#line 64 "calc_code_provides.y" 1244 { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } 1245break; 1246case 18: 1247#line 66 "calc_code_provides.y" 1248 { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } 1249break; 1250#line 1249 "calc_code_provides.tab.c" 1251 default: 1252 break; 1253 } 1254 yystack.s_mark -= yym; 1255 yystate = *yystack.s_mark; 1256 yystack.l_mark -= yym; 1257#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1258 yystack.p_mark -= yym; 1259#endif 1260 yym = yylhs[yyn]; 1261 if (yystate == 0 && yym == 0) 1262 { 1263#if YYDEBUG 1264 if (yydebug) 1265 { 1266 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); 1267#ifdef YYSTYPE_TOSTRING 1268#if YYBTYACC 1269 if (!yytrial) 1270#endif /* YYBTYACC */ 1271 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); 1272#endif 1273 fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); 1274 } 1275#endif 1276 yystate = YYFINAL; 1277 *++yystack.s_mark = YYFINAL; 1278 *++yystack.l_mark = yyval; 1279#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1280 *++yystack.p_mark = yyloc; 1281#endif 1282 if (yychar < 0) 1283 { 1284#if YYBTYACC 1285 do { 1286 if (yylvp < yylve) 1287 { 1288 /* we're currently re-reading tokens */ 1289 yylval = *yylvp++; 1290#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1291 yylloc = *yylpp++; 1292#endif 1293 yychar = *yylexp++; 1294 break; 1295 } 1296 if (yyps->save) 1297 { 1298 /* in trial mode; save scanner results for future parse attempts */ 1299 if (yylvp == yylvlim) 1300 { /* Enlarge lexical value queue */ 1301 size_t p = (size_t) (yylvp - yylvals); 1302 size_t s = (size_t) (yylvlim - yylvals); 1303 1304 s += YYLVQUEUEGROWTH; 1305 if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) 1306 goto yyenomem; 1307 if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) 1308 goto yyenomem; 1309#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1310 if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) 1311 goto yyenomem; 1312#endif 1313 yylvp = yylve = yylvals + p; 1314 yylvlim = yylvals + s; 1315#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1316 yylpp = yylpe = yylpsns + p; 1317 yylplim = yylpsns + s; 1318#endif 1319 yylexp = yylexemes + p; 1320 } 1321 *yylexp = (YYINT) YYLEX; 1322 *yylvp++ = yylval; 1323 yylve++; 1324#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1325 *yylpp++ = yylloc; 1326 yylpe++; 1327#endif 1328 yychar = *yylexp++; 1329 break; 1330 } 1331 /* normal operation, no conflict encountered */ 1332#endif /* YYBTYACC */ 1333 yychar = YYLEX; 1334#if YYBTYACC 1335 } while (0); 1336#endif /* YYBTYACC */ 1337 if (yychar < 0) yychar = YYEOF; 1338#if YYDEBUG 1339 if (yydebug) 1340 { 1341 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; 1342 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", 1343 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); 1344 } 1345#endif 1346 } 1347 if (yychar == YYEOF) goto yyaccept; 1348 goto yyloop; 1349 } 1350 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && 1351 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) 1352 yystate = yytable[yyn]; 1353 else 1354 yystate = yydgoto[yym]; 1355#if YYDEBUG 1356 if (yydebug) 1357 { 1358 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); 1359#ifdef YYSTYPE_TOSTRING 1360#if YYBTYACC 1361 if (!yytrial) 1362#endif /* YYBTYACC */ 1363 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); 1364#endif 1365 fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); 1366 } 1367#endif 1368 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 1369 *++yystack.s_mark = (YYINT) yystate; 1370 *++yystack.l_mark = yyval; 1371#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1372 *++yystack.p_mark = yyloc; 1373#endif 1374 goto yyloop; 1375#if YYBTYACC 1376 1377 /* Reduction declares that this path is valid. Set yypath and do a full parse */ 1378yyvalid: 1379 if (yypath) YYABORT; 1380 while (yyps->save) 1381 { 1382 YYParseState *save = yyps->save; 1383 yyps->save = save->save; 1384 save->save = yypath; 1385 yypath = save; 1386 } 1387#if YYDEBUG 1388 if (yydebug) 1389 fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", 1390 YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); 1391#endif 1392 if (yyerrctx) 1393 { 1394 yyFreeState(yyerrctx); 1395 yyerrctx = NULL; 1396 } 1397 yylvp = yylvals + yypath->lexeme; 1398#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1399 yylpp = yylpsns + yypath->lexeme; 1400#endif 1401 yylexp = yylexemes + yypath->lexeme; 1402 yychar = YYEMPTY; 1403 yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); 1404 memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); 1405 yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); 1406 memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 1407#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1408 yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); 1409 memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 1410#endif 1411 yystate = yypath->state; 1412 goto yyloop; 1413#endif /* YYBTYACC */ 1414 1415yyoverflow: 1416 YYERROR_CALL("yacc stack overflow"); 1417#if YYBTYACC 1418 goto yyabort_nomem; 1419yyenomem: 1420 YYERROR_CALL("memory exhausted"); 1421yyabort_nomem: 1422#endif /* YYBTYACC */ 1423 yyresult = 2; 1424 goto yyreturn; 1425 1426yyabort: 1427 yyresult = 1; 1428 goto yyreturn; 1429 1430yyaccept: 1431#if YYBTYACC 1432 if (yyps->save) goto yyvalid; 1433#endif /* YYBTYACC */ 1434 yyresult = 0; 1435 1436yyreturn: 1437#if defined(YYDESTRUCT_CALL) 1438 if (yychar != YYEOF && yychar != YYEMPTY) 1439#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1440 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); 1441#else 1442 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); 1443#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 1444 1445 { 1446 YYSTYPE *pv; 1447#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1448 YYLTYPE *pp; 1449 1450 for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) 1451 YYDESTRUCT_CALL("cleanup: discarding state", 1452 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); 1453#else 1454 for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) 1455 YYDESTRUCT_CALL("cleanup: discarding state", 1456 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); 1457#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 1458 } 1459#endif /* defined(YYDESTRUCT_CALL) */ 1460 1461#if YYBTYACC 1462 if (yyerrctx) 1463 { 1464 yyFreeState(yyerrctx); 1465 yyerrctx = NULL; 1466 } 1467 while (yyps) 1468 { 1469 YYParseState *save = yyps; 1470 yyps = save->save; 1471 save->save = NULL; 1472 yyFreeState(save); 1473 } 1474 while (yypath) 1475 { 1476 YYParseState *save = yypath; 1477 yypath = save->save; 1478 save->save = NULL; 1479 yyFreeState(save); 1480 } 1481#endif /* YYBTYACC */ 1482 yyfreestack(&yystack); 1483 return (yyresult); 1484} 1485