#ifndef lint
static char yysccsid[] = "@(#)yaccpar	1.9 (Berkeley) 02/21/93";
#endif
#define YYBYACC 1
#define YYMAJOR 1
#define YYMINOR 9
#define yyclearin (yychar=(-1))
#define yyerrok (yyerrflag=0)
#define YYRECOVERING (yyerrflag!=0)
#define YYPREFIX "yy"
#line 2 "agParse.y"
/*
 *  agParse.y
 *  $Id: agParse.y,v 2.5 1999/07/07 19:42:33 bkorb Exp $
 *  Parse rules for the macro definitions
 */

/*
 *  AutoGen copyright 1992-1999 Bruce Korb
 *
 *  AutoGen is free software.
 *  You may redistribute it and/or modify it under the terms of the
 *  GNU General Public License, as published by the Free Software
 *  Foundation; either version 2, or (at your option) any later version.
 *
 *  AutoGen is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with AutoGen.  See the file "COPYING".  If not,
 *  write to:  The Free Software Foundation, Inc.,
 *             59 Temple Place - Suite 330,
 *             Boston,  MA  02111-1307, USA.
 */


/*
 *  Declarations
 */
#include "autogen.h"

extern YYSTYPE addSibMacro( YYSTYPE, YYSTYPE );
extern YYSTYPE makeTextMacro( YYSTYPE, YYSTYPE );
extern YYSTYPE makeBlockMacro( YYSTYPE, YYSTYPE );
extern YYSTYPE findPlace( YYSTYPE, YYSTYPE );
extern YYSTYPE identify( YYSTYPE );

