Home | History | Annotate | Line # | Download | only in yacc
rename_debug.c revision 1.1.1.7
      1  1.1.1.3  christos /*	$NetBSD: rename_debug.c,v 1.1.1.7 2024/09/14 21:25:37 christos Exp $	*/
      2  1.1.1.3  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.1.6  christos #define YYMAJOR 2
      9  1.1.1.6  christos #define YYMINOR 0
     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.1.7  christos typedef int 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.1.5  christos #if YYDEBUG
     72      1.1  christos int      yydebug;
     73  1.1.1.5  christos #endif
     74      1.1  christos 
     75      1.1  christos int      yyerrflag;
     76      1.1  christos int      yychar;
     77      1.1  christos YYSTYPE  yyval;
     78      1.1  christos YYSTYPE  yylval;
     79  1.1.1.5  christos int      yynerrs;
     80      1.1  christos 
     81      1.1  christos /* define the initial stack-sizes */
     82      1.1  christos #ifdef YYSTACKSIZE
     83      1.1  christos #undef YYMAXDEPTH
     84      1.1  christos #define YYMAXDEPTH  YYSTACKSIZE
     85      1.1  christos #else
     86      1.1  christos #ifdef YYMAXDEPTH
     87      1.1  christos #define YYSTACKSIZE YYMAXDEPTH
     88      1.1  christos #else
     89      1.1  christos #define YYSTACKSIZE 10000
     90      1.1  christos #define YYMAXDEPTH  10000
     91      1.1  christos #endif
     92      1.1  christos #endif
     93      1.1  christos 
     94      1.1  christos #define YYINITSTACKSIZE 200
     95      1.1  christos 
     96      1.1  christos typedef struct {
     97      1.1  christos     unsigned stacksize;
     98      1.1  christos     YYINT    *s_base;
     99      1.1  christos     YYINT    *s_mark;
    100      1.1  christos     YYINT    *s_last;
    101      1.1  christos     YYSTYPE  *l_base;
    102      1.1  christos     YYSTYPE  *l_mark;
    103      1.1  christos } YYSTACKDATA;
    104      1.1  christos /* variables for the parser stack */
    105      1.1  christos static YYSTACKDATA yystack;
    106      1.1  christos #line 12 "code_debug.y"
    107      1.1  christos 
    108      1.1  christos #include <stdio.h>
    109      1.1  christos 
    110      1.1  christos #ifdef YYBYACC
    111      1.1  christos extern int YYLEX_DECL();
    112      1.1  christos #endif
    113      1.1  christos 
    114      1.1  christos int
    115      1.1  christos main(void)
    116      1.1  christos {
    117      1.1  christos     printf("yyparse() = %d\n", yyparse());
    118      1.1  christos     return 0;
    119      1.1  christos }
    120      1.1  christos 
    121      1.1  christos int
    122      1.1  christos yylex(void)
    123      1.1  christos {
    124      1.1  christos     return -1;
    125      1.1  christos }
    126      1.1  christos 
    127      1.1  christos static void
    128      1.1  christos yyerror(const char* s)
    129      1.1  christos {
    130      1.1  christos     printf("%s\n", s);
    131      1.1  christos }
    132  1.1.1.5  christos #line 132 "rename_debug.c"
    133      1.1  christos 
    134      1.1  christos #if YYDEBUG
    135  1.1.1.4  christos #include <stdio.h>	/* needed for printf */
    136      1.1  christos #endif
    137      1.1  christos 
    138      1.1  christos #include <stdlib.h>	/* needed for malloc, etc */
    139      1.1  christos #include <string.h>	/* needed for memset */
    140      1.1  christos 
    141      1.1  christos /* allocate initial stack or double stack size, up to YYMAXDEPTH */
    142      1.1  christos static int yygrowstack(YYSTACKDATA *data)
    143      1.1  christos {
    144      1.1  christos     int i;
    145      1.1  christos     unsigned newsize;
    146      1.1  christos     YYINT *newss;
    147      1.1  christos     YYSTYPE *newvs;
    148      1.1  christos 
    149      1.1  christos     if ((newsize = data->stacksize) == 0)
    150      1.1  christos         newsize = YYINITSTACKSIZE;
    151      1.1  christos     else if (newsize >= YYMAXDEPTH)
    152      1.1  christos         return YYENOMEM;
    153      1.1  christos     else if ((newsize *= 2) > YYMAXDEPTH)
    154      1.1  christos         newsize = YYMAXDEPTH;
    155      1.1  christos 
    156      1.1  christos     i = (int) (data->s_mark - data->s_base);
    157      1.1  christos     newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
    158      1.1  christos     if (newss == 0)
    159      1.1  christos         return YYENOMEM;
    160      1.1  christos 
    161      1.1  christos     data->s_base = newss;
    162      1.1  christos     data->s_mark = newss + i;
    163      1.1  christos 
    164      1.1  christos     newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
    165      1.1  christos     if (newvs == 0)
    166      1.1  christos         return YYENOMEM;
    167      1.1  christos 
    168      1.1  christos     data->l_base = newvs;
    169      1.1  christos     data->l_mark = newvs + i;
    170      1.1  christos 
    171      1.1  christos     data->stacksize = newsize;
    172      1.1  christos     data->s_last = data->s_base + newsize - 1;
    173      1.1  christos     return 0;
    174      1.1  christos }
    175      1.1  christos 
    176      1.1  christos #if YYPURE || defined(YY_NO_LEAKS)
    177      1.1  christos static void yyfreestack(YYSTACKDATA *data)
    178      1.1  christos {
    179      1.1  christos     free(data->s_base);
    180      1.1  christos     free(data->l_base);
    181      1.1  christos     memset(data, 0, sizeof(*data));
    182      1.1  christos }
    183      1.1  christos #else
    184      1.1  christos #define yyfreestack(data) /* nothing */
    185      1.1  christos #endif
    186      1.1  christos 
    187      1.1  christos #define YYABORT  goto yyabort
    188      1.1  christos #define YYREJECT goto yyabort
    189      1.1  christos #define YYACCEPT goto yyaccept
    190      1.1  christos #define YYERROR  goto yyerrlab
    191      1.1  christos 
    192      1.1  christos int
    193      1.1  christos YYPARSE_DECL()
    194      1.1  christos {
    195      1.1  christos     int yym, yyn, yystate;
    196      1.1  christos #if YYDEBUG
    197      1.1  christos     const char *yys;
    198      1.1  christos 
    199      1.1  christos     if ((yys = getenv("YYDEBUG")) != 0)
    200      1.1  christos     {
    201      1.1  christos         yyn = *yys;
    202      1.1  christos         if (yyn >= '0' && yyn <= '9')
    203      1.1  christos             yydebug = yyn - '0';
    204      1.1  christos     }
    205      1.1  christos #endif
    206      1.1  christos 
    207  1.1.1.7  christos     /* yym is set below */
    208  1.1.1.7  christos     /* yyn is set below */
    209      1.1  christos     yynerrs = 0;
    210      1.1  christos     yyerrflag = 0;
    211      1.1  christos     yychar = YYEMPTY;
    212      1.1  christos     yystate = 0;
    213      1.1  christos 
    214      1.1  christos #if YYPURE
    215      1.1  christos     memset(&yystack, 0, sizeof(yystack));
    216      1.1  christos #endif
    217      1.1  christos 
    218      1.1  christos     if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
    219      1.1  christos     yystack.s_mark = yystack.s_base;
    220      1.1  christos     yystack.l_mark = yystack.l_base;
    221      1.1  christos     yystate = 0;
    222      1.1  christos     *yystack.s_mark = 0;
    223      1.1  christos 
    224      1.1  christos yyloop:
    225      1.1  christos     if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
    226      1.1  christos     if (yychar < 0)
    227      1.1  christos     {
    228  1.1.1.4  christos         yychar = YYLEX;
    229  1.1.1.4  christos         if (yychar < 0) yychar = YYEOF;
    230      1.1  christos #if YYDEBUG
    231      1.1  christos         if (yydebug)
    232      1.1  christos         {
    233  1.1.1.4  christos             if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
    234      1.1  christos             printf("%sdebug: state %d, reading %d (%s)\n",
    235      1.1  christos                     YYPREFIX, yystate, yychar, yys);
    236      1.1  christos         }
    237      1.1  christos #endif
    238      1.1  christos     }
    239  1.1.1.4  christos     if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
    240  1.1.1.4  christos             yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
    241      1.1  christos     {
    242      1.1  christos #if YYDEBUG
    243      1.1  christos         if (yydebug)
    244      1.1  christos             printf("%sdebug: state %d, shifting to state %d\n",
    245      1.1  christos                     YYPREFIX, yystate, yytable[yyn]);
    246      1.1  christos #endif
    247  1.1.1.4  christos         if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
    248      1.1  christos         yystate = yytable[yyn];
    249      1.1  christos         *++yystack.s_mark = yytable[yyn];
    250      1.1  christos         *++yystack.l_mark = yylval;
    251      1.1  christos         yychar = YYEMPTY;
    252      1.1  christos         if (yyerrflag > 0)  --yyerrflag;
    253      1.1  christos         goto yyloop;
    254      1.1  christos     }
    255  1.1.1.4  christos     if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
    256  1.1.1.4  christos             yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
    257      1.1  christos     {
    258      1.1  christos         yyn = yytable[yyn];
    259      1.1  christos         goto yyreduce;
    260      1.1  christos     }
    261  1.1.1.4  christos     if (yyerrflag != 0) goto yyinrecovery;
    262      1.1  christos 
    263      1.1  christos     YYERROR_CALL("syntax error");
    264      1.1  christos 
    265  1.1.1.4  christos     goto yyerrlab; /* redundant goto avoids 'unused label' warning */
    266      1.1  christos yyerrlab:
    267      1.1  christos     ++yynerrs;
    268      1.1  christos 
    269      1.1  christos yyinrecovery:
    270      1.1  christos     if (yyerrflag < 3)
    271      1.1  christos     {
    272      1.1  christos         yyerrflag = 3;
    273      1.1  christos         for (;;)
    274      1.1  christos         {
    275  1.1.1.4  christos             if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
    276  1.1.1.4  christos                     yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
    277      1.1  christos             {
    278      1.1  christos #if YYDEBUG
    279      1.1  christos                 if (yydebug)
    280      1.1  christos                     printf("%sdebug: state %d, error recovery shifting\
    281      1.1  christos  to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
    282      1.1  christos #endif
    283  1.1.1.4  christos                 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
    284      1.1  christos                 yystate = yytable[yyn];
    285      1.1  christos                 *++yystack.s_mark = yytable[yyn];
    286      1.1  christos                 *++yystack.l_mark = yylval;
    287      1.1  christos                 goto yyloop;
    288      1.1  christos             }
    289      1.1  christos             else
    290      1.1  christos             {
    291      1.1  christos #if YYDEBUG
    292      1.1  christos                 if (yydebug)
    293      1.1  christos                     printf("%sdebug: error recovery discarding state %d\n",
    294      1.1  christos                             YYPREFIX, *yystack.s_mark);
    295      1.1  christos #endif
    296      1.1  christos                 if (yystack.s_mark <= yystack.s_base) goto yyabort;
    297      1.1  christos                 --yystack.s_mark;
    298      1.1  christos                 --yystack.l_mark;
    299      1.1  christos             }
    300      1.1  christos         }
    301      1.1  christos     }
    302      1.1  christos     else
    303      1.1  christos     {
    304      1.1  christos         if (yychar == YYEOF) goto yyabort;
    305      1.1  christos #if YYDEBUG
    306      1.1  christos         if (yydebug)
    307      1.1  christos         {
    308  1.1.1.4  christos             if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
    309      1.1  christos             printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
    310      1.1  christos                     YYPREFIX, yystate, yychar, yys);
    311      1.1  christos         }
    312      1.1  christos #endif
    313      1.1  christos         yychar = YYEMPTY;
    314      1.1  christos         goto yyloop;
    315      1.1  christos     }
    316      1.1  christos 
    317      1.1  christos yyreduce:
    318      1.1  christos #if YYDEBUG
    319      1.1  christos     if (yydebug)
    320      1.1  christos         printf("%sdebug: state %d, reducing by rule %d (%s)\n",
    321      1.1  christos                 YYPREFIX, yystate, yyn, yyrule[yyn]);
    322      1.1  christos #endif
    323      1.1  christos     yym = yylen[yyn];
    324  1.1.1.4  christos     if (yym > 0)
    325      1.1  christos         yyval = yystack.l_mark[1-yym];
    326      1.1  christos     else
    327      1.1  christos         memset(&yyval, 0, sizeof yyval);
    328  1.1.1.4  christos 
    329      1.1  christos     switch (yyn)
    330      1.1  christos     {
    331      1.1  christos     }
    332      1.1  christos     yystack.s_mark -= yym;
    333      1.1  christos     yystate = *yystack.s_mark;
    334      1.1  christos     yystack.l_mark -= yym;
    335      1.1  christos     yym = yylhs[yyn];
    336      1.1  christos     if (yystate == 0 && yym == 0)
    337      1.1  christos     {
    338      1.1  christos #if YYDEBUG
    339      1.1  christos         if (yydebug)
    340      1.1  christos             printf("%sdebug: after reduction, shifting from state 0 to\
    341      1.1  christos  state %d\n", YYPREFIX, YYFINAL);
    342      1.1  christos #endif
    343      1.1  christos         yystate = YYFINAL;
    344      1.1  christos         *++yystack.s_mark = YYFINAL;
    345      1.1  christos         *++yystack.l_mark = yyval;
    346      1.1  christos         if (yychar < 0)
    347      1.1  christos         {
    348  1.1.1.4  christos             yychar = YYLEX;
    349  1.1.1.4  christos             if (yychar < 0) yychar = YYEOF;
    350      1.1  christos #if YYDEBUG
    351      1.1  christos             if (yydebug)
    352      1.1  christos             {
    353  1.1.1.4  christos                 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
    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.1.4  christos     if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
    363  1.1.1.4  christos             yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) 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.1.4  christos     if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
    373      1.1  christos     *++yystack.s_mark = (YYINT) yystate;
    374      1.1  christos     *++yystack.l_mark = yyval;
    375      1.1  christos     goto yyloop;
    376      1.1  christos 
    377      1.1  christos yyoverflow:
    378      1.1  christos     YYERROR_CALL("yacc stack overflow");
    379      1.1  christos 
    380      1.1  christos yyabort:
    381      1.1  christos     yyfreestack(&yystack);
    382      1.1  christos     return (1);
    383      1.1  christos 
    384      1.1  christos yyaccept:
    385      1.1  christos     yyfreestack(&yystack);
    386      1.1  christos     return (0);
    387      1.1  christos }
    388