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