quote_calc3-s.tab.c revision 274475
1264790Sbapt/* original parser id follows */ 2264790Sbapt/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ 3264790Sbapt/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ 4264790Sbapt 5264790Sbapt#define YYBYACC 1 6264790Sbapt#define YYMAJOR 1 7264790Sbapt#define YYMINOR 9 8264790Sbapt#define YYCHECK "yyyymmdd" 9264790Sbapt 10264790Sbapt#define YYEMPTY (-1) 11264790Sbapt#define yyclearin (yychar = YYEMPTY) 12264790Sbapt#define yyerrok (yyerrflag = 0) 13264790Sbapt#define YYRECOVERING() (yyerrflag != 0) 14264790Sbapt#define YYENOMEM (-2) 15264790Sbapt#define YYEOF 0 16264790Sbapt 17264790Sbapt#ifndef yyparse 18264790Sbapt#define yyparse quote_calc3_parse 19264790Sbapt#endif /* yyparse */ 20264790Sbapt 21264790Sbapt#ifndef yylex 22264790Sbapt#define yylex quote_calc3_lex 23264790Sbapt#endif /* yylex */ 24264790Sbapt 25264790Sbapt#ifndef yyerror 26264790Sbapt#define yyerror quote_calc3_error 27264790Sbapt#endif /* yyerror */ 28264790Sbapt 29264790Sbapt#ifndef yychar 30264790Sbapt#define yychar quote_calc3_char 31264790Sbapt#endif /* yychar */ 32264790Sbapt 33264790Sbapt#ifndef yyval 34264790Sbapt#define yyval quote_calc3_val 35264790Sbapt#endif /* yyval */ 36264790Sbapt 37264790Sbapt#ifndef yylval 38264790Sbapt#define yylval quote_calc3_lval 39264790Sbapt#endif /* yylval */ 40264790Sbapt 41264790Sbapt#ifndef yydebug 42264790Sbapt#define yydebug quote_calc3_debug 43264790Sbapt#endif /* yydebug */ 44264790Sbapt 45264790Sbapt#ifndef yynerrs 46264790Sbapt#define yynerrs quote_calc3_nerrs 47264790Sbapt#endif /* yynerrs */ 48264790Sbapt 49264790Sbapt#ifndef yyerrflag 50264790Sbapt#define yyerrflag quote_calc3_errflag 51264790Sbapt#endif /* yyerrflag */ 52264790Sbapt 53264790Sbapt#ifndef yylhs 54264790Sbapt#define yylhs quote_calc3_lhs 55264790Sbapt#endif /* yylhs */ 56264790Sbapt 57264790Sbapt#ifndef yylen 58264790Sbapt#define yylen quote_calc3_len 59264790Sbapt#endif /* yylen */ 60264790Sbapt 61264790Sbapt#ifndef yydefred 62264790Sbapt#define yydefred quote_calc3_defred 63264790Sbapt#endif /* yydefred */ 64264790Sbapt 65264790Sbapt#ifndef yydgoto 66264790Sbapt#define yydgoto quote_calc3_dgoto 67264790Sbapt#endif /* yydgoto */ 68264790Sbapt 69264790Sbapt#ifndef yysindex 70264790Sbapt#define yysindex quote_calc3_sindex 71264790Sbapt#endif /* yysindex */ 72264790Sbapt 73264790Sbapt#ifndef yyrindex 74264790Sbapt#define yyrindex quote_calc3_rindex 75264790Sbapt#endif /* yyrindex */ 76264790Sbapt 77264790Sbapt#ifndef yygindex 78264790Sbapt#define yygindex quote_calc3_gindex 79264790Sbapt#endif /* yygindex */ 80264790Sbapt 81264790Sbapt#ifndef yytable 82264790Sbapt#define yytable quote_calc3_table 83264790Sbapt#endif /* yytable */ 84264790Sbapt 85264790Sbapt#ifndef yycheck 86264790Sbapt#define yycheck quote_calc3_check 87264790Sbapt#endif /* yycheck */ 88264790Sbapt 89264790Sbapt#ifndef yyname 90264790Sbapt#define yyname quote_calc3_name 91264790Sbapt#endif /* yyname */ 92264790Sbapt 93264790Sbapt#ifndef yyrule 94264790Sbapt#define yyrule quote_calc3_rule 95264790Sbapt#endif /* yyrule */ 96264790Sbapt#define YYPREFIX "quote_calc3_" 97264790Sbapt 98264790Sbapt#define YYPURE 0 99264790Sbapt 100264790Sbapt#line 2 "quote_calc3.y" 101264790Sbapt# include <stdio.h> 102264790Sbapt# include <ctype.h> 103264790Sbapt 104264790Sbaptint regs[26]; 105264790Sbaptint base; 106264790Sbapt 107264790Sbaptint yylex(void); 108264790Sbaptstatic void yyerror(const char *s); 109264790Sbapt 110264790Sbapt#line 111 "quote_calc3-s.tab.c" 111264790Sbapt 112264790Sbapt#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) 113264790Sbapt/* Default: YYSTYPE is the semantic value type. */ 114264790Sbapttypedef int YYSTYPE; 115264790Sbapt# define YYSTYPE_IS_DECLARED 1 116264790Sbapt#endif 117264790Sbapt 118264790Sbapt/* compatibility with bison */ 119264790Sbapt#ifdef YYPARSE_PARAM 120264790Sbapt/* compatibility with FreeBSD */ 121264790Sbapt# ifdef YYPARSE_PARAM_TYPE 122264790Sbapt# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) 123264790Sbapt# else 124264790Sbapt# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) 125264790Sbapt# endif 126264790Sbapt#else 127264790Sbapt# define YYPARSE_DECL() yyparse(void) 128264790Sbapt#endif 129264790Sbapt 130264790Sbapt/* Parameters sent to lex. */ 131264790Sbapt#ifdef YYLEX_PARAM 132264790Sbapt# define YYLEX_DECL() yylex(void *YYLEX_PARAM) 133264790Sbapt# define YYLEX yylex(YYLEX_PARAM) 134264790Sbapt#else 135264790Sbapt# define YYLEX_DECL() yylex(void) 136264790Sbapt# define YYLEX yylex() 137264790Sbapt#endif 138264790Sbapt 139264790Sbapt/* Parameters sent to yyerror. */ 140264790Sbapt#ifndef YYERROR_DECL 141264790Sbapt#define YYERROR_DECL() yyerror(const char *s) 142264790Sbapt#endif 143264790Sbapt#ifndef YYERROR_CALL 144264790Sbapt#define YYERROR_CALL(msg) yyerror(msg) 145264790Sbapt#endif 146264790Sbapt 147264790Sbaptextern int YYPARSE_DECL(); 148264790Sbapt 149264790Sbapt#define OP_ADD 257 150264790Sbapt#define OP_SUB 259 151264790Sbapt#define OP_MUL 261 152264790Sbapt#define OP_DIV 263 153264790Sbapt#define OP_MOD 265 154264790Sbapt#define OP_AND 267 155264790Sbapt#define DIGIT 269 156264790Sbapt#define LETTER 270 157264790Sbapt#define UMINUS 271 158264790Sbapt#define YYERRCODE 256 159274475Sjkimtypedef int YYINT; 160264790Sbaptstatic const YYINT quote_calc3_lhs[] = { -1, 161264790Sbapt 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, 162264790Sbapt 2, 2, 2, 2, 2, 2, 3, 3, 163264790Sbapt}; 164264790Sbaptstatic const YYINT quote_calc3_len[] = { 2, 165264790Sbapt 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, 166264790Sbapt 3, 3, 3, 2, 1, 1, 1, 2, 167264790Sbapt}; 168264790Sbaptstatic const YYINT quote_calc3_defred[] = { 1, 169264790Sbapt 0, 0, 0, 17, 0, 0, 0, 0, 0, 3, 170264790Sbapt 15, 0, 0, 0, 2, 0, 0, 0, 0, 0, 171264790Sbapt 0, 0, 18, 0, 6, 0, 0, 0, 0, 0, 172264790Sbapt 0, 0, 173264790Sbapt}; 174264790Sbaptstatic const YYINT quote_calc3_dgoto[] = { 1, 175264790Sbapt 7, 8, 9, 176264790Sbapt}; 177264790Sbaptstatic const YYINT quote_calc3_sindex[] = { 0, 178264790Sbapt -38, 5, -36, 0, -51, -36, 7, -121, -248, 0, 179264790Sbapt 0, -243, -36, -22, 0, -36, -36, -36, -36, -36, 180264790Sbapt -36, -36, 0, -121, 0, -121, -121, -121, -121, -121, 181264790Sbapt -121, -243, 182264790Sbapt}; 183264790Sbaptstatic const YYINT quote_calc3_rindex[] = { 0, 184264790Sbapt 0, 0, 0, 0, -9, 0, 0, 13, -10, 0, 185264790Sbapt 0, -5, 0, 0, 0, 0, 0, 0, 0, 0, 186264790Sbapt 0, 0, 0, 15, 0, -3, -2, -1, 1, 2, 187264790Sbapt 3, -4, 188264790Sbapt}; 189264790Sbaptstatic const YYINT quote_calc3_gindex[] = { 0, 190264790Sbapt 0, 42, 0, 191264790Sbapt}; 192264790Sbapt#define YYTABLESIZE 258 193264790Sbaptstatic const YYINT quote_calc3_table[] = { 16, 194264790Sbapt 15, 6, 22, 6, 14, 13, 7, 8, 9, 13, 195264790Sbapt 10, 11, 12, 16, 10, 17, 15, 18, 25, 19, 196264790Sbapt 23, 20, 4, 21, 5, 0, 0, 0, 0, 0, 197264790Sbapt 16, 0, 0, 0, 0, 14, 13, 7, 8, 9, 198264790Sbapt 0, 10, 11, 12, 12, 0, 0, 14, 0, 0, 199264790Sbapt 0, 0, 0, 0, 24, 0, 0, 26, 27, 28, 200264790Sbapt 29, 30, 31, 32, 0, 0, 0, 0, 0, 0, 201264790Sbapt 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 202264790Sbapt 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 203264790Sbapt 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 204264790Sbapt 0, 22, 0, 0, 0, 0, 0, 0, 0, 0, 205264790Sbapt 0, 0, 0, 16, 15, 0, 0, 0, 14, 13, 206264790Sbapt 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 207264790Sbapt 0, 0, 0, 0, 0, 16, 0, 17, 0, 18, 208264790Sbapt 0, 19, 0, 20, 0, 21, 0, 0, 0, 0, 209264790Sbapt 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 210264790Sbapt 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 211264790Sbapt 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 212264790Sbapt 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 213264790Sbapt 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 214264790Sbapt 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 215264790Sbapt 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 216264790Sbapt 3, 0, 3, 0, 0, 0, 0, 0, 0, 0, 217264790Sbapt 4, 5, 4, 11, 16, 0, 17, 0, 18, 0, 218264790Sbapt 19, 0, 20, 0, 21, 0, 16, 15, 16, 15, 219264790Sbapt 16, 15, 16, 15, 16, 15, 16, 15, 220264790Sbapt}; 221264790Sbaptstatic const YYINT quote_calc3_check[] = { 10, 222264790Sbapt 10, 40, 124, 40, 10, 10, 10, 10, 10, 61, 223264790Sbapt 10, 10, 10, 257, 10, 259, 10, 261, 41, 263, 224264790Sbapt 269, 265, 10, 267, 10, -1, -1, -1, -1, -1, 225264790Sbapt 41, -1, -1, -1, -1, 41, 41, 41, 41, 41, 226264790Sbapt -1, 41, 41, 41, 3, -1, -1, 6, -1, -1, 227264790Sbapt -1, -1, -1, -1, 13, -1, -1, 16, 17, 18, 228264790Sbapt 19, 20, 21, 22, -1, -1, -1, -1, -1, -1, 229264790Sbapt -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 230264790Sbapt -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 231264790Sbapt -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 232264790Sbapt -1, 124, -1, -1, -1, -1, -1, -1, -1, -1, 233264790Sbapt -1, -1, -1, 124, 124, -1, -1, -1, 124, 124, 234264790Sbapt -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 235264790Sbapt -1, -1, -1, -1, -1, 257, -1, 259, -1, 261, 236264790Sbapt -1, 263, -1, 265, -1, 267, -1, -1, -1, -1, 237264790Sbapt -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 238264790Sbapt -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 239264790Sbapt -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 240264790Sbapt -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 241264790Sbapt -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 242264790Sbapt -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 243264790Sbapt -1, -1, -1, -1, -1, -1, -1, 256, -1, -1, 244264790Sbapt 259, -1, 259, -1, -1, -1, -1, -1, -1, -1, 245264790Sbapt 269, 270, 269, 270, 257, -1, 259, -1, 261, -1, 246264790Sbapt 263, -1, 265, -1, 267, -1, 257, 257, 259, 259, 247264790Sbapt 261, 261, 263, 263, 265, 265, 267, 267, 248264790Sbapt}; 249264790Sbapt#define YYFINAL 1 250264790Sbapt#ifndef YYDEBUG 251264790Sbapt#define YYDEBUG 0 252264790Sbapt#endif 253264790Sbapt#define YYMAXTOKEN 271 254264790Sbapt#define YYUNDFTOKEN 277 255264790Sbapt#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) 256264790Sbapt#if YYDEBUG 257264790Sbaptstatic const char *const quote_calc3_name[] = { 258264790Sbapt 259264790Sbapt"end-of-file",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, 260264790Sbapt0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0, 261264790Sbapt0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 262264790Sbapt0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0, 263264790Sbapt0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 264264790Sbapt0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 265264790Sbapt0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 266264790Sbapt0,0,0,0,0,0,"OP_ADD","\"ADD-operator\"","OP_SUB","\"SUB-operator\"","OP_MUL", 267264790Sbapt"\"MUL-operator\"","OP_DIV","\"DIV-operator\"","OP_MOD","\"MOD-operator\"", 268264790Sbapt"OP_AND","\"AND-operator\"","DIGIT","LETTER","UMINUS",0,0,0,0,0, 269264790Sbapt"illegal-symbol", 270264790Sbapt}; 271264790Sbaptstatic const char *const quote_calc3_rule[] = { 272264790Sbapt"$accept : list", 273264790Sbapt"list :", 274264790Sbapt"list : list stat '\\n'", 275264790Sbapt"list : list error '\\n'", 276264790Sbapt"stat : expr", 277264790Sbapt"stat : LETTER '=' expr", 278264790Sbapt"expr : '(' expr ')'", 279264790Sbapt"expr : expr OP_ADD expr", 280264790Sbapt"expr : expr OP_SUB expr", 281264790Sbapt"expr : expr OP_MUL expr", 282264790Sbapt"expr : expr OP_DIV expr", 283264790Sbapt"expr : expr OP_MOD expr", 284264790Sbapt"expr : expr OP_AND expr", 285264790Sbapt"expr : expr '|' expr", 286264790Sbapt"expr : OP_SUB expr", 287264790Sbapt"expr : LETTER", 288264790Sbapt"expr : number", 289264790Sbapt"number : DIGIT", 290264790Sbapt"number : number DIGIT", 291264790Sbapt 292264790Sbapt}; 293264790Sbapt#endif 294264790Sbapt 295264790Sbaptint yydebug; 296264790Sbaptint yynerrs; 297264790Sbapt 298264790Sbaptint yyerrflag; 299264790Sbaptint yychar; 300264790SbaptYYSTYPE yyval; 301264790SbaptYYSTYPE yylval; 302264790Sbapt 303264790Sbapt/* define the initial stack-sizes */ 304264790Sbapt#ifdef YYSTACKSIZE 305264790Sbapt#undef YYMAXDEPTH 306264790Sbapt#define YYMAXDEPTH YYSTACKSIZE 307264790Sbapt#else 308264790Sbapt#ifdef YYMAXDEPTH 309264790Sbapt#define YYSTACKSIZE YYMAXDEPTH 310264790Sbapt#else 311264790Sbapt#define YYSTACKSIZE 10000 312264790Sbapt#define YYMAXDEPTH 10000 313264790Sbapt#endif 314264790Sbapt#endif 315264790Sbapt 316264790Sbapt#define YYINITSTACKSIZE 200 317264790Sbapt 318264790Sbapttypedef struct { 319264790Sbapt unsigned stacksize; 320264790Sbapt YYINT *s_base; 321264790Sbapt YYINT *s_mark; 322264790Sbapt YYINT *s_last; 323264790Sbapt YYSTYPE *l_base; 324264790Sbapt YYSTYPE *l_mark; 325264790Sbapt} YYSTACKDATA; 326264790Sbapt/* variables for the parser stack */ 327264790Sbaptstatic YYSTACKDATA yystack; 328264790Sbapt#line 73 "quote_calc3.y" 329264790Sbapt /* start of programs */ 330264790Sbapt 331264790Sbaptint 332264790Sbaptmain (void) 333264790Sbapt{ 334264790Sbapt while(!feof(stdin)) { 335264790Sbapt yyparse(); 336264790Sbapt } 337264790Sbapt return 0; 338264790Sbapt} 339264790Sbapt 340264790Sbaptstatic void 341264790Sbaptyyerror(const char *s) 342264790Sbapt{ 343264790Sbapt fprintf(stderr, "%s\n", s); 344264790Sbapt} 345264790Sbapt 346264790Sbaptint 347264790Sbaptyylex(void) { 348264790Sbapt /* lexical analysis routine */ 349264790Sbapt /* returns LETTER for a lower case letter, yylval = 0 through 25 */ 350264790Sbapt /* return DIGIT for a digit, yylval = 0 through 9 */ 351264790Sbapt /* all other characters are returned immediately */ 352264790Sbapt 353264790Sbapt int c; 354264790Sbapt 355264790Sbapt while( (c=getchar()) == ' ' ) { /* skip blanks */ } 356264790Sbapt 357264790Sbapt /* c is now nonblank */ 358264790Sbapt 359264790Sbapt if( islower( c )) { 360264790Sbapt yylval = c - 'a'; 361264790Sbapt return ( LETTER ); 362264790Sbapt } 363264790Sbapt if( isdigit( c )) { 364264790Sbapt yylval = c - '0'; 365264790Sbapt return ( DIGIT ); 366264790Sbapt } 367264790Sbapt return( c ); 368264790Sbapt} 369264790Sbapt#line 370 "quote_calc3-s.tab.c" 370264790Sbapt 371264790Sbapt#if YYDEBUG 372264790Sbapt#include <stdio.h> /* needed for printf */ 373264790Sbapt#endif 374264790Sbapt 375264790Sbapt#include <stdlib.h> /* needed for malloc, etc */ 376264790Sbapt#include <string.h> /* needed for memset */ 377264790Sbapt 378264790Sbapt/* allocate initial stack or double stack size, up to YYMAXDEPTH */ 379264790Sbaptstatic int yygrowstack(YYSTACKDATA *data) 380264790Sbapt{ 381264790Sbapt int i; 382264790Sbapt unsigned newsize; 383264790Sbapt YYINT *newss; 384264790Sbapt YYSTYPE *newvs; 385264790Sbapt 386264790Sbapt if ((newsize = data->stacksize) == 0) 387264790Sbapt newsize = YYINITSTACKSIZE; 388264790Sbapt else if (newsize >= YYMAXDEPTH) 389264790Sbapt return YYENOMEM; 390264790Sbapt else if ((newsize *= 2) > YYMAXDEPTH) 391264790Sbapt newsize = YYMAXDEPTH; 392264790Sbapt 393264790Sbapt i = (int) (data->s_mark - data->s_base); 394264790Sbapt newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); 395264790Sbapt if (newss == 0) 396264790Sbapt return YYENOMEM; 397264790Sbapt 398264790Sbapt data->s_base = newss; 399264790Sbapt data->s_mark = newss + i; 400264790Sbapt 401264790Sbapt newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); 402264790Sbapt if (newvs == 0) 403264790Sbapt return YYENOMEM; 404264790Sbapt 405264790Sbapt data->l_base = newvs; 406264790Sbapt data->l_mark = newvs + i; 407264790Sbapt 408264790Sbapt data->stacksize = newsize; 409264790Sbapt data->s_last = data->s_base + newsize - 1; 410264790Sbapt return 0; 411264790Sbapt} 412264790Sbapt 413264790Sbapt#if YYPURE || defined(YY_NO_LEAKS) 414264790Sbaptstatic void yyfreestack(YYSTACKDATA *data) 415264790Sbapt{ 416264790Sbapt free(data->s_base); 417264790Sbapt free(data->l_base); 418264790Sbapt memset(data, 0, sizeof(*data)); 419264790Sbapt} 420264790Sbapt#else 421264790Sbapt#define yyfreestack(data) /* nothing */ 422264790Sbapt#endif 423264790Sbapt 424264790Sbapt#define YYABORT goto yyabort 425264790Sbapt#define YYREJECT goto yyabort 426264790Sbapt#define YYACCEPT goto yyaccept 427264790Sbapt#define YYERROR goto yyerrlab 428264790Sbapt 429264790Sbaptint 430264790SbaptYYPARSE_DECL() 431264790Sbapt{ 432264790Sbapt int yym, yyn, yystate; 433264790Sbapt#if YYDEBUG 434264790Sbapt const char *yys; 435264790Sbapt 436264790Sbapt if ((yys = getenv("YYDEBUG")) != 0) 437264790Sbapt { 438264790Sbapt yyn = *yys; 439264790Sbapt if (yyn >= '0' && yyn <= '9') 440264790Sbapt yydebug = yyn - '0'; 441264790Sbapt } 442264790Sbapt#endif 443264790Sbapt 444264790Sbapt yynerrs = 0; 445264790Sbapt yyerrflag = 0; 446264790Sbapt yychar = YYEMPTY; 447264790Sbapt yystate = 0; 448264790Sbapt 449264790Sbapt#if YYPURE 450264790Sbapt memset(&yystack, 0, sizeof(yystack)); 451264790Sbapt#endif 452264790Sbapt 453264790Sbapt if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 454264790Sbapt yystack.s_mark = yystack.s_base; 455264790Sbapt yystack.l_mark = yystack.l_base; 456264790Sbapt yystate = 0; 457264790Sbapt *yystack.s_mark = 0; 458264790Sbapt 459264790Sbaptyyloop: 460264790Sbapt if ((yyn = yydefred[yystate]) != 0) goto yyreduce; 461264790Sbapt if (yychar < 0) 462264790Sbapt { 463264790Sbapt if ((yychar = YYLEX) < 0) yychar = YYEOF; 464264790Sbapt#if YYDEBUG 465264790Sbapt if (yydebug) 466264790Sbapt { 467264790Sbapt yys = yyname[YYTRANSLATE(yychar)]; 468264790Sbapt printf("%sdebug: state %d, reading %d (%s)\n", 469264790Sbapt YYPREFIX, yystate, yychar, yys); 470264790Sbapt } 471264790Sbapt#endif 472264790Sbapt } 473264790Sbapt if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && 474264790Sbapt yyn <= YYTABLESIZE && yycheck[yyn] == yychar) 475264790Sbapt { 476264790Sbapt#if YYDEBUG 477264790Sbapt if (yydebug) 478264790Sbapt printf("%sdebug: state %d, shifting to state %d\n", 479264790Sbapt YYPREFIX, yystate, yytable[yyn]); 480264790Sbapt#endif 481264790Sbapt if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) 482264790Sbapt { 483264790Sbapt goto yyoverflow; 484264790Sbapt } 485264790Sbapt yystate = yytable[yyn]; 486264790Sbapt *++yystack.s_mark = yytable[yyn]; 487264790Sbapt *++yystack.l_mark = yylval; 488264790Sbapt yychar = YYEMPTY; 489264790Sbapt if (yyerrflag > 0) --yyerrflag; 490264790Sbapt goto yyloop; 491264790Sbapt } 492264790Sbapt if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && 493264790Sbapt yyn <= YYTABLESIZE && yycheck[yyn] == yychar) 494264790Sbapt { 495264790Sbapt yyn = yytable[yyn]; 496264790Sbapt goto yyreduce; 497264790Sbapt } 498264790Sbapt if (yyerrflag) goto yyinrecovery; 499264790Sbapt 500264790Sbapt YYERROR_CALL("syntax error"); 501264790Sbapt 502264790Sbapt goto yyerrlab; 503264790Sbapt 504264790Sbaptyyerrlab: 505264790Sbapt ++yynerrs; 506264790Sbapt 507264790Sbaptyyinrecovery: 508264790Sbapt if (yyerrflag < 3) 509264790Sbapt { 510264790Sbapt yyerrflag = 3; 511264790Sbapt for (;;) 512264790Sbapt { 513264790Sbapt if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 && 514264790Sbapt yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) 515264790Sbapt { 516264790Sbapt#if YYDEBUG 517264790Sbapt if (yydebug) 518264790Sbapt printf("%sdebug: state %d, error recovery shifting\ 519264790Sbapt to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); 520264790Sbapt#endif 521264790Sbapt if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) 522264790Sbapt { 523264790Sbapt goto yyoverflow; 524264790Sbapt } 525264790Sbapt yystate = yytable[yyn]; 526264790Sbapt *++yystack.s_mark = yytable[yyn]; 527264790Sbapt *++yystack.l_mark = yylval; 528264790Sbapt goto yyloop; 529264790Sbapt } 530264790Sbapt else 531264790Sbapt { 532264790Sbapt#if YYDEBUG 533264790Sbapt if (yydebug) 534264790Sbapt printf("%sdebug: error recovery discarding state %d\n", 535264790Sbapt YYPREFIX, *yystack.s_mark); 536264790Sbapt#endif 537264790Sbapt if (yystack.s_mark <= yystack.s_base) goto yyabort; 538264790Sbapt --yystack.s_mark; 539264790Sbapt --yystack.l_mark; 540264790Sbapt } 541264790Sbapt } 542264790Sbapt } 543264790Sbapt else 544264790Sbapt { 545264790Sbapt if (yychar == YYEOF) goto yyabort; 546264790Sbapt#if YYDEBUG 547264790Sbapt if (yydebug) 548264790Sbapt { 549264790Sbapt yys = yyname[YYTRANSLATE(yychar)]; 550264790Sbapt printf("%sdebug: state %d, error recovery discards token %d (%s)\n", 551264790Sbapt YYPREFIX, yystate, yychar, yys); 552264790Sbapt } 553264790Sbapt#endif 554264790Sbapt yychar = YYEMPTY; 555264790Sbapt goto yyloop; 556264790Sbapt } 557264790Sbapt 558264790Sbaptyyreduce: 559264790Sbapt#if YYDEBUG 560264790Sbapt if (yydebug) 561264790Sbapt printf("%sdebug: state %d, reducing by rule %d (%s)\n", 562264790Sbapt YYPREFIX, yystate, yyn, yyrule[yyn]); 563264790Sbapt#endif 564264790Sbapt yym = yylen[yyn]; 565264790Sbapt if (yym) 566264790Sbapt yyval = yystack.l_mark[1-yym]; 567264790Sbapt else 568264790Sbapt memset(&yyval, 0, sizeof yyval); 569264790Sbapt switch (yyn) 570264790Sbapt { 571264790Sbaptcase 3: 572264790Sbapt#line 35 "quote_calc3.y" 573264790Sbapt { yyerrok ; } 574264790Sbaptbreak; 575264790Sbaptcase 4: 576264790Sbapt#line 39 "quote_calc3.y" 577264790Sbapt { printf("%d\n",yystack.l_mark[0]);} 578264790Sbaptbreak; 579264790Sbaptcase 5: 580264790Sbapt#line 41 "quote_calc3.y" 581264790Sbapt { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } 582264790Sbaptbreak; 583264790Sbaptcase 6: 584264790Sbapt#line 45 "quote_calc3.y" 585264790Sbapt { yyval = yystack.l_mark[-1]; } 586264790Sbaptbreak; 587264790Sbaptcase 7: 588264790Sbapt#line 47 "quote_calc3.y" 589264790Sbapt { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } 590264790Sbaptbreak; 591264790Sbaptcase 8: 592264790Sbapt#line 49 "quote_calc3.y" 593264790Sbapt { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } 594264790Sbaptbreak; 595264790Sbaptcase 9: 596264790Sbapt#line 51 "quote_calc3.y" 597264790Sbapt { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } 598264790Sbaptbreak; 599264790Sbaptcase 10: 600264790Sbapt#line 53 "quote_calc3.y" 601264790Sbapt { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } 602264790Sbaptbreak; 603264790Sbaptcase 11: 604264790Sbapt#line 55 "quote_calc3.y" 605264790Sbapt { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } 606264790Sbaptbreak; 607264790Sbaptcase 12: 608264790Sbapt#line 57 "quote_calc3.y" 609264790Sbapt { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } 610264790Sbaptbreak; 611264790Sbaptcase 13: 612264790Sbapt#line 59 "quote_calc3.y" 613264790Sbapt { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } 614264790Sbaptbreak; 615264790Sbaptcase 14: 616264790Sbapt#line 61 "quote_calc3.y" 617264790Sbapt { yyval = - yystack.l_mark[0]; } 618264790Sbaptbreak; 619264790Sbaptcase 15: 620264790Sbapt#line 63 "quote_calc3.y" 621264790Sbapt { yyval = regs[yystack.l_mark[0]]; } 622264790Sbaptbreak; 623264790Sbaptcase 17: 624264790Sbapt#line 68 "quote_calc3.y" 625264790Sbapt { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } 626264790Sbaptbreak; 627264790Sbaptcase 18: 628264790Sbapt#line 70 "quote_calc3.y" 629264790Sbapt { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } 630264790Sbaptbreak; 631264790Sbapt#line 632 "quote_calc3-s.tab.c" 632264790Sbapt } 633264790Sbapt yystack.s_mark -= yym; 634264790Sbapt yystate = *yystack.s_mark; 635264790Sbapt yystack.l_mark -= yym; 636264790Sbapt yym = yylhs[yyn]; 637264790Sbapt if (yystate == 0 && yym == 0) 638264790Sbapt { 639264790Sbapt#if YYDEBUG 640264790Sbapt if (yydebug) 641264790Sbapt printf("%sdebug: after reduction, shifting from state 0 to\ 642264790Sbapt state %d\n", YYPREFIX, YYFINAL); 643264790Sbapt#endif 644264790Sbapt yystate = YYFINAL; 645264790Sbapt *++yystack.s_mark = YYFINAL; 646264790Sbapt *++yystack.l_mark = yyval; 647264790Sbapt if (yychar < 0) 648264790Sbapt { 649264790Sbapt if ((yychar = YYLEX) < 0) yychar = YYEOF; 650264790Sbapt#if YYDEBUG 651264790Sbapt if (yydebug) 652264790Sbapt { 653264790Sbapt yys = yyname[YYTRANSLATE(yychar)]; 654264790Sbapt printf("%sdebug: state %d, reading %d (%s)\n", 655264790Sbapt YYPREFIX, YYFINAL, yychar, yys); 656264790Sbapt } 657264790Sbapt#endif 658264790Sbapt } 659264790Sbapt if (yychar == YYEOF) goto yyaccept; 660264790Sbapt goto yyloop; 661264790Sbapt } 662264790Sbapt if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && 663264790Sbapt yyn <= YYTABLESIZE && yycheck[yyn] == yystate) 664264790Sbapt yystate = yytable[yyn]; 665264790Sbapt else 666264790Sbapt yystate = yydgoto[yym]; 667264790Sbapt#if YYDEBUG 668264790Sbapt if (yydebug) 669264790Sbapt printf("%sdebug: after reduction, shifting from state %d \ 670264790Sbaptto state %d\n", YYPREFIX, *yystack.s_mark, yystate); 671264790Sbapt#endif 672264790Sbapt if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) 673264790Sbapt { 674264790Sbapt goto yyoverflow; 675264790Sbapt } 676264790Sbapt *++yystack.s_mark = (YYINT) yystate; 677264790Sbapt *++yystack.l_mark = yyval; 678264790Sbapt goto yyloop; 679264790Sbapt 680264790Sbaptyyoverflow: 681264790Sbapt YYERROR_CALL("yacc stack overflow"); 682264790Sbapt 683264790Sbaptyyabort: 684264790Sbapt yyfreestack(&yystack); 685264790Sbapt return (1); 686264790Sbapt 687264790Sbaptyyaccept: 688264790Sbapt yyfreestack(&yystack); 689264790Sbapt return (0); 690264790Sbapt} 691