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