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