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