1 /* $NetBSD: pure_error.tab.c,v 1.1.1.4 2013/04/06 14:45:27 christos Exp $ */
4 static const char yysccsid
[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
12 #define yyclearin (yychar = YYEMPTY)
13 #define yyerrok (yyerrflag = 0)
14 #define YYRECOVERING() (yyerrflag != 0)
18 #define yyparse error_parse
22 #define yylex error_lex
26 #define yyerror error_error
30 #define yychar error_char
34 #define yyval error_val
38 #define yylval error_lval
42 #define yydebug error_debug
46 #define yynerrs error_nerrs
50 #define yyerrflag error_errflag
51 #endif /* yyerrflag */
54 #define yylhs error_lhs
58 #define yylen error_len
62 #define yydefred error_defred
66 #define yydgoto error_dgoto
70 #define yysindex error_sindex
74 #define yyrindex error_rindex
78 #define yygindex error_gindex
82 #define yytable error_table
86 #define yycheck error_check
90 #define yyname error_name
94 #define yyrule error_rule
96 #define YYPREFIX "error_"
100 #line 2 "pure_error.y"
104 #define YYLEX_PARAM &yylval
105 #define YYLEX_DECL() yylex(YYSTYPE *yylval)
106 #define YYERROR_DECL() yyerror(const char *s)
108 static void YYERROR_DECL();
111 #line 110 "pure_error.tab.c"
117 /* compatibility with bison */
119 /* compatibility with FreeBSD */
120 # ifdef YYPARSE_PARAM_TYPE
121 # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
123 # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
126 # define YYPARSE_DECL() yyparse(void)
129 /* Parameters sent to lex. */
131 # ifdef YYLEX_PARAM_TYPE
132 # define YYLEX_DECL() yylex(YYSTYPE *yylval, YYLEX_PARAM_TYPE YYLEX_PARAM)
134 # define YYLEX_DECL() yylex(YYSTYPE *yylval, void * YYLEX_PARAM)
136 # define YYLEX yylex(&yylval, YYLEX_PARAM)
138 # define YYLEX_DECL() yylex(YYSTYPE *yylval)
139 # define YYLEX yylex(&yylval)
142 /* Parameters sent to yyerror. */
144 #define YYERROR_DECL() yyerror(const char *s)
147 #define YYERROR_CALL(msg) yyerror(msg)
150 extern int YYPARSE_DECL();
152 #define YYERRCODE 256
153 static const short error_lhs
[] = { -1,
156 static const short error_len
[] = { 2,
159 static const short error_defred
[] = { 0,
162 static const short error_dgoto
[] = { 2,
164 static const short error_sindex
[] = { -256,
167 static const short error_rindex
[] = { 0,
170 static const short error_gindex
[] = { 0,
172 #define YYTABLESIZE 0
173 static const short error_table
[] = { 1,
175 static const short error_check
[] = { 256,
183 static const char *yyname
[] = {
187 static const char *yyrule
[] = {
197 /* define the initial stack-sizes */
200 #define YYMAXDEPTH YYSTACKSIZE
203 #define YYSTACKSIZE YYMAXDEPTH
205 #define YYSTACKSIZE 500
206 #define YYMAXDEPTH 500
210 #define YYINITSTACKSIZE 500
220 #line 17 "pure_error.y"
225 extern int YYLEX_DECL();
231 printf("yyparse() = %d\n", yyparse());
236 yylex(YYSTYPE
*value
)
238 return value
? 0 : -1;
242 yyerror(const char* s
)
246 #line 245 "pure_error.tab.c"
249 #include <stdio.h> /* needed for printf */
252 #include <stdlib.h> /* needed for malloc, etc */
253 #include <string.h> /* needed for memset */
255 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
256 static int yygrowstack(YYSTACKDATA
*data
)
263 if ((newsize
= data
->stacksize
) == 0)
264 newsize
= YYINITSTACKSIZE
;
265 else if (newsize
>= YYMAXDEPTH
)
267 else if ((newsize
*= 2) > YYMAXDEPTH
)
268 newsize
= YYMAXDEPTH
;
270 i
= (int) (data
->s_mark
- data
->s_base
);
271 newss
= (short *)realloc(data
->s_base
, newsize
* sizeof(*newss
));
275 data
->s_base
= newss
;
276 data
->s_mark
= newss
+ i
;
278 newvs
= (YYSTYPE
*)realloc(data
->l_base
, newsize
* sizeof(*newvs
));
282 data
->l_base
= newvs
;
283 data
->l_mark
= newvs
+ i
;
285 data
->stacksize
= newsize
;
286 data
->s_last
= data
->s_base
+ newsize
- 1;
290 #if YYPURE || defined(YY_NO_LEAKS)
291 static void yyfreestack(YYSTACKDATA
*data
)
295 memset(data
, 0, sizeof(*data
));
298 #define yyfreestack(data) /* nothing */
301 #define YYABORT goto yyabort
302 #define YYREJECT goto yyabort
303 #define YYACCEPT goto yyaccept
304 #define YYERROR goto yyerrlab
314 /* variables for the parser stack */
316 int yym
, yyn
, yystate
;
320 if ((yys
= getenv("YYDEBUG")) != 0)
323 if (yyn
>= '0' && yyn
<= '9')
334 memset(&yystack
, 0, sizeof(yystack
));
337 if (yystack
.s_base
== NULL
&& yygrowstack(&yystack
)) goto yyoverflow
;
338 yystack
.s_mark
= yystack
.s_base
;
339 yystack
.l_mark
= yystack
.l_base
;
344 if ((yyn
= yydefred
[yystate
]) != 0) goto yyreduce
;
347 if ((yychar
= YYLEX
) < 0) yychar
= 0;
352 if (yychar
<= YYMAXTOKEN
) yys
= yyname
[yychar
];
353 if (!yys
) yys
= "illegal-symbol";
354 printf("%sdebug: state %d, reading %d (%s)\n",
355 YYPREFIX
, yystate
, yychar
, yys
);
359 if ((yyn
= yysindex
[yystate
]) && (yyn
+= yychar
) >= 0 &&
360 yyn
<= YYTABLESIZE
&& yycheck
[yyn
] == yychar
)
364 printf("%sdebug: state %d, shifting to state %d\n",
365 YYPREFIX
, yystate
, yytable
[yyn
]);
367 if (yystack
.s_mark
>= yystack
.s_last
&& yygrowstack(&yystack
))
371 yystate
= yytable
[yyn
];
372 *++yystack
.s_mark
= yytable
[yyn
];
373 *++yystack
.l_mark
= yylval
;
375 if (yyerrflag
> 0) --yyerrflag
;
378 if ((yyn
= yyrindex
[yystate
]) && (yyn
+= yychar
) >= 0 &&
379 yyn
<= YYTABLESIZE
&& yycheck
[yyn
] == yychar
)
384 if (yyerrflag
) goto yyinrecovery
;
386 yyerror("syntax error");
399 if ((yyn
= yysindex
[*yystack
.s_mark
]) && (yyn
+= YYERRCODE
) >= 0 &&
400 yyn
<= YYTABLESIZE
&& yycheck
[yyn
] == YYERRCODE
)
404 printf("%sdebug: state %d, error recovery shifting\
405 to state %d\n", YYPREFIX
, *yystack
.s_mark
, yytable
[yyn
]);
407 if (yystack
.s_mark
>= yystack
.s_last
&& yygrowstack(&yystack
))
411 yystate
= yytable
[yyn
];
412 *++yystack
.s_mark
= yytable
[yyn
];
413 *++yystack
.l_mark
= yylval
;
420 printf("%sdebug: error recovery discarding state %d\n",
421 YYPREFIX
, *yystack
.s_mark
);
423 if (yystack
.s_mark
<= yystack
.s_base
) goto yyabort
;
431 if (yychar
== 0) goto yyabort
;
436 if (yychar
<= YYMAXTOKEN
) yys
= yyname
[yychar
];
437 if (!yys
) yys
= "illegal-symbol";
438 printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
439 YYPREFIX
, yystate
, yychar
, yys
);
449 printf("%sdebug: state %d, reducing by rule %d (%s)\n",
450 YYPREFIX
, yystate
, yyn
, yyrule
[yyn
]);
454 yyval
= yystack
.l_mark
[1-yym
];
456 memset(&yyval
, 0, sizeof yyval
);
460 yystack
.s_mark
-= yym
;
461 yystate
= *yystack
.s_mark
;
462 yystack
.l_mark
-= yym
;
464 if (yystate
== 0 && yym
== 0)
468 printf("%sdebug: after reduction, shifting from state 0 to\
469 state %d\n", YYPREFIX
, YYFINAL
);
472 *++yystack
.s_mark
= YYFINAL
;
473 *++yystack
.l_mark
= yyval
;
476 if ((yychar
= YYLEX
) < 0) yychar
= 0;
481 if (yychar
<= YYMAXTOKEN
) yys
= yyname
[yychar
];
482 if (!yys
) yys
= "illegal-symbol";
483 printf("%sdebug: state %d, reading %d (%s)\n",
484 YYPREFIX
, YYFINAL
, yychar
, yys
);
488 if (yychar
== 0) goto yyaccept
;
491 if ((yyn
= yygindex
[yym
]) && (yyn
+= yystate
) >= 0 &&
492 yyn
<= YYTABLESIZE
&& yycheck
[yyn
] == yystate
)
493 yystate
= yytable
[yyn
];
495 yystate
= yydgoto
[yym
];
498 printf("%sdebug: after reduction, shifting from state %d \
499 to state %d\n", YYPREFIX
, *yystack
.s_mark
, yystate
);
501 if (yystack
.s_mark
>= yystack
.s_last
&& yygrowstack(&yystack
))
505 *++yystack
.s_mark
= (short) yystate
;
506 *++yystack
.l_mark
= yyval
;
510 yyerror("yacc stack overflow");
513 yyfreestack(&yystack
);
517 yyfreestack(&yystack
);