2 static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
8 #define YYPATCH 20140101
11 #define yyclearin (yychar = YYEMPTY)
12 #define yyerrok (yyerrflag = 0)
13 #define YYRECOVERING() (yyerrflag != 0)
26 extern int yylex(void);
27 static void yyerror(const char *s);
29 #line 29 "/dev/stdout"
35 /* compatibility with bison */
37 /* compatibility with FreeBSD */
38 # ifdef YYPARSE_PARAM_TYPE
39 # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
41 # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
44 # define YYPARSE_DECL() yyparse(void)
47 /* Parameters sent to lex. */
49 # define YYLEX_DECL() yylex(void *YYLEX_PARAM)
50 # define YYLEX yylex(YYLEX_PARAM)
52 # define YYLEX_DECL() yylex(void)
53 # define YYLEX yylex()
56 /* Parameters sent to yyerror. */
58 #define YYERROR_DECL() yyerror(const char *s)
61 #define YYERROR_CALL(msg) yyerror(msg)
64 extern int YYPARSE_DECL();
70 static const short yylhs[] = { -1,
71 0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
72 2, 2, 2, 2, 2, 2, 3, 3,
74 static const short yylen[] = { 2,
75 0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
76 3, 3, 3, 2, 1, 1, 1, 2,
78 static const short yydefred[] = { 1,
79 0, 0, 17, 0, 0, 0, 0, 0, 0, 3,
80 0, 15, 14, 0, 2, 0, 0, 0, 0, 0,
81 0, 0, 18, 0, 6, 0, 0, 0, 0, 9,
84 static const short yydgoto[] = { 1,
87 static const short yysindex[] = { 0,
88 -40, -7, 0, -55, -38, -38, 1, -29, -247, 0,
89 -38, 0, 0, 22, 0, -38, -38, -38, -38, -38,
90 -38, -38, 0, -29, 0, 51, 60, -20, -20, 0,
93 static const short yyrindex[] = { 0,
94 0, 0, 0, 2, 0, 0, 0, 9, -9, 0,
95 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
96 0, 0, 0, 10, 0, -6, 14, 5, 13, 0,
99 static const short yygindex[] = { 0,
102 #define YYTABLESIZE 220
103 static const short yytable[] = { 6,
104 16, 6, 10, 13, 5, 11, 5, 22, 17, 23,
105 15, 15, 20, 18, 7, 19, 22, 21, 4, 5,
106 0, 20, 8, 12, 0, 0, 21, 16, 16, 0,
107 0, 16, 16, 16, 13, 16, 0, 16, 15, 15,
108 0, 0, 7, 15, 15, 7, 15, 7, 15, 7,
109 8, 12, 0, 8, 12, 8, 0, 8, 22, 17,
110 0, 0, 25, 20, 18, 0, 19, 0, 21, 13,
111 14, 0, 0, 0, 0, 24, 0, 0, 0, 0,
112 26, 27, 28, 29, 30, 31, 32, 22, 17, 0,
113 0, 0, 20, 18, 16, 19, 22, 21, 0, 0,
114 0, 20, 18, 0, 19, 0, 21, 0, 0, 0,
115 0, 0, 0, 0, 16, 0, 0, 13, 0, 0,
116 0, 0, 0, 0, 0, 15, 0, 0, 7, 0,
117 0, 0, 0, 0, 0, 0, 8, 12, 0, 0,
118 0, 0, 0, 0, 0, 16, 0, 0, 0, 0,
119 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
120 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
121 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
122 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
123 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
124 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
125 0, 0, 0, 0, 0, 2, 3, 4, 3, 12,
127 static const short yycheck[] = { 40,
128 10, 40, 10, 10, 45, 61, 45, 37, 38, 257,
129 10, 10, 42, 43, 10, 45, 37, 47, 10, 10,
130 -1, 42, 10, 10, -1, -1, 47, 37, 38, -1,
131 -1, 41, 42, 43, 41, 45, -1, 47, 37, 38,
132 -1, -1, 38, 42, 43, 41, 45, 43, 47, 45,
133 38, 38, -1, 41, 41, 43, -1, 45, 37, 38,
134 -1, -1, 41, 42, 43, -1, 45, -1, 47, 5,
135 6, -1, -1, -1, -1, 11, -1, -1, -1, -1,
136 16, 17, 18, 19, 20, 21, 22, 37, 38, -1,
137 -1, -1, 42, 43, 124, 45, 37, 47, -1, -1,
138 -1, 42, 43, -1, 45, -1, 47, -1, -1, -1,
139 -1, -1, -1, -1, 124, -1, -1, 124, -1, -1,
140 -1, -1, -1, -1, -1, 124, -1, -1, 124, -1,
141 -1, -1, -1, -1, -1, -1, 124, 124, -1, -1,
142 -1, -1, -1, -1, -1, 124, -1, -1, -1, -1,
143 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
144 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
145 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
146 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
147 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
148 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
149 -1, -1, -1, -1, -1, 256, 257, 258, 257, 258,
155 #define YYMAXTOKEN 259
156 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? (YYMAXTOKEN + 1) : (a))
158 static const char *yyname[] = {
160 "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,
161 0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,
162 0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
163 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,
164 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
165 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
166 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
167 0,0,0,0,0,0,"DIGIT","LETTER","UMINUS","illegal-symbol",
169 static const char *yyrule[] = {
172 "list : list stat '\\n'",
173 "list : list error '\\n'",
175 "stat : LETTER '=' expr",
176 "expr : '(' expr ')'",
177 "expr : expr '+' expr",
178 "expr : expr '-' expr",
179 "expr : expr '*' expr",
180 "expr : expr '/' expr",
181 "expr : expr '%' expr",
182 "expr : expr '&' expr",
183 "expr : expr '|' expr",
188 "number : number DIGIT",
201 /* define the initial stack-sizes */
204 #define YYMAXDEPTH YYSTACKSIZE
207 #define YYSTACKSIZE YYMAXDEPTH
209 #define YYSTACKSIZE 10000
210 #define YYMAXDEPTH 10000
214 #define YYINITSTACKSIZE 200
224 /* variables for the parser stack */
225 static YYSTACKDATA yystack;
227 /* start of programs */
232 while(!feof(stdin)) {
239 yyerror(const char *s)
241 fprintf(stderr, "%s\n", s);
247 /* lexical analysis routine */
248 /* returns LETTER for a lower case letter, yylval = 0 through 25 */
249 /* return DIGIT for a digit, yylval = 0 through 9 */
250 /* all other characters are returned immediately */
254 while( (c=getchar()) == ' ' ) { /* skip blanks */ }
256 /* c is now nonblank */
268 #line 267 "/dev/stdout"
271 #include <stdio.h> /* needed for printf */
274 #include <stdlib.h> /* needed for malloc, etc */
275 #include <string.h> /* needed for memset */
277 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
278 static int yygrowstack(YYSTACKDATA *data)
285 if ((newsize = data->stacksize) == 0)
286 newsize = YYINITSTACKSIZE;
287 else if (newsize >= YYMAXDEPTH)
289 else if ((newsize *= 2) > YYMAXDEPTH)
290 newsize = YYMAXDEPTH;
292 i = (int) (data->s_mark - data->s_base);
293 newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
297 data->s_base = newss;
298 data->s_mark = newss + i;
300 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
304 data->l_base = newvs;
305 data->l_mark = newvs + i;
307 data->stacksize = newsize;
308 data->s_last = data->s_base + newsize - 1;
312 #if YYPURE || defined(YY_NO_LEAKS)
313 static void yyfreestack(YYSTACKDATA *data)
317 memset(data, 0, sizeof(*data));
320 #define yyfreestack(data) /* nothing */
323 #define YYABORT goto yyabort
324 #define YYREJECT goto yyabort
325 #define YYACCEPT goto yyaccept
326 #define YYERROR goto yyerrlab
331 int yym, yyn, yystate;
335 if ((yys = getenv("YYDEBUG")) != 0)
338 if (yyn >= '0' && yyn <= '9')
349 memset(&yystack, 0, sizeof(yystack));
352 if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
353 yystack.s_mark = yystack.s_base;
354 yystack.l_mark = yystack.l_base;
359 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
362 if ((yychar = YYLEX) < 0) yychar = 0;
366 yys = yyname[YYTRANSLATE(yychar)];
367 printf("%sdebug: state %d, reading %d (%s)\n",
368 YYPREFIX, yystate, yychar, yys);
372 if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
373 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
377 printf("%sdebug: state %d, shifting to state %d\n",
378 YYPREFIX, yystate, yytable[yyn]);
380 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
384 yystate = yytable[yyn];
385 *++yystack.s_mark = yytable[yyn];
386 *++yystack.l_mark = yylval;
388 if (yyerrflag > 0) --yyerrflag;
391 if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
392 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
397 if (yyerrflag) goto yyinrecovery;
399 yyerror("syntax error");
412 if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
413 yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
417 printf("%sdebug: state %d, error recovery shifting\
418 to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
420 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
424 yystate = yytable[yyn];
425 *++yystack.s_mark = yytable[yyn];
426 *++yystack.l_mark = yylval;
433 printf("%sdebug: error recovery discarding state %d\n",
434 YYPREFIX, *yystack.s_mark);
436 if (yystack.s_mark <= yystack.s_base) goto yyabort;
444 if (yychar == 0) goto yyabort;
448 yys = yyname[YYTRANSLATE(yychar)];
449 printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
450 YYPREFIX, yystate, yychar, yys);
460 printf("%sdebug: state %d, reducing by rule %d (%s)\n",
461 YYPREFIX, yystate, yyn, yyrule[yyn]);
465 yyval = yystack.l_mark[1-yym];
467 memset(&yyval, 0, sizeof yyval);
476 { printf("%d\n",yystack.l_mark[0]);}
480 { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
484 { yyval = yystack.l_mark[-1]; }
488 { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
492 { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
496 { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
500 { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
504 { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
508 { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
512 { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
516 { yyval = - yystack.l_mark[0]; }
520 { yyval = regs[yystack.l_mark[0]]; }
524 { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
528 { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
530 #line 529 "/dev/stdout"
532 yystack.s_mark -= yym;
533 yystate = *yystack.s_mark;
534 yystack.l_mark -= yym;
536 if (yystate == 0 && yym == 0)
540 printf("%sdebug: after reduction, shifting from state 0 to\
541 state %d\n", YYPREFIX, YYFINAL);
544 *++yystack.s_mark = YYFINAL;
545 *++yystack.l_mark = yyval;
548 if ((yychar = YYLEX) < 0) yychar = 0;
552 yys = yyname[YYTRANSLATE(yychar)];
553 printf("%sdebug: state %d, reading %d (%s)\n",
554 YYPREFIX, YYFINAL, yychar, yys);
558 if (yychar == 0) goto yyaccept;
561 if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
562 yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
563 yystate = yytable[yyn];
565 yystate = yydgoto[yym];
568 printf("%sdebug: after reduction, shifting from state %d \
569 to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
571 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
575 *++yystack.s_mark = (short) yystate;
576 *++yystack.l_mark = yyval;
580 yyerror("yacc stack overflow");
583 yyfreestack(&yystack);
587 yyfreestack(&yystack);