quote_calc2.tab.c revision 264790
1219820Sjeff/* original parser id follows */ 2219820Sjeff/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ 3219820Sjeff/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ 4219820Sjeff 5271127Shselasky#define YYBYACC 1 6219820Sjeff#define YYMAJOR 1 7219820Sjeff#define YYMINOR 9 8219820Sjeff#define YYCHECK "yyyymmdd" 9219820Sjeff 10219820Sjeff#define YYEMPTY (-1) 11219820Sjeff#define yyclearin (yychar = YYEMPTY) 12219820Sjeff#define yyerrok (yyerrflag = 0) 13219820Sjeff#define YYRECOVERING() (yyerrflag != 0) 14219820Sjeff#define YYENOMEM (-2) 15219820Sjeff#define YYEOF 0 16219820Sjeff#undef YYBTYACC 17219820Sjeff#define YYBTYACC 0 18219820Sjeff#define YYDEBUGSTR YYPREFIX "debug" 19219820Sjeff 20219820Sjeff#ifndef yyparse 21219820Sjeff#define yyparse quote_calc2_parse 22219820Sjeff#endif /* yyparse */ 23219820Sjeff 24219820Sjeff#ifndef yylex 25219820Sjeff#define yylex quote_calc2_lex 26219820Sjeff#endif /* yylex */ 27219820Sjeff 28219820Sjeff#ifndef yyerror 29219820Sjeff#define yyerror quote_calc2_error 30219820Sjeff#endif /* yyerror */ 31219820Sjeff 32219820Sjeff#ifndef yychar 33219820Sjeff#define yychar quote_calc2_char 34219820Sjeff#endif /* yychar */ 35219820Sjeff 36219820Sjeff#ifndef yyval 37219820Sjeff#define yyval quote_calc2_val 38219820Sjeff#endif /* yyval */ 39219820Sjeff 40219820Sjeff#ifndef yylval 41219820Sjeff#define yylval quote_calc2_lval 42219820Sjeff#endif /* yylval */ 43219820Sjeff 44219820Sjeff#ifndef yydebug 45219820Sjeff#define yydebug quote_calc2_debug 46219820Sjeff#endif /* yydebug */ 47219820Sjeff 48219820Sjeff#ifndef yynerrs 49219820Sjeff#define yynerrs quote_calc2_nerrs 50219820Sjeff#endif /* yynerrs */ 51219820Sjeff 52219820Sjeff#ifndef yyerrflag 53227293Sed#define yyerrflag quote_calc2_errflag 54219820Sjeff#endif /* yyerrflag */ 55219820Sjeff 56219820Sjeff#ifndef yylhs 57219820Sjeff#define yylhs quote_calc2_lhs 58219820Sjeff#endif /* yylhs */ 59219820Sjeff 60219820Sjeff#ifndef yylen 61219820Sjeff#define yylen quote_calc2_len 62219820Sjeff#endif /* yylen */ 63219820Sjeff 64219820Sjeff#ifndef yydefred 65219820Sjeff#define yydefred quote_calc2_defred 66219820Sjeff#endif /* yydefred */ 67219820Sjeff 68219820Sjeff#ifndef yystos 69219820Sjeff#define yystos quote_calc2_stos 70219820Sjeff#endif /* yystos */ 71219820Sjeff 72219820Sjeff#ifndef yydgoto 73219820Sjeff#define yydgoto quote_calc2_dgoto 74219820Sjeff#endif /* yydgoto */ 75219820Sjeff 76219820Sjeff#ifndef yysindex 77219820Sjeff#define yysindex quote_calc2_sindex 78219820Sjeff#endif /* yysindex */ 79219820Sjeff 80277139Shselasky#ifndef yyrindex 81219820Sjeff#define yyrindex quote_calc2_rindex 82219820Sjeff#endif /* yyrindex */ 83219820Sjeff 84219820Sjeff#ifndef yygindex 85219820Sjeff#define yygindex quote_calc2_gindex 86219820Sjeff#endif /* yygindex */ 87219820Sjeff 88219820Sjeff#ifndef yytable 89219820Sjeff#define yytable quote_calc2_table 90219820Sjeff#endif /* yytable */ 91219820Sjeff 92219820Sjeff#ifndef yycheck 93219820Sjeff#define yycheck quote_calc2_check 94219820Sjeff#endif /* yycheck */ 95219820Sjeff 96219820Sjeff#ifndef yyname 97219820Sjeff#define yyname quote_calc2_name 98219820Sjeff#endif /* yyname */ 99219820Sjeff 100219820Sjeff#ifndef yyrule 101219820Sjeff#define yyrule quote_calc2_rule 102219820Sjeff#endif /* yyrule */ 103219820Sjeff 104219820Sjeff#if YYBTYACC 105219820Sjeff 106219820Sjeff#ifndef yycindex 107219820Sjeff#define yycindex quote_calc2_cindex 108219820Sjeff#endif /* yycindex */ 109219820Sjeff 110219820Sjeff#ifndef yyctable 111219820Sjeff#define yyctable quote_calc2_ctable 112219820Sjeff#endif /* yyctable */ 113219820Sjeff 114219820Sjeff#endif /* YYBTYACC */ 115219820Sjeff 116219820Sjeff#define YYPREFIX "quote_calc2_" 117219820Sjeff 118219820Sjeff#define YYPURE 0 119219820Sjeff 120219820Sjeff#line 2 "quote_calc2.y" 121219820Sjeff# include <stdio.h> 122219820Sjeff# include <ctype.h> 123219820Sjeff 124219820Sjeffint regs[26]; 125219820Sjeffint base; 126219820Sjeff 127219820Sjeffint yylex(void); 128219820Sjeffstatic void yyerror(const char *s); 129219820Sjeff 130219820Sjeff#line 131 "quote_calc2.tab.c" 131219820Sjeff 132219820Sjeff#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) 133219820Sjeff/* Default: YYSTYPE is the semantic value type. */ 134219820Sjefftypedef int YYSTYPE; 135219820Sjeff# define YYSTYPE_IS_DECLARED 1 136219820Sjeff#endif 137219820Sjeff 138219820Sjeff/* compatibility with bison */ 139219820Sjeff#ifdef YYPARSE_PARAM 140219820Sjeff/* compatibility with FreeBSD */ 141219820Sjeff# ifdef YYPARSE_PARAM_TYPE 142219820Sjeff# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) 143219820Sjeff# else 144219820Sjeff# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) 145219820Sjeff# endif 146219820Sjeff#else 147219820Sjeff# define YYPARSE_DECL() yyparse(void) 148219820Sjeff#endif 149219820Sjeff 150219820Sjeff/* Parameters sent to lex. */ 151219820Sjeff#ifdef YYLEX_PARAM 152219820Sjeff# define YYLEX_DECL() yylex(void *YYLEX_PARAM) 153219820Sjeff# define YYLEX yylex(YYLEX_PARAM) 154219820Sjeff#else 155219820Sjeff# define YYLEX_DECL() yylex(void) 156219820Sjeff# define YYLEX yylex() 157219820Sjeff#endif 158219820Sjeff 159219820Sjeff/* Parameters sent to yyerror. */ 160219820Sjeff#ifndef YYERROR_DECL 161219820Sjeff#define YYERROR_DECL() yyerror(const char *s) 162219820Sjeff#endif 163219820Sjeff#ifndef YYERROR_CALL 164219820Sjeff#define YYERROR_CALL(msg) yyerror(msg) 165219820Sjeff#endif 166219820Sjeff 167219820Sjeffextern int YYPARSE_DECL(); 168219820Sjeff 169219820Sjeff#define OP_ADD 257 170219820Sjeff#define ADD 258 171219820Sjeff#define OP_SUB 259 172219820Sjeff#define SUB 260 173219820Sjeff#define OP_MUL 261 174219820Sjeff#define MUL 262 175219820Sjeff#define OP_DIV 263 176219820Sjeff#define DIV 264 177219820Sjeff#define OP_MOD 265 178219820Sjeff#define MOD 266 179219820Sjeff#define OP_AND 267 180219820Sjeff#define AND 268 181219820Sjeff#define DIGIT 269 182219820Sjeff#define LETTER 270 183219820Sjeff#define UMINUS 271 184219820Sjeff#define YYERRCODE 256 185219820Sjefftypedef short YYINT; 186219820Sjeffstatic const YYINT quote_calc2_lhs[] = { -1, 187219820Sjeff 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, 188283675Smarkj 2, 2, 2, 2, 2, 2, 3, 3, 189283675Smarkj}; 190219820Sjeffstatic const YYINT quote_calc2_len[] = { 2, 191219820Sjeff 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, 192219820Sjeff 3, 3, 3, 2, 1, 1, 1, 2, 193219820Sjeff}; 194219820Sjeffstatic const YYINT quote_calc2_defred[] = { 1, 195283675Smarkj 0, 0, 0, 17, 0, 0, 0, 0, 0, 3, 196283675Smarkj 15, 0, 0, 0, 2, 0, 0, 0, 0, 0, 197283675Smarkj 0, 0, 18, 0, 6, 0, 0, 0, 0, 0, 198219820Sjeff 0, 0, 199219820Sjeff}; 200219820Sjeffstatic const YYINT quote_calc2_stos[] = { 0, 201219820Sjeff 273, 256, 260, 269, 270, 40, 274, 275, 276, 10, 202283675Smarkj 270, 275, 61, 275, 10, 258, 260, 262, 264, 266, 203219820Sjeff 268, 124, 269, 275, 41, 275, 275, 275, 275, 275, 204219820Sjeff 275, 275, 205219820Sjeff}; 206219820Sjeffstatic const YYINT quote_calc2_dgoto[] = { 1, 207219820Sjeff 7, 8, 9, 208219820Sjeff}; 209283675Smarkjstatic const YYINT quote_calc2_sindex[] = { 0, 210283675Smarkj -38, 4, -36, 0, -51, -36, 6, -121, -249, 0, 211283675Smarkj 0, -243, -36, -23, 0, -36, -36, -36, -36, -36, 212283675Smarkj -36, -36, 0, -121, 0, -121, -121, -121, -121, -121, 213283675Smarkj -121, -243, 214283675Smarkj}; 215283675Smarkjstatic const YYINT quote_calc2_rindex[] = { 0, 216283675Smarkj 0, 0, 0, 0, -9, 0, 0, 12, -10, 0, 217283675Smarkj 0, -5, 0, 0, 0, 0, 0, 0, 0, 0, 218283675Smarkj 0, 0, 0, 14, 0, -3, -2, -1, 1, 2, 219219820Sjeff 3, -4, 220219820Sjeff}; 221219820Sjeff#if YYBTYACC 222219820Sjeffstatic const YYINT quote_calc2_cindex[] = { 0, 223219820Sjeff 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224219820Sjeff 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 225219820Sjeff 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 226219820Sjeff 0, 0, 227219820Sjeff}; 228219820Sjeff#endif 229219820Sjeffstatic const YYINT quote_calc2_gindex[] = { 0, 230219820Sjeff 0, 42, 0, 231219820Sjeff}; 232219820Sjeff#define YYTABLESIZE 259 233219820Sjeffstatic const YYINT quote_calc2_table[] = { 16, 234219820Sjeff 15, 6, 22, 6, 14, 13, 7, 8, 9, 13, 235219820Sjeff 10, 11, 12, 10, 16, 15, 17, 25, 18, 23, 236219820Sjeff 19, 4, 20, 5, 21, 0, 0, 0, 0, 0, 237219820Sjeff 16, 0, 0, 0, 0, 14, 13, 7, 8, 9, 238219820Sjeff 0, 10, 11, 12, 12, 0, 0, 14, 0, 0, 239219820Sjeff 0, 0, 0, 0, 24, 0, 0, 26, 27, 28, 240219820Sjeff 29, 30, 31, 32, 0, 0, 0, 0, 0, 0, 241219820Sjeff 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 242219820Sjeff 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 243219820Sjeff 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 244219820Sjeff 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, 245219820Sjeff 0, 0, 0, 16, 15, 0, 0, 0, 14, 13, 246219820Sjeff 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 247219820Sjeff 0, 0, 0, 0, 0, 0, 16, 0, 17, 0, 248219820Sjeff 18, 0, 19, 0, 20, 0, 21, 0, 0, 0, 249219820Sjeff 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 250219820Sjeff 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 251219820Sjeff 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 252219820Sjeff 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 253219820Sjeff 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 254219820Sjeff 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255219820Sjeff 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 256219820Sjeff 0, 3, 0, 3, 0, 0, 0, 0, 0, 0, 257219820Sjeff 4, 5, 4, 11, 16, 0, 17, 0, 18, 0, 258219820Sjeff 19, 0, 20, 0, 21, 0, 0, 16, 15, 16, 259219820Sjeff 15, 16, 15, 16, 15, 16, 15, 16, 15, 260219820Sjeff}; 261219820Sjeffstatic const YYINT quote_calc2_check[] = { 10, 262219820Sjeff 10, 40, 124, 40, 10, 10, 10, 10, 10, 61, 263219820Sjeff 10, 10, 10, 10, 258, 10, 260, 41, 262, 269, 264219820Sjeff 264, 10, 266, 10, 268, -1, -1, -1, -1, -1, 265219820Sjeff 41, -1, -1, -1, -1, 41, 41, 41, 41, 41, 266219820Sjeff -1, 41, 41, 41, 3, -1, -1, 6, -1, -1, 267219820Sjeff -1, -1, -1, -1, 13, -1, -1, 16, 17, 18, 268219820Sjeff 19, 20, 21, 22, -1, -1, -1, -1, -1, -1, 269219820Sjeff -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 270219820Sjeff -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 271219820Sjeff -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 272219820Sjeff 124, -1, -1, -1, -1, -1, -1, -1, -1, -1, 273219820Sjeff -1, -1, -1, 124, 124, -1, -1, -1, 124, 124, 274219820Sjeff -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 275219820Sjeff -1, -1, -1, -1, -1, -1, 258, -1, 260, -1, 276219820Sjeff 262, -1, 264, -1, 266, -1, 268, -1, -1, -1, 277219820Sjeff -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 278219820Sjeff -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 279219820Sjeff -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 280219820Sjeff -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 281219820Sjeff -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 282219820Sjeff -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 283219820Sjeff -1, -1, -1, -1, -1, -1, -1, 256, -1, -1, 284219820Sjeff -1, 260, -1, 260, -1, -1, -1, -1, -1, -1, 285219820Sjeff 269, 270, 269, 270, 258, -1, 260, -1, 262, -1, 286219820Sjeff 264, -1, 266, -1, 268, -1, -1, 258, 258, 260, 287219820Sjeff 260, 262, 262, 264, 264, 266, 266, 268, 268, 288219820Sjeff}; 289219820Sjeff#define YYFINAL 1 290219820Sjeff#ifndef YYDEBUG 291219820Sjeff#define YYDEBUG 0 292219820Sjeff#endif 293219820Sjeff#define YYMAXTOKEN 271 294219820Sjeff#define YYUNDFTOKEN 277 295219820Sjeff#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) 296219820Sjeff#if YYDEBUG 297219820Sjeffstatic const char *const quote_calc2_name[] = { 298219820Sjeff 299219820Sjeff"$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, 300219820Sjeff0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0, 301219820Sjeff0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 302219820Sjeff0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,0,0,0, 303219820Sjeff0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 304219820Sjeff0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 305219820Sjeff0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 306219820Sjeff0,0,"error","OP_ADD","\"ADD\"","OP_SUB","\"SUB\"","OP_MUL","\"MUL\"","OP_DIV", 307219820Sjeff"\"DIV\"","OP_MOD","\"MOD\"","OP_AND","\"AND\"","DIGIT","LETTER","UMINUS", 308219820Sjeff"$accept","list","stat","expr","number","illegal-symbol", 309219820Sjeff}; 310219820Sjeffstatic const char *const quote_calc2_rule[] = { 311219820Sjeff"$accept : list", 312219820Sjeff"list :", 313219820Sjeff"list : list stat '\\n'", 314219820Sjeff"list : list error '\\n'", 315219820Sjeff"stat : expr", 316219820Sjeff"stat : LETTER '=' expr", 317219820Sjeff"expr : '(' expr ')'", 318219820Sjeff"expr : expr \"ADD\" expr", 319219820Sjeff"expr : expr \"SUB\" expr", 320219820Sjeff"expr : expr \"MUL\" expr", 321219820Sjeff"expr : expr \"DIV\" expr", 322219820Sjeff"expr : expr \"MOD\" expr", 323219820Sjeff"expr : expr \"AND\" expr", 324219820Sjeff"expr : expr '|' expr", 325219820Sjeff"expr : \"SUB\" expr", 326219820Sjeff"expr : LETTER", 327219820Sjeff"expr : number", 328219820Sjeff"number : DIGIT", 329219820Sjeff"number : number DIGIT", 330219820Sjeff 331219820Sjeff}; 332219820Sjeff#endif 333219820Sjeff 334219820Sjeffint yydebug; 335219820Sjeffint yynerrs; 336219820Sjeff 337219820Sjeffint yyerrflag; 338219820Sjeffint yychar; 339219820SjeffYYSTYPE yyval; 340219820SjeffYYSTYPE yylval; 341219820Sjeff#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 342219820SjeffYYLTYPE yyloc; /* position returned by actions */ 343219820SjeffYYLTYPE yylloc; /* position from the lexer */ 344219820Sjeff#endif 345283675Smarkj 346219820Sjeff#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 347219820Sjeff#ifndef YYLLOC_DEFAULT 348219820Sjeff#define YYLLOC_DEFAULT(loc, rhs, n) \ 349219820Sjeffdo \ 350283675Smarkj{ \ 351219820Sjeff if (n == 0) \ 352219820Sjeff { \ 353219820Sjeff (loc).first_line = ((rhs)[-1]).last_line; \ 354219820Sjeff (loc).first_column = ((rhs)[-1]).last_column; \ 355219820Sjeff (loc).last_line = ((rhs)[-1]).last_line; \ 356219820Sjeff (loc).last_column = ((rhs)[-1]).last_column; \ 357219820Sjeff } \ 358219820Sjeff else \ 359219820Sjeff { \ 360219820Sjeff (loc).first_line = ((rhs)[ 0 ]).first_line; \ 361219820Sjeff (loc).first_column = ((rhs)[ 0 ]).first_column; \ 362219820Sjeff (loc).last_line = ((rhs)[n-1]).last_line; \ 363219820Sjeff (loc).last_column = ((rhs)[n-1]).last_column; \ 364219820Sjeff } \ 365219820Sjeff} while (0) 366219820Sjeff#endif /* YYLLOC_DEFAULT */ 367219820Sjeff#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 368219820Sjeff#if YYBTYACC 369219820Sjeff 370219820Sjeff#ifndef YYLVQUEUEGROWTH 371219820Sjeff#define YYLVQUEUEGROWTH 32 372219820Sjeff#endif 373219820Sjeff#endif /* YYBTYACC */ 374219820Sjeff 375219820Sjeff/* define the initial stack-sizes */ 376219820Sjeff#ifdef YYSTACKSIZE 377219820Sjeff#undef YYMAXDEPTH 378219820Sjeff#define YYMAXDEPTH YYSTACKSIZE 379219820Sjeff#else 380219820Sjeff#ifdef YYMAXDEPTH 381219820Sjeff#define YYSTACKSIZE YYMAXDEPTH 382219820Sjeff#else 383219820Sjeff#define YYSTACKSIZE 10000 384219820Sjeff#define YYMAXDEPTH 10000 385219820Sjeff#endif 386219820Sjeff#endif 387219820Sjeff 388219820Sjeff#ifndef YYINITSTACKSIZE 389219820Sjeff#define YYINITSTACKSIZE 200 390219820Sjeff#endif 391219820Sjeff 392219820Sjefftypedef struct { 393219820Sjeff unsigned stacksize; 394219820Sjeff short *s_base; 395219820Sjeff short *s_mark; 396219820Sjeff short *s_last; 397219820Sjeff YYSTYPE *l_base; 398219820Sjeff YYSTYPE *l_mark; 399219820Sjeff#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 400219820Sjeff YYLTYPE *p_base; 401219820Sjeff YYLTYPE *p_mark; 402219820Sjeff#endif 403219820Sjeff} YYSTACKDATA; 404219820Sjeff#if YYBTYACC 405219820Sjeff 406219820Sjeffstruct YYParseState_s 407219820Sjeff{ 408219820Sjeff struct YYParseState_s *save; /* Previously saved parser state */ 409219820Sjeff YYSTACKDATA yystack; /* saved parser stack */ 410219820Sjeff int state; /* saved parser state */ 411219820Sjeff int errflag; /* saved error recovery status */ 412219820Sjeff int lexeme; /* saved index of the conflict lexeme in the lexical queue */ 413219820Sjeff YYINT ctry; /* saved index in yyctable[] for this conflict */ 414219820Sjeff}; 415219820Sjefftypedef struct YYParseState_s YYParseState; 416219820Sjeff#endif /* YYBTYACC */ 417219820Sjeff/* variables for the parser stack */ 418219820Sjeffstatic YYSTACKDATA yystack; 419219820Sjeff#if YYBTYACC 420219820Sjeff 421284530Snp/* Current parser state */ 422219820Sjeffstatic YYParseState *yyps = 0; 423219820Sjeff 424219820Sjeff/* yypath != NULL: do the full parse, starting at *yypath parser state. */ 425219820Sjeffstatic YYParseState *yypath = 0; 426219820Sjeff 427219820Sjeff/* Base of the lexical value queue */ 428219820Sjeffstatic YYSTYPE *yylvals = 0; 429219820Sjeff 430219820Sjeff/* Current position at lexical value queue */ 431219820Sjeffstatic YYSTYPE *yylvp = 0; 432219820Sjeff 433219820Sjeff/* End position of lexical value queue */ 434219820Sjeffstatic YYSTYPE *yylve = 0; 435219820Sjeff 436219820Sjeff/* The last allocated position at the lexical value queue */ 437219820Sjeffstatic YYSTYPE *yylvlim = 0; 438219820Sjeff 439219820Sjeff#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 440219820Sjeff/* Base of the lexical position queue */ 441219820Sjeffstatic YYLTYPE *yylpsns = 0; 442219820Sjeff 443219820Sjeff/* Current position at lexical position queue */ 444219820Sjeffstatic YYLTYPE *yylpp = 0; 445219820Sjeff 446219820Sjeff/* End position of lexical position queue */ 447219820Sjeffstatic YYLTYPE *yylpe = 0; 448219820Sjeff 449219820Sjeff/* The last allocated position at the lexical position queue */ 450219820Sjeffstatic YYLTYPE *yylplim = 0; 451219820Sjeff#endif 452283675Smarkj 453219820Sjeff/* Current position at lexical token queue */ 454219820Sjeffstatic short *yylexp = 0; 455219820Sjeff 456219820Sjeffstatic short *yylexemes = 0; 457283675Smarkj#endif /* YYBTYACC */ 458219820Sjeff#line 73 "quote_calc2.y" 459219820Sjeff /* start of programs */ 460 461int 462main (void) 463{ 464 while(!feof(stdin)) { 465 yyparse(); 466 } 467 return 0; 468} 469 470static void 471yyerror(const char *s) 472{ 473 fprintf(stderr, "%s\n", s); 474} 475 476int 477yylex(void) { 478 /* lexical analysis routine */ 479 /* returns LETTER for a lower case letter, yylval = 0 through 25 */ 480 /* return DIGIT for a digit, yylval = 0 through 9 */ 481 /* all other characters are returned immediately */ 482 483 int c; 484 485 while( (c=getchar()) == ' ' ) { /* skip blanks */ } 486 487 /* c is now nonblank */ 488 489 if( islower( c )) { 490 yylval = c - 'a'; 491 return ( LETTER ); 492 } 493 if( isdigit( c )) { 494 yylval = c - '0'; 495 return ( DIGIT ); 496 } 497 return( c ); 498} 499#line 500 "quote_calc2.tab.c" 500 501/* For use in generated program */ 502#define yydepth (int)(yystack.s_mark - yystack.s_base) 503#if YYBTYACC 504#define yytrial (yyps->save) 505#endif /* YYBTYACC */ 506 507#if YYDEBUG 508#include <stdio.h> /* needed for printf */ 509#endif 510 511#include <stdlib.h> /* needed for malloc, etc */ 512#include <string.h> /* needed for memset */ 513 514/* allocate initial stack or double stack size, up to YYMAXDEPTH */ 515static int yygrowstack(YYSTACKDATA *data) 516{ 517 int i; 518 unsigned newsize; 519 short *newss; 520 YYSTYPE *newvs; 521#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 522 YYLTYPE *newps; 523#endif 524 525 if ((newsize = data->stacksize) == 0) 526 newsize = YYINITSTACKSIZE; 527 else if (newsize >= YYMAXDEPTH) 528 return YYENOMEM; 529 else if ((newsize *= 2) > YYMAXDEPTH) 530 newsize = YYMAXDEPTH; 531 532 i = (int) (data->s_mark - data->s_base); 533 newss = (short *)realloc(data->s_base, newsize * sizeof(*newss)); 534 if (newss == 0) 535 return YYENOMEM; 536 537 data->s_base = newss; 538 data->s_mark = newss + i; 539 540 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); 541 if (newvs == 0) 542 return YYENOMEM; 543 544 data->l_base = newvs; 545 data->l_mark = newvs + i; 546 547#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 548 newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); 549 if (newps == 0) 550 return YYENOMEM; 551 552 data->p_base = newps; 553 data->p_mark = newps + i; 554#endif 555 556 data->stacksize = newsize; 557 data->s_last = data->s_base + newsize - 1; 558 559#if YYDEBUG 560 if (yydebug) 561 fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); 562#endif 563 return 0; 564} 565 566#if YYPURE || defined(YY_NO_LEAKS) 567static void yyfreestack(YYSTACKDATA *data) 568{ 569 free(data->s_base); 570 free(data->l_base); 571#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 572 free(data->p_base); 573#endif 574 memset(data, 0, sizeof(*data)); 575} 576#else 577#define yyfreestack(data) /* nothing */ 578#endif /* YYPURE || defined(YY_NO_LEAKS) */ 579#if YYBTYACC 580 581static YYParseState * 582yyNewState(unsigned size) 583{ 584 YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); 585 if (p == NULL) return NULL; 586 587 p->yystack.stacksize = size; 588 if (size == 0) 589 { 590 p->yystack.s_base = NULL; 591 p->yystack.l_base = NULL; 592#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 593 p->yystack.p_base = NULL; 594#endif 595 return p; 596 } 597 p->yystack.s_base = (short *) malloc(size * sizeof(short)); 598 if (p->yystack.s_base == NULL) return NULL; 599 p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); 600 if (p->yystack.l_base == NULL) return NULL; 601 memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); 602#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 603 p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); 604 if (p->yystack.p_base == NULL) return NULL; 605 memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); 606#endif 607 608 return p; 609} 610 611static void 612yyFreeState(YYParseState *p) 613{ 614 yyfreestack(&p->yystack); 615 free(p); 616} 617#endif /* YYBTYACC */ 618 619#define YYABORT goto yyabort 620#define YYREJECT goto yyabort 621#define YYACCEPT goto yyaccept 622#define YYERROR goto yyerrlab 623#if YYBTYACC 624#define YYVALID do { if (yyps->save) goto yyvalid; } while(0) 625#define YYVALID_NESTED do { if (yyps->save && \ 626 yyps->save->save == 0) goto yyvalid; } while(0) 627#endif /* YYBTYACC */ 628 629int 630YYPARSE_DECL() 631{ 632 int yym, yyn, yystate, yyresult; 633#if YYBTYACC 634 int yynewerrflag; 635 YYParseState *yyerrctx = NULL; 636#endif /* YYBTYACC */ 637#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 638 YYLTYPE yyerror_loc_range[2]; /* position of error start & end */ 639#endif 640#if YYDEBUG 641 const char *yys; 642 643 if ((yys = getenv("YYDEBUG")) != 0) 644 { 645 yyn = *yys; 646 if (yyn >= '0' && yyn <= '9') 647 yydebug = yyn - '0'; 648 } 649 if (yydebug) 650 fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); 651#endif 652 653#if YYBTYACC 654 yyps = yyNewState(0); if (yyps == 0) goto yyenomem; 655 yyps->save = 0; 656#endif /* YYBTYACC */ 657 yynerrs = 0; 658 yyerrflag = 0; 659 yychar = YYEMPTY; 660 yystate = 0; 661 662#if YYPURE 663 memset(&yystack, 0, sizeof(yystack)); 664#endif 665 666 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 667 yystack.s_mark = yystack.s_base; 668 yystack.l_mark = yystack.l_base; 669#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 670 yystack.p_mark = yystack.p_base; 671#endif 672 yystate = 0; 673 *yystack.s_mark = 0; 674 675yyloop: 676 if ((yyn = yydefred[yystate]) != 0) goto yyreduce; 677 if (yychar < 0) 678 { 679#if YYBTYACC 680 do { 681 if (yylvp < yylve) 682 { 683 /* we're currently re-reading tokens */ 684 yylval = *yylvp++; 685#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 686 yylloc = *yylpp++; 687#endif 688 yychar = *yylexp++; 689 break; 690 } 691 if (yyps->save) 692 { 693 /* in trial mode; save scanner results for future parse attempts */ 694 if (yylvp == yylvlim) 695 { /* Enlarge lexical value queue */ 696 int p = yylvp - yylvals; 697 int s = yylvlim - yylvals; 698 699 s += YYLVQUEUEGROWTH; 700 if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem; 701 if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; 702#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 703 if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; 704#endif 705 yylvp = yylve = yylvals + p; 706 yylvlim = yylvals + s; 707#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 708 yylpp = yylpe = yylpsns + p; 709 yylplim = yylpsns + s; 710#endif 711 yylexp = yylexemes + p; 712 } 713 *yylexp = (short) YYLEX; 714 *yylvp++ = yylval; 715 yylve++; 716#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 717 *yylpp++ = yylloc; 718 yylpe++; 719#endif 720 yychar = *yylexp++; 721 break; 722 } 723 /* normal operation, no conflict encountered */ 724#endif /* YYBTYACC */ 725 yychar = YYLEX; 726#if YYBTYACC 727 } while (0); 728#endif /* YYBTYACC */ 729 if (yychar < 0) yychar = YYEOF; 730 /* if ((yychar = YYLEX) < 0) yychar = YYEOF; */ 731#if YYDEBUG 732 if (yydebug) 733 { 734 yys = yyname[YYTRANSLATE(yychar)]; 735 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", 736 YYDEBUGSTR, yydepth, yystate, yychar, yys); 737#ifdef YYSTYPE_TOSTRING 738#if YYBTYACC 739 if (!yytrial) 740#endif /* YYBTYACC */ 741 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); 742#endif 743 fputc('\n', stderr); 744 } 745#endif 746 } 747#if YYBTYACC 748 749 /* Do we have a conflict? */ 750 if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && 751 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) 752 { 753 YYINT ctry; 754 755 if (yypath) 756 { 757 YYParseState *save; 758#if YYDEBUG 759 if (yydebug) 760 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", 761 YYDEBUGSTR, yydepth, yystate); 762#endif 763 /* Switch to the next conflict context */ 764 save = yypath; 765 yypath = save->save; 766 save->save = NULL; 767 ctry = save->ctry; 768 if (save->state != yystate) YYABORT; 769 yyFreeState(save); 770 771 } 772 else 773 { 774 775 /* Unresolved conflict - start/continue trial parse */ 776 YYParseState *save; 777#if YYDEBUG 778 if (yydebug) 779 { 780 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); 781 if (yyps->save) 782 fputs("ALREADY in conflict, continuing trial parse.\n", stderr); 783 else 784 fputs("Starting trial parse.\n", stderr); 785 } 786#endif 787 save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); 788 if (save == NULL) goto yyenomem; 789 save->save = yyps->save; 790 save->state = yystate; 791 save->errflag = yyerrflag; 792 save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); 793 memcpy (save->yystack.s_base, yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); 794 save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); 795 memcpy (save->yystack.l_base, yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 796#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 797 save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); 798 memcpy (save->yystack.p_base, yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 799#endif 800 ctry = yytable[yyn]; 801 if (yyctable[ctry] == -1) 802 { 803#if YYDEBUG 804 if (yydebug && yychar >= YYEOF) 805 fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); 806#endif 807 ctry++; 808 } 809 save->ctry = ctry; 810 if (yyps->save == NULL) 811 { 812 /* If this is a first conflict in the stack, start saving lexemes */ 813 if (!yylexemes) 814 { 815 yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); 816 if (yylexemes == NULL) goto yyenomem; 817 yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); 818 if (yylvals == NULL) goto yyenomem; 819 yylvlim = yylvals + YYLVQUEUEGROWTH; 820#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 821 yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); 822 if (yylpsns == NULL) goto yyenomem; 823 yylplim = yylpsns + YYLVQUEUEGROWTH; 824#endif 825 } 826 if (yylvp == yylve) 827 { 828 yylvp = yylve = yylvals; 829#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 830 yylpp = yylpe = yylpsns; 831#endif 832 yylexp = yylexemes; 833 if (yychar >= YYEOF) 834 { 835 *yylve++ = yylval; 836#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 837 *yylpe++ = yylloc; 838#endif 839 *yylexp = (short) yychar; 840 yychar = YYEMPTY; 841 } 842 } 843 } 844 if (yychar >= YYEOF) 845 { 846 yylvp--; 847#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 848 yylpp--; 849#endif 850 yylexp--; 851 yychar = YYEMPTY; 852 } 853 save->lexeme = yylvp - yylvals; 854 yyps->save = save; 855 } 856 if (yytable[yyn] == ctry) 857 { 858#if YYDEBUG 859 if (yydebug) 860 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", 861 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); 862#endif 863 if (yychar < 0) 864 { 865 yylvp++; 866#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 867 yylpp++; 868#endif 869 yylexp++; 870 } 871 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) 872 goto yyoverflow; 873 yystate = yyctable[ctry]; 874 *++yystack.s_mark = (short) yystate; 875 *++yystack.l_mark = yylval; 876#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 877 *++yystack.p_mark = yylloc; 878#endif 879 yychar = YYEMPTY; 880 if (yyerrflag > 0) --yyerrflag; 881 goto yyloop; 882 } 883 else 884 { 885 yyn = yyctable[ctry]; 886 goto yyreduce; 887 } 888 } /* End of code dealing with conflicts */ 889#endif /* YYBTYACC */ 890 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && 891 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) 892 { 893#if YYDEBUG 894 if (yydebug) 895 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", 896 YYDEBUGSTR, yydepth, yystate, yytable[yyn]); 897#endif 898 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 899 yystate = yytable[yyn]; 900 *++yystack.s_mark = yytable[yyn]; 901 *++yystack.l_mark = yylval; 902#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 903 *++yystack.p_mark = yylloc; 904#endif 905 yychar = YYEMPTY; 906 if (yyerrflag > 0) --yyerrflag; 907 goto yyloop; 908 } 909 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && 910 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) 911 { 912 yyn = yytable[yyn]; 913 goto yyreduce; 914 } 915 if (yyerrflag != 0) goto yyinrecovery; 916#if YYBTYACC 917 918 yynewerrflag = 1; 919 goto yyerrhandler; 920 goto yyerrlab; 921 922yyerrlab: 923 yynewerrflag = 0; 924yyerrhandler: 925 while (yyps->save) 926 { 927 int ctry; 928 YYParseState *save = yyps->save; 929#if YYDEBUG 930 if (yydebug) 931 fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", 932 YYDEBUGSTR, yydepth, yystate, yyps->save->state, 933 (int)(yylvp - yylvals - yyps->save->lexeme)); 934#endif 935 /* Memorize most forward-looking error state in case it's really an error. */ 936 if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) 937 { 938 /* Free old saved error context state */ 939 if (yyerrctx) yyFreeState(yyerrctx); 940 /* Create and fill out new saved error context state */ 941 yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); 942 if (yyerrctx == NULL) goto yyenomem; 943 yyerrctx->save = yyps->save; 944 yyerrctx->state = yystate; 945 yyerrctx->errflag = yyerrflag; 946 yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); 947 memcpy (yyerrctx->yystack.s_base, yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); 948 yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); 949 memcpy (yyerrctx->yystack.l_base, yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 950#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 951 yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); 952 memcpy (yyerrctx->yystack.p_base, yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 953#endif 954 yyerrctx->lexeme = yylvp - yylvals; 955 } 956 yylvp = yylvals + save->lexeme; 957#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 958 yylpp = yylpsns + save->lexeme; 959#endif 960 yylexp = yylexemes + save->lexeme; 961 yychar = YYEMPTY; 962 yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); 963 memcpy (yystack.s_base, save->yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); 964 yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); 965 memcpy (yystack.l_base, save->yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 966#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 967 yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); 968 memcpy (yystack.p_base, save->yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 969#endif 970 ctry = ++save->ctry; 971 yystate = save->state; 972 /* We tried shift, try reduce now */ 973 if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; 974 yyps->save = save->save; 975 save->save = NULL; 976 yyFreeState(save); 977 978 /* Nothing left on the stack -- error */ 979 if (!yyps->save) 980 { 981#if YYDEBUG 982 if (yydebug) 983 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", 984 YYPREFIX, yydepth); 985#endif 986 /* Restore state as it was in the most forward-advanced error */ 987 yylvp = yylvals + yyerrctx->lexeme; 988#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 989 yylpp = yylpsns + yyerrctx->lexeme; 990#endif 991 yylexp = yylexemes + yyerrctx->lexeme; 992 yychar = yylexp[-1]; 993 yylval = yylvp[-1]; 994#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 995 yylloc = yylpp[-1]; 996#endif 997 yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); 998 memcpy (yystack.s_base, yyerrctx->yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); 999 yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); 1000 memcpy (yystack.l_base, yyerrctx->yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 1001#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1002 yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); 1003 memcpy (yystack.p_base, yyerrctx->yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 1004#endif 1005 yystate = yyerrctx->state; 1006 yyFreeState(yyerrctx); 1007 yyerrctx = NULL; 1008 } 1009 yynewerrflag = 1; 1010 } 1011 if (yynewerrflag == 0) goto yyinrecovery; 1012#endif /* YYBTYACC */ 1013 1014 YYERROR_CALL("syntax error"); 1015#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1016 yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ 1017#endif 1018 1019#if !YYBTYACC 1020 goto yyerrlab; 1021yyerrlab: 1022#endif 1023 ++yynerrs; 1024 1025yyinrecovery: 1026 if (yyerrflag < 3) 1027 { 1028 yyerrflag = 3; 1029 for (;;) 1030 { 1031 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && 1032 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) 1033 { 1034#if YYDEBUG 1035 if (yydebug) 1036 fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", 1037 YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); 1038#endif 1039 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 1040 yystate = yytable[yyn]; 1041 *++yystack.s_mark = yytable[yyn]; 1042 *++yystack.l_mark = yylval; 1043#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1044 /* lookahead position is error end position */ 1045 yyerror_loc_range[1] = yylloc; 1046 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ 1047 *++yystack.p_mark = yyloc; 1048#endif 1049 goto yyloop; 1050 } 1051 else 1052 { 1053#if YYDEBUG 1054 if (yydebug) 1055 fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", 1056 YYDEBUGSTR, yydepth, *yystack.s_mark); 1057#endif 1058 if (yystack.s_mark <= yystack.s_base) goto yyabort; 1059#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1060 /* the current TOS position is the error start position */ 1061 yyerror_loc_range[0] = *yystack.p_mark; 1062#endif 1063#if defined(YYDESTRUCT_CALL) 1064#if YYBTYACC 1065 if (!yytrial) 1066#endif /* YYBTYACC */ 1067#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1068 YYDESTRUCT_CALL("error: discarding state", 1069 yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); 1070#else 1071 YYDESTRUCT_CALL("error: discarding state", 1072 yystos[*yystack.s_mark], yystack.l_mark); 1073#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 1074#endif /* defined(YYDESTRUCT_CALL) */ 1075 --yystack.s_mark; 1076 --yystack.l_mark; 1077#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1078 --yystack.p_mark; 1079#endif 1080 } 1081 } 1082 } 1083 else 1084 { 1085 if (yychar == YYEOF) goto yyabort; 1086#if YYDEBUG 1087 if (yydebug) 1088 { 1089 yys = yyname[YYTRANSLATE(yychar)]; 1090 fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", 1091 YYDEBUGSTR, yydepth, yystate, yychar, yys); 1092 } 1093#endif 1094#if defined(YYDESTRUCT_CALL) 1095#if YYBTYACC 1096 if (!yytrial) 1097#endif /* YYBTYACC */ 1098#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1099 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); 1100#else 1101 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); 1102#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 1103#endif /* defined(YYDESTRUCT_CALL) */ 1104 yychar = YYEMPTY; 1105 goto yyloop; 1106 } 1107 1108yyreduce: 1109 yym = yylen[yyn]; 1110#if YYDEBUG 1111 if (yydebug) 1112 { 1113 fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", 1114 YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); 1115#ifdef YYSTYPE_TOSTRING 1116#if YYBTYACC 1117 if (!yytrial) 1118#endif /* YYBTYACC */ 1119 if (yym > 0) 1120 { 1121 int i; 1122 fputc('<', stderr); 1123 for (i = yym; i > 0; i--) 1124 { 1125 if (i != yym) fputs(", ", stderr); 1126 fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], 1127 yystack.l_mark[1-i]), stderr); 1128 } 1129 fputc('>', stderr); 1130 } 1131#endif 1132 fputc('\n', stderr); 1133 } 1134#endif 1135 if (yym > 0) 1136 yyval = yystack.l_mark[1-yym]; 1137 else 1138 memset(&yyval, 0, sizeof yyval); 1139#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1140 1141 /* Perform position reduction */ 1142 memset(&yyloc, 0, sizeof(yyloc)); 1143#if YYBTYACC 1144 if (!yytrial) 1145#endif /* YYBTYACC */ 1146 { 1147 YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); 1148 /* just in case YYERROR is invoked within the action, save 1149 the start of the rhs as the error start position */ 1150 yyerror_loc_range[0] = yystack.p_mark[1-yym]; 1151 } 1152#endif 1153 1154 switch (yyn) 1155 { 1156case 3: 1157#line 35 "quote_calc2.y" 1158 { yyerrok ; } 1159break; 1160case 4: 1161#line 39 "quote_calc2.y" 1162 { printf("%d\n",yystack.l_mark[0]);} 1163break; 1164case 5: 1165#line 41 "quote_calc2.y" 1166 { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } 1167break; 1168case 6: 1169#line 45 "quote_calc2.y" 1170 { yyval = yystack.l_mark[-1]; } 1171break; 1172case 7: 1173#line 47 "quote_calc2.y" 1174 { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } 1175break; 1176case 8: 1177#line 49 "quote_calc2.y" 1178 { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } 1179break; 1180case 9: 1181#line 51 "quote_calc2.y" 1182 { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } 1183break; 1184case 10: 1185#line 53 "quote_calc2.y" 1186 { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } 1187break; 1188case 11: 1189#line 55 "quote_calc2.y" 1190 { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } 1191break; 1192case 12: 1193#line 57 "quote_calc2.y" 1194 { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } 1195break; 1196case 13: 1197#line 59 "quote_calc2.y" 1198 { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } 1199break; 1200case 14: 1201#line 61 "quote_calc2.y" 1202 { yyval = - yystack.l_mark[0]; } 1203break; 1204case 15: 1205#line 63 "quote_calc2.y" 1206 { yyval = regs[yystack.l_mark[0]]; } 1207break; 1208case 17: 1209#line 68 "quote_calc2.y" 1210 { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } 1211break; 1212case 18: 1213#line 70 "quote_calc2.y" 1214 { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } 1215break; 1216#line 1217 "quote_calc2.tab.c" 1217 default: 1218 break; 1219 } 1220 yystack.s_mark -= yym; 1221 yystate = *yystack.s_mark; 1222 yystack.l_mark -= yym; 1223#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1224 yystack.p_mark -= yym; 1225#endif 1226 yym = yylhs[yyn]; 1227 if (yystate == 0 && yym == 0) 1228 { 1229#if YYDEBUG 1230 if (yydebug) 1231 { 1232 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); 1233#ifdef YYSTYPE_TOSTRING 1234#if YYBTYACC 1235 if (!yytrial) 1236#endif /* YYBTYACC */ 1237 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); 1238#endif 1239 fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); 1240 } 1241#endif 1242 yystate = YYFINAL; 1243 *++yystack.s_mark = YYFINAL; 1244 *++yystack.l_mark = yyval; 1245#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1246 *++yystack.p_mark = yyloc; 1247#endif 1248 if (yychar < 0) 1249 { 1250#if YYBTYACC 1251 do { 1252 if (yylvp < yylve) 1253 { 1254 /* we're currently re-reading tokens */ 1255 yylval = *yylvp++; 1256#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1257 yylloc = *yylpp++; 1258#endif 1259 yychar = *yylexp++; 1260 break; 1261 } 1262 if (yyps->save) 1263 { 1264 /* in trial mode; save scanner results for future parse attempts */ 1265 if (yylvp == yylvlim) 1266 { /* Enlarge lexical value queue */ 1267 int p = yylvp - yylvals; 1268 int s = yylvlim - yylvals; 1269 1270 s += YYLVQUEUEGROWTH; 1271 if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) 1272 goto yyenomem; 1273 if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) 1274 goto yyenomem; 1275#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1276 if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) 1277 goto yyenomem; 1278#endif 1279 yylvp = yylve = yylvals + p; 1280 yylvlim = yylvals + s; 1281#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1282 yylpp = yylpe = yylpsns + p; 1283 yylplim = yylpsns + s; 1284#endif 1285 yylexp = yylexemes + p; 1286 } 1287 *yylexp = (short) YYLEX; 1288 *yylvp++ = yylval; 1289 yylve++; 1290#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1291 *yylpp++ = yylloc; 1292 yylpe++; 1293#endif 1294 yychar = *yylexp++; 1295 break; 1296 } 1297 /* normal operation, no conflict encountered */ 1298#endif /* YYBTYACC */ 1299 yychar = YYLEX; 1300#if YYBTYACC 1301 } while (0); 1302#endif /* YYBTYACC */ 1303 if (yychar < 0) yychar = YYEOF; 1304 /* if ((yychar = YYLEX) < 0) yychar = YYEOF; */ 1305#if YYDEBUG 1306 if (yydebug) 1307 { 1308 yys = yyname[YYTRANSLATE(yychar)]; 1309 fprintf(stderr, "%s[%d]: state %d, reading %d (%s)\n", 1310 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); 1311 } 1312#endif 1313 } 1314 if (yychar == YYEOF) goto yyaccept; 1315 goto yyloop; 1316 } 1317 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && 1318 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) 1319 yystate = yytable[yyn]; 1320 else 1321 yystate = yydgoto[yym]; 1322#if YYDEBUG 1323 if (yydebug) 1324 { 1325 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); 1326#ifdef YYSTYPE_TOSTRING 1327#if YYBTYACC 1328 if (!yytrial) 1329#endif /* YYBTYACC */ 1330 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); 1331#endif 1332 fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); 1333 } 1334#endif 1335 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 1336 *++yystack.s_mark = (short) yystate; 1337 *++yystack.l_mark = yyval; 1338#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1339 *++yystack.p_mark = yyloc; 1340#endif 1341 goto yyloop; 1342#if YYBTYACC 1343 1344 /* Reduction declares that this path is valid. Set yypath and do a full parse */ 1345yyvalid: 1346 if (yypath) YYABORT; 1347 while (yyps->save) 1348 { 1349 YYParseState *save = yyps->save; 1350 yyps->save = save->save; 1351 save->save = yypath; 1352 yypath = save; 1353 } 1354#if YYDEBUG 1355 if (yydebug) 1356 fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", 1357 YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); 1358#endif 1359 if (yyerrctx) 1360 { 1361 yyFreeState(yyerrctx); 1362 yyerrctx = NULL; 1363 } 1364 yylvp = yylvals + yypath->lexeme; 1365#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1366 yylpp = yylpsns + yypath->lexeme; 1367#endif 1368 yylexp = yylexemes + yypath->lexeme; 1369 yychar = YYEMPTY; 1370 yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); 1371 memcpy (yystack.s_base, yypath->yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); 1372 yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); 1373 memcpy (yystack.l_base, yypath->yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 1374#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1375 yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); 1376 memcpy (yystack.p_base, yypath->yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 1377#endif 1378 yystate = yypath->state; 1379 goto yyloop; 1380#endif /* YYBTYACC */ 1381 1382yyoverflow: 1383 YYERROR_CALL("yacc stack overflow"); 1384#if YYBTYACC 1385 goto yyabort_nomem; 1386yyenomem: 1387 YYERROR_CALL("memory exhausted"); 1388yyabort_nomem: 1389#endif /* YYBTYACC */ 1390 yyresult = 2; 1391 goto yyreturn; 1392 1393yyabort: 1394 yyresult = 1; 1395 goto yyreturn; 1396 1397yyaccept: 1398#if YYBTYACC 1399 if (yyps->save) goto yyvalid; 1400#endif /* YYBTYACC */ 1401 yyresult = 0; 1402 1403yyreturn: 1404#if defined(YYDESTRUCT_CALL) 1405 if (yychar != YYEOF && yychar != YYEMPTY) 1406#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1407 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); 1408#else 1409 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); 1410#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 1411 1412 { 1413 YYSTYPE *pv; 1414#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1415 YYLTYPE *pp; 1416 1417 for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) 1418 YYDESTRUCT_CALL("cleanup: discarding state", 1419 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); 1420#else 1421 for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) 1422 YYDESTRUCT_CALL("cleanup: discarding state", 1423 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); 1424#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 1425 } 1426#endif /* defined(YYDESTRUCT_CALL) */ 1427 1428#if YYBTYACC 1429 if (yyerrctx) 1430 { 1431 yyFreeState(yyerrctx); 1432 yyerrctx = NULL; 1433 } 1434 while (yyps) 1435 { 1436 YYParseState *save = yyps; 1437 yyps = save->save; 1438 save->save = NULL; 1439 yyFreeState(save); 1440 } 1441 while (yypath) 1442 { 1443 YYParseState *save = yypath; 1444 yypath = save->save; 1445 save->save = NULL; 1446 yyFreeState(save); 1447 } 1448#endif /* YYBTYACC */ 1449 yyfreestack(&yystack); 1450 return (yyresult); 1451} 1452