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