xref: /freebsd/contrib/byacc/test/btyacc/calc2.tab.c (revision 193d9e768ba63fcfb187cfd17f461f7d41345048)
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 
674 #if YYBTYACC
675     yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
676     yyps->save = 0;
677 #endif /* YYBTYACC */
678     yym = 0;
679     yyn = 0;
680     yynerrs = 0;
681     yyerrflag = 0;
682     yychar = YYEMPTY;
683     yystate = 0;
684 
685 #if YYPURE
686     memset(&yystack, 0, sizeof(yystack));
687 #endif
688 
689     if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
690     yystack.s_mark = yystack.s_base;
691     yystack.l_mark = yystack.l_base;
692 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
693     yystack.p_mark = yystack.p_base;
694 #endif
695     yystate = 0;
696     *yystack.s_mark = 0;
697 
698 yyloop:
699     if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
700     if (yychar < 0)
701     {
702 #if YYBTYACC
703         do {
704         if (yylvp < yylve)
705         {
706             /* we're currently re-reading tokens */
707             yylval = *yylvp++;
708 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
709             yylloc = *yylpp++;
710 #endif
711             yychar = *yylexp++;
712             break;
713         }
714         if (yyps->save)
715         {
716             /* in trial mode; save scanner results for future parse attempts */
717             if (yylvp == yylvlim)
718             {   /* Enlarge lexical value queue */
719                 size_t p = (size_t) (yylvp - yylvals);
720                 size_t s = (size_t) (yylvlim - yylvals);
721 
722                 s += YYLVQUEUEGROWTH;
723                 if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
724                 if ((yylvals   = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
725 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
726                 if ((yylpsns   = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
727 #endif
728                 yylvp   = yylve = yylvals + p;
729                 yylvlim = yylvals + s;
730 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
731                 yylpp   = yylpe = yylpsns + p;
732                 yylplim = yylpsns + s;
733 #endif
734                 yylexp  = yylexemes + p;
735             }
736             *yylexp = (YYINT) YYLEX;
737             *yylvp++ = yylval;
738             yylve++;
739 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
740             *yylpp++ = yylloc;
741             yylpe++;
742 #endif
743             yychar = *yylexp++;
744             break;
745         }
746         /* normal operation, no conflict encountered */
747 #endif /* YYBTYACC */
748         yychar = YYLEX;
749 #if YYBTYACC
750         } while (0);
751 #endif /* YYBTYACC */
752         if (yychar < 0) yychar = YYEOF;
753 #if YYDEBUG
754         if (yydebug)
755         {
756             if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
757             fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
758                             YYDEBUGSTR, yydepth, yystate, yychar, yys);
759 #ifdef YYSTYPE_TOSTRING
760 #if YYBTYACC
761             if (!yytrial)
762 #endif /* YYBTYACC */
763                 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
764 #endif
765             fputc('\n', stderr);
766         }
767 #endif
768     }
769 #if YYBTYACC
770 
771     /* Do we have a conflict? */
772     if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
773         yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
774     {
775         YYINT ctry;
776 
777         if (yypath)
778         {
779             YYParseState *save;
780 #if YYDEBUG
781             if (yydebug)
782                 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
783                                 YYDEBUGSTR, yydepth, yystate);
784 #endif
785             /* Switch to the next conflict context */
786             save = yypath;
787             yypath = save->save;
788             save->save = NULL;
789             ctry = save->ctry;
790             if (save->state != yystate) YYABORT;
791             yyFreeState(save);
792 
793         }
794         else
795         {
796 
797             /* Unresolved conflict - start/continue trial parse */
798             YYParseState *save;
799 #if YYDEBUG
800             if (yydebug)
801             {
802                 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
803                 if (yyps->save)
804                     fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
805                 else
806                     fputs("Starting trial parse.\n", stderr);
807             }
808 #endif
809             save                  = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
810             if (save == NULL) goto yyenomem;
811             save->save            = yyps->save;
812             save->state           = yystate;
813             save->errflag         = yyerrflag;
814             save->yystack.s_mark  = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
815             memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
816             save->yystack.l_mark  = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
817             memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
818 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
819             save->yystack.p_mark  = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
820             memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
821 #endif
822             ctry                  = yytable[yyn];
823             if (yyctable[ctry] == -1)
824             {
825 #if YYDEBUG
826                 if (yydebug && yychar >= YYEOF)
827                     fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
828 #endif
829                 ctry++;
830             }
831             save->ctry = ctry;
832             if (yyps->save == NULL)
833             {
834                 /* If this is a first conflict in the stack, start saving lexemes */
835                 if (!yylexemes)
836                 {
837                     yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
838                     if (yylexemes == NULL) goto yyenomem;
839                     yylvals   = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
840                     if (yylvals == NULL) goto yyenomem;
841                     yylvlim   = yylvals + YYLVQUEUEGROWTH;
842 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
843                     yylpsns   = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
844                     if (yylpsns == NULL) goto yyenomem;
845                     yylplim   = yylpsns + YYLVQUEUEGROWTH;
846 #endif
847                 }
848                 if (yylvp == yylve)
849                 {
850                     yylvp  = yylve = yylvals;
851 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
852                     yylpp  = yylpe = yylpsns;
853 #endif
854                     yylexp = yylexemes;
855                     if (yychar >= YYEOF)
856                     {
857                         *yylve++ = yylval;
858 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
859                         *yylpe++ = yylloc;
860 #endif
861                         *yylexp  = (YYINT) yychar;
862                         yychar   = YYEMPTY;
863                     }
864                 }
865             }
866             if (yychar >= YYEOF)
867             {
868                 yylvp--;
869 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
870                 yylpp--;
871 #endif
872                 yylexp--;
873                 yychar = YYEMPTY;
874             }
875             save->lexeme = (int) (yylvp - yylvals);
876             yyps->save   = save;
877         }
878         if (yytable[yyn] == ctry)
879         {
880 #if YYDEBUG
881             if (yydebug)
882                 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
883                                 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
884 #endif
885             if (yychar < 0)
886             {
887                 yylvp++;
888 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
889                 yylpp++;
890 #endif
891                 yylexp++;
892             }
893             if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
894                 goto yyoverflow;
895             yystate = yyctable[ctry];
896             *++yystack.s_mark = (YYINT) yystate;
897             *++yystack.l_mark = yylval;
898 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
899             *++yystack.p_mark = yylloc;
900 #endif
901             yychar  = YYEMPTY;
902             if (yyerrflag > 0) --yyerrflag;
903             goto yyloop;
904         }
905         else
906         {
907             yyn = yyctable[ctry];
908             goto yyreduce;
909         }
910     } /* End of code dealing with conflicts */
911 #endif /* YYBTYACC */
912     if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
913             yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
914     {
915 #if YYDEBUG
916         if (yydebug)
917             fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
918                             YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
919 #endif
920         if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
921         yystate = yytable[yyn];
922         *++yystack.s_mark = yytable[yyn];
923         *++yystack.l_mark = yylval;
924 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
925         *++yystack.p_mark = yylloc;
926 #endif
927         yychar = YYEMPTY;
928         if (yyerrflag > 0)  --yyerrflag;
929         goto yyloop;
930     }
931     if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
932             yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
933     {
934         yyn = yytable[yyn];
935         goto yyreduce;
936     }
937     if (yyerrflag != 0) goto yyinrecovery;
938 #if YYBTYACC
939 
940     yynewerrflag = 1;
941     goto yyerrhandler;
942     goto yyerrlab; /* redundant goto avoids 'unused label' warning */
943 
944 yyerrlab:
945     /* explicit YYERROR from an action -- pop the rhs of the rule reduced
946      * before looking for error recovery */
947     yystack.s_mark -= yym;
948     yystate = *yystack.s_mark;
949     yystack.l_mark -= yym;
950 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
951     yystack.p_mark -= yym;
952 #endif
953 
954     yynewerrflag = 0;
955 yyerrhandler:
956     while (yyps->save)
957     {
958         int ctry;
959         YYParseState *save = yyps->save;
960 #if YYDEBUG
961         if (yydebug)
962             fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
963                             YYDEBUGSTR, yydepth, yystate, yyps->save->state,
964                     (int)(yylvp - yylvals - yyps->save->lexeme));
965 #endif
966         /* Memorize most forward-looking error state in case it's really an error. */
967         if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
968         {
969             /* Free old saved error context state */
970             if (yyerrctx) yyFreeState(yyerrctx);
971             /* Create and fill out new saved error context state */
972             yyerrctx                 = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
973             if (yyerrctx == NULL) goto yyenomem;
974             yyerrctx->save           = yyps->save;
975             yyerrctx->state          = yystate;
976             yyerrctx->errflag        = yyerrflag;
977             yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
978             memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
979             yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
980             memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
981 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
982             yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
983             memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
984 #endif
985             yyerrctx->lexeme         = (int) (yylvp - yylvals);
986         }
987         yylvp          = yylvals   + save->lexeme;
988 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
989         yylpp          = yylpsns   + save->lexeme;
990 #endif
991         yylexp         = yylexemes + save->lexeme;
992         yychar         = YYEMPTY;
993         yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
994         memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
995         yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
996         memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
997 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
998         yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
999         memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1000 #endif
1001         ctry           = ++save->ctry;
1002         yystate        = save->state;
1003         /* We tried shift, try reduce now */
1004         if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
1005         yyps->save     = save->save;
1006         save->save     = NULL;
1007         yyFreeState(save);
1008 
1009         /* Nothing left on the stack -- error */
1010         if (!yyps->save)
1011         {
1012 #if YYDEBUG
1013             if (yydebug)
1014                 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
1015                                 YYPREFIX, yydepth);
1016 #endif
1017             /* Restore state as it was in the most forward-advanced error */
1018             yylvp          = yylvals   + yyerrctx->lexeme;
1019 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1020             yylpp          = yylpsns   + yyerrctx->lexeme;
1021 #endif
1022             yylexp         = yylexemes + yyerrctx->lexeme;
1023             yychar         = yylexp[-1];
1024             yylval         = yylvp[-1];
1025 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1026             yylloc         = yylpp[-1];
1027 #endif
1028             yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
1029             memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1030             yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
1031             memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1032 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1033             yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
1034             memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1035 #endif
1036             yystate        = yyerrctx->state;
1037             yyFreeState(yyerrctx);
1038             yyerrctx       = NULL;
1039         }
1040         yynewerrflag = 1;
1041     }
1042     if (yynewerrflag == 0) goto yyinrecovery;
1043 #endif /* YYBTYACC */
1044 
1045     YYERROR_CALL("syntax error");
1046 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1047     yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
1048 #endif
1049 
1050 #if !YYBTYACC
1051     goto yyerrlab; /* redundant goto avoids 'unused label' warning */
1052 yyerrlab:
1053 #endif
1054     ++yynerrs;
1055 
1056 yyinrecovery:
1057     if (yyerrflag < 3)
1058     {
1059         yyerrflag = 3;
1060         for (;;)
1061         {
1062             if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
1063                     yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
1064             {
1065 #if YYDEBUG
1066                 if (yydebug)
1067                     fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
1068                                     YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
1069 #endif
1070                 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1071                 yystate = yytable[yyn];
1072                 *++yystack.s_mark = yytable[yyn];
1073                 *++yystack.l_mark = yylval;
1074 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1075                 /* lookahead position is error end position */
1076                 yyerror_loc_range[1] = yylloc;
1077                 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
1078                 *++yystack.p_mark = yyloc;
1079 #endif
1080                 goto yyloop;
1081             }
1082             else
1083             {
1084 #if YYDEBUG
1085                 if (yydebug)
1086                     fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
1087                                     YYDEBUGSTR, yydepth, *yystack.s_mark);
1088 #endif
1089                 if (yystack.s_mark <= yystack.s_base) goto yyabort;
1090 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1091                 /* the current TOS position is the error start position */
1092                 yyerror_loc_range[0] = *yystack.p_mark;
1093 #endif
1094 #if defined(YYDESTRUCT_CALL)
1095 #if YYBTYACC
1096                 if (!yytrial)
1097 #endif /* YYBTYACC */
1098 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1099                     YYDESTRUCT_CALL("error: discarding state",
1100                                     yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
1101 #else
1102                     YYDESTRUCT_CALL("error: discarding state",
1103                                     yystos[*yystack.s_mark], yystack.l_mark);
1104 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1105 #endif /* defined(YYDESTRUCT_CALL) */
1106                 --yystack.s_mark;
1107                 --yystack.l_mark;
1108 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1109                 --yystack.p_mark;
1110 #endif
1111             }
1112         }
1113     }
1114     else
1115     {
1116         if (yychar == YYEOF) goto yyabort;
1117 #if YYDEBUG
1118         if (yydebug)
1119         {
1120             if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1121             fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
1122                             YYDEBUGSTR, yydepth, yystate, yychar, yys);
1123         }
1124 #endif
1125 #if defined(YYDESTRUCT_CALL)
1126 #if YYBTYACC
1127         if (!yytrial)
1128 #endif /* YYBTYACC */
1129 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1130             YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
1131 #else
1132             YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
1133 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1134 #endif /* defined(YYDESTRUCT_CALL) */
1135         yychar = YYEMPTY;
1136         goto yyloop;
1137     }
1138 
1139 yyreduce:
1140     yym = yylen[yyn];
1141 #if YYDEBUG
1142     if (yydebug)
1143     {
1144         fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
1145                         YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
1146 #ifdef YYSTYPE_TOSTRING
1147 #if YYBTYACC
1148         if (!yytrial)
1149 #endif /* YYBTYACC */
1150             if (yym > 0)
1151             {
1152                 int i;
1153                 fputc('<', stderr);
1154                 for (i = yym; i > 0; i--)
1155                 {
1156                     if (i != yym) fputs(", ", stderr);
1157                     fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
1158                                            yystack.l_mark[1-i]), stderr);
1159                 }
1160                 fputc('>', stderr);
1161             }
1162 #endif
1163         fputc('\n', stderr);
1164     }
1165 #endif
1166     if (yym > 0)
1167         yyval = yystack.l_mark[1-yym];
1168     else
1169         memset(&yyval, 0, sizeof yyval);
1170 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1171 
1172     /* Perform position reduction */
1173     memset(&yyloc, 0, sizeof(yyloc));
1174 #if YYBTYACC
1175     if (!yytrial)
1176 #endif /* YYBTYACC */
1177     {
1178         YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
1179         /* just in case YYERROR is invoked within the action, save
1180            the start of the rhs as the error start position */
1181         yyerror_loc_range[0] = yystack.p_mark[1-yym];
1182     }
1183 #endif
1184 
1185     switch (yyn)
1186     {
1187 case 3:
1188 #line 35 "calc2.y"
1189 	{  yyerrok ; }
1190 break;
1191 case 4:
1192 #line 39 "calc2.y"
1193 	{  printf("%d\n",yystack.l_mark[0]);}
1194 break;
1195 case 5:
1196 #line 41 "calc2.y"
1197 	{  regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
1198 break;
1199 case 6:
1200 #line 45 "calc2.y"
1201 	{  yyval = yystack.l_mark[-1]; }
1202 break;
1203 case 7:
1204 #line 47 "calc2.y"
1205 	{  yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
1206 break;
1207 case 8:
1208 #line 49 "calc2.y"
1209 	{  yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
1210 break;
1211 case 9:
1212 #line 51 "calc2.y"
1213 	{  yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
1214 break;
1215 case 10:
1216 #line 53 "calc2.y"
1217 	{  yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
1218 break;
1219 case 11:
1220 #line 55 "calc2.y"
1221 	{  yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
1222 break;
1223 case 12:
1224 #line 57 "calc2.y"
1225 	{  yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
1226 break;
1227 case 13:
1228 #line 59 "calc2.y"
1229 	{  yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
1230 break;
1231 case 14:
1232 #line 61 "calc2.y"
1233 	{  yyval = - yystack.l_mark[0]; }
1234 break;
1235 case 15:
1236 #line 63 "calc2.y"
1237 	{  yyval = regs[yystack.l_mark[0]]; }
1238 break;
1239 case 17:
1240 #line 68 "calc2.y"
1241 	{  yyval = yystack.l_mark[0]; (*base) = (yystack.l_mark[0]==0) ? 8 : 10; }
1242 break;
1243 case 18:
1244 #line 70 "calc2.y"
1245 	{  yyval = (*base) * yystack.l_mark[-1] + yystack.l_mark[0]; }
1246 break;
1247 #line 1248 "calc2.tab.c"
1248     default:
1249         break;
1250     }
1251     yystack.s_mark -= yym;
1252     yystate = *yystack.s_mark;
1253     yystack.l_mark -= yym;
1254 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1255     yystack.p_mark -= yym;
1256 #endif
1257     yym = yylhs[yyn];
1258     if (yystate == 0 && yym == 0)
1259     {
1260 #if YYDEBUG
1261         if (yydebug)
1262         {
1263             fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1264 #ifdef YYSTYPE_TOSTRING
1265 #if YYBTYACC
1266             if (!yytrial)
1267 #endif /* YYBTYACC */
1268                 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
1269 #endif
1270             fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
1271         }
1272 #endif
1273         yystate = YYFINAL;
1274         *++yystack.s_mark = YYFINAL;
1275         *++yystack.l_mark = yyval;
1276 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1277         *++yystack.p_mark = yyloc;
1278 #endif
1279         if (yychar < 0)
1280         {
1281 #if YYBTYACC
1282             do {
1283             if (yylvp < yylve)
1284             {
1285                 /* we're currently re-reading tokens */
1286                 yylval = *yylvp++;
1287 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1288                 yylloc = *yylpp++;
1289 #endif
1290                 yychar = *yylexp++;
1291                 break;
1292             }
1293             if (yyps->save)
1294             {
1295                 /* in trial mode; save scanner results for future parse attempts */
1296                 if (yylvp == yylvlim)
1297                 {   /* Enlarge lexical value queue */
1298                     size_t p = (size_t) (yylvp - yylvals);
1299                     size_t s = (size_t) (yylvlim - yylvals);
1300 
1301                     s += YYLVQUEUEGROWTH;
1302                     if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
1303                         goto yyenomem;
1304                     if ((yylvals   = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
1305                         goto yyenomem;
1306 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1307                     if ((yylpsns   = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
1308                         goto yyenomem;
1309 #endif
1310                     yylvp   = yylve = yylvals + p;
1311                     yylvlim = yylvals + s;
1312 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1313                     yylpp   = yylpe = yylpsns + p;
1314                     yylplim = yylpsns + s;
1315 #endif
1316                     yylexp  = yylexemes + p;
1317                 }
1318                 *yylexp = (YYINT) YYLEX;
1319                 *yylvp++ = yylval;
1320                 yylve++;
1321 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1322                 *yylpp++ = yylloc;
1323                 yylpe++;
1324 #endif
1325                 yychar = *yylexp++;
1326                 break;
1327             }
1328             /* normal operation, no conflict encountered */
1329 #endif /* YYBTYACC */
1330             yychar = YYLEX;
1331 #if YYBTYACC
1332             } while (0);
1333 #endif /* YYBTYACC */
1334             if (yychar < 0) yychar = YYEOF;
1335 #if YYDEBUG
1336             if (yydebug)
1337             {
1338                 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1339                 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n",
1340                                 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
1341             }
1342 #endif
1343         }
1344         if (yychar == YYEOF) goto yyaccept;
1345         goto yyloop;
1346     }
1347     if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
1348             yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
1349         yystate = yytable[yyn];
1350     else
1351         yystate = yydgoto[yym];
1352 #if YYDEBUG
1353     if (yydebug)
1354     {
1355         fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1356 #ifdef YYSTYPE_TOSTRING
1357 #if YYBTYACC
1358         if (!yytrial)
1359 #endif /* YYBTYACC */
1360             fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
1361 #endif
1362         fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
1363     }
1364 #endif
1365     if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1366     *++yystack.s_mark = (YYINT) yystate;
1367     *++yystack.l_mark = yyval;
1368 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1369     *++yystack.p_mark = yyloc;
1370 #endif
1371     goto yyloop;
1372 #if YYBTYACC
1373 
1374     /* Reduction declares that this path is valid. Set yypath and do a full parse */
1375 yyvalid:
1376     if (yypath) YYABORT;
1377     while (yyps->save)
1378     {
1379         YYParseState *save = yyps->save;
1380         yyps->save = save->save;
1381         save->save = yypath;
1382         yypath = save;
1383     }
1384 #if YYDEBUG
1385     if (yydebug)
1386         fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
1387                         YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
1388 #endif
1389     if (yyerrctx)
1390     {
1391         yyFreeState(yyerrctx);
1392         yyerrctx = NULL;
1393     }
1394     yylvp          = yylvals + yypath->lexeme;
1395 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1396     yylpp          = yylpsns + yypath->lexeme;
1397 #endif
1398     yylexp         = yylexemes + yypath->lexeme;
1399     yychar         = YYEMPTY;
1400     yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
1401     memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1402     yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
1403     memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1404 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1405     yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
1406     memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1407 #endif
1408     yystate        = yypath->state;
1409     goto yyloop;
1410 #endif /* YYBTYACC */
1411 
1412 yyoverflow:
1413     YYERROR_CALL("yacc stack overflow");
1414 #if YYBTYACC
1415     goto yyabort_nomem;
1416 yyenomem:
1417     YYERROR_CALL("memory exhausted");
1418 yyabort_nomem:
1419 #endif /* YYBTYACC */
1420     yyresult = 2;
1421     goto yyreturn;
1422 
1423 yyabort:
1424     yyresult = 1;
1425     goto yyreturn;
1426 
1427 yyaccept:
1428 #if YYBTYACC
1429     if (yyps->save) goto yyvalid;
1430 #endif /* YYBTYACC */
1431     yyresult = 0;
1432 
1433 yyreturn:
1434 #if defined(YYDESTRUCT_CALL)
1435     if (yychar != YYEOF && yychar != YYEMPTY)
1436 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1437         YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
1438 #else
1439         YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
1440 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1441 
1442     {
1443         YYSTYPE *pv;
1444 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1445         YYLTYPE *pp;
1446 
1447         for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
1448              YYDESTRUCT_CALL("cleanup: discarding state",
1449                              yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
1450 #else
1451         for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
1452              YYDESTRUCT_CALL("cleanup: discarding state",
1453                              yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
1454 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1455     }
1456 #endif /* defined(YYDESTRUCT_CALL) */
1457 
1458 #if YYBTYACC
1459     if (yyerrctx)
1460     {
1461         yyFreeState(yyerrctx);
1462         yyerrctx = NULL;
1463     }
1464     while (yyps)
1465     {
1466         YYParseState *save = yyps;
1467         yyps = save->save;
1468         save->save = NULL;
1469         yyFreeState(save);
1470     }
1471     while (yypath)
1472     {
1473         YYParseState *save = yypath;
1474         yypath = save->save;
1475         save->save = NULL;
1476         yyFreeState(save);
1477     }
1478 #endif /* YYBTYACC */
1479     yyfreestack(&yystack);
1480     return (yyresult);
1481 }
1482