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