Home | History | Annotate | Line # | Download | only in yacc
rename_debug.c revision 1.1
      1  1.1  christos /*	$NetBSD: rename_debug.c,v 1.1 2015/01/03 22:58:23 christos Exp $	*/
      2  1.1  christos 
      3  1.1  christos /* original parser id follows */
      4  1.1  christos /* yysccsid[] = "@(#)yaccpar	1.9 (Berkeley) 02/21/93" */
      5  1.1  christos /* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */
      6  1.1  christos 
      7  1.1  christos #define YYBYACC 1
      8  1.1  christos #define YYMAJOR 1
      9  1.1  christos #define YYMINOR 9
     10  1.1  christos #define YYCHECK "yyyymmdd"
     11  1.1  christos 
     12  1.1  christos #define YYEMPTY        (-1)
     13  1.1  christos #define yyclearin      (yychar = YYEMPTY)
     14  1.1  christos #define yyerrok        (yyerrflag = 0)
     15  1.1  christos #define YYRECOVERING() (yyerrflag != 0)
     16  1.1  christos #define YYENOMEM       (-2)
     17  1.1  christos #define YYEOF          0
     18  1.1  christos #line 17 "rename_debug.c"
     19  1.1  christos #include "rename_debug.i"
     20  1.1  christos #include "rename_debug.h"
     21  1.1  christos typedef short YYINT;
     22  1.1  christos static const YYINT yylhs[] = {                           -1,
     23  1.1  christos     0,
     24  1.1  christos };
     25  1.1  christos static const YYINT yylen[] = {                            2,
     26  1.1  christos     1,
     27  1.1  christos };
     28  1.1  christos static const YYINT yydefred[] = {                         0,
     29  1.1  christos     1,    0,
     30  1.1  christos };
     31  1.1  christos static const YYINT yydgoto[] = {                          2,
     32  1.1  christos };
     33  1.1  christos static const YYINT yysindex[] = {                      -256,
     34  1.1  christos     0,    0,
     35  1.1  christos };
     36  1.1  christos static const YYINT yyrindex[] = {                         0,
     37  1.1  christos     0,    0,
     38  1.1  christos };
     39  1.1  christos static const YYINT yygindex[] = {                         0,
     40  1.1  christos };
     41  1.1  christos #define YYTABLESIZE 0
     42  1.1  christos static const YYINT yytable[] = {                          1,
     43  1.1  christos };
     44  1.1  christos static const YYINT yycheck[] = {                        256,
     45  1.1  christos };
     46  1.1  christos #define YYFINAL 2
     47  1.1  christos #ifndef YYDEBUG
     48  1.1  christos #define YYDEBUG 1
     49  1.1  christos #endif
     50  1.1  christos #define YYMAXTOKEN 256
     51  1.1  christos #define YYUNDFTOKEN 259
     52  1.1  christos #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
     53  1.1  christos #if YYDEBUG
     54  1.1  christos static const char *const yyname[] = {
     55  1.1  christos 
     56  1.1  christos "end-of-file",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,
     57  1.1  christos 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,
     58  1.1  christos 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,
     59  1.1  christos 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,
     60  1.1  christos 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,
     61  1.1  christos 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,
     62  1.1  christos 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,"illegal-symbol",
     63  1.1  christos };
     64  1.1  christos static const char *const yyrule[] = {
     65  1.1  christos "$accept : S",
     66  1.1  christos "S : error",
     67  1.1  christos 
     68  1.1  christos };
     69  1.1  christos #endif
     70  1.1  christos 
     71  1.1  christos int      yydebug;
     72  1.1  christos int      yynerrs;
     73  1.1  christos 
     74  1.1  christos int      yyerrflag;
     75  1.1  christos int      yychar;
     76  1.1  christos YYSTYPE  yyval;
     77  1.1  christos YYSTYPE  yylval;
     78  1.1  christos 
     79  1.1  christos /* define the initial stack-sizes */
     80  1.1  christos #ifdef YYSTACKSIZE
     81  1.1  christos #undef YYMAXDEPTH
     82  1.1  christos #define YYMAXDEPTH  YYSTACKSIZE
     83  1.1  christos #else
     84  1.1  christos #ifdef YYMAXDEPTH
     85  1.1  christos #define YYSTACKSIZE YYMAXDEPTH
     86  1.1  christos #else
     87  1.1  christos #define YYSTACKSIZE 10000
     88  1.1  christos #define YYMAXDEPTH  10000
     89  1.1  christos #endif
     90  1.1  christos #endif
     91  1.1  christos 
     92  1.1  christos #define YYINITSTACKSIZE 200
     93  1.1  christos 
     94  1.1  christos typedef struct {
     95  1.1  christos     unsigned stacksize;
     96  1.1  christos     YYINT    *s_base;
     97  1.1  christos     YYINT    *s_mark;
     98  1.1  christos     YYINT    *s_last;
     99  1.1  christos     YYSTYPE  *l_base;
    100  1.1  christos     YYSTYPE  *l_mark;
    101  1.1  christos } YYSTACKDATA;
    102  1.1  christos /* variables for the parser stack */
    103  1.1  christos static YYSTACKDATA yystack;
    104  1.1  christos #line 12 "code_debug.y"
    105  1.1  christos 
    106  1.1  christos #include <stdio.h>
    107  1.1  christos 
    108  1.1  christos #ifdef YYBYACC
    109  1.1  christos extern int YYLEX_DECL();
    110  1.1  christos #endif
    111  1.1  christos 
    112  1.1  christos int
    113  1.1  christos main(void)
    114  1.1  christos {
    115  1.1  christos     printf("yyparse() = %d\n", yyparse());
    116  1.1  christos     return 0;
    117  1.1  christos }
    118  1.1  christos 
    119  1.1  christos int
    120  1.1  christos yylex(void)
    121  1.1  christos {
    122  1.1  christos     return -1;
    123  1.1  christos }
    124  1.1  christos 
    125  1.1  christos static void
    126  1.1  christos yyerror(const char* s)
    127  1.1  christos {
    128  1.1  christos     printf("%s\n", s);
    129  1.1  christos }
    130  1.1  christos #line 130 "rename_debug.c"
    131  1.1  christos 
    132  1.1  christos #if YYDEBUG
    133  1.1  christos #include <stdio.h>		/* needed for printf */
    134  1.1  christos #endif
    135  1.1  christos 
    136  1.1  christos #include <stdlib.h>	/* needed for malloc, etc */
    137  1.1  christos #include <string.h>	/* needed for memset */
    138  1.1  christos 
    139  1.1  christos /* allocate initial stack or double stack size, up to YYMAXDEPTH */
    140  1.1  christos static int yygrowstack(YYSTACKDATA *data)
    141  1.1  christos {
    142  1.1  christos     int i;
    143  1.1  christos     unsigned newsize;
    144  1.1  christos     YYINT *newss;
    145  1.1  christos     YYSTYPE *newvs;
    146  1.1  christos 
    147  1.1  christos     if ((newsize = data->stacksize) == 0)
    148  1.1  christos         newsize = YYINITSTACKSIZE;
    149  1.1  christos     else if (newsize >= YYMAXDEPTH)
    150  1.1  christos         return YYENOMEM;
    151  1.1  christos     else if ((newsize *= 2) > YYMAXDEPTH)
    152  1.1  christos         newsize = YYMAXDEPTH;
    153  1.1  christos 
    154  1.1  christos     i = (int) (data->s_mark - data->s_base);
    155  1.1  christos     newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
    156  1.1  christos     if (newss == 0)
    157  1.1  christos         return YYENOMEM;
    158  1.1  christos 
    159  1.1  christos     data->s_base = newss;
    160  1.1  christos     data->s_mark = newss + i;
    161  1.1  christos 
    162  1.1  christos     newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
    163  1.1  christos     if (newvs == 0)
    164  1.1  christos         return YYENOMEM;
    165  1.1  christos 
    166  1.1  christos     data->l_base = newvs;
    167  1.1  christos     data->l_mark = newvs + i;
    168  1.1  christos 
    169  1.1  christos     data->stacksize = newsize;
    170  1.1  christos     data->s_last = data->s_base + newsize - 1;
    171  1.1  christos     return 0;
    172  1.1  christos }
    173  1.1  christos 
    174  1.1  christos #if YYPURE || defined(YY_NO_LEAKS)
    175  1.1  christos static void yyfreestack(YYSTACKDATA *data)
    176  1.1  christos {
    177  1.1  christos     free(data->s_base);
    178  1.1  christos     free(data->l_base);
    179  1.1  christos     memset(data, 0, sizeof(*data));
    180  1.1  christos }
    181  1.1  christos #else
    182  1.1  christos #define yyfreestack(data) /* nothing */
    183  1.1  christos #endif
    184  1.1  christos 
    185  1.1  christos #define YYABORT  goto yyabort
    186  1.1  christos #define YYREJECT goto yyabort
    187  1.1  christos #define YYACCEPT goto yyaccept
    188  1.1  christos #define YYERROR  goto yyerrlab
    189  1.1  christos 
    190  1.1  christos int
    191  1.1  christos YYPARSE_DECL()
    192  1.1  christos {
    193  1.1  christos     int yym, yyn, yystate;
    194  1.1  christos #if YYDEBUG
    195  1.1  christos     const char *yys;
    196  1.1  christos 
    197  1.1  christos     if ((yys = getenv("YYDEBUG")) != 0)
    198  1.1  christos     {
    199  1.1  christos         yyn = *yys;
    200  1.1  christos         if (yyn >= '0' && yyn <= '9')
    201  1.1  christos             yydebug = yyn - '0';
    202  1.1  christos     }
    203  1.1  christos #endif
    204  1.1  christos 
    205  1.1  christos     yynerrs = 0;
    206  1.1  christos     yyerrflag = 0;
    207  1.1  christos     yychar = YYEMPTY;
    208  1.1  christos     yystate = 0;
    209  1.1  christos 
    210  1.1  christos #if YYPURE
    211  1.1  christos     memset(&yystack, 0, sizeof(yystack));
    212  1.1  christos #endif
    213  1.1  christos 
    214  1.1  christos     if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
    215  1.1  christos     yystack.s_mark = yystack.s_base;
    216  1.1  christos     yystack.l_mark = yystack.l_base;
    217  1.1  christos     yystate = 0;
    218  1.1  christos     *yystack.s_mark = 0;
    219  1.1  christos 
    220  1.1  christos yyloop:
    221  1.1  christos     if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
    222  1.1  christos     if (yychar < 0)
    223  1.1  christos     {
    224  1.1  christos         if ((yychar = YYLEX) < 0) yychar = YYEOF;
    225  1.1  christos #if YYDEBUG
    226  1.1  christos         if (yydebug)
    227  1.1  christos         {
    228  1.1  christos             yys = yyname[YYTRANSLATE(yychar)];
    229  1.1  christos             printf("%sdebug: state %d, reading %d (%s)\n",
    230  1.1  christos                     YYPREFIX, yystate, yychar, yys);
    231  1.1  christos         }
    232  1.1  christos #endif
    233  1.1  christos     }
    234  1.1  christos     if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
    235  1.1  christos             yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
    236  1.1  christos     {
    237  1.1  christos #if YYDEBUG
    238  1.1  christos         if (yydebug)
    239  1.1  christos             printf("%sdebug: state %d, shifting to state %d\n",
    240  1.1  christos                     YYPREFIX, yystate, yytable[yyn]);
    241  1.1  christos #endif
    242  1.1  christos         if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
    243  1.1  christos         {
    244  1.1  christos             goto yyoverflow;
    245  1.1  christos         }
    246  1.1  christos         yystate = yytable[yyn];
    247  1.1  christos         *++yystack.s_mark = yytable[yyn];
    248  1.1  christos         *++yystack.l_mark = yylval;
    249  1.1  christos         yychar = YYEMPTY;
    250  1.1  christos         if (yyerrflag > 0)  --yyerrflag;
    251  1.1  christos         goto yyloop;
    252  1.1  christos     }
    253  1.1  christos     if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
    254  1.1  christos             yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
    255  1.1  christos     {
    256  1.1  christos         yyn = yytable[yyn];
    257  1.1  christos         goto yyreduce;
    258  1.1  christos     }
    259  1.1  christos     if (yyerrflag) goto yyinrecovery;
    260  1.1  christos 
    261  1.1  christos     YYERROR_CALL("syntax error");
    262  1.1  christos 
    263  1.1  christos     goto yyerrlab;
    264  1.1  christos 
    265  1.1  christos yyerrlab:
    266  1.1  christos     ++yynerrs;
    267  1.1  christos 
    268  1.1  christos yyinrecovery:
    269  1.1  christos     if (yyerrflag < 3)
    270  1.1  christos     {
    271  1.1  christos         yyerrflag = 3;
    272  1.1  christos         for (;;)
    273  1.1  christos         {
    274  1.1  christos             if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
    275  1.1  christos                     yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
    276  1.1  christos             {
    277  1.1  christos #if YYDEBUG
    278  1.1  christos                 if (yydebug)
    279  1.1  christos                     printf("%sdebug: state %d, error recovery shifting\
    280  1.1  christos  to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
    281  1.1  christos #endif
    282  1.1  christos                 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
    283  1.1  christos                 {
    284  1.1  christos                     goto yyoverflow;
    285  1.1  christos                 }
    286  1.1  christos                 yystate = yytable[yyn];
    287  1.1  christos                 *++yystack.s_mark = yytable[yyn];
    288  1.1  christos                 *++yystack.l_mark = yylval;
    289  1.1  christos                 goto yyloop;
    290  1.1  christos             }
    291  1.1  christos             else
    292  1.1  christos             {
    293  1.1  christos #if YYDEBUG
    294  1.1  christos                 if (yydebug)
    295  1.1  christos                     printf("%sdebug: error recovery discarding state %d\n",
    296  1.1  christos                             YYPREFIX, *yystack.s_mark);
    297  1.1  christos #endif
    298  1.1  christos                 if (yystack.s_mark <= yystack.s_base) goto yyabort;
    299  1.1  christos                 --yystack.s_mark;
    300  1.1  christos                 --yystack.l_mark;
    301  1.1  christos             }
    302  1.1  christos         }
    303  1.1  christos     }
    304  1.1  christos     else
    305  1.1  christos     {
    306  1.1  christos         if (yychar == YYEOF) goto yyabort;
    307  1.1  christos #if YYDEBUG
    308  1.1  christos         if (yydebug)
    309  1.1  christos         {
    310  1.1  christos             yys = yyname[YYTRANSLATE(yychar)];
    311  1.1  christos             printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
    312  1.1  christos                     YYPREFIX, yystate, yychar, yys);
    313  1.1  christos         }
    314  1.1  christos #endif
    315  1.1  christos         yychar = YYEMPTY;
    316  1.1  christos         goto yyloop;
    317  1.1  christos     }
    318  1.1  christos 
    319  1.1  christos yyreduce:
    320  1.1  christos #if YYDEBUG
    321  1.1  christos     if (yydebug)
    322  1.1  christos         printf("%sdebug: state %d, reducing by rule %d (%s)\n",
    323  1.1  christos                 YYPREFIX, yystate, yyn, yyrule[yyn]);
    324  1.1  christos #endif
    325  1.1  christos     yym = yylen[yyn];
    326  1.1  christos     if (yym)
    327  1.1  christos         yyval = yystack.l_mark[1-yym];
    328  1.1  christos     else
    329  1.1  christos         memset(&yyval, 0, sizeof yyval);
    330  1.1  christos     switch (yyn)
    331  1.1  christos     {
    332  1.1  christos     }
    333  1.1  christos     yystack.s_mark -= yym;
    334  1.1  christos     yystate = *yystack.s_mark;
    335  1.1  christos     yystack.l_mark -= yym;
    336  1.1  christos     yym = yylhs[yyn];
    337  1.1  christos     if (yystate == 0 && yym == 0)
    338  1.1  christos     {
    339  1.1  christos #if YYDEBUG
    340  1.1  christos         if (yydebug)
    341  1.1  christos             printf("%sdebug: after reduction, shifting from state 0 to\
    342  1.1  christos  state %d\n", YYPREFIX, YYFINAL);
    343  1.1  christos #endif
    344  1.1  christos         yystate = YYFINAL;
    345  1.1  christos         *++yystack.s_mark = YYFINAL;
    346  1.1  christos         *++yystack.l_mark = yyval;
    347  1.1  christos         if (yychar < 0)
    348  1.1  christos         {
    349  1.1  christos             if ((yychar = YYLEX) < 0) yychar = YYEOF;
    350  1.1  christos #if YYDEBUG
    351  1.1  christos             if (yydebug)
    352  1.1  christos             {
    353  1.1  christos                 yys = yyname[YYTRANSLATE(yychar)];
    354  1.1  christos                 printf("%sdebug: state %d, reading %d (%s)\n",
    355  1.1  christos                         YYPREFIX, YYFINAL, yychar, yys);
    356  1.1  christos             }
    357  1.1  christos #endif
    358  1.1  christos         }
    359  1.1  christos         if (yychar == YYEOF) goto yyaccept;
    360  1.1  christos         goto yyloop;
    361  1.1  christos     }
    362  1.1  christos     if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
    363  1.1  christos             yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
    364  1.1  christos         yystate = yytable[yyn];
    365  1.1  christos     else
    366  1.1  christos         yystate = yydgoto[yym];
    367  1.1  christos #if YYDEBUG
    368  1.1  christos     if (yydebug)
    369  1.1  christos         printf("%sdebug: after reduction, shifting from state %d \
    370  1.1  christos to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
    371  1.1  christos #endif
    372  1.1  christos     if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
    373  1.1  christos     {
    374  1.1  christos         goto yyoverflow;
    375  1.1  christos     }
    376  1.1  christos     *++yystack.s_mark = (YYINT) yystate;
    377  1.1  christos     *++yystack.l_mark = yyval;
    378  1.1  christos     goto yyloop;
    379  1.1  christos 
    380  1.1  christos yyoverflow:
    381  1.1  christos     YYERROR_CALL("yacc stack overflow");
    382  1.1  christos 
    383  1.1  christos yyabort:
    384  1.1  christos     yyfreestack(&yystack);
    385  1.1  christos     return (1);
    386  1.1  christos 
    387  1.1  christos yyaccept:
    388  1.1  christos     yyfreestack(&yystack);
    389  1.1  christos     return (0);
    390  1.1  christos }
    391