1*0c8de5b0SBaptiste Daroussin /* original parser id follows */ 2*0c8de5b0SBaptiste Daroussin /* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ 3*0c8de5b0SBaptiste Daroussin /* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ 4*0c8de5b0SBaptiste Daroussin 5*0c8de5b0SBaptiste Daroussin #define YYBYACC 1 6*0c8de5b0SBaptiste Daroussin #define YYMAJOR 1 7*0c8de5b0SBaptiste Daroussin #define YYMINOR 9 8*0c8de5b0SBaptiste Daroussin #define YYCHECK "yyyymmdd" 9*0c8de5b0SBaptiste Daroussin 10*0c8de5b0SBaptiste Daroussin #define YYEMPTY (-1) 11*0c8de5b0SBaptiste Daroussin #define yyclearin (yychar = YYEMPTY) 12*0c8de5b0SBaptiste Daroussin #define yyerrok (yyerrflag = 0) 13*0c8de5b0SBaptiste Daroussin #define YYRECOVERING() (yyerrflag != 0) 14*0c8de5b0SBaptiste Daroussin #define YYENOMEM (-2) 15*0c8de5b0SBaptiste Daroussin #define YYEOF 0 16*0c8de5b0SBaptiste Daroussin 17*0c8de5b0SBaptiste Daroussin #ifndef yyparse 18*0c8de5b0SBaptiste Daroussin #define yyparse calc_parse 19*0c8de5b0SBaptiste Daroussin #endif /* yyparse */ 20*0c8de5b0SBaptiste Daroussin 21*0c8de5b0SBaptiste Daroussin #ifndef yylex 22*0c8de5b0SBaptiste Daroussin #define yylex calc_lex 23*0c8de5b0SBaptiste Daroussin #endif /* yylex */ 24*0c8de5b0SBaptiste Daroussin 25*0c8de5b0SBaptiste Daroussin #ifndef yyerror 26*0c8de5b0SBaptiste Daroussin #define yyerror calc_error 27*0c8de5b0SBaptiste Daroussin #endif /* yyerror */ 28*0c8de5b0SBaptiste Daroussin 29*0c8de5b0SBaptiste Daroussin #ifndef yychar 30*0c8de5b0SBaptiste Daroussin #define yychar calc_char 31*0c8de5b0SBaptiste Daroussin #endif /* yychar */ 32*0c8de5b0SBaptiste Daroussin 33*0c8de5b0SBaptiste Daroussin #ifndef yyval 34*0c8de5b0SBaptiste Daroussin #define yyval calc_val 35*0c8de5b0SBaptiste Daroussin #endif /* yyval */ 36*0c8de5b0SBaptiste Daroussin 37*0c8de5b0SBaptiste Daroussin #ifndef yylval 38*0c8de5b0SBaptiste Daroussin #define yylval calc_lval 39*0c8de5b0SBaptiste Daroussin #endif /* yylval */ 40*0c8de5b0SBaptiste Daroussin 41*0c8de5b0SBaptiste Daroussin #ifndef yydebug 42*0c8de5b0SBaptiste Daroussin #define yydebug calc_debug 43*0c8de5b0SBaptiste Daroussin #endif /* yydebug */ 44*0c8de5b0SBaptiste Daroussin 45*0c8de5b0SBaptiste Daroussin #ifndef yynerrs 46*0c8de5b0SBaptiste Daroussin #define yynerrs calc_nerrs 47*0c8de5b0SBaptiste Daroussin #endif /* yynerrs */ 48*0c8de5b0SBaptiste Daroussin 49*0c8de5b0SBaptiste Daroussin #ifndef yyerrflag 50*0c8de5b0SBaptiste Daroussin #define yyerrflag calc_errflag 51*0c8de5b0SBaptiste Daroussin #endif /* yyerrflag */ 52*0c8de5b0SBaptiste Daroussin 53*0c8de5b0SBaptiste Daroussin #ifndef yylhs 54*0c8de5b0SBaptiste Daroussin #define yylhs calc_lhs 55*0c8de5b0SBaptiste Daroussin #endif /* yylhs */ 56*0c8de5b0SBaptiste Daroussin 57*0c8de5b0SBaptiste Daroussin #ifndef yylen 58*0c8de5b0SBaptiste Daroussin #define yylen calc_len 59*0c8de5b0SBaptiste Daroussin #endif /* yylen */ 60*0c8de5b0SBaptiste Daroussin 61*0c8de5b0SBaptiste Daroussin #ifndef yydefred 62*0c8de5b0SBaptiste Daroussin #define yydefred calc_defred 63*0c8de5b0SBaptiste Daroussin #endif /* yydefred */ 64*0c8de5b0SBaptiste Daroussin 65*0c8de5b0SBaptiste Daroussin #ifndef yydgoto 66*0c8de5b0SBaptiste Daroussin #define yydgoto calc_dgoto 67*0c8de5b0SBaptiste Daroussin #endif /* yydgoto */ 68*0c8de5b0SBaptiste Daroussin 69*0c8de5b0SBaptiste Daroussin #ifndef yysindex 70*0c8de5b0SBaptiste Daroussin #define yysindex calc_sindex 71*0c8de5b0SBaptiste Daroussin #endif /* yysindex */ 72*0c8de5b0SBaptiste Daroussin 73*0c8de5b0SBaptiste Daroussin #ifndef yyrindex 74*0c8de5b0SBaptiste Daroussin #define yyrindex calc_rindex 75*0c8de5b0SBaptiste Daroussin #endif /* yyrindex */ 76*0c8de5b0SBaptiste Daroussin 77*0c8de5b0SBaptiste Daroussin #ifndef yygindex 78*0c8de5b0SBaptiste Daroussin #define yygindex calc_gindex 79*0c8de5b0SBaptiste Daroussin #endif /* yygindex */ 80*0c8de5b0SBaptiste Daroussin 81*0c8de5b0SBaptiste Daroussin #ifndef yytable 82*0c8de5b0SBaptiste Daroussin #define yytable calc_table 83*0c8de5b0SBaptiste Daroussin #endif /* yytable */ 84*0c8de5b0SBaptiste Daroussin 85*0c8de5b0SBaptiste Daroussin #ifndef yycheck 86*0c8de5b0SBaptiste Daroussin #define yycheck calc_check 87*0c8de5b0SBaptiste Daroussin #endif /* yycheck */ 88*0c8de5b0SBaptiste Daroussin 89*0c8de5b0SBaptiste Daroussin #ifndef yyname 90*0c8de5b0SBaptiste Daroussin #define yyname calc_name 91*0c8de5b0SBaptiste Daroussin #endif /* yyname */ 92*0c8de5b0SBaptiste Daroussin 93*0c8de5b0SBaptiste Daroussin #ifndef yyrule 94*0c8de5b0SBaptiste Daroussin #define yyrule calc_rule 95*0c8de5b0SBaptiste Daroussin #endif /* yyrule */ 96*0c8de5b0SBaptiste Daroussin #define YYPREFIX "calc_" 97*0c8de5b0SBaptiste Daroussin 98*0c8de5b0SBaptiste Daroussin #define YYPURE 0 99*0c8de5b0SBaptiste Daroussin 100*0c8de5b0SBaptiste Daroussin #line 2 "calc.y" 101*0c8de5b0SBaptiste Daroussin # include <stdio.h> 102*0c8de5b0SBaptiste Daroussin # include <ctype.h> 103*0c8de5b0SBaptiste Daroussin 104*0c8de5b0SBaptiste Daroussin int regs[26]; 105*0c8de5b0SBaptiste Daroussin int base; 106*0c8de5b0SBaptiste Daroussin 107*0c8de5b0SBaptiste Daroussin extern int yylex(void); 108*0c8de5b0SBaptiste Daroussin static void yyerror(const char *s); 109*0c8de5b0SBaptiste Daroussin 110*0c8de5b0SBaptiste Daroussin #line 111 "calc.tab.c" 111*0c8de5b0SBaptiste Daroussin 112*0c8de5b0SBaptiste Daroussin #if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) 113*0c8de5b0SBaptiste Daroussin /* Default: YYSTYPE is the semantic value type. */ 114*0c8de5b0SBaptiste Daroussin typedef int YYSTYPE; 115*0c8de5b0SBaptiste Daroussin # define YYSTYPE_IS_DECLARED 1 116*0c8de5b0SBaptiste Daroussin #endif 117*0c8de5b0SBaptiste Daroussin 118*0c8de5b0SBaptiste Daroussin /* compatibility with bison */ 119*0c8de5b0SBaptiste Daroussin #ifdef YYPARSE_PARAM 120*0c8de5b0SBaptiste Daroussin /* compatibility with FreeBSD */ 121*0c8de5b0SBaptiste Daroussin # ifdef YYPARSE_PARAM_TYPE 122*0c8de5b0SBaptiste Daroussin # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) 123*0c8de5b0SBaptiste Daroussin # else 124*0c8de5b0SBaptiste Daroussin # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) 125*0c8de5b0SBaptiste Daroussin # endif 126*0c8de5b0SBaptiste Daroussin #else 127*0c8de5b0SBaptiste Daroussin # define YYPARSE_DECL() yyparse(void) 128*0c8de5b0SBaptiste Daroussin #endif 129*0c8de5b0SBaptiste Daroussin 130*0c8de5b0SBaptiste Daroussin /* Parameters sent to lex. */ 131*0c8de5b0SBaptiste Daroussin #ifdef YYLEX_PARAM 132*0c8de5b0SBaptiste Daroussin # define YYLEX_DECL() yylex(void *YYLEX_PARAM) 133*0c8de5b0SBaptiste Daroussin # define YYLEX yylex(YYLEX_PARAM) 134*0c8de5b0SBaptiste Daroussin #else 135*0c8de5b0SBaptiste Daroussin # define YYLEX_DECL() yylex(void) 136*0c8de5b0SBaptiste Daroussin # define YYLEX yylex() 137*0c8de5b0SBaptiste Daroussin #endif 138*0c8de5b0SBaptiste Daroussin 139*0c8de5b0SBaptiste Daroussin /* Parameters sent to yyerror. */ 140*0c8de5b0SBaptiste Daroussin #ifndef YYERROR_DECL 141*0c8de5b0SBaptiste Daroussin #define YYERROR_DECL() yyerror(const char *s) 142*0c8de5b0SBaptiste Daroussin #endif 143*0c8de5b0SBaptiste Daroussin #ifndef YYERROR_CALL 144*0c8de5b0SBaptiste Daroussin #define YYERROR_CALL(msg) yyerror(msg) 145*0c8de5b0SBaptiste Daroussin #endif 146*0c8de5b0SBaptiste Daroussin 147*0c8de5b0SBaptiste Daroussin extern int YYPARSE_DECL(); 148*0c8de5b0SBaptiste Daroussin 149*0c8de5b0SBaptiste Daroussin #define DIGIT 257 150*0c8de5b0SBaptiste Daroussin #define LETTER 258 151*0c8de5b0SBaptiste Daroussin #define UMINUS 259 152*0c8de5b0SBaptiste Daroussin #define YYERRCODE 256 153*0c8de5b0SBaptiste Daroussin typedef short YYINT; 154*0c8de5b0SBaptiste Daroussin static const YYINT calc_lhs[] = { -1, 155*0c8de5b0SBaptiste Daroussin 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, 156*0c8de5b0SBaptiste Daroussin 2, 2, 2, 2, 2, 2, 3, 3, 157*0c8de5b0SBaptiste Daroussin }; 158*0c8de5b0SBaptiste Daroussin static const YYINT calc_len[] = { 2, 159*0c8de5b0SBaptiste Daroussin 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, 160*0c8de5b0SBaptiste Daroussin 3, 3, 3, 2, 1, 1, 1, 2, 161*0c8de5b0SBaptiste Daroussin }; 162*0c8de5b0SBaptiste Daroussin static const YYINT calc_defred[] = { 1, 163*0c8de5b0SBaptiste Daroussin 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, 164*0c8de5b0SBaptiste Daroussin 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, 165*0c8de5b0SBaptiste Daroussin 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, 166*0c8de5b0SBaptiste Daroussin 10, 11, 167*0c8de5b0SBaptiste Daroussin }; 168*0c8de5b0SBaptiste Daroussin static const YYINT calc_dgoto[] = { 1, 169*0c8de5b0SBaptiste Daroussin 7, 8, 9, 170*0c8de5b0SBaptiste Daroussin }; 171*0c8de5b0SBaptiste Daroussin static const YYINT calc_sindex[] = { 0, 172*0c8de5b0SBaptiste Daroussin -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, 173*0c8de5b0SBaptiste Daroussin -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, 174*0c8de5b0SBaptiste Daroussin -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, 175*0c8de5b0SBaptiste Daroussin 0, 0, 176*0c8de5b0SBaptiste Daroussin }; 177*0c8de5b0SBaptiste Daroussin static const YYINT calc_rindex[] = { 0, 178*0c8de5b0SBaptiste Daroussin 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, 179*0c8de5b0SBaptiste Daroussin 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 180*0c8de5b0SBaptiste Daroussin 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, 181*0c8de5b0SBaptiste Daroussin 0, 0, 182*0c8de5b0SBaptiste Daroussin }; 183*0c8de5b0SBaptiste Daroussin static const YYINT calc_gindex[] = { 0, 184*0c8de5b0SBaptiste Daroussin 0, 65, 0, 185*0c8de5b0SBaptiste Daroussin }; 186*0c8de5b0SBaptiste Daroussin #define YYTABLESIZE 220 187*0c8de5b0SBaptiste Daroussin static const YYINT calc_table[] = { 6, 188*0c8de5b0SBaptiste Daroussin 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, 189*0c8de5b0SBaptiste Daroussin 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, 190*0c8de5b0SBaptiste Daroussin 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, 191*0c8de5b0SBaptiste Daroussin 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, 192*0c8de5b0SBaptiste Daroussin 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, 193*0c8de5b0SBaptiste Daroussin 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, 194*0c8de5b0SBaptiste Daroussin 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, 195*0c8de5b0SBaptiste Daroussin 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, 196*0c8de5b0SBaptiste Daroussin 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, 197*0c8de5b0SBaptiste Daroussin 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, 198*0c8de5b0SBaptiste Daroussin 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, 199*0c8de5b0SBaptiste Daroussin 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, 200*0c8de5b0SBaptiste Daroussin 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, 201*0c8de5b0SBaptiste Daroussin 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, 202*0c8de5b0SBaptiste Daroussin 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 203*0c8de5b0SBaptiste Daroussin 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 204*0c8de5b0SBaptiste Daroussin 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 205*0c8de5b0SBaptiste Daroussin 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 206*0c8de5b0SBaptiste Daroussin 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 207*0c8de5b0SBaptiste Daroussin 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 208*0c8de5b0SBaptiste Daroussin 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 209*0c8de5b0SBaptiste Daroussin 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, 210*0c8de5b0SBaptiste Daroussin }; 211*0c8de5b0SBaptiste Daroussin static const YYINT calc_check[] = { 40, 212*0c8de5b0SBaptiste Daroussin 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, 213*0c8de5b0SBaptiste Daroussin 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, 214*0c8de5b0SBaptiste Daroussin -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, 215*0c8de5b0SBaptiste Daroussin -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, 216*0c8de5b0SBaptiste Daroussin -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, 217*0c8de5b0SBaptiste Daroussin 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, 218*0c8de5b0SBaptiste Daroussin -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, 219*0c8de5b0SBaptiste Daroussin 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, 220*0c8de5b0SBaptiste Daroussin 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, 221*0c8de5b0SBaptiste Daroussin -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, 222*0c8de5b0SBaptiste Daroussin -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, 223*0c8de5b0SBaptiste Daroussin -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, 224*0c8de5b0SBaptiste Daroussin -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, 225*0c8de5b0SBaptiste Daroussin -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, 226*0c8de5b0SBaptiste Daroussin -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, 227*0c8de5b0SBaptiste Daroussin -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 228*0c8de5b0SBaptiste Daroussin -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 229*0c8de5b0SBaptiste Daroussin -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 230*0c8de5b0SBaptiste Daroussin -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 231*0c8de5b0SBaptiste Daroussin -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 232*0c8de5b0SBaptiste Daroussin -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 233*0c8de5b0SBaptiste Daroussin -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, 234*0c8de5b0SBaptiste Daroussin }; 235*0c8de5b0SBaptiste Daroussin #define YYFINAL 1 236*0c8de5b0SBaptiste Daroussin #ifndef YYDEBUG 237*0c8de5b0SBaptiste Daroussin #define YYDEBUG 0 238*0c8de5b0SBaptiste Daroussin #endif 239*0c8de5b0SBaptiste Daroussin #define YYMAXTOKEN 259 240*0c8de5b0SBaptiste Daroussin #define YYUNDFTOKEN 265 241*0c8de5b0SBaptiste Daroussin #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) 242*0c8de5b0SBaptiste Daroussin #if YYDEBUG 243*0c8de5b0SBaptiste Daroussin static const char *const calc_name[] = { 244*0c8de5b0SBaptiste Daroussin 245*0c8de5b0SBaptiste Daroussin "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, 246*0c8de5b0SBaptiste Daroussin 0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0, 247*0c8de5b0SBaptiste Daroussin 0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 248*0c8de5b0SBaptiste Daroussin 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0, 249*0c8de5b0SBaptiste Daroussin 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 250*0c8de5b0SBaptiste Daroussin 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 251*0c8de5b0SBaptiste Daroussin 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 252*0c8de5b0SBaptiste Daroussin 0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol", 253*0c8de5b0SBaptiste Daroussin }; 254*0c8de5b0SBaptiste Daroussin static const char *const calc_rule[] = { 255*0c8de5b0SBaptiste Daroussin "$accept : list", 256*0c8de5b0SBaptiste Daroussin "list :", 257*0c8de5b0SBaptiste Daroussin "list : list stat '\\n'", 258*0c8de5b0SBaptiste Daroussin "list : list error '\\n'", 259*0c8de5b0SBaptiste Daroussin "stat : expr", 260*0c8de5b0SBaptiste Daroussin "stat : LETTER '=' expr", 261*0c8de5b0SBaptiste Daroussin "expr : '(' expr ')'", 262*0c8de5b0SBaptiste Daroussin "expr : expr '+' expr", 263*0c8de5b0SBaptiste Daroussin "expr : expr '-' expr", 264*0c8de5b0SBaptiste Daroussin "expr : expr '*' expr", 265*0c8de5b0SBaptiste Daroussin "expr : expr '/' expr", 266*0c8de5b0SBaptiste Daroussin "expr : expr '%' expr", 267*0c8de5b0SBaptiste Daroussin "expr : expr '&' expr", 268*0c8de5b0SBaptiste Daroussin "expr : expr '|' expr", 269*0c8de5b0SBaptiste Daroussin "expr : '-' expr", 270*0c8de5b0SBaptiste Daroussin "expr : LETTER", 271*0c8de5b0SBaptiste Daroussin "expr : number", 272*0c8de5b0SBaptiste Daroussin "number : DIGIT", 273*0c8de5b0SBaptiste Daroussin "number : number DIGIT", 274*0c8de5b0SBaptiste Daroussin 275*0c8de5b0SBaptiste Daroussin }; 276*0c8de5b0SBaptiste Daroussin #endif 277*0c8de5b0SBaptiste Daroussin 278*0c8de5b0SBaptiste Daroussin int yydebug; 279*0c8de5b0SBaptiste Daroussin int yynerrs; 280*0c8de5b0SBaptiste Daroussin 281*0c8de5b0SBaptiste Daroussin int yyerrflag; 282*0c8de5b0SBaptiste Daroussin int yychar; 283*0c8de5b0SBaptiste Daroussin YYSTYPE yyval; 284*0c8de5b0SBaptiste Daroussin YYSTYPE yylval; 285*0c8de5b0SBaptiste Daroussin 286*0c8de5b0SBaptiste Daroussin /* define the initial stack-sizes */ 287*0c8de5b0SBaptiste Daroussin #ifdef YYSTACKSIZE 288*0c8de5b0SBaptiste Daroussin #undef YYMAXDEPTH 289*0c8de5b0SBaptiste Daroussin #define YYMAXDEPTH YYSTACKSIZE 290*0c8de5b0SBaptiste Daroussin #else 291*0c8de5b0SBaptiste Daroussin #ifdef YYMAXDEPTH 292*0c8de5b0SBaptiste Daroussin #define YYSTACKSIZE YYMAXDEPTH 293*0c8de5b0SBaptiste Daroussin #else 294*0c8de5b0SBaptiste Daroussin #define YYSTACKSIZE 10000 295*0c8de5b0SBaptiste Daroussin #define YYMAXDEPTH 10000 296*0c8de5b0SBaptiste Daroussin #endif 297*0c8de5b0SBaptiste Daroussin #endif 298*0c8de5b0SBaptiste Daroussin 299*0c8de5b0SBaptiste Daroussin #define YYINITSTACKSIZE 200 300*0c8de5b0SBaptiste Daroussin 301*0c8de5b0SBaptiste Daroussin typedef struct { 302*0c8de5b0SBaptiste Daroussin unsigned stacksize; 303*0c8de5b0SBaptiste Daroussin YYINT *s_base; 304*0c8de5b0SBaptiste Daroussin YYINT *s_mark; 305*0c8de5b0SBaptiste Daroussin YYINT *s_last; 306*0c8de5b0SBaptiste Daroussin YYSTYPE *l_base; 307*0c8de5b0SBaptiste Daroussin YYSTYPE *l_mark; 308*0c8de5b0SBaptiste Daroussin } YYSTACKDATA; 309*0c8de5b0SBaptiste Daroussin /* variables for the parser stack */ 310*0c8de5b0SBaptiste Daroussin static YYSTACKDATA yystack; 311*0c8de5b0SBaptiste Daroussin #line 66 "calc.y" 312*0c8de5b0SBaptiste Daroussin /* start of programs */ 313*0c8de5b0SBaptiste Daroussin 314*0c8de5b0SBaptiste Daroussin int 315*0c8de5b0SBaptiste Daroussin main (void) 316*0c8de5b0SBaptiste Daroussin { 317*0c8de5b0SBaptiste Daroussin while(!feof(stdin)) { 318*0c8de5b0SBaptiste Daroussin yyparse(); 319*0c8de5b0SBaptiste Daroussin } 320*0c8de5b0SBaptiste Daroussin return 0; 321*0c8de5b0SBaptiste Daroussin } 322*0c8de5b0SBaptiste Daroussin 323*0c8de5b0SBaptiste Daroussin static void 324*0c8de5b0SBaptiste Daroussin yyerror(const char *s) 325*0c8de5b0SBaptiste Daroussin { 326*0c8de5b0SBaptiste Daroussin fprintf(stderr, "%s\n", s); 327*0c8de5b0SBaptiste Daroussin } 328*0c8de5b0SBaptiste Daroussin 329*0c8de5b0SBaptiste Daroussin int 330*0c8de5b0SBaptiste Daroussin yylex(void) 331*0c8de5b0SBaptiste Daroussin { 332*0c8de5b0SBaptiste Daroussin /* lexical analysis routine */ 333*0c8de5b0SBaptiste Daroussin /* returns LETTER for a lower case letter, yylval = 0 through 25 */ 334*0c8de5b0SBaptiste Daroussin /* return DIGIT for a digit, yylval = 0 through 9 */ 335*0c8de5b0SBaptiste Daroussin /* all other characters are returned immediately */ 336*0c8de5b0SBaptiste Daroussin 337*0c8de5b0SBaptiste Daroussin int c; 338*0c8de5b0SBaptiste Daroussin 339*0c8de5b0SBaptiste Daroussin while( (c=getchar()) == ' ' ) { /* skip blanks */ } 340*0c8de5b0SBaptiste Daroussin 341*0c8de5b0SBaptiste Daroussin /* c is now nonblank */ 342*0c8de5b0SBaptiste Daroussin 343*0c8de5b0SBaptiste Daroussin if( islower( c )) { 344*0c8de5b0SBaptiste Daroussin yylval = c - 'a'; 345*0c8de5b0SBaptiste Daroussin return ( LETTER ); 346*0c8de5b0SBaptiste Daroussin } 347*0c8de5b0SBaptiste Daroussin if( isdigit( c )) { 348*0c8de5b0SBaptiste Daroussin yylval = c - '0'; 349*0c8de5b0SBaptiste Daroussin return ( DIGIT ); 350*0c8de5b0SBaptiste Daroussin } 351*0c8de5b0SBaptiste Daroussin return( c ); 352*0c8de5b0SBaptiste Daroussin } 353*0c8de5b0SBaptiste Daroussin #line 354 "calc.tab.c" 354*0c8de5b0SBaptiste Daroussin 355*0c8de5b0SBaptiste Daroussin #if YYDEBUG 356*0c8de5b0SBaptiste Daroussin #include <stdio.h> /* needed for printf */ 357*0c8de5b0SBaptiste Daroussin #endif 358*0c8de5b0SBaptiste Daroussin 359*0c8de5b0SBaptiste Daroussin #include <stdlib.h> /* needed for malloc, etc */ 360*0c8de5b0SBaptiste Daroussin #include <string.h> /* needed for memset */ 361*0c8de5b0SBaptiste Daroussin 362*0c8de5b0SBaptiste Daroussin /* allocate initial stack or double stack size, up to YYMAXDEPTH */ 363*0c8de5b0SBaptiste Daroussin static int yygrowstack(YYSTACKDATA *data) 364*0c8de5b0SBaptiste Daroussin { 365*0c8de5b0SBaptiste Daroussin int i; 366*0c8de5b0SBaptiste Daroussin unsigned newsize; 367*0c8de5b0SBaptiste Daroussin YYINT *newss; 368*0c8de5b0SBaptiste Daroussin YYSTYPE *newvs; 369*0c8de5b0SBaptiste Daroussin 370*0c8de5b0SBaptiste Daroussin if ((newsize = data->stacksize) == 0) 371*0c8de5b0SBaptiste Daroussin newsize = YYINITSTACKSIZE; 372*0c8de5b0SBaptiste Daroussin else if (newsize >= YYMAXDEPTH) 373*0c8de5b0SBaptiste Daroussin return YYENOMEM; 374*0c8de5b0SBaptiste Daroussin else if ((newsize *= 2) > YYMAXDEPTH) 375*0c8de5b0SBaptiste Daroussin newsize = YYMAXDEPTH; 376*0c8de5b0SBaptiste Daroussin 377*0c8de5b0SBaptiste Daroussin i = (int) (data->s_mark - data->s_base); 378*0c8de5b0SBaptiste Daroussin newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); 379*0c8de5b0SBaptiste Daroussin if (newss == 0) 380*0c8de5b0SBaptiste Daroussin return YYENOMEM; 381*0c8de5b0SBaptiste Daroussin 382*0c8de5b0SBaptiste Daroussin data->s_base = newss; 383*0c8de5b0SBaptiste Daroussin data->s_mark = newss + i; 384*0c8de5b0SBaptiste Daroussin 385*0c8de5b0SBaptiste Daroussin newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); 386*0c8de5b0SBaptiste Daroussin if (newvs == 0) 387*0c8de5b0SBaptiste Daroussin return YYENOMEM; 388*0c8de5b0SBaptiste Daroussin 389*0c8de5b0SBaptiste Daroussin data->l_base = newvs; 390*0c8de5b0SBaptiste Daroussin data->l_mark = newvs + i; 391*0c8de5b0SBaptiste Daroussin 392*0c8de5b0SBaptiste Daroussin data->stacksize = newsize; 393*0c8de5b0SBaptiste Daroussin data->s_last = data->s_base + newsize - 1; 394*0c8de5b0SBaptiste Daroussin return 0; 395*0c8de5b0SBaptiste Daroussin } 396*0c8de5b0SBaptiste Daroussin 397*0c8de5b0SBaptiste Daroussin #if YYPURE || defined(YY_NO_LEAKS) 398*0c8de5b0SBaptiste Daroussin static void yyfreestack(YYSTACKDATA *data) 399*0c8de5b0SBaptiste Daroussin { 400*0c8de5b0SBaptiste Daroussin free(data->s_base); 401*0c8de5b0SBaptiste Daroussin free(data->l_base); 402*0c8de5b0SBaptiste Daroussin memset(data, 0, sizeof(*data)); 403*0c8de5b0SBaptiste Daroussin } 404*0c8de5b0SBaptiste Daroussin #else 405*0c8de5b0SBaptiste Daroussin #define yyfreestack(data) /* nothing */ 406*0c8de5b0SBaptiste Daroussin #endif 407*0c8de5b0SBaptiste Daroussin 408*0c8de5b0SBaptiste Daroussin #define YYABORT goto yyabort 409*0c8de5b0SBaptiste Daroussin #define YYREJECT goto yyabort 410*0c8de5b0SBaptiste Daroussin #define YYACCEPT goto yyaccept 411*0c8de5b0SBaptiste Daroussin #define YYERROR goto yyerrlab 412*0c8de5b0SBaptiste Daroussin 413*0c8de5b0SBaptiste Daroussin int 414*0c8de5b0SBaptiste Daroussin YYPARSE_DECL() 415*0c8de5b0SBaptiste Daroussin { 416*0c8de5b0SBaptiste Daroussin int yym, yyn, yystate; 417*0c8de5b0SBaptiste Daroussin #if YYDEBUG 418*0c8de5b0SBaptiste Daroussin const char *yys; 419*0c8de5b0SBaptiste Daroussin 420*0c8de5b0SBaptiste Daroussin if ((yys = getenv("YYDEBUG")) != 0) 421*0c8de5b0SBaptiste Daroussin { 422*0c8de5b0SBaptiste Daroussin yyn = *yys; 423*0c8de5b0SBaptiste Daroussin if (yyn >= '0' && yyn <= '9') 424*0c8de5b0SBaptiste Daroussin yydebug = yyn - '0'; 425*0c8de5b0SBaptiste Daroussin } 426*0c8de5b0SBaptiste Daroussin #endif 427*0c8de5b0SBaptiste Daroussin 428*0c8de5b0SBaptiste Daroussin yynerrs = 0; 429*0c8de5b0SBaptiste Daroussin yyerrflag = 0; 430*0c8de5b0SBaptiste Daroussin yychar = YYEMPTY; 431*0c8de5b0SBaptiste Daroussin yystate = 0; 432*0c8de5b0SBaptiste Daroussin 433*0c8de5b0SBaptiste Daroussin #if YYPURE 434*0c8de5b0SBaptiste Daroussin memset(&yystack, 0, sizeof(yystack)); 435*0c8de5b0SBaptiste Daroussin #endif 436*0c8de5b0SBaptiste Daroussin 437*0c8de5b0SBaptiste Daroussin if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 438*0c8de5b0SBaptiste Daroussin yystack.s_mark = yystack.s_base; 439*0c8de5b0SBaptiste Daroussin yystack.l_mark = yystack.l_base; 440*0c8de5b0SBaptiste Daroussin yystate = 0; 441*0c8de5b0SBaptiste Daroussin *yystack.s_mark = 0; 442*0c8de5b0SBaptiste Daroussin 443*0c8de5b0SBaptiste Daroussin yyloop: 444*0c8de5b0SBaptiste Daroussin if ((yyn = yydefred[yystate]) != 0) goto yyreduce; 445*0c8de5b0SBaptiste Daroussin if (yychar < 0) 446*0c8de5b0SBaptiste Daroussin { 447*0c8de5b0SBaptiste Daroussin if ((yychar = YYLEX) < 0) yychar = YYEOF; 448*0c8de5b0SBaptiste Daroussin #if YYDEBUG 449*0c8de5b0SBaptiste Daroussin if (yydebug) 450*0c8de5b0SBaptiste Daroussin { 451*0c8de5b0SBaptiste Daroussin yys = yyname[YYTRANSLATE(yychar)]; 452*0c8de5b0SBaptiste Daroussin printf("%sdebug: state %d, reading %d (%s)\n", 453*0c8de5b0SBaptiste Daroussin YYPREFIX, yystate, yychar, yys); 454*0c8de5b0SBaptiste Daroussin } 455*0c8de5b0SBaptiste Daroussin #endif 456*0c8de5b0SBaptiste Daroussin } 457*0c8de5b0SBaptiste Daroussin if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && 458*0c8de5b0SBaptiste Daroussin yyn <= YYTABLESIZE && yycheck[yyn] == yychar) 459*0c8de5b0SBaptiste Daroussin { 460*0c8de5b0SBaptiste Daroussin #if YYDEBUG 461*0c8de5b0SBaptiste Daroussin if (yydebug) 462*0c8de5b0SBaptiste Daroussin printf("%sdebug: state %d, shifting to state %d\n", 463*0c8de5b0SBaptiste Daroussin YYPREFIX, yystate, yytable[yyn]); 464*0c8de5b0SBaptiste Daroussin #endif 465*0c8de5b0SBaptiste Daroussin if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) 466*0c8de5b0SBaptiste Daroussin { 467*0c8de5b0SBaptiste Daroussin goto yyoverflow; 468*0c8de5b0SBaptiste Daroussin } 469*0c8de5b0SBaptiste Daroussin yystate = yytable[yyn]; 470*0c8de5b0SBaptiste Daroussin *++yystack.s_mark = yytable[yyn]; 471*0c8de5b0SBaptiste Daroussin *++yystack.l_mark = yylval; 472*0c8de5b0SBaptiste Daroussin yychar = YYEMPTY; 473*0c8de5b0SBaptiste Daroussin if (yyerrflag > 0) --yyerrflag; 474*0c8de5b0SBaptiste Daroussin goto yyloop; 475*0c8de5b0SBaptiste Daroussin } 476*0c8de5b0SBaptiste Daroussin if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && 477*0c8de5b0SBaptiste Daroussin yyn <= YYTABLESIZE && yycheck[yyn] == yychar) 478*0c8de5b0SBaptiste Daroussin { 479*0c8de5b0SBaptiste Daroussin yyn = yytable[yyn]; 480*0c8de5b0SBaptiste Daroussin goto yyreduce; 481*0c8de5b0SBaptiste Daroussin } 482*0c8de5b0SBaptiste Daroussin if (yyerrflag) goto yyinrecovery; 483*0c8de5b0SBaptiste Daroussin 484*0c8de5b0SBaptiste Daroussin YYERROR_CALL("syntax error"); 485*0c8de5b0SBaptiste Daroussin 486*0c8de5b0SBaptiste Daroussin goto yyerrlab; 487*0c8de5b0SBaptiste Daroussin 488*0c8de5b0SBaptiste Daroussin yyerrlab: 489*0c8de5b0SBaptiste Daroussin ++yynerrs; 490*0c8de5b0SBaptiste Daroussin 491*0c8de5b0SBaptiste Daroussin yyinrecovery: 492*0c8de5b0SBaptiste Daroussin if (yyerrflag < 3) 493*0c8de5b0SBaptiste Daroussin { 494*0c8de5b0SBaptiste Daroussin yyerrflag = 3; 495*0c8de5b0SBaptiste Daroussin for (;;) 496*0c8de5b0SBaptiste Daroussin { 497*0c8de5b0SBaptiste Daroussin if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 && 498*0c8de5b0SBaptiste Daroussin yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) 499*0c8de5b0SBaptiste Daroussin { 500*0c8de5b0SBaptiste Daroussin #if YYDEBUG 501*0c8de5b0SBaptiste Daroussin if (yydebug) 502*0c8de5b0SBaptiste Daroussin printf("%sdebug: state %d, error recovery shifting\ 503*0c8de5b0SBaptiste Daroussin to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); 504*0c8de5b0SBaptiste Daroussin #endif 505*0c8de5b0SBaptiste Daroussin if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) 506*0c8de5b0SBaptiste Daroussin { 507*0c8de5b0SBaptiste Daroussin goto yyoverflow; 508*0c8de5b0SBaptiste Daroussin } 509*0c8de5b0SBaptiste Daroussin yystate = yytable[yyn]; 510*0c8de5b0SBaptiste Daroussin *++yystack.s_mark = yytable[yyn]; 511*0c8de5b0SBaptiste Daroussin *++yystack.l_mark = yylval; 512*0c8de5b0SBaptiste Daroussin goto yyloop; 513*0c8de5b0SBaptiste Daroussin } 514*0c8de5b0SBaptiste Daroussin else 515*0c8de5b0SBaptiste Daroussin { 516*0c8de5b0SBaptiste Daroussin #if YYDEBUG 517*0c8de5b0SBaptiste Daroussin if (yydebug) 518*0c8de5b0SBaptiste Daroussin printf("%sdebug: error recovery discarding state %d\n", 519*0c8de5b0SBaptiste Daroussin YYPREFIX, *yystack.s_mark); 520*0c8de5b0SBaptiste Daroussin #endif 521*0c8de5b0SBaptiste Daroussin if (yystack.s_mark <= yystack.s_base) goto yyabort; 522*0c8de5b0SBaptiste Daroussin --yystack.s_mark; 523*0c8de5b0SBaptiste Daroussin --yystack.l_mark; 524*0c8de5b0SBaptiste Daroussin } 525*0c8de5b0SBaptiste Daroussin } 526*0c8de5b0SBaptiste Daroussin } 527*0c8de5b0SBaptiste Daroussin else 528*0c8de5b0SBaptiste Daroussin { 529*0c8de5b0SBaptiste Daroussin if (yychar == YYEOF) goto yyabort; 530*0c8de5b0SBaptiste Daroussin #if YYDEBUG 531*0c8de5b0SBaptiste Daroussin if (yydebug) 532*0c8de5b0SBaptiste Daroussin { 533*0c8de5b0SBaptiste Daroussin yys = yyname[YYTRANSLATE(yychar)]; 534*0c8de5b0SBaptiste Daroussin printf("%sdebug: state %d, error recovery discards token %d (%s)\n", 535*0c8de5b0SBaptiste Daroussin YYPREFIX, yystate, yychar, yys); 536*0c8de5b0SBaptiste Daroussin } 537*0c8de5b0SBaptiste Daroussin #endif 538*0c8de5b0SBaptiste Daroussin yychar = YYEMPTY; 539*0c8de5b0SBaptiste Daroussin goto yyloop; 540*0c8de5b0SBaptiste Daroussin } 541*0c8de5b0SBaptiste Daroussin 542*0c8de5b0SBaptiste Daroussin yyreduce: 543*0c8de5b0SBaptiste Daroussin #if YYDEBUG 544*0c8de5b0SBaptiste Daroussin if (yydebug) 545*0c8de5b0SBaptiste Daroussin printf("%sdebug: state %d, reducing by rule %d (%s)\n", 546*0c8de5b0SBaptiste Daroussin YYPREFIX, yystate, yyn, yyrule[yyn]); 547*0c8de5b0SBaptiste Daroussin #endif 548*0c8de5b0SBaptiste Daroussin yym = yylen[yyn]; 549*0c8de5b0SBaptiste Daroussin if (yym) 550*0c8de5b0SBaptiste Daroussin yyval = yystack.l_mark[1-yym]; 551*0c8de5b0SBaptiste Daroussin else 552*0c8de5b0SBaptiste Daroussin memset(&yyval, 0, sizeof yyval); 553*0c8de5b0SBaptiste Daroussin switch (yyn) 554*0c8de5b0SBaptiste Daroussin { 555*0c8de5b0SBaptiste Daroussin case 3: 556*0c8de5b0SBaptiste Daroussin #line 28 "calc.y" 557*0c8de5b0SBaptiste Daroussin { yyerrok ; } 558*0c8de5b0SBaptiste Daroussin break; 559*0c8de5b0SBaptiste Daroussin case 4: 560*0c8de5b0SBaptiste Daroussin #line 32 "calc.y" 561*0c8de5b0SBaptiste Daroussin { printf("%d\n",yystack.l_mark[0]);} 562*0c8de5b0SBaptiste Daroussin break; 563*0c8de5b0SBaptiste Daroussin case 5: 564*0c8de5b0SBaptiste Daroussin #line 34 "calc.y" 565*0c8de5b0SBaptiste Daroussin { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } 566*0c8de5b0SBaptiste Daroussin break; 567*0c8de5b0SBaptiste Daroussin case 6: 568*0c8de5b0SBaptiste Daroussin #line 38 "calc.y" 569*0c8de5b0SBaptiste Daroussin { yyval = yystack.l_mark[-1]; } 570*0c8de5b0SBaptiste Daroussin break; 571*0c8de5b0SBaptiste Daroussin case 7: 572*0c8de5b0SBaptiste Daroussin #line 40 "calc.y" 573*0c8de5b0SBaptiste Daroussin { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } 574*0c8de5b0SBaptiste Daroussin break; 575*0c8de5b0SBaptiste Daroussin case 8: 576*0c8de5b0SBaptiste Daroussin #line 42 "calc.y" 577*0c8de5b0SBaptiste Daroussin { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } 578*0c8de5b0SBaptiste Daroussin break; 579*0c8de5b0SBaptiste Daroussin case 9: 580*0c8de5b0SBaptiste Daroussin #line 44 "calc.y" 581*0c8de5b0SBaptiste Daroussin { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } 582*0c8de5b0SBaptiste Daroussin break; 583*0c8de5b0SBaptiste Daroussin case 10: 584*0c8de5b0SBaptiste Daroussin #line 46 "calc.y" 585*0c8de5b0SBaptiste Daroussin { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } 586*0c8de5b0SBaptiste Daroussin break; 587*0c8de5b0SBaptiste Daroussin case 11: 588*0c8de5b0SBaptiste Daroussin #line 48 "calc.y" 589*0c8de5b0SBaptiste Daroussin { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } 590*0c8de5b0SBaptiste Daroussin break; 591*0c8de5b0SBaptiste Daroussin case 12: 592*0c8de5b0SBaptiste Daroussin #line 50 "calc.y" 593*0c8de5b0SBaptiste Daroussin { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } 594*0c8de5b0SBaptiste Daroussin break; 595*0c8de5b0SBaptiste Daroussin case 13: 596*0c8de5b0SBaptiste Daroussin #line 52 "calc.y" 597*0c8de5b0SBaptiste Daroussin { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } 598*0c8de5b0SBaptiste Daroussin break; 599*0c8de5b0SBaptiste Daroussin case 14: 600*0c8de5b0SBaptiste Daroussin #line 54 "calc.y" 601*0c8de5b0SBaptiste Daroussin { yyval = - yystack.l_mark[0]; } 602*0c8de5b0SBaptiste Daroussin break; 603*0c8de5b0SBaptiste Daroussin case 15: 604*0c8de5b0SBaptiste Daroussin #line 56 "calc.y" 605*0c8de5b0SBaptiste Daroussin { yyval = regs[yystack.l_mark[0]]; } 606*0c8de5b0SBaptiste Daroussin break; 607*0c8de5b0SBaptiste Daroussin case 17: 608*0c8de5b0SBaptiste Daroussin #line 61 "calc.y" 609*0c8de5b0SBaptiste Daroussin { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } 610*0c8de5b0SBaptiste Daroussin break; 611*0c8de5b0SBaptiste Daroussin case 18: 612*0c8de5b0SBaptiste Daroussin #line 63 "calc.y" 613*0c8de5b0SBaptiste Daroussin { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } 614*0c8de5b0SBaptiste Daroussin break; 615*0c8de5b0SBaptiste Daroussin #line 616 "calc.tab.c" 616*0c8de5b0SBaptiste Daroussin } 617*0c8de5b0SBaptiste Daroussin yystack.s_mark -= yym; 618*0c8de5b0SBaptiste Daroussin yystate = *yystack.s_mark; 619*0c8de5b0SBaptiste Daroussin yystack.l_mark -= yym; 620*0c8de5b0SBaptiste Daroussin yym = yylhs[yyn]; 621*0c8de5b0SBaptiste Daroussin if (yystate == 0 && yym == 0) 622*0c8de5b0SBaptiste Daroussin { 623*0c8de5b0SBaptiste Daroussin #if YYDEBUG 624*0c8de5b0SBaptiste Daroussin if (yydebug) 625*0c8de5b0SBaptiste Daroussin printf("%sdebug: after reduction, shifting from state 0 to\ 626*0c8de5b0SBaptiste Daroussin state %d\n", YYPREFIX, YYFINAL); 627*0c8de5b0SBaptiste Daroussin #endif 628*0c8de5b0SBaptiste Daroussin yystate = YYFINAL; 629*0c8de5b0SBaptiste Daroussin *++yystack.s_mark = YYFINAL; 630*0c8de5b0SBaptiste Daroussin *++yystack.l_mark = yyval; 631*0c8de5b0SBaptiste Daroussin if (yychar < 0) 632*0c8de5b0SBaptiste Daroussin { 633*0c8de5b0SBaptiste Daroussin if ((yychar = YYLEX) < 0) yychar = YYEOF; 634*0c8de5b0SBaptiste Daroussin #if YYDEBUG 635*0c8de5b0SBaptiste Daroussin if (yydebug) 636*0c8de5b0SBaptiste Daroussin { 637*0c8de5b0SBaptiste Daroussin yys = yyname[YYTRANSLATE(yychar)]; 638*0c8de5b0SBaptiste Daroussin printf("%sdebug: state %d, reading %d (%s)\n", 639*0c8de5b0SBaptiste Daroussin YYPREFIX, YYFINAL, yychar, yys); 640*0c8de5b0SBaptiste Daroussin } 641*0c8de5b0SBaptiste Daroussin #endif 642*0c8de5b0SBaptiste Daroussin } 643*0c8de5b0SBaptiste Daroussin if (yychar == YYEOF) goto yyaccept; 644*0c8de5b0SBaptiste Daroussin goto yyloop; 645*0c8de5b0SBaptiste Daroussin } 646*0c8de5b0SBaptiste Daroussin if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && 647*0c8de5b0SBaptiste Daroussin yyn <= YYTABLESIZE && yycheck[yyn] == yystate) 648*0c8de5b0SBaptiste Daroussin yystate = yytable[yyn]; 649*0c8de5b0SBaptiste Daroussin else 650*0c8de5b0SBaptiste Daroussin yystate = yydgoto[yym]; 651*0c8de5b0SBaptiste Daroussin #if YYDEBUG 652*0c8de5b0SBaptiste Daroussin if (yydebug) 653*0c8de5b0SBaptiste Daroussin printf("%sdebug: after reduction, shifting from state %d \ 654*0c8de5b0SBaptiste Daroussin to state %d\n", YYPREFIX, *yystack.s_mark, yystate); 655*0c8de5b0SBaptiste Daroussin #endif 656*0c8de5b0SBaptiste Daroussin if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) 657*0c8de5b0SBaptiste Daroussin { 658*0c8de5b0SBaptiste Daroussin goto yyoverflow; 659*0c8de5b0SBaptiste Daroussin } 660*0c8de5b0SBaptiste Daroussin *++yystack.s_mark = (YYINT) yystate; 661*0c8de5b0SBaptiste Daroussin *++yystack.l_mark = yyval; 662*0c8de5b0SBaptiste Daroussin goto yyloop; 663*0c8de5b0SBaptiste Daroussin 664*0c8de5b0SBaptiste Daroussin yyoverflow: 665*0c8de5b0SBaptiste Daroussin YYERROR_CALL("yacc stack overflow"); 666*0c8de5b0SBaptiste Daroussin 667*0c8de5b0SBaptiste Daroussin yyabort: 668*0c8de5b0SBaptiste Daroussin yyfreestack(&yystack); 669*0c8de5b0SBaptiste Daroussin return (1); 670*0c8de5b0SBaptiste Daroussin 671*0c8de5b0SBaptiste Daroussin yyaccept: 672*0c8de5b0SBaptiste Daroussin yyfreestack(&yystack); 673*0c8de5b0SBaptiste Daroussin return (0); 674*0c8de5b0SBaptiste Daroussin } 675