xref: /minix3/external/bsd/byacc/dist/test/yacc/calc1.tab.c (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc /*	$NetBSD: calc1.tab.c,v 1.1.1.1 2015/01/03 22:58:24 christos Exp $	*/
2*0a6a1f1dSLionel Sambuc 
3*0a6a1f1dSLionel Sambuc /* original parser id follows */
4*0a6a1f1dSLionel Sambuc /* yysccsid[] = "@(#)yaccpar	1.9 (Berkeley) 02/21/93" */
5*0a6a1f1dSLionel Sambuc /* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */
6*0a6a1f1dSLionel Sambuc 
7*0a6a1f1dSLionel Sambuc #define YYBYACC 1
8*0a6a1f1dSLionel Sambuc #define YYMAJOR 1
9*0a6a1f1dSLionel Sambuc #define YYMINOR 9
10*0a6a1f1dSLionel Sambuc #define YYCHECK "yyyymmdd"
11*0a6a1f1dSLionel Sambuc 
12*0a6a1f1dSLionel Sambuc #define YYEMPTY        (-1)
13*0a6a1f1dSLionel Sambuc #define yyclearin      (yychar = YYEMPTY)
14*0a6a1f1dSLionel Sambuc #define yyerrok        (yyerrflag = 0)
15*0a6a1f1dSLionel Sambuc #define YYRECOVERING() (yyerrflag != 0)
16*0a6a1f1dSLionel Sambuc #define YYENOMEM       (-2)
17*0a6a1f1dSLionel Sambuc #define YYEOF          0
18*0a6a1f1dSLionel Sambuc 
19*0a6a1f1dSLionel Sambuc #ifndef yyparse
20*0a6a1f1dSLionel Sambuc #define yyparse    calc1_parse
21*0a6a1f1dSLionel Sambuc #endif /* yyparse */
22*0a6a1f1dSLionel Sambuc 
23*0a6a1f1dSLionel Sambuc #ifndef yylex
24*0a6a1f1dSLionel Sambuc #define yylex      calc1_lex
25*0a6a1f1dSLionel Sambuc #endif /* yylex */
26*0a6a1f1dSLionel Sambuc 
27*0a6a1f1dSLionel Sambuc #ifndef yyerror
28*0a6a1f1dSLionel Sambuc #define yyerror    calc1_error
29*0a6a1f1dSLionel Sambuc #endif /* yyerror */
30*0a6a1f1dSLionel Sambuc 
31*0a6a1f1dSLionel Sambuc #ifndef yychar
32*0a6a1f1dSLionel Sambuc #define yychar     calc1_char
33*0a6a1f1dSLionel Sambuc #endif /* yychar */
34*0a6a1f1dSLionel Sambuc 
35*0a6a1f1dSLionel Sambuc #ifndef yyval
36*0a6a1f1dSLionel Sambuc #define yyval      calc1_val
37*0a6a1f1dSLionel Sambuc #endif /* yyval */
38*0a6a1f1dSLionel Sambuc 
39*0a6a1f1dSLionel Sambuc #ifndef yylval
40*0a6a1f1dSLionel Sambuc #define yylval     calc1_lval
41*0a6a1f1dSLionel Sambuc #endif /* yylval */
42*0a6a1f1dSLionel Sambuc 
43*0a6a1f1dSLionel Sambuc #ifndef yydebug
44*0a6a1f1dSLionel Sambuc #define yydebug    calc1_debug
45*0a6a1f1dSLionel Sambuc #endif /* yydebug */
46*0a6a1f1dSLionel Sambuc 
47*0a6a1f1dSLionel Sambuc #ifndef yynerrs
48*0a6a1f1dSLionel Sambuc #define yynerrs    calc1_nerrs
49*0a6a1f1dSLionel Sambuc #endif /* yynerrs */
50*0a6a1f1dSLionel Sambuc 
51*0a6a1f1dSLionel Sambuc #ifndef yyerrflag
52*0a6a1f1dSLionel Sambuc #define yyerrflag  calc1_errflag
53*0a6a1f1dSLionel Sambuc #endif /* yyerrflag */
54*0a6a1f1dSLionel Sambuc 
55*0a6a1f1dSLionel Sambuc #ifndef yylhs
56*0a6a1f1dSLionel Sambuc #define yylhs      calc1_lhs
57*0a6a1f1dSLionel Sambuc #endif /* yylhs */
58*0a6a1f1dSLionel Sambuc 
59*0a6a1f1dSLionel Sambuc #ifndef yylen
60*0a6a1f1dSLionel Sambuc #define yylen      calc1_len
61*0a6a1f1dSLionel Sambuc #endif /* yylen */
62*0a6a1f1dSLionel Sambuc 
63*0a6a1f1dSLionel Sambuc #ifndef yydefred
64*0a6a1f1dSLionel Sambuc #define yydefred   calc1_defred
65*0a6a1f1dSLionel Sambuc #endif /* yydefred */
66*0a6a1f1dSLionel Sambuc 
67*0a6a1f1dSLionel Sambuc #ifndef yydgoto
68*0a6a1f1dSLionel Sambuc #define yydgoto    calc1_dgoto
69*0a6a1f1dSLionel Sambuc #endif /* yydgoto */
70*0a6a1f1dSLionel Sambuc 
71*0a6a1f1dSLionel Sambuc #ifndef yysindex
72*0a6a1f1dSLionel Sambuc #define yysindex   calc1_sindex
73*0a6a1f1dSLionel Sambuc #endif /* yysindex */
74*0a6a1f1dSLionel Sambuc 
75*0a6a1f1dSLionel Sambuc #ifndef yyrindex
76*0a6a1f1dSLionel Sambuc #define yyrindex   calc1_rindex
77*0a6a1f1dSLionel Sambuc #endif /* yyrindex */
78*0a6a1f1dSLionel Sambuc 
79*0a6a1f1dSLionel Sambuc #ifndef yygindex
80*0a6a1f1dSLionel Sambuc #define yygindex   calc1_gindex
81*0a6a1f1dSLionel Sambuc #endif /* yygindex */
82*0a6a1f1dSLionel Sambuc 
83*0a6a1f1dSLionel Sambuc #ifndef yytable
84*0a6a1f1dSLionel Sambuc #define yytable    calc1_table
85*0a6a1f1dSLionel Sambuc #endif /* yytable */
86*0a6a1f1dSLionel Sambuc 
87*0a6a1f1dSLionel Sambuc #ifndef yycheck
88*0a6a1f1dSLionel Sambuc #define yycheck    calc1_check
89*0a6a1f1dSLionel Sambuc #endif /* yycheck */
90*0a6a1f1dSLionel Sambuc 
91*0a6a1f1dSLionel Sambuc #ifndef yyname
92*0a6a1f1dSLionel Sambuc #define yyname     calc1_name
93*0a6a1f1dSLionel Sambuc #endif /* yyname */
94*0a6a1f1dSLionel Sambuc 
95*0a6a1f1dSLionel Sambuc #ifndef yyrule
96*0a6a1f1dSLionel Sambuc #define yyrule     calc1_rule
97*0a6a1f1dSLionel Sambuc #endif /* yyrule */
98*0a6a1f1dSLionel Sambuc #define YYPREFIX "calc1_"
99*0a6a1f1dSLionel Sambuc 
100*0a6a1f1dSLionel Sambuc #define YYPURE 0
101*0a6a1f1dSLionel Sambuc 
102*0a6a1f1dSLionel Sambuc #line 2 "calc1.y"
103*0a6a1f1dSLionel Sambuc 
104*0a6a1f1dSLionel Sambuc /* http://dinosaur.compilertools.net/yacc/index.html */
105*0a6a1f1dSLionel Sambuc 
106*0a6a1f1dSLionel Sambuc #include <stdlib.h>
107*0a6a1f1dSLionel Sambuc #include <stdio.h>
108*0a6a1f1dSLionel Sambuc #include <ctype.h>
109*0a6a1f1dSLionel Sambuc #include <math.h>
110*0a6a1f1dSLionel Sambuc 
111*0a6a1f1dSLionel Sambuc typedef struct interval
112*0a6a1f1dSLionel Sambuc {
113*0a6a1f1dSLionel Sambuc     double lo, hi;
114*0a6a1f1dSLionel Sambuc }
115*0a6a1f1dSLionel Sambuc INTERVAL;
116*0a6a1f1dSLionel Sambuc 
117*0a6a1f1dSLionel Sambuc INTERVAL vmul(double, double, INTERVAL);
118*0a6a1f1dSLionel Sambuc INTERVAL vdiv(double, double, INTERVAL);
119*0a6a1f1dSLionel Sambuc 
120*0a6a1f1dSLionel Sambuc extern int yylex(void);
121*0a6a1f1dSLionel Sambuc static void yyerror(const char *s);
122*0a6a1f1dSLionel Sambuc 
123*0a6a1f1dSLionel Sambuc int dcheck(INTERVAL);
124*0a6a1f1dSLionel Sambuc 
125*0a6a1f1dSLionel Sambuc double dreg[26];
126*0a6a1f1dSLionel Sambuc INTERVAL vreg[26];
127*0a6a1f1dSLionel Sambuc 
128*0a6a1f1dSLionel Sambuc #line 31 "calc1.y"
129*0a6a1f1dSLionel Sambuc #ifdef YYSTYPE
130*0a6a1f1dSLionel Sambuc #undef  YYSTYPE_IS_DECLARED
131*0a6a1f1dSLionel Sambuc #define YYSTYPE_IS_DECLARED 1
132*0a6a1f1dSLionel Sambuc #endif
133*0a6a1f1dSLionel Sambuc #ifndef YYSTYPE_IS_DECLARED
134*0a6a1f1dSLionel Sambuc #define YYSTYPE_IS_DECLARED 1
135*0a6a1f1dSLionel Sambuc typedef union
136*0a6a1f1dSLionel Sambuc {
137*0a6a1f1dSLionel Sambuc 	int ival;
138*0a6a1f1dSLionel Sambuc 	double dval;
139*0a6a1f1dSLionel Sambuc 	INTERVAL vval;
140*0a6a1f1dSLionel Sambuc } YYSTYPE;
141*0a6a1f1dSLionel Sambuc #endif /* !YYSTYPE_IS_DECLARED */
142*0a6a1f1dSLionel Sambuc #line 141 "calc1.tab.c"
143*0a6a1f1dSLionel Sambuc 
144*0a6a1f1dSLionel Sambuc /* compatibility with bison */
145*0a6a1f1dSLionel Sambuc #ifdef YYPARSE_PARAM
146*0a6a1f1dSLionel Sambuc /* compatibility with FreeBSD */
147*0a6a1f1dSLionel Sambuc # ifdef YYPARSE_PARAM_TYPE
148*0a6a1f1dSLionel Sambuc #  define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
149*0a6a1f1dSLionel Sambuc # else
150*0a6a1f1dSLionel Sambuc #  define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
151*0a6a1f1dSLionel Sambuc # endif
152*0a6a1f1dSLionel Sambuc #else
153*0a6a1f1dSLionel Sambuc # define YYPARSE_DECL() yyparse(void)
154*0a6a1f1dSLionel Sambuc #endif
155*0a6a1f1dSLionel Sambuc 
156*0a6a1f1dSLionel Sambuc /* Parameters sent to lex. */
157*0a6a1f1dSLionel Sambuc #ifdef YYLEX_PARAM
158*0a6a1f1dSLionel Sambuc # define YYLEX_DECL() yylex(void *YYLEX_PARAM)
159*0a6a1f1dSLionel Sambuc # define YYLEX yylex(YYLEX_PARAM)
160*0a6a1f1dSLionel Sambuc #else
161*0a6a1f1dSLionel Sambuc # define YYLEX_DECL() yylex(void)
162*0a6a1f1dSLionel Sambuc # define YYLEX yylex()
163*0a6a1f1dSLionel Sambuc #endif
164*0a6a1f1dSLionel Sambuc 
165*0a6a1f1dSLionel Sambuc /* Parameters sent to yyerror. */
166*0a6a1f1dSLionel Sambuc #ifndef YYERROR_DECL
167*0a6a1f1dSLionel Sambuc #define YYERROR_DECL() yyerror(const char *s)
168*0a6a1f1dSLionel Sambuc #endif
169*0a6a1f1dSLionel Sambuc #ifndef YYERROR_CALL
170*0a6a1f1dSLionel Sambuc #define YYERROR_CALL(msg) yyerror(msg)
171*0a6a1f1dSLionel Sambuc #endif
172*0a6a1f1dSLionel Sambuc 
173*0a6a1f1dSLionel Sambuc extern int YYPARSE_DECL();
174*0a6a1f1dSLionel Sambuc 
175*0a6a1f1dSLionel Sambuc #define DREG 257
176*0a6a1f1dSLionel Sambuc #define VREG 258
177*0a6a1f1dSLionel Sambuc #define CONST 259
178*0a6a1f1dSLionel Sambuc #define UMINUS 260
179*0a6a1f1dSLionel Sambuc #define YYERRCODE 256
180*0a6a1f1dSLionel Sambuc typedef short YYINT;
181*0a6a1f1dSLionel Sambuc static const YYINT calc1_lhs[] = {                       -1,
182*0a6a1f1dSLionel Sambuc     3,    3,    0,    0,    0,    0,    0,    1,    1,    1,
183*0a6a1f1dSLionel Sambuc     1,    1,    1,    1,    1,    2,    2,    2,    2,    2,
184*0a6a1f1dSLionel Sambuc     2,    2,    2,    2,    2,    2,    2,    2,
185*0a6a1f1dSLionel Sambuc };
186*0a6a1f1dSLionel Sambuc static const YYINT calc1_len[] = {                        2,
187*0a6a1f1dSLionel Sambuc     0,    2,    2,    2,    4,    4,    2,    1,    1,    3,
188*0a6a1f1dSLionel Sambuc     3,    3,    3,    2,    3,    1,    5,    1,    3,    3,
189*0a6a1f1dSLionel Sambuc     3,    3,    3,    3,    3,    3,    2,    3,
190*0a6a1f1dSLionel Sambuc };
191*0a6a1f1dSLionel Sambuc static const YYINT calc1_defred[] = {                     0,
192*0a6a1f1dSLionel Sambuc     0,    0,    0,    8,    0,    0,    0,    0,    0,    7,
193*0a6a1f1dSLionel Sambuc     0,    0,    9,   18,   14,   27,    0,    0,    0,    0,
194*0a6a1f1dSLionel Sambuc     0,    0,    3,    0,    0,    0,    0,    4,    0,    0,
195*0a6a1f1dSLionel Sambuc     0,    0,    0,   15,    0,   28,    0,    0,    0,    0,
196*0a6a1f1dSLionel Sambuc    12,   24,   13,   26,    0,    0,   23,   25,   14,    0,
197*0a6a1f1dSLionel Sambuc     0,    0,    0,    0,    5,    6,    0,    0,    0,   12,
198*0a6a1f1dSLionel Sambuc    13,   17,
199*0a6a1f1dSLionel Sambuc };
200*0a6a1f1dSLionel Sambuc static const YYINT calc1_dgoto[] = {                      7,
201*0a6a1f1dSLionel Sambuc    32,    9,    0,
202*0a6a1f1dSLionel Sambuc };
203*0a6a1f1dSLionel Sambuc static const YYINT calc1_sindex[] = {                   -40,
204*0a6a1f1dSLionel Sambuc    -8,  -48,  -47,    0,  -37,  -37,    0,    2,   17,    0,
205*0a6a1f1dSLionel Sambuc   -34,  -37,    0,    0,    0,    0,  -25,   90,  -37,  -37,
206*0a6a1f1dSLionel Sambuc   -37,  -37,    0,  -37,  -37,  -37,  -37,    0,  -34,  -34,
207*0a6a1f1dSLionel Sambuc    25,  125,   31,    0,  -34,    0,  -11,   37,  -11,   37,
208*0a6a1f1dSLionel Sambuc     0,    0,    0,    0,   37,   37,    0,    0,    0,  111,
209*0a6a1f1dSLionel Sambuc   -34,  -34,  -34,  -34,    0,    0,  118,   69,   69,    0,
210*0a6a1f1dSLionel Sambuc     0,    0,
211*0a6a1f1dSLionel Sambuc };
212*0a6a1f1dSLionel Sambuc static const YYINT calc1_rindex[] = {                     0,
213*0a6a1f1dSLionel Sambuc     0,   38,   44,    0,    0,    0,    0,    0,    0,    0,
214*0a6a1f1dSLionel Sambuc     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
215*0a6a1f1dSLionel Sambuc     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
216*0a6a1f1dSLionel Sambuc     0,   -9,    0,    0,    0,    0,   51,   -3,   56,   61,
217*0a6a1f1dSLionel Sambuc     0,    0,    0,    0,   67,   72,    0,    0,    0,    0,
218*0a6a1f1dSLionel Sambuc     0,    0,    0,    0,    0,    0,    0,   78,   83,    0,
219*0a6a1f1dSLionel Sambuc     0,    0,
220*0a6a1f1dSLionel Sambuc };
221*0a6a1f1dSLionel Sambuc static const YYINT calc1_gindex[] = {                     0,
222*0a6a1f1dSLionel Sambuc     4,  124,    0,
223*0a6a1f1dSLionel Sambuc };
224*0a6a1f1dSLionel Sambuc #define YYTABLESIZE 225
225*0a6a1f1dSLionel Sambuc static const YYINT calc1_table[] = {                      6,
226*0a6a1f1dSLionel Sambuc    16,   10,    6,    8,    5,   30,   20,    5,   15,   17,
227*0a6a1f1dSLionel Sambuc    29,   23,   11,   12,   31,   34,   21,   19,   35,   20,
228*0a6a1f1dSLionel Sambuc     0,   22,   37,   39,   41,   43,   28,    0,    0,    0,
229*0a6a1f1dSLionel Sambuc    21,   16,   49,   50,   55,   22,    0,   20,   57,   20,
230*0a6a1f1dSLionel Sambuc    56,   20,    0,   21,   19,    0,   20,    9,   22,    0,
231*0a6a1f1dSLionel Sambuc     0,    0,    0,   18,   58,   59,   60,   61,   26,   24,
232*0a6a1f1dSLionel Sambuc    10,   25,    0,   27,    0,   11,   53,   51,    0,   52,
233*0a6a1f1dSLionel Sambuc    22,   54,   26,   24,    0,   25,   19,   27,   26,    9,
234*0a6a1f1dSLionel Sambuc     9,   21,    9,   27,    9,   18,   18,   10,   18,    0,
235*0a6a1f1dSLionel Sambuc    18,   10,   11,   10,   10,   10,   11,    0,   11,   11,
236*0a6a1f1dSLionel Sambuc    11,   22,    0,   22,    0,   22,    0,   19,    0,   19,
237*0a6a1f1dSLionel Sambuc    53,   19,   21,    0,   21,   54,   21,    0,   10,    0,
238*0a6a1f1dSLionel Sambuc    10,    0,   10,   11,    0,   11,    0,   11,   16,   18,
239*0a6a1f1dSLionel Sambuc    36,   26,   24,    0,   25,   33,   27,    0,    0,    0,
240*0a6a1f1dSLionel Sambuc     0,    0,   38,   40,   42,   44,    0,   45,   46,   47,
241*0a6a1f1dSLionel Sambuc    48,   34,   53,   51,    0,   52,    0,   54,   62,   53,
242*0a6a1f1dSLionel Sambuc    51,    0,   52,    0,   54,    0,   21,   19,    0,   20,
243*0a6a1f1dSLionel Sambuc     0,   22,    0,    0,    0,    0,    0,    0,    0,    0,
244*0a6a1f1dSLionel Sambuc     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
245*0a6a1f1dSLionel Sambuc     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
246*0a6a1f1dSLionel Sambuc     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
247*0a6a1f1dSLionel Sambuc     0,    0,    0,    0,    0,    1,    2,    3,    4,   13,
248*0a6a1f1dSLionel Sambuc    14,    4,   13,    0,    4,
249*0a6a1f1dSLionel Sambuc };
250*0a6a1f1dSLionel Sambuc static const YYINT calc1_check[] = {                     40,
251*0a6a1f1dSLionel Sambuc    10,   10,   40,    0,   45,   40,   10,   45,    5,    6,
252*0a6a1f1dSLionel Sambuc    45,   10,   61,   61,   11,   41,   42,   43,   44,   45,
253*0a6a1f1dSLionel Sambuc    -1,   47,   19,   20,   21,   22,   10,   -1,   -1,   -1,
254*0a6a1f1dSLionel Sambuc    42,   41,   29,   30,   10,   47,   -1,   41,   35,   43,
255*0a6a1f1dSLionel Sambuc    10,   45,   -1,   42,   43,   -1,   45,   10,   47,   -1,
256*0a6a1f1dSLionel Sambuc    -1,   -1,   -1,   10,   51,   52,   53,   54,   42,   43,
257*0a6a1f1dSLionel Sambuc    10,   45,   -1,   47,   -1,   10,   42,   43,   -1,   45,
258*0a6a1f1dSLionel Sambuc    10,   47,   42,   43,   -1,   45,   10,   47,   42,   42,
259*0a6a1f1dSLionel Sambuc    43,   10,   45,   47,   47,   42,   43,   10,   45,   -1,
260*0a6a1f1dSLionel Sambuc    47,   41,   10,   43,   44,   45,   41,   -1,   43,   44,
261*0a6a1f1dSLionel Sambuc    45,   41,   -1,   43,   -1,   45,   -1,   41,   -1,   43,
262*0a6a1f1dSLionel Sambuc    42,   45,   41,   -1,   43,   47,   45,   -1,   41,   -1,
263*0a6a1f1dSLionel Sambuc    43,   -1,   45,   41,   -1,   43,   -1,   45,    5,    6,
264*0a6a1f1dSLionel Sambuc    41,   42,   43,   -1,   45,   12,   47,   -1,   -1,   -1,
265*0a6a1f1dSLionel Sambuc    -1,   -1,   19,   20,   21,   22,   -1,   24,   25,   26,
266*0a6a1f1dSLionel Sambuc    27,   41,   42,   43,   -1,   45,   -1,   47,   41,   42,
267*0a6a1f1dSLionel Sambuc    43,   -1,   45,   -1,   47,   -1,   42,   43,   -1,   45,
268*0a6a1f1dSLionel Sambuc    -1,   47,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
269*0a6a1f1dSLionel Sambuc    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
270*0a6a1f1dSLionel Sambuc    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
271*0a6a1f1dSLionel Sambuc    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
272*0a6a1f1dSLionel Sambuc    -1,   -1,   -1,   -1,   -1,  256,  257,  258,  259,  257,
273*0a6a1f1dSLionel Sambuc   258,  259,  257,   -1,  259,
274*0a6a1f1dSLionel Sambuc };
275*0a6a1f1dSLionel Sambuc #define YYFINAL 7
276*0a6a1f1dSLionel Sambuc #ifndef YYDEBUG
277*0a6a1f1dSLionel Sambuc #define YYDEBUG 0
278*0a6a1f1dSLionel Sambuc #endif
279*0a6a1f1dSLionel Sambuc #define YYMAXTOKEN 260
280*0a6a1f1dSLionel Sambuc #define YYUNDFTOKEN 266
281*0a6a1f1dSLionel Sambuc #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
282*0a6a1f1dSLionel Sambuc #if YYDEBUG
283*0a6a1f1dSLionel Sambuc static const char *const calc1_name[] = {
284*0a6a1f1dSLionel Sambuc 
285*0a6a1f1dSLionel Sambuc "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,
286*0a6a1f1dSLionel Sambuc 0,0,0,0,0,0,0,0,0,"'('","')'","'*'","'+'","','","'-'",0,"'/'",0,0,0,0,0,0,0,0,0,
287*0a6a1f1dSLionel Sambuc 0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
288*0a6a1f1dSLionel Sambuc 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
289*0a6a1f1dSLionel Sambuc 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
290*0a6a1f1dSLionel Sambuc 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
291*0a6a1f1dSLionel Sambuc 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
292*0a6a1f1dSLionel Sambuc 0,0,"DREG","VREG","CONST","UMINUS",0,0,0,0,0,"illegal-symbol",
293*0a6a1f1dSLionel Sambuc };
294*0a6a1f1dSLionel Sambuc static const char *const calc1_rule[] = {
295*0a6a1f1dSLionel Sambuc "$accept : line",
296*0a6a1f1dSLionel Sambuc "lines :",
297*0a6a1f1dSLionel Sambuc "lines : lines line",
298*0a6a1f1dSLionel Sambuc "line : dexp '\\n'",
299*0a6a1f1dSLionel Sambuc "line : vexp '\\n'",
300*0a6a1f1dSLionel Sambuc "line : DREG '=' dexp '\\n'",
301*0a6a1f1dSLionel Sambuc "line : VREG '=' vexp '\\n'",
302*0a6a1f1dSLionel Sambuc "line : error '\\n'",
303*0a6a1f1dSLionel Sambuc "dexp : CONST",
304*0a6a1f1dSLionel Sambuc "dexp : DREG",
305*0a6a1f1dSLionel Sambuc "dexp : dexp '+' dexp",
306*0a6a1f1dSLionel Sambuc "dexp : dexp '-' dexp",
307*0a6a1f1dSLionel Sambuc "dexp : dexp '*' dexp",
308*0a6a1f1dSLionel Sambuc "dexp : dexp '/' dexp",
309*0a6a1f1dSLionel Sambuc "dexp : '-' dexp",
310*0a6a1f1dSLionel Sambuc "dexp : '(' dexp ')'",
311*0a6a1f1dSLionel Sambuc "vexp : dexp",
312*0a6a1f1dSLionel Sambuc "vexp : '(' dexp ',' dexp ')'",
313*0a6a1f1dSLionel Sambuc "vexp : VREG",
314*0a6a1f1dSLionel Sambuc "vexp : vexp '+' vexp",
315*0a6a1f1dSLionel Sambuc "vexp : dexp '+' vexp",
316*0a6a1f1dSLionel Sambuc "vexp : vexp '-' vexp",
317*0a6a1f1dSLionel Sambuc "vexp : dexp '-' vexp",
318*0a6a1f1dSLionel Sambuc "vexp : vexp '*' vexp",
319*0a6a1f1dSLionel Sambuc "vexp : dexp '*' vexp",
320*0a6a1f1dSLionel Sambuc "vexp : vexp '/' vexp",
321*0a6a1f1dSLionel Sambuc "vexp : dexp '/' vexp",
322*0a6a1f1dSLionel Sambuc "vexp : '-' vexp",
323*0a6a1f1dSLionel Sambuc "vexp : '(' vexp ')'",
324*0a6a1f1dSLionel Sambuc 
325*0a6a1f1dSLionel Sambuc };
326*0a6a1f1dSLionel Sambuc #endif
327*0a6a1f1dSLionel Sambuc 
328*0a6a1f1dSLionel Sambuc int      yydebug;
329*0a6a1f1dSLionel Sambuc int      yynerrs;
330*0a6a1f1dSLionel Sambuc 
331*0a6a1f1dSLionel Sambuc int      yyerrflag;
332*0a6a1f1dSLionel Sambuc int      yychar;
333*0a6a1f1dSLionel Sambuc YYSTYPE  yyval;
334*0a6a1f1dSLionel Sambuc YYSTYPE  yylval;
335*0a6a1f1dSLionel Sambuc 
336*0a6a1f1dSLionel Sambuc /* define the initial stack-sizes */
337*0a6a1f1dSLionel Sambuc #ifdef YYSTACKSIZE
338*0a6a1f1dSLionel Sambuc #undef YYMAXDEPTH
339*0a6a1f1dSLionel Sambuc #define YYMAXDEPTH  YYSTACKSIZE
340*0a6a1f1dSLionel Sambuc #else
341*0a6a1f1dSLionel Sambuc #ifdef YYMAXDEPTH
342*0a6a1f1dSLionel Sambuc #define YYSTACKSIZE YYMAXDEPTH
343*0a6a1f1dSLionel Sambuc #else
344*0a6a1f1dSLionel Sambuc #define YYSTACKSIZE 10000
345*0a6a1f1dSLionel Sambuc #define YYMAXDEPTH  10000
346*0a6a1f1dSLionel Sambuc #endif
347*0a6a1f1dSLionel Sambuc #endif
348*0a6a1f1dSLionel Sambuc 
349*0a6a1f1dSLionel Sambuc #define YYINITSTACKSIZE 200
350*0a6a1f1dSLionel Sambuc 
351*0a6a1f1dSLionel Sambuc typedef struct {
352*0a6a1f1dSLionel Sambuc     unsigned stacksize;
353*0a6a1f1dSLionel Sambuc     YYINT    *s_base;
354*0a6a1f1dSLionel Sambuc     YYINT    *s_mark;
355*0a6a1f1dSLionel Sambuc     YYINT    *s_last;
356*0a6a1f1dSLionel Sambuc     YYSTYPE  *l_base;
357*0a6a1f1dSLionel Sambuc     YYSTYPE  *l_mark;
358*0a6a1f1dSLionel Sambuc } YYSTACKDATA;
359*0a6a1f1dSLionel Sambuc /* variables for the parser stack */
360*0a6a1f1dSLionel Sambuc static YYSTACKDATA yystack;
361*0a6a1f1dSLionel Sambuc #line 176 "calc1.y"
362*0a6a1f1dSLionel Sambuc 	/* beginning of subroutines section */
363*0a6a1f1dSLionel Sambuc 
364*0a6a1f1dSLionel Sambuc #define BSZ 50			/* buffer size for floating point numbers */
365*0a6a1f1dSLionel Sambuc 
366*0a6a1f1dSLionel Sambuc 	/* lexical analysis */
367*0a6a1f1dSLionel Sambuc 
368*0a6a1f1dSLionel Sambuc static void
yyerror(const char * s)369*0a6a1f1dSLionel Sambuc yyerror(const char *s)
370*0a6a1f1dSLionel Sambuc {
371*0a6a1f1dSLionel Sambuc     fprintf(stderr, "%s\n", s);
372*0a6a1f1dSLionel Sambuc }
373*0a6a1f1dSLionel Sambuc 
374*0a6a1f1dSLionel Sambuc int
yylex(void)375*0a6a1f1dSLionel Sambuc yylex(void)
376*0a6a1f1dSLionel Sambuc {
377*0a6a1f1dSLionel Sambuc     int c;
378*0a6a1f1dSLionel Sambuc 
379*0a6a1f1dSLionel Sambuc     while ((c = getchar()) == ' ')
380*0a6a1f1dSLionel Sambuc     {				/* skip over blanks */
381*0a6a1f1dSLionel Sambuc     }
382*0a6a1f1dSLionel Sambuc 
383*0a6a1f1dSLionel Sambuc     if (isupper(c))
384*0a6a1f1dSLionel Sambuc     {
385*0a6a1f1dSLionel Sambuc 	yylval.ival = c - 'A';
386*0a6a1f1dSLionel Sambuc 	return (VREG);
387*0a6a1f1dSLionel Sambuc     }
388*0a6a1f1dSLionel Sambuc     if (islower(c))
389*0a6a1f1dSLionel Sambuc     {
390*0a6a1f1dSLionel Sambuc 	yylval.ival = c - 'a';
391*0a6a1f1dSLionel Sambuc 	return (DREG);
392*0a6a1f1dSLionel Sambuc     }
393*0a6a1f1dSLionel Sambuc 
394*0a6a1f1dSLionel Sambuc     if (isdigit(c) || c == '.')
395*0a6a1f1dSLionel Sambuc     {
396*0a6a1f1dSLionel Sambuc 	/* gobble up digits, points, exponents */
397*0a6a1f1dSLionel Sambuc 	char buf[BSZ + 1], *cp = buf;
398*0a6a1f1dSLionel Sambuc 	int dot = 0, expr = 0;
399*0a6a1f1dSLionel Sambuc 
400*0a6a1f1dSLionel Sambuc 	for (; (cp - buf) < BSZ; ++cp, c = getchar())
401*0a6a1f1dSLionel Sambuc 	{
402*0a6a1f1dSLionel Sambuc 
403*0a6a1f1dSLionel Sambuc 	    *cp = (char) c;
404*0a6a1f1dSLionel Sambuc 	    if (isdigit(c))
405*0a6a1f1dSLionel Sambuc 		continue;
406*0a6a1f1dSLionel Sambuc 	    if (c == '.')
407*0a6a1f1dSLionel Sambuc 	    {
408*0a6a1f1dSLionel Sambuc 		if (dot++ || expr)
409*0a6a1f1dSLionel Sambuc 		    return ('.');	/* will cause syntax error */
410*0a6a1f1dSLionel Sambuc 		continue;
411*0a6a1f1dSLionel Sambuc 	    }
412*0a6a1f1dSLionel Sambuc 
413*0a6a1f1dSLionel Sambuc 	    if (c == 'e')
414*0a6a1f1dSLionel Sambuc 	    {
415*0a6a1f1dSLionel Sambuc 		if (expr++)
416*0a6a1f1dSLionel Sambuc 		    return ('e');	/*  will  cause  syntax  error  */
417*0a6a1f1dSLionel Sambuc 		continue;
418*0a6a1f1dSLionel Sambuc 	    }
419*0a6a1f1dSLionel Sambuc 
420*0a6a1f1dSLionel Sambuc 	    /*  end  of  number  */
421*0a6a1f1dSLionel Sambuc 	    break;
422*0a6a1f1dSLionel Sambuc 	}
423*0a6a1f1dSLionel Sambuc 	*cp = '\0';
424*0a6a1f1dSLionel Sambuc 
425*0a6a1f1dSLionel Sambuc 	if ((cp - buf) >= BSZ)
426*0a6a1f1dSLionel Sambuc 	    printf("constant  too  long:  truncated\n");
427*0a6a1f1dSLionel Sambuc 	else
428*0a6a1f1dSLionel Sambuc 	    ungetc(c, stdin);	/*  push  back  last  char  read  */
429*0a6a1f1dSLionel Sambuc 	yylval.dval = atof(buf);
430*0a6a1f1dSLionel Sambuc 	return (CONST);
431*0a6a1f1dSLionel Sambuc     }
432*0a6a1f1dSLionel Sambuc     return (c);
433*0a6a1f1dSLionel Sambuc }
434*0a6a1f1dSLionel Sambuc 
435*0a6a1f1dSLionel Sambuc static INTERVAL
hilo(double a,double b,double c,double d)436*0a6a1f1dSLionel Sambuc hilo(double a, double b, double c, double d)
437*0a6a1f1dSLionel Sambuc {
438*0a6a1f1dSLionel Sambuc     /*  returns  the  smallest  interval  containing  a,  b,  c,  and  d  */
439*0a6a1f1dSLionel Sambuc     /*  used  by  *,  /  routines  */
440*0a6a1f1dSLionel Sambuc     INTERVAL v;
441*0a6a1f1dSLionel Sambuc 
442*0a6a1f1dSLionel Sambuc     if (a > b)
443*0a6a1f1dSLionel Sambuc     {
444*0a6a1f1dSLionel Sambuc 	v.hi = a;
445*0a6a1f1dSLionel Sambuc 	v.lo = b;
446*0a6a1f1dSLionel Sambuc     }
447*0a6a1f1dSLionel Sambuc     else
448*0a6a1f1dSLionel Sambuc     {
449*0a6a1f1dSLionel Sambuc 	v.hi = b;
450*0a6a1f1dSLionel Sambuc 	v.lo = a;
451*0a6a1f1dSLionel Sambuc     }
452*0a6a1f1dSLionel Sambuc 
453*0a6a1f1dSLionel Sambuc     if (c > d)
454*0a6a1f1dSLionel Sambuc     {
455*0a6a1f1dSLionel Sambuc 	if (c > v.hi)
456*0a6a1f1dSLionel Sambuc 	    v.hi = c;
457*0a6a1f1dSLionel Sambuc 	if (d < v.lo)
458*0a6a1f1dSLionel Sambuc 	    v.lo = d;
459*0a6a1f1dSLionel Sambuc     }
460*0a6a1f1dSLionel Sambuc     else
461*0a6a1f1dSLionel Sambuc     {
462*0a6a1f1dSLionel Sambuc 	if (d > v.hi)
463*0a6a1f1dSLionel Sambuc 	    v.hi = d;
464*0a6a1f1dSLionel Sambuc 	if (c < v.lo)
465*0a6a1f1dSLionel Sambuc 	    v.lo = c;
466*0a6a1f1dSLionel Sambuc     }
467*0a6a1f1dSLionel Sambuc     return (v);
468*0a6a1f1dSLionel Sambuc }
469*0a6a1f1dSLionel Sambuc 
470*0a6a1f1dSLionel Sambuc INTERVAL
vmul(double a,double b,INTERVAL v)471*0a6a1f1dSLionel Sambuc vmul(double a, double b, INTERVAL v)
472*0a6a1f1dSLionel Sambuc {
473*0a6a1f1dSLionel Sambuc     return (hilo(a * v.hi, a * v.lo, b * v.hi, b * v.lo));
474*0a6a1f1dSLionel Sambuc }
475*0a6a1f1dSLionel Sambuc 
476*0a6a1f1dSLionel Sambuc int
dcheck(INTERVAL v)477*0a6a1f1dSLionel Sambuc dcheck(INTERVAL v)
478*0a6a1f1dSLionel Sambuc {
479*0a6a1f1dSLionel Sambuc     if (v.hi >= 0. && v.lo <= 0.)
480*0a6a1f1dSLionel Sambuc     {
481*0a6a1f1dSLionel Sambuc 	printf("divisor  interval  contains  0.\n");
482*0a6a1f1dSLionel Sambuc 	return (1);
483*0a6a1f1dSLionel Sambuc     }
484*0a6a1f1dSLionel Sambuc     return (0);
485*0a6a1f1dSLionel Sambuc }
486*0a6a1f1dSLionel Sambuc 
487*0a6a1f1dSLionel Sambuc INTERVAL
vdiv(double a,double b,INTERVAL v)488*0a6a1f1dSLionel Sambuc vdiv(double a, double b, INTERVAL v)
489*0a6a1f1dSLionel Sambuc {
490*0a6a1f1dSLionel Sambuc     return (hilo(a / v.hi, a / v.lo, b / v.hi, b / v.lo));
491*0a6a1f1dSLionel Sambuc }
492*0a6a1f1dSLionel Sambuc #line 491 "calc1.tab.c"
493*0a6a1f1dSLionel Sambuc 
494*0a6a1f1dSLionel Sambuc #if YYDEBUG
495*0a6a1f1dSLionel Sambuc #include <stdio.h>		/* needed for printf */
496*0a6a1f1dSLionel Sambuc #endif
497*0a6a1f1dSLionel Sambuc 
498*0a6a1f1dSLionel Sambuc #include <stdlib.h>	/* needed for malloc, etc */
499*0a6a1f1dSLionel Sambuc #include <string.h>	/* needed for memset */
500*0a6a1f1dSLionel Sambuc 
501*0a6a1f1dSLionel Sambuc /* allocate initial stack or double stack size, up to YYMAXDEPTH */
yygrowstack(YYSTACKDATA * data)502*0a6a1f1dSLionel Sambuc static int yygrowstack(YYSTACKDATA *data)
503*0a6a1f1dSLionel Sambuc {
504*0a6a1f1dSLionel Sambuc     int i;
505*0a6a1f1dSLionel Sambuc     unsigned newsize;
506*0a6a1f1dSLionel Sambuc     YYINT *newss;
507*0a6a1f1dSLionel Sambuc     YYSTYPE *newvs;
508*0a6a1f1dSLionel Sambuc 
509*0a6a1f1dSLionel Sambuc     if ((newsize = data->stacksize) == 0)
510*0a6a1f1dSLionel Sambuc         newsize = YYINITSTACKSIZE;
511*0a6a1f1dSLionel Sambuc     else if (newsize >= YYMAXDEPTH)
512*0a6a1f1dSLionel Sambuc         return YYENOMEM;
513*0a6a1f1dSLionel Sambuc     else if ((newsize *= 2) > YYMAXDEPTH)
514*0a6a1f1dSLionel Sambuc         newsize = YYMAXDEPTH;
515*0a6a1f1dSLionel Sambuc 
516*0a6a1f1dSLionel Sambuc     i = (int) (data->s_mark - data->s_base);
517*0a6a1f1dSLionel Sambuc     newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
518*0a6a1f1dSLionel Sambuc     if (newss == 0)
519*0a6a1f1dSLionel Sambuc         return YYENOMEM;
520*0a6a1f1dSLionel Sambuc 
521*0a6a1f1dSLionel Sambuc     data->s_base = newss;
522*0a6a1f1dSLionel Sambuc     data->s_mark = newss + i;
523*0a6a1f1dSLionel Sambuc 
524*0a6a1f1dSLionel Sambuc     newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
525*0a6a1f1dSLionel Sambuc     if (newvs == 0)
526*0a6a1f1dSLionel Sambuc         return YYENOMEM;
527*0a6a1f1dSLionel Sambuc 
528*0a6a1f1dSLionel Sambuc     data->l_base = newvs;
529*0a6a1f1dSLionel Sambuc     data->l_mark = newvs + i;
530*0a6a1f1dSLionel Sambuc 
531*0a6a1f1dSLionel Sambuc     data->stacksize = newsize;
532*0a6a1f1dSLionel Sambuc     data->s_last = data->s_base + newsize - 1;
533*0a6a1f1dSLionel Sambuc     return 0;
534*0a6a1f1dSLionel Sambuc }
535*0a6a1f1dSLionel Sambuc 
536*0a6a1f1dSLionel Sambuc #if YYPURE || defined(YY_NO_LEAKS)
yyfreestack(YYSTACKDATA * data)537*0a6a1f1dSLionel Sambuc static void yyfreestack(YYSTACKDATA *data)
538*0a6a1f1dSLionel Sambuc {
539*0a6a1f1dSLionel Sambuc     free(data->s_base);
540*0a6a1f1dSLionel Sambuc     free(data->l_base);
541*0a6a1f1dSLionel Sambuc     memset(data, 0, sizeof(*data));
542*0a6a1f1dSLionel Sambuc }
543*0a6a1f1dSLionel Sambuc #else
544*0a6a1f1dSLionel Sambuc #define yyfreestack(data) /* nothing */
545*0a6a1f1dSLionel Sambuc #endif
546*0a6a1f1dSLionel Sambuc 
547*0a6a1f1dSLionel Sambuc #define YYABORT  goto yyabort
548*0a6a1f1dSLionel Sambuc #define YYREJECT goto yyabort
549*0a6a1f1dSLionel Sambuc #define YYACCEPT goto yyaccept
550*0a6a1f1dSLionel Sambuc #define YYERROR  goto yyerrlab
551*0a6a1f1dSLionel Sambuc 
552*0a6a1f1dSLionel Sambuc int
YYPARSE_DECL()553*0a6a1f1dSLionel Sambuc YYPARSE_DECL()
554*0a6a1f1dSLionel Sambuc {
555*0a6a1f1dSLionel Sambuc     int yym, yyn, yystate;
556*0a6a1f1dSLionel Sambuc #if YYDEBUG
557*0a6a1f1dSLionel Sambuc     const char *yys;
558*0a6a1f1dSLionel Sambuc 
559*0a6a1f1dSLionel Sambuc     if ((yys = getenv("YYDEBUG")) != 0)
560*0a6a1f1dSLionel Sambuc     {
561*0a6a1f1dSLionel Sambuc         yyn = *yys;
562*0a6a1f1dSLionel Sambuc         if (yyn >= '0' && yyn <= '9')
563*0a6a1f1dSLionel Sambuc             yydebug = yyn - '0';
564*0a6a1f1dSLionel Sambuc     }
565*0a6a1f1dSLionel Sambuc #endif
566*0a6a1f1dSLionel Sambuc 
567*0a6a1f1dSLionel Sambuc     yynerrs = 0;
568*0a6a1f1dSLionel Sambuc     yyerrflag = 0;
569*0a6a1f1dSLionel Sambuc     yychar = YYEMPTY;
570*0a6a1f1dSLionel Sambuc     yystate = 0;
571*0a6a1f1dSLionel Sambuc 
572*0a6a1f1dSLionel Sambuc #if YYPURE
573*0a6a1f1dSLionel Sambuc     memset(&yystack, 0, sizeof(yystack));
574*0a6a1f1dSLionel Sambuc #endif
575*0a6a1f1dSLionel Sambuc 
576*0a6a1f1dSLionel Sambuc     if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
577*0a6a1f1dSLionel Sambuc     yystack.s_mark = yystack.s_base;
578*0a6a1f1dSLionel Sambuc     yystack.l_mark = yystack.l_base;
579*0a6a1f1dSLionel Sambuc     yystate = 0;
580*0a6a1f1dSLionel Sambuc     *yystack.s_mark = 0;
581*0a6a1f1dSLionel Sambuc 
582*0a6a1f1dSLionel Sambuc yyloop:
583*0a6a1f1dSLionel Sambuc     if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
584*0a6a1f1dSLionel Sambuc     if (yychar < 0)
585*0a6a1f1dSLionel Sambuc     {
586*0a6a1f1dSLionel Sambuc         if ((yychar = YYLEX) < 0) yychar = YYEOF;
587*0a6a1f1dSLionel Sambuc #if YYDEBUG
588*0a6a1f1dSLionel Sambuc         if (yydebug)
589*0a6a1f1dSLionel Sambuc         {
590*0a6a1f1dSLionel Sambuc             yys = yyname[YYTRANSLATE(yychar)];
591*0a6a1f1dSLionel Sambuc             printf("%sdebug: state %d, reading %d (%s)\n",
592*0a6a1f1dSLionel Sambuc                     YYPREFIX, yystate, yychar, yys);
593*0a6a1f1dSLionel Sambuc         }
594*0a6a1f1dSLionel Sambuc #endif
595*0a6a1f1dSLionel Sambuc     }
596*0a6a1f1dSLionel Sambuc     if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
597*0a6a1f1dSLionel Sambuc             yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
598*0a6a1f1dSLionel Sambuc     {
599*0a6a1f1dSLionel Sambuc #if YYDEBUG
600*0a6a1f1dSLionel Sambuc         if (yydebug)
601*0a6a1f1dSLionel Sambuc             printf("%sdebug: state %d, shifting to state %d\n",
602*0a6a1f1dSLionel Sambuc                     YYPREFIX, yystate, yytable[yyn]);
603*0a6a1f1dSLionel Sambuc #endif
604*0a6a1f1dSLionel Sambuc         if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
605*0a6a1f1dSLionel Sambuc         {
606*0a6a1f1dSLionel Sambuc             goto yyoverflow;
607*0a6a1f1dSLionel Sambuc         }
608*0a6a1f1dSLionel Sambuc         yystate = yytable[yyn];
609*0a6a1f1dSLionel Sambuc         *++yystack.s_mark = yytable[yyn];
610*0a6a1f1dSLionel Sambuc         *++yystack.l_mark = yylval;
611*0a6a1f1dSLionel Sambuc         yychar = YYEMPTY;
612*0a6a1f1dSLionel Sambuc         if (yyerrflag > 0)  --yyerrflag;
613*0a6a1f1dSLionel Sambuc         goto yyloop;
614*0a6a1f1dSLionel Sambuc     }
615*0a6a1f1dSLionel Sambuc     if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
616*0a6a1f1dSLionel Sambuc             yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
617*0a6a1f1dSLionel Sambuc     {
618*0a6a1f1dSLionel Sambuc         yyn = yytable[yyn];
619*0a6a1f1dSLionel Sambuc         goto yyreduce;
620*0a6a1f1dSLionel Sambuc     }
621*0a6a1f1dSLionel Sambuc     if (yyerrflag) goto yyinrecovery;
622*0a6a1f1dSLionel Sambuc 
623*0a6a1f1dSLionel Sambuc     YYERROR_CALL("syntax error");
624*0a6a1f1dSLionel Sambuc 
625*0a6a1f1dSLionel Sambuc     goto yyerrlab;
626*0a6a1f1dSLionel Sambuc 
627*0a6a1f1dSLionel Sambuc yyerrlab:
628*0a6a1f1dSLionel Sambuc     ++yynerrs;
629*0a6a1f1dSLionel Sambuc 
630*0a6a1f1dSLionel Sambuc yyinrecovery:
631*0a6a1f1dSLionel Sambuc     if (yyerrflag < 3)
632*0a6a1f1dSLionel Sambuc     {
633*0a6a1f1dSLionel Sambuc         yyerrflag = 3;
634*0a6a1f1dSLionel Sambuc         for (;;)
635*0a6a1f1dSLionel Sambuc         {
636*0a6a1f1dSLionel Sambuc             if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
637*0a6a1f1dSLionel Sambuc                     yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
638*0a6a1f1dSLionel Sambuc             {
639*0a6a1f1dSLionel Sambuc #if YYDEBUG
640*0a6a1f1dSLionel Sambuc                 if (yydebug)
641*0a6a1f1dSLionel Sambuc                     printf("%sdebug: state %d, error recovery shifting\
642*0a6a1f1dSLionel Sambuc  to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
643*0a6a1f1dSLionel Sambuc #endif
644*0a6a1f1dSLionel Sambuc                 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
645*0a6a1f1dSLionel Sambuc                 {
646*0a6a1f1dSLionel Sambuc                     goto yyoverflow;
647*0a6a1f1dSLionel Sambuc                 }
648*0a6a1f1dSLionel Sambuc                 yystate = yytable[yyn];
649*0a6a1f1dSLionel Sambuc                 *++yystack.s_mark = yytable[yyn];
650*0a6a1f1dSLionel Sambuc                 *++yystack.l_mark = yylval;
651*0a6a1f1dSLionel Sambuc                 goto yyloop;
652*0a6a1f1dSLionel Sambuc             }
653*0a6a1f1dSLionel Sambuc             else
654*0a6a1f1dSLionel Sambuc             {
655*0a6a1f1dSLionel Sambuc #if YYDEBUG
656*0a6a1f1dSLionel Sambuc                 if (yydebug)
657*0a6a1f1dSLionel Sambuc                     printf("%sdebug: error recovery discarding state %d\n",
658*0a6a1f1dSLionel Sambuc                             YYPREFIX, *yystack.s_mark);
659*0a6a1f1dSLionel Sambuc #endif
660*0a6a1f1dSLionel Sambuc                 if (yystack.s_mark <= yystack.s_base) goto yyabort;
661*0a6a1f1dSLionel Sambuc                 --yystack.s_mark;
662*0a6a1f1dSLionel Sambuc                 --yystack.l_mark;
663*0a6a1f1dSLionel Sambuc             }
664*0a6a1f1dSLionel Sambuc         }
665*0a6a1f1dSLionel Sambuc     }
666*0a6a1f1dSLionel Sambuc     else
667*0a6a1f1dSLionel Sambuc     {
668*0a6a1f1dSLionel Sambuc         if (yychar == YYEOF) goto yyabort;
669*0a6a1f1dSLionel Sambuc #if YYDEBUG
670*0a6a1f1dSLionel Sambuc         if (yydebug)
671*0a6a1f1dSLionel Sambuc         {
672*0a6a1f1dSLionel Sambuc             yys = yyname[YYTRANSLATE(yychar)];
673*0a6a1f1dSLionel Sambuc             printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
674*0a6a1f1dSLionel Sambuc                     YYPREFIX, yystate, yychar, yys);
675*0a6a1f1dSLionel Sambuc         }
676*0a6a1f1dSLionel Sambuc #endif
677*0a6a1f1dSLionel Sambuc         yychar = YYEMPTY;
678*0a6a1f1dSLionel Sambuc         goto yyloop;
679*0a6a1f1dSLionel Sambuc     }
680*0a6a1f1dSLionel Sambuc 
681*0a6a1f1dSLionel Sambuc yyreduce:
682*0a6a1f1dSLionel Sambuc #if YYDEBUG
683*0a6a1f1dSLionel Sambuc     if (yydebug)
684*0a6a1f1dSLionel Sambuc         printf("%sdebug: state %d, reducing by rule %d (%s)\n",
685*0a6a1f1dSLionel Sambuc                 YYPREFIX, yystate, yyn, yyrule[yyn]);
686*0a6a1f1dSLionel Sambuc #endif
687*0a6a1f1dSLionel Sambuc     yym = yylen[yyn];
688*0a6a1f1dSLionel Sambuc     if (yym)
689*0a6a1f1dSLionel Sambuc         yyval = yystack.l_mark[1-yym];
690*0a6a1f1dSLionel Sambuc     else
691*0a6a1f1dSLionel Sambuc         memset(&yyval, 0, sizeof yyval);
692*0a6a1f1dSLionel Sambuc     switch (yyn)
693*0a6a1f1dSLionel Sambuc     {
694*0a6a1f1dSLionel Sambuc case 3:
695*0a6a1f1dSLionel Sambuc #line 57 "calc1.y"
696*0a6a1f1dSLionel Sambuc 	{
697*0a6a1f1dSLionel Sambuc 		(void) printf("%15.8f\n", yystack.l_mark[-1].dval);
698*0a6a1f1dSLionel Sambuc 	}
699*0a6a1f1dSLionel Sambuc break;
700*0a6a1f1dSLionel Sambuc case 4:
701*0a6a1f1dSLionel Sambuc #line 61 "calc1.y"
702*0a6a1f1dSLionel Sambuc 	{
703*0a6a1f1dSLionel Sambuc 		(void) printf("(%15.8f, %15.8f)\n", yystack.l_mark[-1].vval.lo, yystack.l_mark[-1].vval.hi);
704*0a6a1f1dSLionel Sambuc 	}
705*0a6a1f1dSLionel Sambuc break;
706*0a6a1f1dSLionel Sambuc case 5:
707*0a6a1f1dSLionel Sambuc #line 65 "calc1.y"
708*0a6a1f1dSLionel Sambuc 	{
709*0a6a1f1dSLionel Sambuc 		dreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].dval;
710*0a6a1f1dSLionel Sambuc 	}
711*0a6a1f1dSLionel Sambuc break;
712*0a6a1f1dSLionel Sambuc case 6:
713*0a6a1f1dSLionel Sambuc #line 69 "calc1.y"
714*0a6a1f1dSLionel Sambuc 	{
715*0a6a1f1dSLionel Sambuc 		vreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].vval;
716*0a6a1f1dSLionel Sambuc 	}
717*0a6a1f1dSLionel Sambuc break;
718*0a6a1f1dSLionel Sambuc case 7:
719*0a6a1f1dSLionel Sambuc #line 73 "calc1.y"
720*0a6a1f1dSLionel Sambuc 	{
721*0a6a1f1dSLionel Sambuc 		yyerrok;
722*0a6a1f1dSLionel Sambuc 	}
723*0a6a1f1dSLionel Sambuc break;
724*0a6a1f1dSLionel Sambuc case 9:
725*0a6a1f1dSLionel Sambuc #line 80 "calc1.y"
726*0a6a1f1dSLionel Sambuc 	{
727*0a6a1f1dSLionel Sambuc 		yyval.dval = dreg[yystack.l_mark[0].ival];
728*0a6a1f1dSLionel Sambuc 	}
729*0a6a1f1dSLionel Sambuc break;
730*0a6a1f1dSLionel Sambuc case 10:
731*0a6a1f1dSLionel Sambuc #line 84 "calc1.y"
732*0a6a1f1dSLionel Sambuc 	{
733*0a6a1f1dSLionel Sambuc 		yyval.dval = yystack.l_mark[-2].dval + yystack.l_mark[0].dval;
734*0a6a1f1dSLionel Sambuc 	}
735*0a6a1f1dSLionel Sambuc break;
736*0a6a1f1dSLionel Sambuc case 11:
737*0a6a1f1dSLionel Sambuc #line 88 "calc1.y"
738*0a6a1f1dSLionel Sambuc 	{
739*0a6a1f1dSLionel Sambuc 		yyval.dval = yystack.l_mark[-2].dval - yystack.l_mark[0].dval;
740*0a6a1f1dSLionel Sambuc 	}
741*0a6a1f1dSLionel Sambuc break;
742*0a6a1f1dSLionel Sambuc case 12:
743*0a6a1f1dSLionel Sambuc #line 92 "calc1.y"
744*0a6a1f1dSLionel Sambuc 	{
745*0a6a1f1dSLionel Sambuc 		yyval.dval = yystack.l_mark[-2].dval * yystack.l_mark[0].dval;
746*0a6a1f1dSLionel Sambuc 	}
747*0a6a1f1dSLionel Sambuc break;
748*0a6a1f1dSLionel Sambuc case 13:
749*0a6a1f1dSLionel Sambuc #line 96 "calc1.y"
750*0a6a1f1dSLionel Sambuc 	{
751*0a6a1f1dSLionel Sambuc 		yyval.dval = yystack.l_mark[-2].dval / yystack.l_mark[0].dval;
752*0a6a1f1dSLionel Sambuc 	}
753*0a6a1f1dSLionel Sambuc break;
754*0a6a1f1dSLionel Sambuc case 14:
755*0a6a1f1dSLionel Sambuc #line 100 "calc1.y"
756*0a6a1f1dSLionel Sambuc 	{
757*0a6a1f1dSLionel Sambuc 		yyval.dval = -yystack.l_mark[0].dval;
758*0a6a1f1dSLionel Sambuc 	}
759*0a6a1f1dSLionel Sambuc break;
760*0a6a1f1dSLionel Sambuc case 15:
761*0a6a1f1dSLionel Sambuc #line 104 "calc1.y"
762*0a6a1f1dSLionel Sambuc 	{
763*0a6a1f1dSLionel Sambuc 		yyval.dval = yystack.l_mark[-1].dval;
764*0a6a1f1dSLionel Sambuc 	}
765*0a6a1f1dSLionel Sambuc break;
766*0a6a1f1dSLionel Sambuc case 16:
767*0a6a1f1dSLionel Sambuc #line 110 "calc1.y"
768*0a6a1f1dSLionel Sambuc 	{
769*0a6a1f1dSLionel Sambuc 		yyval.vval.hi = yyval.vval.lo = yystack.l_mark[0].dval;
770*0a6a1f1dSLionel Sambuc 	}
771*0a6a1f1dSLionel Sambuc break;
772*0a6a1f1dSLionel Sambuc case 17:
773*0a6a1f1dSLionel Sambuc #line 114 "calc1.y"
774*0a6a1f1dSLionel Sambuc 	{
775*0a6a1f1dSLionel Sambuc 		yyval.vval.lo = yystack.l_mark[-3].dval;
776*0a6a1f1dSLionel Sambuc 		yyval.vval.hi = yystack.l_mark[-1].dval;
777*0a6a1f1dSLionel Sambuc 		if ( yyval.vval.lo > yyval.vval.hi )
778*0a6a1f1dSLionel Sambuc 		{
779*0a6a1f1dSLionel Sambuc 			(void) printf("interval out of order\n");
780*0a6a1f1dSLionel Sambuc 			YYERROR;
781*0a6a1f1dSLionel Sambuc 		}
782*0a6a1f1dSLionel Sambuc 	}
783*0a6a1f1dSLionel Sambuc break;
784*0a6a1f1dSLionel Sambuc case 18:
785*0a6a1f1dSLionel Sambuc #line 124 "calc1.y"
786*0a6a1f1dSLionel Sambuc 	{
787*0a6a1f1dSLionel Sambuc 		yyval.vval = vreg[yystack.l_mark[0].ival];
788*0a6a1f1dSLionel Sambuc 	}
789*0a6a1f1dSLionel Sambuc break;
790*0a6a1f1dSLionel Sambuc case 19:
791*0a6a1f1dSLionel Sambuc #line 128 "calc1.y"
792*0a6a1f1dSLionel Sambuc 	{
793*0a6a1f1dSLionel Sambuc 		yyval.vval.hi = yystack.l_mark[-2].vval.hi + yystack.l_mark[0].vval.hi;
794*0a6a1f1dSLionel Sambuc 		yyval.vval.lo = yystack.l_mark[-2].vval.lo + yystack.l_mark[0].vval.lo;
795*0a6a1f1dSLionel Sambuc 	}
796*0a6a1f1dSLionel Sambuc break;
797*0a6a1f1dSLionel Sambuc case 20:
798*0a6a1f1dSLionel Sambuc #line 133 "calc1.y"
799*0a6a1f1dSLionel Sambuc 	{
800*0a6a1f1dSLionel Sambuc 		yyval.vval.hi = yystack.l_mark[-2].dval + yystack.l_mark[0].vval.hi;
801*0a6a1f1dSLionel Sambuc 		yyval.vval.lo = yystack.l_mark[-2].dval + yystack.l_mark[0].vval.lo;
802*0a6a1f1dSLionel Sambuc 	}
803*0a6a1f1dSLionel Sambuc break;
804*0a6a1f1dSLionel Sambuc case 21:
805*0a6a1f1dSLionel Sambuc #line 138 "calc1.y"
806*0a6a1f1dSLionel Sambuc 	{
807*0a6a1f1dSLionel Sambuc 		yyval.vval.hi = yystack.l_mark[-2].vval.hi - yystack.l_mark[0].vval.lo;
808*0a6a1f1dSLionel Sambuc 		yyval.vval.lo = yystack.l_mark[-2].vval.lo - yystack.l_mark[0].vval.hi;
809*0a6a1f1dSLionel Sambuc 	}
810*0a6a1f1dSLionel Sambuc break;
811*0a6a1f1dSLionel Sambuc case 22:
812*0a6a1f1dSLionel Sambuc #line 143 "calc1.y"
813*0a6a1f1dSLionel Sambuc 	{
814*0a6a1f1dSLionel Sambuc 		yyval.vval.hi = yystack.l_mark[-2].dval - yystack.l_mark[0].vval.lo;
815*0a6a1f1dSLionel Sambuc 		yyval.vval.lo = yystack.l_mark[-2].dval - yystack.l_mark[0].vval.hi;
816*0a6a1f1dSLionel Sambuc 	}
817*0a6a1f1dSLionel Sambuc break;
818*0a6a1f1dSLionel Sambuc case 23:
819*0a6a1f1dSLionel Sambuc #line 148 "calc1.y"
820*0a6a1f1dSLionel Sambuc 	{
821*0a6a1f1dSLionel Sambuc 		yyval.vval = vmul( yystack.l_mark[-2].vval.lo, yystack.l_mark[-2].vval.hi, yystack.l_mark[0].vval );
822*0a6a1f1dSLionel Sambuc 	}
823*0a6a1f1dSLionel Sambuc break;
824*0a6a1f1dSLionel Sambuc case 24:
825*0a6a1f1dSLionel Sambuc #line 152 "calc1.y"
826*0a6a1f1dSLionel Sambuc 	{
827*0a6a1f1dSLionel Sambuc 		yyval.vval = vmul (yystack.l_mark[-2].dval, yystack.l_mark[-2].dval, yystack.l_mark[0].vval );
828*0a6a1f1dSLionel Sambuc 	}
829*0a6a1f1dSLionel Sambuc break;
830*0a6a1f1dSLionel Sambuc case 25:
831*0a6a1f1dSLionel Sambuc #line 156 "calc1.y"
832*0a6a1f1dSLionel Sambuc 	{
833*0a6a1f1dSLionel Sambuc 		if (dcheck(yystack.l_mark[0].vval)) YYERROR;
834*0a6a1f1dSLionel Sambuc 		yyval.vval = vdiv ( yystack.l_mark[-2].vval.lo, yystack.l_mark[-2].vval.hi, yystack.l_mark[0].vval );
835*0a6a1f1dSLionel Sambuc 	}
836*0a6a1f1dSLionel Sambuc break;
837*0a6a1f1dSLionel Sambuc case 26:
838*0a6a1f1dSLionel Sambuc #line 161 "calc1.y"
839*0a6a1f1dSLionel Sambuc 	{
840*0a6a1f1dSLionel Sambuc 		if (dcheck ( yystack.l_mark[0].vval )) YYERROR;
841*0a6a1f1dSLionel Sambuc 		yyval.vval = vdiv (yystack.l_mark[-2].dval, yystack.l_mark[-2].dval, yystack.l_mark[0].vval );
842*0a6a1f1dSLionel Sambuc 	}
843*0a6a1f1dSLionel Sambuc break;
844*0a6a1f1dSLionel Sambuc case 27:
845*0a6a1f1dSLionel Sambuc #line 166 "calc1.y"
846*0a6a1f1dSLionel Sambuc 	{
847*0a6a1f1dSLionel Sambuc 		yyval.vval.hi = -yystack.l_mark[0].vval.lo;
848*0a6a1f1dSLionel Sambuc 		yyval.vval.lo = -yystack.l_mark[0].vval.hi;
849*0a6a1f1dSLionel Sambuc 	}
850*0a6a1f1dSLionel Sambuc break;
851*0a6a1f1dSLionel Sambuc case 28:
852*0a6a1f1dSLionel Sambuc #line 171 "calc1.y"
853*0a6a1f1dSLionel Sambuc 	{
854*0a6a1f1dSLionel Sambuc 		yyval.vval = yystack.l_mark[-1].vval;
855*0a6a1f1dSLionel Sambuc 	}
856*0a6a1f1dSLionel Sambuc break;
857*0a6a1f1dSLionel Sambuc #line 856 "calc1.tab.c"
858*0a6a1f1dSLionel Sambuc     }
859*0a6a1f1dSLionel Sambuc     yystack.s_mark -= yym;
860*0a6a1f1dSLionel Sambuc     yystate = *yystack.s_mark;
861*0a6a1f1dSLionel Sambuc     yystack.l_mark -= yym;
862*0a6a1f1dSLionel Sambuc     yym = yylhs[yyn];
863*0a6a1f1dSLionel Sambuc     if (yystate == 0 && yym == 0)
864*0a6a1f1dSLionel Sambuc     {
865*0a6a1f1dSLionel Sambuc #if YYDEBUG
866*0a6a1f1dSLionel Sambuc         if (yydebug)
867*0a6a1f1dSLionel Sambuc             printf("%sdebug: after reduction, shifting from state 0 to\
868*0a6a1f1dSLionel Sambuc  state %d\n", YYPREFIX, YYFINAL);
869*0a6a1f1dSLionel Sambuc #endif
870*0a6a1f1dSLionel Sambuc         yystate = YYFINAL;
871*0a6a1f1dSLionel Sambuc         *++yystack.s_mark = YYFINAL;
872*0a6a1f1dSLionel Sambuc         *++yystack.l_mark = yyval;
873*0a6a1f1dSLionel Sambuc         if (yychar < 0)
874*0a6a1f1dSLionel Sambuc         {
875*0a6a1f1dSLionel Sambuc             if ((yychar = YYLEX) < 0) yychar = YYEOF;
876*0a6a1f1dSLionel Sambuc #if YYDEBUG
877*0a6a1f1dSLionel Sambuc             if (yydebug)
878*0a6a1f1dSLionel Sambuc             {
879*0a6a1f1dSLionel Sambuc                 yys = yyname[YYTRANSLATE(yychar)];
880*0a6a1f1dSLionel Sambuc                 printf("%sdebug: state %d, reading %d (%s)\n",
881*0a6a1f1dSLionel Sambuc                         YYPREFIX, YYFINAL, yychar, yys);
882*0a6a1f1dSLionel Sambuc             }
883*0a6a1f1dSLionel Sambuc #endif
884*0a6a1f1dSLionel Sambuc         }
885*0a6a1f1dSLionel Sambuc         if (yychar == YYEOF) goto yyaccept;
886*0a6a1f1dSLionel Sambuc         goto yyloop;
887*0a6a1f1dSLionel Sambuc     }
888*0a6a1f1dSLionel Sambuc     if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
889*0a6a1f1dSLionel Sambuc             yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
890*0a6a1f1dSLionel Sambuc         yystate = yytable[yyn];
891*0a6a1f1dSLionel Sambuc     else
892*0a6a1f1dSLionel Sambuc         yystate = yydgoto[yym];
893*0a6a1f1dSLionel Sambuc #if YYDEBUG
894*0a6a1f1dSLionel Sambuc     if (yydebug)
895*0a6a1f1dSLionel Sambuc         printf("%sdebug: after reduction, shifting from state %d \
896*0a6a1f1dSLionel Sambuc to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
897*0a6a1f1dSLionel Sambuc #endif
898*0a6a1f1dSLionel Sambuc     if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
899*0a6a1f1dSLionel Sambuc     {
900*0a6a1f1dSLionel Sambuc         goto yyoverflow;
901*0a6a1f1dSLionel Sambuc     }
902*0a6a1f1dSLionel Sambuc     *++yystack.s_mark = (YYINT) yystate;
903*0a6a1f1dSLionel Sambuc     *++yystack.l_mark = yyval;
904*0a6a1f1dSLionel Sambuc     goto yyloop;
905*0a6a1f1dSLionel Sambuc 
906*0a6a1f1dSLionel Sambuc yyoverflow:
907*0a6a1f1dSLionel Sambuc     YYERROR_CALL("yacc stack overflow");
908*0a6a1f1dSLionel Sambuc 
909*0a6a1f1dSLionel Sambuc yyabort:
910*0a6a1f1dSLionel Sambuc     yyfreestack(&yystack);
911*0a6a1f1dSLionel Sambuc     return (1);
912*0a6a1f1dSLionel Sambuc 
913*0a6a1f1dSLionel Sambuc yyaccept:
914*0a6a1f1dSLionel Sambuc     yyfreestack(&yystack);
915*0a6a1f1dSLionel Sambuc     return (0);
916*0a6a1f1dSLionel Sambuc }
917