#ifndef lint
static char yysccsid[] = "@(#)yaccpar	1.8 (Berkeley) 01/20/90";
#endif
#define YYBYACC 1
#line 2 "xmlgiim.y"
  /* yacc for xml->gm_iim */
#include "xmlgiim.h"
#include "xmlgiimglob.h"
#include <string.h>
char *bsu_now;


#line 11 "xmlgiim.y"
typedef union{
   char *val;
} YYSTYPE;
#line 18 "y.tab.c"
#define SUPPLIER_LIB_START 257
#define SUPPLIER_LIB_END 258
#define CLASS_START 259
#define CLASS_END 260
#define PROPERTY_START 261
#define PROPERTY_END 262
#define TABLE_START 263
#define TABLE_END 264
#define QUOTED_STRING 265
#define GREATER_THAN 266
#define CNAME_START 267
#define CNAME_END 268
#define PNAME_START 269
#define PNAME_END 270
#define PTYPE_START 271
#define PTYPE_END 272
#define COLUMN_START 273
#define COLUMN_END 274
#define TD_START 275
#define TD_END 276
#define TAGGED_TEXT 277
#define YYERRCODE 256
short yylhs[] = {                                        -1,
    0,    1,    2,    2,    4,    9,    9,    5,    6,    7,
    7,   10,   10,   11,   12,    3,   13,   14,    8,    8,
   15,   16,   17,   17,   18,   19,   19,   20,
};
short yylen[] = {                                         2,
    3,    3,    2,    1,    6,    0,    1,    3,    3,    0,
    1,    2,    1,    4,    3,    1,    3,    3,    0,    1,
    3,    3,    2,    1,    3,    2,    1,    3,
};
short yydefred[] = {                                      0,
    0,    0,    0,   16,    0,    0,    0,    4,    0,    2,
    0,    1,    3,    0,    0,    8,    0,    0,    0,    0,
   13,    0,    9,    0,    0,    0,   20,    0,   12,    0,
    0,   15,    0,    0,    0,    0,    0,   24,    0,    0,
    0,   22,    5,    0,    0,   27,   21,   23,   17,    0,
   14,    0,   25,   26,   18,   28,
};
short yydgoto[] = {                                       2,
    3,    7,    5,    8,    9,   15,   19,   26,   35,   20,
   21,   22,   31,   41,   27,   28,   37,   38,   45,   46,
};
short yysindex[] = {                                   -249,
 -255,    0, -247,    0, -245, -255, -244,    0, -243,    0,
 -240,    0,    0, -252, -239,    0, -238, -255, -235, -239,
    0, -246,    0, -237, -255, -247,    0, -242,    0, -236,
 -234,    0, -233, -247, -228, -232, -262,    0, -231, -230,
 -227,    0,    0, -229, -258,    0,    0,    0,    0, -226,
    0, -225,    0,    0,    0,    0,
};
short yyrindex[] = {                                      0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0, -256,    0,    0,    0, -241, -254,
    0,    0,    0,    0,    0, -224,    0,    0,    0,    0,
    0,    0,    0, -222,    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,
    0,    8,   -5,   -7,    0,    0,    0,    0,    0,    0,
   20,    0,    0,    0,    0,    0,    0,    5,    0,   -1,
};
#define YYTABLESIZE 51
short yytable[] = {                                      13,
   11,   47,   10,   10,   11,   11,   10,    1,   11,    4,
   36,    6,   24,   12,    6,   53,   44,   19,   19,   33,
   10,   18,   30,   14,   17,   16,   13,   25,   32,   23,
   36,   43,   42,   34,   51,    6,   40,    7,   49,   29,
   39,   48,   44,   54,    0,   55,   50,   52,    0,    0,
   56,
};
short yycheck[] = {                                       7,
    6,  264,  259,  260,  259,  260,  263,  257,  263,  265,
  273,  259,   18,  258,  259,  274,  275,  259,  260,   25,
  266,  261,  269,  267,  277,  266,   34,  263,  266,  268,
  273,  260,  266,   26,  262,  260,  271,  260,  270,   20,
  277,   37,  275,   45,   -1,  272,  277,  277,   -1,   -1,
  276,
};
#define YYFINAL 2
#ifndef YYDEBUG
#define YYDEBUG 0
#endif
#define YYMAXTOKEN 277
#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,0,0,0,0,0,0,"SUPPLIER_LIB_START",
"SUPPLIER_LIB_END","CLASS_START","CLASS_END","PROPERTY_START","PROPERTY_END",
"TABLE_START","TABLE_END","QUOTED_STRING","GREATER_THAN","CNAME_START",
"CNAME_END","PNAME_START","PNAME_END","PTYPE_START","PTYPE_END","COLUMN_START",
"COLUMN_END","TD_START","TD_END","TAGGED_TEXT",
};
char *yyrule[] = {
"$accept : supplier_library",
"supplier_library : supplier_lib_start class_list SUPPLIER_LIB_END",
"supplier_lib_start : SUPPLIER_LIB_START bsu GREATER_THAN",
"class_list : class_list class",
"class_list : class",
"class : class_start cname opt_property_list opt_table opt_class_list CLASS_END",
"opt_class_list :",
"opt_class_list : class_list",
"class_start : CLASS_START bsu GREATER_THAN",
"cname : CNAME_START TAGGED_TEXT CNAME_END",
"opt_property_list :",
"opt_property_list : property_list",
"property_list : property_list property",
"property_list : property",
"property : property_start pname ptype PROPERTY_END",
"property_start : PROPERTY_START bsu GREATER_THAN",
"bsu : QUOTED_STRING",
"pname : PNAME_START TAGGED_TEXT PNAME_END",
"ptype : PTYPE_START TAGGED_TEXT PTYPE_END",
"opt_table :",
"opt_table : table",
"table : table_start column_list TABLE_END",
"table_start : TABLE_START bsu GREATER_THAN",
"column_list : column_list column",
"column_list : column",
"column : COLUMN_START table_data_list COLUMN_END",
"table_data_list : table_data_list table_data",
"table_data_list : table_data",
"table_data : TD_START TAGGED_TEXT TD_END",
};
#endif
#define yyclearin (yychar=(-1))
#define yyerrok (yyerrflag=0)
#ifdef YYSTACKSIZE
#ifndef YYMAXDEPTH
#define YYMAXDEPTH YYSTACKSIZE
#endif
#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 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("yydebug: state %d, reading %d (%s)\n", yystate,
                    yychar, yys);
        }
