1/*	$NetBSD: error.tab.c,v 1.1.1.4 2011/09/10 21:22:03 christos Exp $	*/
2
3#ifndef lint
4/* static const char yysccsid[] = "@(#)yaccpar	1.9 (Berkeley) 02/21/93"; */
5static char rcsid[] = "$NetBSD: error.tab.c,v 1.3 2010/12/24 02:58:21 christos Exp $";
6#endif
7
8#define YYBYACC 1
9#define YYMAJOR 1
10#define YYMINOR 9
11
12#define YYEMPTY        (-1)
13#define yyclearin      (yychar = YYEMPTY)
14#define yyerrok        (yyerrflag = 0)
15#define YYRECOVERING() (yyerrflag != 0)
16
17
18#ifndef yyparse
19#define yyparse    error_parse
20#endif /* yyparse */
21
22#ifndef yylex
23#define yylex      error_lex
24#endif /* yylex */
25
26#ifndef yyerror
27#define yyerror    error_error
28#endif /* yyerror */
29
30#ifndef yychar
31#define yychar     error_char
32#endif /* yychar */
33
34#ifndef yyval
35#define yyval      error_val
36#endif /* yyval */
37
38#ifndef yylval
39#define yylval     error_lval
40#endif /* yylval */
41
42#ifndef yydebug
43#define yydebug    error_debug
44#endif /* yydebug */
45
46#ifndef yynerrs
47#define yynerrs    error_nerrs
48#endif /* yynerrs */
49
50#ifndef yyerrflag
51#define yyerrflag  error_errflag
52#endif /* yyerrflag */
53
54#ifndef yylhs
55#define yylhs      error_lhs
56#endif /* yylhs */
57
58#ifndef yylen
59#define yylen      error_len
60#endif /* yylen */
61
62#ifndef yydefred
63#define yydefred   error_defred
64#endif /* yydefred */
65
66#ifndef yydgoto
67#define yydgoto    error_dgoto
68#endif /* yydgoto */
69
70#ifndef yysindex
71#define yysindex   error_sindex
72#endif /* yysindex */
73
74#ifndef yyrindex
75#define yyrindex   error_rindex
76#endif /* yyrindex */
77
78#ifndef yygindex
79#define yygindex   error_gindex
80#endif /* yygindex */
81
82#ifndef yytable
83#define yytable    error_table
84#endif /* yytable */
85
86#ifndef yycheck
87#define yycheck    error_check
88#endif /* yycheck */
89
90#ifndef yyname
91#define yyname     error_name
92#endif /* yyname */
93
94#ifndef yyrule
95#define yyrule     error_rule
96#endif /* yyrule */
97#define YYPREFIX "error_"
98
99#define YYPURE 0
100
101
102#ifndef YYSTYPE
103typedef int YYSTYPE;
104#endif
105
106/* compatibility with bison */
107#ifdef YYPARSE_PARAM
108/* compatibility with FreeBSD */
109# ifdef YYPARSE_PARAM_TYPE
110#  define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
111# else
112#  define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
113# endif
114#else
115# define YYPARSE_DECL() yyparse(void)
116#endif
117
118/* Parameters sent to lex. */
119#ifdef YYLEX_PARAM
120# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
121# define YYLEX yylex(YYLEX_PARAM)
122#else
123# define YYLEX_DECL() yylex(void)
124# define YYLEX yylex()
125#endif
126
127/* Parameters sent to yyerror. */
128#define YYERROR_DECL() yyerror(const char *s)
129#define YYERROR_CALL(msg) yyerror(msg)
130
131extern int YYPARSE_DECL();
132
133#define YYERRCODE 256
134static const short error_lhs[] = {                       -1,
135    0,
136};
137static const short error_len[] = {                        2,
138    1,
139};
140static const short error_defred[] = {                     0,
141    1,    0,
142};
143static const short error_dgoto[] = {                      2,
144};
145static const short error_sindex[] = {                  -256,
146    0,    0,
147};
148static const short error_rindex[] = {                     0,
149    0,    0,
150};
151static const short error_gindex[] = {                     0,
152};
153#define YYTABLESIZE 0
154static const short error_table[] = {                      1,
155};
156static const short error_check[] = {                    256,
157};
158#define YYFINAL 2
159#ifndef YYDEBUG
160#define YYDEBUG 0
161#endif
162#define YYMAXTOKEN 0
163#if YYDEBUG
164static const char *yyname[] = {
165
166"end-of-file",
167};
168static const char *yyrule[] = {
169"$accept : S",
170"S : error",
171
172};
173#endif
174
175int      yydebug;
176int      yynerrs;
177
178int      yyerrflag;
179int      yychar;
180YYSTYPE  yyval;
181YYSTYPE  yylval;
182
183/* define the initial stack-sizes */
184#ifdef YYSTACKSIZE
185#undef YYMAXDEPTH
186#define YYMAXDEPTH  YYSTACKSIZE
187#else
188#ifdef YYMAXDEPTH
189#define YYSTACKSIZE YYMAXDEPTH
190#else
191#define YYSTACKSIZE 500
192#define YYMAXDEPTH  500
193#endif
194#endif
195
196#define YYINITSTACKSIZE 500
197
198typedef struct {
199    unsigned stacksize;
200    short    *s_base;
201    short    *s_mark;
202    short    *s_last;
203    YYSTYPE  *l_base;
204    YYSTYPE  *l_mark;
205} YYSTACKDATA;
206/* variables for the parser stack */
207static YYSTACKDATA yystack;
208#line 4 "error.y"
209
210#include <stdio.h>
211
212#ifdef YYBYACC
213extern int YYLEX_DECL();
214static void YYERROR_DECL();
215#endif
216
217int
218main(void)
219{
220    printf("yyparse() = %d\n", yyparse());
221    return 0;
222}
223
224int
225yylex(void)
226{
227    return -1;
228}
229
230static void
231yyerror(const char* s)
232{
233    printf("%s\n", s);
234}
235#line 233 "error.tab.c"
236
237#if YYDEBUG
238#include <stdio.h>		/* needed for printf */
239#endif
240
241#include <stdlib.h>	/* needed for malloc, etc */
242#include <string.h>	/* needed for memset */
243
244/* allocate initial stack or double stack size, up to YYMAXDEPTH */
245static int yygrowstack(YYSTACKDATA *data)
246{
247    int i;
248    unsigned newsize;
249    short *newss;
250    YYSTYPE *newvs;
251
252    if ((newsize = data->stacksize) == 0)
253        newsize = YYINITSTACKSIZE;
254    else if (newsize >= YYMAXDEPTH)
255        return -1;
256    else if ((newsize *= 2) > YYMAXDEPTH)
257        newsize = YYMAXDEPTH;
258
259    i = data->s_mark - data->s_base;
260    newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
261    if (newss == 0)
262        return -1;
263
264    data->s_base = newss;
265    data->s_mark = newss + i;
266
267    newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
268    if (newvs == 0)
269        return -1;
270
271    data->l_base = newvs;
272    data->l_mark = newvs + i;
273
274    data->stacksize = newsize;
275    data->s_last = data->s_base + newsize - 1;
276    return 0;
277}
278
279#if YYPURE || defined(YY_NO_LEAKS)
280static void yyfreestack(YYSTACKDATA *data)
281{
282    free(data->s_base);
283    free(data->l_base);
284    memset(data, 0, sizeof(*data));
285}
286#else
287#define yyfreestack(data) /* nothing */
288#endif
289
290#define YYABORT  goto yyabort
291#define YYREJECT goto yyabort
292#define YYACCEPT goto yyaccept
293#define YYERROR  goto yyerrlab
294
295int
296YYPARSE_DECL()
297{
298    int yym, yyn, yystate;
299#if YYDEBUG
300    const char *yys;
301
302    if ((yys = getenv("YYDEBUG")) != 0)
303    {
304        yyn = *yys;
305        if (yyn >= '0' && yyn <= '9')
306            yydebug = yyn - '0';
307    }
308#endif
309
310    yynerrs = 0;
311    yyerrflag = 0;
312    yychar = YYEMPTY;
313    yystate = 0;
314
315#if YYPURE
316    memset(&yystack, 0, sizeof(yystack));
317#endif
318
319    if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
320    yystack.s_mark = yystack.s_base;
321    yystack.l_mark = yystack.l_base;
322    yystate = 0;
323    *yystack.s_mark = 0;
324
325yyloop:
326    if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
327    if (yychar < 0)
328    {
329        if ((yychar = YYLEX) < 0) yychar = 0;
330#if YYDEBUG
331        if (yydebug)
332        {
333            yys = 0;
334            if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
335            if (!yys) yys = "illegal-symbol";
336            printf("%sdebug: state %d, reading %d (%s)\n",
337                    YYPREFIX, yystate, yychar, yys);
338        }
339#endif
340    }
341    if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
342            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
343    {
344#if YYDEBUG
345        if (yydebug)
346            printf("%sdebug: state %d, shifting to state %d\n",
347                    YYPREFIX, yystate, yytable[yyn]);
348#endif
349        if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
350        {
351            goto yyoverflow;
352        }
353        yystate = yytable[yyn];
354        *++yystack.s_mark = yytable[yyn];
355        *++yystack.l_mark = yylval;
356        yychar = YYEMPTY;
357        if (yyerrflag > 0)  --yyerrflag;
358        goto yyloop;
359    }
360    if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
361            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
362    {
363        yyn = yytable[yyn];
364        goto yyreduce;
365    }
366    if (yyerrflag) goto yyinrecovery;
367
368    yyerror("syntax error");
369
370    goto yyerrlab;
371
372yyerrlab:
373    ++yynerrs;
374
375yyinrecovery:
376    if (yyerrflag < 3)
377    {
378        yyerrflag = 3;
379        for (;;)
380        {
381            if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
382                    yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
383            {
384#if YYDEBUG
385                if (yydebug)
386                    printf("%sdebug: state %d, error recovery shifting\
387 to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
388#endif
389                if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
390                {
391                    goto yyoverflow;
392                }
393                yystate = yytable[yyn];
394                *++yystack.s_mark = yytable[yyn];
395                *++yystack.l_mark = yylval;
396                goto yyloop;
397            }
398            else
399            {
400#if YYDEBUG
401                if (yydebug)
402                    printf("%sdebug: error recovery discarding state %d\n",
403                            YYPREFIX, *yystack.s_mark);
404#endif
405                if (yystack.s_mark <= yystack.s_base) goto yyabort;
406                --yystack.s_mark;
407                --yystack.l_mark;
408            }
409        }
410    }
411    else
412    {
413        if (yychar == 0) goto yyabort;
414#if YYDEBUG
415        if (yydebug)
416        {
417            yys = 0;
418            if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
419            if (!yys) yys = "illegal-symbol";
420            printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
421                    YYPREFIX, yystate, yychar, yys);
422        }
423#endif
424        yychar = YYEMPTY;
425        goto yyloop;
426    }
427
428yyreduce:
429#if YYDEBUG
430    if (yydebug)
431        printf("%sdebug: state %d, reducing by rule %d (%s)\n",
432                YYPREFIX, yystate, yyn, yyrule[yyn]);
433#endif
434    yym = yylen[yyn];
435    if (yym)
436        yyval = yystack.l_mark[1-yym];
437    else
438        memset(&yyval, 0, sizeof yyval);
439    switch (yyn)
440    {
441    }
442    yystack.s_mark -= yym;
443    yystate = *yystack.s_mark;
444    yystack.l_mark -= yym;
445    yym = yylhs[yyn];
446    if (yystate == 0 && yym == 0)
447    {
448#if YYDEBUG
449        if (yydebug)
450            printf("%sdebug: after reduction, shifting from state 0 to\
451 state %d\n", YYPREFIX, YYFINAL);
452#endif
453        yystate = YYFINAL;
454        *++yystack.s_mark = YYFINAL;
455        *++yystack.l_mark = yyval;
456        if (yychar < 0)
457        {
458            if ((yychar = YYLEX) < 0) yychar = 0;
459#if YYDEBUG
460            if (yydebug)
461            {
462                yys = 0;
463                if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
464                if (!yys) yys = "illegal-symbol";
465                printf("%sdebug: state %d, reading %d (%s)\n",
466                        YYPREFIX, YYFINAL, yychar, yys);
467            }
468#endif
469        }
470        if (yychar == 0) goto yyaccept;
471        goto yyloop;
472    }
473    if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
474            yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
475        yystate = yytable[yyn];
476    else
477        yystate = yydgoto[yym];
478#if YYDEBUG
479    if (yydebug)
480        printf("%sdebug: after reduction, shifting from state %d \
481to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
482#endif
483    if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
484    {
485        goto yyoverflow;
486    }
487    *++yystack.s_mark = (short) yystate;
488    *++yystack.l_mark = yyval;
489    goto yyloop;
490
491yyoverflow:
492    yyerror("yacc stack overflow");
493
494yyabort:
495    yyfreestack(&yystack);
496    return (1);
497
498yyaccept:
499    yyfreestack(&yystack);
500    return (0);
501}
502