#line 51 "y.tab.c"
#define TK_AUTOGEN 257
#define TK_DEFINITIONS 258
#define TK_END 259
#define TK_VAR_NAME 260
#define TK_OTHER_NAME 261
#define TK_STRING 262
#define TK_NUMBER 263
#define YYERRCODE 256
short yylhs[] = {                                        -1,
    0,    2,    2,    2,    3,    3,    3,    1,    5,    5,
    5,    6,    6,    4,    4,    4,
};
short yylen[] = {                                         2,
    3,    1,    2,    2,    2,    4,    6,    4,    1,    1,
    1,    1,    1,    1,    4,    4,
};
short yydefred[] = {                                      0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,   13,
   12,    0,    0,    4,    1,    3,    5,    0,    8,    0,
    0,   10,   11,    0,    0,    9,   16,   15,    0,    6,
    0,    7,
};
short yydgoto[] = {                                       2,
    6,    7,    8,    9,   25,   12,
};
short yysindex[] = {                                   -246,
 -243,    0, -254, -247,  -75, -254, -242, -254,  -52,    0,
    0,  -41, -255,    0,    0,    0,    0, -123,    0,  -74,
  -72,    0,    0, -254,  -37,    0,    0,    0, -102,    0,
  -35,    0,
};
short yyrindex[] = {                                      0,
    0,    0,    0,    0,  -49,    0,    0, -124,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,
};
short yygindex[] = {                                      0,
   25,   -4,    0,    0,    0,    8,
};
#define YYTABLESIZE 140
short yytable[] = {                                      24,
    2,   14,    1,   16,   20,    5,   17,   21,   18,   14,
    1,   14,   10,   11,    4,   13,   15,   19,   27,   29,
   28,   30,   31,   32,    3,   26,    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,    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,    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,    2,    0,   10,   11,   22,   23,
};
short yycheck[] = {                                     123,
  125,    6,  257,    8,  260,  260,   59,  263,   61,   59,
  257,   61,  260,  261,  258,   91,  259,   59,   93,   24,
   93,   59,  125,   59,    0,   18,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,  259,   -1,  260,  261,  262,  263,
};
#define YYFINAL 2
#ifndef YYDEBUG
#define YYDEBUG 0
#endif
#define YYMAXTOKEN 263
#if YYDEBUG
char *yyname[] = {
"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,
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,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,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,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,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
"TK_AUTOGEN","TK_DEFINITIONS","TK_END","TK_VAR_NAME","TK_OTHER_NAME",
"TK_STRING","TK_NUMBER",
};
char *yyrule[] = {
"$accept : definitions",
"definitions : identity def_list TK_END",
"def_list : definition",
"def_list : definition def_list",
"def_list : identity def_list",
"definition : place ';'",
"definition : place '=' anystring ';'",
"definition : place '=' '{' def_list '}' ';'",
"identity : TK_AUTOGEN TK_DEFINITIONS anyname ';'",
"anystring : anyname",
"anystring : TK_STRING",
"anystring : TK_NUMBER",
"anyname : TK_OTHER_NAME",
"anyname : TK_VAR_NAME",
"place : TK_VAR_NAME",
"place : TK_VAR_NAME '[' TK_NUMBER ']'",
"place : TK_VAR_NAME '[' TK_VAR_NAME ']'",
};
#endif
#ifndef YYSTYPE
typedef int YYSTYPE;
#endif
#ifdef YYSTACKSIZE
#undef YYMAXDEPTH
#define YYMAXDEPTH YYSTACKSIZE
#else
#ifdef YYMAXDEPTH
#define YYSTACKSIZE YYMAXDEPTH
#else
#define YYSTACKSIZE 500
#define YYMAXDEPTH 500
#endif
#endif
int yydebug;
int yynerrs;
int yyerrflag;
int yychar;
short *yyssp;
YYSTYPE *yyvsp;
YYSTYPE yyval;
YYSTYPE yylval;
short yyss[YYSTACKSIZE];
YYSTYPE yyvs[YYSTACKSIZE];
#define yystacksize YYSTACKSIZE
#define YYABORT goto yyabort
#define YYREJECT goto yyabort
#define YYACCEPT goto yyaccept
#define YYERROR goto yyerrlab
int
yyparse()
{
    register int yym, yyn, yystate;
#if YYDEBUG
    register char *yys;
    extern char *getenv();

    if (yys = getenv("YYDEBUG"))
    {
        yyn = *yys;
        if (yyn >= '0' && yyn <= '9')
            yydebug = yyn - '0';
    }
#endif

    yynerrs = 0;
    yyerrflag = 0;
    yychar = (-1);

    yyssp = yyss;
    yyvsp = yyvs;
    *yyssp = yystate = 0;

yyloop:
    if (yyn = yydefred[yystate]) goto yyreduce;
    if (yychar < 0)
    {
        if ((yychar = yylex()) < 0) yychar = 0;
#if YYDEBUG
        if (yydebug)
        {
            yys = 0;
            if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
            if (!yys) yys = "illegal-symbol";
            printf("%sdebug: state %d, reading %d (%s)\n",
                    YYPREFIX, yystate, yychar, yys);
        }
#endif
    }
    if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
    {
#if YYDEBUG
        if (yydebug)
            printf("%sdebug: state %d, shifting to state %d\n",
                    YYPREFIX, yystate, yytable[yyn]);
#endif
        if (yyssp >= yyss + yystacksize - 1)
        {
            goto yyoverflow;
        }
        *++yyssp = yystate = yytable[yyn];
        *++yyvsp = yylval;
        yychar = (-1);
        if (yyerrflag > 0)  --yyerrflag;
        goto yyloop;
    }
    if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
    {
        yyn = yytable[yyn];
        goto yyreduce;
    }
    if (yyerrflag) goto yyinrecovery;
#ifdef lint
    goto yynewerror;
#endif
yynewerror:
    yyerror("syntax error");
#ifdef lint
    goto yyerrlab;
#endif
yyerrlab:
    ++yynerrs;
yyinrecovery:
    if (yyerrflag < 3)
    {
        yyerrflag = 3;
        for (;;)
        {
            if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
                    yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
            {
#if YYDEBUG
                if (yydebug)
                    printf("%sdebug: state %d, error recovery shifting\
 to state %d\n", YYPREFIX, *yyssp, yytable[yyn]);
#endif
                if (yyssp >= yyss + yystacksize - 1)
                {
                    goto yyoverflow;
                }
                *++yyssp = yystate = yytable[yyn];
                *++yyvsp = yylval;
                goto yyloop;
            }
            else
            {
#if YYDEBUG
                if (yydebug)
                    printf("%sdebug: error recovery discarding state %d\n",
                            YYPREFIX, *yyssp);
#endif
                if (yyssp <= yyss) goto yyabort;
                --yyssp;
                --yyvsp;
            }
        }
    }
    else
    {
        if (yychar == 0) goto yyabort;
#if YYDEBUG
        if (yydebug)
        {
            yys = 0;
            if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
            if (!yys) yys = "illegal-symbol";
            printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
                    YYPREFIX, yystate, yychar, yys);
        }
#endif
        yychar = (-1);
        goto yyloop;
    }
