calc2.tab.c revision 277086
1184610Salfred/* original parser id follows */
2184610Salfred/* yysccsid[] = "@(#)yaccpar	1.9 (Berkeley) 02/21/93" */
3184610Salfred/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */
4184610Salfred
5184610Salfred#define YYBYACC 1
6184610Salfred#define YYMAJOR 1
7184610Salfred#define YYMINOR 9
8184610Salfred#define YYCHECK "yyyymmdd"
9184610Salfred
10184610Salfred#define YYEMPTY        (-1)
11184610Salfred#define yyclearin      (yychar = YYEMPTY)
12184610Salfred#define yyerrok        (yyerrflag = 0)
13184610Salfred#define YYRECOVERING() (yyerrflag != 0)
14184610Salfred#define YYENOMEM       (-2)
15184610Salfred#define YYEOF          0
16184610Salfred
17184610Salfred#ifndef yyparse
18184610Salfred#define yyparse    calc2_parse
19184610Salfred#endif /* yyparse */
20184610Salfred
21184610Salfred#ifndef yylex
22184610Salfred#define yylex      calc2_lex
23184610Salfred#endif /* yylex */
24184610Salfred
25184610Salfred#ifndef yyerror
26184610Salfred#define yyerror    calc2_error
27184610Salfred#endif /* yyerror */
28184610Salfred
29194677Sthompsa#ifndef yychar
30194677Sthompsa#define yychar     calc2_char
31194677Sthompsa#endif /* yychar */
32194677Sthompsa
33194677Sthompsa#ifndef yyval
34194677Sthompsa#define yyval      calc2_val
35194677Sthompsa#endif /* yyval */
36194677Sthompsa
37194677Sthompsa#ifndef yylval
38194677Sthompsa#define yylval     calc2_lval
39194677Sthompsa#endif /* yylval */
40194677Sthompsa
41194677Sthompsa#ifndef yydebug
42194677Sthompsa#define yydebug    calc2_debug
43194677Sthompsa#endif /* yydebug */
44194677Sthompsa
45194677Sthompsa#ifndef yynerrs
46194677Sthompsa#define yynerrs    calc2_nerrs
47194677Sthompsa#endif /* yynerrs */
48194677Sthompsa
49188942Sthompsa#ifndef yyerrflag
50188942Sthompsa#define yyerrflag  calc2_errflag
51194677Sthompsa#endif /* yyerrflag */
52188746Sthompsa
53184610Salfred#ifndef yylhs
54194228Sthompsa#define yylhs      calc2_lhs
55188942Sthompsa#endif /* yylhs */
56188942Sthompsa
57184610Salfred#ifndef yylen
58188942Sthompsa#define yylen      calc2_len
59184610Salfred#endif /* yylen */
60188942Sthompsa
61188942Sthompsa#ifndef yydefred
62184610Salfred#define yydefred   calc2_defred
63200886Sthompsa#endif /* yydefred */
64184610Salfred
65184610Salfred#ifndef yydgoto
66194228Sthompsa#define yydgoto    calc2_dgoto
67184610Salfred#endif /* yydgoto */
68184610Salfred
69184610Salfred#ifndef yysindex
70184610Salfred#define yysindex   calc2_sindex
71184610Salfred#endif /* yysindex */
72184610Salfred
73184610Salfred#ifndef yyrindex
74194228Sthompsa#define yyrindex   calc2_rindex
75184610Salfred#endif /* yyrindex */
76201071Sthompsa
77201071Sthompsa#ifndef yygindex
78201071Sthompsa#define yygindex   calc2_gindex
79200887Sthompsa#endif /* yygindex */
80201071Sthompsa
81201071Sthompsa#ifndef yytable
82194228Sthompsa#define yytable    calc2_table
83201071Sthompsa#endif /* yytable */
84201071Sthompsa
85201071Sthompsa#ifndef yycheck
86201071Sthompsa#define yycheck    calc2_check
87201071Sthompsa#endif /* yycheck */
88201071Sthompsa
89201071Sthompsa#ifndef yyname
90201071Sthompsa#define yyname     calc2_name
91201071Sthompsa#endif /* yyname */
92201071Sthompsa
93201071Sthompsa#ifndef yyrule
94201071Sthompsa#define yyrule     calc2_rule
95201071Sthompsa#endif /* yyrule */
96201071Sthompsa#define YYPREFIX "calc2_"
97201071Sthompsa
98184610Salfred#define YYPURE 0
99184610Salfred
100184610Salfred#line 7 "calc2.y"
101184610Salfred# include <stdio.h>
102184610Salfred# include <ctype.h>
103201071Sthompsa
104201071Sthompsa#ifdef YYBISON
105201071Sthompsa#define YYLEX_PARAM base
106201071Sthompsa#define YYLEX_DECL() yylex(int *YYLEX_PARAM)
107201071Sthompsa#define YYERROR_DECL() yyerror(int regs[26], int *base, const char *s)
108201071Sthompsaint YYLEX_DECL();
109201071Sthompsastatic void YYERROR_DECL();
110184610Salfred#endif
111201071Sthompsa
112201071Sthompsa#line 113 "calc2.tab.c"
113201071Sthompsa
114201071Sthompsa#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED)
115201071Sthompsa/* Default: YYSTYPE is the semantic value type. */
116201071Sthompsatypedef int YYSTYPE;
117201071Sthompsa# define YYSTYPE_IS_DECLARED 1
118201071Sthompsa#endif
119201071Sthompsa
120201071Sthompsa/* compatibility with bison */
121184610Salfred#ifdef YYPARSE_PARAM
122201071Sthompsa/* compatibility with FreeBSD */
123201071Sthompsa# ifdef YYPARSE_PARAM_TYPE
124201071Sthompsa#  define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
125184610Salfred# else
126201071Sthompsa#  define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
127201071Sthompsa# endif
128200395Sthompsa#else
129201071Sthompsa# define YYPARSE_DECL() yyparse(int regs[26], int *base)
130201071Sthompsa#endif
131201071Sthompsa
132201071Sthompsa/* Parameters sent to lex. */
133201071Sthompsa#ifdef YYLEX_PARAM
134201071Sthompsa# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
135201071Sthompsa# define YYLEX yylex(YYLEX_PARAM)
136201071Sthompsa#else
137200395Sthompsa# define YYLEX_DECL() yylex(int *base)
138200886Sthompsa# define YYLEX yylex(base)
139201071Sthompsa#endif
140201071Sthompsa
141201071Sthompsa/* Parameters sent to yyerror. */
142201071Sthompsa#ifndef YYERROR_DECL
143201071Sthompsa#define YYERROR_DECL() yyerror(int regs[26], int *base, const char *s)
144201071Sthompsa#endif
145201071Sthompsa#ifndef YYERROR_CALL
146201071Sthompsa#define YYERROR_CALL(msg) yyerror(regs, base, msg)
147201071Sthompsa#endif
148201071Sthompsa
149201071Sthompsaextern int YYPARSE_DECL();
150201071Sthompsa
151201071Sthompsa#define DIGIT 257
152201071Sthompsa#define LETTER 258
153201071Sthompsa#define UMINUS 259
154201071Sthompsa#define YYERRCODE 256
155201071Sthompsatypedef int YYINT;
156201071Sthompsastatic const YYINT calc2_lhs[] = {                       -1,
157201071Sthompsa    0,    0,    0,    1,    1,    2,    2,    2,    2,    2,
158201071Sthompsa    2,    2,    2,    2,    2,    2,    3,    3,
159201071Sthompsa};
160201071Sthompsastatic const YYINT calc2_len[] = {                        2,
161201071Sthompsa    0,    3,    3,    1,    3,    3,    3,    3,    3,    3,
162201071Sthompsa    3,    3,    3,    2,    1,    1,    1,    2,
163201071Sthompsa};
164201071Sthompsastatic const YYINT calc2_defred[] = {                     1,
165201071Sthompsa    0,    0,   17,    0,    0,    0,    0,    0,    0,    3,
166201071Sthompsa    0,   15,   14,    0,    2,    0,    0,    0,    0,    0,
167201071Sthompsa    0,    0,   18,    0,    6,    0,    0,    0,    0,    9,
168201071Sthompsa   10,   11,
169201071Sthompsa};
170201071Sthompsastatic const YYINT calc2_dgoto[] = {                      1,
171201071Sthompsa    7,    8,    9,
172201071Sthompsa};
173201071Sthompsastatic const YYINT calc2_sindex[] = {                     0,
174201071Sthompsa  -40,   -7,    0,  -55,  -38,  -38,    1,  -29, -247,    0,
175201071Sthompsa  -38,    0,    0,   22,    0,  -38,  -38,  -38,  -38,  -38,
176201071Sthompsa  -38,  -38,    0,  -29,    0,   51,   60,  -20,  -20,    0,
177201071Sthompsa    0,    0,
178201071Sthompsa};
179201071Sthompsastatic const YYINT calc2_rindex[] = {                     0,
180201071Sthompsa    0,    0,    0,    2,    0,    0,    0,    9,   -9,    0,
181201071Sthompsa    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
182201071Sthompsa    0,    0,    0,   10,    0,   -6,   14,    5,   13,    0,
183201071Sthompsa    0,    0,
184201071Sthompsa};
185201071Sthompsastatic const YYINT calc2_gindex[] = {                     0,
186201071Sthompsa    0,   65,    0,
187201071Sthompsa};
188201071Sthompsa#define YYTABLESIZE 220
189201071Sthompsastatic const YYINT calc2_table[] = {                      6,
190201071Sthompsa   16,    6,   10,   13,    5,   11,    5,   22,   17,   23,
191201071Sthompsa   15,   15,   20,   18,    7,   19,   22,   21,    4,    5,
192200886Sthompsa    0,   20,    8,   12,    0,    0,   21,   16,   16,    0,
193201071Sthompsa    0,   16,   16,   16,   13,   16,    0,   16,   15,   15,
194201071Sthompsa    0,    0,    7,   15,   15,    7,   15,    7,   15,    7,
195201071Sthompsa    8,   12,    0,    8,   12,    8,    0,    8,   22,   17,
196201071Sthompsa    0,    0,   25,   20,   18,    0,   19,    0,   21,   13,
197201071Sthompsa   14,    0,    0,    0,    0,   24,    0,    0,    0,    0,
198201071Sthompsa   26,   27,   28,   29,   30,   31,   32,   22,   17,    0,
199201071Sthompsa    0,    0,   20,   18,   16,   19,   22,   21,    0,    0,
200201071Sthompsa    0,   20,   18,    0,   19,    0,   21,    0,    0,    0,
201201071Sthompsa    0,    0,    0,    0,   16,    0,    0,   13,    0,    0,
202201071Sthompsa    0,    0,    0,    0,    0,   15,    0,    0,    7,    0,
203201071Sthompsa    0,    0,    0,    0,    0,    0,    8,   12,    0,    0,
204201071Sthompsa    0,    0,    0,    0,    0,   16,    0,    0,    0,    0,
205201071Sthompsa    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
206201071Sthompsa    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
207201071Sthompsa    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
208201071Sthompsa    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
209201071Sthompsa    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
210201071Sthompsa    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
211201071Sthompsa    0,    0,    0,    0,    0,    2,    3,    4,    3,   12,
212201071Sthompsa};
213201071Sthompsastatic const YYINT calc2_check[] = {                     40,
214201071Sthompsa   10,   40,   10,   10,   45,   61,   45,   37,   38,  257,
215201071Sthompsa   10,   10,   42,   43,   10,   45,   37,   47,   10,   10,
216201071Sthompsa   -1,   42,   10,   10,   -1,   -1,   47,   37,   38,   -1,
217201071Sthompsa   -1,   41,   42,   43,   41,   45,   -1,   47,   37,   38,
218201071Sthompsa   -1,   -1,   38,   42,   43,   41,   45,   43,   47,   45,
219201071Sthompsa   38,   38,   -1,   41,   41,   43,   -1,   45,   37,   38,
220201071Sthompsa   -1,   -1,   41,   42,   43,   -1,   45,   -1,   47,    5,
221201071Sthompsa    6,   -1,   -1,   -1,   -1,   11,   -1,   -1,   -1,   -1,
222201071Sthompsa   16,   17,   18,   19,   20,   21,   22,   37,   38,   -1,
223201071Sthompsa   -1,   -1,   42,   43,  124,   45,   37,   47,   -1,   -1,
224201071Sthompsa   -1,   42,   43,   -1,   45,   -1,   47,   -1,   -1,   -1,
225201071Sthompsa   -1,   -1,   -1,   -1,  124,   -1,   -1,  124,   -1,   -1,
226201071Sthompsa   -1,   -1,   -1,   -1,   -1,  124,   -1,   -1,  124,   -1,
227201071Sthompsa   -1,   -1,   -1,   -1,   -1,   -1,  124,  124,   -1,   -1,
228201701Sthompsa   -1,   -1,   -1,   -1,   -1,  124,   -1,   -1,   -1,   -1,
229201701Sthompsa   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
230201701Sthompsa   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
231201071Sthompsa   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
232201071Sthompsa   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
233201071Sthompsa   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
234201071Sthompsa   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
235201071Sthompsa   -1,   -1,   -1,   -1,   -1,  256,  257,  258,  257,  258,
236201071Sthompsa};
237201071Sthompsa#define YYFINAL 1
238201071Sthompsa#ifndef YYDEBUG
239201071Sthompsa#define YYDEBUG 0
240201071Sthompsa#endif
241201071Sthompsa#define YYMAXTOKEN 259
242201071Sthompsa#define YYUNDFTOKEN 265
243201071Sthompsa#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
244201071Sthompsa#if YYDEBUG
245201071Sthompsastatic const char *const calc2_name[] = {
246201071Sthompsa
247201071Sthompsa"end-of-file",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,
248201071Sthompsa0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,
249201071Sthompsa0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
250201071Sthompsa0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,
251201071Sthompsa0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
252201071Sthompsa0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
253201071Sthompsa0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
254201071Sthompsa0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol",
255201071Sthompsa};
256201071Sthompsastatic const char *const calc2_rule[] = {
257201071Sthompsa"$accept : list",
258201071Sthompsa"list :",
259201071Sthompsa"list : list stat '\\n'",
260201071Sthompsa"list : list error '\\n'",
261201071Sthompsa"stat : expr",
262201071Sthompsa"stat : LETTER '=' expr",
263201071Sthompsa"expr : '(' expr ')'",
264201071Sthompsa"expr : expr '+' expr",
265201071Sthompsa"expr : expr '-' expr",
266201071Sthompsa"expr : expr '*' expr",
267201071Sthompsa"expr : expr '/' expr",
268201071Sthompsa"expr : expr '%' expr",
269201071Sthompsa"expr : expr '&' expr",
270201071Sthompsa"expr : expr '|' expr",
271201071Sthompsa"expr : '-' expr",
272201071Sthompsa"expr : LETTER",
273201071Sthompsa"expr : number",
274201071Sthompsa"number : DIGIT",
275201071Sthompsa"number : number DIGIT",
276201071Sthompsa
277201071Sthompsa};
278201071Sthompsa#endif
279201071Sthompsa
280201071Sthompsaint      yydebug;
281201071Sthompsaint      yynerrs;
282201071Sthompsa
283201071Sthompsaint      yyerrflag;
284201071Sthompsaint      yychar;
285201071SthompsaYYSTYPE  yyval;
286201071SthompsaYYSTYPE  yylval;
287201071Sthompsa
288201071Sthompsa/* define the initial stack-sizes */
289201071Sthompsa#ifdef YYSTACKSIZE
290201071Sthompsa#undef YYMAXDEPTH
291201071Sthompsa#define YYMAXDEPTH  YYSTACKSIZE
292201071Sthompsa#else
293201071Sthompsa#ifdef YYMAXDEPTH
294201071Sthompsa#define YYSTACKSIZE YYMAXDEPTH
295201071Sthompsa#else
296201071Sthompsa#define YYSTACKSIZE 10000
297201071Sthompsa#define YYMAXDEPTH  10000
298201071Sthompsa#endif
299201071Sthompsa#endif
300201071Sthompsa
301201071Sthompsa#define YYINITSTACKSIZE 200
302201071Sthompsa
303201071Sthompsatypedef struct {
304201071Sthompsa    unsigned stacksize;
305201071Sthompsa    YYINT    *s_base;
306201071Sthompsa    YYINT    *s_mark;
307201071Sthompsa    YYINT    *s_last;
308201071Sthompsa    YYSTYPE  *l_base;
309201071Sthompsa    YYSTYPE  *l_mark;
310201071Sthompsa} YYSTACKDATA;
311201071Sthompsa/* variables for the parser stack */
312201071Sthompsastatic YYSTACKDATA yystack;
313201071Sthompsa#line 73 "calc2.y"
314201071Sthompsa /* start of programs */
315201071Sthompsa
316201071Sthompsa#ifdef YYBYACC
317201071Sthompsaextern int YYLEX_DECL();
318201071Sthompsa#endif
319201071Sthompsa
320201071Sthompsaint
321201071Sthompsamain (void)
322201071Sthompsa{
323201071Sthompsa    int regs[26];
324201071Sthompsa    int base = 10;
325201071Sthompsa
326201071Sthompsa    while(!feof(stdin)) {
327201071Sthompsa	yyparse(regs, &base);
328201071Sthompsa    }
329201071Sthompsa    return 0;
330201071Sthompsa}
331201071Sthompsa
332201071Sthompsa#define UNUSED(x) ((void)(x))
333201071Sthompsa
334201071Sthompsastatic void
335201071SthompsaYYERROR_DECL()
336201071Sthompsa{
337201071Sthompsa    UNUSED(regs); /* %parse-param regs is not actually used here */
338201071Sthompsa    UNUSED(base); /* %parse-param base is not actually used here */
339201071Sthompsa    fprintf(stderr, "%s\n", s);
340201071Sthompsa}
341201071Sthompsa
342201071Sthompsaint
343201071SthompsaYYLEX_DECL()
344201071Sthompsa{
345201071Sthompsa	/* lexical analysis routine */
346201071Sthompsa	/* returns LETTER for a lower case letter, yylval = 0 through 25 */
347201071Sthompsa	/* return DIGIT for a digit, yylval = 0 through 9 */
348201071Sthompsa	/* all other characters are returned immediately */
349201071Sthompsa
350201071Sthompsa    int c;
351201071Sthompsa
352201071Sthompsa    while( (c=getchar()) == ' ' )   { /* skip blanks */ }
353201071Sthompsa
354201071Sthompsa    /* c is now nonblank */
355201071Sthompsa
356201071Sthompsa    if( islower( c )) {
357201071Sthompsa	yylval = c - 'a';
358201071Sthompsa	return ( LETTER );
359201071Sthompsa    }
360201071Sthompsa    if( isdigit( c )) {
361201071Sthompsa	yylval = (c - '0') % (*base);
362201071Sthompsa	return ( DIGIT );
363201071Sthompsa    }
364201071Sthompsa    return( c );
365201071Sthompsa}
366201071Sthompsa#line 367 "calc2.tab.c"
367201071Sthompsa
368201071Sthompsa#if YYDEBUG
369201071Sthompsa#include <stdio.h>		/* needed for printf */
370201071Sthompsa#endif
371201071Sthompsa
372201071Sthompsa#include <stdlib.h>	/* needed for malloc, etc */
373201071Sthompsa#include <string.h>	/* needed for memset */
374201071Sthompsa
375201071Sthompsa/* allocate initial stack or double stack size, up to YYMAXDEPTH */
376201071Sthompsastatic int yygrowstack(YYSTACKDATA *data)
377201071Sthompsa{
378201071Sthompsa    int i;
379201071Sthompsa    unsigned newsize;
380201071Sthompsa    YYINT *newss;
381201071Sthompsa    YYSTYPE *newvs;
382201071Sthompsa
383201071Sthompsa    if ((newsize = data->stacksize) == 0)
384201071Sthompsa        newsize = YYINITSTACKSIZE;
385201071Sthompsa    else if (newsize >= YYMAXDEPTH)
386201071Sthompsa        return YYENOMEM;
387201071Sthompsa    else if ((newsize *= 2) > YYMAXDEPTH)
388201071Sthompsa        newsize = YYMAXDEPTH;
389201071Sthompsa
390201071Sthompsa    i = (int) (data->s_mark - data->s_base);
391201071Sthompsa    newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
392201071Sthompsa    if (newss == 0)
393201071Sthompsa        return YYENOMEM;
394201071Sthompsa
395201071Sthompsa    data->s_base = newss;
396201071Sthompsa    data->s_mark = newss + i;
397201071Sthompsa
398201071Sthompsa    newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
399201071Sthompsa    if (newvs == 0)
400201071Sthompsa        return YYENOMEM;
401201071Sthompsa
402201071Sthompsa    data->l_base = newvs;
403201071Sthompsa    data->l_mark = newvs + i;
404201071Sthompsa
405201071Sthompsa    data->stacksize = newsize;
406201071Sthompsa    data->s_last = data->s_base + newsize - 1;
407201071Sthompsa    return 0;
408201071Sthompsa}
409201071Sthompsa
410201071Sthompsa#if YYPURE || defined(YY_NO_LEAKS)
411201071Sthompsastatic void yyfreestack(YYSTACKDATA *data)
412201071Sthompsa{
413201071Sthompsa    free(data->s_base);
414201071Sthompsa    free(data->l_base);
415201071Sthompsa    memset(data, 0, sizeof(*data));
416201071Sthompsa}
417201071Sthompsa#else
418201071Sthompsa#define yyfreestack(data) /* nothing */
419201701Sthompsa#endif
420201701Sthompsa
421201071Sthompsa#define YYABORT  goto yyabort
422201071Sthompsa#define YYREJECT goto yyabort
423201071Sthompsa#define YYACCEPT goto yyaccept
424201071Sthompsa#define YYERROR  goto yyerrlab
425201071Sthompsa
426201071Sthompsaint
427201071SthompsaYYPARSE_DECL()
428201071Sthompsa{
429201071Sthompsa    int yym, yyn, yystate;
430201071Sthompsa#if YYDEBUG
431201071Sthompsa    const char *yys;
432201071Sthompsa
433201071Sthompsa    if ((yys = getenv("YYDEBUG")) != 0)
434201071Sthompsa    {
435201071Sthompsa        yyn = *yys;
436201071Sthompsa        if (yyn >= '0' && yyn <= '9')
437201071Sthompsa            yydebug = yyn - '0';
438201071Sthompsa    }
439201071Sthompsa#endif
440201071Sthompsa
441201071Sthompsa    yynerrs = 0;
442201071Sthompsa    yyerrflag = 0;
443201071Sthompsa    yychar = YYEMPTY;
444201071Sthompsa    yystate = 0;
445184610Salfred
446201071Sthompsa#if YYPURE
447200887Sthompsa    memset(&yystack, 0, sizeof(yystack));
448184610Salfred#endif
449188074Sthompsa
450188076Sthompsa    if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
451200886Sthompsa    yystack.s_mark = yystack.s_base;
452188076Sthompsa    yystack.l_mark = yystack.l_base;
453188076Sthompsa    yystate = 0;
454188076Sthompsa    *yystack.s_mark = 0;
455188076Sthompsa
456188076Sthompsayyloop:
457188076Sthompsa    if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
458188076Sthompsa    if (yychar < 0)
459188076Sthompsa    {
460188076Sthompsa        if ((yychar = YYLEX) < 0) yychar = YYEOF;
461188076Sthompsa#if YYDEBUG
462188076Sthompsa        if (yydebug)
463188076Sthompsa        {
464188076Sthompsa            yys = yyname[YYTRANSLATE(yychar)];
465188076Sthompsa            printf("%sdebug: state %d, reading %d (%s)\n",
466188076Sthompsa                    YYPREFIX, yystate, yychar, yys);
467188076Sthompsa        }
468188076Sthompsa#endif
469188076Sthompsa    }
470188076Sthompsa    if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
471188076Sthompsa            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
472188076Sthompsa    {
473188076Sthompsa#if YYDEBUG
474188076Sthompsa        if (yydebug)
475200886Sthompsa            printf("%sdebug: state %d, shifting to state %d\n",
476200886Sthompsa                    YYPREFIX, yystate, yytable[yyn]);
477200886Sthompsa#endif
478200886Sthompsa        if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
479200886Sthompsa        {
480200886Sthompsa            goto yyoverflow;
481200886Sthompsa        }
482200886Sthompsa        yystate = yytable[yyn];
483200886Sthompsa        *++yystack.s_mark = yytable[yyn];
484200886Sthompsa        *++yystack.l_mark = yylval;
485200886Sthompsa        yychar = YYEMPTY;
486200886Sthompsa        if (yyerrflag > 0)  --yyerrflag;
487200886Sthompsa        goto yyloop;
488200886Sthompsa    }
489200886Sthompsa    if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
490200886Sthompsa            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
491200886Sthompsa    {
492200886Sthompsa        yyn = yytable[yyn];
493200886Sthompsa        goto yyreduce;
494200886Sthompsa    }
495200886Sthompsa    if (yyerrflag) goto yyinrecovery;
496200886Sthompsa
497200886Sthompsa    YYERROR_CALL("syntax error");
498188074Sthompsa
499184610Salfred    goto yyerrlab;
500184610Salfred
501194228Sthompsayyerrlab:
502184610Salfred    ++yynerrs;
503184610Salfred
504184610Salfredyyinrecovery:
505184610Salfred    if (yyerrflag < 3)
506194228Sthompsa    {
507184610Salfred        yyerrflag = 3;
508184610Salfred        for (;;)
509188074Sthompsa        {
510184610Salfred            if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
511184610Salfred                    yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
512184610Salfred            {
513194228Sthompsa#if YYDEBUG
514184610Salfred                if (yydebug)
515184610Salfred                    printf("%sdebug: state %d, error recovery shifting\
516184610Salfred to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
517184610Salfred#endif
518184610Salfred                if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
519184610Salfred                {
520194228Sthompsa                    goto yyoverflow;
521184610Salfred                }
522184610Salfred                yystate = yytable[yyn];
523184610Salfred                *++yystack.s_mark = yytable[yyn];
524184610Salfred                *++yystack.l_mark = yylval;
525184610Salfred                goto yyloop;
526184610Salfred            }
527184610Salfred            else
528194228Sthompsa            {
529184610Salfred#if YYDEBUG
530184610Salfred                if (yydebug)
531184610Salfred                    printf("%sdebug: error recovery discarding state %d\n",
532194228Sthompsa                            YYPREFIX, *yystack.s_mark);
533194228Sthompsa#endif
534194228Sthompsa                if (yystack.s_mark <= yystack.s_base) goto yyabort;
535184610Salfred                --yystack.s_mark;
536184610Salfred                --yystack.l_mark;
537200886Sthompsa            }
538200886Sthompsa        }
539200886Sthompsa    }
540200886Sthompsa    else
541200886Sthompsa    {
542200886Sthompsa        if (yychar == YYEOF) goto yyabort;
543200886Sthompsa#if YYDEBUG
544200886Sthompsa        if (yydebug)
545200886Sthompsa        {
546200886Sthompsa            yys = yyname[YYTRANSLATE(yychar)];
547200886Sthompsa            printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
548200886Sthompsa                    YYPREFIX, yystate, yychar, yys);
549184610Salfred        }
550184610Salfred#endif
551194228Sthompsa        yychar = YYEMPTY;
552194228Sthompsa        goto yyloop;
553194228Sthompsa    }
554184610Salfred
555184610Salfredyyreduce:
556184610Salfred#if YYDEBUG
557184610Salfred    if (yydebug)
558184610Salfred        printf("%sdebug: state %d, reducing by rule %d (%s)\n",
559184610Salfred                YYPREFIX, yystate, yyn, yyrule[yyn]);
560194228Sthompsa#endif
561184610Salfred    yym = yylen[yyn];
562184610Salfred    if (yym)
563184610Salfred        yyval = yystack.l_mark[1-yym];
564194228Sthompsa    else
565194228Sthompsa        memset(&yyval, 0, sizeof yyval);
566184610Salfred    switch (yyn)
567184610Salfred    {
568184610Salfredcase 3:
569184610Salfred#line 35 "calc2.y"
570194228Sthompsa	{  yyerrok ; }
571184610Salfredbreak;
572184610Salfredcase 4:
573184610Salfred#line 39 "calc2.y"
574194228Sthompsa	{  printf("%d\n",yystack.l_mark[0]);}
575184610Salfredbreak;
576184610Salfredcase 5:
577184610Salfred#line 41 "calc2.y"
578184610Salfred	{  regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
579194228Sthompsabreak;
580194228Sthompsacase 6:
581194228Sthompsa#line 45 "calc2.y"
582194228Sthompsa	{  yyval = yystack.l_mark[-1]; }
583184610Salfredbreak;
584184610Salfredcase 7:
585194228Sthompsa#line 47 "calc2.y"
586184610Salfred	{  yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
587184610Salfredbreak;
588184610Salfredcase 8:
589184610Salfred#line 49 "calc2.y"
590184610Salfred	{  yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
591184610Salfredbreak;
592184610Salfredcase 9:
593184610Salfred#line 51 "calc2.y"
594184610Salfred	{  yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
595194228Sthompsabreak;
596194228Sthompsacase 10:
597194228Sthompsa#line 53 "calc2.y"
598194228Sthompsa	{  yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
599184610Salfredbreak;
600184610Salfredcase 11:
601194228Sthompsa#line 55 "calc2.y"
602194228Sthompsa	{  yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
603194228Sthompsabreak;
604194228Sthompsacase 12:
605184610Salfred#line 57 "calc2.y"
606194228Sthompsa	{  yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
607184610Salfredbreak;
608184610Salfredcase 13:
609184610Salfred#line 59 "calc2.y"
610184610Salfred	{  yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
611184610Salfredbreak;
612184610Salfredcase 14:
613184610Salfred#line 61 "calc2.y"
614194228Sthompsa	{  yyval = - yystack.l_mark[0]; }
615184610Salfredbreak;
616184610Salfredcase 15:
617184610Salfred#line 63 "calc2.y"
618184610Salfred	{  yyval = regs[yystack.l_mark[0]]; }
619184610Salfredbreak;
620184610Salfredcase 17:
621194228Sthompsa#line 68 "calc2.y"
622184610Salfred	{  yyval = yystack.l_mark[0]; (*base) = (yystack.l_mark[0]==0) ? 8 : 10; }
623184610Salfredbreak;
624192984Sthompsacase 18:
625194228Sthompsa#line 70 "calc2.y"
626184610Salfred	{  yyval = (*base) * yystack.l_mark[-1] + yystack.l_mark[0]; }
627184610Salfredbreak;
628184610Salfred#line 629 "calc2.tab.c"
629184610Salfred    }
630184610Salfred    yystack.s_mark -= yym;
631184610Salfred    yystate = *yystack.s_mark;
632184610Salfred    yystack.l_mark -= yym;
633184610Salfred    yym = yylhs[yyn];
634184610Salfred    if (yystate == 0 && yym == 0)
635184610Salfred    {
636184610Salfred#if YYDEBUG
637184610Salfred        if (yydebug)
638194228Sthompsa            printf("%sdebug: after reduction, shifting from state 0 to\
639184610Salfred state %d\n", YYPREFIX, YYFINAL);
640194228Sthompsa#endif
641194228Sthompsa        yystate = YYFINAL;
642194228Sthompsa        *++yystack.s_mark = YYFINAL;
643194228Sthompsa        *++yystack.l_mark = yyval;
644184610Salfred        if (yychar < 0)
645194228Sthompsa        {
646184610Salfred            if ((yychar = YYLEX) < 0) yychar = YYEOF;
647194228Sthompsa#if YYDEBUG
648184610Salfred            if (yydebug)
649184610Salfred            {
650184610Salfred                yys = yyname[YYTRANSLATE(yychar)];
651184610Salfred                printf("%sdebug: state %d, reading %d (%s)\n",
652184610Salfred                        YYPREFIX, YYFINAL, yychar, yys);
653184610Salfred            }
654184610Salfred#endif
655184610Salfred        }
656184610Salfred        if (yychar == YYEOF) goto yyaccept;
657194228Sthompsa        goto yyloop;
658184610Salfred    }
659184610Salfred    if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
660184610Salfred            yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
661184610Salfred        yystate = yytable[yyn];
662184610Salfred    else
663184610Salfred        yystate = yydgoto[yym];
664184610Salfred#if YYDEBUG
665184610Salfred    if (yydebug)
666184610Salfred        printf("%sdebug: after reduction, shifting from state %d \
667184610Salfredto state %d\n", YYPREFIX, *yystack.s_mark, yystate);
668184610Salfred#endif
669184610Salfred    if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
670194228Sthompsa    {
671184610Salfred        goto yyoverflow;
672184610Salfred    }
673184610Salfred    *++yystack.s_mark = (YYINT) yystate;
674184610Salfred    *++yystack.l_mark = yyval;
675184610Salfred    goto yyloop;
676184610Salfred
677184610Salfredyyoverflow:
678184610Salfred    YYERROR_CALL("yacc stack overflow");
679184610Salfred
680194228Sthompsayyabort:
681194228Sthompsa    yyfreestack(&yystack);
682184610Salfred    return (1);
683184610Salfred
684184610Salfredyyaccept:
685184610Salfred    yyfreestack(&yystack);
686184610Salfred    return (0);
687184610Salfred}
688184610Salfred