10c8de5b0SBaptiste Daroussin /* original parser id follows */ 20c8de5b0SBaptiste Daroussin /* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ 30c8de5b0SBaptiste Daroussin /* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ 40c8de5b0SBaptiste Daroussin 50c8de5b0SBaptiste Daroussin #define YYBYACC 1 60c8de5b0SBaptiste Daroussin #define YYMAJOR 1 70c8de5b0SBaptiste Daroussin #define YYMINOR 9 80c8de5b0SBaptiste Daroussin #define YYCHECK "yyyymmdd" 90c8de5b0SBaptiste Daroussin 100c8de5b0SBaptiste Daroussin #define YYEMPTY (-1) 110c8de5b0SBaptiste Daroussin #define yyclearin (yychar = YYEMPTY) 120c8de5b0SBaptiste Daroussin #define yyerrok (yyerrflag = 0) 130c8de5b0SBaptiste Daroussin #define YYRECOVERING() (yyerrflag != 0) 140c8de5b0SBaptiste Daroussin #define YYENOMEM (-2) 150c8de5b0SBaptiste Daroussin #define YYEOF 0 160c8de5b0SBaptiste Daroussin 170c8de5b0SBaptiste Daroussin #ifndef yyparse 180c8de5b0SBaptiste Daroussin #define yyparse calc_parse 190c8de5b0SBaptiste Daroussin #endif /* yyparse */ 200c8de5b0SBaptiste Daroussin 210c8de5b0SBaptiste Daroussin #ifndef yylex 220c8de5b0SBaptiste Daroussin #define yylex calc_lex 230c8de5b0SBaptiste Daroussin #endif /* yylex */ 240c8de5b0SBaptiste Daroussin 250c8de5b0SBaptiste Daroussin #ifndef yyerror 260c8de5b0SBaptiste Daroussin #define yyerror calc_error 270c8de5b0SBaptiste Daroussin #endif /* yyerror */ 280c8de5b0SBaptiste Daroussin 290c8de5b0SBaptiste Daroussin #ifndef yychar 300c8de5b0SBaptiste Daroussin #define yychar calc_char 310c8de5b0SBaptiste Daroussin #endif /* yychar */ 320c8de5b0SBaptiste Daroussin 330c8de5b0SBaptiste Daroussin #ifndef yyval 340c8de5b0SBaptiste Daroussin #define yyval calc_val 350c8de5b0SBaptiste Daroussin #endif /* yyval */ 360c8de5b0SBaptiste Daroussin 370c8de5b0SBaptiste Daroussin #ifndef yylval 380c8de5b0SBaptiste Daroussin #define yylval calc_lval 390c8de5b0SBaptiste Daroussin #endif /* yylval */ 400c8de5b0SBaptiste Daroussin 410c8de5b0SBaptiste Daroussin #ifndef yydebug 420c8de5b0SBaptiste Daroussin #define yydebug calc_debug 430c8de5b0SBaptiste Daroussin #endif /* yydebug */ 440c8de5b0SBaptiste Daroussin 450c8de5b0SBaptiste Daroussin #ifndef yynerrs 460c8de5b0SBaptiste Daroussin #define yynerrs calc_nerrs 470c8de5b0SBaptiste Daroussin #endif /* yynerrs */ 480c8de5b0SBaptiste Daroussin 490c8de5b0SBaptiste Daroussin #ifndef yyerrflag 500c8de5b0SBaptiste Daroussin #define yyerrflag calc_errflag 510c8de5b0SBaptiste Daroussin #endif /* yyerrflag */ 520c8de5b0SBaptiste Daroussin 530c8de5b0SBaptiste Daroussin #ifndef yylhs 540c8de5b0SBaptiste Daroussin #define yylhs calc_lhs 550c8de5b0SBaptiste Daroussin #endif /* yylhs */ 560c8de5b0SBaptiste Daroussin 570c8de5b0SBaptiste Daroussin #ifndef yylen 580c8de5b0SBaptiste Daroussin #define yylen calc_len 590c8de5b0SBaptiste Daroussin #endif /* yylen */ 600c8de5b0SBaptiste Daroussin 610c8de5b0SBaptiste Daroussin #ifndef yydefred 620c8de5b0SBaptiste Daroussin #define yydefred calc_defred 630c8de5b0SBaptiste Daroussin #endif /* yydefred */ 640c8de5b0SBaptiste Daroussin 650c8de5b0SBaptiste Daroussin #ifndef yydgoto 660c8de5b0SBaptiste Daroussin #define yydgoto calc_dgoto 670c8de5b0SBaptiste Daroussin #endif /* yydgoto */ 680c8de5b0SBaptiste Daroussin 690c8de5b0SBaptiste Daroussin #ifndef yysindex 700c8de5b0SBaptiste Daroussin #define yysindex calc_sindex 710c8de5b0SBaptiste Daroussin #endif /* yysindex */ 720c8de5b0SBaptiste Daroussin 730c8de5b0SBaptiste Daroussin #ifndef yyrindex 740c8de5b0SBaptiste Daroussin #define yyrindex calc_rindex 750c8de5b0SBaptiste Daroussin #endif /* yyrindex */ 760c8de5b0SBaptiste Daroussin 770c8de5b0SBaptiste Daroussin #ifndef yygindex 780c8de5b0SBaptiste Daroussin #define yygindex calc_gindex 790c8de5b0SBaptiste Daroussin #endif /* yygindex */ 800c8de5b0SBaptiste Daroussin 810c8de5b0SBaptiste Daroussin #ifndef yytable 820c8de5b0SBaptiste Daroussin #define yytable calc_table 830c8de5b0SBaptiste Daroussin #endif /* yytable */ 840c8de5b0SBaptiste Daroussin 850c8de5b0SBaptiste Daroussin #ifndef yycheck 860c8de5b0SBaptiste Daroussin #define yycheck calc_check 870c8de5b0SBaptiste Daroussin #endif /* yycheck */ 880c8de5b0SBaptiste Daroussin 890c8de5b0SBaptiste Daroussin #ifndef yyname 900c8de5b0SBaptiste Daroussin #define yyname calc_name 910c8de5b0SBaptiste Daroussin #endif /* yyname */ 920c8de5b0SBaptiste Daroussin 930c8de5b0SBaptiste Daroussin #ifndef yyrule 940c8de5b0SBaptiste Daroussin #define yyrule calc_rule 950c8de5b0SBaptiste Daroussin #endif /* yyrule */ 960c8de5b0SBaptiste Daroussin #define YYPREFIX "calc_" 970c8de5b0SBaptiste Daroussin 980c8de5b0SBaptiste Daroussin #define YYPURE 0 990c8de5b0SBaptiste Daroussin 1000c8de5b0SBaptiste Daroussin #line 2 "calc.y" 1010c8de5b0SBaptiste Daroussin # include <stdio.h> 1020c8de5b0SBaptiste Daroussin # include <ctype.h> 1030c8de5b0SBaptiste Daroussin 1040c8de5b0SBaptiste Daroussin int regs[26]; 1050c8de5b0SBaptiste Daroussin int base; 1060c8de5b0SBaptiste Daroussin 1070c8de5b0SBaptiste Daroussin extern int yylex(void); 1080c8de5b0SBaptiste Daroussin static void yyerror(const char *s); 1090c8de5b0SBaptiste Daroussin 1100c8de5b0SBaptiste Daroussin #line 111 "calc.tab.c" 1110c8de5b0SBaptiste Daroussin 1120c8de5b0SBaptiste Daroussin #if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) 1130c8de5b0SBaptiste Daroussin /* Default: YYSTYPE is the semantic value type. */ 1140c8de5b0SBaptiste Daroussin typedef int YYSTYPE; 1150c8de5b0SBaptiste Daroussin # define YYSTYPE_IS_DECLARED 1 1160c8de5b0SBaptiste Daroussin #endif 1170c8de5b0SBaptiste Daroussin 1180c8de5b0SBaptiste Daroussin /* compatibility with bison */ 1190c8de5b0SBaptiste Daroussin #ifdef YYPARSE_PARAM 1200c8de5b0SBaptiste Daroussin /* compatibility with FreeBSD */ 1210c8de5b0SBaptiste Daroussin # ifdef YYPARSE_PARAM_TYPE 1220c8de5b0SBaptiste Daroussin # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) 1230c8de5b0SBaptiste Daroussin # else 1240c8de5b0SBaptiste Daroussin # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) 1250c8de5b0SBaptiste Daroussin # endif 1260c8de5b0SBaptiste Daroussin #else 1270c8de5b0SBaptiste Daroussin # define YYPARSE_DECL() yyparse(void) 1280c8de5b0SBaptiste Daroussin #endif 1290c8de5b0SBaptiste Daroussin 1300c8de5b0SBaptiste Daroussin /* Parameters sent to lex. */ 1310c8de5b0SBaptiste Daroussin #ifdef YYLEX_PARAM 1320c8de5b0SBaptiste Daroussin # define YYLEX_DECL() yylex(void *YYLEX_PARAM) 1330c8de5b0SBaptiste Daroussin # define YYLEX yylex(YYLEX_PARAM) 1340c8de5b0SBaptiste Daroussin #else 1350c8de5b0SBaptiste Daroussin # define YYLEX_DECL() yylex(void) 1360c8de5b0SBaptiste Daroussin # define YYLEX yylex() 1370c8de5b0SBaptiste Daroussin #endif 1380c8de5b0SBaptiste Daroussin 1390c8de5b0SBaptiste Daroussin /* Parameters sent to yyerror. */ 1400c8de5b0SBaptiste Daroussin #ifndef YYERROR_DECL 1410c8de5b0SBaptiste Daroussin #define YYERROR_DECL() yyerror(const char *s) 1420c8de5b0SBaptiste Daroussin #endif 1430c8de5b0SBaptiste Daroussin #ifndef YYERROR_CALL 1440c8de5b0SBaptiste Daroussin #define YYERROR_CALL(msg) yyerror(msg) 1450c8de5b0SBaptiste Daroussin #endif 1460c8de5b0SBaptiste Daroussin 1470c8de5b0SBaptiste Daroussin extern int YYPARSE_DECL(); 1480c8de5b0SBaptiste Daroussin 1490c8de5b0SBaptiste Daroussin #define DIGIT 257 1500c8de5b0SBaptiste Daroussin #define LETTER 258 1510c8de5b0SBaptiste Daroussin #define UMINUS 259 1520c8de5b0SBaptiste Daroussin #define YYERRCODE 256 153ea2af5c8SJung-uk Kim typedef int YYINT; 1540c8de5b0SBaptiste Daroussin static const YYINT calc_lhs[] = { -1, 1550c8de5b0SBaptiste Daroussin 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, 1560c8de5b0SBaptiste Daroussin 2, 2, 2, 2, 2, 2, 3, 3, 1570c8de5b0SBaptiste Daroussin }; 1580c8de5b0SBaptiste Daroussin static const YYINT calc_len[] = { 2, 1590c8de5b0SBaptiste Daroussin 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, 1600c8de5b0SBaptiste Daroussin 3, 3, 3, 2, 1, 1, 1, 2, 1610c8de5b0SBaptiste Daroussin }; 1620c8de5b0SBaptiste Daroussin static const YYINT calc_defred[] = { 1, 1630c8de5b0SBaptiste Daroussin 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, 1640c8de5b0SBaptiste Daroussin 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, 1650c8de5b0SBaptiste Daroussin 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, 1660c8de5b0SBaptiste Daroussin 10, 11, 1670c8de5b0SBaptiste Daroussin }; 1680c8de5b0SBaptiste Daroussin static const YYINT calc_dgoto[] = { 1, 1690c8de5b0SBaptiste Daroussin 7, 8, 9, 1700c8de5b0SBaptiste Daroussin }; 1710c8de5b0SBaptiste Daroussin static const YYINT calc_sindex[] = { 0, 1720c8de5b0SBaptiste Daroussin -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, 1730c8de5b0SBaptiste Daroussin -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, 1740c8de5b0SBaptiste Daroussin -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, 1750c8de5b0SBaptiste Daroussin 0, 0, 1760c8de5b0SBaptiste Daroussin }; 1770c8de5b0SBaptiste Daroussin static const YYINT calc_rindex[] = { 0, 1780c8de5b0SBaptiste Daroussin 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, 1790c8de5b0SBaptiste Daroussin 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1800c8de5b0SBaptiste Daroussin 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, 1810c8de5b0SBaptiste Daroussin 0, 0, 1820c8de5b0SBaptiste Daroussin }; 1830c8de5b0SBaptiste Daroussin static const YYINT calc_gindex[] = { 0, 1840c8de5b0SBaptiste Daroussin 0, 65, 0, 1850c8de5b0SBaptiste Daroussin }; 1860c8de5b0SBaptiste Daroussin #define YYTABLESIZE 220 1870c8de5b0SBaptiste Daroussin static const YYINT calc_table[] = { 6, 1880c8de5b0SBaptiste Daroussin 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, 1890c8de5b0SBaptiste Daroussin 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, 1900c8de5b0SBaptiste Daroussin 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, 1910c8de5b0SBaptiste Daroussin 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, 1920c8de5b0SBaptiste Daroussin 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, 1930c8de5b0SBaptiste Daroussin 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, 1940c8de5b0SBaptiste Daroussin 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, 1950c8de5b0SBaptiste Daroussin 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, 1960c8de5b0SBaptiste Daroussin 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, 1970c8de5b0SBaptiste Daroussin 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, 1980c8de5b0SBaptiste Daroussin 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, 1990c8de5b0SBaptiste Daroussin 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, 2000c8de5b0SBaptiste Daroussin 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, 2010c8de5b0SBaptiste Daroussin 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, 2020c8de5b0SBaptiste Daroussin 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 2030c8de5b0SBaptiste Daroussin 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2040c8de5b0SBaptiste Daroussin 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2050c8de5b0SBaptiste Daroussin 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2060c8de5b0SBaptiste Daroussin 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2070c8de5b0SBaptiste Daroussin 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2080c8de5b0SBaptiste Daroussin 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2090c8de5b0SBaptiste Daroussin 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, 2100c8de5b0SBaptiste Daroussin }; 2110c8de5b0SBaptiste Daroussin static const YYINT calc_check[] = { 40, 2120c8de5b0SBaptiste Daroussin 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, 2130c8de5b0SBaptiste Daroussin 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, 2140c8de5b0SBaptiste Daroussin -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, 2150c8de5b0SBaptiste Daroussin -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, 2160c8de5b0SBaptiste Daroussin -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, 2170c8de5b0SBaptiste Daroussin 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, 2180c8de5b0SBaptiste Daroussin -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, 2190c8de5b0SBaptiste Daroussin 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, 2200c8de5b0SBaptiste Daroussin 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, 2210c8de5b0SBaptiste Daroussin -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, 2220c8de5b0SBaptiste Daroussin -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, 2230c8de5b0SBaptiste Daroussin -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, 2240c8de5b0SBaptiste Daroussin -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, 2250c8de5b0SBaptiste Daroussin -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, 2260c8de5b0SBaptiste Daroussin -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, 2270c8de5b0SBaptiste Daroussin -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2280c8de5b0SBaptiste Daroussin -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2290c8de5b0SBaptiste Daroussin -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2300c8de5b0SBaptiste Daroussin -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2310c8de5b0SBaptiste Daroussin -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2320c8de5b0SBaptiste Daroussin -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2330c8de5b0SBaptiste Daroussin -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, 2340c8de5b0SBaptiste Daroussin }; 2350c8de5b0SBaptiste Daroussin #define YYFINAL 1 2360c8de5b0SBaptiste Daroussin #ifndef YYDEBUG 2370c8de5b0SBaptiste Daroussin #define YYDEBUG 0 2380c8de5b0SBaptiste Daroussin #endif 2390c8de5b0SBaptiste Daroussin #define YYMAXTOKEN 259 2400c8de5b0SBaptiste Daroussin #define YYUNDFTOKEN 265 2410c8de5b0SBaptiste Daroussin #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) 2420c8de5b0SBaptiste Daroussin #if YYDEBUG 2430c8de5b0SBaptiste Daroussin static const char *const calc_name[] = { 2440c8de5b0SBaptiste Daroussin 2450c8de5b0SBaptiste 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, 2460c8de5b0SBaptiste Daroussin 0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0, 2470c8de5b0SBaptiste 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, 2480c8de5b0SBaptiste 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, 2490c8de5b0SBaptiste 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, 2500c8de5b0SBaptiste 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, 2510c8de5b0SBaptiste 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, 2520c8de5b0SBaptiste Daroussin 0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol", 2530c8de5b0SBaptiste Daroussin }; 2540c8de5b0SBaptiste Daroussin static const char *const calc_rule[] = { 2550c8de5b0SBaptiste Daroussin "$accept : list", 2560c8de5b0SBaptiste Daroussin "list :", 2570c8de5b0SBaptiste Daroussin "list : list stat '\\n'", 2580c8de5b0SBaptiste Daroussin "list : list error '\\n'", 2590c8de5b0SBaptiste Daroussin "stat : expr", 2600c8de5b0SBaptiste Daroussin "stat : LETTER '=' expr", 2610c8de5b0SBaptiste Daroussin "expr : '(' expr ')'", 2620c8de5b0SBaptiste Daroussin "expr : expr '+' expr", 2630c8de5b0SBaptiste Daroussin "expr : expr '-' expr", 2640c8de5b0SBaptiste Daroussin "expr : expr '*' expr", 2650c8de5b0SBaptiste Daroussin "expr : expr '/' expr", 2660c8de5b0SBaptiste Daroussin "expr : expr '%' expr", 2670c8de5b0SBaptiste Daroussin "expr : expr '&' expr", 2680c8de5b0SBaptiste Daroussin "expr : expr '|' expr", 2690c8de5b0SBaptiste Daroussin "expr : '-' expr", 2700c8de5b0SBaptiste Daroussin "expr : LETTER", 2710c8de5b0SBaptiste Daroussin "expr : number", 2720c8de5b0SBaptiste Daroussin "number : DIGIT", 2730c8de5b0SBaptiste Daroussin "number : number DIGIT", 2740c8de5b0SBaptiste Daroussin 2750c8de5b0SBaptiste Daroussin }; 2760c8de5b0SBaptiste Daroussin #endif 2770c8de5b0SBaptiste Daroussin 2780c8de5b0SBaptiste Daroussin int yydebug; 2790c8de5b0SBaptiste Daroussin int yynerrs; 2800c8de5b0SBaptiste Daroussin 2810c8de5b0SBaptiste Daroussin int yyerrflag; 2820c8de5b0SBaptiste Daroussin int yychar; 2830c8de5b0SBaptiste Daroussin YYSTYPE yyval; 2840c8de5b0SBaptiste Daroussin YYSTYPE yylval; 2850c8de5b0SBaptiste Daroussin 2860c8de5b0SBaptiste Daroussin /* define the initial stack-sizes */ 2870c8de5b0SBaptiste Daroussin #ifdef YYSTACKSIZE 2880c8de5b0SBaptiste Daroussin #undef YYMAXDEPTH 2890c8de5b0SBaptiste Daroussin #define YYMAXDEPTH YYSTACKSIZE 2900c8de5b0SBaptiste Daroussin #else 2910c8de5b0SBaptiste Daroussin #ifdef YYMAXDEPTH 2920c8de5b0SBaptiste Daroussin #define YYSTACKSIZE YYMAXDEPTH 2930c8de5b0SBaptiste Daroussin #else 2940c8de5b0SBaptiste Daroussin #define YYSTACKSIZE 10000 2950c8de5b0SBaptiste Daroussin #define YYMAXDEPTH 10000 2960c8de5b0SBaptiste Daroussin #endif 2970c8de5b0SBaptiste Daroussin #endif 2980c8de5b0SBaptiste Daroussin 2990c8de5b0SBaptiste Daroussin #define YYINITSTACKSIZE 200 3000c8de5b0SBaptiste Daroussin 3010c8de5b0SBaptiste Daroussin typedef struct { 3020c8de5b0SBaptiste Daroussin unsigned stacksize; 3030c8de5b0SBaptiste Daroussin YYINT *s_base; 3040c8de5b0SBaptiste Daroussin YYINT *s_mark; 3050c8de5b0SBaptiste Daroussin YYINT *s_last; 3060c8de5b0SBaptiste Daroussin YYSTYPE *l_base; 3070c8de5b0SBaptiste Daroussin YYSTYPE *l_mark; 3080c8de5b0SBaptiste Daroussin } YYSTACKDATA; 3090c8de5b0SBaptiste Daroussin /* variables for the parser stack */ 3100c8de5b0SBaptiste Daroussin static YYSTACKDATA yystack; 3110c8de5b0SBaptiste Daroussin #line 66 "calc.y" 3120c8de5b0SBaptiste Daroussin /* start of programs */ 3130c8de5b0SBaptiste Daroussin 3140c8de5b0SBaptiste Daroussin int 3150c8de5b0SBaptiste Daroussin main (void) 3160c8de5b0SBaptiste Daroussin { 3170c8de5b0SBaptiste Daroussin while(!feof(stdin)) { 3180c8de5b0SBaptiste Daroussin yyparse(); 3190c8de5b0SBaptiste Daroussin } 3200c8de5b0SBaptiste Daroussin return 0; 3210c8de5b0SBaptiste Daroussin } 3220c8de5b0SBaptiste Daroussin 3230c8de5b0SBaptiste Daroussin static void 3240c8de5b0SBaptiste Daroussin yyerror(const char *s) 3250c8de5b0SBaptiste Daroussin { 3260c8de5b0SBaptiste Daroussin fprintf(stderr, "%s\n", s); 3270c8de5b0SBaptiste Daroussin } 3280c8de5b0SBaptiste Daroussin 3290c8de5b0SBaptiste Daroussin int 3300c8de5b0SBaptiste Daroussin yylex(void) 3310c8de5b0SBaptiste Daroussin { 3320c8de5b0SBaptiste Daroussin /* lexical analysis routine */ 3330c8de5b0SBaptiste Daroussin /* returns LETTER for a lower case letter, yylval = 0 through 25 */ 3340c8de5b0SBaptiste Daroussin /* return DIGIT for a digit, yylval = 0 through 9 */ 3350c8de5b0SBaptiste Daroussin /* all other characters are returned immediately */ 3360c8de5b0SBaptiste Daroussin 3370c8de5b0SBaptiste Daroussin int c; 3380c8de5b0SBaptiste Daroussin 3390c8de5b0SBaptiste Daroussin while( (c=getchar()) == ' ' ) { /* skip blanks */ } 3400c8de5b0SBaptiste Daroussin 3410c8de5b0SBaptiste Daroussin /* c is now nonblank */ 3420c8de5b0SBaptiste Daroussin 3430c8de5b0SBaptiste Daroussin if( islower( c )) { 3440c8de5b0SBaptiste Daroussin yylval = c - 'a'; 3450c8de5b0SBaptiste Daroussin return ( LETTER ); 3460c8de5b0SBaptiste Daroussin } 3470c8de5b0SBaptiste Daroussin if( isdigit( c )) { 3480c8de5b0SBaptiste Daroussin yylval = c - '0'; 3490c8de5b0SBaptiste Daroussin return ( DIGIT ); 3500c8de5b0SBaptiste Daroussin } 3510c8de5b0SBaptiste Daroussin return( c ); 3520c8de5b0SBaptiste Daroussin } 3530c8de5b0SBaptiste Daroussin #line 354 "calc.tab.c" 3540c8de5b0SBaptiste Daroussin 3550c8de5b0SBaptiste Daroussin #if YYDEBUG 3560c8de5b0SBaptiste Daroussin #include <stdio.h> /* needed for printf */ 3570c8de5b0SBaptiste Daroussin #endif 3580c8de5b0SBaptiste Daroussin 3590c8de5b0SBaptiste Daroussin #include <stdlib.h> /* needed for malloc, etc */ 3600c8de5b0SBaptiste Daroussin #include <string.h> /* needed for memset */ 3610c8de5b0SBaptiste Daroussin 3620c8de5b0SBaptiste Daroussin /* allocate initial stack or double stack size, up to YYMAXDEPTH */ 3630c8de5b0SBaptiste Daroussin static int yygrowstack(YYSTACKDATA *data) 3640c8de5b0SBaptiste Daroussin { 3650c8de5b0SBaptiste Daroussin int i; 3660c8de5b0SBaptiste Daroussin unsigned newsize; 3670c8de5b0SBaptiste Daroussin YYINT *newss; 3680c8de5b0SBaptiste Daroussin YYSTYPE *newvs; 3690c8de5b0SBaptiste Daroussin 3700c8de5b0SBaptiste Daroussin if ((newsize = data->stacksize) == 0) 3710c8de5b0SBaptiste Daroussin newsize = YYINITSTACKSIZE; 3720c8de5b0SBaptiste Daroussin else if (newsize >= YYMAXDEPTH) 3730c8de5b0SBaptiste Daroussin return YYENOMEM; 3740c8de5b0SBaptiste Daroussin else if ((newsize *= 2) > YYMAXDEPTH) 3750c8de5b0SBaptiste Daroussin newsize = YYMAXDEPTH; 3760c8de5b0SBaptiste Daroussin 3770c8de5b0SBaptiste Daroussin i = (int) (data->s_mark - data->s_base); 3780c8de5b0SBaptiste Daroussin newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); 3790c8de5b0SBaptiste Daroussin if (newss == 0) 3800c8de5b0SBaptiste Daroussin return YYENOMEM; 3810c8de5b0SBaptiste Daroussin 3820c8de5b0SBaptiste Daroussin data->s_base = newss; 3830c8de5b0SBaptiste Daroussin data->s_mark = newss + i; 3840c8de5b0SBaptiste Daroussin 3850c8de5b0SBaptiste Daroussin newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); 3860c8de5b0SBaptiste Daroussin if (newvs == 0) 3870c8de5b0SBaptiste Daroussin return YYENOMEM; 3880c8de5b0SBaptiste Daroussin 3890c8de5b0SBaptiste Daroussin data->l_base = newvs; 3900c8de5b0SBaptiste Daroussin data->l_mark = newvs + i; 3910c8de5b0SBaptiste Daroussin 3920c8de5b0SBaptiste Daroussin data->stacksize = newsize; 3930c8de5b0SBaptiste Daroussin data->s_last = data->s_base + newsize - 1; 3940c8de5b0SBaptiste Daroussin return 0; 3950c8de5b0SBaptiste Daroussin } 3960c8de5b0SBaptiste Daroussin 3970c8de5b0SBaptiste Daroussin #if YYPURE || defined(YY_NO_LEAKS) 3980c8de5b0SBaptiste Daroussin static void yyfreestack(YYSTACKDATA *data) 3990c8de5b0SBaptiste Daroussin { 4000c8de5b0SBaptiste Daroussin free(data->s_base); 4010c8de5b0SBaptiste Daroussin free(data->l_base); 4020c8de5b0SBaptiste Daroussin memset(data, 0, sizeof(*data)); 4030c8de5b0SBaptiste Daroussin } 4040c8de5b0SBaptiste Daroussin #else 4050c8de5b0SBaptiste Daroussin #define yyfreestack(data) /* nothing */ 4060c8de5b0SBaptiste Daroussin #endif 4070c8de5b0SBaptiste Daroussin 4080c8de5b0SBaptiste Daroussin #define YYABORT goto yyabort 4090c8de5b0SBaptiste Daroussin #define YYREJECT goto yyabort 4100c8de5b0SBaptiste Daroussin #define YYACCEPT goto yyaccept 4110c8de5b0SBaptiste Daroussin #define YYERROR goto yyerrlab 4120c8de5b0SBaptiste Daroussin 4130c8de5b0SBaptiste Daroussin int 4140c8de5b0SBaptiste Daroussin YYPARSE_DECL() 4150c8de5b0SBaptiste Daroussin { 4160c8de5b0SBaptiste Daroussin int yym, yyn, yystate; 4170c8de5b0SBaptiste Daroussin #if YYDEBUG 4180c8de5b0SBaptiste Daroussin const char *yys; 4190c8de5b0SBaptiste Daroussin 4200c8de5b0SBaptiste Daroussin if ((yys = getenv("YYDEBUG")) != 0) 4210c8de5b0SBaptiste Daroussin { 4220c8de5b0SBaptiste Daroussin yyn = *yys; 4230c8de5b0SBaptiste Daroussin if (yyn >= '0' && yyn <= '9') 4240c8de5b0SBaptiste Daroussin yydebug = yyn - '0'; 4250c8de5b0SBaptiste Daroussin } 4260c8de5b0SBaptiste Daroussin #endif 4270c8de5b0SBaptiste Daroussin 428*c5b5d71aSJung-uk Kim yym = 0; 429*c5b5d71aSJung-uk Kim yyn = 0; 4300c8de5b0SBaptiste Daroussin yynerrs = 0; 4310c8de5b0SBaptiste Daroussin yyerrflag = 0; 4320c8de5b0SBaptiste Daroussin yychar = YYEMPTY; 4330c8de5b0SBaptiste Daroussin yystate = 0; 4340c8de5b0SBaptiste Daroussin 4350c8de5b0SBaptiste Daroussin #if YYPURE 4360c8de5b0SBaptiste Daroussin memset(&yystack, 0, sizeof(yystack)); 4370c8de5b0SBaptiste Daroussin #endif 4380c8de5b0SBaptiste Daroussin 4390c8de5b0SBaptiste Daroussin if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 4400c8de5b0SBaptiste Daroussin yystack.s_mark = yystack.s_base; 4410c8de5b0SBaptiste Daroussin yystack.l_mark = yystack.l_base; 4420c8de5b0SBaptiste Daroussin yystate = 0; 4430c8de5b0SBaptiste Daroussin *yystack.s_mark = 0; 4440c8de5b0SBaptiste Daroussin 4450c8de5b0SBaptiste Daroussin yyloop: 4460c8de5b0SBaptiste Daroussin if ((yyn = yydefred[yystate]) != 0) goto yyreduce; 4470c8de5b0SBaptiste Daroussin if (yychar < 0) 4480c8de5b0SBaptiste Daroussin { 449*c5b5d71aSJung-uk Kim yychar = YYLEX; 450*c5b5d71aSJung-uk Kim if (yychar < 0) yychar = YYEOF; 4510c8de5b0SBaptiste Daroussin #if YYDEBUG 4520c8de5b0SBaptiste Daroussin if (yydebug) 4530c8de5b0SBaptiste Daroussin { 454*c5b5d71aSJung-uk Kim if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; 4550c8de5b0SBaptiste Daroussin printf("%sdebug: state %d, reading %d (%s)\n", 4560c8de5b0SBaptiste Daroussin YYPREFIX, yystate, yychar, yys); 4570c8de5b0SBaptiste Daroussin } 4580c8de5b0SBaptiste Daroussin #endif 4590c8de5b0SBaptiste Daroussin } 460*c5b5d71aSJung-uk Kim if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && 461*c5b5d71aSJung-uk Kim yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) 4620c8de5b0SBaptiste Daroussin { 4630c8de5b0SBaptiste Daroussin #if YYDEBUG 4640c8de5b0SBaptiste Daroussin if (yydebug) 4650c8de5b0SBaptiste Daroussin printf("%sdebug: state %d, shifting to state %d\n", 4660c8de5b0SBaptiste Daroussin YYPREFIX, yystate, yytable[yyn]); 4670c8de5b0SBaptiste Daroussin #endif 468*c5b5d71aSJung-uk Kim if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 4690c8de5b0SBaptiste Daroussin yystate = yytable[yyn]; 4700c8de5b0SBaptiste Daroussin *++yystack.s_mark = yytable[yyn]; 4710c8de5b0SBaptiste Daroussin *++yystack.l_mark = yylval; 4720c8de5b0SBaptiste Daroussin yychar = YYEMPTY; 4730c8de5b0SBaptiste Daroussin if (yyerrflag > 0) --yyerrflag; 4740c8de5b0SBaptiste Daroussin goto yyloop; 4750c8de5b0SBaptiste Daroussin } 476*c5b5d71aSJung-uk Kim if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && 477*c5b5d71aSJung-uk Kim yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) 4780c8de5b0SBaptiste Daroussin { 4790c8de5b0SBaptiste Daroussin yyn = yytable[yyn]; 4800c8de5b0SBaptiste Daroussin goto yyreduce; 4810c8de5b0SBaptiste Daroussin } 482*c5b5d71aSJung-uk Kim if (yyerrflag != 0) goto yyinrecovery; 4830c8de5b0SBaptiste Daroussin 4840c8de5b0SBaptiste Daroussin YYERROR_CALL("syntax error"); 4850c8de5b0SBaptiste Daroussin 486*c5b5d71aSJung-uk Kim goto yyerrlab; /* redundant goto avoids 'unused label' warning */ 4870c8de5b0SBaptiste Daroussin yyerrlab: 4880c8de5b0SBaptiste Daroussin ++yynerrs; 4890c8de5b0SBaptiste Daroussin 4900c8de5b0SBaptiste Daroussin yyinrecovery: 4910c8de5b0SBaptiste Daroussin if (yyerrflag < 3) 4920c8de5b0SBaptiste Daroussin { 4930c8de5b0SBaptiste Daroussin yyerrflag = 3; 4940c8de5b0SBaptiste Daroussin for (;;) 4950c8de5b0SBaptiste Daroussin { 496*c5b5d71aSJung-uk Kim if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && 497*c5b5d71aSJung-uk Kim yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) 4980c8de5b0SBaptiste Daroussin { 4990c8de5b0SBaptiste Daroussin #if YYDEBUG 5000c8de5b0SBaptiste Daroussin if (yydebug) 5010c8de5b0SBaptiste Daroussin printf("%sdebug: state %d, error recovery shifting\ 5020c8de5b0SBaptiste Daroussin to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); 5030c8de5b0SBaptiste Daroussin #endif 504*c5b5d71aSJung-uk Kim if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 5050c8de5b0SBaptiste Daroussin yystate = yytable[yyn]; 5060c8de5b0SBaptiste Daroussin *++yystack.s_mark = yytable[yyn]; 5070c8de5b0SBaptiste Daroussin *++yystack.l_mark = yylval; 5080c8de5b0SBaptiste Daroussin goto yyloop; 5090c8de5b0SBaptiste Daroussin } 5100c8de5b0SBaptiste Daroussin else 5110c8de5b0SBaptiste Daroussin { 5120c8de5b0SBaptiste Daroussin #if YYDEBUG 5130c8de5b0SBaptiste Daroussin if (yydebug) 5140c8de5b0SBaptiste Daroussin printf("%sdebug: error recovery discarding state %d\n", 5150c8de5b0SBaptiste Daroussin YYPREFIX, *yystack.s_mark); 5160c8de5b0SBaptiste Daroussin #endif 5170c8de5b0SBaptiste Daroussin if (yystack.s_mark <= yystack.s_base) goto yyabort; 5180c8de5b0SBaptiste Daroussin --yystack.s_mark; 5190c8de5b0SBaptiste Daroussin --yystack.l_mark; 5200c8de5b0SBaptiste Daroussin } 5210c8de5b0SBaptiste Daroussin } 5220c8de5b0SBaptiste Daroussin } 5230c8de5b0SBaptiste Daroussin else 5240c8de5b0SBaptiste Daroussin { 5250c8de5b0SBaptiste Daroussin if (yychar == YYEOF) goto yyabort; 5260c8de5b0SBaptiste Daroussin #if YYDEBUG 5270c8de5b0SBaptiste Daroussin if (yydebug) 5280c8de5b0SBaptiste Daroussin { 529*c5b5d71aSJung-uk Kim if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; 5300c8de5b0SBaptiste Daroussin printf("%sdebug: state %d, error recovery discards token %d (%s)\n", 5310c8de5b0SBaptiste Daroussin YYPREFIX, yystate, yychar, yys); 5320c8de5b0SBaptiste Daroussin } 5330c8de5b0SBaptiste Daroussin #endif 5340c8de5b0SBaptiste Daroussin yychar = YYEMPTY; 5350c8de5b0SBaptiste Daroussin goto yyloop; 5360c8de5b0SBaptiste Daroussin } 5370c8de5b0SBaptiste Daroussin 5380c8de5b0SBaptiste Daroussin yyreduce: 5390c8de5b0SBaptiste Daroussin #if YYDEBUG 5400c8de5b0SBaptiste Daroussin if (yydebug) 5410c8de5b0SBaptiste Daroussin printf("%sdebug: state %d, reducing by rule %d (%s)\n", 5420c8de5b0SBaptiste Daroussin YYPREFIX, yystate, yyn, yyrule[yyn]); 5430c8de5b0SBaptiste Daroussin #endif 5440c8de5b0SBaptiste Daroussin yym = yylen[yyn]; 545*c5b5d71aSJung-uk Kim if (yym > 0) 5460c8de5b0SBaptiste Daroussin yyval = yystack.l_mark[1-yym]; 5470c8de5b0SBaptiste Daroussin else 5480c8de5b0SBaptiste Daroussin memset(&yyval, 0, sizeof yyval); 549*c5b5d71aSJung-uk Kim 5500c8de5b0SBaptiste Daroussin switch (yyn) 5510c8de5b0SBaptiste Daroussin { 5520c8de5b0SBaptiste Daroussin case 3: 5530c8de5b0SBaptiste Daroussin #line 28 "calc.y" 5540c8de5b0SBaptiste Daroussin { yyerrok ; } 5550c8de5b0SBaptiste Daroussin break; 5560c8de5b0SBaptiste Daroussin case 4: 5570c8de5b0SBaptiste Daroussin #line 32 "calc.y" 5580c8de5b0SBaptiste Daroussin { printf("%d\n",yystack.l_mark[0]);} 5590c8de5b0SBaptiste Daroussin break; 5600c8de5b0SBaptiste Daroussin case 5: 5610c8de5b0SBaptiste Daroussin #line 34 "calc.y" 5620c8de5b0SBaptiste Daroussin { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } 5630c8de5b0SBaptiste Daroussin break; 5640c8de5b0SBaptiste Daroussin case 6: 5650c8de5b0SBaptiste Daroussin #line 38 "calc.y" 5660c8de5b0SBaptiste Daroussin { yyval = yystack.l_mark[-1]; } 5670c8de5b0SBaptiste Daroussin break; 5680c8de5b0SBaptiste Daroussin case 7: 5690c8de5b0SBaptiste Daroussin #line 40 "calc.y" 5700c8de5b0SBaptiste Daroussin { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } 5710c8de5b0SBaptiste Daroussin break; 5720c8de5b0SBaptiste Daroussin case 8: 5730c8de5b0SBaptiste Daroussin #line 42 "calc.y" 5740c8de5b0SBaptiste Daroussin { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } 5750c8de5b0SBaptiste Daroussin break; 5760c8de5b0SBaptiste Daroussin case 9: 5770c8de5b0SBaptiste Daroussin #line 44 "calc.y" 5780c8de5b0SBaptiste Daroussin { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } 5790c8de5b0SBaptiste Daroussin break; 5800c8de5b0SBaptiste Daroussin case 10: 5810c8de5b0SBaptiste Daroussin #line 46 "calc.y" 5820c8de5b0SBaptiste Daroussin { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } 5830c8de5b0SBaptiste Daroussin break; 5840c8de5b0SBaptiste Daroussin case 11: 5850c8de5b0SBaptiste Daroussin #line 48 "calc.y" 5860c8de5b0SBaptiste Daroussin { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } 5870c8de5b0SBaptiste Daroussin break; 5880c8de5b0SBaptiste Daroussin case 12: 5890c8de5b0SBaptiste Daroussin #line 50 "calc.y" 5900c8de5b0SBaptiste Daroussin { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } 5910c8de5b0SBaptiste Daroussin break; 5920c8de5b0SBaptiste Daroussin case 13: 5930c8de5b0SBaptiste Daroussin #line 52 "calc.y" 5940c8de5b0SBaptiste Daroussin { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } 5950c8de5b0SBaptiste Daroussin break; 5960c8de5b0SBaptiste Daroussin case 14: 5970c8de5b0SBaptiste Daroussin #line 54 "calc.y" 5980c8de5b0SBaptiste Daroussin { yyval = - yystack.l_mark[0]; } 5990c8de5b0SBaptiste Daroussin break; 6000c8de5b0SBaptiste Daroussin case 15: 6010c8de5b0SBaptiste Daroussin #line 56 "calc.y" 6020c8de5b0SBaptiste Daroussin { yyval = regs[yystack.l_mark[0]]; } 6030c8de5b0SBaptiste Daroussin break; 6040c8de5b0SBaptiste Daroussin case 17: 6050c8de5b0SBaptiste Daroussin #line 61 "calc.y" 6060c8de5b0SBaptiste Daroussin { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } 6070c8de5b0SBaptiste Daroussin break; 6080c8de5b0SBaptiste Daroussin case 18: 6090c8de5b0SBaptiste Daroussin #line 63 "calc.y" 6100c8de5b0SBaptiste Daroussin { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } 6110c8de5b0SBaptiste Daroussin break; 612*c5b5d71aSJung-uk Kim #line 613 "calc.tab.c" 6130c8de5b0SBaptiste Daroussin } 6140c8de5b0SBaptiste Daroussin yystack.s_mark -= yym; 6150c8de5b0SBaptiste Daroussin yystate = *yystack.s_mark; 6160c8de5b0SBaptiste Daroussin yystack.l_mark -= yym; 6170c8de5b0SBaptiste Daroussin yym = yylhs[yyn]; 6180c8de5b0SBaptiste Daroussin if (yystate == 0 && yym == 0) 6190c8de5b0SBaptiste Daroussin { 6200c8de5b0SBaptiste Daroussin #if YYDEBUG 6210c8de5b0SBaptiste Daroussin if (yydebug) 6220c8de5b0SBaptiste Daroussin printf("%sdebug: after reduction, shifting from state 0 to\ 6230c8de5b0SBaptiste Daroussin state %d\n", YYPREFIX, YYFINAL); 6240c8de5b0SBaptiste Daroussin #endif 6250c8de5b0SBaptiste Daroussin yystate = YYFINAL; 6260c8de5b0SBaptiste Daroussin *++yystack.s_mark = YYFINAL; 6270c8de5b0SBaptiste Daroussin *++yystack.l_mark = yyval; 6280c8de5b0SBaptiste Daroussin if (yychar < 0) 6290c8de5b0SBaptiste Daroussin { 630*c5b5d71aSJung-uk Kim yychar = YYLEX; 631*c5b5d71aSJung-uk Kim if (yychar < 0) yychar = YYEOF; 6320c8de5b0SBaptiste Daroussin #if YYDEBUG 6330c8de5b0SBaptiste Daroussin if (yydebug) 6340c8de5b0SBaptiste Daroussin { 635*c5b5d71aSJung-uk Kim if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; 6360c8de5b0SBaptiste Daroussin printf("%sdebug: state %d, reading %d (%s)\n", 6370c8de5b0SBaptiste Daroussin YYPREFIX, YYFINAL, yychar, yys); 6380c8de5b0SBaptiste Daroussin } 6390c8de5b0SBaptiste Daroussin #endif 6400c8de5b0SBaptiste Daroussin } 6410c8de5b0SBaptiste Daroussin if (yychar == YYEOF) goto yyaccept; 6420c8de5b0SBaptiste Daroussin goto yyloop; 6430c8de5b0SBaptiste Daroussin } 644*c5b5d71aSJung-uk Kim if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && 645*c5b5d71aSJung-uk Kim yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) 6460c8de5b0SBaptiste Daroussin yystate = yytable[yyn]; 6470c8de5b0SBaptiste Daroussin else 6480c8de5b0SBaptiste Daroussin yystate = yydgoto[yym]; 6490c8de5b0SBaptiste Daroussin #if YYDEBUG 6500c8de5b0SBaptiste Daroussin if (yydebug) 6510c8de5b0SBaptiste Daroussin printf("%sdebug: after reduction, shifting from state %d \ 6520c8de5b0SBaptiste Daroussin to state %d\n", YYPREFIX, *yystack.s_mark, yystate); 6530c8de5b0SBaptiste Daroussin #endif 654*c5b5d71aSJung-uk Kim if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 6550c8de5b0SBaptiste Daroussin *++yystack.s_mark = (YYINT) yystate; 6560c8de5b0SBaptiste Daroussin *++yystack.l_mark = yyval; 6570c8de5b0SBaptiste Daroussin goto yyloop; 6580c8de5b0SBaptiste Daroussin 6590c8de5b0SBaptiste Daroussin yyoverflow: 6600c8de5b0SBaptiste Daroussin YYERROR_CALL("yacc stack overflow"); 6610c8de5b0SBaptiste Daroussin 6620c8de5b0SBaptiste Daroussin yyabort: 6630c8de5b0SBaptiste Daroussin yyfreestack(&yystack); 6640c8de5b0SBaptiste Daroussin return (1); 6650c8de5b0SBaptiste Daroussin 6660c8de5b0SBaptiste Daroussin yyaccept: 6670c8de5b0SBaptiste Daroussin yyfreestack(&yystack); 6680c8de5b0SBaptiste Daroussin return (0); 6690c8de5b0SBaptiste Daroussin } 670