Imported Upstream version 20101229
[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
116 int dcheck(INTERVAL);
117
118 double dreg[26];
119 INTERVAL vreg[26];
120
121 #line 28 "calc1.y"
122 #ifdef YYSTYPE
123 #undef  YYSTYPE_IS_DECLARED
124 #define YYSTYPE_IS_DECLARED 1
125 #endif
126 #ifndef YYSTYPE_IS_DECLARED
127 #define YYSTYPE_IS_DECLARED 1
128 typedef union
129 {
130         int ival;
131         double dval;
132         INTERVAL vval;
133 } YYSTYPE;
134 #endif /* !YYSTYPE_IS_DECLARED */
135 #line 136 "calc1.tab.c"
136 /* compatibility with bison */
137 #ifdef YYPARSE_PARAM
138 /* compatibility with FreeBSD */
139 # ifdef YYPARSE_PARAM_TYPE
140 #  define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
141 # else
142 #  define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
143 # endif
144 #else
145 # define YYPARSE_DECL() yyparse(void)
146 #endif
147
148 /* Parameters sent to lex. */
149 #ifdef YYLEX_PARAM
150 # define YYLEX_DECL() yylex(void *YYLEX_PARAM)
151 # define YYLEX yylex(YYLEX_PARAM)
152 #else
153 # define YYLEX_DECL() yylex(void)
154 # define YYLEX yylex()
155 #endif
156
157 /* Parameters sent to yyerror. */
158 #define YYERROR_DECL() yyerror(const char *s)
159 #define YYERROR_CALL(msg) yyerror(msg)
160
161 extern int YYPARSE_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 173 "calc1.y"
346         /* beginning of subroutines section */
347
348 #ifdef YYBYACC
349 extern int YYLEX_DECL();
350 static void YYERROR_DECL();
351 #endif
352
353 #define BSZ 50                  /* buffer size for floating point numbers */
354
355         /* lexical analysis */
356
357 static void
358 yyerror(const char *s)
359 {
360     fprintf(stderr, "%s\n", s);
361 }
362
363 int
364 yylex(void)
365 {
366     int c;
367
368     while ((c = getchar()) == ' ')
369     {                           /* skip over blanks */
370     }
371
372     if (isupper(c))
373     {
374         yylval.ival = c - 'A';
375         return (VREG);
376     }
377     if (islower(c))
378     {
379         yylval.ival = c - 'a';
380         return (DREG);
381     }
382
383     if (isdigit(c) || c == '.')
384     {
385         /* gobble up digits, points, exponents */
386         char buf[BSZ + 1], *cp = buf;
387         int dot = 0, expr = 0;
388
389         for (; (cp - buf) < BSZ; ++cp, c = getchar())
390         {
391
392             *cp = c;
393             if (isdigit(c))
394                 continue;
395             if (c == '.')
396             {
397                 if (dot++ || expr)
398                     return ('.');       /* will cause syntax error */
399                 continue;
400             }
401
402             if (c == 'e')
403             {
404                 if (expr++)
405                     return ('e');       /*  will  cause  syntax  error  */
406                 continue;
407             }
408
409             /*  end  of  number  */
410             break;
411         }
412         *cp = '\0';
413
414         if ((cp - buf) >= BSZ)
415             printf("constant  too  long:  truncated\n");
416         else
417             ungetc(c, stdin);   /*  push  back  last  char  read  */
418         yylval.dval = atof(buf);
419         return (CONST);
420     }
421     return (c);
422 }
423
424 static INTERVAL
425 hilo(double a, double b, double c, double d)
426 {
427     /*  returns  the  smallest  interval  containing  a,  b,  c,  and  d  */
428     /*  used  by  *,  /  routines  */
429     INTERVAL v;
430
431     if (a > b)
432     {
433         v.hi = a;
434         v.lo = b;
435     }
436     else
437     {
438         v.hi = b;
439         v.lo = a;
440     }
441
442     if (c > d)
443     {
444         if (c > v.hi)
445             v.hi = c;
446         if (d < v.lo)
447             v.lo = d;
448     }
449     else
450     {
451         if (d > v.hi)
452             v.hi = d;
453         if (c < v.lo)
454             v.lo = c;
455     }
456     return (v);
457 }
458
459 INTERVAL
460 vmul(double a, double b, INTERVAL v)
461 {
462     return (hilo(a * v.hi, a * v.lo, b * v.hi, b * v.lo));
463 }
464
465 int
466 dcheck(INTERVAL v)
467 {
468     if (v.hi >= 0. && v.lo <= 0.)
469     {
470         printf("divisor  interval  contains  0.\n");
471         return (1);
472     }
473     return (0);
474 }
475
476 INTERVAL
477 vdiv(double a, double b, INTERVAL v)
478 {
479     return (hilo(a / v.hi, a / v.lo, b / v.hi, b / v.lo));
480 }
481 #line 482 "calc1.tab.c"
482
483 #if YYDEBUG
484 #include <stdio.h>              /* needed for printf */
485 #endif
486
487 #include <stdlib.h>     /* needed for malloc, etc */
488 #include <string.h>     /* needed for memset */
489
490 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
491 static int yygrowstack(YYSTACKDATA *data)
492 {
493     int i;
494     unsigned newsize;
495     short *newss;
496     YYSTYPE *newvs;
497
498     if ((newsize = data->stacksize) == 0)
499         newsize = YYINITSTACKSIZE;
500     else if (newsize >= YYMAXDEPTH)
501         return -1;
502     else if ((newsize *= 2) > YYMAXDEPTH)
503         newsize = YYMAXDEPTH;
504
505     i = data->s_mark - data->s_base;
506     newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
507     if (newss == 0)
508         return -1;
509
510     data->s_base = newss;
511     data->s_mark = newss + i;
512
513     newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
514     if (newvs == 0)
515         return -1;
516
517     data->l_base = newvs;
518     data->l_mark = newvs + i;
519
520     data->stacksize = newsize;
521     data->s_last = data->s_base + newsize - 1;
522     return 0;
523 }
524
525 #if YYPURE || defined(YY_NO_LEAKS)
526 static void yyfreestack(YYSTACKDATA *data)
527 {
528     free(data->s_base);
529     free(data->l_base);
530     memset(data, 0, sizeof(*data));
531 }
532 #else
533 #define yyfreestack(data) /* nothing */
534 #endif
535
536 #define YYABORT  goto yyabort
537 #define YYREJECT goto yyabort
538 #define YYACCEPT goto yyaccept
539 #define YYERROR  goto yyerrlab
540
541 int
542 YYPARSE_DECL()
543 {
544     int yym, yyn, yystate;
545 #if YYDEBUG
546     const char *yys;
547
548     if ((yys = getenv("YYDEBUG")) != 0)
549     {
550         yyn = *yys;
551         if (yyn >= '0' && yyn <= '9')
552             yydebug = yyn - '0';
553     }
554 #endif
555
556     yynerrs = 0;
557     yyerrflag = 0;
558     yychar = YYEMPTY;
559     yystate = 0;
560
561 #if YYPURE
562     memset(&yystack, 0, sizeof(yystack));
563 #endif
564
565     if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
566     yystack.s_mark = yystack.s_base;
567     yystack.l_mark = yystack.l_base;
568     yystate = 0;
569     *yystack.s_mark = 0;
570
571 yyloop:
572     if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
573     if (yychar < 0)
574     {
575         if ((yychar = YYLEX) < 0) yychar = 0;
576 #if YYDEBUG
577         if (yydebug)
578         {
579             yys = 0;
580             if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
581             if (!yys) yys = "illegal-symbol";
582             printf("%sdebug: state %d, reading %d (%s)\n",
583                     YYPREFIX, yystate, yychar, yys);
584         }
585 #endif
586     }
587     if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
588             yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
589     {
590 #if YYDEBUG
591         if (yydebug)
592             printf("%sdebug: state %d, shifting to state %d\n",
593                     YYPREFIX, yystate, yytable[yyn]);
594 #endif
595         if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
596         {
597             goto yyoverflow;
598         }
599         yystate = yytable[yyn];
600         *++yystack.s_mark = yytable[yyn];
601         *++yystack.l_mark = yylval;
602         yychar = YYEMPTY;
603         if (yyerrflag > 0)  --yyerrflag;
604         goto yyloop;
605     }
606     if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
607             yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
608     {
609         yyn = yytable[yyn];
610         goto yyreduce;
611     }
612     if (yyerrflag) goto yyinrecovery;
613
614     yyerror("syntax error");
615
616     goto yyerrlab;
617
618 yyerrlab:
619     ++yynerrs;
620
621 yyinrecovery:
622     if (yyerrflag < 3)
623     {
624         yyerrflag = 3;
625         for (;;)
626         {
627             if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
628                     yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
629             {
630 #if YYDEBUG
631                 if (yydebug)
632                     printf("%sdebug: state %d, error recovery shifting\
633  to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
634 #endif
635                 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
636                 {
637                     goto yyoverflow;
638                 }
639                 yystate = yytable[yyn];
640                 *++yystack.s_mark = yytable[yyn];
641                 *++yystack.l_mark = yylval;
642                 goto yyloop;
643             }
644             else
645             {
646 #if YYDEBUG
647                 if (yydebug)
648                     printf("%sdebug: error recovery discarding state %d\n",
649                             YYPREFIX, *yystack.s_mark);
650 #endif
651                 if (yystack.s_mark <= yystack.s_base) goto yyabort;
652                 --yystack.s_mark;
653                 --yystack.l_mark;
654             }
655         }
656     }
657     else
658     {
659         if (yychar == 0) goto yyabort;
660 #if YYDEBUG
661         if (yydebug)
662         {
663             yys = 0;
664             if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
665             if (!yys) yys = "illegal-symbol";
666             printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
667                     YYPREFIX, yystate, yychar, yys);
668         }
669 #endif
670         yychar = YYEMPTY;
671         goto yyloop;
672     }
673
674 yyreduce:
675 #if YYDEBUG
676     if (yydebug)
677         printf("%sdebug: state %d, reducing by rule %d (%s)\n",
678                 YYPREFIX, yystate, yyn, yyrule[yyn]);
679 #endif
680     yym = yylen[yyn];
681     if (yym)
682         yyval = yystack.l_mark[1-yym];
683     else
684         memset(&yyval, 0, sizeof yyval);
685     switch (yyn)
686     {
687 case 3:
688 #line 54 "calc1.y"
689         {
690                 (void) printf("%15.8f\n", yystack.l_mark[-1].dval);
691         }
692 break;
693 case 4:
694 #line 58 "calc1.y"
695         {
696                 (void) printf("(%15.8f, %15.8f)\n", yystack.l_mark[-1].vval.lo, yystack.l_mark[-1].vval.hi);
697         }
698 break;
699 case 5:
700 #line 62 "calc1.y"
701         {
702                 dreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].dval;
703         }
704 break;
705 case 6:
706 #line 66 "calc1.y"
707         {
708                 vreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].vval;
709         }
710 break;
711 case 7:
712 #line 70 "calc1.y"
713         {
714                 yyerrok;
715         }
716 break;
717 case 9:
718 #line 77 "calc1.y"
719         {
720                 yyval.dval = dreg[yystack.l_mark[0].ival];
721         }
722 break;
723 case 10:
724 #line 81 "calc1.y"
725         {
726                 yyval.dval = yystack.l_mark[-2].dval + yystack.l_mark[0].dval;
727         }
728 break;
729 case 11:
730 #line 85 "calc1.y"
731         {
732                 yyval.dval = yystack.l_mark[-2].dval - yystack.l_mark[0].dval;
733         }
734 break;
735 case 12:
736 #line 89 "calc1.y"
737         {
738                 yyval.dval = yystack.l_mark[-2].dval * yystack.l_mark[0].dval;
739         }
740 break;
741 case 13:
742 #line 93 "calc1.y"
743         {
744                 yyval.dval = yystack.l_mark[-2].dval / yystack.l_mark[0].dval;
745         }
746 break;
747 case 14:
748 #line 97 "calc1.y"
749         {
750                 yyval.dval = -yystack.l_mark[0].dval;
751         }
752 break;
753 case 15:
754 #line 101 "calc1.y"
755         {
756                 yyval.dval = yystack.l_mark[-1].dval;
757         }
758 break;
759 case 16:
760 #line 107 "calc1.y"
761         {
762                 yyval.vval.hi = yyval.vval.lo = yystack.l_mark[0].dval;
763         }
764 break;
765 case 17:
766 #line 111 "calc1.y"
767         {
768                 yyval.vval.lo = yystack.l_mark[-3].dval;
769                 yyval.vval.hi = yystack.l_mark[-1].dval;
770                 if ( yyval.vval.lo > yyval.vval.hi ) 
771                 {
772                         (void) printf("interval out of order\n");
773                         YYERROR;
774                 }
775         }
776 break;
777 case 18:
778 #line 121 "calc1.y"
779         {
780                 yyval.vval = vreg[yystack.l_mark[0].ival];
781         }
782 break;
783 case 19:
784 #line 125 "calc1.y"
785         {
786                 yyval.vval.hi = yystack.l_mark[-2].vval.hi + yystack.l_mark[0].vval.hi;
787                 yyval.vval.lo = yystack.l_mark[-2].vval.lo + yystack.l_mark[0].vval.lo;
788         }
789 break;
790 case 20:
791 #line 130 "calc1.y"
792         {
793                 yyval.vval.hi = yystack.l_mark[-2].dval + yystack.l_mark[0].vval.hi;
794                 yyval.vval.lo = yystack.l_mark[-2].dval + yystack.l_mark[0].vval.lo;
795         }
796 break;
797 case 21:
798 #line 135 "calc1.y"
799         {
800                 yyval.vval.hi = yystack.l_mark[-2].vval.hi - yystack.l_mark[0].vval.lo;
801                 yyval.vval.lo = yystack.l_mark[-2].vval.lo - yystack.l_mark[0].vval.hi;
802         }
803 break;
804 case 22:
805 #line 140 "calc1.y"
806         {
807                 yyval.vval.hi = yystack.l_mark[-2].dval - yystack.l_mark[0].vval.lo;
808                 yyval.vval.lo = yystack.l_mark[-2].dval - yystack.l_mark[0].vval.hi;
809         }
810 break;
811 case 23:
812 #line 145 "calc1.y"
813         {
814                 yyval.vval = vmul( yystack.l_mark[-2].vval.lo, yystack.l_mark[-2].vval.hi, yystack.l_mark[0].vval );
815         }
816 break;
817 case 24:
818 #line 149 "calc1.y"
819         {
820                 yyval.vval = vmul (yystack.l_mark[-2].dval, yystack.l_mark[-2].dval, yystack.l_mark[0].vval );
821         }
822 break;
823 case 25:
824 #line 153 "calc1.y"
825         {
826                 if (dcheck(yystack.l_mark[0].vval)) YYERROR;
827                 yyval.vval = vdiv ( yystack.l_mark[-2].vval.lo, yystack.l_mark[-2].vval.hi, yystack.l_mark[0].vval );
828         }
829 break;
830 case 26:
831 #line 158 "calc1.y"
832         {
833                 if (dcheck ( yystack.l_mark[0].vval )) YYERROR;
834                 yyval.vval = vdiv (yystack.l_mark[-2].dval, yystack.l_mark[-2].dval, yystack.l_mark[0].vval );
835         }
836 break;
837 case 27:
838 #line 163 "calc1.y"
839         {
840                 yyval.vval.hi = -yystack.l_mark[0].vval.lo;
841                 yyval.vval.lo = -yystack.l_mark[0].vval.hi;
842         }
843 break;
844 case 28:
845 #line 168 "calc1.y"
846         {
847                 yyval.vval = yystack.l_mark[-1].vval;
848         }
849 break;
850 #line 851 "calc1.tab.c"
851     }
852     yystack.s_mark -= yym;
853     yystate = *yystack.s_mark;
854     yystack.l_mark -= yym;
855     yym = yylhs[yyn];
856     if (yystate == 0 && yym == 0)
857     {
858 #if YYDEBUG
859         if (yydebug)
860             printf("%sdebug: after reduction, shifting from state 0 to\
861  state %d\n", YYPREFIX, YYFINAL);
862 #endif
863         yystate = YYFINAL;
864         *++yystack.s_mark = YYFINAL;
865         *++yystack.l_mark = yyval;
866         if (yychar < 0)
867         {
868             if ((yychar = YYLEX) < 0) yychar = 0;
869 #if YYDEBUG
870             if (yydebug)
871             {
872                 yys = 0;
873                 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
874                 if (!yys) yys = "illegal-symbol";
875                 printf("%sdebug: state %d, reading %d (%s)\n",
876                         YYPREFIX, YYFINAL, yychar, yys);
877             }
878 #endif
879         }
880         if (yychar == 0) goto yyaccept;
881         goto yyloop;
882     }
883     if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
884             yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
885         yystate = yytable[yyn];
886     else
887         yystate = yydgoto[yym];
888 #if YYDEBUG
889     if (yydebug)
890         printf("%sdebug: after reduction, shifting from state %d \
891 to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
892 #endif
893     if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
894     {
895         goto yyoverflow;
896     }
897     *++yystack.s_mark = (short) yystate;
898     *++yystack.l_mark = yyval;
899     goto yyloop;
900
901 yyoverflow:
902     yyerror("yacc stack overflow");
903
904 yyabort:
905     yyfreestack(&yystack);
906     return (1);
907
908 yyaccept:
909     yyfreestack(&yystack);
910     return (0);
911 }