xref: /freebsd/contrib/byacc/test/btyacc/calc1.tab.c (revision ef36b3f75658d201edb495068db5e1be49593de5)
1 /* original parser id follows */
2 /* yysccsid[] = "@(#)yaccpar	1.9 (Berkeley) 02/21/93" */
3 /* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */
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 
129 typedef struct interval
130 {
131     double lo, hi;
132 }
133 INTERVAL;
134 
135 INTERVAL vmul(double, double, INTERVAL);
136 INTERVAL vdiv(double, double, INTERVAL);
137 
138 extern int yylex(void);
139 static void yyerror(const char *s);
140 
141 int dcheck(INTERVAL);
142 
143 double dreg[26];
144 INTERVAL vreg[26];
145 
146 #ifdef YYSTYPE
147 #undef  YYSTYPE_IS_DECLARED
148 #define YYSTYPE_IS_DECLARED 1
149 #endif
150 #ifndef YYSTYPE_IS_DECLARED
151 #define YYSTYPE_IS_DECLARED 1
152 #line 31 "calc1.y"
153 typedef 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 
191 extern int YYPARSE_DECL();
192 
193 #define DREG 257
194 #define VREG 258
195 #define CONST 259
196 #define UMINUS 260
197 #define YYERRCODE 256
198 typedef short YYINT;
199 static 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 };
204 static 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 };
209 static 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 };
218 #if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING)
219 static const YYINT calc1_stos[] = {                       0,
220   256,  257,  258,  259,   45,   40,  262,  263,  264,   10,
221    61,   61,  257,  258,  263,  264,  263,  264,   43,   45,
222    42,   47,   10,   43,   45,   42,   47,   10,   45,   40,
223   263,  263,  264,   41,   44,   41,  263,  264,  263,  264,
224   263,  264,  263,  264,  264,  264,  264,  264,  263,  263,
225    43,   45,   42,   47,   10,   10,  263,  263,  263,  263,
226   263,   41,
227 };
228 #endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */
229 static const YYINT calc1_dgoto[] = {                      7,
230    32,    9,    0,
231 };
232 static const YYINT calc1_sindex[] = {                   -40,
233    -8,  -48,  -47,    0,  -37,  -37,    0,    2,   17,    0,
234   -34,  -37,    0,    0,    0,    0,  -25,   90,  -37,  -37,
235   -37,  -37,    0,  -37,  -37,  -37,  -37,    0,  -34,  -34,
236    25,  125,   31,    0,  -34,    0,  -11,   37,  -11,   37,
237     0,    0,    0,    0,   37,   37,    0,    0,    0,  111,
238   -34,  -34,  -34,  -34,    0,    0,  118,   69,   69,    0,
239     0,    0,
240 };
241 static const YYINT calc1_rindex[] = {                     0,
242     0,   38,   44,    0,    0,    0,    0,    0,    0,    0,
243     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
244     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
245     0,   -9,    0,    0,    0,    0,   51,   -3,   56,   61,
246     0,    0,    0,    0,   67,   72,    0,    0,    0,    0,
247     0,    0,    0,    0,    0,    0,    0,   78,   83,    0,
248     0,    0,
249 };
250 #if YYBTYACC
251 static const YYINT calc1_cindex[] = {                     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,    0,    0,    0,    0,    0,    0,    0,    0,
257     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
258     0,    0,
259 };
260 #endif
261 static const YYINT calc1_gindex[] = {                     0,
262     4,  124,    0,
263 };
264 #define YYTABLESIZE 225
265 static const YYINT calc1_table[] = {                      6,
266    16,   10,    6,    8,    5,   30,   20,    5,   15,   17,
267    29,   23,   11,   12,   31,   34,   21,   19,   35,   20,
268     0,   22,   37,   39,   41,   43,   28,    0,    0,    0,
269    21,   16,   49,   50,   55,   22,    0,   20,   57,   20,
270    56,   20,    0,   21,   19,    0,   20,    9,   22,    0,
271     0,    0,    0,   18,   58,   59,   60,   61,   26,   24,
272    10,   25,    0,   27,    0,   11,   53,   51,    0,   52,
273    22,   54,   26,   24,    0,   25,   19,   27,   26,    9,
274     9,   21,    9,   27,    9,   18,   18,   10,   18,    0,
275    18,   10,   11,   10,   10,   10,   11,    0,   11,   11,
276    11,   22,    0,   22,    0,   22,    0,   19,    0,   19,
277    53,   19,   21,    0,   21,   54,   21,    0,   10,    0,
278    10,    0,   10,   11,    0,   11,    0,   11,   16,   18,
279    36,   26,   24,    0,   25,   33,   27,    0,    0,    0,
280     0,    0,   38,   40,   42,   44,    0,   45,   46,   47,
281    48,   34,   53,   51,    0,   52,    0,   54,   62,   53,
282    51,    0,   52,    0,   54,    0,   21,   19,    0,   20,
283     0,   22,    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,    0,    0,    0,    0,    0,
286     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
287     0,    0,    0,    0,    0,    1,    2,    3,    4,   13,
288    14,    4,   13,    0,    4,
289 };
290 static const YYINT calc1_check[] = {                     40,
291    10,   10,   40,    0,   45,   40,   10,   45,    5,    6,
292    45,   10,   61,   61,   11,   41,   42,   43,   44,   45,
293    -1,   47,   19,   20,   21,   22,   10,   -1,   -1,   -1,
294    42,   41,   29,   30,   10,   47,   -1,   41,   35,   43,
295    10,   45,   -1,   42,   43,   -1,   45,   10,   47,   -1,
296    -1,   -1,   -1,   10,   51,   52,   53,   54,   42,   43,
297    10,   45,   -1,   47,   -1,   10,   42,   43,   -1,   45,
298    10,   47,   42,   43,   -1,   45,   10,   47,   42,   42,
299    43,   10,   45,   47,   47,   42,   43,   10,   45,   -1,
300    47,   41,   10,   43,   44,   45,   41,   -1,   43,   44,
301    45,   41,   -1,   43,   -1,   45,   -1,   41,   -1,   43,
302    42,   45,   41,   -1,   43,   47,   45,   -1,   41,   -1,
303    43,   -1,   45,   41,   -1,   43,   -1,   45,    5,    6,
304    41,   42,   43,   -1,   45,   12,   47,   -1,   -1,   -1,
305    -1,   -1,   19,   20,   21,   22,   -1,   24,   25,   26,
306    27,   41,   42,   43,   -1,   45,   -1,   47,   41,   42,
307    43,   -1,   45,   -1,   47,   -1,   42,   43,   -1,   45,
308    -1,   47,   -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,   -1,   -1,   -1,   -1,   -1,
311    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
312    -1,   -1,   -1,   -1,   -1,  256,  257,  258,  259,  257,
313   258,  259,  257,   -1,  259,
314 };
315 #if YYBTYACC
316 static const YYINT calc1_ctable[] = {                    -1,
317    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
318    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
319    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
320    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
321    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
322    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
323    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
324    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
325    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
326    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
327    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
328    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
329    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
330    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
331    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
332    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
333    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
334    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
335    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
336    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
337    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
338    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
339    -1,   -1,   -1,   -1,
340 };
341 #endif
342 #define YYFINAL 7
343 #ifndef YYDEBUG
344 #define YYDEBUG 0
345 #endif
346 #define YYMAXTOKEN 260
347 #define YYUNDFTOKEN 266
348 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
349 #if YYDEBUG
350 static const char *const calc1_name[] = {
351 
352 "$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,
353 0,0,0,0,0,0,"'('","')'","'*'","'+'","','","'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0,0,0,
354 0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
355 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
356 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
358 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
359 "error","DREG","VREG","CONST","UMINUS","$accept","line","dexp","vexp","lines",
360 "illegal-symbol",
361 };
362 static const char *const calc1_rule[] = {
363 "$accept : line",
364 "lines :",
365 "lines : lines line",
366 "line : dexp '\\n'",
367 "line : vexp '\\n'",
368 "line : DREG '=' dexp '\\n'",
369 "line : VREG '=' vexp '\\n'",
370 "line : error '\\n'",
371 "dexp : CONST",
372 "dexp : DREG",
373 "dexp : dexp '+' dexp",
374 "dexp : dexp '-' dexp",
375 "dexp : dexp '*' dexp",
376 "dexp : dexp '/' dexp",
377 "dexp : '-' dexp",
378 "dexp : '(' dexp ')'",
379 "vexp : dexp",
380 "vexp : '(' dexp ',' dexp ')'",
381 "vexp : VREG",
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 '/' vexp",
389 "vexp : dexp '/' vexp",
390 "vexp : '-' vexp",
391 "vexp : '(' vexp ')'",
392 
393 };
394 #endif
395 
396 int      yydebug;
397 int      yynerrs;
398 
399 int      yyerrflag;
400 int      yychar;
401 YYSTYPE  yyval;
402 YYSTYPE  yylval;
403 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
404 YYLTYPE  yyloc; /* position returned by actions */
405 YYLTYPE  yylloc; /* position from the lexer */
406 #endif
407 
408 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
409 #ifndef YYLLOC_DEFAULT
410 #define YYLLOC_DEFAULT(loc, rhs, n) \
411 do \
412 { \
413     if (n == 0) \
414     { \
415         (loc).first_line   = ((rhs)[-1]).last_line; \
416         (loc).first_column = ((rhs)[-1]).last_column; \
417         (loc).last_line    = ((rhs)[-1]).last_line; \
418         (loc).last_column  = ((rhs)[-1]).last_column; \
419     } \
420     else \
421     { \
422         (loc).first_line   = ((rhs)[ 0 ]).first_line; \
423         (loc).first_column = ((rhs)[ 0 ]).first_column; \
424         (loc).last_line    = ((rhs)[n-1]).last_line; \
425         (loc).last_column  = ((rhs)[n-1]).last_column; \
426     } \
427 } while (0)
428 #endif /* YYLLOC_DEFAULT */
429 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
430 #if YYBTYACC
431 
432 #ifndef YYLVQUEUEGROWTH
433 #define YYLVQUEUEGROWTH 32
434 #endif
435 #endif /* YYBTYACC */
436 
437 /* define the initial stack-sizes */
438 #ifdef YYSTACKSIZE
439 #undef YYMAXDEPTH
440 #define YYMAXDEPTH  YYSTACKSIZE
441 #else
442 #ifdef YYMAXDEPTH
443 #define YYSTACKSIZE YYMAXDEPTH
444 #else
445 #define YYSTACKSIZE 10000
446 #define YYMAXDEPTH  10000
447 #endif
448 #endif
449 
450 #ifndef YYINITSTACKSIZE
451 #define YYINITSTACKSIZE 200
452 #endif
453 
454 typedef struct {
455     unsigned stacksize;
456     YYINT    *s_base;
457     YYINT    *s_mark;
458     YYINT    *s_last;
459     YYSTYPE  *l_base;
460     YYSTYPE  *l_mark;
461 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
462     YYLTYPE  *p_base;
463     YYLTYPE  *p_mark;
464 #endif
465 } YYSTACKDATA;
466 #if YYBTYACC
467 
468 struct YYParseState_s
469 {
470     struct YYParseState_s *save;    /* Previously saved parser state */
471     YYSTACKDATA            yystack; /* saved parser stack */
472     int                    state;   /* saved parser state */
473     int                    errflag; /* saved error recovery status */
474     int                    lexeme;  /* saved index of the conflict lexeme in the lexical queue */
475     YYINT                  ctry;    /* saved index in yyctable[] for this conflict */
476 };
477 typedef struct YYParseState_s YYParseState;
478 #endif /* YYBTYACC */
479 /* variables for the parser stack */
480 static YYSTACKDATA yystack;
481 #if YYBTYACC
482 
483 /* Current parser state */
484 static YYParseState *yyps = 0;
485 
486 /* yypath != NULL: do the full parse, starting at *yypath parser state. */
487 static YYParseState *yypath = 0;
488 
489 /* Base of the lexical value queue */
490 static YYSTYPE *yylvals = 0;
491 
492 /* Current position at lexical value queue */
493 static YYSTYPE *yylvp = 0;
494 
495 /* End position of lexical value queue */
496 static YYSTYPE *yylve = 0;
497 
498 /* The last allocated position at the lexical value queue */
499 static YYSTYPE *yylvlim = 0;
500 
501 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
502 /* Base of the lexical position queue */
503 static YYLTYPE *yylpsns = 0;
504 
505 /* Current position at lexical position queue */
506 static YYLTYPE *yylpp = 0;
507 
508 /* End position of lexical position queue */
509 static YYLTYPE *yylpe = 0;
510 
511 /* The last allocated position at the lexical position queue */
512 static YYLTYPE *yylplim = 0;
513 #endif
514 
515 /* Current position at lexical token queue */
516 static YYINT  *yylexp = 0;
517 
518 static YYINT  *yylexemes = 0;
519 #endif /* YYBTYACC */
520 #line 176 "calc1.y"
521 	/* beginning of subroutines section */
522 
523 #define BSZ 50			/* buffer size for floating point numbers */
524 
525 	/* lexical analysis */
526 
527 static void
528 yyerror(const char *s)
529 {
530     fprintf(stderr, "%s\n", s);
531 }
532 
533 int
534 yylex(void)
535 {
536     int c;
537 
538     while ((c = getchar()) == ' ')
539     {				/* skip over blanks */
540     }
541 
542     if (isupper(c))
543     {
544 	yylval.ival = c - 'A';
545 	return (VREG);
546     }
547     if (islower(c))
548     {
549 	yylval.ival = c - 'a';
550 	return (DREG);
551     }
552 
553     if (isdigit(c) || c == '.')
554     {
555 	/* gobble up digits, points, exponents */
556 	char buf[BSZ + 1], *cp = buf;
557 	int dot = 0, expr = 0;
558 
559 	for (; (cp - buf) < BSZ; ++cp, c = getchar())
560 	{
561 
562 	    *cp = (char) c;
563 	    if (isdigit(c))
564 		continue;
565 	    if (c == '.')
566 	    {
567 		if (dot++ || expr)
568 		    return ('.');	/* will cause syntax error */
569 		continue;
570 	    }
571 
572 	    if (c == 'e')
573 	    {
574 		if (expr++)
575 		    return ('e');	/*  will  cause  syntax  error  */
576 		continue;
577 	    }
578 
579 	    /*  end  of  number  */
580 	    break;
581 	}
582 	*cp = '\0';
583 
584 	if ((cp - buf) >= BSZ)
585 	    printf("constant  too  long:  truncated\n");
586 	else
587 	    ungetc(c, stdin);	/*  push  back  last  char  read  */
588 	yylval.dval = atof(buf);
589 	return (CONST);
590     }
591     return (c);
592 }
593 
594 static INTERVAL
595 hilo(double a, double b, double c, double d)
596 {
597     /*  returns  the  smallest  interval  containing  a,  b,  c,  and  d  */
598     /*  used  by  *,  /  routines  */
599     INTERVAL v;
600 
601     if (a > b)
602     {
603 	v.hi = a;
604 	v.lo = b;
605     }
606     else
607     {
608 	v.hi = b;
609 	v.lo = a;
610     }
611 
612     if (c > d)
613     {
614 	if (c > v.hi)
615 	    v.hi = c;
616 	if (d < v.lo)
617 	    v.lo = d;
618     }
619     else
620     {
621 	if (d > v.hi)
622 	    v.hi = d;
623 	if (c < v.lo)
624 	    v.lo = c;
625     }
626     return (v);
627 }
628 
629 INTERVAL
630 vmul(double a, double b, INTERVAL v)
631 {
632     return (hilo(a * v.hi, a * v.lo, b * v.hi, b * v.lo));
633 }
634 
635 int
636 dcheck(INTERVAL v)
637 {
638     if (v.hi >= 0. && v.lo <= 0.)
639     {
640 	printf("divisor  interval  contains  0.\n");
641 	return (1);
642     }
643     return (0);
644 }
645 
646 INTERVAL
647 vdiv(double a, double b, INTERVAL v)
648 {
649     return (hilo(a / v.hi, a / v.lo, b / v.hi, b / v.lo));
650 }
651 #line 652 "calc1.tab.c"
652 
653 /* For use in generated program */
654 #define yydepth (int)(yystack.s_mark - yystack.s_base)
655 #if YYBTYACC
656 #define yytrial (yyps->save)
657 #endif /* YYBTYACC */
658 
659 #if YYDEBUG
660 #include <stdio.h>	/* needed for printf */
661 #endif
662 
663 #include <stdlib.h>	/* needed for malloc, etc */
664 #include <string.h>	/* needed for memset */
665 
666 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
667 static int yygrowstack(YYSTACKDATA *data)
668 {
669     int i;
670     unsigned newsize;
671     YYINT *newss;
672     YYSTYPE *newvs;
673 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
674     YYLTYPE *newps;
675 #endif
676 
677     if ((newsize = data->stacksize) == 0)
678         newsize = YYINITSTACKSIZE;
679     else if (newsize >= YYMAXDEPTH)
680         return YYENOMEM;
681     else if ((newsize *= 2) > YYMAXDEPTH)
682         newsize = YYMAXDEPTH;
683 
684     i = (int) (data->s_mark - data->s_base);
685     newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
686     if (newss == 0)
687         return YYENOMEM;
688 
689     data->s_base = newss;
690     data->s_mark = newss + i;
691 
692     newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
693     if (newvs == 0)
694         return YYENOMEM;
695 
696     data->l_base = newvs;
697     data->l_mark = newvs + i;
698 
699 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
700     newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps));
701     if (newps == 0)
702         return YYENOMEM;
703 
704     data->p_base = newps;
705     data->p_mark = newps + i;
706 #endif
707 
708     data->stacksize = newsize;
709     data->s_last = data->s_base + newsize - 1;
710 
711 #if YYDEBUG
712     if (yydebug)
713         fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize);
714 #endif
715     return 0;
716 }
717 
718 #if YYPURE || defined(YY_NO_LEAKS)
719 static void yyfreestack(YYSTACKDATA *data)
720 {
721     free(data->s_base);
722     free(data->l_base);
723 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
724     free(data->p_base);
725 #endif
726     memset(data, 0, sizeof(*data));
727 }
728 #else
729 #define yyfreestack(data) /* nothing */
730 #endif /* YYPURE || defined(YY_NO_LEAKS) */
731 #if YYBTYACC
732 
733 static YYParseState *
734 yyNewState(unsigned size)
735 {
736     YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState));
737     if (p == NULL) return NULL;
738 
739     p->yystack.stacksize = size;
740     if (size == 0)
741     {
742         p->yystack.s_base = NULL;
743         p->yystack.l_base = NULL;
744 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
745         p->yystack.p_base = NULL;
746 #endif
747         return p;
748     }
749     p->yystack.s_base    = (YYINT *) malloc(size * sizeof(YYINT));
750     if (p->yystack.s_base == NULL) return NULL;
751     p->yystack.l_base    = (YYSTYPE *) malloc(size * sizeof(YYSTYPE));
752     if (p->yystack.l_base == NULL) return NULL;
753     memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE));
754 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
755     p->yystack.p_base    = (YYLTYPE *) malloc(size * sizeof(YYLTYPE));
756     if (p->yystack.p_base == NULL) return NULL;
757     memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE));
758 #endif
759 
760     return p;
761 }
762 
763 static void
764 yyFreeState(YYParseState *p)
765 {
766     yyfreestack(&p->yystack);
767     free(p);
768 }
769 #endif /* YYBTYACC */
770 
771 #define YYABORT  goto yyabort
772 #define YYREJECT goto yyabort
773 #define YYACCEPT goto yyaccept
774 #define YYERROR  goto yyerrlab
775 #if YYBTYACC
776 #define YYVALID        do { if (yyps->save)            goto yyvalid; } while(0)
777 #define YYVALID_NESTED do { if (yyps->save && \
778                                 yyps->save->save == 0) goto yyvalid; } while(0)
779 #endif /* YYBTYACC */
780 
781 int
782 YYPARSE_DECL()
783 {
784     int yym, yyn, yystate, yyresult;
785 #if YYBTYACC
786     int yynewerrflag;
787     YYParseState *yyerrctx = NULL;
788 #endif /* YYBTYACC */
789 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
790     YYLTYPE  yyerror_loc_range[2]; /* position of error start & end */
791 #endif
792 #if YYDEBUG
793     const char *yys;
794 
795     if ((yys = getenv("YYDEBUG")) != 0)
796     {
797         yyn = *yys;
798         if (yyn >= '0' && yyn <= '9')
799             yydebug = yyn - '0';
800     }
801     if (yydebug)
802         fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX);
803 #endif
804 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
805     memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range));
806 #endif
807 
808 #if YYBTYACC
809     yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
810     yyps->save = 0;
811 #endif /* YYBTYACC */
812     yym = 0;
813     yyn = 0;
814     yynerrs = 0;
815     yyerrflag = 0;
816     yychar = YYEMPTY;
817     yystate = 0;
818 
819 #if YYPURE
820     memset(&yystack, 0, sizeof(yystack));
821 #endif
822 
823     if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
824     yystack.s_mark = yystack.s_base;
825     yystack.l_mark = yystack.l_base;
826 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
827     yystack.p_mark = yystack.p_base;
828 #endif
829     yystate = 0;
830     *yystack.s_mark = 0;
831 
832 yyloop:
833     if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
834     if (yychar < 0)
835     {
836 #if YYBTYACC
837         do {
838         if (yylvp < yylve)
839         {
840             /* we're currently re-reading tokens */
841             yylval = *yylvp++;
842 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
843             yylloc = *yylpp++;
844 #endif
845             yychar = *yylexp++;
846             break;
847         }
848         if (yyps->save)
849         {
850             /* in trial mode; save scanner results for future parse attempts */
851             if (yylvp == yylvlim)
852             {   /* Enlarge lexical value queue */
853                 size_t p = (size_t) (yylvp - yylvals);
854                 size_t s = (size_t) (yylvlim - yylvals);
855 
856                 s += YYLVQUEUEGROWTH;
857                 if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
858                 if ((yylvals   = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
859 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
860                 if ((yylpsns   = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
861 #endif
862                 yylvp   = yylve = yylvals + p;
863                 yylvlim = yylvals + s;
864 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
865                 yylpp   = yylpe = yylpsns + p;
866                 yylplim = yylpsns + s;
867 #endif
868                 yylexp  = yylexemes + p;
869             }
870             *yylexp = (YYINT) YYLEX;
871             *yylvp++ = yylval;
872             yylve++;
873 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
874             *yylpp++ = yylloc;
875             yylpe++;
876 #endif
877             yychar = *yylexp++;
878             break;
879         }
880         /* normal operation, no conflict encountered */
881 #endif /* YYBTYACC */
882         yychar = YYLEX;
883 #if YYBTYACC
884         } while (0);
885 #endif /* YYBTYACC */
886         if (yychar < 0) yychar = YYEOF;
887 #if YYDEBUG
888         if (yydebug)
889         {
890             if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
891             fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
892                             YYDEBUGSTR, yydepth, yystate, yychar, yys);
893 #ifdef YYSTYPE_TOSTRING
894 #if YYBTYACC
895             if (!yytrial)
896 #endif /* YYBTYACC */
897                 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
898 #endif
899             fputc('\n', stderr);
900         }
901 #endif
902     }
903 #if YYBTYACC
904 
905     /* Do we have a conflict? */
906     if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
907         yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
908     {
909         YYINT ctry;
910 
911         if (yypath)
912         {
913             YYParseState *save;
914 #if YYDEBUG
915             if (yydebug)
916                 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
917                                 YYDEBUGSTR, yydepth, yystate);
918 #endif
919             /* Switch to the next conflict context */
920             save = yypath;
921             yypath = save->save;
922             save->save = NULL;
923             ctry = save->ctry;
924             if (save->state != yystate) YYABORT;
925             yyFreeState(save);
926 
927         }
928         else
929         {
930 
931             /* Unresolved conflict - start/continue trial parse */
932             YYParseState *save;
933 #if YYDEBUG
934             if (yydebug)
935             {
936                 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
937                 if (yyps->save)
938                     fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
939                 else
940                     fputs("Starting trial parse.\n", stderr);
941             }
942 #endif
943             save                  = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
944             if (save == NULL) goto yyenomem;
945             save->save            = yyps->save;
946             save->state           = yystate;
947             save->errflag         = yyerrflag;
948             save->yystack.s_mark  = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
949             memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
950             save->yystack.l_mark  = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
951             memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
952 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
953             save->yystack.p_mark  = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
954             memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
955 #endif
956             ctry                  = yytable[yyn];
957             if (yyctable[ctry] == -1)
958             {
959 #if YYDEBUG
960                 if (yydebug && yychar >= YYEOF)
961                     fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
962 #endif
963                 ctry++;
964             }
965             save->ctry = ctry;
966             if (yyps->save == NULL)
967             {
968                 /* If this is a first conflict in the stack, start saving lexemes */
969                 if (!yylexemes)
970                 {
971                     yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
972                     if (yylexemes == NULL) goto yyenomem;
973                     yylvals   = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
974                     if (yylvals == NULL) goto yyenomem;
975                     yylvlim   = yylvals + YYLVQUEUEGROWTH;
976 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
977                     yylpsns   = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
978                     if (yylpsns == NULL) goto yyenomem;
979                     yylplim   = yylpsns + YYLVQUEUEGROWTH;
980 #endif
981                 }
982                 if (yylvp == yylve)
983                 {
984                     yylvp  = yylve = yylvals;
985 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
986                     yylpp  = yylpe = yylpsns;
987 #endif
988                     yylexp = yylexemes;
989                     if (yychar >= YYEOF)
990                     {
991                         *yylve++ = yylval;
992 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
993                         *yylpe++ = yylloc;
994 #endif
995                         *yylexp  = (YYINT) yychar;
996                         yychar   = YYEMPTY;
997                     }
998                 }
999             }
1000             if (yychar >= YYEOF)
1001             {
1002                 yylvp--;
1003 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1004                 yylpp--;
1005 #endif
1006                 yylexp--;
1007                 yychar = YYEMPTY;
1008             }
1009             save->lexeme = (int) (yylvp - yylvals);
1010             yyps->save   = save;
1011         }
1012         if (yytable[yyn] == ctry)
1013         {
1014 #if YYDEBUG
1015             if (yydebug)
1016                 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
1017                                 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
1018 #endif
1019             if (yychar < 0)
1020             {
1021                 yylvp++;
1022 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1023                 yylpp++;
1024 #endif
1025                 yylexp++;
1026             }
1027             if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
1028                 goto yyoverflow;
1029             yystate = yyctable[ctry];
1030             *++yystack.s_mark = (YYINT) yystate;
1031             *++yystack.l_mark = yylval;
1032 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1033             *++yystack.p_mark = yylloc;
1034 #endif
1035             yychar  = YYEMPTY;
1036             if (yyerrflag > 0) --yyerrflag;
1037             goto yyloop;
1038         }
1039         else
1040         {
1041             yyn = yyctable[ctry];
1042             goto yyreduce;
1043         }
1044     } /* End of code dealing with conflicts */
1045 #endif /* YYBTYACC */
1046     if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
1047             yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
1048     {
1049 #if YYDEBUG
1050         if (yydebug)
1051             fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
1052                             YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
1053 #endif
1054         if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1055         yystate = yytable[yyn];
1056         *++yystack.s_mark = yytable[yyn];
1057         *++yystack.l_mark = yylval;
1058 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1059         *++yystack.p_mark = yylloc;
1060 #endif
1061         yychar = YYEMPTY;
1062         if (yyerrflag > 0)  --yyerrflag;
1063         goto yyloop;
1064     }
1065     if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
1066             yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
1067     {
1068         yyn = yytable[yyn];
1069         goto yyreduce;
1070     }
1071     if (yyerrflag != 0) goto yyinrecovery;
1072 #if YYBTYACC
1073 
1074     yynewerrflag = 1;
1075     goto yyerrhandler;
1076     goto yyerrlab; /* redundant goto avoids 'unused label' warning */
1077 
1078 yyerrlab:
1079     /* explicit YYERROR from an action -- pop the rhs of the rule reduced
1080      * before looking for error recovery */
1081     yystack.s_mark -= yym;
1082     yystate = *yystack.s_mark;
1083     yystack.l_mark -= yym;
1084 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1085     yystack.p_mark -= yym;
1086 #endif
1087 
1088     yynewerrflag = 0;
1089 yyerrhandler:
1090     while (yyps->save)
1091     {
1092         int ctry;
1093         YYParseState *save = yyps->save;
1094 #if YYDEBUG
1095         if (yydebug)
1096             fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
1097                             YYDEBUGSTR, yydepth, yystate, yyps->save->state,
1098                     (int)(yylvp - yylvals - yyps->save->lexeme));
1099 #endif
1100         /* Memorize most forward-looking error state in case it's really an error. */
1101         if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
1102         {
1103             /* Free old saved error context state */
1104             if (yyerrctx) yyFreeState(yyerrctx);
1105             /* Create and fill out new saved error context state */
1106             yyerrctx                 = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
1107             if (yyerrctx == NULL) goto yyenomem;
1108             yyerrctx->save           = yyps->save;
1109             yyerrctx->state          = yystate;
1110             yyerrctx->errflag        = yyerrflag;
1111             yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
1112             memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1113             yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
1114             memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1115 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1116             yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
1117             memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1118 #endif
1119             yyerrctx->lexeme         = (int) (yylvp - yylvals);
1120         }
1121         yylvp          = yylvals   + save->lexeme;
1122 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1123         yylpp          = yylpsns   + save->lexeme;
1124 #endif
1125         yylexp         = yylexemes + save->lexeme;
1126         yychar         = YYEMPTY;
1127         yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
1128         memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1129         yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
1130         memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1131 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1132         yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
1133         memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1134 #endif
1135         ctry           = ++save->ctry;
1136         yystate        = save->state;
1137         /* We tried shift, try reduce now */
1138         if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
1139         yyps->save     = save->save;
1140         save->save     = NULL;
1141         yyFreeState(save);
1142 
1143         /* Nothing left on the stack -- error */
1144         if (!yyps->save)
1145         {
1146 #if YYDEBUG
1147             if (yydebug)
1148                 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
1149                                 YYPREFIX, yydepth);
1150 #endif
1151             /* Restore state as it was in the most forward-advanced error */
1152             yylvp          = yylvals   + yyerrctx->lexeme;
1153 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1154             yylpp          = yylpsns   + yyerrctx->lexeme;
1155 #endif
1156             yylexp         = yylexemes + yyerrctx->lexeme;
1157             yychar         = yylexp[-1];
1158             yylval         = yylvp[-1];
1159 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1160             yylloc         = yylpp[-1];
1161 #endif
1162             yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
1163             memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1164             yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
1165             memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1166 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1167             yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
1168             memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1169 #endif
1170             yystate        = yyerrctx->state;
1171             yyFreeState(yyerrctx);
1172             yyerrctx       = NULL;
1173         }
1174         yynewerrflag = 1;
1175     }
1176     if (yynewerrflag == 0) goto yyinrecovery;
1177 #endif /* YYBTYACC */
1178 
1179     YYERROR_CALL("syntax error");
1180 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1181     yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
1182 #endif
1183 
1184 #if !YYBTYACC
1185     goto yyerrlab; /* redundant goto avoids 'unused label' warning */
1186 yyerrlab:
1187 #endif
1188     ++yynerrs;
1189 
1190 yyinrecovery:
1191     if (yyerrflag < 3)
1192     {
1193         yyerrflag = 3;
1194         for (;;)
1195         {
1196             if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
1197                     yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
1198             {
1199 #if YYDEBUG
1200                 if (yydebug)
1201                     fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
1202                                     YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
1203 #endif
1204                 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1205                 yystate = yytable[yyn];
1206                 *++yystack.s_mark = yytable[yyn];
1207                 *++yystack.l_mark = yylval;
1208 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1209                 /* lookahead position is error end position */
1210                 yyerror_loc_range[1] = yylloc;
1211                 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
1212                 *++yystack.p_mark = yyloc;
1213 #endif
1214                 goto yyloop;
1215             }
1216             else
1217             {
1218 #if YYDEBUG
1219                 if (yydebug)
1220                     fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
1221                                     YYDEBUGSTR, yydepth, *yystack.s_mark);
1222 #endif
1223                 if (yystack.s_mark <= yystack.s_base) goto yyabort;
1224 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1225                 /* the current TOS position is the error start position */
1226                 yyerror_loc_range[0] = *yystack.p_mark;
1227 #endif
1228 #if defined(YYDESTRUCT_CALL)
1229 #if YYBTYACC
1230                 if (!yytrial)
1231 #endif /* YYBTYACC */
1232 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1233                     YYDESTRUCT_CALL("error: discarding state",
1234                                     yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
1235 #else
1236                     YYDESTRUCT_CALL("error: discarding state",
1237                                     yystos[*yystack.s_mark], yystack.l_mark);
1238 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1239 #endif /* defined(YYDESTRUCT_CALL) */
1240                 --yystack.s_mark;
1241                 --yystack.l_mark;
1242 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1243                 --yystack.p_mark;
1244 #endif
1245             }
1246         }
1247     }
1248     else
1249     {
1250         if (yychar == YYEOF) goto yyabort;
1251 #if YYDEBUG
1252         if (yydebug)
1253         {
1254             if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1255             fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
1256                             YYDEBUGSTR, yydepth, yystate, yychar, yys);
1257         }
1258 #endif
1259 #if defined(YYDESTRUCT_CALL)
1260 #if YYBTYACC
1261         if (!yytrial)
1262 #endif /* YYBTYACC */
1263 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1264             YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
1265 #else
1266             YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
1267 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1268 #endif /* defined(YYDESTRUCT_CALL) */
1269         yychar = YYEMPTY;
1270         goto yyloop;
1271     }
1272 
1273 yyreduce:
1274     yym = yylen[yyn];
1275 #if YYDEBUG
1276     if (yydebug)
1277     {
1278         fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
1279                         YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
1280 #ifdef YYSTYPE_TOSTRING
1281 #if YYBTYACC
1282         if (!yytrial)
1283 #endif /* YYBTYACC */
1284             if (yym > 0)
1285             {
1286                 int i;
1287                 fputc('<', stderr);
1288                 for (i = yym; i > 0; i--)
1289                 {
1290                     if (i != yym) fputs(", ", stderr);
1291                     fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
1292                                            yystack.l_mark[1-i]), stderr);
1293                 }
1294                 fputc('>', stderr);
1295             }
1296 #endif
1297         fputc('\n', stderr);
1298     }
1299 #endif
1300     if (yym > 0)
1301         yyval = yystack.l_mark[1-yym];
1302     else
1303         memset(&yyval, 0, sizeof yyval);
1304 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1305 
1306     /* Perform position reduction */
1307     memset(&yyloc, 0, sizeof(yyloc));
1308 #if YYBTYACC
1309     if (!yytrial)
1310 #endif /* YYBTYACC */
1311     {
1312         YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
1313         /* just in case YYERROR is invoked within the action, save
1314            the start of the rhs as the error start position */
1315         yyerror_loc_range[0] = yystack.p_mark[1-yym];
1316     }
1317 #endif
1318 
1319     switch (yyn)
1320     {
1321 case 3:
1322 #line 57 "calc1.y"
1323 	{
1324 		(void) printf("%15.8f\n", yystack.l_mark[-1].dval);
1325 	}
1326 break;
1327 case 4:
1328 #line 61 "calc1.y"
1329 	{
1330 		(void) printf("(%15.8f, %15.8f)\n", yystack.l_mark[-1].vval.lo, yystack.l_mark[-1].vval.hi);
1331 	}
1332 break;
1333 case 5:
1334 #line 65 "calc1.y"
1335 	{
1336 		dreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].dval;
1337 	}
1338 break;
1339 case 6:
1340 #line 69 "calc1.y"
1341 	{
1342 		vreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].vval;
1343 	}
1344 break;
1345 case 7:
1346 #line 73 "calc1.y"
1347 	{
1348 		yyerrok;
1349 	}
1350 break;
1351 case 9:
1352 #line 80 "calc1.y"
1353 	{
1354 		yyval.dval = dreg[yystack.l_mark[0].ival];
1355 	}
1356 break;
1357 case 10:
1358 #line 84 "calc1.y"
1359 	{
1360 		yyval.dval = yystack.l_mark[-2].dval + yystack.l_mark[0].dval;
1361 	}
1362 break;
1363 case 11:
1364 #line 88 "calc1.y"
1365 	{
1366 		yyval.dval = yystack.l_mark[-2].dval - yystack.l_mark[0].dval;
1367 	}
1368 break;
1369 case 12:
1370 #line 92 "calc1.y"
1371 	{
1372 		yyval.dval = yystack.l_mark[-2].dval * yystack.l_mark[0].dval;
1373 	}
1374 break;
1375 case 13:
1376 #line 96 "calc1.y"
1377 	{
1378 		yyval.dval = yystack.l_mark[-2].dval / yystack.l_mark[0].dval;
1379 	}
1380 break;
1381 case 14:
1382 #line 100 "calc1.y"
1383 	{
1384 		yyval.dval = -yystack.l_mark[0].dval;
1385 	}
1386 break;
1387 case 15:
1388 #line 104 "calc1.y"
1389 	{
1390 		yyval.dval = yystack.l_mark[-1].dval;
1391 	}
1392 break;
1393 case 16:
1394 #line 110 "calc1.y"
1395 	{
1396 		yyval.vval.hi = yyval.vval.lo = yystack.l_mark[0].dval;
1397 	}
1398 break;
1399 case 17:
1400 #line 114 "calc1.y"
1401 	{
1402 		yyval.vval.lo = yystack.l_mark[-3].dval;
1403 		yyval.vval.hi = yystack.l_mark[-1].dval;
1404 		if ( yyval.vval.lo > yyval.vval.hi )
1405 		{
1406 			(void) printf("interval out of order\n");
1407 			YYERROR;
1408 		}
1409 	}
1410 break;
1411 case 18:
1412 #line 124 "calc1.y"
1413 	{
1414 		yyval.vval = vreg[yystack.l_mark[0].ival];
1415 	}
1416 break;
1417 case 19:
1418 #line 128 "calc1.y"
1419 	{
1420 		yyval.vval.hi = yystack.l_mark[-2].vval.hi + yystack.l_mark[0].vval.hi;
1421 		yyval.vval.lo = yystack.l_mark[-2].vval.lo + yystack.l_mark[0].vval.lo;
1422 	}
1423 break;
1424 case 20:
1425 #line 133 "calc1.y"
1426 	{
1427 		yyval.vval.hi = yystack.l_mark[-2].dval + yystack.l_mark[0].vval.hi;
1428 		yyval.vval.lo = yystack.l_mark[-2].dval + yystack.l_mark[0].vval.lo;
1429 	}
1430 break;
1431 case 21:
1432 #line 138 "calc1.y"
1433 	{
1434 		yyval.vval.hi = yystack.l_mark[-2].vval.hi - yystack.l_mark[0].vval.lo;
1435 		yyval.vval.lo = yystack.l_mark[-2].vval.lo - yystack.l_mark[0].vval.hi;
1436 	}
1437 break;
1438 case 22:
1439 #line 143 "calc1.y"
1440 	{
1441 		yyval.vval.hi = yystack.l_mark[-2].dval - yystack.l_mark[0].vval.lo;
1442 		yyval.vval.lo = yystack.l_mark[-2].dval - yystack.l_mark[0].vval.hi;
1443 	}
1444 break;
1445 case 23:
1446 #line 148 "calc1.y"
1447 	{
1448 		yyval.vval = vmul( yystack.l_mark[-2].vval.lo, yystack.l_mark[-2].vval.hi, yystack.l_mark[0].vval );
1449 	}
1450 break;
1451 case 24:
1452 #line 152 "calc1.y"
1453 	{
1454 		yyval.vval = vmul (yystack.l_mark[-2].dval, yystack.l_mark[-2].dval, yystack.l_mark[0].vval );
1455 	}
1456 break;
1457 case 25:
1458 #line 156 "calc1.y"
1459 	{
1460 		if (dcheck(yystack.l_mark[0].vval)) YYERROR;
1461 		yyval.vval = vdiv ( yystack.l_mark[-2].vval.lo, yystack.l_mark[-2].vval.hi, yystack.l_mark[0].vval );
1462 	}
1463 break;
1464 case 26:
1465 #line 161 "calc1.y"
1466 	{
1467 		if (dcheck ( yystack.l_mark[0].vval )) YYERROR;
1468 		yyval.vval = vdiv (yystack.l_mark[-2].dval, yystack.l_mark[-2].dval, yystack.l_mark[0].vval );
1469 	}
1470 break;
1471 case 27:
1472 #line 166 "calc1.y"
1473 	{
1474 		yyval.vval.hi = -yystack.l_mark[0].vval.lo;
1475 		yyval.vval.lo = -yystack.l_mark[0].vval.hi;
1476 	}
1477 break;
1478 case 28:
1479 #line 171 "calc1.y"
1480 	{
1481 		yyval.vval = yystack.l_mark[-1].vval;
1482 	}
1483 break;
1484 #line 1485 "calc1.tab.c"
1485     default:
1486         break;
1487     }
1488     yystack.s_mark -= yym;
1489     yystate = *yystack.s_mark;
1490     yystack.l_mark -= yym;
1491 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1492     yystack.p_mark -= yym;
1493 #endif
1494     yym = yylhs[yyn];
1495     if (yystate == 0 && yym == 0)
1496     {
1497 #if YYDEBUG
1498         if (yydebug)
1499         {
1500             fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1501 #ifdef YYSTYPE_TOSTRING
1502 #if YYBTYACC
1503             if (!yytrial)
1504 #endif /* YYBTYACC */
1505                 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
1506 #endif
1507             fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
1508         }
1509 #endif
1510         yystate = YYFINAL;
1511         *++yystack.s_mark = YYFINAL;
1512         *++yystack.l_mark = yyval;
1513 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1514         *++yystack.p_mark = yyloc;
1515 #endif
1516         if (yychar < 0)
1517         {
1518 #if YYBTYACC
1519             do {
1520             if (yylvp < yylve)
1521             {
1522                 /* we're currently re-reading tokens */
1523                 yylval = *yylvp++;
1524 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1525                 yylloc = *yylpp++;
1526 #endif
1527                 yychar = *yylexp++;
1528                 break;
1529             }
1530             if (yyps->save)
1531             {
1532                 /* in trial mode; save scanner results for future parse attempts */
1533                 if (yylvp == yylvlim)
1534                 {   /* Enlarge lexical value queue */
1535                     size_t p = (size_t) (yylvp - yylvals);
1536                     size_t s = (size_t) (yylvlim - yylvals);
1537 
1538                     s += YYLVQUEUEGROWTH;
1539                     if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
1540                         goto yyenomem;
1541                     if ((yylvals   = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
1542                         goto yyenomem;
1543 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1544                     if ((yylpsns   = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
1545                         goto yyenomem;
1546 #endif
1547                     yylvp   = yylve = yylvals + p;
1548                     yylvlim = yylvals + s;
1549 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1550                     yylpp   = yylpe = yylpsns + p;
1551                     yylplim = yylpsns + s;
1552 #endif
1553                     yylexp  = yylexemes + p;
1554                 }
1555                 *yylexp = (YYINT) YYLEX;
1556                 *yylvp++ = yylval;
1557                 yylve++;
1558 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1559                 *yylpp++ = yylloc;
1560                 yylpe++;
1561 #endif
1562                 yychar = *yylexp++;
1563                 break;
1564             }
1565             /* normal operation, no conflict encountered */
1566 #endif /* YYBTYACC */
1567             yychar = YYLEX;
1568 #if YYBTYACC
1569             } while (0);
1570 #endif /* YYBTYACC */
1571             if (yychar < 0) yychar = YYEOF;
1572 #if YYDEBUG
1573             if (yydebug)
1574             {
1575                 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1576                 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n",
1577                                 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
1578             }
1579 #endif
1580         }
1581         if (yychar == YYEOF) goto yyaccept;
1582         goto yyloop;
1583     }
1584     if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
1585             yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
1586         yystate = yytable[yyn];
1587     else
1588         yystate = yydgoto[yym];
1589 #if YYDEBUG
1590     if (yydebug)
1591     {
1592         fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1593 #ifdef YYSTYPE_TOSTRING
1594 #if YYBTYACC
1595         if (!yytrial)
1596 #endif /* YYBTYACC */
1597             fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
1598 #endif
1599         fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
1600     }
1601 #endif
1602     if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1603     *++yystack.s_mark = (YYINT) yystate;
1604     *++yystack.l_mark = yyval;
1605 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1606     *++yystack.p_mark = yyloc;
1607 #endif
1608     goto yyloop;
1609 #if YYBTYACC
1610 
1611     /* Reduction declares that this path is valid. Set yypath and do a full parse */
1612 yyvalid:
1613     if (yypath) YYABORT;
1614     while (yyps->save)
1615     {
1616         YYParseState *save = yyps->save;
1617         yyps->save = save->save;
1618         save->save = yypath;
1619         yypath = save;
1620     }
1621 #if YYDEBUG
1622     if (yydebug)
1623         fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
1624                         YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
1625 #endif
1626     if (yyerrctx)
1627     {
1628         yyFreeState(yyerrctx);
1629         yyerrctx = NULL;
1630     }
1631     yylvp          = yylvals + yypath->lexeme;
1632 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1633     yylpp          = yylpsns + yypath->lexeme;
1634 #endif
1635     yylexp         = yylexemes + yypath->lexeme;
1636     yychar         = YYEMPTY;
1637     yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
1638     memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1639     yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
1640     memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1641 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1642     yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
1643     memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1644 #endif
1645     yystate        = yypath->state;
1646     goto yyloop;
1647 #endif /* YYBTYACC */
1648 
1649 yyoverflow:
1650     YYERROR_CALL("yacc stack overflow");
1651 #if YYBTYACC
1652     goto yyabort_nomem;
1653 yyenomem:
1654     YYERROR_CALL("memory exhausted");
1655 yyabort_nomem:
1656 #endif /* YYBTYACC */
1657     yyresult = 2;
1658     goto yyreturn;
1659 
1660 yyabort:
1661     yyresult = 1;
1662     goto yyreturn;
1663 
1664 yyaccept:
1665 #if YYBTYACC
1666     if (yyps->save) goto yyvalid;
1667 #endif /* YYBTYACC */
1668     yyresult = 0;
1669 
1670 yyreturn:
1671 #if defined(YYDESTRUCT_CALL)
1672     if (yychar != YYEOF && yychar != YYEMPTY)
1673 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1674         YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
1675 #else
1676         YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
1677 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1678 
1679     {
1680         YYSTYPE *pv;
1681 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1682         YYLTYPE *pp;
1683 
1684         for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
1685              YYDESTRUCT_CALL("cleanup: discarding state",
1686                              yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
1687 #else
1688         for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
1689              YYDESTRUCT_CALL("cleanup: discarding state",
1690                              yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
1691 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1692     }
1693 #endif /* defined(YYDESTRUCT_CALL) */
1694 
1695 #if YYBTYACC
1696     if (yyerrctx)
1697     {
1698         yyFreeState(yyerrctx);
1699         yyerrctx = NULL;
1700     }
1701     while (yyps)
1702     {
1703         YYParseState *save = yyps;
1704         yyps = save->save;
1705         save->save = NULL;
1706         yyFreeState(save);
1707     }
1708     while (yypath)
1709     {
1710         YYParseState *save = yypath;
1711         yypath = save->save;
1712         save->save = NULL;
1713         yyFreeState(save);
1714     }
1715 #endif /* YYBTYACC */
1716     yyfreestack(&yystack);
1717     return (yyresult);
1718 }
1719