#endif
    }
    if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
    {
#if YYDEBUG
        if (yydebug)
            printf("yydebug: state %d, shifting to state %d\n",
                    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("yydebug: state %d, error recovery shifting\
 to state %d\n", *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("yydebug: error recovery discarding state %d\n",
                            *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("yydebug: state %d, error recovery discards token %d (%s)\n",
                    yystate, yychar, yys);
        }
#endif
        yychar = (-1);
        goto yyloop;
    }
yyreduce:
#if YYDEBUG
    if (yydebug)
        printf("yydebug: state %d, reducing by rule %d (%s)\n",
                yystate, yyn, yyrule[yyn]);
#endif
    yym = yylen[yyn];
    yyval = yyvsp[1-yym];
    switch (yyn)
    {
case 2:
#line 31 "xmlgiim.y"
{
            supplier_bsu  = strdup(bsu_now);
            }
break;
case 5:
#line 40 "xmlgiim.y"
{
              level--;
      }
break;
case 8:
#line 52 "xmlgiim.y"
{
              level++;
              if (class_now->level < level)
		{
              class_temp = (struct class*)malloc(sizeof(struct class));
              class_temp->level = level;
	      class_temp->next = NULL;
              class_temp->property_first = NULL;
              class_temp->table = NULL;
              class_temp-> next = NULL;
              class_temp->parent = class_now;
              class_now->first_child = class_temp;
              class_now = class_temp;
              class_now->class_bsu = strdup(bsu_now);
		}
              else if (class_now->level == level)
		{
              class_temp = (struct class*)malloc(sizeof(struct class));
              class_temp->level = level;
              class_temp->parent = class_now->parent;
              class_now->next = class_temp;
              class_now = class_temp;
              class_now->class_bsu = strdup(bsu_now);
		}
              else if (class_now->level - level == 1)
		{
              class_now = class_now->parent;
              class_temp = (struct class*)malloc(sizeof(struct class));
              class_temp->level = level;
              class_temp->parent = class_now->parent;
              class_now->next = class_temp;
              class_now = class_temp;
              class_now->class_bsu = strdup(bsu_now);
		}
	      else {printf("error with class level\n"); 
                    printf("class(%s) level: %d",class_now->class_name,class_now->level); printf("level = %d\n",level);exit(0);}

            }
break;
case 9:
#line 92 "xmlgiim.y"
{
        class_now->class_name = strdup(yyvsp[-1].val);
      }
break;
case 11:
#line 98 "xmlgiim.y"
{
                     class_now->property_first = property_first;
	             property_first = (struct property*)malloc(sizeof(struct property));
                     property_now = property_first;
                     property_first->next = NULL;
                  }
break;
case 14:
#line 110 "xmlgiim.y"
{
            property_temp = (struct property*)malloc(sizeof(struct property));
            property_now->next = property_temp;
            property_temp->next = NULL;
            property_now = property_temp;
         }
break;
case 15:
#line 117 "xmlgiim.y"
{
            property_now->property_bsu  = strdup(bsu_now);
            }
break;
case 16:
#line 122 "xmlgiim.y"
{
      bsu_now = strdup(yyvsp[0].val);
      /* strip off the quotes */
         bsu_now[strlen(bsu_now)-1] = 0;
         bsu_now = &bsu_now[1];
    }
break;
case 17:
#line 130 "xmlgiim.y"
{
            property_now->property_name = strdup(yyvsp[-1].val);
      }
break;
case 18:
#line 134 "xmlgiim.y"
{
            property_now->property_type = strdup(yyvsp[-1].val);
      }
break;
case 20:
#line 140 "xmlgiim.y"
{
              class_now->table = table_now;
              table_now = (struct table*)malloc(sizeof(struct table));
              table_now->column_first = NULL;
          }
break;
case 21:
#line 147 "xmlgiim.y"
{
        table_now->column_first = column_first;
        column_first = (struct column*)malloc(sizeof(struct column));
        column_first->next = NULL;
        column_first->td_first;
        column_now=column_first;
      }
break;
case 22:
#line 155 "xmlgiim.y"
{
              table_now->table_bsu = strdup(bsu_now);
            }
break;
case 25:
#line 164 "xmlgiim.y"
{
         column_now->td_first = td_first;
         column_temp = (struct column*)malloc(sizeof(struct column));
	 column_now->next = column_temp;
         column_temp->next = NULL;
	 column_now = column_temp;
	 td_first = (struct td*)malloc(sizeof(struct td));
	 td_now = td_first;
	 td_now->next = NULL;
       }
break;
case 28:
#line 178 "xmlgiim.y"
{
            td_now->value = strdup(yyvsp[-1].val);
            td_temp = (struct td*)malloc(sizeof(struct td));
            td_now->next = td_temp;
            td_temp->next = NULL;
            td_now = td_temp;
          }
break;
#line 466 "y.tab.c"
    }
    yyssp -= yym;
    yystate = *yyssp;
    yyvsp -= yym;
    yym = yylhs[yyn];
    if (yystate == 0 && yym == 0)
    {
#if YYDEBUG
        if (yydebug)
            printf("yydebug: after reduction, shifting from state 0 to\
 state %d\n", 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("yydebug: state %d, reading %d (%s)\n",
                        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("yydebug: after reduction, shifting from state %d \
to state %d\n", *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);
}
