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