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