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