yyreduce:
#if YYDEBUG
    if (yydebug)
        printf("%sdebug: state %d, reducing by rule %d (%s)\n",
                YYPREFIX, yystate, yyn, yyrule[yyn]);
#endif
    yym = yylen[yyn];
    yyval = yyvsp[1-yym];
    switch (yyn)
    {
case 1:
#line 54 "agParse.y"
{
                        yyval = makeBlockMacro( (YYSTYPE)&rootEntry, yyvsp[-1] );
                    }
break;
case 2:
#line 63 "agParse.y"
{ yyval = yyvsp[0]; }
break;
case 3:
#line 64 "agParse.y"
{ yyval = addSibMacro( yyvsp[-1], yyvsp[0] ); }
break;
case 4:
#line 65 "agParse.y"
{ yyval = yyvsp[0]; }
break;
case 5:
#line 70 "agParse.y"
{ yyval = makeTextMacro( yyvsp[-1], (YYSTYPE)"" ); }
break;
case 6:
#line 73 "agParse.y"
{ yyval = makeTextMacro( yyvsp[-3], yyvsp[-1] ); }
break;
case 7:
#line 76 "agParse.y"
{ yyval = makeBlockMacro( yyvsp[-5], yyvsp[-2] ); }
break;
case 8:
#line 80 "agParse.y"
{ yyval = identify( yyvsp[-1] ); }
break;
case 9:
#line 83 "agParse.y"
{ yyval = yyvsp[0]; }
break;
case 10:
#line 84 "agParse.y"
{ yyval = yyvsp[0]; }
break;
case 11:
#line 85 "agParse.y"
{ yyval = yyvsp[0]; }
break;
case 12:
#line 88 "agParse.y"
{ yyval = yyvsp[0]; }
break;
case 13:
#line 89 "agParse.y"
{ yyval = yyvsp[0]; }
break;
case 14:
#line 93 "agParse.y"
{ yyval = findPlace( yyvsp[0], (YYSTYPE)NULL ); }
break;
case 15:
#line 96 "agParse.y"
{ yyval = findPlace( yyvsp[-3], yyvsp[-1] ); }
break;
case 16:
#line 99 "agParse.y"
{ yyval = findPlace( yyvsp[-3], yyvsp[-1] ); }
break;
#line 393 "y.tab.c"
    }
    yyssp -= yym;
    yystate = *yyssp;
    yyvsp -= yym;
    yym = yylhs[yyn];
    if (yystate == 0 && yym == 0)
    {
#if YYDEBUG
        if (yydebug)
            printf("%sdebug: after reduction, shifting from state 0 to\
 state %d\n", YYPREFIX, YYFINAL);
#endif
        yystate = YYFINAL;
        *++yyssp = YYFINAL;
        *++yyvsp = yyval;
        if (yychar < 0)
        {
            if ((yychar = yylex()) < 0) yychar = 0;
#if YYDEBUG
            if (yydebug)
            {
                yys = 0;
                if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
                if (!yys) yys = "illegal-symbol";
                printf("%sdebug: state %d, reading %d (%s)\n",
                        YYPREFIX, YYFINAL, yychar, yys);
            }
#endif
        }
        if (yychar == 0) goto yyaccept;
        goto yyloop;
    }
    if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
            yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
        yystate = yytable[yyn];
    else
        yystate = yydgoto[yym];
#if YYDEBUG
    if (yydebug)
        printf("%sdebug: after reduction, shifting from state %d \
to state %d\n", YYPREFIX, *yyssp, yystate);
#endif
    if (yyssp >= yyss + yystacksize - 1)
    {
        goto yyoverflow;
    }
    *++yyssp = yystate;
    *++yyvsp = yyval;
    goto yyloop;
yyoverflow:
    yyerror("yacc stack overflow");
yyabort:
    return (1);
yyaccept:
    return (0);
}
