xref: /freebsd/contrib/byacc/test/btyacc/calc1.tab.c (revision 5bd73b51076b5cb5a2c9810f76c1d7ed20c4460e)
1 /* original parser id follows */
2 /* yysccsid[] = "@(#)yaccpar	1.9 (Berkeley) 02/21/93" */
3 /* (use YYMAJOR/YYMINOR for ifdefs dependent of 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 #line 31 "calc1.y"
147 #ifdef YYSTYPE
148 #undef  YYSTYPE_IS_DECLARED
149 #define YYSTYPE_IS_DECLARED 1
150 #endif
151 #ifndef YYSTYPE_IS_DECLARED
152 #define YYSTYPE_IS_DECLARED 1
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     short    *s_base;
455     short    *s_mark;
456     short    *s_last;
457     YYSTYPE  *l_base;
458     YYSTYPE  *l_mark;
459 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
460     YYLTYPE  *p_base;
461     YYLTYPE  *p_mark;
462 #endif
463 } YYSTACKDATA;
464 #if YYBTYACC
465 
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     short *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 = (short *)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    = (short *) malloc(size * sizeof(short));
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     yynerrs = 0;
808     yyerrflag = 0;
809     yychar = YYEMPTY;
810     yystate = 0;
811 
812 #if YYPURE
813     memset(&yystack, 0, sizeof(yystack));
814 #endif
815 
816     if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
817     yystack.s_mark = yystack.s_base;
818     yystack.l_mark = yystack.l_base;
819 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
820     yystack.p_mark = yystack.p_base;
821 #endif
822     yystate = 0;
823     *yystack.s_mark = 0;
824 
825 yyloop:
826     if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
827     if (yychar < 0)
828     {
829 #if YYBTYACC
830         do {
831         if (yylvp < yylve)
832         {
833             /* we're currently re-reading tokens */
834             yylval = *yylvp++;
835 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
836             yylloc = *yylpp++;
837 #endif
838             yychar = *yylexp++;
839             break;
840         }
841         if (yyps->save)
842         {
843             /* in trial mode; save scanner results for future parse attempts */
844             if (yylvp == yylvlim)
845             {   /* Enlarge lexical value queue */
846                 size_t p = (size_t) (yylvp - yylvals);
847                 size_t s = (size_t) (yylvlim - yylvals);
848 
849                 s += YYLVQUEUEGROWTH;
850                 if ((yylexemes = (short *)   realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem;
851                 if ((yylvals   = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
852 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
853                 if ((yylpsns   = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
854 #endif
855                 yylvp   = yylve = yylvals + p;
856                 yylvlim = yylvals + s;
857 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
858                 yylpp   = yylpe = yylpsns + p;
859                 yylplim = yylpsns + s;
860 #endif
861                 yylexp  = yylexemes + p;
862             }
863             *yylexp = (short) YYLEX;
864             *yylvp++ = yylval;
865             yylve++;
866 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
867             *yylpp++ = yylloc;
868             yylpe++;
869 #endif
870             yychar = *yylexp++;
871             break;
872         }
873         /* normal operation, no conflict encountered */
874 #endif /* YYBTYACC */
875         yychar = YYLEX;
876 #if YYBTYACC
877         } while (0);
878 #endif /* YYBTYACC */
879         if (yychar < 0) yychar = YYEOF;
880         /* if ((yychar = YYLEX) < 0) yychar = YYEOF; */
881 #if YYDEBUG
882         if (yydebug)
883         {
884             yys = yyname[YYTRANSLATE(yychar)];
885             fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
886                             YYDEBUGSTR, yydepth, yystate, yychar, yys);
887 #ifdef YYSTYPE_TOSTRING
888 #if YYBTYACC
889             if (!yytrial)
890 #endif /* YYBTYACC */
891                 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
892 #endif
893             fputc('\n', stderr);
894         }
895 #endif
896     }
897 #if YYBTYACC
898 
899     /* Do we have a conflict? */
900     if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
901         yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
902     {
903         YYINT ctry;
904 
905         if (yypath)
906         {
907             YYParseState *save;
908 #if YYDEBUG
909             if (yydebug)
910                 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
911                                 YYDEBUGSTR, yydepth, yystate);
912 #endif
913             /* Switch to the next conflict context */
914             save = yypath;
915             yypath = save->save;
916             save->save = NULL;
917             ctry = save->ctry;
918             if (save->state != yystate) YYABORT;
919             yyFreeState(save);
920 
921         }
922         else
923         {
924 
925             /* Unresolved conflict - start/continue trial parse */
926             YYParseState *save;
927 #if YYDEBUG
928             if (yydebug)
929             {
930                 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
931                 if (yyps->save)
932                     fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
933                 else
934                     fputs("Starting trial parse.\n", stderr);
935             }
936 #endif
937             save                  = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
938             if (save == NULL) goto yyenomem;
939             save->save            = yyps->save;
940             save->state           = yystate;
941             save->errflag         = yyerrflag;
942             save->yystack.s_mark  = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
943             memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
944             save->yystack.l_mark  = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
945             memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
946 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
947             save->yystack.p_mark  = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
948             memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
949 #endif
950             ctry                  = yytable[yyn];
951             if (yyctable[ctry] == -1)
952             {
953 #if YYDEBUG
954                 if (yydebug && yychar >= YYEOF)
955                     fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
956 #endif
957                 ctry++;
958             }
959             save->ctry = ctry;
960             if (yyps->save == NULL)
961             {
962                 /* If this is a first conflict in the stack, start saving lexemes */
963                 if (!yylexemes)
964                 {
965                     yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short));
966                     if (yylexemes == NULL) goto yyenomem;
967                     yylvals   = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
968                     if (yylvals == NULL) goto yyenomem;
969                     yylvlim   = yylvals + YYLVQUEUEGROWTH;
970 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
971                     yylpsns   = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
972                     if (yylpsns == NULL) goto yyenomem;
973                     yylplim   = yylpsns + YYLVQUEUEGROWTH;
974 #endif
975                 }
976                 if (yylvp == yylve)
977                 {
978                     yylvp  = yylve = yylvals;
979 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
980                     yylpp  = yylpe = yylpsns;
981 #endif
982                     yylexp = yylexemes;
983                     if (yychar >= YYEOF)
984                     {
985                         *yylve++ = yylval;
986 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
987                         *yylpe++ = yylloc;
988 #endif
989                         *yylexp  = (short) yychar;
990                         yychar   = YYEMPTY;
991                     }
992                 }
993             }
994             if (yychar >= YYEOF)
995             {
996                 yylvp--;
997 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
998                 yylpp--;
999 #endif
1000                 yylexp--;
1001                 yychar = YYEMPTY;
1002             }
1003             save->lexeme = (int) (yylvp - yylvals);
1004             yyps->save   = save;
1005         }
1006         if (yytable[yyn] == ctry)
1007         {
1008 #if YYDEBUG
1009             if (yydebug)
1010                 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
1011                                 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
1012 #endif
1013             if (yychar < 0)
1014             {
1015                 yylvp++;
1016 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1017                 yylpp++;
1018 #endif
1019                 yylexp++;
1020             }
1021             if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
1022                 goto yyoverflow;
1023             yystate = yyctable[ctry];
1024             *++yystack.s_mark = (short) yystate;
1025             *++yystack.l_mark = yylval;
1026 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1027             *++yystack.p_mark = yylloc;
1028 #endif
1029             yychar  = YYEMPTY;
1030             if (yyerrflag > 0) --yyerrflag;
1031             goto yyloop;
1032         }
1033         else
1034         {
1035             yyn = yyctable[ctry];
1036             goto yyreduce;
1037         }
1038     } /* End of code dealing with conflicts */
1039 #endif /* YYBTYACC */
1040     if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
1041             yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
1042     {
1043 #if YYDEBUG
1044         if (yydebug)
1045             fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
1046                             YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
1047 #endif
1048         if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1049         yystate = yytable[yyn];
1050         *++yystack.s_mark = yytable[yyn];
1051         *++yystack.l_mark = yylval;
1052 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1053         *++yystack.p_mark = yylloc;
1054 #endif
1055         yychar = YYEMPTY;
1056         if (yyerrflag > 0)  --yyerrflag;
1057         goto yyloop;
1058     }
1059     if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
1060             yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
1061     {
1062         yyn = yytable[yyn];
1063         goto yyreduce;
1064     }
1065     if (yyerrflag != 0) goto yyinrecovery;
1066 #if YYBTYACC
1067 
1068     yynewerrflag = 1;
1069     goto yyerrhandler;
1070     goto yyerrlab;
1071 
1072 yyerrlab:
1073     yynewerrflag = 0;
1074 yyerrhandler:
1075     while (yyps->save)
1076     {
1077         int ctry;
1078         YYParseState *save = yyps->save;
1079 #if YYDEBUG
1080         if (yydebug)
1081             fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
1082                             YYDEBUGSTR, yydepth, yystate, yyps->save->state,
1083                     (int)(yylvp - yylvals - yyps->save->lexeme));
1084 #endif
1085         /* Memorize most forward-looking error state in case it's really an error. */
1086         if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
1087         {
1088             /* Free old saved error context state */
1089             if (yyerrctx) yyFreeState(yyerrctx);
1090             /* Create and fill out new saved error context state */
1091             yyerrctx                 = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
1092             if (yyerrctx == NULL) goto yyenomem;
1093             yyerrctx->save           = yyps->save;
1094             yyerrctx->state          = yystate;
1095             yyerrctx->errflag        = yyerrflag;
1096             yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
1097             memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
1098             yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
1099             memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1100 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1101             yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
1102             memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1103 #endif
1104             yyerrctx->lexeme         = (int) (yylvp - yylvals);
1105         }
1106         yylvp          = yylvals   + save->lexeme;
1107 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1108         yylpp          = yylpsns   + save->lexeme;
1109 #endif
1110         yylexp         = yylexemes + save->lexeme;
1111         yychar         = YYEMPTY;
1112         yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
1113         memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
1114         yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
1115         memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1116 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1117         yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
1118         memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1119 #endif
1120         ctry           = ++save->ctry;
1121         yystate        = save->state;
1122         /* We tried shift, try reduce now */
1123         if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
1124         yyps->save     = save->save;
1125         save->save     = NULL;
1126         yyFreeState(save);
1127 
1128         /* Nothing left on the stack -- error */
1129         if (!yyps->save)
1130         {
1131 #if YYDEBUG
1132             if (yydebug)
1133                 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
1134                                 YYPREFIX, yydepth);
1135 #endif
1136             /* Restore state as it was in the most forward-advanced error */
1137             yylvp          = yylvals   + yyerrctx->lexeme;
1138 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1139             yylpp          = yylpsns   + yyerrctx->lexeme;
1140 #endif
1141             yylexp         = yylexemes + yyerrctx->lexeme;
1142             yychar         = yylexp[-1];
1143             yylval         = yylvp[-1];
1144 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1145             yylloc         = yylpp[-1];
1146 #endif
1147             yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
1148             memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
1149             yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
1150             memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1151 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1152             yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
1153             memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1154 #endif
1155             yystate        = yyerrctx->state;
1156             yyFreeState(yyerrctx);
1157             yyerrctx       = NULL;
1158         }
1159         yynewerrflag = 1;
1160     }
1161     if (yynewerrflag == 0) goto yyinrecovery;
1162 #endif /* YYBTYACC */
1163 
1164     YYERROR_CALL("syntax error");
1165 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1166     yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
1167 #endif
1168 
1169 #if !YYBTYACC
1170     goto yyerrlab;
1171 yyerrlab:
1172 #endif
1173     ++yynerrs;
1174 
1175 yyinrecovery:
1176     if (yyerrflag < 3)
1177     {
1178         yyerrflag = 3;
1179         for (;;)
1180         {
1181             if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
1182                     yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
1183             {
1184 #if YYDEBUG
1185                 if (yydebug)
1186                     fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
1187                                     YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
1188 #endif
1189                 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1190                 yystate = yytable[yyn];
1191                 *++yystack.s_mark = yytable[yyn];
1192                 *++yystack.l_mark = yylval;
1193 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1194                 /* lookahead position is error end position */
1195                 yyerror_loc_range[1] = yylloc;
1196                 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
1197                 *++yystack.p_mark = yyloc;
1198 #endif
1199                 goto yyloop;
1200             }
1201             else
1202             {
1203 #if YYDEBUG
1204                 if (yydebug)
1205                     fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
1206                                     YYDEBUGSTR, yydepth, *yystack.s_mark);
1207 #endif
1208                 if (yystack.s_mark <= yystack.s_base) goto yyabort;
1209 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1210                 /* the current TOS position is the error start position */
1211                 yyerror_loc_range[0] = *yystack.p_mark;
1212 #endif
1213 #if defined(YYDESTRUCT_CALL)
1214 #if YYBTYACC
1215                 if (!yytrial)
1216 #endif /* YYBTYACC */
1217 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1218                     YYDESTRUCT_CALL("error: discarding state",
1219                                     yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
1220 #else
1221                     YYDESTRUCT_CALL("error: discarding state",
1222                                     yystos[*yystack.s_mark], yystack.l_mark);
1223 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1224 #endif /* defined(YYDESTRUCT_CALL) */
1225                 --yystack.s_mark;
1226                 --yystack.l_mark;
1227 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1228                 --yystack.p_mark;
1229 #endif
1230             }
1231         }
1232     }
1233     else
1234     {
1235         if (yychar == YYEOF) goto yyabort;
1236 #if YYDEBUG
1237         if (yydebug)
1238         {
1239             yys = yyname[YYTRANSLATE(yychar)];
1240             fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
1241                             YYDEBUGSTR, yydepth, yystate, yychar, yys);
1242         }
1243 #endif
1244 #if defined(YYDESTRUCT_CALL)
1245 #if YYBTYACC
1246         if (!yytrial)
1247 #endif /* YYBTYACC */
1248 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1249             YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
1250 #else
1251             YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
1252 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1253 #endif /* defined(YYDESTRUCT_CALL) */
1254         yychar = YYEMPTY;
1255         goto yyloop;
1256     }
1257 
1258 yyreduce:
1259     yym = yylen[yyn];
1260 #if YYDEBUG
1261     if (yydebug)
1262     {
1263         fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
1264                         YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
1265 #ifdef YYSTYPE_TOSTRING
1266 #if YYBTYACC
1267         if (!yytrial)
1268 #endif /* YYBTYACC */
1269             if (yym > 0)
1270             {
1271                 int i;
1272                 fputc('<', stderr);
1273                 for (i = yym; i > 0; i--)
1274                 {
1275                     if (i != yym) fputs(", ", stderr);
1276                     fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
1277                                            yystack.l_mark[1-i]), stderr);
1278                 }
1279                 fputc('>', stderr);
1280             }
1281 #endif
1282         fputc('\n', stderr);
1283     }
1284 #endif
1285     if (yym > 0)
1286         yyval = yystack.l_mark[1-yym];
1287     else
1288         memset(&yyval, 0, sizeof yyval);
1289 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1290 
1291     /* Perform position reduction */
1292     memset(&yyloc, 0, sizeof(yyloc));
1293 #if YYBTYACC
1294     if (!yytrial)
1295 #endif /* YYBTYACC */
1296     {
1297         YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
1298         /* just in case YYERROR is invoked within the action, save
1299            the start of the rhs as the error start position */
1300         yyerror_loc_range[0] = yystack.p_mark[1-yym];
1301     }
1302 #endif
1303 
1304     switch (yyn)
1305     {
1306 case 3:
1307 #line 57 "calc1.y"
1308 	{
1309 		(void) printf("%15.8f\n", yystack.l_mark[-1].dval);
1310 	}
1311 break;
1312 case 4:
1313 #line 61 "calc1.y"
1314 	{
1315 		(void) printf("(%15.8f, %15.8f)\n", yystack.l_mark[-1].vval.lo, yystack.l_mark[-1].vval.hi);
1316 	}
1317 break;
1318 case 5:
1319 #line 65 "calc1.y"
1320 	{
1321 		dreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].dval;
1322 	}
1323 break;
1324 case 6:
1325 #line 69 "calc1.y"
1326 	{
1327 		vreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].vval;
1328 	}
1329 break;
1330 case 7:
1331 #line 73 "calc1.y"
1332 	{
1333 		yyerrok;
1334 	}
1335 break;
1336 case 9:
1337 #line 80 "calc1.y"
1338 	{
1339 		yyval.dval = dreg[yystack.l_mark[0].ival];
1340 	}
1341 break;
1342 case 10:
1343 #line 84 "calc1.y"
1344 	{
1345 		yyval.dval = yystack.l_mark[-2].dval + yystack.l_mark[0].dval;
1346 	}
1347 break;
1348 case 11:
1349 #line 88 "calc1.y"
1350 	{
1351 		yyval.dval = yystack.l_mark[-2].dval - yystack.l_mark[0].dval;
1352 	}
1353 break;
1354 case 12:
1355 #line 92 "calc1.y"
1356 	{
1357 		yyval.dval = yystack.l_mark[-2].dval * yystack.l_mark[0].dval;
1358 	}
1359 break;
1360 case 13:
1361 #line 96 "calc1.y"
1362 	{
1363 		yyval.dval = yystack.l_mark[-2].dval / yystack.l_mark[0].dval;
1364 	}
1365 break;
1366 case 14:
1367 #line 100 "calc1.y"
1368 	{
1369 		yyval.dval = -yystack.l_mark[0].dval;
1370 	}
1371 break;
1372 case 15:
1373 #line 104 "calc1.y"
1374 	{
1375 		yyval.dval = yystack.l_mark[-1].dval;
1376 	}
1377 break;
1378 case 16:
1379 #line 110 "calc1.y"
1380 	{
1381 		yyval.vval.hi = yyval.vval.lo = yystack.l_mark[0].dval;
1382 	}
1383 break;
1384 case 17:
1385 #line 114 "calc1.y"
1386 	{
1387 		yyval.vval.lo = yystack.l_mark[-3].dval;
1388 		yyval.vval.hi = yystack.l_mark[-1].dval;
1389 		if ( yyval.vval.lo > yyval.vval.hi )
1390 		{
1391 			(void) printf("interval out of order\n");
1392 			YYERROR;
1393 		}
1394 	}
1395 break;
1396 case 18:
1397 #line 124 "calc1.y"
1398 	{
1399 		yyval.vval = vreg[yystack.l_mark[0].ival];
1400 	}
1401 break;
1402 case 19:
1403 #line 128 "calc1.y"
1404 	{
1405 		yyval.vval.hi = yystack.l_mark[-2].vval.hi + yystack.l_mark[0].vval.hi;
1406 		yyval.vval.lo = yystack.l_mark[-2].vval.lo + yystack.l_mark[0].vval.lo;
1407 	}
1408 break;
1409 case 20:
1410 #line 133 "calc1.y"
1411 	{
1412 		yyval.vval.hi = yystack.l_mark[-2].dval + yystack.l_mark[0].vval.hi;
1413 		yyval.vval.lo = yystack.l_mark[-2].dval + yystack.l_mark[0].vval.lo;
1414 	}
1415 break;
1416 case 21:
1417 #line 138 "calc1.y"
1418 	{
1419 		yyval.vval.hi = yystack.l_mark[-2].vval.hi - yystack.l_mark[0].vval.lo;
1420 		yyval.vval.lo = yystack.l_mark[-2].vval.lo - yystack.l_mark[0].vval.hi;
1421 	}
1422 break;
1423 case 22:
1424 #line 143 "calc1.y"
1425 	{
1426 		yyval.vval.hi = yystack.l_mark[-2].dval - yystack.l_mark[0].vval.lo;
1427 		yyval.vval.lo = yystack.l_mark[-2].dval - yystack.l_mark[0].vval.hi;
1428 	}
1429 break;
1430 case 23:
1431 #line 148 "calc1.y"
1432 	{
1433 		yyval.vval = vmul( yystack.l_mark[-2].vval.lo, yystack.l_mark[-2].vval.hi, yystack.l_mark[0].vval );
1434 	}
1435 break;
1436 case 24:
1437 #line 152 "calc1.y"
1438 	{
1439 		yyval.vval = vmul (yystack.l_mark[-2].dval, yystack.l_mark[-2].dval, yystack.l_mark[0].vval );
1440 	}
1441 break;
1442 case 25:
1443 #line 156 "calc1.y"
1444 	{
1445 		if (dcheck(yystack.l_mark[0].vval)) YYERROR;
1446 		yyval.vval = vdiv ( yystack.l_mark[-2].vval.lo, yystack.l_mark[-2].vval.hi, yystack.l_mark[0].vval );
1447 	}
1448 break;
1449 case 26:
1450 #line 161 "calc1.y"
1451 	{
1452 		if (dcheck ( yystack.l_mark[0].vval )) YYERROR;
1453 		yyval.vval = vdiv (yystack.l_mark[-2].dval, yystack.l_mark[-2].dval, yystack.l_mark[0].vval );
1454 	}
1455 break;
1456 case 27:
1457 #line 166 "calc1.y"
1458 	{
1459 		yyval.vval.hi = -yystack.l_mark[0].vval.lo;
1460 		yyval.vval.lo = -yystack.l_mark[0].vval.hi;
1461 	}
1462 break;
1463 case 28:
1464 #line 171 "calc1.y"
1465 	{
1466 		yyval.vval = yystack.l_mark[-1].vval;
1467 	}
1468 break;
1469 #line 1470 "calc1.tab.c"
1470     default:
1471         break;
1472     }
1473     yystack.s_mark -= yym;
1474     yystate = *yystack.s_mark;
1475     yystack.l_mark -= yym;
1476 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1477     yystack.p_mark -= yym;
1478 #endif
1479     yym = yylhs[yyn];
1480     if (yystate == 0 && yym == 0)
1481     {
1482 #if YYDEBUG
1483         if (yydebug)
1484         {
1485             fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1486 #ifdef YYSTYPE_TOSTRING
1487 #if YYBTYACC
1488             if (!yytrial)
1489 #endif /* YYBTYACC */
1490                 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
1491 #endif
1492             fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
1493         }
1494 #endif
1495         yystate = YYFINAL;
1496         *++yystack.s_mark = YYFINAL;
1497         *++yystack.l_mark = yyval;
1498 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1499         *++yystack.p_mark = yyloc;
1500 #endif
1501         if (yychar < 0)
1502         {
1503 #if YYBTYACC
1504             do {
1505             if (yylvp < yylve)
1506             {
1507                 /* we're currently re-reading tokens */
1508                 yylval = *yylvp++;
1509 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1510                 yylloc = *yylpp++;
1511 #endif
1512                 yychar = *yylexp++;
1513                 break;
1514             }
1515             if (yyps->save)
1516             {
1517                 /* in trial mode; save scanner results for future parse attempts */
1518                 if (yylvp == yylvlim)
1519                 {   /* Enlarge lexical value queue */
1520                     size_t p = (size_t) (yylvp - yylvals);
1521                     size_t s = (size_t) (yylvlim - yylvals);
1522 
1523                     s += YYLVQUEUEGROWTH;
1524                     if ((yylexemes = (short *)   realloc(yylexemes, s * sizeof(short))) == NULL)
1525                         goto yyenomem;
1526                     if ((yylvals   = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
1527                         goto yyenomem;
1528 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1529                     if ((yylpsns   = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
1530                         goto yyenomem;
1531 #endif
1532                     yylvp   = yylve = yylvals + p;
1533                     yylvlim = yylvals + s;
1534 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1535                     yylpp   = yylpe = yylpsns + p;
1536                     yylplim = yylpsns + s;
1537 #endif
1538                     yylexp  = yylexemes + p;
1539                 }
1540                 *yylexp = (short) YYLEX;
1541                 *yylvp++ = yylval;
1542                 yylve++;
1543 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1544                 *yylpp++ = yylloc;
1545                 yylpe++;
1546 #endif
1547                 yychar = *yylexp++;
1548                 break;
1549             }
1550             /* normal operation, no conflict encountered */
1551 #endif /* YYBTYACC */
1552             yychar = YYLEX;
1553 #if YYBTYACC
1554             } while (0);
1555 #endif /* YYBTYACC */
1556             if (yychar < 0) yychar = YYEOF;
1557             /* if ((yychar = YYLEX) < 0) yychar = YYEOF; */
1558 #if YYDEBUG
1559             if (yydebug)
1560             {
1561                 yys = yyname[YYTRANSLATE(yychar)];
1562                 fprintf(stderr, "%s[%d]: state %d, reading %d (%s)\n",
1563                                 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
1564             }
1565 #endif
1566         }
1567         if (yychar == YYEOF) goto yyaccept;
1568         goto yyloop;
1569     }
1570     if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
1571             yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
1572         yystate = yytable[yyn];
1573     else
1574         yystate = yydgoto[yym];
1575 #if YYDEBUG
1576     if (yydebug)
1577     {
1578         fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1579 #ifdef YYSTYPE_TOSTRING
1580 #if YYBTYACC
1581         if (!yytrial)
1582 #endif /* YYBTYACC */
1583             fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
1584 #endif
1585         fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
1586     }
1587 #endif
1588     if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1589     *++yystack.s_mark = (short) yystate;
1590     *++yystack.l_mark = yyval;
1591 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1592     *++yystack.p_mark = yyloc;
1593 #endif
1594     goto yyloop;
1595 #if YYBTYACC
1596 
1597     /* Reduction declares that this path is valid. Set yypath and do a full parse */
1598 yyvalid:
1599     if (yypath) YYABORT;
1600     while (yyps->save)
1601     {
1602         YYParseState *save = yyps->save;
1603         yyps->save = save->save;
1604         save->save = yypath;
1605         yypath = save;
1606     }
1607 #if YYDEBUG
1608     if (yydebug)
1609         fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
1610                         YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
1611 #endif
1612     if (yyerrctx)
1613     {
1614         yyFreeState(yyerrctx);
1615         yyerrctx = NULL;
1616     }
1617     yylvp          = yylvals + yypath->lexeme;
1618 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1619     yylpp          = yylpsns + yypath->lexeme;
1620 #endif
1621     yylexp         = yylexemes + yypath->lexeme;
1622     yychar         = YYEMPTY;
1623     yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
1624     memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
1625     yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
1626     memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1627 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1628     yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
1629     memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1630 #endif
1631     yystate        = yypath->state;
1632     goto yyloop;
1633 #endif /* YYBTYACC */
1634 
1635 yyoverflow:
1636     YYERROR_CALL("yacc stack overflow");
1637 #if YYBTYACC
1638     goto yyabort_nomem;
1639 yyenomem:
1640     YYERROR_CALL("memory exhausted");
1641 yyabort_nomem:
1642 #endif /* YYBTYACC */
1643     yyresult = 2;
1644     goto yyreturn;
1645 
1646 yyabort:
1647     yyresult = 1;
1648     goto yyreturn;
1649 
1650 yyaccept:
1651 #if YYBTYACC
1652     if (yyps->save) goto yyvalid;
1653 #endif /* YYBTYACC */
1654     yyresult = 0;
1655 
1656 yyreturn:
1657 #if defined(YYDESTRUCT_CALL)
1658     if (yychar != YYEOF && yychar != YYEMPTY)
1659 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1660         YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
1661 #else
1662         YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
1663 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1664 
1665     {
1666         YYSTYPE *pv;
1667 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1668         YYLTYPE *pp;
1669 
1670         for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
1671              YYDESTRUCT_CALL("cleanup: discarding state",
1672                              yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
1673 #else
1674         for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
1675              YYDESTRUCT_CALL("cleanup: discarding state",
1676                              yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
1677 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1678     }
1679 #endif /* defined(YYDESTRUCT_CALL) */
1680 
1681 #if YYBTYACC
1682     if (yyerrctx)
1683     {
1684         yyFreeState(yyerrctx);
1685         yyerrctx = NULL;
1686     }
1687     while (yyps)
1688     {
1689         YYParseState *save = yyps;
1690         yyps = save->save;
1691         save->save = NULL;
1692         yyFreeState(save);
1693     }
1694     while (yypath)
1695     {
1696         YYParseState *save = yypath;
1697         yypath = save->save;
1698         save->save = NULL;
1699         yyFreeState(save);
1700     }
1701 #endif /* YYBTYACC */
1702     yyfreestack(&yystack);
1703     return (yyresult);
1704 }
1705