varsyntax_calc1.tab.c revision 1.1 1 /* $NetBSD: varsyntax_calc1.tab.c,v 1.1 2015/01/03 22:58:25 christos Exp $ */
2
3 /* original parser id follows */
4 /* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */
5 /* (use YYMAJOR/YYMINOR for ifdefs dependent of parser version) */
6
7 #define YYBYACC 1
8 #define YYMAJOR 1
9 #define YYMINOR 9
10 #define YYCHECK "yyyymmdd"
11
12 #define YYEMPTY (-1)
13 #define yyclearin (yychar = YYEMPTY)
14 #define yyerrok (yyerrflag = 0)
15 #define YYRECOVERING() (yyerrflag != 0)
16 #define YYENOMEM (-2)
17 #define YYEOF 0
18 #ident "check variant syntax features"
19 #undef YYBTYACC
20 #define YYBTYACC 0
21 #define YYDEBUGSTR YYPREFIX "debug"
22
23 #ifndef yyparse
24 #define yyparse varsyntax_calc1_parse
25 #endif /* yyparse */
26
27 #ifndef yylex
28 #define yylex varsyntax_calc1_lex
29 #endif /* yylex */
30
31 #ifndef yyerror
32 #define yyerror varsyntax_calc1_error
33 #endif /* yyerror */
34
35 #ifndef yychar
36 #define yychar varsyntax_calc1_char
37 #endif /* yychar */
38
39 #ifndef yyval
40 #define yyval varsyntax_calc1_val
41 #endif /* yyval */
42
43 #ifndef yylval
44 #define yylval varsyntax_calc1_lval
45 #endif /* yylval */
46
47 #ifndef yydebug
48 #define yydebug varsyntax_calc1_debug
49 #endif /* yydebug */
50
51 #ifndef yynerrs
52 #define yynerrs varsyntax_calc1_nerrs
53 #endif /* yynerrs */
54
55 #ifndef yyerrflag
56 #define yyerrflag varsyntax_calc1_errflag
57 #endif /* yyerrflag */
58
59 #ifndef yylhs
60 #define yylhs varsyntax_calc1_lhs
61 #endif /* yylhs */
62
63 #ifndef yylen
64 #define yylen varsyntax_calc1_len
65 #endif /* yylen */
66
67 #ifndef yydefred
68 #define yydefred varsyntax_calc1_defred
69 #endif /* yydefred */
70
71 #ifndef yystos
72 #define yystos varsyntax_calc1_stos
73 #endif /* yystos */
74
75 #ifndef yydgoto
76 #define yydgoto varsyntax_calc1_dgoto
77 #endif /* yydgoto */
78
79 #ifndef yysindex
80 #define yysindex varsyntax_calc1_sindex
81 #endif /* yysindex */
82
83 #ifndef yyrindex
84 #define yyrindex varsyntax_calc1_rindex
85 #endif /* yyrindex */
86
87 #ifndef yygindex
88 #define yygindex varsyntax_calc1_gindex
89 #endif /* yygindex */
90
91 #ifndef yytable
92 #define yytable varsyntax_calc1_table
93 #endif /* yytable */
94
95 #ifndef yycheck
96 #define yycheck varsyntax_calc1_check
97 #endif /* yycheck */
98
99 #ifndef yyname
100 #define yyname varsyntax_calc1_name
101 #endif /* yyname */
102
103 #ifndef yyrule
104 #define yyrule varsyntax_calc1_rule
105 #endif /* yyrule */
106
107 #if YYBTYACC
108
109 #ifndef yycindex
110 #define yycindex varsyntax_calc1_cindex
111 #endif /* yycindex */
112
113 #ifndef yyctable
114 #define yyctable varsyntax_calc1_ctable
115 #endif /* yyctable */
116
117 #endif /* YYBTYACC */
118
119 #define YYPREFIX "varsyntax_calc1_"
120
121 #define YYPURE 0
122
123 #line 3 "varsyntax_calc1.y"
124
125 /* http://dinosaur.compilertools.net/yacc/index.html * /*/
126
127 #include <stdlib.h>
128 #include <stdio.h>
129 #include <ctype.h>
130 #include <math.h>
131
132 typedef struct interval
133 {
134 double lo, hi;
135 }
136 INTERVAL;
137
138 INTERVAL vmul(double, double, INTERVAL);
139 INTERVAL vdiv(double, double, INTERVAL);
140
141 extern int yylex(void);
142 static void yyerror(const char *s);
143
144 int dcheck(INTERVAL);
145
146 double dreg[26];
147 INTERVAL vreg[26];
148
149 #line 32 "varsyntax_calc1.y"
150 #ifdef YYSTYPE
151 #undef YYSTYPE_IS_DECLARED
152 #define YYSTYPE_IS_DECLARED 1
153 #endif
154 #ifndef YYSTYPE_IS_DECLARED
155 #define YYSTYPE_IS_DECLARED 1
156 typedef union
157 {
158 int ival; /* dreg & vreg array index values*/
159 double dval; /* floating point values*/
160 INTERVAL vval; /* interval values*/
161 } YYSTYPE;
162 #endif /* !YYSTYPE_IS_DECLARED */
163 #line 162 "varsyntax_calc1.tab.c"
164
165 /* compatibility with bison */
166 #ifdef YYPARSE_PARAM
167 /* compatibility with FreeBSD */
168 # ifdef YYPARSE_PARAM_TYPE
169 # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
170 # else
171 # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
172 # endif
173 #else
174 # define YYPARSE_DECL() yyparse(void)
175 #endif
176
177 /* Parameters sent to lex. */
178 #ifdef YYLEX_PARAM
179 # define YYLEX_DECL() yylex(void *YYLEX_PARAM)
180 # define YYLEX yylex(YYLEX_PARAM)
181 #else
182 # define YYLEX_DECL() yylex(void)
183 # define YYLEX yylex()
184 #endif
185
186 /* Parameters sent to yyerror. */
187 #ifndef YYERROR_DECL
188 #define YYERROR_DECL() yyerror(const char *s)
189 #endif
190 #ifndef YYERROR_CALL
191 #define YYERROR_CALL(msg) yyerror(msg)
192 #endif
193
194 extern int YYPARSE_DECL();
195
196 #define DREG 257
197 #define VREG 258
198 #define CONST 259
199 #define UMINUS 260
200 #define YYERRCODE 256
201 typedef short YYINT;
202 static const YYINT varsyntax_calc1_lhs[] = { -1,
203 3, 3, 0, 0, 0, 0, 0, 1, 1, 1,
204 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
205 2, 2, 2, 2, 2, 2, 2, 2,
206 };
207 static const YYINT varsyntax_calc1_len[] = { 2,
208 0, 2, 2, 2, 4, 4, 2, 1, 1, 3,
209 3, 3, 3, 2, 3, 1, 5, 1, 3, 3,
210 3, 3, 3, 3, 3, 3, 2, 3,
211 };
212 static const YYINT varsyntax_calc1_defred[] = { 0,
213 0, 0, 0, 8, 0, 0, 0, 0, 0, 7,
214 0, 0, 9, 18, 14, 27, 0, 0, 0, 0,
215 0, 0, 3, 0, 0, 0, 0, 4, 0, 0,
216 0, 0, 0, 15, 0, 28, 0, 0, 0, 0,
217 12, 24, 13, 26, 0, 0, 23, 25, 14, 0,
218 0, 0, 0, 0, 5, 6, 0, 0, 0, 12,
219 13, 17,
220 };
221 static const YYINT varsyntax_calc1_stos[] = { 0,
222 256, 257, 258, 259, 45, 40, 262, 263, 264, 10,
223 61, 61, 257, 258, 263, 264, 263, 264, 43, 45,
224 42, 47, 10, 43, 45, 42, 47, 10, 45, 40,
225 263, 263, 264, 41, 44, 41, 263, 264, 263, 264,
226 263, 264, 263, 264, 264, 264, 264, 264, 263, 263,
227 43, 45, 42, 47, 10, 10, 263, 263, 263, 263,
228 263, 41,
229 };
230 static const YYINT varsyntax_calc1_dgoto[] = { 7,
231 32, 9, 0,
232 };
233 static const YYINT varsyntax_calc1_sindex[] = { -40,
234 -8, -48, -47, 0, -37, -37, 0, 2, 17, 0,
235 -34, -37, 0, 0, 0, 0, -25, 90, -37, -37,
236 -37, -37, 0, -37, -37, -37, -37, 0, -34, -34,
237 25, 125, 31, 0, -34, 0, -11, 37, -11, 37,
238 0, 0, 0, 0, 37, 37, 0, 0, 0, 111,
239 -34, -34, -34, -34, 0, 0, 118, 69, 69, 0,
240 0, 0,
241 };
242 static const YYINT varsyntax_calc1_rindex[] = { 0,
243 0, 38, 44, 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, -9, 0, 0, 0, 0, 51, -3, 56, 61,
247 0, 0, 0, 0, 67, 72, 0, 0, 0, 0,
248 0, 0, 0, 0, 0, 0, 0, 78, 83, 0,
249 0, 0,
250 };
251 #if YYBTYACC
252 static const YYINT varsyntax_calc1_cindex[] = { 0,
253 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
254 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
255 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
256 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
257 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
258 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
259 0, 0,
260 };
261 #endif
262 static const YYINT varsyntax_calc1_gindex[] = { 0,
263 4, 124, 0,
264 };
265 #define YYTABLESIZE 225
266 static const YYINT varsyntax_calc1_table[] = { 6,
267 16, 10, 6, 8, 5, 30, 20, 5, 15, 17,
268 29, 23, 11, 12, 31, 34, 21, 19, 35, 20,
269 0, 22, 37, 39, 41, 43, 28, 0, 0, 0,
270 21, 16, 49, 50, 55, 22, 0, 20, 57, 20,
271 56, 20, 0, 21, 19, 0, 20, 9, 22, 0,
272 0, 0, 0, 18, 58, 59, 60, 61, 26, 24,
273 10, 25, 0, 27, 0, 11, 53, 51, 0, 52,
274 22, 54, 26, 24, 0, 25, 19, 27, 26, 9,
275 9, 21, 9, 27, 9, 18, 18, 10, 18, 0,
276 18, 10, 11, 10, 10, 10, 11, 0, 11, 11,
277 11, 22, 0, 22, 0, 22, 0, 19, 0, 19,
278 53, 19, 21, 0, 21, 54, 21, 0, 10, 0,
279 10, 0, 10, 11, 0, 11, 0, 11, 16, 18,
280 36, 26, 24, 0, 25, 33, 27, 0, 0, 0,
281 0, 0, 38, 40, 42, 44, 0, 45, 46, 47,
282 48, 34, 53, 51, 0, 52, 0, 54, 62, 53,
283 51, 0, 52, 0, 54, 0, 21, 19, 0, 20,
284 0, 22, 0, 0, 0, 0, 0, 0, 0, 0,
285 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
286 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
287 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
288 0, 0, 0, 0, 0, 1, 2, 3, 4, 13,
289 14, 4, 13, 0, 4,
290 };
291 static const YYINT varsyntax_calc1_check[] = { 40,
292 10, 10, 40, 0, 45, 40, 10, 45, 5, 6,
293 45, 10, 61, 61, 11, 41, 42, 43, 44, 45,
294 -1, 47, 19, 20, 21, 22, 10, -1, -1, -1,
295 42, 41, 29, 30, 10, 47, -1, 41, 35, 43,
296 10, 45, -1, 42, 43, -1, 45, 10, 47, -1,
297 -1, -1, -1, 10, 51, 52, 53, 54, 42, 43,
298 10, 45, -1, 47, -1, 10, 42, 43, -1, 45,
299 10, 47, 42, 43, -1, 45, 10, 47, 42, 42,
300 43, 10, 45, 47, 47, 42, 43, 10, 45, -1,
301 47, 41, 10, 43, 44, 45, 41, -1, 43, 44,
302 45, 41, -1, 43, -1, 45, -1, 41, -1, 43,
303 42, 45, 41, -1, 43, 47, 45, -1, 41, -1,
304 43, -1, 45, 41, -1, 43, -1, 45, 5, 6,
305 41, 42, 43, -1, 45, 12, 47, -1, -1, -1,
306 -1, -1, 19, 20, 21, 22, -1, 24, 25, 26,
307 27, 41, 42, 43, -1, 45, -1, 47, 41, 42,
308 43, -1, 45, -1, 47, -1, 42, 43, -1, 45,
309 -1, 47, -1, -1, -1, -1, -1, -1, -1, -1,
310 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
311 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
312 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
313 -1, -1, -1, -1, -1, 256, 257, 258, 259, 257,
314 258, 259, 257, -1, 259,
315 };
316 #if YYBTYACC
317 static const YYINT varsyntax_calc1_ctable[] = { -1,
318 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
319 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
320 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
321 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
322 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
323 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
324 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
325 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
326 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
327 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
328 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
329 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
330 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
331 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
332 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
333 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
334 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
335 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
336 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
337 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
338 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
339 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
340 -1, -1, -1, -1,
341 };
342 #endif
343 #define YYFINAL 7
344 #ifndef YYDEBUG
345 #define YYDEBUG 0
346 #endif
347 #define YYMAXTOKEN 260
348 #define YYUNDFTOKEN 266
349 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
350 #if YYDEBUG
351 static const char *const varsyntax_calc1_name[] = {
352
353 "$end",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,0,0,0,
354 0,0,0,0,0,0,"'('","')'","'*'","'+'","','","'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0,0,0,
355 0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
356 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
357 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
358 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
359 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
360 "error","DREG","VREG","CONST","UMINUS","$accept","line","dexp","vexp","lines",
361 "illegal-symbol",
362 };
363 static const char *const varsyntax_calc1_rule[] = {
364 "$accept : line",
365 "lines :",
366 "lines : lines line",
367 "line : dexp '\\n'",
368 "line : vexp '\\n'",
369 "line : DREG '=' dexp '\\n'",
370 "line : VREG '=' vexp '\\n'",
371 "line : error '\\n'",
372 "dexp : CONST",
373 "dexp : DREG",
374 "dexp : dexp '+' dexp",
375 "dexp : dexp '-' dexp",
376 "dexp : dexp '*' dexp",
377 "dexp : dexp '/' dexp",
378 "dexp : '-' dexp",
379 "dexp : '(' dexp ')'",
380 "vexp : dexp",
381 "vexp : '(' dexp ',' dexp ')'",
382 "vexp : VREG",
383 "vexp : vexp '+' vexp",
384 "vexp : dexp '+' vexp",
385 "vexp : vexp '-' vexp",
386 "vexp : dexp '-' vexp",
387 "vexp : vexp '*' vexp",
388 "vexp : dexp '*' vexp",
389 "vexp : vexp '/' vexp",
390 "vexp : dexp '/' vexp",
391 "vexp : '-' vexp",
392 "vexp : '(' vexp ')'",
393
394 };
395 #endif
396
397 int yydebug;
398 int yynerrs;
399
400 int yyerrflag;
401 int yychar;
402 YYSTYPE yyval;
403 YYSTYPE yylval;
404 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
405 YYLTYPE yyloc; /* position returned by actions */
406 YYLTYPE yylloc; /* position from the lexer */
407 #endif
408
409 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
410 #ifndef YYLLOC_DEFAULT
411 #define YYLLOC_DEFAULT(loc, rhs, n) \
412 do \
413 { \
414 if (n == 0) \
415 { \
416 (loc).first_line = ((rhs)[-1]).last_line; \
417 (loc).first_column = ((rhs)[-1]).last_column; \
418 (loc).last_line = ((rhs)[-1]).last_line; \
419 (loc).last_column = ((rhs)[-1]).last_column; \
420 } \
421 else \
422 { \
423 (loc).first_line = ((rhs)[ 0 ]).first_line; \
424 (loc).first_column = ((rhs)[ 0 ]).first_column; \
425 (loc).last_line = ((rhs)[n-1]).last_line; \
426 (loc).last_column = ((rhs)[n-1]).last_column; \
427 } \
428 } while (0)
429 #endif /* YYLLOC_DEFAULT */
430 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
431 #if YYBTYACC
432
433 #ifndef YYLVQUEUEGROWTH
434 #define YYLVQUEUEGROWTH 32
435 #endif
436 #endif /* YYBTYACC */
437
438 /* define the initial stack-sizes */
439 #ifdef YYSTACKSIZE
440 #undef YYMAXDEPTH
441 #define YYMAXDEPTH YYSTACKSIZE
442 #else
443 #ifdef YYMAXDEPTH
444 #define YYSTACKSIZE YYMAXDEPTH
445 #else
446 #define YYSTACKSIZE 10000
447 #define YYMAXDEPTH 10000
448 #endif
449 #endif
450
451 #ifndef YYINITSTACKSIZE
452 #define YYINITSTACKSIZE 200
453 #endif
454
455 typedef struct {
456 unsigned stacksize;
457 short *s_base;
458 short *s_mark;
459 short *s_last;
460 YYSTYPE *l_base;
461 YYSTYPE *l_mark;
462 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
463 YYLTYPE *p_base;
464 YYLTYPE *p_mark;
465 #endif
466 } YYSTACKDATA;
467 #if YYBTYACC
468
469 struct YYParseState_s
470 {
471 struct YYParseState_s *save; /* Previously saved parser state */
472 YYSTACKDATA yystack; /* saved parser stack */
473 int state; /* saved parser state */
474 int errflag; /* saved error recovery status */
475 int lexeme; /* saved index of the conflict lexeme in the lexical queue */
476 YYINT ctry; /* saved index in yyctable[] for this conflict */
477 };
478 typedef struct YYParseState_s YYParseState;
479 #endif /* YYBTYACC */
480 /* variables for the parser stack */
481 static YYSTACKDATA yystack;
482 #if YYBTYACC
483
484 /* Current parser state */
485 static YYParseState *yyps = 0;
486
487 /* yypath != NULL: do the full parse, starting at *yypath parser state. */
488 static YYParseState *yypath = 0;
489
490 /* Base of the lexical value queue */
491 static YYSTYPE *yylvals = 0;
492
493 /* Current position at lexical value queue */
494 static YYSTYPE *yylvp = 0;
495
496 /* End position of lexical value queue */
497 static YYSTYPE *yylve = 0;
498
499 /* The last allocated position at the lexical value queue */
500 static YYSTYPE *yylvlim = 0;
501
502 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
503 /* Base of the lexical position queue */
504 static YYLTYPE *yylpsns = 0;
505
506 /* Current position at lexical position queue */
507 static YYLTYPE *yylpp = 0;
508
509 /* End position of lexical position queue */
510 static YYLTYPE *yylpe = 0;
511
512 /* The last allocated position at the lexical position queue */
513 static YYLTYPE *yylplim = 0;
514 #endif
515
516 /* Current position at lexical token queue */
517 static short *yylexp = 0;
518
519 static short *yylexemes = 0;
520 #endif /* YYBTYACC */
521 #line 178 "varsyntax_calc1.y"
522 /* beginning of subroutines section */
523
524 #define BSZ 50 /* buffer size for floating point numbers */
525
526 /* lexical analysis */
527
528 static void
529 yyerror(const char *s)
530 {
531 fprintf(stderr, "%s\n", s);
532 }
533
534 int
535 yylex(void)
536 {
537 int c;
538
539 while ((c = getchar()) == ' ')
540 { /* skip over blanks */
541 }
542
543 if (isupper(c))
544 {
545 yylval.ival = c - 'A';
546 return (VREG);
547 }
548 if (islower(c))
549 {
550 yylval.ival = c - 'a';
551 return (DREG);
552 }
553
554 if (isdigit(c) || c == '.')
555 {
556 /* gobble up digits, points, exponents */
557 char buf[BSZ + 1], *cp = buf;
558 int dot = 0, expr = 0;
559
560 for (; (cp - buf) < BSZ; ++cp, c = getchar())
561 {
562
563 *cp = (char) c;
564 if (isdigit(c))
565 continue;
566 if (c == '.')
567 {
568 if (dot++ || expr)
569 return ('.'); /* will cause syntax error */
570 continue;
571 }
572
573 if (c == 'e')
574 {
575 if (expr++)
576 return ('e'); /* will cause syntax error */
577 continue;
578 }
579
580 /* end of number */
581 break;
582 }
583 *cp = '\0';
584
585 if ((cp - buf) >= BSZ)
586 printf("constant too long: truncated\n");
587 else
588 ungetc(c, stdin); /* push back last char read */
589 yylval.dval = atof(buf);
590 return (CONST);
591 }
592 return (c);
593 }
594
595 static INTERVAL
596 hilo(double a, double b, double c, double d)
597 {
598 /* returns the smallest interval containing a, b, c, and d */
599 /* used by *, / routines */
600 INTERVAL v;
601
602 if (a > b)
603 {
604 v.hi = a;
605 v.lo = b;
606 }
607 else
608 {
609 v.hi = b;
610 v.lo = a;
611 }
612
613 if (c > d)
614 {
615 if (c > v.hi)
616 v.hi = c;
617 if (d < v.lo)
618 v.lo = d;
619 }
620 else
621 {
622 if (d > v.hi)
623 v.hi = d;
624 if (c < v.lo)
625 v.lo = c;
626 }
627 return (v);
628 }
629
630 INTERVAL
631 vmul(double a, double b, INTERVAL v)
632 {
633 return (hilo(a * v.hi, a * v.lo, b * v.hi, b * v.lo));
634 }
635
636 int
637 dcheck(INTERVAL v)
638 {
639 if (v.hi >= 0. && v.lo <= 0.)
640 {
641 printf("divisor interval contains 0.\n");
642 return (1);
643 }
644 return (0);
645 }
646
647 INTERVAL
648 vdiv(double a, double b, INTERVAL v)
649 {
650 return (hilo(a / v.hi, a / v.lo, b / v.hi, b / v.lo));
651 }
652 #line 651 "varsyntax_calc1.tab.c"
653
654 /* For use in generated program */
655 #define yydepth (int)(yystack.s_mark - yystack.s_base)
656 #if YYBTYACC
657 #define yytrial (yyps->save)
658 #endif /* YYBTYACC */
659
660 #if YYDEBUG
661 #include <stdio.h> /* needed for printf */
662 #endif
663
664 #include <stdlib.h> /* needed for malloc, etc */
665 #include <string.h> /* needed for memset */
666
667 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
668 static int yygrowstack(YYSTACKDATA *data)
669 {
670 int i;
671 unsigned newsize;
672 short *newss;
673 YYSTYPE *newvs;
674 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
675 YYLTYPE *newps;
676 #endif
677
678 if ((newsize = data->stacksize) == 0)
679 newsize = YYINITSTACKSIZE;
680 else if (newsize >= YYMAXDEPTH)
681 return YYENOMEM;
682 else if ((newsize *= 2) > YYMAXDEPTH)
683 newsize = YYMAXDEPTH;
684
685 i = (int) (data->s_mark - data->s_base);
686 newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
687 if (newss == 0)
688 return YYENOMEM;
689
690 data->s_base = newss;
691 data->s_mark = newss + i;
692
693 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
694 if (newvs == 0)
695 return YYENOMEM;
696
697 data->l_base = newvs;
698 data->l_mark = newvs + i;
699
700 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
701 newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps));
702 if (newps == 0)
703 return YYENOMEM;
704
705 data->p_base = newps;
706 data->p_mark = newps + i;
707 #endif
708
709 data->stacksize = newsize;
710 data->s_last = data->s_base + newsize - 1;
711
712 #if YYDEBUG
713 if (yydebug)
714 fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize);
715 #endif
716 return 0;
717 }
718
719 #if YYPURE || defined(YY_NO_LEAKS)
720 static void yyfreestack(YYSTACKDATA *data)
721 {
722 free(data->s_base);
723 free(data->l_base);
724 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
725 free(data->p_base);
726 #endif
727 memset(data, 0, sizeof(*data));
728 }
729 #else
730 #define yyfreestack(data) /* nothing */
731 #endif /* YYPURE || defined(YY_NO_LEAKS) */
732 #if YYBTYACC
733
734 static YYParseState *
735 yyNewState(unsigned size)
736 {
737 YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState));
738 if (p == NULL) return NULL;
739
740 p->yystack.stacksize = size;
741 if (size == 0)
742 {
743 p->yystack.s_base = NULL;
744 p->yystack.l_base = NULL;
745 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
746 p->yystack.p_base = NULL;
747 #endif
748 return p;
749 }
750 p->yystack.s_base = (short *) malloc(size * sizeof(short));
751 if (p->yystack.s_base == NULL) return NULL;
752 p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE));
753 if (p->yystack.l_base == NULL) return NULL;
754 memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE));
755 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
756 p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE));
757 if (p->yystack.p_base == NULL) return NULL;
758 memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE));
759 #endif
760
761 return p;
762 }
763
764 static void
765 yyFreeState(YYParseState *p)
766 {
767 yyfreestack(&p->yystack);
768 free(p);
769 }
770 #endif /* YYBTYACC */
771
772 #define YYABORT goto yyabort
773 #define YYREJECT goto yyabort
774 #define YYACCEPT goto yyaccept
775 #define YYERROR goto yyerrlab
776 #if YYBTYACC
777 #define YYVALID do { if (yyps->save) goto yyvalid; } while(0)
778 #define YYVALID_NESTED do { if (yyps->save && \
779 yyps->save->save == 0) goto yyvalid; } while(0)
780 #endif /* YYBTYACC */
781
782 int
783 YYPARSE_DECL()
784 {
785 int yym, yyn, yystate, yyresult;
786 #if YYBTYACC
787 int yynewerrflag;
788 YYParseState *yyerrctx = NULL;
789 #endif /* YYBTYACC */
790 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
791 YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
792 #endif
793 #if YYDEBUG
794 const char *yys;
795
796 if ((yys = getenv("YYDEBUG")) != 0)
797 {
798 yyn = *yys;
799 if (yyn >= '0' && yyn <= '9')
800 yydebug = yyn - '0';
801 }
802 if (yydebug)
803 fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX);
804 #endif
805
806 #if YYBTYACC
807 yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
808 yyps->save = 0;
809 #endif /* YYBTYACC */
810 yynerrs = 0;
811 yyerrflag = 0;
812 yychar = YYEMPTY;
813 yystate = 0;
814
815 #if YYPURE
816 memset(&yystack, 0, sizeof(yystack));
817 #endif
818
819 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
820 yystack.s_mark = yystack.s_base;
821 yystack.l_mark = yystack.l_base;
822 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
823 yystack.p_mark = yystack.p_base;
824 #endif
825 yystate = 0;
826 *yystack.s_mark = 0;
827
828 yyloop:
829 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
830 if (yychar < 0)
831 {
832 #if YYBTYACC
833 do {
834 if (yylvp < yylve)
835 {
836 /* we're currently re-reading tokens */
837 yylval = *yylvp++;
838 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
839 yylloc = *yylpp++;
840 #endif
841 yychar = *yylexp++;
842 break;
843 }
844 if (yyps->save)
845 {
846 /* in trial mode; save scanner results for future parse attempts */
847 if (yylvp == yylvlim)
848 { /* Enlarge lexical value queue */
849 size_t p = (size_t) (yylvp - yylvals);
850 size_t s = (size_t) (yylvlim - yylvals);
851
852 s += YYLVQUEUEGROWTH;
853 if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem;
854 if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
855 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
856 if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
857 #endif
858 yylvp = yylve = yylvals + p;
859 yylvlim = yylvals + s;
860 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
861 yylpp = yylpe = yylpsns + p;
862 yylplim = yylpsns + s;
863 #endif
864 yylexp = yylexemes + p;
865 }
866 *yylexp = (short) YYLEX;
867 *yylvp++ = yylval;
868 yylve++;
869 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
870 *yylpp++ = yylloc;
871 yylpe++;
872 #endif
873 yychar = *yylexp++;
874 break;
875 }
876 /* normal operation, no conflict encountered */
877 #endif /* YYBTYACC */
878 yychar = YYLEX;
879 #if YYBTYACC
880 } while (0);
881 #endif /* YYBTYACC */
882 if (yychar < 0) yychar = YYEOF;
883 /* if ((yychar = YYLEX) < 0) yychar = YYEOF; */
884 #if YYDEBUG
885 if (yydebug)
886 {
887 yys = yyname[YYTRANSLATE(yychar)];
888 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
889 YYDEBUGSTR, yydepth, yystate, yychar, yys);
890 #ifdef YYSTYPE_TOSTRING
891 #if YYBTYACC
892 if (!yytrial)
893 #endif /* YYBTYACC */
894 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
895 #endif
896 fputc('\n', stderr);
897 }
898 #endif
899 }
900 #if YYBTYACC
901
902 /* Do we have a conflict? */
903 if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
904 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
905 {
906 YYINT ctry;
907
908 if (yypath)
909 {
910 YYParseState *save;
911 #if YYDEBUG
912 if (yydebug)
913 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
914 YYDEBUGSTR, yydepth, yystate);
915 #endif
916 /* Switch to the next conflict context */
917 save = yypath;
918 yypath = save->save;
919 save->save = NULL;
920 ctry = save->ctry;
921 if (save->state != yystate) YYABORT;
922 yyFreeState(save);
923
924 }
925 else
926 {
927
928 /* Unresolved conflict - start/continue trial parse */
929 YYParseState *save;
930 #if YYDEBUG
931 if (yydebug)
932 {
933 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
934 if (yyps->save)
935 fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
936 else
937 fputs("Starting trial parse.\n", stderr);
938 }
939 #endif
940 save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
941 if (save == NULL) goto yyenomem;
942 save->save = yyps->save;
943 save->state = yystate;
944 save->errflag = yyerrflag;
945 save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
946 memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
947 save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
948 memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
949 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
950 save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
951 memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
952 #endif
953 ctry = yytable[yyn];
954 if (yyctable[ctry] == -1)
955 {
956 #if YYDEBUG
957 if (yydebug && yychar >= YYEOF)
958 fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
959 #endif
960 ctry++;
961 }
962 save->ctry = ctry;
963 if (yyps->save == NULL)
964 {
965 /* If this is a first conflict in the stack, start saving lexemes */
966 if (!yylexemes)
967 {
968 yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short));
969 if (yylexemes == NULL) goto yyenomem;
970 yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
971 if (yylvals == NULL) goto yyenomem;
972 yylvlim = yylvals + YYLVQUEUEGROWTH;
973 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
974 yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
975 if (yylpsns == NULL) goto yyenomem;
976 yylplim = yylpsns + YYLVQUEUEGROWTH;
977 #endif
978 }
979 if (yylvp == yylve)
980 {
981 yylvp = yylve = yylvals;
982 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
983 yylpp = yylpe = yylpsns;
984 #endif
985 yylexp = yylexemes;
986 if (yychar >= YYEOF)
987 {
988 *yylve++ = yylval;
989 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
990 *yylpe++ = yylloc;
991 #endif
992 *yylexp = (short) yychar;
993 yychar = YYEMPTY;
994 }
995 }
996 }
997 if (yychar >= YYEOF)
998 {
999 yylvp--;
1000 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1001 yylpp--;
1002 #endif
1003 yylexp--;
1004 yychar = YYEMPTY;
1005 }
1006 save->lexeme = (int) (yylvp - yylvals);
1007 yyps->save = save;
1008 }
1009 if (yytable[yyn] == ctry)
1010 {
1011 #if YYDEBUG
1012 if (yydebug)
1013 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
1014 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
1015 #endif
1016 if (yychar < 0)
1017 {
1018 yylvp++;
1019 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1020 yylpp++;
1021 #endif
1022 yylexp++;
1023 }
1024 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
1025 goto yyoverflow;
1026 yystate = yyctable[ctry];
1027 *++yystack.s_mark = (short) yystate;
1028 *++yystack.l_mark = yylval;
1029 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1030 *++yystack.p_mark = yylloc;
1031 #endif
1032 yychar = YYEMPTY;
1033 if (yyerrflag > 0) --yyerrflag;
1034 goto yyloop;
1035 }
1036 else
1037 {
1038 yyn = yyctable[ctry];
1039 goto yyreduce;
1040 }
1041 } /* End of code dealing with conflicts */
1042 #endif /* YYBTYACC */
1043 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
1044 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
1045 {
1046 #if YYDEBUG
1047 if (yydebug)
1048 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
1049 YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
1050 #endif
1051 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1052 yystate = yytable[yyn];
1053 *++yystack.s_mark = yytable[yyn];
1054 *++yystack.l_mark = yylval;
1055 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1056 *++yystack.p_mark = yylloc;
1057 #endif
1058 yychar = YYEMPTY;
1059 if (yyerrflag > 0) --yyerrflag;
1060 goto yyloop;
1061 }
1062 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
1063 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
1064 {
1065 yyn = yytable[yyn];
1066 goto yyreduce;
1067 }
1068 if (yyerrflag != 0) goto yyinrecovery;
1069 #if YYBTYACC
1070
1071 yynewerrflag = 1;
1072 goto yyerrhandler;
1073 goto yyerrlab;
1074
1075 yyerrlab:
1076 yynewerrflag = 0;
1077 yyerrhandler:
1078 while (yyps->save)
1079 {
1080 int ctry;
1081 YYParseState *save = yyps->save;
1082 #if YYDEBUG
1083 if (yydebug)
1084 fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
1085 YYDEBUGSTR, yydepth, yystate, yyps->save->state,
1086 (int)(yylvp - yylvals - yyps->save->lexeme));
1087 #endif
1088 /* Memorize most forward-looking error state in case it's really an error. */
1089 if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
1090 {
1091 /* Free old saved error context state */
1092 if (yyerrctx) yyFreeState(yyerrctx);
1093 /* Create and fill out new saved error context state */
1094 yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
1095 if (yyerrctx == NULL) goto yyenomem;
1096 yyerrctx->save = yyps->save;
1097 yyerrctx->state = yystate;
1098 yyerrctx->errflag = yyerrflag;
1099 yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
1100 memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
1101 yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
1102 memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1103 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1104 yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
1105 memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1106 #endif
1107 yyerrctx->lexeme = (int) (yylvp - yylvals);
1108 }
1109 yylvp = yylvals + save->lexeme;
1110 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1111 yylpp = yylpsns + save->lexeme;
1112 #endif
1113 yylexp = yylexemes + save->lexeme;
1114 yychar = YYEMPTY;
1115 yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
1116 memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
1117 yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
1118 memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1119 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1120 yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
1121 memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1122 #endif
1123 ctry = ++save->ctry;
1124 yystate = save->state;
1125 /* We tried shift, try reduce now */
1126 if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
1127 yyps->save = save->save;
1128 save->save = NULL;
1129 yyFreeState(save);
1130
1131 /* Nothing left on the stack -- error */
1132 if (!yyps->save)
1133 {
1134 #if YYDEBUG
1135 if (yydebug)
1136 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
1137 YYPREFIX, yydepth);
1138 #endif
1139 /* Restore state as it was in the most forward-advanced error */
1140 yylvp = yylvals + yyerrctx->lexeme;
1141 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1142 yylpp = yylpsns + yyerrctx->lexeme;
1143 #endif
1144 yylexp = yylexemes + yyerrctx->lexeme;
1145 yychar = yylexp[-1];
1146 yylval = yylvp[-1];
1147 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1148 yylloc = yylpp[-1];
1149 #endif
1150 yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
1151 memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
1152 yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
1153 memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1154 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1155 yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
1156 memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1157 #endif
1158 yystate = yyerrctx->state;
1159 yyFreeState(yyerrctx);
1160 yyerrctx = NULL;
1161 }
1162 yynewerrflag = 1;
1163 }
1164 if (yynewerrflag == 0) goto yyinrecovery;
1165 #endif /* YYBTYACC */
1166
1167 YYERROR_CALL("syntax error");
1168 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1169 yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
1170 #endif
1171
1172 #if !YYBTYACC
1173 goto yyerrlab;
1174 yyerrlab:
1175 #endif
1176 ++yynerrs;
1177
1178 yyinrecovery:
1179 if (yyerrflag < 3)
1180 {
1181 yyerrflag = 3;
1182 for (;;)
1183 {
1184 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
1185 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
1186 {
1187 #if YYDEBUG
1188 if (yydebug)
1189 fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
1190 YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
1191 #endif
1192 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1193 yystate = yytable[yyn];
1194 *++yystack.s_mark = yytable[yyn];
1195 *++yystack.l_mark = yylval;
1196 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1197 /* lookahead position is error end position */
1198 yyerror_loc_range[1] = yylloc;
1199 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
1200 *++yystack.p_mark = yyloc;
1201 #endif
1202 goto yyloop;
1203 }
1204 else
1205 {
1206 #if YYDEBUG
1207 if (yydebug)
1208 fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
1209 YYDEBUGSTR, yydepth, *yystack.s_mark);
1210 #endif
1211 if (yystack.s_mark <= yystack.s_base) goto yyabort;
1212 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1213 /* the current TOS position is the error start position */
1214 yyerror_loc_range[0] = *yystack.p_mark;
1215 #endif
1216 #if defined(YYDESTRUCT_CALL)
1217 #if YYBTYACC
1218 if (!yytrial)
1219 #endif /* YYBTYACC */
1220 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1221 YYDESTRUCT_CALL("error: discarding state",
1222 yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
1223 #else
1224 YYDESTRUCT_CALL("error: discarding state",
1225 yystos[*yystack.s_mark], yystack.l_mark);
1226 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1227 #endif /* defined(YYDESTRUCT_CALL) */
1228 --yystack.s_mark;
1229 --yystack.l_mark;
1230 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1231 --yystack.p_mark;
1232 #endif
1233 }
1234 }
1235 }
1236 else
1237 {
1238 if (yychar == YYEOF) goto yyabort;
1239 #if YYDEBUG
1240 if (yydebug)
1241 {
1242 yys = yyname[YYTRANSLATE(yychar)];
1243 fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
1244 YYDEBUGSTR, yydepth, yystate, yychar, yys);
1245 }
1246 #endif
1247 #if defined(YYDESTRUCT_CALL)
1248 #if YYBTYACC
1249 if (!yytrial)
1250 #endif /* YYBTYACC */
1251 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1252 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
1253 #else
1254 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
1255 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1256 #endif /* defined(YYDESTRUCT_CALL) */
1257 yychar = YYEMPTY;
1258 goto yyloop;
1259 }
1260
1261 yyreduce:
1262 yym = yylen[yyn];
1263 #if YYDEBUG
1264 if (yydebug)
1265 {
1266 fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
1267 YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
1268 #ifdef YYSTYPE_TOSTRING
1269 #if YYBTYACC
1270 if (!yytrial)
1271 #endif /* YYBTYACC */
1272 if (yym > 0)
1273 {
1274 int i;
1275 fputc('<', stderr);
1276 for (i = yym; i > 0; i--)
1277 {
1278 if (i != yym) fputs(", ", stderr);
1279 fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
1280 yystack.l_mark[1-i]), stderr);
1281 }
1282 fputc('>', stderr);
1283 }
1284 #endif
1285 fputc('\n', stderr);
1286 }
1287 #endif
1288 if (yym > 0)
1289 yyval = yystack.l_mark[1-yym];
1290 else
1291 memset(&yyval, 0, sizeof yyval);
1292 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1293
1294 /* Perform position reduction */
1295 memset(&yyloc, 0, sizeof(yyloc));
1296 #if YYBTYACC
1297 if (!yytrial)
1298 #endif /* YYBTYACC */
1299 {
1300 YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
1301 /* just in case YYERROR is invoked within the action, save
1302 the start of the rhs as the error start position */
1303 yyerror_loc_range[0] = yystack.p_mark[1-yym];
1304 }
1305 #endif
1306
1307 switch (yyn)
1308 {
1309 case 3:
1310 #line 59 "varsyntax_calc1.y"
1311 {
1312 (void) printf("%15.8f\n", yystack.l_mark[-1].dval);
1313 }
1314 break;
1315 case 4:
1316 #line 63 "varsyntax_calc1.y"
1317 {
1318 (void) printf("(%15.8f, %15.8f)\n", yystack.l_mark[-1].vval.lo, yystack.l_mark[-1].vval.hi);
1319 }
1320 break;
1321 case 5:
1322 #line 67 "varsyntax_calc1.y"
1323 {
1324 dreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].dval;
1325 }
1326 break;
1327 case 6:
1328 #line 71 "varsyntax_calc1.y"
1329 {
1330 vreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].vval;
1331 }
1332 break;
1333 case 7:
1334 #line 75 "varsyntax_calc1.y"
1335 {
1336 yyerrok;
1337 }
1338 break;
1339 case 9:
1340 #line 82 "varsyntax_calc1.y"
1341 {
1342 yyval.dval = dreg[yystack.l_mark[0].ival]; /* $$ & $1 are sufficient here*/
1343 }
1344 break;
1345 case 10:
1346 #line 86 "varsyntax_calc1.y"
1347 {
1348 yyval.dval = yystack.l_mark[-2].dval + yystack.l_mark[0].dval;
1349 }
1350 break;
1351 case 11:
1352 #line 90 "varsyntax_calc1.y"
1353 {
1354 yyval.dval = yystack.l_mark[-2].dval - yystack.l_mark[0].dval;
1355 }
1356 break;
1357 case 12:
1358 #line 94 "varsyntax_calc1.y"
1359 {
1360 yyval.dval = yystack.l_mark[-2].dval * yystack.l_mark[0].dval;
1361 }
1362 break;
1363 case 13:
1364 #line 98 "varsyntax_calc1.y"
1365 {
1366 yyval.dval = yystack.l_mark[-2].dval / yystack.l_mark[0].dval;
1367 }
1368 break;
1369 case 14:
1370 #line 102 "varsyntax_calc1.y"
1371 {
1372 yyval.dval = -yystack.l_mark[0].dval;
1373 }
1374 break;
1375 case 15:
1376 #line 106 "varsyntax_calc1.y"
1377 {
1378 yyval.dval = yystack.l_mark[-1].dval;
1379 }
1380 break;
1381 case 16:
1382 #line 112 "varsyntax_calc1.y"
1383 {
1384 yyval.vval.hi = yyval.vval.lo = yystack.l_mark[0].dval;
1385 }
1386 break;
1387 case 17:
1388 #line 116 "varsyntax_calc1.y"
1389 {
1390 yyval.vval.lo = yystack.l_mark[-3].dval;
1391 yyval.vval.hi = yystack.l_mark[-1].dval;
1392 if ( yyval.vval.lo > yyval.vval.hi )
1393 {
1394 (void) printf("interval out of order\n");
1395 YYERROR;
1396 }
1397 }
1398 break;
1399 case 18:
1400 #line 126 "varsyntax_calc1.y"
1401 {
1402 yyval.vval = vreg[yystack.l_mark[0].ival];
1403 }
1404 break;
1405 case 19:
1406 #line 130 "varsyntax_calc1.y"
1407 {
1408 yyval.vval.hi = yystack.l_mark[-2].vval.hi + yystack.l_mark[0].vval.hi;
1409 yyval.vval.lo = yystack.l_mark[-2].vval.lo + yystack.l_mark[0].vval.lo;
1410 }
1411 break;
1412 case 20:
1413 #line 135 "varsyntax_calc1.y"
1414 {
1415 yyval.vval.hi = yystack.l_mark[-2].dval + yystack.l_mark[0].vval.hi;
1416 yyval.vval.lo = yystack.l_mark[-2].dval + yystack.l_mark[0].vval.lo;
1417 }
1418 break;
1419 case 21:
1420 #line 140 "varsyntax_calc1.y"
1421 {
1422 yyval.vval.hi = yystack.l_mark[-2].vval.hi - yystack.l_mark[0].vval.lo;
1423 yyval.vval.lo = yystack.l_mark[-2].vval.lo - yystack.l_mark[0].vval.hi;
1424 }
1425 break;
1426 case 22:
1427 #line 145 "varsyntax_calc1.y"
1428 {
1429 yyval.vval.hi = yystack.l_mark[-2].dval - yystack.l_mark[0].vval.lo;
1430 yyval.vval.lo = yystack.l_mark[-2].dval - yystack.l_mark[0].vval.hi;
1431 }
1432 break;
1433 case 23:
1434 #line 150 "varsyntax_calc1.y"
1435 {
1436 yyval.vval = vmul( yystack.l_mark[-2].vval.lo, yystack.l_mark[-2].vval.hi, yystack.l_mark[0].vval );
1437 }
1438 break;
1439 case 24:
1440 #line 154 "varsyntax_calc1.y"
1441 {
1442 yyval.vval = vmul (yystack.l_mark[-2].dval, yystack.l_mark[-2].dval, yystack.l_mark[0].vval );
1443 }
1444 break;
1445 case 25:
1446 #line 158 "varsyntax_calc1.y"
1447 {
1448 if (dcheck(yystack.l_mark[0].vval)) YYERROR;
1449 yyval.vval = vdiv ( yystack.l_mark[-2].vval.lo, yystack.l_mark[-2].vval.hi, yystack.l_mark[0].vval );
1450 }
1451 break;
1452 case 26:
1453 #line 163 "varsyntax_calc1.y"
1454 {
1455 if (dcheck ( yystack.l_mark[0].vval )) YYERROR;
1456 yyval.vval = vdiv (yystack.l_mark[-2].dval, yystack.l_mark[-2].dval, yystack.l_mark[0].vval );
1457 }
1458 break;
1459 case 27:
1460 #line 168 "varsyntax_calc1.y"
1461 {
1462 yyval.vval.hi = -yystack.l_mark[0].vval.lo;
1463 yyval.vval.lo = -yystack.l_mark[0].vval.hi;
1464 }
1465 break;
1466 case 28:
1467 #line 173 "varsyntax_calc1.y"
1468 {
1469 yyval.vval = yystack.l_mark[-1].vval;
1470 }
1471 break;
1472 #line 1471 "varsyntax_calc1.tab.c"
1473 default:
1474 break;
1475 }
1476 yystack.s_mark -= yym;
1477 yystate = *yystack.s_mark;
1478 yystack.l_mark -= yym;
1479 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1480 yystack.p_mark -= yym;
1481 #endif
1482 yym = yylhs[yyn];
1483 if (yystate == 0 && yym == 0)
1484 {
1485 #if YYDEBUG
1486 if (yydebug)
1487 {
1488 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1489 #ifdef YYSTYPE_TOSTRING
1490 #if YYBTYACC
1491 if (!yytrial)
1492 #endif /* YYBTYACC */
1493 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
1494 #endif
1495 fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
1496 }
1497 #endif
1498 yystate = YYFINAL;
1499 *++yystack.s_mark = YYFINAL;
1500 *++yystack.l_mark = yyval;
1501 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1502 *++yystack.p_mark = yyloc;
1503 #endif
1504 if (yychar < 0)
1505 {
1506 #if YYBTYACC
1507 do {
1508 if (yylvp < yylve)
1509 {
1510 /* we're currently re-reading tokens */
1511 yylval = *yylvp++;
1512 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1513 yylloc = *yylpp++;
1514 #endif
1515 yychar = *yylexp++;
1516 break;
1517 }
1518 if (yyps->save)
1519 {
1520 /* in trial mode; save scanner results for future parse attempts */
1521 if (yylvp == yylvlim)
1522 { /* Enlarge lexical value queue */
1523 size_t p = (size_t) (yylvp - yylvals);
1524 size_t s = (size_t) (yylvlim - yylvals);
1525
1526 s += YYLVQUEUEGROWTH;
1527 if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL)
1528 goto yyenomem;
1529 if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
1530 goto yyenomem;
1531 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1532 if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
1533 goto yyenomem;
1534 #endif
1535 yylvp = yylve = yylvals + p;
1536 yylvlim = yylvals + s;
1537 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1538 yylpp = yylpe = yylpsns + p;
1539 yylplim = yylpsns + s;
1540 #endif
1541 yylexp = yylexemes + p;
1542 }
1543 *yylexp = (short) YYLEX;
1544 *yylvp++ = yylval;
1545 yylve++;
1546 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1547 *yylpp++ = yylloc;
1548 yylpe++;
1549 #endif
1550 yychar = *yylexp++;
1551 break;
1552 }
1553 /* normal operation, no conflict encountered */
1554 #endif /* YYBTYACC */
1555 yychar = YYLEX;
1556 #if YYBTYACC
1557 } while (0);
1558 #endif /* YYBTYACC */
1559 if (yychar < 0) yychar = YYEOF;
1560 /* if ((yychar = YYLEX) < 0) yychar = YYEOF; */
1561 #if YYDEBUG
1562 if (yydebug)
1563 {
1564 yys = yyname[YYTRANSLATE(yychar)];
1565 fprintf(stderr, "%s[%d]: state %d, reading %d (%s)\n",
1566 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
1567 }
1568 #endif
1569 }
1570 if (yychar == YYEOF) goto yyaccept;
1571 goto yyloop;
1572 }
1573 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
1574 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
1575 yystate = yytable[yyn];
1576 else
1577 yystate = yydgoto[yym];
1578 #if YYDEBUG
1579 if (yydebug)
1580 {
1581 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1582 #ifdef YYSTYPE_TOSTRING
1583 #if YYBTYACC
1584 if (!yytrial)
1585 #endif /* YYBTYACC */
1586 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
1587 #endif
1588 fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
1589 }
1590 #endif
1591 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1592 *++yystack.s_mark = (short) yystate;
1593 *++yystack.l_mark = yyval;
1594 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1595 *++yystack.p_mark = yyloc;
1596 #endif
1597 goto yyloop;
1598 #if YYBTYACC
1599
1600 /* Reduction declares that this path is valid. Set yypath and do a full parse */
1601 yyvalid:
1602 if (yypath) YYABORT;
1603 while (yyps->save)
1604 {
1605 YYParseState *save = yyps->save;
1606 yyps->save = save->save;
1607 save->save = yypath;
1608 yypath = save;
1609 }
1610 #if YYDEBUG
1611 if (yydebug)
1612 fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
1613 YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
1614 #endif
1615 if (yyerrctx)
1616 {
1617 yyFreeState(yyerrctx);
1618 yyerrctx = NULL;
1619 }
1620 yylvp = yylvals + yypath->lexeme;
1621 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1622 yylpp = yylpsns + yypath->lexeme;
1623 #endif
1624 yylexp = yylexemes + yypath->lexeme;
1625 yychar = YYEMPTY;
1626 yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
1627 memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
1628 yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
1629 memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1630 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1631 yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
1632 memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1633 #endif
1634 yystate = yypath->state;
1635 goto yyloop;
1636 #endif /* YYBTYACC */
1637
1638 yyoverflow:
1639 YYERROR_CALL("yacc stack overflow");
1640 #if YYBTYACC
1641 goto yyabort_nomem;
1642 yyenomem:
1643 YYERROR_CALL("memory exhausted");
1644 yyabort_nomem:
1645 #endif /* YYBTYACC */
1646 yyresult = 2;
1647 goto yyreturn;
1648
1649 yyabort:
1650 yyresult = 1;
1651 goto yyreturn;
1652
1653 yyaccept:
1654 #if YYBTYACC
1655 if (yyps->save) goto yyvalid;
1656 #endif /* YYBTYACC */
1657 yyresult = 0;
1658
1659 yyreturn:
1660 #if defined(YYDESTRUCT_CALL)
1661 if (yychar != YYEOF && yychar != YYEMPTY)
1662 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1663 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
1664 #else
1665 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
1666 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1667
1668 {
1669 YYSTYPE *pv;
1670 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1671 YYLTYPE *pp;
1672
1673 for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
1674 YYDESTRUCT_CALL("cleanup: discarding state",
1675 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
1676 #else
1677 for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
1678 YYDESTRUCT_CALL("cleanup: discarding state",
1679 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
1680 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1681 }
1682 #endif /* defined(YYDESTRUCT_CALL) */
1683
1684 #if YYBTYACC
1685 if (yyerrctx)
1686 {
1687 yyFreeState(yyerrctx);
1688 yyerrctx = NULL;
1689 }
1690 while (yyps)
1691 {
1692 YYParseState *save = yyps;
1693 yyps = save->save;
1694 save->save = NULL;
1695 yyFreeState(save);
1696 }
1697 while (yypath)
1698 {
1699 YYParseState *save = yypath;
1700 yypath = save->save;
1701 save->save = NULL;
1702 yyFreeState(save);
1703 }
1704 #endif /* YYBTYACC */
1705 yyfreestack(&yystack);
1706 return (yyresult);
1707 }
1708