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