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