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 6*8e022d3cSDag-Erling Smørgrav #define YYMAJOR 2 7*8e022d3cSDag-Erling Smørgrav #define YYMINOR 0 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 calc1_parse 190c8de5b0SBaptiste Daroussin #endif /* yyparse */ 200c8de5b0SBaptiste Daroussin 210c8de5b0SBaptiste Daroussin #ifndef yylex 220c8de5b0SBaptiste Daroussin #define yylex calc1_lex 230c8de5b0SBaptiste Daroussin #endif /* yylex */ 240c8de5b0SBaptiste Daroussin 250c8de5b0SBaptiste Daroussin #ifndef yyerror 260c8de5b0SBaptiste Daroussin #define yyerror calc1_error 270c8de5b0SBaptiste Daroussin #endif /* yyerror */ 280c8de5b0SBaptiste Daroussin 290c8de5b0SBaptiste Daroussin #ifndef yychar 300c8de5b0SBaptiste Daroussin #define yychar calc1_char 310c8de5b0SBaptiste Daroussin #endif /* yychar */ 320c8de5b0SBaptiste Daroussin 330c8de5b0SBaptiste Daroussin #ifndef yyval 340c8de5b0SBaptiste Daroussin #define yyval calc1_val 350c8de5b0SBaptiste Daroussin #endif /* yyval */ 360c8de5b0SBaptiste Daroussin 370c8de5b0SBaptiste Daroussin #ifndef yylval 380c8de5b0SBaptiste Daroussin #define yylval calc1_lval 390c8de5b0SBaptiste Daroussin #endif /* yylval */ 400c8de5b0SBaptiste Daroussin 410c8de5b0SBaptiste Daroussin #ifndef yydebug 420c8de5b0SBaptiste Daroussin #define yydebug calc1_debug 430c8de5b0SBaptiste Daroussin #endif /* yydebug */ 440c8de5b0SBaptiste Daroussin 450c8de5b0SBaptiste Daroussin #ifndef yynerrs 460c8de5b0SBaptiste Daroussin #define yynerrs calc1_nerrs 470c8de5b0SBaptiste Daroussin #endif /* yynerrs */ 480c8de5b0SBaptiste Daroussin 490c8de5b0SBaptiste Daroussin #ifndef yyerrflag 500c8de5b0SBaptiste Daroussin #define yyerrflag calc1_errflag 510c8de5b0SBaptiste Daroussin #endif /* yyerrflag */ 520c8de5b0SBaptiste Daroussin 530c8de5b0SBaptiste Daroussin #ifndef yylhs 540c8de5b0SBaptiste Daroussin #define yylhs calc1_lhs 550c8de5b0SBaptiste Daroussin #endif /* yylhs */ 560c8de5b0SBaptiste Daroussin 570c8de5b0SBaptiste Daroussin #ifndef yylen 580c8de5b0SBaptiste Daroussin #define yylen calc1_len 590c8de5b0SBaptiste Daroussin #endif /* yylen */ 600c8de5b0SBaptiste Daroussin 610c8de5b0SBaptiste Daroussin #ifndef yydefred 620c8de5b0SBaptiste Daroussin #define yydefred calc1_defred 630c8de5b0SBaptiste Daroussin #endif /* yydefred */ 640c8de5b0SBaptiste Daroussin 650c8de5b0SBaptiste Daroussin #ifndef yydgoto 660c8de5b0SBaptiste Daroussin #define yydgoto calc1_dgoto 670c8de5b0SBaptiste Daroussin #endif /* yydgoto */ 680c8de5b0SBaptiste Daroussin 690c8de5b0SBaptiste Daroussin #ifndef yysindex 700c8de5b0SBaptiste Daroussin #define yysindex calc1_sindex 710c8de5b0SBaptiste Daroussin #endif /* yysindex */ 720c8de5b0SBaptiste Daroussin 730c8de5b0SBaptiste Daroussin #ifndef yyrindex 740c8de5b0SBaptiste Daroussin #define yyrindex calc1_rindex 750c8de5b0SBaptiste Daroussin #endif /* yyrindex */ 760c8de5b0SBaptiste Daroussin 770c8de5b0SBaptiste Daroussin #ifndef yygindex 780c8de5b0SBaptiste Daroussin #define yygindex calc1_gindex 790c8de5b0SBaptiste Daroussin #endif /* yygindex */ 800c8de5b0SBaptiste Daroussin 810c8de5b0SBaptiste Daroussin #ifndef yytable 820c8de5b0SBaptiste Daroussin #define yytable calc1_table 830c8de5b0SBaptiste Daroussin #endif /* yytable */ 840c8de5b0SBaptiste Daroussin 850c8de5b0SBaptiste Daroussin #ifndef yycheck 860c8de5b0SBaptiste Daroussin #define yycheck calc1_check 870c8de5b0SBaptiste Daroussin #endif /* yycheck */ 880c8de5b0SBaptiste Daroussin 890c8de5b0SBaptiste Daroussin #ifndef yyname 900c8de5b0SBaptiste Daroussin #define yyname calc1_name 910c8de5b0SBaptiste Daroussin #endif /* yyname */ 920c8de5b0SBaptiste Daroussin 930c8de5b0SBaptiste Daroussin #ifndef yyrule 940c8de5b0SBaptiste Daroussin #define yyrule calc1_rule 950c8de5b0SBaptiste Daroussin #endif /* yyrule */ 960c8de5b0SBaptiste Daroussin #define YYPREFIX "calc1_" 970c8de5b0SBaptiste Daroussin 980c8de5b0SBaptiste Daroussin #define YYPURE 0 990c8de5b0SBaptiste Daroussin 1000c8de5b0SBaptiste Daroussin #line 2 "calc1.y" 1010c8de5b0SBaptiste Daroussin 1020c8de5b0SBaptiste Daroussin /* http://dinosaur.compilertools.net/yacc/index.html */ 1030c8de5b0SBaptiste Daroussin 1040c8de5b0SBaptiste Daroussin #include <stdlib.h> 1050c8de5b0SBaptiste Daroussin #include <stdio.h> 1060c8de5b0SBaptiste Daroussin #include <ctype.h> 1070c8de5b0SBaptiste Daroussin #include <math.h> 1080c8de5b0SBaptiste Daroussin 1090c8de5b0SBaptiste Daroussin typedef struct interval 1100c8de5b0SBaptiste Daroussin { 1110c8de5b0SBaptiste Daroussin double lo, hi; 1120c8de5b0SBaptiste Daroussin } 1130c8de5b0SBaptiste Daroussin INTERVAL; 1140c8de5b0SBaptiste Daroussin 1150c8de5b0SBaptiste Daroussin INTERVAL vmul(double, double, INTERVAL); 1160c8de5b0SBaptiste Daroussin INTERVAL vdiv(double, double, INTERVAL); 1170c8de5b0SBaptiste Daroussin 1180c8de5b0SBaptiste Daroussin extern int yylex(void); 1190c8de5b0SBaptiste Daroussin static void yyerror(const char *s); 1200c8de5b0SBaptiste Daroussin 1210c8de5b0SBaptiste Daroussin int dcheck(INTERVAL); 1220c8de5b0SBaptiste Daroussin 1230c8de5b0SBaptiste Daroussin double dreg[26]; 1240c8de5b0SBaptiste Daroussin INTERVAL vreg[26]; 1250c8de5b0SBaptiste Daroussin 1260c8de5b0SBaptiste Daroussin #ifdef YYSTYPE 1270c8de5b0SBaptiste Daroussin #undef YYSTYPE_IS_DECLARED 1280c8de5b0SBaptiste Daroussin #define YYSTYPE_IS_DECLARED 1 1290c8de5b0SBaptiste Daroussin #endif 1300c8de5b0SBaptiste Daroussin #ifndef YYSTYPE_IS_DECLARED 1310c8de5b0SBaptiste Daroussin #define YYSTYPE_IS_DECLARED 1 132c5b5d71aSJung-uk Kim #line 31 "calc1.y" 133*8e022d3cSDag-Erling Smørgrav typedef union YYSTYPE 1340c8de5b0SBaptiste Daroussin { 1350c8de5b0SBaptiste Daroussin int ival; 1360c8de5b0SBaptiste Daroussin double dval; 1370c8de5b0SBaptiste Daroussin INTERVAL vval; 1380c8de5b0SBaptiste Daroussin } YYSTYPE; 1390c8de5b0SBaptiste Daroussin #endif /* !YYSTYPE_IS_DECLARED */ 1400c8de5b0SBaptiste Daroussin #line 141 "calc1.tab.c" 1410c8de5b0SBaptiste Daroussin 1420c8de5b0SBaptiste Daroussin /* compatibility with bison */ 1430c8de5b0SBaptiste Daroussin #ifdef YYPARSE_PARAM 1440c8de5b0SBaptiste Daroussin /* compatibility with FreeBSD */ 1450c8de5b0SBaptiste Daroussin # ifdef YYPARSE_PARAM_TYPE 1460c8de5b0SBaptiste Daroussin # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) 1470c8de5b0SBaptiste Daroussin # else 1480c8de5b0SBaptiste Daroussin # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) 1490c8de5b0SBaptiste Daroussin # endif 1500c8de5b0SBaptiste Daroussin #else 1510c8de5b0SBaptiste Daroussin # define YYPARSE_DECL() yyparse(void) 1520c8de5b0SBaptiste Daroussin #endif 1530c8de5b0SBaptiste Daroussin 1540c8de5b0SBaptiste Daroussin /* Parameters sent to lex. */ 1550c8de5b0SBaptiste Daroussin #ifdef YYLEX_PARAM 1560c8de5b0SBaptiste Daroussin # define YYLEX_DECL() yylex(void *YYLEX_PARAM) 1570c8de5b0SBaptiste Daroussin # define YYLEX yylex(YYLEX_PARAM) 1580c8de5b0SBaptiste Daroussin #else 1590c8de5b0SBaptiste Daroussin # define YYLEX_DECL() yylex(void) 1600c8de5b0SBaptiste Daroussin # define YYLEX yylex() 1610c8de5b0SBaptiste Daroussin #endif 1620c8de5b0SBaptiste Daroussin 1630c8de5b0SBaptiste Daroussin /* Parameters sent to yyerror. */ 1640c8de5b0SBaptiste Daroussin #ifndef YYERROR_DECL 1650c8de5b0SBaptiste Daroussin #define YYERROR_DECL() yyerror(const char *s) 1660c8de5b0SBaptiste Daroussin #endif 1670c8de5b0SBaptiste Daroussin #ifndef YYERROR_CALL 1680c8de5b0SBaptiste Daroussin #define YYERROR_CALL(msg) yyerror(msg) 1690c8de5b0SBaptiste Daroussin #endif 1700c8de5b0SBaptiste Daroussin 1710c8de5b0SBaptiste Daroussin extern int YYPARSE_DECL(); 1720c8de5b0SBaptiste Daroussin 1730c8de5b0SBaptiste Daroussin #define DREG 257 1740c8de5b0SBaptiste Daroussin #define VREG 258 1750c8de5b0SBaptiste Daroussin #define CONST 259 1760c8de5b0SBaptiste Daroussin #define UMINUS 260 1770c8de5b0SBaptiste Daroussin #define YYERRCODE 256 178ea2af5c8SJung-uk Kim typedef int YYINT; 1790c8de5b0SBaptiste Daroussin static const YYINT calc1_lhs[] = { -1, 1800c8de5b0SBaptiste Daroussin 3, 3, 0, 0, 0, 0, 0, 1, 1, 1, 1810c8de5b0SBaptiste Daroussin 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 1820c8de5b0SBaptiste Daroussin 2, 2, 2, 2, 2, 2, 2, 2, 1830c8de5b0SBaptiste Daroussin }; 1840c8de5b0SBaptiste Daroussin static const YYINT calc1_len[] = { 2, 1850c8de5b0SBaptiste Daroussin 0, 2, 2, 2, 4, 4, 2, 1, 1, 3, 1860c8de5b0SBaptiste Daroussin 3, 3, 3, 2, 3, 1, 5, 1, 3, 3, 1870c8de5b0SBaptiste Daroussin 3, 3, 3, 3, 3, 3, 2, 3, 1880c8de5b0SBaptiste Daroussin }; 1890c8de5b0SBaptiste Daroussin static const YYINT calc1_defred[] = { 0, 1900c8de5b0SBaptiste Daroussin 0, 0, 0, 8, 0, 0, 0, 0, 0, 7, 1910c8de5b0SBaptiste Daroussin 0, 0, 9, 18, 14, 27, 0, 0, 0, 0, 1920c8de5b0SBaptiste Daroussin 0, 0, 3, 0, 0, 0, 0, 4, 0, 0, 1930c8de5b0SBaptiste Daroussin 0, 0, 0, 15, 0, 28, 0, 0, 0, 0, 1940c8de5b0SBaptiste Daroussin 12, 24, 13, 26, 0, 0, 23, 25, 14, 0, 1950c8de5b0SBaptiste Daroussin 0, 0, 0, 0, 5, 6, 0, 0, 0, 12, 1960c8de5b0SBaptiste Daroussin 13, 17, 1970c8de5b0SBaptiste Daroussin }; 1980c8de5b0SBaptiste Daroussin static const YYINT calc1_dgoto[] = { 7, 1990c8de5b0SBaptiste Daroussin 32, 9, 0, 2000c8de5b0SBaptiste Daroussin }; 2010c8de5b0SBaptiste Daroussin static const YYINT calc1_sindex[] = { -40, 2020c8de5b0SBaptiste Daroussin -8, -48, -47, 0, -37, -37, 0, 2, 17, 0, 2030c8de5b0SBaptiste Daroussin -34, -37, 0, 0, 0, 0, -25, 90, -37, -37, 2040c8de5b0SBaptiste Daroussin -37, -37, 0, -37, -37, -37, -37, 0, -34, -34, 2050c8de5b0SBaptiste Daroussin 25, 125, 31, 0, -34, 0, -11, 37, -11, 37, 2060c8de5b0SBaptiste Daroussin 0, 0, 0, 0, 37, 37, 0, 0, 0, 111, 2070c8de5b0SBaptiste Daroussin -34, -34, -34, -34, 0, 0, 118, 69, 69, 0, 2080c8de5b0SBaptiste Daroussin 0, 0, 2090c8de5b0SBaptiste Daroussin }; 2100c8de5b0SBaptiste Daroussin static const YYINT calc1_rindex[] = { 0, 2110c8de5b0SBaptiste Daroussin 0, 38, 44, 0, 0, 0, 0, 0, 0, 0, 2120c8de5b0SBaptiste Daroussin 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2130c8de5b0SBaptiste Daroussin 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2140c8de5b0SBaptiste Daroussin 0, -9, 0, 0, 0, 0, 51, -3, 56, 61, 2150c8de5b0SBaptiste Daroussin 0, 0, 0, 0, 67, 72, 0, 0, 0, 0, 2160c8de5b0SBaptiste Daroussin 0, 0, 0, 0, 0, 0, 0, 78, 83, 0, 2170c8de5b0SBaptiste Daroussin 0, 0, 2180c8de5b0SBaptiste Daroussin }; 2190c8de5b0SBaptiste Daroussin static const YYINT calc1_gindex[] = { 0, 2200c8de5b0SBaptiste Daroussin 4, 124, 0, 2210c8de5b0SBaptiste Daroussin }; 2220c8de5b0SBaptiste Daroussin #define YYTABLESIZE 225 2230c8de5b0SBaptiste Daroussin static const YYINT calc1_table[] = { 6, 2240c8de5b0SBaptiste Daroussin 16, 10, 6, 8, 5, 30, 20, 5, 15, 17, 2250c8de5b0SBaptiste Daroussin 29, 23, 11, 12, 31, 34, 21, 19, 35, 20, 2260c8de5b0SBaptiste Daroussin 0, 22, 37, 39, 41, 43, 28, 0, 0, 0, 2270c8de5b0SBaptiste Daroussin 21, 16, 49, 50, 55, 22, 0, 20, 57, 20, 2280c8de5b0SBaptiste Daroussin 56, 20, 0, 21, 19, 0, 20, 9, 22, 0, 2290c8de5b0SBaptiste Daroussin 0, 0, 0, 18, 58, 59, 60, 61, 26, 24, 2300c8de5b0SBaptiste Daroussin 10, 25, 0, 27, 0, 11, 53, 51, 0, 52, 2310c8de5b0SBaptiste Daroussin 22, 54, 26, 24, 0, 25, 19, 27, 26, 9, 2320c8de5b0SBaptiste Daroussin 9, 21, 9, 27, 9, 18, 18, 10, 18, 0, 2330c8de5b0SBaptiste Daroussin 18, 10, 11, 10, 10, 10, 11, 0, 11, 11, 2340c8de5b0SBaptiste Daroussin 11, 22, 0, 22, 0, 22, 0, 19, 0, 19, 2350c8de5b0SBaptiste Daroussin 53, 19, 21, 0, 21, 54, 21, 0, 10, 0, 2360c8de5b0SBaptiste Daroussin 10, 0, 10, 11, 0, 11, 0, 11, 16, 18, 2370c8de5b0SBaptiste Daroussin 36, 26, 24, 0, 25, 33, 27, 0, 0, 0, 2380c8de5b0SBaptiste Daroussin 0, 0, 38, 40, 42, 44, 0, 45, 46, 47, 2390c8de5b0SBaptiste Daroussin 48, 34, 53, 51, 0, 52, 0, 54, 62, 53, 2400c8de5b0SBaptiste Daroussin 51, 0, 52, 0, 54, 0, 21, 19, 0, 20, 2410c8de5b0SBaptiste Daroussin 0, 22, 0, 0, 0, 0, 0, 0, 0, 0, 2420c8de5b0SBaptiste Daroussin 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2430c8de5b0SBaptiste Daroussin 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2440c8de5b0SBaptiste Daroussin 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2450c8de5b0SBaptiste Daroussin 0, 0, 0, 0, 0, 1, 2, 3, 4, 13, 2460c8de5b0SBaptiste Daroussin 14, 4, 13, 0, 4, 2470c8de5b0SBaptiste Daroussin }; 2480c8de5b0SBaptiste Daroussin static const YYINT calc1_check[] = { 40, 2490c8de5b0SBaptiste Daroussin 10, 10, 40, 0, 45, 40, 10, 45, 5, 6, 2500c8de5b0SBaptiste Daroussin 45, 10, 61, 61, 11, 41, 42, 43, 44, 45, 2510c8de5b0SBaptiste Daroussin -1, 47, 19, 20, 21, 22, 10, -1, -1, -1, 2520c8de5b0SBaptiste Daroussin 42, 41, 29, 30, 10, 47, -1, 41, 35, 43, 2530c8de5b0SBaptiste Daroussin 10, 45, -1, 42, 43, -1, 45, 10, 47, -1, 2540c8de5b0SBaptiste Daroussin -1, -1, -1, 10, 51, 52, 53, 54, 42, 43, 2550c8de5b0SBaptiste Daroussin 10, 45, -1, 47, -1, 10, 42, 43, -1, 45, 2560c8de5b0SBaptiste Daroussin 10, 47, 42, 43, -1, 45, 10, 47, 42, 42, 2570c8de5b0SBaptiste Daroussin 43, 10, 45, 47, 47, 42, 43, 10, 45, -1, 2580c8de5b0SBaptiste Daroussin 47, 41, 10, 43, 44, 45, 41, -1, 43, 44, 2590c8de5b0SBaptiste Daroussin 45, 41, -1, 43, -1, 45, -1, 41, -1, 43, 2600c8de5b0SBaptiste Daroussin 42, 45, 41, -1, 43, 47, 45, -1, 41, -1, 2610c8de5b0SBaptiste Daroussin 43, -1, 45, 41, -1, 43, -1, 45, 5, 6, 2620c8de5b0SBaptiste Daroussin 41, 42, 43, -1, 45, 12, 47, -1, -1, -1, 2630c8de5b0SBaptiste Daroussin -1, -1, 19, 20, 21, 22, -1, 24, 25, 26, 2640c8de5b0SBaptiste Daroussin 27, 41, 42, 43, -1, 45, -1, 47, 41, 42, 2650c8de5b0SBaptiste Daroussin 43, -1, 45, -1, 47, -1, 42, 43, -1, 45, 2660c8de5b0SBaptiste Daroussin -1, 47, -1, -1, -1, -1, -1, -1, -1, -1, 2670c8de5b0SBaptiste Daroussin -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2680c8de5b0SBaptiste Daroussin -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2690c8de5b0SBaptiste Daroussin -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2700c8de5b0SBaptiste Daroussin -1, -1, -1, -1, -1, 256, 257, 258, 259, 257, 2710c8de5b0SBaptiste Daroussin 258, 259, 257, -1, 259, 2720c8de5b0SBaptiste Daroussin }; 2730c8de5b0SBaptiste Daroussin #define YYFINAL 7 2740c8de5b0SBaptiste Daroussin #ifndef YYDEBUG 2750c8de5b0SBaptiste Daroussin #define YYDEBUG 0 2760c8de5b0SBaptiste Daroussin #endif 2770c8de5b0SBaptiste Daroussin #define YYMAXTOKEN 260 2780c8de5b0SBaptiste Daroussin #define YYUNDFTOKEN 266 2790c8de5b0SBaptiste Daroussin #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) 2800c8de5b0SBaptiste Daroussin #if YYDEBUG 2810c8de5b0SBaptiste Daroussin static const char *const calc1_name[] = { 2820c8de5b0SBaptiste Daroussin 2830c8de5b0SBaptiste 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, 2840c8de5b0SBaptiste Daroussin 0,0,0,0,0,0,0,0,0,"'('","')'","'*'","'+'","','","'-'",0,"'/'",0,0,0,0,0,0,0,0,0, 2850c8de5b0SBaptiste 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, 2860c8de5b0SBaptiste 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, 2870c8de5b0SBaptiste 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, 2880c8de5b0SBaptiste 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, 2890c8de5b0SBaptiste 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, 2900c8de5b0SBaptiste Daroussin 0,0,"DREG","VREG","CONST","UMINUS",0,0,0,0,0,"illegal-symbol", 2910c8de5b0SBaptiste Daroussin }; 2920c8de5b0SBaptiste Daroussin static const char *const calc1_rule[] = { 2930c8de5b0SBaptiste Daroussin "$accept : line", 2940c8de5b0SBaptiste Daroussin "lines :", 2950c8de5b0SBaptiste Daroussin "lines : lines line", 2960c8de5b0SBaptiste Daroussin "line : dexp '\\n'", 2970c8de5b0SBaptiste Daroussin "line : vexp '\\n'", 2980c8de5b0SBaptiste Daroussin "line : DREG '=' dexp '\\n'", 2990c8de5b0SBaptiste Daroussin "line : VREG '=' vexp '\\n'", 3000c8de5b0SBaptiste Daroussin "line : error '\\n'", 3010c8de5b0SBaptiste Daroussin "dexp : CONST", 3020c8de5b0SBaptiste Daroussin "dexp : DREG", 3030c8de5b0SBaptiste Daroussin "dexp : dexp '+' dexp", 3040c8de5b0SBaptiste Daroussin "dexp : dexp '-' dexp", 3050c8de5b0SBaptiste Daroussin "dexp : dexp '*' dexp", 3060c8de5b0SBaptiste Daroussin "dexp : dexp '/' dexp", 3070c8de5b0SBaptiste Daroussin "dexp : '-' dexp", 3080c8de5b0SBaptiste Daroussin "dexp : '(' dexp ')'", 3090c8de5b0SBaptiste Daroussin "vexp : dexp", 3100c8de5b0SBaptiste Daroussin "vexp : '(' dexp ',' dexp ')'", 3110c8de5b0SBaptiste Daroussin "vexp : VREG", 3120c8de5b0SBaptiste Daroussin "vexp : vexp '+' vexp", 3130c8de5b0SBaptiste Daroussin "vexp : dexp '+' vexp", 3140c8de5b0SBaptiste Daroussin "vexp : vexp '-' vexp", 3150c8de5b0SBaptiste Daroussin "vexp : dexp '-' vexp", 3160c8de5b0SBaptiste Daroussin "vexp : vexp '*' vexp", 3170c8de5b0SBaptiste Daroussin "vexp : dexp '*' vexp", 3180c8de5b0SBaptiste Daroussin "vexp : vexp '/' vexp", 3190c8de5b0SBaptiste Daroussin "vexp : dexp '/' vexp", 3200c8de5b0SBaptiste Daroussin "vexp : '-' vexp", 3210c8de5b0SBaptiste Daroussin "vexp : '(' vexp ')'", 3220c8de5b0SBaptiste Daroussin 3230c8de5b0SBaptiste Daroussin }; 3240c8de5b0SBaptiste Daroussin #endif 3250c8de5b0SBaptiste Daroussin 326b53bb29fSJung-uk Kim #if YYDEBUG 3270c8de5b0SBaptiste Daroussin int yydebug; 328b53bb29fSJung-uk Kim #endif 3290c8de5b0SBaptiste Daroussin 3300c8de5b0SBaptiste Daroussin int yyerrflag; 3310c8de5b0SBaptiste Daroussin int yychar; 3320c8de5b0SBaptiste Daroussin YYSTYPE yyval; 3330c8de5b0SBaptiste Daroussin YYSTYPE yylval; 334b53bb29fSJung-uk Kim int yynerrs; 3350c8de5b0SBaptiste Daroussin 3360c8de5b0SBaptiste Daroussin /* define the initial stack-sizes */ 3370c8de5b0SBaptiste Daroussin #ifdef YYSTACKSIZE 3380c8de5b0SBaptiste Daroussin #undef YYMAXDEPTH 3390c8de5b0SBaptiste Daroussin #define YYMAXDEPTH YYSTACKSIZE 3400c8de5b0SBaptiste Daroussin #else 3410c8de5b0SBaptiste Daroussin #ifdef YYMAXDEPTH 3420c8de5b0SBaptiste Daroussin #define YYSTACKSIZE YYMAXDEPTH 3430c8de5b0SBaptiste Daroussin #else 3440c8de5b0SBaptiste Daroussin #define YYSTACKSIZE 10000 3450c8de5b0SBaptiste Daroussin #define YYMAXDEPTH 10000 3460c8de5b0SBaptiste Daroussin #endif 3470c8de5b0SBaptiste Daroussin #endif 3480c8de5b0SBaptiste Daroussin 3490c8de5b0SBaptiste Daroussin #define YYINITSTACKSIZE 200 3500c8de5b0SBaptiste Daroussin 3510c8de5b0SBaptiste Daroussin typedef struct { 3520c8de5b0SBaptiste Daroussin unsigned stacksize; 3530c8de5b0SBaptiste Daroussin YYINT *s_base; 3540c8de5b0SBaptiste Daroussin YYINT *s_mark; 3550c8de5b0SBaptiste Daroussin YYINT *s_last; 3560c8de5b0SBaptiste Daroussin YYSTYPE *l_base; 3570c8de5b0SBaptiste Daroussin YYSTYPE *l_mark; 3580c8de5b0SBaptiste Daroussin } YYSTACKDATA; 3590c8de5b0SBaptiste Daroussin /* variables for the parser stack */ 3600c8de5b0SBaptiste Daroussin static YYSTACKDATA yystack; 3610c8de5b0SBaptiste Daroussin #line 176 "calc1.y" 3620c8de5b0SBaptiste Daroussin /* beginning of subroutines section */ 3630c8de5b0SBaptiste Daroussin 3640c8de5b0SBaptiste Daroussin #define BSZ 50 /* buffer size for floating point numbers */ 3650c8de5b0SBaptiste Daroussin 3660c8de5b0SBaptiste Daroussin /* lexical analysis */ 3670c8de5b0SBaptiste Daroussin 3680c8de5b0SBaptiste Daroussin static void 3690c8de5b0SBaptiste Daroussin yyerror(const char *s) 3700c8de5b0SBaptiste Daroussin { 3710c8de5b0SBaptiste Daroussin fprintf(stderr, "%s\n", s); 3720c8de5b0SBaptiste Daroussin } 3730c8de5b0SBaptiste Daroussin 3740c8de5b0SBaptiste Daroussin int 3750c8de5b0SBaptiste Daroussin yylex(void) 3760c8de5b0SBaptiste Daroussin { 3770c8de5b0SBaptiste Daroussin int c; 3780c8de5b0SBaptiste Daroussin 3790c8de5b0SBaptiste Daroussin while ((c = getchar()) == ' ') 3800c8de5b0SBaptiste Daroussin { /* skip over blanks */ 3810c8de5b0SBaptiste Daroussin } 3820c8de5b0SBaptiste Daroussin 3830c8de5b0SBaptiste Daroussin if (isupper(c)) 3840c8de5b0SBaptiste Daroussin { 3850c8de5b0SBaptiste Daroussin yylval.ival = c - 'A'; 3860c8de5b0SBaptiste Daroussin return (VREG); 3870c8de5b0SBaptiste Daroussin } 3880c8de5b0SBaptiste Daroussin if (islower(c)) 3890c8de5b0SBaptiste Daroussin { 3900c8de5b0SBaptiste Daroussin yylval.ival = c - 'a'; 3910c8de5b0SBaptiste Daroussin return (DREG); 3920c8de5b0SBaptiste Daroussin } 3930c8de5b0SBaptiste Daroussin 3940c8de5b0SBaptiste Daroussin if (isdigit(c) || c == '.') 3950c8de5b0SBaptiste Daroussin { 3960c8de5b0SBaptiste Daroussin /* gobble up digits, points, exponents */ 3970c8de5b0SBaptiste Daroussin char buf[BSZ + 1], *cp = buf; 3980c8de5b0SBaptiste Daroussin int dot = 0, expr = 0; 3990c8de5b0SBaptiste Daroussin 4000c8de5b0SBaptiste Daroussin for (; (cp - buf) < BSZ; ++cp, c = getchar()) 4010c8de5b0SBaptiste Daroussin { 4020c8de5b0SBaptiste Daroussin 4030c8de5b0SBaptiste Daroussin *cp = (char) c; 4040c8de5b0SBaptiste Daroussin if (isdigit(c)) 4050c8de5b0SBaptiste Daroussin continue; 4060c8de5b0SBaptiste Daroussin if (c == '.') 4070c8de5b0SBaptiste Daroussin { 4080c8de5b0SBaptiste Daroussin if (dot++ || expr) 4090c8de5b0SBaptiste Daroussin return ('.'); /* will cause syntax error */ 4100c8de5b0SBaptiste Daroussin continue; 4110c8de5b0SBaptiste Daroussin } 4120c8de5b0SBaptiste Daroussin 4130c8de5b0SBaptiste Daroussin if (c == 'e') 4140c8de5b0SBaptiste Daroussin { 4150c8de5b0SBaptiste Daroussin if (expr++) 4160c8de5b0SBaptiste Daroussin return ('e'); /* will cause syntax error */ 4170c8de5b0SBaptiste Daroussin continue; 4180c8de5b0SBaptiste Daroussin } 4190c8de5b0SBaptiste Daroussin 4200c8de5b0SBaptiste Daroussin /* end of number */ 4210c8de5b0SBaptiste Daroussin break; 4220c8de5b0SBaptiste Daroussin } 4230c8de5b0SBaptiste Daroussin *cp = '\0'; 4240c8de5b0SBaptiste Daroussin 4250c8de5b0SBaptiste Daroussin if ((cp - buf) >= BSZ) 4260c8de5b0SBaptiste Daroussin printf("constant too long: truncated\n"); 4270c8de5b0SBaptiste Daroussin else 4280c8de5b0SBaptiste Daroussin ungetc(c, stdin); /* push back last char read */ 4290c8de5b0SBaptiste Daroussin yylval.dval = atof(buf); 4300c8de5b0SBaptiste Daroussin return (CONST); 4310c8de5b0SBaptiste Daroussin } 4320c8de5b0SBaptiste Daroussin return (c); 4330c8de5b0SBaptiste Daroussin } 4340c8de5b0SBaptiste Daroussin 4350c8de5b0SBaptiste Daroussin static INTERVAL 4360c8de5b0SBaptiste Daroussin hilo(double a, double b, double c, double d) 4370c8de5b0SBaptiste Daroussin { 4380c8de5b0SBaptiste Daroussin /* returns the smallest interval containing a, b, c, and d */ 4390c8de5b0SBaptiste Daroussin /* used by *, / routines */ 4400c8de5b0SBaptiste Daroussin INTERVAL v; 4410c8de5b0SBaptiste Daroussin 4420c8de5b0SBaptiste Daroussin if (a > b) 4430c8de5b0SBaptiste Daroussin { 4440c8de5b0SBaptiste Daroussin v.hi = a; 4450c8de5b0SBaptiste Daroussin v.lo = b; 4460c8de5b0SBaptiste Daroussin } 4470c8de5b0SBaptiste Daroussin else 4480c8de5b0SBaptiste Daroussin { 4490c8de5b0SBaptiste Daroussin v.hi = b; 4500c8de5b0SBaptiste Daroussin v.lo = a; 4510c8de5b0SBaptiste Daroussin } 4520c8de5b0SBaptiste Daroussin 4530c8de5b0SBaptiste Daroussin if (c > d) 4540c8de5b0SBaptiste Daroussin { 4550c8de5b0SBaptiste Daroussin if (c > v.hi) 4560c8de5b0SBaptiste Daroussin v.hi = c; 4570c8de5b0SBaptiste Daroussin if (d < v.lo) 4580c8de5b0SBaptiste Daroussin v.lo = d; 4590c8de5b0SBaptiste Daroussin } 4600c8de5b0SBaptiste Daroussin else 4610c8de5b0SBaptiste Daroussin { 4620c8de5b0SBaptiste Daroussin if (d > v.hi) 4630c8de5b0SBaptiste Daroussin v.hi = d; 4640c8de5b0SBaptiste Daroussin if (c < v.lo) 4650c8de5b0SBaptiste Daroussin v.lo = c; 4660c8de5b0SBaptiste Daroussin } 4670c8de5b0SBaptiste Daroussin return (v); 4680c8de5b0SBaptiste Daroussin } 4690c8de5b0SBaptiste Daroussin 4700c8de5b0SBaptiste Daroussin INTERVAL 4710c8de5b0SBaptiste Daroussin vmul(double a, double b, INTERVAL v) 4720c8de5b0SBaptiste Daroussin { 4730c8de5b0SBaptiste Daroussin return (hilo(a * v.hi, a * v.lo, b * v.hi, b * v.lo)); 4740c8de5b0SBaptiste Daroussin } 4750c8de5b0SBaptiste Daroussin 4760c8de5b0SBaptiste Daroussin int 4770c8de5b0SBaptiste Daroussin dcheck(INTERVAL v) 4780c8de5b0SBaptiste Daroussin { 4790c8de5b0SBaptiste Daroussin if (v.hi >= 0. && v.lo <= 0.) 4800c8de5b0SBaptiste Daroussin { 4810c8de5b0SBaptiste Daroussin printf("divisor interval contains 0.\n"); 4820c8de5b0SBaptiste Daroussin return (1); 4830c8de5b0SBaptiste Daroussin } 4840c8de5b0SBaptiste Daroussin return (0); 4850c8de5b0SBaptiste Daroussin } 4860c8de5b0SBaptiste Daroussin 4870c8de5b0SBaptiste Daroussin INTERVAL 4880c8de5b0SBaptiste Daroussin vdiv(double a, double b, INTERVAL v) 4890c8de5b0SBaptiste Daroussin { 4900c8de5b0SBaptiste Daroussin return (hilo(a / v.hi, a / v.lo, b / v.hi, b / v.lo)); 4910c8de5b0SBaptiste Daroussin } 492b53bb29fSJung-uk Kim #line 493 "calc1.tab.c" 4930c8de5b0SBaptiste Daroussin 4940c8de5b0SBaptiste Daroussin #if YYDEBUG 4950c8de5b0SBaptiste Daroussin #include <stdio.h> /* needed for printf */ 4960c8de5b0SBaptiste Daroussin #endif 4970c8de5b0SBaptiste Daroussin 4980c8de5b0SBaptiste Daroussin #include <stdlib.h> /* needed for malloc, etc */ 4990c8de5b0SBaptiste Daroussin #include <string.h> /* needed for memset */ 5000c8de5b0SBaptiste Daroussin 5010c8de5b0SBaptiste Daroussin /* allocate initial stack or double stack size, up to YYMAXDEPTH */ 5020c8de5b0SBaptiste Daroussin static int yygrowstack(YYSTACKDATA *data) 5030c8de5b0SBaptiste Daroussin { 5040c8de5b0SBaptiste Daroussin int i; 5050c8de5b0SBaptiste Daroussin unsigned newsize; 5060c8de5b0SBaptiste Daroussin YYINT *newss; 5070c8de5b0SBaptiste Daroussin YYSTYPE *newvs; 5080c8de5b0SBaptiste Daroussin 5090c8de5b0SBaptiste Daroussin if ((newsize = data->stacksize) == 0) 5100c8de5b0SBaptiste Daroussin newsize = YYINITSTACKSIZE; 5110c8de5b0SBaptiste Daroussin else if (newsize >= YYMAXDEPTH) 5120c8de5b0SBaptiste Daroussin return YYENOMEM; 5130c8de5b0SBaptiste Daroussin else if ((newsize *= 2) > YYMAXDEPTH) 5140c8de5b0SBaptiste Daroussin newsize = YYMAXDEPTH; 5150c8de5b0SBaptiste Daroussin 5160c8de5b0SBaptiste Daroussin i = (int) (data->s_mark - data->s_base); 5170c8de5b0SBaptiste Daroussin newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); 518bf80e08eSJung-uk Kim if (newss == NULL) 5190c8de5b0SBaptiste Daroussin return YYENOMEM; 5200c8de5b0SBaptiste Daroussin 5210c8de5b0SBaptiste Daroussin data->s_base = newss; 5220c8de5b0SBaptiste Daroussin data->s_mark = newss + i; 5230c8de5b0SBaptiste Daroussin 5240c8de5b0SBaptiste Daroussin newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); 525bf80e08eSJung-uk Kim if (newvs == NULL) 5260c8de5b0SBaptiste Daroussin return YYENOMEM; 5270c8de5b0SBaptiste Daroussin 5280c8de5b0SBaptiste Daroussin data->l_base = newvs; 5290c8de5b0SBaptiste Daroussin data->l_mark = newvs + i; 5300c8de5b0SBaptiste Daroussin 5310c8de5b0SBaptiste Daroussin data->stacksize = newsize; 5320c8de5b0SBaptiste Daroussin data->s_last = data->s_base + newsize - 1; 5330c8de5b0SBaptiste Daroussin return 0; 5340c8de5b0SBaptiste Daroussin } 5350c8de5b0SBaptiste Daroussin 5360c8de5b0SBaptiste Daroussin #if YYPURE || defined(YY_NO_LEAKS) 5370c8de5b0SBaptiste Daroussin static void yyfreestack(YYSTACKDATA *data) 5380c8de5b0SBaptiste Daroussin { 5390c8de5b0SBaptiste Daroussin free(data->s_base); 5400c8de5b0SBaptiste Daroussin free(data->l_base); 5410c8de5b0SBaptiste Daroussin memset(data, 0, sizeof(*data)); 5420c8de5b0SBaptiste Daroussin } 5430c8de5b0SBaptiste Daroussin #else 5440c8de5b0SBaptiste Daroussin #define yyfreestack(data) /* nothing */ 5450c8de5b0SBaptiste Daroussin #endif 5460c8de5b0SBaptiste Daroussin 5470c8de5b0SBaptiste Daroussin #define YYABORT goto yyabort 5480c8de5b0SBaptiste Daroussin #define YYREJECT goto yyabort 5490c8de5b0SBaptiste Daroussin #define YYACCEPT goto yyaccept 5500c8de5b0SBaptiste Daroussin #define YYERROR goto yyerrlab 5510c8de5b0SBaptiste Daroussin 5520c8de5b0SBaptiste Daroussin int 5530c8de5b0SBaptiste Daroussin YYPARSE_DECL() 5540c8de5b0SBaptiste Daroussin { 5550c8de5b0SBaptiste Daroussin int yym, yyn, yystate; 5560c8de5b0SBaptiste Daroussin #if YYDEBUG 5570c8de5b0SBaptiste Daroussin const char *yys; 5580c8de5b0SBaptiste Daroussin 559bf80e08eSJung-uk Kim if ((yys = getenv("YYDEBUG")) != NULL) 5600c8de5b0SBaptiste Daroussin { 5610c8de5b0SBaptiste Daroussin yyn = *yys; 5620c8de5b0SBaptiste Daroussin if (yyn >= '0' && yyn <= '9') 5630c8de5b0SBaptiste Daroussin yydebug = yyn - '0'; 5640c8de5b0SBaptiste Daroussin } 5650c8de5b0SBaptiste Daroussin #endif 5660c8de5b0SBaptiste Daroussin 567*8e022d3cSDag-Erling Smørgrav /* yym is set below */ 568*8e022d3cSDag-Erling Smørgrav /* yyn is set below */ 5690c8de5b0SBaptiste Daroussin yynerrs = 0; 5700c8de5b0SBaptiste Daroussin yyerrflag = 0; 5710c8de5b0SBaptiste Daroussin yychar = YYEMPTY; 5720c8de5b0SBaptiste Daroussin yystate = 0; 5730c8de5b0SBaptiste Daroussin 5740c8de5b0SBaptiste Daroussin #if YYPURE 5750c8de5b0SBaptiste Daroussin memset(&yystack, 0, sizeof(yystack)); 5760c8de5b0SBaptiste Daroussin #endif 5770c8de5b0SBaptiste Daroussin 5780c8de5b0SBaptiste Daroussin if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 5790c8de5b0SBaptiste Daroussin yystack.s_mark = yystack.s_base; 5800c8de5b0SBaptiste Daroussin yystack.l_mark = yystack.l_base; 5810c8de5b0SBaptiste Daroussin yystate = 0; 5820c8de5b0SBaptiste Daroussin *yystack.s_mark = 0; 5830c8de5b0SBaptiste Daroussin 5840c8de5b0SBaptiste Daroussin yyloop: 5850c8de5b0SBaptiste Daroussin if ((yyn = yydefred[yystate]) != 0) goto yyreduce; 5860c8de5b0SBaptiste Daroussin if (yychar < 0) 5870c8de5b0SBaptiste Daroussin { 588c5b5d71aSJung-uk Kim yychar = YYLEX; 589c5b5d71aSJung-uk Kim if (yychar < 0) yychar = YYEOF; 5900c8de5b0SBaptiste Daroussin #if YYDEBUG 5910c8de5b0SBaptiste Daroussin if (yydebug) 5920c8de5b0SBaptiste Daroussin { 593c5b5d71aSJung-uk Kim if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; 5940c8de5b0SBaptiste Daroussin printf("%sdebug: state %d, reading %d (%s)\n", 5950c8de5b0SBaptiste Daroussin YYPREFIX, yystate, yychar, yys); 5960c8de5b0SBaptiste Daroussin } 5970c8de5b0SBaptiste Daroussin #endif 5980c8de5b0SBaptiste Daroussin } 599c5b5d71aSJung-uk Kim if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && 600c5b5d71aSJung-uk Kim yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) 6010c8de5b0SBaptiste Daroussin { 6020c8de5b0SBaptiste Daroussin #if YYDEBUG 6030c8de5b0SBaptiste Daroussin if (yydebug) 6040c8de5b0SBaptiste Daroussin printf("%sdebug: state %d, shifting to state %d\n", 6050c8de5b0SBaptiste Daroussin YYPREFIX, yystate, yytable[yyn]); 6060c8de5b0SBaptiste Daroussin #endif 607c5b5d71aSJung-uk Kim if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 6080c8de5b0SBaptiste Daroussin yystate = yytable[yyn]; 6090c8de5b0SBaptiste Daroussin *++yystack.s_mark = yytable[yyn]; 6100c8de5b0SBaptiste Daroussin *++yystack.l_mark = yylval; 6110c8de5b0SBaptiste Daroussin yychar = YYEMPTY; 6120c8de5b0SBaptiste Daroussin if (yyerrflag > 0) --yyerrflag; 6130c8de5b0SBaptiste Daroussin goto yyloop; 6140c8de5b0SBaptiste Daroussin } 615c5b5d71aSJung-uk Kim if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && 616c5b5d71aSJung-uk Kim yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) 6170c8de5b0SBaptiste Daroussin { 6180c8de5b0SBaptiste Daroussin yyn = yytable[yyn]; 6190c8de5b0SBaptiste Daroussin goto yyreduce; 6200c8de5b0SBaptiste Daroussin } 621c5b5d71aSJung-uk Kim if (yyerrflag != 0) goto yyinrecovery; 6220c8de5b0SBaptiste Daroussin 6230c8de5b0SBaptiste Daroussin YYERROR_CALL("syntax error"); 6240c8de5b0SBaptiste Daroussin 625c5b5d71aSJung-uk Kim goto yyerrlab; /* redundant goto avoids 'unused label' warning */ 6260c8de5b0SBaptiste Daroussin yyerrlab: 6270c8de5b0SBaptiste Daroussin ++yynerrs; 6280c8de5b0SBaptiste Daroussin 6290c8de5b0SBaptiste Daroussin yyinrecovery: 6300c8de5b0SBaptiste Daroussin if (yyerrflag < 3) 6310c8de5b0SBaptiste Daroussin { 6320c8de5b0SBaptiste Daroussin yyerrflag = 3; 6330c8de5b0SBaptiste Daroussin for (;;) 6340c8de5b0SBaptiste Daroussin { 635c5b5d71aSJung-uk Kim if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && 636c5b5d71aSJung-uk Kim yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) 6370c8de5b0SBaptiste Daroussin { 6380c8de5b0SBaptiste Daroussin #if YYDEBUG 6390c8de5b0SBaptiste Daroussin if (yydebug) 6400c8de5b0SBaptiste Daroussin printf("%sdebug: state %d, error recovery shifting\ 6410c8de5b0SBaptiste Daroussin to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); 6420c8de5b0SBaptiste Daroussin #endif 643c5b5d71aSJung-uk Kim if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 6440c8de5b0SBaptiste Daroussin yystate = yytable[yyn]; 6450c8de5b0SBaptiste Daroussin *++yystack.s_mark = yytable[yyn]; 6460c8de5b0SBaptiste Daroussin *++yystack.l_mark = yylval; 6470c8de5b0SBaptiste Daroussin goto yyloop; 6480c8de5b0SBaptiste Daroussin } 6490c8de5b0SBaptiste Daroussin else 6500c8de5b0SBaptiste Daroussin { 6510c8de5b0SBaptiste Daroussin #if YYDEBUG 6520c8de5b0SBaptiste Daroussin if (yydebug) 6530c8de5b0SBaptiste Daroussin printf("%sdebug: error recovery discarding state %d\n", 6540c8de5b0SBaptiste Daroussin YYPREFIX, *yystack.s_mark); 6550c8de5b0SBaptiste Daroussin #endif 6560c8de5b0SBaptiste Daroussin if (yystack.s_mark <= yystack.s_base) goto yyabort; 6570c8de5b0SBaptiste Daroussin --yystack.s_mark; 6580c8de5b0SBaptiste Daroussin --yystack.l_mark; 6590c8de5b0SBaptiste Daroussin } 6600c8de5b0SBaptiste Daroussin } 6610c8de5b0SBaptiste Daroussin } 6620c8de5b0SBaptiste Daroussin else 6630c8de5b0SBaptiste Daroussin { 6640c8de5b0SBaptiste Daroussin if (yychar == YYEOF) goto yyabort; 6650c8de5b0SBaptiste Daroussin #if YYDEBUG 6660c8de5b0SBaptiste Daroussin if (yydebug) 6670c8de5b0SBaptiste Daroussin { 668c5b5d71aSJung-uk Kim if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; 6690c8de5b0SBaptiste Daroussin printf("%sdebug: state %d, error recovery discards token %d (%s)\n", 6700c8de5b0SBaptiste Daroussin YYPREFIX, yystate, yychar, yys); 6710c8de5b0SBaptiste Daroussin } 6720c8de5b0SBaptiste Daroussin #endif 6730c8de5b0SBaptiste Daroussin yychar = YYEMPTY; 6740c8de5b0SBaptiste Daroussin goto yyloop; 6750c8de5b0SBaptiste Daroussin } 6760c8de5b0SBaptiste Daroussin 6770c8de5b0SBaptiste Daroussin yyreduce: 6780c8de5b0SBaptiste Daroussin #if YYDEBUG 6790c8de5b0SBaptiste Daroussin if (yydebug) 6800c8de5b0SBaptiste Daroussin printf("%sdebug: state %d, reducing by rule %d (%s)\n", 6810c8de5b0SBaptiste Daroussin YYPREFIX, yystate, yyn, yyrule[yyn]); 6820c8de5b0SBaptiste Daroussin #endif 6830c8de5b0SBaptiste Daroussin yym = yylen[yyn]; 684c5b5d71aSJung-uk Kim if (yym > 0) 6850c8de5b0SBaptiste Daroussin yyval = yystack.l_mark[1-yym]; 6860c8de5b0SBaptiste Daroussin else 6870c8de5b0SBaptiste Daroussin memset(&yyval, 0, sizeof yyval); 688c5b5d71aSJung-uk Kim 6890c8de5b0SBaptiste Daroussin switch (yyn) 6900c8de5b0SBaptiste Daroussin { 6910c8de5b0SBaptiste Daroussin case 3: 6920c8de5b0SBaptiste Daroussin #line 57 "calc1.y" 6930c8de5b0SBaptiste Daroussin { 6940c8de5b0SBaptiste Daroussin (void) printf("%15.8f\n", yystack.l_mark[-1].dval); 6950c8de5b0SBaptiste Daroussin } 696*8e022d3cSDag-Erling Smørgrav #line 697 "calc1.tab.c" 6970c8de5b0SBaptiste Daroussin break; 6980c8de5b0SBaptiste Daroussin case 4: 6990c8de5b0SBaptiste Daroussin #line 61 "calc1.y" 7000c8de5b0SBaptiste Daroussin { 7010c8de5b0SBaptiste Daroussin (void) printf("(%15.8f, %15.8f)\n", yystack.l_mark[-1].vval.lo, yystack.l_mark[-1].vval.hi); 7020c8de5b0SBaptiste Daroussin } 703*8e022d3cSDag-Erling Smørgrav #line 704 "calc1.tab.c" 7040c8de5b0SBaptiste Daroussin break; 7050c8de5b0SBaptiste Daroussin case 5: 7060c8de5b0SBaptiste Daroussin #line 65 "calc1.y" 7070c8de5b0SBaptiste Daroussin { 7080c8de5b0SBaptiste Daroussin dreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].dval; 7090c8de5b0SBaptiste Daroussin } 710*8e022d3cSDag-Erling Smørgrav #line 711 "calc1.tab.c" 7110c8de5b0SBaptiste Daroussin break; 7120c8de5b0SBaptiste Daroussin case 6: 7130c8de5b0SBaptiste Daroussin #line 69 "calc1.y" 7140c8de5b0SBaptiste Daroussin { 7150c8de5b0SBaptiste Daroussin vreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].vval; 7160c8de5b0SBaptiste Daroussin } 717*8e022d3cSDag-Erling Smørgrav #line 718 "calc1.tab.c" 7180c8de5b0SBaptiste Daroussin break; 7190c8de5b0SBaptiste Daroussin case 7: 7200c8de5b0SBaptiste Daroussin #line 73 "calc1.y" 7210c8de5b0SBaptiste Daroussin { 7220c8de5b0SBaptiste Daroussin yyerrok; 7230c8de5b0SBaptiste Daroussin } 724*8e022d3cSDag-Erling Smørgrav #line 725 "calc1.tab.c" 7250c8de5b0SBaptiste Daroussin break; 7260c8de5b0SBaptiste Daroussin case 9: 7270c8de5b0SBaptiste Daroussin #line 80 "calc1.y" 7280c8de5b0SBaptiste Daroussin { 7290c8de5b0SBaptiste Daroussin yyval.dval = dreg[yystack.l_mark[0].ival]; 7300c8de5b0SBaptiste Daroussin } 731*8e022d3cSDag-Erling Smørgrav #line 732 "calc1.tab.c" 7320c8de5b0SBaptiste Daroussin break; 7330c8de5b0SBaptiste Daroussin case 10: 7340c8de5b0SBaptiste Daroussin #line 84 "calc1.y" 7350c8de5b0SBaptiste Daroussin { 7360c8de5b0SBaptiste Daroussin yyval.dval = yystack.l_mark[-2].dval + yystack.l_mark[0].dval; 7370c8de5b0SBaptiste Daroussin } 738*8e022d3cSDag-Erling Smørgrav #line 739 "calc1.tab.c" 7390c8de5b0SBaptiste Daroussin break; 7400c8de5b0SBaptiste Daroussin case 11: 7410c8de5b0SBaptiste Daroussin #line 88 "calc1.y" 7420c8de5b0SBaptiste Daroussin { 7430c8de5b0SBaptiste Daroussin yyval.dval = yystack.l_mark[-2].dval - yystack.l_mark[0].dval; 7440c8de5b0SBaptiste Daroussin } 745*8e022d3cSDag-Erling Smørgrav #line 746 "calc1.tab.c" 7460c8de5b0SBaptiste Daroussin break; 7470c8de5b0SBaptiste Daroussin case 12: 7480c8de5b0SBaptiste Daroussin #line 92 "calc1.y" 7490c8de5b0SBaptiste Daroussin { 7500c8de5b0SBaptiste Daroussin yyval.dval = yystack.l_mark[-2].dval * yystack.l_mark[0].dval; 7510c8de5b0SBaptiste Daroussin } 752*8e022d3cSDag-Erling Smørgrav #line 753 "calc1.tab.c" 7530c8de5b0SBaptiste Daroussin break; 7540c8de5b0SBaptiste Daroussin case 13: 7550c8de5b0SBaptiste Daroussin #line 96 "calc1.y" 7560c8de5b0SBaptiste Daroussin { 7570c8de5b0SBaptiste Daroussin yyval.dval = yystack.l_mark[-2].dval / yystack.l_mark[0].dval; 7580c8de5b0SBaptiste Daroussin } 759*8e022d3cSDag-Erling Smørgrav #line 760 "calc1.tab.c" 7600c8de5b0SBaptiste Daroussin break; 7610c8de5b0SBaptiste Daroussin case 14: 7620c8de5b0SBaptiste Daroussin #line 100 "calc1.y" 7630c8de5b0SBaptiste Daroussin { 7640c8de5b0SBaptiste Daroussin yyval.dval = -yystack.l_mark[0].dval; 7650c8de5b0SBaptiste Daroussin } 766*8e022d3cSDag-Erling Smørgrav #line 767 "calc1.tab.c" 7670c8de5b0SBaptiste Daroussin break; 7680c8de5b0SBaptiste Daroussin case 15: 7690c8de5b0SBaptiste Daroussin #line 104 "calc1.y" 7700c8de5b0SBaptiste Daroussin { 7710c8de5b0SBaptiste Daroussin yyval.dval = yystack.l_mark[-1].dval; 7720c8de5b0SBaptiste Daroussin } 773*8e022d3cSDag-Erling Smørgrav #line 774 "calc1.tab.c" 7740c8de5b0SBaptiste Daroussin break; 7750c8de5b0SBaptiste Daroussin case 16: 7760c8de5b0SBaptiste Daroussin #line 110 "calc1.y" 7770c8de5b0SBaptiste Daroussin { 7780c8de5b0SBaptiste Daroussin yyval.vval.hi = yyval.vval.lo = yystack.l_mark[0].dval; 7790c8de5b0SBaptiste Daroussin } 780*8e022d3cSDag-Erling Smørgrav #line 781 "calc1.tab.c" 7810c8de5b0SBaptiste Daroussin break; 7820c8de5b0SBaptiste Daroussin case 17: 7830c8de5b0SBaptiste Daroussin #line 114 "calc1.y" 7840c8de5b0SBaptiste Daroussin { 7850c8de5b0SBaptiste Daroussin yyval.vval.lo = yystack.l_mark[-3].dval; 7860c8de5b0SBaptiste Daroussin yyval.vval.hi = yystack.l_mark[-1].dval; 7870c8de5b0SBaptiste Daroussin if ( yyval.vval.lo > yyval.vval.hi ) 7880c8de5b0SBaptiste Daroussin { 7890c8de5b0SBaptiste Daroussin (void) printf("interval out of order\n"); 7900c8de5b0SBaptiste Daroussin YYERROR; 7910c8de5b0SBaptiste Daroussin } 7920c8de5b0SBaptiste Daroussin } 793*8e022d3cSDag-Erling Smørgrav #line 794 "calc1.tab.c" 7940c8de5b0SBaptiste Daroussin break; 7950c8de5b0SBaptiste Daroussin case 18: 7960c8de5b0SBaptiste Daroussin #line 124 "calc1.y" 7970c8de5b0SBaptiste Daroussin { 7980c8de5b0SBaptiste Daroussin yyval.vval = vreg[yystack.l_mark[0].ival]; 7990c8de5b0SBaptiste Daroussin } 800*8e022d3cSDag-Erling Smørgrav #line 801 "calc1.tab.c" 8010c8de5b0SBaptiste Daroussin break; 8020c8de5b0SBaptiste Daroussin case 19: 8030c8de5b0SBaptiste Daroussin #line 128 "calc1.y" 8040c8de5b0SBaptiste Daroussin { 8050c8de5b0SBaptiste Daroussin yyval.vval.hi = yystack.l_mark[-2].vval.hi + yystack.l_mark[0].vval.hi; 8060c8de5b0SBaptiste Daroussin yyval.vval.lo = yystack.l_mark[-2].vval.lo + yystack.l_mark[0].vval.lo; 8070c8de5b0SBaptiste Daroussin } 808*8e022d3cSDag-Erling Smørgrav #line 809 "calc1.tab.c" 8090c8de5b0SBaptiste Daroussin break; 8100c8de5b0SBaptiste Daroussin case 20: 8110c8de5b0SBaptiste Daroussin #line 133 "calc1.y" 8120c8de5b0SBaptiste Daroussin { 8130c8de5b0SBaptiste Daroussin yyval.vval.hi = yystack.l_mark[-2].dval + yystack.l_mark[0].vval.hi; 8140c8de5b0SBaptiste Daroussin yyval.vval.lo = yystack.l_mark[-2].dval + yystack.l_mark[0].vval.lo; 8150c8de5b0SBaptiste Daroussin } 816*8e022d3cSDag-Erling Smørgrav #line 817 "calc1.tab.c" 8170c8de5b0SBaptiste Daroussin break; 8180c8de5b0SBaptiste Daroussin case 21: 8190c8de5b0SBaptiste Daroussin #line 138 "calc1.y" 8200c8de5b0SBaptiste Daroussin { 8210c8de5b0SBaptiste Daroussin yyval.vval.hi = yystack.l_mark[-2].vval.hi - yystack.l_mark[0].vval.lo; 8220c8de5b0SBaptiste Daroussin yyval.vval.lo = yystack.l_mark[-2].vval.lo - yystack.l_mark[0].vval.hi; 8230c8de5b0SBaptiste Daroussin } 824*8e022d3cSDag-Erling Smørgrav #line 825 "calc1.tab.c" 8250c8de5b0SBaptiste Daroussin break; 8260c8de5b0SBaptiste Daroussin case 22: 8270c8de5b0SBaptiste Daroussin #line 143 "calc1.y" 8280c8de5b0SBaptiste Daroussin { 8290c8de5b0SBaptiste Daroussin yyval.vval.hi = yystack.l_mark[-2].dval - yystack.l_mark[0].vval.lo; 8300c8de5b0SBaptiste Daroussin yyval.vval.lo = yystack.l_mark[-2].dval - yystack.l_mark[0].vval.hi; 8310c8de5b0SBaptiste Daroussin } 832*8e022d3cSDag-Erling Smørgrav #line 833 "calc1.tab.c" 8330c8de5b0SBaptiste Daroussin break; 8340c8de5b0SBaptiste Daroussin case 23: 8350c8de5b0SBaptiste Daroussin #line 148 "calc1.y" 8360c8de5b0SBaptiste Daroussin { 8370c8de5b0SBaptiste Daroussin yyval.vval = vmul( yystack.l_mark[-2].vval.lo, yystack.l_mark[-2].vval.hi, yystack.l_mark[0].vval ); 8380c8de5b0SBaptiste Daroussin } 839*8e022d3cSDag-Erling Smørgrav #line 840 "calc1.tab.c" 8400c8de5b0SBaptiste Daroussin break; 8410c8de5b0SBaptiste Daroussin case 24: 8420c8de5b0SBaptiste Daroussin #line 152 "calc1.y" 8430c8de5b0SBaptiste Daroussin { 8440c8de5b0SBaptiste Daroussin yyval.vval = vmul (yystack.l_mark[-2].dval, yystack.l_mark[-2].dval, yystack.l_mark[0].vval ); 8450c8de5b0SBaptiste Daroussin } 846*8e022d3cSDag-Erling Smørgrav #line 847 "calc1.tab.c" 8470c8de5b0SBaptiste Daroussin break; 8480c8de5b0SBaptiste Daroussin case 25: 8490c8de5b0SBaptiste Daroussin #line 156 "calc1.y" 8500c8de5b0SBaptiste Daroussin { 8510c8de5b0SBaptiste Daroussin if (dcheck(yystack.l_mark[0].vval)) YYERROR; 8520c8de5b0SBaptiste Daroussin yyval.vval = vdiv ( yystack.l_mark[-2].vval.lo, yystack.l_mark[-2].vval.hi, yystack.l_mark[0].vval ); 8530c8de5b0SBaptiste Daroussin } 854*8e022d3cSDag-Erling Smørgrav #line 855 "calc1.tab.c" 8550c8de5b0SBaptiste Daroussin break; 8560c8de5b0SBaptiste Daroussin case 26: 8570c8de5b0SBaptiste Daroussin #line 161 "calc1.y" 8580c8de5b0SBaptiste Daroussin { 8590c8de5b0SBaptiste Daroussin if (dcheck ( yystack.l_mark[0].vval )) YYERROR; 8600c8de5b0SBaptiste Daroussin yyval.vval = vdiv (yystack.l_mark[-2].dval, yystack.l_mark[-2].dval, yystack.l_mark[0].vval ); 8610c8de5b0SBaptiste Daroussin } 862*8e022d3cSDag-Erling Smørgrav #line 863 "calc1.tab.c" 8630c8de5b0SBaptiste Daroussin break; 8640c8de5b0SBaptiste Daroussin case 27: 8650c8de5b0SBaptiste Daroussin #line 166 "calc1.y" 8660c8de5b0SBaptiste Daroussin { 8670c8de5b0SBaptiste Daroussin yyval.vval.hi = -yystack.l_mark[0].vval.lo; 8680c8de5b0SBaptiste Daroussin yyval.vval.lo = -yystack.l_mark[0].vval.hi; 8690c8de5b0SBaptiste Daroussin } 870*8e022d3cSDag-Erling Smørgrav #line 871 "calc1.tab.c" 8710c8de5b0SBaptiste Daroussin break; 8720c8de5b0SBaptiste Daroussin case 28: 8730c8de5b0SBaptiste Daroussin #line 171 "calc1.y" 8740c8de5b0SBaptiste Daroussin { 8750c8de5b0SBaptiste Daroussin yyval.vval = yystack.l_mark[-1].vval; 8760c8de5b0SBaptiste Daroussin } 877*8e022d3cSDag-Erling Smørgrav #line 878 "calc1.tab.c" 8780c8de5b0SBaptiste Daroussin break; 879*8e022d3cSDag-Erling Smørgrav #line 880 "calc1.tab.c" 8800c8de5b0SBaptiste Daroussin } 8810c8de5b0SBaptiste Daroussin yystack.s_mark -= yym; 8820c8de5b0SBaptiste Daroussin yystate = *yystack.s_mark; 8830c8de5b0SBaptiste Daroussin yystack.l_mark -= yym; 8840c8de5b0SBaptiste Daroussin yym = yylhs[yyn]; 8850c8de5b0SBaptiste Daroussin if (yystate == 0 && yym == 0) 8860c8de5b0SBaptiste Daroussin { 8870c8de5b0SBaptiste Daroussin #if YYDEBUG 8880c8de5b0SBaptiste Daroussin if (yydebug) 8890c8de5b0SBaptiste Daroussin printf("%sdebug: after reduction, shifting from state 0 to\ 8900c8de5b0SBaptiste Daroussin state %d\n", YYPREFIX, YYFINAL); 8910c8de5b0SBaptiste Daroussin #endif 8920c8de5b0SBaptiste Daroussin yystate = YYFINAL; 8930c8de5b0SBaptiste Daroussin *++yystack.s_mark = YYFINAL; 8940c8de5b0SBaptiste Daroussin *++yystack.l_mark = yyval; 8950c8de5b0SBaptiste Daroussin if (yychar < 0) 8960c8de5b0SBaptiste Daroussin { 897c5b5d71aSJung-uk Kim yychar = YYLEX; 898c5b5d71aSJung-uk Kim if (yychar < 0) yychar = YYEOF; 8990c8de5b0SBaptiste Daroussin #if YYDEBUG 9000c8de5b0SBaptiste Daroussin if (yydebug) 9010c8de5b0SBaptiste Daroussin { 902c5b5d71aSJung-uk Kim if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; 9030c8de5b0SBaptiste Daroussin printf("%sdebug: state %d, reading %d (%s)\n", 9040c8de5b0SBaptiste Daroussin YYPREFIX, YYFINAL, yychar, yys); 9050c8de5b0SBaptiste Daroussin } 9060c8de5b0SBaptiste Daroussin #endif 9070c8de5b0SBaptiste Daroussin } 9080c8de5b0SBaptiste Daroussin if (yychar == YYEOF) goto yyaccept; 9090c8de5b0SBaptiste Daroussin goto yyloop; 9100c8de5b0SBaptiste Daroussin } 911c5b5d71aSJung-uk Kim if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && 912c5b5d71aSJung-uk Kim yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) 9130c8de5b0SBaptiste Daroussin yystate = yytable[yyn]; 9140c8de5b0SBaptiste Daroussin else 9150c8de5b0SBaptiste Daroussin yystate = yydgoto[yym]; 9160c8de5b0SBaptiste Daroussin #if YYDEBUG 9170c8de5b0SBaptiste Daroussin if (yydebug) 9180c8de5b0SBaptiste Daroussin printf("%sdebug: after reduction, shifting from state %d \ 9190c8de5b0SBaptiste Daroussin to state %d\n", YYPREFIX, *yystack.s_mark, yystate); 9200c8de5b0SBaptiste Daroussin #endif 921c5b5d71aSJung-uk Kim if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 9220c8de5b0SBaptiste Daroussin *++yystack.s_mark = (YYINT) yystate; 9230c8de5b0SBaptiste Daroussin *++yystack.l_mark = yyval; 9240c8de5b0SBaptiste Daroussin goto yyloop; 9250c8de5b0SBaptiste Daroussin 9260c8de5b0SBaptiste Daroussin yyoverflow: 9270c8de5b0SBaptiste Daroussin YYERROR_CALL("yacc stack overflow"); 9280c8de5b0SBaptiste Daroussin 9290c8de5b0SBaptiste Daroussin yyabort: 9300c8de5b0SBaptiste Daroussin yyfreestack(&yystack); 9310c8de5b0SBaptiste Daroussin return (1); 9320c8de5b0SBaptiste Daroussin 9330c8de5b0SBaptiste Daroussin yyaccept: 9340c8de5b0SBaptiste Daroussin yyfreestack(&yystack); 9350c8de5b0SBaptiste Daroussin return (0); 9360c8de5b0SBaptiste Daroussin } 937