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