4 5#define YYBYACC 1 6#define YYMAJOR 1 7#define YYMINOR 9 8#define YYCHECK "yyyymmdd" 9 10#define YYEMPTY (-1) 11#define yyclearin (yychar = YYEMPTY) 12#define yyerrok (yyerrflag = 0) 13#define YYRECOVERING() (yyerrflag != 0) 14#define YYENOMEM (-2) 15#define YYEOF 0 16#undef YYBTYACC 17#define YYBTYACC 0 18#define YYDEBUGSTR YYPREFIX "debug" 19 20#ifndef yyparse 21#define yyparse calc1_parse 22#endif /* yyparse */ 23 24#ifndef yylex 25#define yylex calc1_lex 26#endif /* yylex */ 27 28#ifndef yyerror 29#define yyerror calc1_error 30#endif /* yyerror */ 31 32#ifndef yychar 33#define yychar calc1_char 34#endif /* yychar */ 35 36#ifndef yyval 37#define yyval calc1_val 38#endif /* yyval */ 39 40#ifndef yylval 41#define yylval calc1_lval 42#endif /* yylval */ 43 44#ifndef yydebug 45#define yydebug calc1_debug 46#endif /* yydebug */ 47 48#ifndef yynerrs 49#define yynerrs calc1_nerrs 50#endif /* yynerrs */ 51 52#ifndef yyerrflag 53#define yyerrflag calc1_errflag 54#endif /* yyerrflag */ 55 56#ifndef yylhs 57#define yylhs calc1_lhs 58#endif /* yylhs */ 59 60#ifndef yylen 61#define yylen calc1_len 62#endif /* yylen */ 63 64#ifndef yydefred 65#define yydefred calc1_defred 66#endif /* yydefred */ 67 68#ifndef yystos 69#define yystos calc1_stos 70#endif /* yystos */ 71 72#ifndef yydgoto 73#define yydgoto calc1_dgoto 74#endif /* yydgoto */ 75 76#ifndef yysindex 77#define yysindex calc1_sindex 78#endif /* yysindex */ 79 80#ifndef yyrindex 81#define yyrindex calc1_rindex 82#endif /* yyrindex */ 83 84#ifndef yygindex 85#define yygindex calc1_gindex 86#endif /* yygindex */ 87 88#ifndef yytable 89#define yytable calc1_table 90#endif /* yytable */ 91 92#ifndef yycheck 93#define yycheck calc1_check 94#endif /* yycheck */ 95 96#ifndef yyname 97#define yyname calc1_name 98#endif /* yyname */ 99 100#ifndef yyrule 101#define yyrule calc1_rule 102#endif /* yyrule */ 103 104#if YYBTYACC 105 106#ifndef yycindex 107#define yycindex calc1_cindex 108#endif /* yycindex */ 109 110#ifndef yyctable 111#define yyctable calc1_ctable 112#endif /* yyctable */ 113 114#endif /* YYBTYACC */ 115 116#define YYPREFIX "calc1_" 117 118#define YYPURE 0 119 120#line 2 "calc1.y" 121 122/* http://dinosaur.compilertools.net/yacc/index.html */ 123 124#include <stdlib.h> 125#include <stdio.h> 126#include <ctype.h> 127#include <math.h> 128 129typedef struct interval 130{ 131 double lo, hi; 132} 133INTERVAL; 134 135INTERVAL vmul(double, double, INTERVAL); 136INTERVAL vdiv(double, double, INTERVAL); 137 138extern int yylex(void); 139static void yyerror(const char *s); 140 141int dcheck(INTERVAL); 142 143double dreg[26]; 144INTERVAL vreg[26]; 145 146#line 31 "calc1.y" 147#ifdef YYSTYPE 148#undef YYSTYPE_IS_DECLARED 149#define YYSTYPE_IS_DECLARED 1 150#endif 151#ifndef YYSTYPE_IS_DECLARED 152#define YYSTYPE_IS_DECLARED 1 153typedef union 154{ 155 int ival; 156 double dval; 157 INTERVAL vval; 158} YYSTYPE; 159#endif /* !YYSTYPE_IS_DECLARED */ 160#line 161 "calc1.tab.c" 161 162/* compatibility with bison */ 163#ifdef YYPARSE_PARAM 164/* compatibility with FreeBSD */ 165# ifdef YYPARSE_PARAM_TYPE 166# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) 167# else 168# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) 169# endif 170#else 171# define YYPARSE_DECL() yyparse(void) 172#endif 173 174/* Parameters sent to lex. */ 175#ifdef YYLEX_PARAM 176# define YYLEX_DECL() yylex(void *YYLEX_PARAM) 177# define YYLEX yylex(YYLEX_PARAM) 178#else 179# define YYLEX_DECL() yylex(void) 180# define YYLEX yylex() 181#endif 182 183/* Parameters sent to yyerror. */ 184#ifndef YYERROR_DECL 185#define YYERROR_DECL() yyerror(const char *s) 186#endif 187#ifndef YYERROR_CALL 188#define YYERROR_CALL(msg) yyerror(msg) 189#endif 190 191extern int YYPARSE_DECL(); 192 193#define DREG 257 194#define VREG 258 195#define CONST 259 196#define UMINUS 260 197#define YYERRCODE 256 198typedef short YYINT; 199static const YYINT calc1_lhs[] = { -1, 200 3, 3, 0, 0, 0, 0, 0, 1, 1, 1, 201 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 202 2, 2, 2, 2, 2, 2, 2, 2, 203}; 204static const YYINT calc1_len[] = { 2, 205 0, 2, 2, 2, 4, 4, 2, 1, 1, 3, 206 3, 3, 3, 2, 3, 1, 5, 1, 3, 3, 207 3, 3, 3, 3, 3, 3, 2, 3, 208}; 209static const YYINT calc1_defred[] = { 0, 210 0, 0, 0, 8, 0, 0, 0, 0, 0, 7, 211 0, 0, 9, 18, 14, 27, 0, 0, 0, 0, 212 0, 0, 3, 0, 0, 0, 0, 4, 0, 0, 213 0, 0, 0, 15, 0, 28, 0, 0, 0, 0, 214 12, 24, 13, 26, 0, 0, 23, 25, 14, 0, 215 0, 0, 0, 0, 5, 6, 0, 0, 0, 12, 216 13, 17, 217}; 218static const YYINT calc1_stos[] = { 0, 219 256, 257, 258, 259, 45, 40, 262, 263, 264, 10, 220 61, 61, 257, 258, 263, 264, 263, 264, 43, 45, 221 42, 47, 10, 43, 45, 42, 47, 10, 45, 40, 222 263, 263, 264, 41, 44, 41, 263, 264, 263, 264, 223 263, 264, 263, 264, 264, 264, 264, 264, 263, 263, 224 43, 45, 42, 47, 10, 10, 263, 263, 263, 263, 225 263, 41, 226}; 227static const YYINT calc1_dgoto[] = { 7, 228 32, 9, 0, 229}; 230static const YYINT calc1_sindex[] = { -40, 231 -8, -48, -47, 0, -37, -37, 0, 2, 17, 0, 232 -34, -37, 0, 0, 0, 0, -25, 90, -37, -37, 233 -37, -37, 0, -37, -37, -37, -37, 0, -34, -34, 234 25, 125, 31, 0, -34, 0, -11, 37, -11, 37, 235 0, 0, 0, 0, 37, 37, 0, 0, 0, 111, 236 -34, -34, -34, -34, 0, 0, 118, 69, 69, 0, 237 0, 0, 238}; 239static const YYINT calc1_rindex[] = { 0, 240 0, 38, 44, 0, 0, 0, 0, 0, 0, 0, 241 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 242 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 243 0, -9, 0, 0, 0, 0, 51, -3, 56, 61, 244 0, 0, 0, 0, 67, 72, 0, 0, 0, 0, 245 0, 0, 0, 0, 0, 0, 0, 78, 83, 0, 246 0, 0, 247}; 248#if YYBTYACC 249static const YYINT calc1_cindex[] = { 0, 250 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 251 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 252 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 253 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 254 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 256 0, 0, 257}; 258#endif 259static const YYINT calc1_gindex[] = { 0, 260 4, 124, 0, 261}; 262#define YYTABLESIZE 225 263static const YYINT calc1_table[] = { 6, 264 16, 10, 6, 8, 5, 30, 20, 5, 15, 17, 265 29, 23, 11, 12, 31, 34, 21, 19, 35, 20, 266 0, 22, 37, 39, 41, 43, 28, 0, 0, 0, 267 21, 16, 49, 50, 55, 22, 0, 20, 57, 20, 268 56, 20, 0, 21, 19, 0, 20, 9, 22, 0, 269 0, 0, 0, 18, 58, 59, 60, 61, 26, 24, 270 10, 25, 0, 27, 0, 11, 53, 51, 0, 52, 271 22, 54, 26, 24, 0, 25, 19, 27, 26, 9, 272 9, 21, 9, 27, 9, 18, 18, 10, 18, 0, 273 18, 10, 11, 10, 10, 10, 11, 0, 11, 11, 274 11, 22, 0, 22, 0, 22, 0, 19, 0, 19, 275 53, 19, 21, 0, 21, 54, 21, 0, 10, 0, 276 10, 0, 10, 11, 0, 11, 0, 11, 16, 18, 277 36, 26, 24, 0, 25, 33, 27, 0, 0, 0, 278 0, 0, 38, 40, 42, 44, 0, 45, 46, 47, 279 48, 34, 53, 51, 0, 52, 0, 54, 62, 53, 280 51, 0, 52, 0, 54, 0, 21, 19, 0, 20, 281 0, 22, 0, 0, 0, 0, 0, 0, 0, 0, 282 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 283 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 284 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 285 0, 0, 0, 0, 0, 1, 2, 3, 4, 13, 286 14, 4, 13, 0, 4, 287}; 288static const YYINT calc1_check[] = { 40, 289 10, 10, 40, 0, 45, 40, 10, 45, 5, 6, 290 45, 10, 61, 61, 11, 41, 42, 43, 44, 45, 291 -1, 47, 19, 20, 21, 22, 10, -1, -1, -1, 292 42, 41, 29, 30, 10, 47, -1, 41, 35, 43, 293 10, 45, -1, 42, 43, -1, 45, 10, 47, -1, 294 -1, -1, -1, 10, 51, 52, 53, 54, 42, 43, 295 10, 45, -1, 47, -1, 10, 42, 43, -1, 45, 296 10, 47, 42, 43, -1, 45, 10, 47, 42, 42, 297 43, 10, 45, 47, 47, 42, 43, 10, 45, -1, 298 47, 41, 10, 43, 44, 45, 41, -1, 43, 44, 299 45, 41, -1, 43, -1, 45, -1, 41, -1, 43, 300 42, 45, 41, -1, 43, 47, 45, -1, 41, -1, 301 43, -1, 45, 41, -1, 43, -1, 45, 5, 6, 302 41, 42, 43, -1, 45, 12, 47, -1, -1, -1, 303 -1, -1, 19, 20, 21, 22, -1, 24, 25, 26, 304 27, 41, 42, 43, -1, 45, -1, 47, 41, 42, 305 43, -1, 45, -1, 47, -1, 42, 43, -1, 45, 306 -1, 47, -1, -1, -1, -1, -1, -1, -1, -1, 307 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 308 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 309 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 310 -1, -1, -1, -1, -1, 256, 257, 258, 259, 257, 311 258, 259, 257, -1, 259, 312};
| 4 5#define YYBYACC 1 6#define YYMAJOR 1 7#define YYMINOR 9 8#define YYCHECK "yyyymmdd" 9 10#define YYEMPTY (-1) 11#define yyclearin (yychar = YYEMPTY) 12#define yyerrok (yyerrflag = 0) 13#define YYRECOVERING() (yyerrflag != 0) 14#define YYENOMEM (-2) 15#define YYEOF 0 16#undef YYBTYACC 17#define YYBTYACC 0 18#define YYDEBUGSTR YYPREFIX "debug" 19 20#ifndef yyparse 21#define yyparse calc1_parse 22#endif /* yyparse */ 23 24#ifndef yylex 25#define yylex calc1_lex 26#endif /* yylex */ 27 28#ifndef yyerror 29#define yyerror calc1_error 30#endif /* yyerror */ 31 32#ifndef yychar 33#define yychar calc1_char 34#endif /* yychar */ 35 36#ifndef yyval 37#define yyval calc1_val 38#endif /* yyval */ 39 40#ifndef yylval 41#define yylval calc1_lval 42#endif /* yylval */ 43 44#ifndef yydebug 45#define yydebug calc1_debug 46#endif /* yydebug */ 47 48#ifndef yynerrs 49#define yynerrs calc1_nerrs 50#endif /* yynerrs */ 51 52#ifndef yyerrflag 53#define yyerrflag calc1_errflag 54#endif /* yyerrflag */ 55 56#ifndef yylhs 57#define yylhs calc1_lhs 58#endif /* yylhs */ 59 60#ifndef yylen 61#define yylen calc1_len 62#endif /* yylen */ 63 64#ifndef yydefred 65#define yydefred calc1_defred 66#endif /* yydefred */ 67 68#ifndef yystos 69#define yystos calc1_stos 70#endif /* yystos */ 71 72#ifndef yydgoto 73#define yydgoto calc1_dgoto 74#endif /* yydgoto */ 75 76#ifndef yysindex 77#define yysindex calc1_sindex 78#endif /* yysindex */ 79 80#ifndef yyrindex 81#define yyrindex calc1_rindex 82#endif /* yyrindex */ 83 84#ifndef yygindex 85#define yygindex calc1_gindex 86#endif /* yygindex */ 87 88#ifndef yytable 89#define yytable calc1_table 90#endif /* yytable */ 91 92#ifndef yycheck 93#define yycheck calc1_check 94#endif /* yycheck */ 95 96#ifndef yyname 97#define yyname calc1_name 98#endif /* yyname */ 99 100#ifndef yyrule 101#define yyrule calc1_rule 102#endif /* yyrule */ 103 104#if YYBTYACC 105 106#ifndef yycindex 107#define yycindex calc1_cindex 108#endif /* yycindex */ 109 110#ifndef yyctable 111#define yyctable calc1_ctable 112#endif /* yyctable */ 113 114#endif /* YYBTYACC */ 115 116#define YYPREFIX "calc1_" 117 118#define YYPURE 0 119 120#line 2 "calc1.y" 121 122/* http://dinosaur.compilertools.net/yacc/index.html */ 123 124#include <stdlib.h> 125#include <stdio.h> 126#include <ctype.h> 127#include <math.h> 128 129typedef struct interval 130{ 131 double lo, hi; 132} 133INTERVAL; 134 135INTERVAL vmul(double, double, INTERVAL); 136INTERVAL vdiv(double, double, INTERVAL); 137 138extern int yylex(void); 139static void yyerror(const char *s); 140 141int dcheck(INTERVAL); 142 143double dreg[26]; 144INTERVAL vreg[26]; 145 146#line 31 "calc1.y" 147#ifdef YYSTYPE 148#undef YYSTYPE_IS_DECLARED 149#define YYSTYPE_IS_DECLARED 1 150#endif 151#ifndef YYSTYPE_IS_DECLARED 152#define YYSTYPE_IS_DECLARED 1 153typedef union 154{ 155 int ival; 156 double dval; 157 INTERVAL vval; 158} YYSTYPE; 159#endif /* !YYSTYPE_IS_DECLARED */ 160#line 161 "calc1.tab.c" 161 162/* compatibility with bison */ 163#ifdef YYPARSE_PARAM 164/* compatibility with FreeBSD */ 165# ifdef YYPARSE_PARAM_TYPE 166# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) 167# else 168# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) 169# endif 170#else 171# define YYPARSE_DECL() yyparse(void) 172#endif 173 174/* Parameters sent to lex. */ 175#ifdef YYLEX_PARAM 176# define YYLEX_DECL() yylex(void *YYLEX_PARAM) 177# define YYLEX yylex(YYLEX_PARAM) 178#else 179# define YYLEX_DECL() yylex(void) 180# define YYLEX yylex() 181#endif 182 183/* Parameters sent to yyerror. */ 184#ifndef YYERROR_DECL 185#define YYERROR_DECL() yyerror(const char *s) 186#endif 187#ifndef YYERROR_CALL 188#define YYERROR_CALL(msg) yyerror(msg) 189#endif 190 191extern int YYPARSE_DECL(); 192 193#define DREG 257 194#define VREG 258 195#define CONST 259 196#define UMINUS 260 197#define YYERRCODE 256 198typedef short YYINT; 199static const YYINT calc1_lhs[] = { -1, 200 3, 3, 0, 0, 0, 0, 0, 1, 1, 1, 201 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 202 2, 2, 2, 2, 2, 2, 2, 2, 203}; 204static const YYINT calc1_len[] = { 2, 205 0, 2, 2, 2, 4, 4, 2, 1, 1, 3, 206 3, 3, 3, 2, 3, 1, 5, 1, 3, 3, 207 3, 3, 3, 3, 3, 3, 2, 3, 208}; 209static const YYINT calc1_defred[] = { 0, 210 0, 0, 0, 8, 0, 0, 0, 0, 0, 7, 211 0, 0, 9, 18, 14, 27, 0, 0, 0, 0, 212 0, 0, 3, 0, 0, 0, 0, 4, 0, 0, 213 0, 0, 0, 15, 0, 28, 0, 0, 0, 0, 214 12, 24, 13, 26, 0, 0, 23, 25, 14, 0, 215 0, 0, 0, 0, 5, 6, 0, 0, 0, 12, 216 13, 17, 217}; 218static const YYINT calc1_stos[] = { 0, 219 256, 257, 258, 259, 45, 40, 262, 263, 264, 10, 220 61, 61, 257, 258, 263, 264, 263, 264, 43, 45, 221 42, 47, 10, 43, 45, 42, 47, 10, 45, 40, 222 263, 263, 264, 41, 44, 41, 263, 264, 263, 264, 223 263, 264, 263, 264, 264, 264, 264, 264, 263, 263, 224 43, 45, 42, 47, 10, 10, 263, 263, 263, 263, 225 263, 41, 226}; 227static const YYINT calc1_dgoto[] = { 7, 228 32, 9, 0, 229}; 230static const YYINT calc1_sindex[] = { -40, 231 -8, -48, -47, 0, -37, -37, 0, 2, 17, 0, 232 -34, -37, 0, 0, 0, 0, -25, 90, -37, -37, 233 -37, -37, 0, -37, -37, -37, -37, 0, -34, -34, 234 25, 125, 31, 0, -34, 0, -11, 37, -11, 37, 235 0, 0, 0, 0, 37, 37, 0, 0, 0, 111, 236 -34, -34, -34, -34, 0, 0, 118, 69, 69, 0, 237 0, 0, 238}; 239static const YYINT calc1_rindex[] = { 0, 240 0, 38, 44, 0, 0, 0, 0, 0, 0, 0, 241 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 242 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 243 0, -9, 0, 0, 0, 0, 51, -3, 56, 61, 244 0, 0, 0, 0, 67, 72, 0, 0, 0, 0, 245 0, 0, 0, 0, 0, 0, 0, 78, 83, 0, 246 0, 0, 247}; 248#if YYBTYACC 249static const YYINT calc1_cindex[] = { 0, 250 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 251 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 252 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 253 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 254 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 256 0, 0, 257}; 258#endif 259static const YYINT calc1_gindex[] = { 0, 260 4, 124, 0, 261}; 262#define YYTABLESIZE 225 263static const YYINT calc1_table[] = { 6, 264 16, 10, 6, 8, 5, 30, 20, 5, 15, 17, 265 29, 23, 11, 12, 31, 34, 21, 19, 35, 20, 266 0, 22, 37, 39, 41, 43, 28, 0, 0, 0, 267 21, 16, 49, 50, 55, 22, 0, 20, 57, 20, 268 56, 20, 0, 21, 19, 0, 20, 9, 22, 0, 269 0, 0, 0, 18, 58, 59, 60, 61, 26, 24, 270 10, 25, 0, 27, 0, 11, 53, 51, 0, 52, 271 22, 54, 26, 24, 0, 25, 19, 27, 26, 9, 272 9, 21, 9, 27, 9, 18, 18, 10, 18, 0, 273 18, 10, 11, 10, 10, 10, 11, 0, 11, 11, 274 11, 22, 0, 22, 0, 22, 0, 19, 0, 19, 275 53, 19, 21, 0, 21, 54, 21, 0, 10, 0, 276 10, 0, 10, 11, 0, 11, 0, 11, 16, 18, 277 36, 26, 24, 0, 25, 33, 27, 0, 0, 0, 278 0, 0, 38, 40, 42, 44, 0, 45, 46, 47, 279 48, 34, 53, 51, 0, 52, 0, 54, 62, 53, 280 51, 0, 52, 0, 54, 0, 21, 19, 0, 20, 281 0, 22, 0, 0, 0, 0, 0, 0, 0, 0, 282 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 283 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 284 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 285 0, 0, 0, 0, 0, 1, 2, 3, 4, 13, 286 14, 4, 13, 0, 4, 287}; 288static const YYINT calc1_check[] = { 40, 289 10, 10, 40, 0, 45, 40, 10, 45, 5, 6, 290 45, 10, 61, 61, 11, 41, 42, 43, 44, 45, 291 -1, 47, 19, 20, 21, 22, 10, -1, -1, -1, 292 42, 41, 29, 30, 10, 47, -1, 41, 35, 43, 293 10, 45, -1, 42, 43, -1, 45, 10, 47, -1, 294 -1, -1, -1, 10, 51, 52, 53, 54, 42, 43, 295 10, 45, -1, 47, -1, 10, 42, 43, -1, 45, 296 10, 47, 42, 43, -1, 45, 10, 47, 42, 42, 297 43, 10, 45, 47, 47, 42, 43, 10, 45, -1, 298 47, 41, 10, 43, 44, 45, 41, -1, 43, 44, 299 45, 41, -1, 43, -1, 45, -1, 41, -1, 43, 300 42, 45, 41, -1, 43, 47, 45, -1, 41, -1, 301 43, -1, 45, 41, -1, 43, -1, 45, 5, 6, 302 41, 42, 43, -1, 45, 12, 47, -1, -1, -1, 303 -1, -1, 19, 20, 21, 22, -1, 24, 25, 26, 304 27, 41, 42, 43, -1, 45, -1, 47, 41, 42, 305 43, -1, 45, -1, 47, -1, 42, 43, -1, 45, 306 -1, 47, -1, -1, -1, -1, -1, -1, -1, -1, 307 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 308 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 309 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 310 -1, -1, -1, -1, -1, 256, 257, 258, 259, 257, 311 258, 259, 257, -1, 259, 312};
|
313#define YYFINAL 7 314#ifndef YYDEBUG 315#define YYDEBUG 0 316#endif 317#define YYMAXTOKEN 260 318#define YYUNDFTOKEN 266 319#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) 320#if YYDEBUG 321static const char *const calc1_name[] = { 322 323"$end",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,0,0,0, 3240,0,0,0,0,0,"'('","')'","'*'","'+'","','","'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0,0,0, 3250,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 3260,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 3270,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 3280,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 3290,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 330"error","DREG","VREG","CONST","UMINUS","$accept","line","dexp","vexp","lines", 331"illegal-symbol", 332}; 333static const char *const calc1_rule[] = { 334"$accept : line", 335"lines :", 336"lines : lines line", 337"line : dexp '\\n'", 338"line : vexp '\\n'", 339"line : DREG '=' dexp '\\n'", 340"line : VREG '=' vexp '\\n'", 341"line : error '\\n'", 342"dexp : CONST", 343"dexp : DREG", 344"dexp : dexp '+' dexp", 345"dexp : dexp '-' dexp", 346"dexp : dexp '*' dexp", 347"dexp : dexp '/' dexp", 348"dexp : '-' dexp", 349"dexp : '(' dexp ')'", 350"vexp : dexp", 351"vexp : '(' dexp ',' dexp ')'", 352"vexp : VREG", 353"vexp : vexp '+' vexp", 354"vexp : dexp '+' vexp", 355"vexp : vexp '-' vexp", 356"vexp : dexp '-' vexp", 357"vexp : vexp '*' vexp", 358"vexp : dexp '*' vexp", 359"vexp : vexp '/' vexp", 360"vexp : dexp '/' vexp", 361"vexp : '-' vexp", 362"vexp : '(' vexp ')'", 363 364}; 365#endif 366 367int yydebug; 368int yynerrs; 369 370int yyerrflag; 371int yychar; 372YYSTYPE yyval; 373YYSTYPE yylval; 374#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 375YYLTYPE yyloc; /* position returned by actions */ 376YYLTYPE yylloc; /* position from the lexer */ 377#endif 378 379#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 380#ifndef YYLLOC_DEFAULT 381#define YYLLOC_DEFAULT(loc, rhs, n) \ 382do \ 383{ \ 384 if (n == 0) \ 385 { \ 386 (loc).first_line = ((rhs)[-1]).last_line; \ 387 (loc).first_column = ((rhs)[-1]).last_column; \ 388 (loc).last_line = ((rhs)[-1]).last_line; \ 389 (loc).last_column = ((rhs)[-1]).last_column; \ 390 } \ 391 else \ 392 { \ 393 (loc).first_line = ((rhs)[ 0 ]).first_line; \ 394 (loc).first_column = ((rhs)[ 0 ]).first_column; \ 395 (loc).last_line = ((rhs)[n-1]).last_line; \ 396 (loc).last_column = ((rhs)[n-1]).last_column; \ 397 } \ 398} while (0) 399#endif /* YYLLOC_DEFAULT */ 400#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 401#if YYBTYACC 402 403#ifndef YYLVQUEUEGROWTH 404#define YYLVQUEUEGROWTH 32 405#endif 406#endif /* YYBTYACC */ 407 408/* define the initial stack-sizes */ 409#ifdef YYSTACKSIZE 410#undef YYMAXDEPTH 411#define YYMAXDEPTH YYSTACKSIZE 412#else 413#ifdef YYMAXDEPTH 414#define YYSTACKSIZE YYMAXDEPTH 415#else 416#define YYSTACKSIZE 10000 417#define YYMAXDEPTH 10000 418#endif 419#endif 420 421#ifndef YYINITSTACKSIZE 422#define YYINITSTACKSIZE 200 423#endif 424 425typedef struct { 426 unsigned stacksize; 427 short *s_base; 428 short *s_mark; 429 short *s_last; 430 YYSTYPE *l_base; 431 YYSTYPE *l_mark; 432#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 433 YYLTYPE *p_base; 434 YYLTYPE *p_mark; 435#endif 436} YYSTACKDATA; 437#if YYBTYACC 438 439struct YYParseState_s 440{ 441 struct YYParseState_s *save; /* Previously saved parser state */ 442 YYSTACKDATA yystack; /* saved parser stack */ 443 int state; /* saved parser state */ 444 int errflag; /* saved error recovery status */ 445 int lexeme; /* saved index of the conflict lexeme in the lexical queue */ 446 YYINT ctry; /* saved index in yyctable[] for this conflict */ 447}; 448typedef struct YYParseState_s YYParseState; 449#endif /* YYBTYACC */ 450/* variables for the parser stack */ 451static YYSTACKDATA yystack; 452#if YYBTYACC 453 454/* Current parser state */ 455static YYParseState *yyps = 0; 456 457/* yypath != NULL: do the full parse, starting at *yypath parser state. */ 458static YYParseState *yypath = 0; 459 460/* Base of the lexical value queue */ 461static YYSTYPE *yylvals = 0; 462 463/* Current position at lexical value queue */ 464static YYSTYPE *yylvp = 0; 465 466/* End position of lexical value queue */ 467static YYSTYPE *yylve = 0; 468 469/* The last allocated position at the lexical value queue */ 470static YYSTYPE *yylvlim = 0; 471 472#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 473/* Base of the lexical position queue */ 474static YYLTYPE *yylpsns = 0; 475 476/* Current position at lexical position queue */ 477static YYLTYPE *yylpp = 0; 478 479/* End position of lexical position queue */ 480static YYLTYPE *yylpe = 0; 481 482/* The last allocated position at the lexical position queue */ 483static YYLTYPE *yylplim = 0; 484#endif 485 486/* Current position at lexical token queue */ 487static short *yylexp = 0; 488 489static short *yylexemes = 0; 490#endif /* YYBTYACC */ 491#line 176 "calc1.y" 492 /* beginning of subroutines section */ 493 494#define BSZ 50 /* buffer size for floating point numbers */ 495 496 /* lexical analysis */ 497 498static void 499yyerror(const char *s) 500{ 501 fprintf(stderr, "%s\n", s); 502} 503 504int 505yylex(void) 506{ 507 int c; 508 509 while ((c = getchar()) == ' ') 510 { /* skip over blanks */ 511 } 512 513 if (isupper(c)) 514 { 515 yylval.ival = c - 'A'; 516 return (VREG); 517 } 518 if (islower(c)) 519 { 520 yylval.ival = c - 'a'; 521 return (DREG); 522 } 523 524 if (isdigit(c) || c == '.') 525 { 526 /* gobble up digits, points, exponents */ 527 char buf[BSZ + 1], *cp = buf; 528 int dot = 0, expr = 0; 529 530 for (; (cp - buf) < BSZ; ++cp, c = getchar()) 531 { 532 533 *cp = (char) c; 534 if (isdigit(c)) 535 continue; 536 if (c == '.') 537 { 538 if (dot++ || expr) 539 return ('.'); /* will cause syntax error */ 540 continue; 541 } 542 543 if (c == 'e') 544 { 545 if (expr++) 546 return ('e'); /* will cause syntax error */ 547 continue; 548 } 549 550 /* end of number */ 551 break; 552 } 553 *cp = '\0'; 554 555 if ((cp - buf) >= BSZ) 556 printf("constant too long: truncated\n"); 557 else 558 ungetc(c, stdin); /* push back last char read */ 559 yylval.dval = atof(buf); 560 return (CONST); 561 } 562 return (c); 563} 564 565static INTERVAL 566hilo(double a, double b, double c, double d) 567{ 568 /* returns the smallest interval containing a, b, c, and d */ 569 /* used by *, / routines */ 570 INTERVAL v; 571 572 if (a > b) 573 { 574 v.hi = a; 575 v.lo = b; 576 } 577 else 578 { 579 v.hi = b; 580 v.lo = a; 581 } 582 583 if (c > d) 584 { 585 if (c > v.hi) 586 v.hi = c; 587 if (d < v.lo) 588 v.lo = d; 589 } 590 else 591 { 592 if (d > v.hi) 593 v.hi = d; 594 if (c < v.lo) 595 v.lo = c; 596 } 597 return (v); 598} 599 600INTERVAL 601vmul(double a, double b, INTERVAL v) 602{ 603 return (hilo(a * v.hi, a * v.lo, b * v.hi, b * v.lo)); 604} 605 606int 607dcheck(INTERVAL v) 608{ 609 if (v.hi >= 0. && v.lo <= 0.) 610 { 611 printf("divisor interval contains 0.\n"); 612 return (1); 613 } 614 return (0); 615} 616 617INTERVAL 618vdiv(double a, double b, INTERVAL v) 619{ 620 return (hilo(a / v.hi, a / v.lo, b / v.hi, b / v.lo)); 621}
| 340#define YYFINAL 7 341#ifndef YYDEBUG 342#define YYDEBUG 0 343#endif 344#define YYMAXTOKEN 260 345#define YYUNDFTOKEN 266 346#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) 347#if YYDEBUG 348static const char *const calc1_name[] = { 349 350"$end",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,0,0,0, 3510,0,0,0,0,0,"'('","')'","'*'","'+'","','","'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0,0,0, 3520,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 3530,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 3540,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 3550,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 3560,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 357"error","DREG","VREG","CONST","UMINUS","$accept","line","dexp","vexp","lines", 358"illegal-symbol", 359}; 360static const char *const calc1_rule[] = { 361"$accept : line", 362"lines :", 363"lines : lines line", 364"line : dexp '\\n'", 365"line : vexp '\\n'", 366"line : DREG '=' dexp '\\n'", 367"line : VREG '=' vexp '\\n'", 368"line : error '\\n'", 369"dexp : CONST", 370"dexp : DREG", 371"dexp : dexp '+' dexp", 372"dexp : dexp '-' dexp", 373"dexp : dexp '*' dexp", 374"dexp : dexp '/' dexp", 375"dexp : '-' dexp", 376"dexp : '(' dexp ')'", 377"vexp : dexp", 378"vexp : '(' dexp ',' dexp ')'", 379"vexp : VREG", 380"vexp : vexp '+' vexp", 381"vexp : dexp '+' vexp", 382"vexp : vexp '-' vexp", 383"vexp : dexp '-' vexp", 384"vexp : vexp '*' vexp", 385"vexp : dexp '*' vexp", 386"vexp : vexp '/' vexp", 387"vexp : dexp '/' vexp", 388"vexp : '-' vexp", 389"vexp : '(' vexp ')'", 390 391}; 392#endif 393 394int yydebug; 395int yynerrs; 396 397int yyerrflag; 398int yychar; 399YYSTYPE yyval; 400YYSTYPE yylval; 401#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 402YYLTYPE yyloc; /* position returned by actions */ 403YYLTYPE yylloc; /* position from the lexer */ 404#endif 405 406#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 407#ifndef YYLLOC_DEFAULT 408#define YYLLOC_DEFAULT(loc, rhs, n) \ 409do \ 410{ \ 411 if (n == 0) \ 412 { \ 413 (loc).first_line = ((rhs)[-1]).last_line; \ 414 (loc).first_column = ((rhs)[-1]).last_column; \ 415 (loc).last_line = ((rhs)[-1]).last_line; \ 416 (loc).last_column = ((rhs)[-1]).last_column; \ 417 } \ 418 else \ 419 { \ 420 (loc).first_line = ((rhs)[ 0 ]).first_line; \ 421 (loc).first_column = ((rhs)[ 0 ]).first_column; \ 422 (loc).last_line = ((rhs)[n-1]).last_line; \ 423 (loc).last_column = ((rhs)[n-1]).last_column; \ 424 } \ 425} while (0) 426#endif /* YYLLOC_DEFAULT */ 427#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 428#if YYBTYACC 429 430#ifndef YYLVQUEUEGROWTH 431#define YYLVQUEUEGROWTH 32 432#endif 433#endif /* YYBTYACC */ 434 435/* define the initial stack-sizes */ 436#ifdef YYSTACKSIZE 437#undef YYMAXDEPTH 438#define YYMAXDEPTH YYSTACKSIZE 439#else 440#ifdef YYMAXDEPTH 441#define YYSTACKSIZE YYMAXDEPTH 442#else 443#define YYSTACKSIZE 10000 444#define YYMAXDEPTH 10000 445#endif 446#endif 447 448#ifndef YYINITSTACKSIZE 449#define YYINITSTACKSIZE 200 450#endif 451 452typedef struct { 453 unsigned stacksize; 454 short *s_base; 455 short *s_mark; 456 short *s_last; 457 YYSTYPE *l_base; 458 YYSTYPE *l_mark; 459#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 460 YYLTYPE *p_base; 461 YYLTYPE *p_mark; 462#endif 463} YYSTACKDATA; 464#if YYBTYACC 465 466struct YYParseState_s 467{ 468 struct YYParseState_s *save; /* Previously saved parser state */ 469 YYSTACKDATA yystack; /* saved parser stack */ 470 int state; /* saved parser state */ 471 int errflag; /* saved error recovery status */ 472 int lexeme; /* saved index of the conflict lexeme in the lexical queue */ 473 YYINT ctry; /* saved index in yyctable[] for this conflict */ 474}; 475typedef struct YYParseState_s YYParseState; 476#endif /* YYBTYACC */ 477/* variables for the parser stack */ 478static YYSTACKDATA yystack; 479#if YYBTYACC 480 481/* Current parser state */ 482static YYParseState *yyps = 0; 483 484/* yypath != NULL: do the full parse, starting at *yypath parser state. */ 485static YYParseState *yypath = 0; 486 487/* Base of the lexical value queue */ 488static YYSTYPE *yylvals = 0; 489 490/* Current position at lexical value queue */ 491static YYSTYPE *yylvp = 0; 492 493/* End position of lexical value queue */ 494static YYSTYPE *yylve = 0; 495 496/* The last allocated position at the lexical value queue */ 497static YYSTYPE *yylvlim = 0; 498 499#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 500/* Base of the lexical position queue */ 501static YYLTYPE *yylpsns = 0; 502 503/* Current position at lexical position queue */ 504static YYLTYPE *yylpp = 0; 505 506/* End position of lexical position queue */ 507static YYLTYPE *yylpe = 0; 508 509/* The last allocated position at the lexical position queue */ 510static YYLTYPE *yylplim = 0; 511#endif 512 513/* Current position at lexical token queue */ 514static short *yylexp = 0; 515 516static short *yylexemes = 0; 517#endif /* YYBTYACC */ 518#line 176 "calc1.y" 519 /* beginning of subroutines section */ 520 521#define BSZ 50 /* buffer size for floating point numbers */ 522 523 /* lexical analysis */ 524 525static void 526yyerror(const char *s) 527{ 528 fprintf(stderr, "%s\n", s); 529} 530 531int 532yylex(void) 533{ 534 int c; 535 536 while ((c = getchar()) == ' ') 537 { /* skip over blanks */ 538 } 539 540 if (isupper(c)) 541 { 542 yylval.ival = c - 'A'; 543 return (VREG); 544 } 545 if (islower(c)) 546 { 547 yylval.ival = c - 'a'; 548 return (DREG); 549 } 550 551 if (isdigit(c) || c == '.') 552 { 553 /* gobble up digits, points, exponents */ 554 char buf[BSZ + 1], *cp = buf; 555 int dot = 0, expr = 0; 556 557 for (; (cp - buf) < BSZ; ++cp, c = getchar()) 558 { 559 560 *cp = (char) c; 561 if (isdigit(c)) 562 continue; 563 if (c == '.') 564 { 565 if (dot++ || expr) 566 return ('.'); /* will cause syntax error */ 567 continue; 568 } 569 570 if (c == 'e') 571 { 572 if (expr++) 573 return ('e'); /* will cause syntax error */ 574 continue; 575 } 576 577 /* end of number */ 578 break; 579 } 580 *cp = '\0'; 581 582 if ((cp - buf) >= BSZ) 583 printf("constant too long: truncated\n"); 584 else 585 ungetc(c, stdin); /* push back last char read */ 586 yylval.dval = atof(buf); 587 return (CONST); 588 } 589 return (c); 590} 591 592static INTERVAL 593hilo(double a, double b, double c, double d) 594{ 595 /* returns the smallest interval containing a, b, c, and d */ 596 /* used by *, / routines */ 597 INTERVAL v; 598 599 if (a > b) 600 { 601 v.hi = a; 602 v.lo = b; 603 } 604 else 605 { 606 v.hi = b; 607 v.lo = a; 608 } 609 610 if (c > d) 611 { 612 if (c > v.hi) 613 v.hi = c; 614 if (d < v.lo) 615 v.lo = d; 616 } 617 else 618 { 619 if (d > v.hi) 620 v.hi = d; 621 if (c < v.lo) 622 v.lo = c; 623 } 624 return (v); 625} 626 627INTERVAL 628vmul(double a, double b, INTERVAL v) 629{ 630 return (hilo(a * v.hi, a * v.lo, b * v.hi, b * v.lo)); 631} 632 633int 634dcheck(INTERVAL v) 635{ 636 if (v.hi >= 0. && v.lo <= 0.) 637 { 638 printf("divisor interval contains 0.\n"); 639 return (1); 640 } 641 return (0); 642} 643 644INTERVAL 645vdiv(double a, double b, INTERVAL v) 646{ 647 return (hilo(a / v.hi, a / v.lo, b / v.hi, b / v.lo)); 648}
|