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