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 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 #line 31 "calc1.y" 1270c8de5b0SBaptiste Daroussin #ifdef YYSTYPE 1280c8de5b0SBaptiste Daroussin #undef YYSTYPE_IS_DECLARED 1290c8de5b0SBaptiste Daroussin #define YYSTYPE_IS_DECLARED 1 1300c8de5b0SBaptiste Daroussin #endif 1310c8de5b0SBaptiste Daroussin #ifndef YYSTYPE_IS_DECLARED 1320c8de5b0SBaptiste Daroussin #define YYSTYPE_IS_DECLARED 1 1330c8de5b0SBaptiste Daroussin typedef union 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 178*ea2af5c8SJung-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 3260c8de5b0SBaptiste Daroussin int yydebug; 3270c8de5b0SBaptiste Daroussin int yynerrs; 3280c8de5b0SBaptiste Daroussin 3290c8de5b0SBaptiste Daroussin int yyerrflag; 3300c8de5b0SBaptiste Daroussin int yychar; 3310c8de5b0SBaptiste Daroussin YYSTYPE yyval; 3320c8de5b0SBaptiste Daroussin YYSTYPE yylval; 3330c8de5b0SBaptiste Daroussin 3340c8de5b0SBaptiste Daroussin /* define the initial stack-sizes */ 3350c8de5b0SBaptiste Daroussin #ifdef YYSTACKSIZE 3360c8de5b0SBaptiste Daroussin #undef YYMAXDEPTH 3370c8de5b0SBaptiste Daroussin #define YYMAXDEPTH YYSTACKSIZE 3380c8de5b0SBaptiste Daroussin #else 3390c8de5b0SBaptiste Daroussin #ifdef YYMAXDEPTH 3400c8de5b0SBaptiste Daroussin #define YYSTACKSIZE YYMAXDEPTH 3410c8de5b0SBaptiste Daroussin #else 3420c8de5b0SBaptiste Daroussin #define YYSTACKSIZE 10000 3430c8de5b0SBaptiste Daroussin #define YYMAXDEPTH 10000 3440c8de5b0SBaptiste Daroussin #endif 3450c8de5b0SBaptiste Daroussin #endif 3460c8de5b0SBaptiste Daroussin 3470c8de5b0SBaptiste Daroussin #define YYINITSTACKSIZE 200 3480c8de5b0SBaptiste Daroussin 3490c8de5b0SBaptiste Daroussin typedef struct { 3500c8de5b0SBaptiste Daroussin unsigned stacksize; 3510c8de5b0SBaptiste Daroussin YYINT *s_base; 3520c8de5b0SBaptiste Daroussin YYINT *s_mark; 3530c8de5b0SBaptiste Daroussin YYINT *s_last; 3540c8de5b0SBaptiste Daroussin YYSTYPE *l_base; 3550c8de5b0SBaptiste Daroussin YYSTYPE *l_mark; 3560c8de5b0SBaptiste Daroussin } YYSTACKDATA; 3570c8de5b0SBaptiste Daroussin /* variables for the parser stack */ 3580c8de5b0SBaptiste Daroussin static YYSTACKDATA yystack; 3590c8de5b0SBaptiste Daroussin #line 176 "calc1.y" 3600c8de5b0SBaptiste Daroussin /* beginning of subroutines section */ 3610c8de5b0SBaptiste Daroussin 3620c8de5b0SBaptiste Daroussin #define BSZ 50 /* buffer size for floating point numbers */ 3630c8de5b0SBaptiste Daroussin 3640c8de5b0SBaptiste Daroussin /* lexical analysis */ 3650c8de5b0SBaptiste Daroussin 3660c8de5b0SBaptiste Daroussin static void 3670c8de5b0SBaptiste Daroussin yyerror(const char *s) 3680c8de5b0SBaptiste Daroussin { 3690c8de5b0SBaptiste Daroussin fprintf(stderr, "%s\n", s); 3700c8de5b0SBaptiste Daroussin } 3710c8de5b0SBaptiste Daroussin 3720c8de5b0SBaptiste Daroussin int 3730c8de5b0SBaptiste Daroussin yylex(void) 3740c8de5b0SBaptiste Daroussin { 3750c8de5b0SBaptiste Daroussin int c; 3760c8de5b0SBaptiste Daroussin 3770c8de5b0SBaptiste Daroussin while ((c = getchar()) == ' ') 3780c8de5b0SBaptiste Daroussin { /* skip over blanks */ 3790c8de5b0SBaptiste Daroussin } 3800c8de5b0SBaptiste Daroussin 3810c8de5b0SBaptiste Daroussin if (isupper(c)) 3820c8de5b0SBaptiste Daroussin { 3830c8de5b0SBaptiste Daroussin yylval.ival = c - 'A'; 3840c8de5b0SBaptiste Daroussin return (VREG); 3850c8de5b0SBaptiste Daroussin } 3860c8de5b0SBaptiste Daroussin if (islower(c)) 3870c8de5b0SBaptiste Daroussin { 3880c8de5b0SBaptiste Daroussin yylval.ival = c - 'a'; 3890c8de5b0SBaptiste Daroussin return (DREG); 3900c8de5b0SBaptiste Daroussin } 3910c8de5b0SBaptiste Daroussin 3920c8de5b0SBaptiste Daroussin if (isdigit(c) || c == '.') 3930c8de5b0SBaptiste Daroussin { 3940c8de5b0SBaptiste Daroussin /* gobble up digits, points, exponents */ 3950c8de5b0SBaptiste Daroussin char buf[BSZ + 1], *cp = buf; 3960c8de5b0SBaptiste Daroussin int dot = 0, expr = 0; 3970c8de5b0SBaptiste Daroussin 3980c8de5b0SBaptiste Daroussin for (; (cp - buf) < BSZ; ++cp, c = getchar()) 3990c8de5b0SBaptiste Daroussin { 4000c8de5b0SBaptiste Daroussin 4010c8de5b0SBaptiste Daroussin *cp = (char) c; 4020c8de5b0SBaptiste Daroussin if (isdigit(c)) 4030c8de5b0SBaptiste Daroussin continue; 4040c8de5b0SBaptiste Daroussin if (c == '.') 4050c8de5b0SBaptiste Daroussin { 4060c8de5b0SBaptiste Daroussin if (dot++ || expr) 4070c8de5b0SBaptiste Daroussin return ('.'); /* will cause syntax error */ 4080c8de5b0SBaptiste Daroussin continue; 4090c8de5b0SBaptiste Daroussin } 4100c8de5b0SBaptiste Daroussin 4110c8de5b0SBaptiste Daroussin if (c == 'e') 4120c8de5b0SBaptiste Daroussin { 4130c8de5b0SBaptiste Daroussin if (expr++) 4140c8de5b0SBaptiste Daroussin return ('e'); /* will cause syntax error */ 4150c8de5b0SBaptiste Daroussin continue; 4160c8de5b0SBaptiste Daroussin } 4170c8de5b0SBaptiste Daroussin 4180c8de5b0SBaptiste Daroussin /* end of number */ 4190c8de5b0SBaptiste Daroussin break; 4200c8de5b0SBaptiste Daroussin } 4210c8de5b0SBaptiste Daroussin *cp = '\0'; 4220c8de5b0SBaptiste Daroussin 4230c8de5b0SBaptiste Daroussin if ((cp - buf) >= BSZ) 4240c8de5b0SBaptiste Daroussin printf("constant too long: truncated\n"); 4250c8de5b0SBaptiste Daroussin else 4260c8de5b0SBaptiste Daroussin ungetc(c, stdin); /* push back last char read */ 4270c8de5b0SBaptiste Daroussin yylval.dval = atof(buf); 4280c8de5b0SBaptiste Daroussin return (CONST); 4290c8de5b0SBaptiste Daroussin } 4300c8de5b0SBaptiste Daroussin return (c); 4310c8de5b0SBaptiste Daroussin } 4320c8de5b0SBaptiste Daroussin 4330c8de5b0SBaptiste Daroussin static INTERVAL 4340c8de5b0SBaptiste Daroussin hilo(double a, double b, double c, double d) 4350c8de5b0SBaptiste Daroussin { 4360c8de5b0SBaptiste Daroussin /* returns the smallest interval containing a, b, c, and d */ 4370c8de5b0SBaptiste Daroussin /* used by *, / routines */ 4380c8de5b0SBaptiste Daroussin INTERVAL v; 4390c8de5b0SBaptiste Daroussin 4400c8de5b0SBaptiste Daroussin if (a > b) 4410c8de5b0SBaptiste Daroussin { 4420c8de5b0SBaptiste Daroussin v.hi = a; 4430c8de5b0SBaptiste Daroussin v.lo = b; 4440c8de5b0SBaptiste Daroussin } 4450c8de5b0SBaptiste Daroussin else 4460c8de5b0SBaptiste Daroussin { 4470c8de5b0SBaptiste Daroussin v.hi = b; 4480c8de5b0SBaptiste Daroussin v.lo = a; 4490c8de5b0SBaptiste Daroussin } 4500c8de5b0SBaptiste Daroussin 4510c8de5b0SBaptiste Daroussin if (c > d) 4520c8de5b0SBaptiste Daroussin { 4530c8de5b0SBaptiste Daroussin if (c > v.hi) 4540c8de5b0SBaptiste Daroussin v.hi = c; 4550c8de5b0SBaptiste Daroussin if (d < v.lo) 4560c8de5b0SBaptiste Daroussin v.lo = d; 4570c8de5b0SBaptiste Daroussin } 4580c8de5b0SBaptiste Daroussin else 4590c8de5b0SBaptiste Daroussin { 4600c8de5b0SBaptiste Daroussin if (d > v.hi) 4610c8de5b0SBaptiste Daroussin v.hi = d; 4620c8de5b0SBaptiste Daroussin if (c < v.lo) 4630c8de5b0SBaptiste Daroussin v.lo = c; 4640c8de5b0SBaptiste Daroussin } 4650c8de5b0SBaptiste Daroussin return (v); 4660c8de5b0SBaptiste Daroussin } 4670c8de5b0SBaptiste Daroussin 4680c8de5b0SBaptiste Daroussin INTERVAL 4690c8de5b0SBaptiste Daroussin vmul(double a, double b, INTERVAL v) 4700c8de5b0SBaptiste Daroussin { 4710c8de5b0SBaptiste Daroussin return (hilo(a * v.hi, a * v.lo, b * v.hi, b * v.lo)); 4720c8de5b0SBaptiste Daroussin } 4730c8de5b0SBaptiste Daroussin 4740c8de5b0SBaptiste Daroussin int 4750c8de5b0SBaptiste Daroussin dcheck(INTERVAL v) 4760c8de5b0SBaptiste Daroussin { 4770c8de5b0SBaptiste Daroussin if (v.hi >= 0. && v.lo <= 0.) 4780c8de5b0SBaptiste Daroussin { 4790c8de5b0SBaptiste Daroussin printf("divisor interval contains 0.\n"); 4800c8de5b0SBaptiste Daroussin return (1); 4810c8de5b0SBaptiste Daroussin } 4820c8de5b0SBaptiste Daroussin return (0); 4830c8de5b0SBaptiste Daroussin } 4840c8de5b0SBaptiste Daroussin 4850c8de5b0SBaptiste Daroussin INTERVAL 4860c8de5b0SBaptiste Daroussin vdiv(double a, double b, INTERVAL v) 4870c8de5b0SBaptiste Daroussin { 4880c8de5b0SBaptiste Daroussin return (hilo(a / v.hi, a / v.lo, b / v.hi, b / v.lo)); 4890c8de5b0SBaptiste Daroussin } 4900c8de5b0SBaptiste Daroussin #line 491 "calc1.tab.c" 4910c8de5b0SBaptiste Daroussin 4920c8de5b0SBaptiste Daroussin #if YYDEBUG 4930c8de5b0SBaptiste Daroussin #include <stdio.h> /* needed for printf */ 4940c8de5b0SBaptiste Daroussin #endif 4950c8de5b0SBaptiste Daroussin 4960c8de5b0SBaptiste Daroussin #include <stdlib.h> /* needed for malloc, etc */ 4970c8de5b0SBaptiste Daroussin #include <string.h> /* needed for memset */ 4980c8de5b0SBaptiste Daroussin 4990c8de5b0SBaptiste Daroussin /* allocate initial stack or double stack size, up to YYMAXDEPTH */ 5000c8de5b0SBaptiste Daroussin static int yygrowstack(YYSTACKDATA *data) 5010c8de5b0SBaptiste Daroussin { 5020c8de5b0SBaptiste Daroussin int i; 5030c8de5b0SBaptiste Daroussin unsigned newsize; 5040c8de5b0SBaptiste Daroussin YYINT *newss; 5050c8de5b0SBaptiste Daroussin YYSTYPE *newvs; 5060c8de5b0SBaptiste Daroussin 5070c8de5b0SBaptiste Daroussin if ((newsize = data->stacksize) == 0) 5080c8de5b0SBaptiste Daroussin newsize = YYINITSTACKSIZE; 5090c8de5b0SBaptiste Daroussin else if (newsize >= YYMAXDEPTH) 5100c8de5b0SBaptiste Daroussin return YYENOMEM; 5110c8de5b0SBaptiste Daroussin else if ((newsize *= 2) > YYMAXDEPTH) 5120c8de5b0SBaptiste Daroussin newsize = YYMAXDEPTH; 5130c8de5b0SBaptiste Daroussin 5140c8de5b0SBaptiste Daroussin i = (int) (data->s_mark - data->s_base); 5150c8de5b0SBaptiste Daroussin newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); 5160c8de5b0SBaptiste Daroussin if (newss == 0) 5170c8de5b0SBaptiste Daroussin return YYENOMEM; 5180c8de5b0SBaptiste Daroussin 5190c8de5b0SBaptiste Daroussin data->s_base = newss; 5200c8de5b0SBaptiste Daroussin data->s_mark = newss + i; 5210c8de5b0SBaptiste Daroussin 5220c8de5b0SBaptiste Daroussin newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); 5230c8de5b0SBaptiste Daroussin if (newvs == 0) 5240c8de5b0SBaptiste Daroussin return YYENOMEM; 5250c8de5b0SBaptiste Daroussin 5260c8de5b0SBaptiste Daroussin data->l_base = newvs; 5270c8de5b0SBaptiste Daroussin data->l_mark = newvs + i; 5280c8de5b0SBaptiste Daroussin 5290c8de5b0SBaptiste Daroussin data->stacksize = newsize; 5300c8de5b0SBaptiste Daroussin data->s_last = data->s_base + newsize - 1; 5310c8de5b0SBaptiste Daroussin return 0; 5320c8de5b0SBaptiste Daroussin } 5330c8de5b0SBaptiste Daroussin 5340c8de5b0SBaptiste Daroussin #if YYPURE || defined(YY_NO_LEAKS) 5350c8de5b0SBaptiste Daroussin static void yyfreestack(YYSTACKDATA *data) 5360c8de5b0SBaptiste Daroussin { 5370c8de5b0SBaptiste Daroussin free(data->s_base); 5380c8de5b0SBaptiste Daroussin free(data->l_base); 5390c8de5b0SBaptiste Daroussin memset(data, 0, sizeof(*data)); 5400c8de5b0SBaptiste Daroussin } 5410c8de5b0SBaptiste Daroussin #else 5420c8de5b0SBaptiste Daroussin #define yyfreestack(data) /* nothing */ 5430c8de5b0SBaptiste Daroussin #endif 5440c8de5b0SBaptiste Daroussin 5450c8de5b0SBaptiste Daroussin #define YYABORT goto yyabort 5460c8de5b0SBaptiste Daroussin #define YYREJECT goto yyabort 5470c8de5b0SBaptiste Daroussin #define YYACCEPT goto yyaccept 5480c8de5b0SBaptiste Daroussin #define YYERROR goto yyerrlab 5490c8de5b0SBaptiste Daroussin 5500c8de5b0SBaptiste Daroussin int 5510c8de5b0SBaptiste Daroussin YYPARSE_DECL() 5520c8de5b0SBaptiste Daroussin { 5530c8de5b0SBaptiste Daroussin int yym, yyn, yystate; 5540c8de5b0SBaptiste Daroussin #if YYDEBUG 5550c8de5b0SBaptiste Daroussin const char *yys; 5560c8de5b0SBaptiste Daroussin 5570c8de5b0SBaptiste Daroussin if ((yys = getenv("YYDEBUG")) != 0) 5580c8de5b0SBaptiste Daroussin { 5590c8de5b0SBaptiste Daroussin yyn = *yys; 5600c8de5b0SBaptiste Daroussin if (yyn >= '0' && yyn <= '9') 5610c8de5b0SBaptiste Daroussin yydebug = yyn - '0'; 5620c8de5b0SBaptiste Daroussin } 5630c8de5b0SBaptiste Daroussin #endif 5640c8de5b0SBaptiste Daroussin 5650c8de5b0SBaptiste Daroussin yynerrs = 0; 5660c8de5b0SBaptiste Daroussin yyerrflag = 0; 5670c8de5b0SBaptiste Daroussin yychar = YYEMPTY; 5680c8de5b0SBaptiste Daroussin yystate = 0; 5690c8de5b0SBaptiste Daroussin 5700c8de5b0SBaptiste Daroussin #if YYPURE 5710c8de5b0SBaptiste Daroussin memset(&yystack, 0, sizeof(yystack)); 5720c8de5b0SBaptiste Daroussin #endif 5730c8de5b0SBaptiste Daroussin 5740c8de5b0SBaptiste Daroussin if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 5750c8de5b0SBaptiste Daroussin yystack.s_mark = yystack.s_base; 5760c8de5b0SBaptiste Daroussin yystack.l_mark = yystack.l_base; 5770c8de5b0SBaptiste Daroussin yystate = 0; 5780c8de5b0SBaptiste Daroussin *yystack.s_mark = 0; 5790c8de5b0SBaptiste Daroussin 5800c8de5b0SBaptiste Daroussin yyloop: 5810c8de5b0SBaptiste Daroussin if ((yyn = yydefred[yystate]) != 0) goto yyreduce; 5820c8de5b0SBaptiste Daroussin if (yychar < 0) 5830c8de5b0SBaptiste Daroussin { 5840c8de5b0SBaptiste Daroussin if ((yychar = YYLEX) < 0) yychar = YYEOF; 5850c8de5b0SBaptiste Daroussin #if YYDEBUG 5860c8de5b0SBaptiste Daroussin if (yydebug) 5870c8de5b0SBaptiste Daroussin { 5880c8de5b0SBaptiste Daroussin yys = yyname[YYTRANSLATE(yychar)]; 5890c8de5b0SBaptiste Daroussin printf("%sdebug: state %d, reading %d (%s)\n", 5900c8de5b0SBaptiste Daroussin YYPREFIX, yystate, yychar, yys); 5910c8de5b0SBaptiste Daroussin } 5920c8de5b0SBaptiste Daroussin #endif 5930c8de5b0SBaptiste Daroussin } 5940c8de5b0SBaptiste Daroussin if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && 5950c8de5b0SBaptiste Daroussin yyn <= YYTABLESIZE && yycheck[yyn] == yychar) 5960c8de5b0SBaptiste Daroussin { 5970c8de5b0SBaptiste Daroussin #if YYDEBUG 5980c8de5b0SBaptiste Daroussin if (yydebug) 5990c8de5b0SBaptiste Daroussin printf("%sdebug: state %d, shifting to state %d\n", 6000c8de5b0SBaptiste Daroussin YYPREFIX, yystate, yytable[yyn]); 6010c8de5b0SBaptiste Daroussin #endif 6020c8de5b0SBaptiste Daroussin if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) 6030c8de5b0SBaptiste Daroussin { 6040c8de5b0SBaptiste Daroussin goto yyoverflow; 6050c8de5b0SBaptiste Daroussin } 6060c8de5b0SBaptiste Daroussin yystate = yytable[yyn]; 6070c8de5b0SBaptiste Daroussin *++yystack.s_mark = yytable[yyn]; 6080c8de5b0SBaptiste Daroussin *++yystack.l_mark = yylval; 6090c8de5b0SBaptiste Daroussin yychar = YYEMPTY; 6100c8de5b0SBaptiste Daroussin if (yyerrflag > 0) --yyerrflag; 6110c8de5b0SBaptiste Daroussin goto yyloop; 6120c8de5b0SBaptiste Daroussin } 6130c8de5b0SBaptiste Daroussin if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && 6140c8de5b0SBaptiste Daroussin yyn <= YYTABLESIZE && yycheck[yyn] == yychar) 6150c8de5b0SBaptiste Daroussin { 6160c8de5b0SBaptiste Daroussin yyn = yytable[yyn]; 6170c8de5b0SBaptiste Daroussin goto yyreduce; 6180c8de5b0SBaptiste Daroussin } 6190c8de5b0SBaptiste Daroussin if (yyerrflag) goto yyinrecovery; 6200c8de5b0SBaptiste Daroussin 6210c8de5b0SBaptiste Daroussin YYERROR_CALL("syntax error"); 6220c8de5b0SBaptiste Daroussin 6230c8de5b0SBaptiste Daroussin goto yyerrlab; 6240c8de5b0SBaptiste Daroussin 6250c8de5b0SBaptiste Daroussin yyerrlab: 6260c8de5b0SBaptiste Daroussin ++yynerrs; 6270c8de5b0SBaptiste Daroussin 6280c8de5b0SBaptiste Daroussin yyinrecovery: 6290c8de5b0SBaptiste Daroussin if (yyerrflag < 3) 6300c8de5b0SBaptiste Daroussin { 6310c8de5b0SBaptiste Daroussin yyerrflag = 3; 6320c8de5b0SBaptiste Daroussin for (;;) 6330c8de5b0SBaptiste Daroussin { 6340c8de5b0SBaptiste Daroussin if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 && 6350c8de5b0SBaptiste Daroussin yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) 6360c8de5b0SBaptiste Daroussin { 6370c8de5b0SBaptiste Daroussin #if YYDEBUG 6380c8de5b0SBaptiste Daroussin if (yydebug) 6390c8de5b0SBaptiste Daroussin printf("%sdebug: state %d, error recovery shifting\ 6400c8de5b0SBaptiste Daroussin to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); 6410c8de5b0SBaptiste Daroussin #endif 6420c8de5b0SBaptiste Daroussin if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) 6430c8de5b0SBaptiste Daroussin { 6440c8de5b0SBaptiste Daroussin goto yyoverflow; 6450c8de5b0SBaptiste Daroussin } 6460c8de5b0SBaptiste Daroussin yystate = yytable[yyn]; 6470c8de5b0SBaptiste Daroussin *++yystack.s_mark = yytable[yyn]; 6480c8de5b0SBaptiste Daroussin *++yystack.l_mark = yylval; 6490c8de5b0SBaptiste Daroussin goto yyloop; 6500c8de5b0SBaptiste Daroussin } 6510c8de5b0SBaptiste Daroussin else 6520c8de5b0SBaptiste Daroussin { 6530c8de5b0SBaptiste Daroussin #if YYDEBUG 6540c8de5b0SBaptiste Daroussin if (yydebug) 6550c8de5b0SBaptiste Daroussin printf("%sdebug: error recovery discarding state %d\n", 6560c8de5b0SBaptiste Daroussin YYPREFIX, *yystack.s_mark); 6570c8de5b0SBaptiste Daroussin #endif 6580c8de5b0SBaptiste Daroussin if (yystack.s_mark <= yystack.s_base) goto yyabort; 6590c8de5b0SBaptiste Daroussin --yystack.s_mark; 6600c8de5b0SBaptiste Daroussin --yystack.l_mark; 6610c8de5b0SBaptiste Daroussin } 6620c8de5b0SBaptiste Daroussin } 6630c8de5b0SBaptiste Daroussin } 6640c8de5b0SBaptiste Daroussin else 6650c8de5b0SBaptiste Daroussin { 6660c8de5b0SBaptiste Daroussin if (yychar == YYEOF) goto yyabort; 6670c8de5b0SBaptiste Daroussin #if YYDEBUG 6680c8de5b0SBaptiste Daroussin if (yydebug) 6690c8de5b0SBaptiste Daroussin { 6700c8de5b0SBaptiste Daroussin yys = yyname[YYTRANSLATE(yychar)]; 6710c8de5b0SBaptiste Daroussin printf("%sdebug: state %d, error recovery discards token %d (%s)\n", 6720c8de5b0SBaptiste Daroussin YYPREFIX, yystate, yychar, yys); 6730c8de5b0SBaptiste Daroussin } 6740c8de5b0SBaptiste Daroussin #endif 6750c8de5b0SBaptiste Daroussin yychar = YYEMPTY; 6760c8de5b0SBaptiste Daroussin goto yyloop; 6770c8de5b0SBaptiste Daroussin } 6780c8de5b0SBaptiste Daroussin 6790c8de5b0SBaptiste Daroussin yyreduce: 6800c8de5b0SBaptiste Daroussin #if YYDEBUG 6810c8de5b0SBaptiste Daroussin if (yydebug) 6820c8de5b0SBaptiste Daroussin printf("%sdebug: state %d, reducing by rule %d (%s)\n", 6830c8de5b0SBaptiste Daroussin YYPREFIX, yystate, yyn, yyrule[yyn]); 6840c8de5b0SBaptiste Daroussin #endif 6850c8de5b0SBaptiste Daroussin yym = yylen[yyn]; 6860c8de5b0SBaptiste Daroussin if (yym) 6870c8de5b0SBaptiste Daroussin yyval = yystack.l_mark[1-yym]; 6880c8de5b0SBaptiste Daroussin else 6890c8de5b0SBaptiste Daroussin memset(&yyval, 0, sizeof yyval); 6900c8de5b0SBaptiste Daroussin switch (yyn) 6910c8de5b0SBaptiste Daroussin { 6920c8de5b0SBaptiste Daroussin case 3: 6930c8de5b0SBaptiste Daroussin #line 57 "calc1.y" 6940c8de5b0SBaptiste Daroussin { 6950c8de5b0SBaptiste Daroussin (void) printf("%15.8f\n", yystack.l_mark[-1].dval); 6960c8de5b0SBaptiste Daroussin } 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 } 7030c8de5b0SBaptiste Daroussin break; 7040c8de5b0SBaptiste Daroussin case 5: 7050c8de5b0SBaptiste Daroussin #line 65 "calc1.y" 7060c8de5b0SBaptiste Daroussin { 7070c8de5b0SBaptiste Daroussin dreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].dval; 7080c8de5b0SBaptiste Daroussin } 7090c8de5b0SBaptiste Daroussin break; 7100c8de5b0SBaptiste Daroussin case 6: 7110c8de5b0SBaptiste Daroussin #line 69 "calc1.y" 7120c8de5b0SBaptiste Daroussin { 7130c8de5b0SBaptiste Daroussin vreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].vval; 7140c8de5b0SBaptiste Daroussin } 7150c8de5b0SBaptiste Daroussin break; 7160c8de5b0SBaptiste Daroussin case 7: 7170c8de5b0SBaptiste Daroussin #line 73 "calc1.y" 7180c8de5b0SBaptiste Daroussin { 7190c8de5b0SBaptiste Daroussin yyerrok; 7200c8de5b0SBaptiste Daroussin } 7210c8de5b0SBaptiste Daroussin break; 7220c8de5b0SBaptiste Daroussin case 9: 7230c8de5b0SBaptiste Daroussin #line 80 "calc1.y" 7240c8de5b0SBaptiste Daroussin { 7250c8de5b0SBaptiste Daroussin yyval.dval = dreg[yystack.l_mark[0].ival]; 7260c8de5b0SBaptiste Daroussin } 7270c8de5b0SBaptiste Daroussin break; 7280c8de5b0SBaptiste Daroussin case 10: 7290c8de5b0SBaptiste Daroussin #line 84 "calc1.y" 7300c8de5b0SBaptiste Daroussin { 7310c8de5b0SBaptiste Daroussin yyval.dval = yystack.l_mark[-2].dval + yystack.l_mark[0].dval; 7320c8de5b0SBaptiste Daroussin } 7330c8de5b0SBaptiste Daroussin break; 7340c8de5b0SBaptiste Daroussin case 11: 7350c8de5b0SBaptiste Daroussin #line 88 "calc1.y" 7360c8de5b0SBaptiste Daroussin { 7370c8de5b0SBaptiste Daroussin yyval.dval = yystack.l_mark[-2].dval - yystack.l_mark[0].dval; 7380c8de5b0SBaptiste Daroussin } 7390c8de5b0SBaptiste Daroussin break; 7400c8de5b0SBaptiste Daroussin case 12: 7410c8de5b0SBaptiste Daroussin #line 92 "calc1.y" 7420c8de5b0SBaptiste Daroussin { 7430c8de5b0SBaptiste Daroussin yyval.dval = yystack.l_mark[-2].dval * yystack.l_mark[0].dval; 7440c8de5b0SBaptiste Daroussin } 7450c8de5b0SBaptiste Daroussin break; 7460c8de5b0SBaptiste Daroussin case 13: 7470c8de5b0SBaptiste Daroussin #line 96 "calc1.y" 7480c8de5b0SBaptiste Daroussin { 7490c8de5b0SBaptiste Daroussin yyval.dval = yystack.l_mark[-2].dval / yystack.l_mark[0].dval; 7500c8de5b0SBaptiste Daroussin } 7510c8de5b0SBaptiste Daroussin break; 7520c8de5b0SBaptiste Daroussin case 14: 7530c8de5b0SBaptiste Daroussin #line 100 "calc1.y" 7540c8de5b0SBaptiste Daroussin { 7550c8de5b0SBaptiste Daroussin yyval.dval = -yystack.l_mark[0].dval; 7560c8de5b0SBaptiste Daroussin } 7570c8de5b0SBaptiste Daroussin break; 7580c8de5b0SBaptiste Daroussin case 15: 7590c8de5b0SBaptiste Daroussin #line 104 "calc1.y" 7600c8de5b0SBaptiste Daroussin { 7610c8de5b0SBaptiste Daroussin yyval.dval = yystack.l_mark[-1].dval; 7620c8de5b0SBaptiste Daroussin } 7630c8de5b0SBaptiste Daroussin break; 7640c8de5b0SBaptiste Daroussin case 16: 7650c8de5b0SBaptiste Daroussin #line 110 "calc1.y" 7660c8de5b0SBaptiste Daroussin { 7670c8de5b0SBaptiste Daroussin yyval.vval.hi = yyval.vval.lo = yystack.l_mark[0].dval; 7680c8de5b0SBaptiste Daroussin } 7690c8de5b0SBaptiste Daroussin break; 7700c8de5b0SBaptiste Daroussin case 17: 7710c8de5b0SBaptiste Daroussin #line 114 "calc1.y" 7720c8de5b0SBaptiste Daroussin { 7730c8de5b0SBaptiste Daroussin yyval.vval.lo = yystack.l_mark[-3].dval; 7740c8de5b0SBaptiste Daroussin yyval.vval.hi = yystack.l_mark[-1].dval; 7750c8de5b0SBaptiste Daroussin if ( yyval.vval.lo > yyval.vval.hi ) 7760c8de5b0SBaptiste Daroussin { 7770c8de5b0SBaptiste Daroussin (void) printf("interval out of order\n"); 7780c8de5b0SBaptiste Daroussin YYERROR; 7790c8de5b0SBaptiste Daroussin } 7800c8de5b0SBaptiste Daroussin } 7810c8de5b0SBaptiste Daroussin break; 7820c8de5b0SBaptiste Daroussin case 18: 7830c8de5b0SBaptiste Daroussin #line 124 "calc1.y" 7840c8de5b0SBaptiste Daroussin { 7850c8de5b0SBaptiste Daroussin yyval.vval = vreg[yystack.l_mark[0].ival]; 7860c8de5b0SBaptiste Daroussin } 7870c8de5b0SBaptiste Daroussin break; 7880c8de5b0SBaptiste Daroussin case 19: 7890c8de5b0SBaptiste Daroussin #line 128 "calc1.y" 7900c8de5b0SBaptiste Daroussin { 7910c8de5b0SBaptiste Daroussin yyval.vval.hi = yystack.l_mark[-2].vval.hi + yystack.l_mark[0].vval.hi; 7920c8de5b0SBaptiste Daroussin yyval.vval.lo = yystack.l_mark[-2].vval.lo + yystack.l_mark[0].vval.lo; 7930c8de5b0SBaptiste Daroussin } 7940c8de5b0SBaptiste Daroussin break; 7950c8de5b0SBaptiste Daroussin case 20: 7960c8de5b0SBaptiste Daroussin #line 133 "calc1.y" 7970c8de5b0SBaptiste Daroussin { 7980c8de5b0SBaptiste Daroussin yyval.vval.hi = yystack.l_mark[-2].dval + yystack.l_mark[0].vval.hi; 7990c8de5b0SBaptiste Daroussin yyval.vval.lo = yystack.l_mark[-2].dval + yystack.l_mark[0].vval.lo; 8000c8de5b0SBaptiste Daroussin } 8010c8de5b0SBaptiste Daroussin break; 8020c8de5b0SBaptiste Daroussin case 21: 8030c8de5b0SBaptiste Daroussin #line 138 "calc1.y" 8040c8de5b0SBaptiste Daroussin { 8050c8de5b0SBaptiste Daroussin yyval.vval.hi = yystack.l_mark[-2].vval.hi - yystack.l_mark[0].vval.lo; 8060c8de5b0SBaptiste Daroussin yyval.vval.lo = yystack.l_mark[-2].vval.lo - yystack.l_mark[0].vval.hi; 8070c8de5b0SBaptiste Daroussin } 8080c8de5b0SBaptiste Daroussin break; 8090c8de5b0SBaptiste Daroussin case 22: 8100c8de5b0SBaptiste Daroussin #line 143 "calc1.y" 8110c8de5b0SBaptiste Daroussin { 8120c8de5b0SBaptiste Daroussin yyval.vval.hi = yystack.l_mark[-2].dval - yystack.l_mark[0].vval.lo; 8130c8de5b0SBaptiste Daroussin yyval.vval.lo = yystack.l_mark[-2].dval - yystack.l_mark[0].vval.hi; 8140c8de5b0SBaptiste Daroussin } 8150c8de5b0SBaptiste Daroussin break; 8160c8de5b0SBaptiste Daroussin case 23: 8170c8de5b0SBaptiste Daroussin #line 148 "calc1.y" 8180c8de5b0SBaptiste Daroussin { 8190c8de5b0SBaptiste Daroussin yyval.vval = vmul( yystack.l_mark[-2].vval.lo, yystack.l_mark[-2].vval.hi, yystack.l_mark[0].vval ); 8200c8de5b0SBaptiste Daroussin } 8210c8de5b0SBaptiste Daroussin break; 8220c8de5b0SBaptiste Daroussin case 24: 8230c8de5b0SBaptiste Daroussin #line 152 "calc1.y" 8240c8de5b0SBaptiste Daroussin { 8250c8de5b0SBaptiste Daroussin yyval.vval = vmul (yystack.l_mark[-2].dval, yystack.l_mark[-2].dval, yystack.l_mark[0].vval ); 8260c8de5b0SBaptiste Daroussin } 8270c8de5b0SBaptiste Daroussin break; 8280c8de5b0SBaptiste Daroussin case 25: 8290c8de5b0SBaptiste Daroussin #line 156 "calc1.y" 8300c8de5b0SBaptiste Daroussin { 8310c8de5b0SBaptiste Daroussin if (dcheck(yystack.l_mark[0].vval)) YYERROR; 8320c8de5b0SBaptiste Daroussin yyval.vval = vdiv ( yystack.l_mark[-2].vval.lo, yystack.l_mark[-2].vval.hi, yystack.l_mark[0].vval ); 8330c8de5b0SBaptiste Daroussin } 8340c8de5b0SBaptiste Daroussin break; 8350c8de5b0SBaptiste Daroussin case 26: 8360c8de5b0SBaptiste Daroussin #line 161 "calc1.y" 8370c8de5b0SBaptiste Daroussin { 8380c8de5b0SBaptiste Daroussin if (dcheck ( yystack.l_mark[0].vval )) YYERROR; 8390c8de5b0SBaptiste Daroussin yyval.vval = vdiv (yystack.l_mark[-2].dval, yystack.l_mark[-2].dval, yystack.l_mark[0].vval ); 8400c8de5b0SBaptiste Daroussin } 8410c8de5b0SBaptiste Daroussin break; 8420c8de5b0SBaptiste Daroussin case 27: 8430c8de5b0SBaptiste Daroussin #line 166 "calc1.y" 8440c8de5b0SBaptiste Daroussin { 8450c8de5b0SBaptiste Daroussin yyval.vval.hi = -yystack.l_mark[0].vval.lo; 8460c8de5b0SBaptiste Daroussin yyval.vval.lo = -yystack.l_mark[0].vval.hi; 8470c8de5b0SBaptiste Daroussin } 8480c8de5b0SBaptiste Daroussin break; 8490c8de5b0SBaptiste Daroussin case 28: 8500c8de5b0SBaptiste Daroussin #line 171 "calc1.y" 8510c8de5b0SBaptiste Daroussin { 8520c8de5b0SBaptiste Daroussin yyval.vval = yystack.l_mark[-1].vval; 8530c8de5b0SBaptiste Daroussin } 8540c8de5b0SBaptiste Daroussin break; 8550c8de5b0SBaptiste Daroussin #line 856 "calc1.tab.c" 8560c8de5b0SBaptiste Daroussin } 8570c8de5b0SBaptiste Daroussin yystack.s_mark -= yym; 8580c8de5b0SBaptiste Daroussin yystate = *yystack.s_mark; 8590c8de5b0SBaptiste Daroussin yystack.l_mark -= yym; 8600c8de5b0SBaptiste Daroussin yym = yylhs[yyn]; 8610c8de5b0SBaptiste Daroussin if (yystate == 0 && yym == 0) 8620c8de5b0SBaptiste Daroussin { 8630c8de5b0SBaptiste Daroussin #if YYDEBUG 8640c8de5b0SBaptiste Daroussin if (yydebug) 8650c8de5b0SBaptiste Daroussin printf("%sdebug: after reduction, shifting from state 0 to\ 8660c8de5b0SBaptiste Daroussin state %d\n", YYPREFIX, YYFINAL); 8670c8de5b0SBaptiste Daroussin #endif 8680c8de5b0SBaptiste Daroussin yystate = YYFINAL; 8690c8de5b0SBaptiste Daroussin *++yystack.s_mark = YYFINAL; 8700c8de5b0SBaptiste Daroussin *++yystack.l_mark = yyval; 8710c8de5b0SBaptiste Daroussin if (yychar < 0) 8720c8de5b0SBaptiste Daroussin { 8730c8de5b0SBaptiste Daroussin if ((yychar = YYLEX) < 0) yychar = YYEOF; 8740c8de5b0SBaptiste Daroussin #if YYDEBUG 8750c8de5b0SBaptiste Daroussin if (yydebug) 8760c8de5b0SBaptiste Daroussin { 8770c8de5b0SBaptiste Daroussin yys = yyname[YYTRANSLATE(yychar)]; 8780c8de5b0SBaptiste Daroussin printf("%sdebug: state %d, reading %d (%s)\n", 8790c8de5b0SBaptiste Daroussin YYPREFIX, YYFINAL, yychar, yys); 8800c8de5b0SBaptiste Daroussin } 8810c8de5b0SBaptiste Daroussin #endif 8820c8de5b0SBaptiste Daroussin } 8830c8de5b0SBaptiste Daroussin if (yychar == YYEOF) goto yyaccept; 8840c8de5b0SBaptiste Daroussin goto yyloop; 8850c8de5b0SBaptiste Daroussin } 8860c8de5b0SBaptiste Daroussin if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && 8870c8de5b0SBaptiste Daroussin yyn <= YYTABLESIZE && yycheck[yyn] == yystate) 8880c8de5b0SBaptiste Daroussin yystate = yytable[yyn]; 8890c8de5b0SBaptiste Daroussin else 8900c8de5b0SBaptiste Daroussin yystate = yydgoto[yym]; 8910c8de5b0SBaptiste Daroussin #if YYDEBUG 8920c8de5b0SBaptiste Daroussin if (yydebug) 8930c8de5b0SBaptiste Daroussin printf("%sdebug: after reduction, shifting from state %d \ 8940c8de5b0SBaptiste Daroussin to state %d\n", YYPREFIX, *yystack.s_mark, yystate); 8950c8de5b0SBaptiste Daroussin #endif 8960c8de5b0SBaptiste Daroussin if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) 8970c8de5b0SBaptiste Daroussin { 8980c8de5b0SBaptiste Daroussin goto yyoverflow; 8990c8de5b0SBaptiste Daroussin } 9000c8de5b0SBaptiste Daroussin *++yystack.s_mark = (YYINT) yystate; 9010c8de5b0SBaptiste Daroussin *++yystack.l_mark = yyval; 9020c8de5b0SBaptiste Daroussin goto yyloop; 9030c8de5b0SBaptiste Daroussin 9040c8de5b0SBaptiste Daroussin yyoverflow: 9050c8de5b0SBaptiste Daroussin YYERROR_CALL("yacc stack overflow"); 9060c8de5b0SBaptiste Daroussin 9070c8de5b0SBaptiste Daroussin yyabort: 9080c8de5b0SBaptiste Daroussin yyfreestack(&yystack); 9090c8de5b0SBaptiste Daroussin return (1); 9100c8de5b0SBaptiste Daroussin 9110c8de5b0SBaptiste Daroussin yyaccept: 9120c8de5b0SBaptiste Daroussin yyfreestack(&yystack); 9130c8de5b0SBaptiste Daroussin return (0); 9140c8de5b0SBaptiste Daroussin } 915