#ifndef lint
static char yysccsid[] = "@(#)yaccpar	1.8 (Berkeley) 01/20/90";
#endif
#define YYBYACC 1
#line 2 "ct.y"
/*
 * Copyright 1987, 1988 by MIT Student Information Processing Board
 *
 * For copyright info, see copyright.h.
 */
#include <stdio.h>
#include "copyright.h"

char *str_concat3(), *ds(), *generate_rqte(), *malloc(), *realloc(), *quote();
long flag_value();
char *last_token = (char *)NULL;
FILE *output_file;
long gensym_n = 0;

#line 17 "ct.y"
typedef union {
	char *dynstr;
	long flags;
} YYSTYPE;
#line 30 "ct.y"
#include "ss.h"
#line 28 "y.tab.c"
#define COMMAND_TABLE 257
#define REQUEST 258
#define UNKNOWN 259
#define UNIMPLEMENTED 260
#define END 261
#define STRING 262
#define FLAGNAME 263
#define OPTIONS 264
#define YYERRCODE 256
short yylhs[] = {                                        -1,
    0,    2,    3,    3,    4,    4,    4,    4,    6,    6,
    5,    5,    1,    1,
};
short yylen[] = {                                         2,
    4,    3,    2,    0,    9,    7,    3,    7,    3,    2,
    3,    1,    1,    3,
};
short yydefred[] = {                                      0,
    0,    0,    4,    0,    0,    2,    0,    0,    0,    0,
    3,    0,   13,    0,    0,    1,    0,    7,    0,    0,
    0,   14,    0,    0,    0,    0,    0,    6,    0,    8,
    0,    0,   12,   10,    0,    5,    0,    9,   11,
};
short yydgoto[] = {                                       2,
   14,    3,    5,   11,   35,   32,
};
short yysindex[] = {                                   -245,
 -249,    0,    0,  -44, -251,    0, -243, -242, -240,  -42,
    0,  -21,    0,  -43,  -19,    0, -238,    0, -236, -235,
  -16,    0,  -15, -242, -242,  -41,  -38,    0,  -40,    0,
  -39,  -29,    0,    0,  -30,    0, -231,    0,    0,
};
short yyrindex[] = {                                      0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    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,
  -20,    0,    0,    0,    0,    0,
};
#define YYTABLESIZE 223
short yytable[] = {                                      31,
   19,   34,   29,   26,   27,   19,    7,    8,    9,   10,
   38,    1,    4,   37,    6,   18,   16,   28,   12,   13,
   30,   15,   17,   21,   20,   22,   23,   24,   25,   36,
   39,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,   22,   33,
};
short yycheck[] = {                                      40,
   44,   41,   44,   24,   25,   44,  258,  259,  260,  261,
   41,  257,  262,   44,   59,   59,   59,   59,  262,  262,
   59,  262,   44,  262,   44,  262,  262,   44,   44,   59,
  262,   -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,   -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,  262,  262,
};
#define YYFINAL 2
#ifndef YYDEBUG
#define YYDEBUG 0
#endif
#define YYMAXTOKEN 264
#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,"COMMAND_TABLE",
"REQUEST","UNKNOWN","UNIMPLEMENTED","END","STRING","FLAGNAME","OPTIONS",
};
char *yyrule[] = {
"$accept : command_table",
"command_table : header request_list END ';'",
"header : COMMAND_TABLE STRING ';'",
"request_list : request_list request_entry",
"request_list :",
"request_entry : REQUEST STRING ',' STRING ',' namelist ',' options ';'",
"request_entry : REQUEST STRING ',' STRING ',' namelist ';'",
"request_entry : UNKNOWN namelist ';'",
"request_entry : UNIMPLEMENTED STRING ',' STRING ',' namelist ';'",
"options : '(' flag_list ')'",
"options : '(' ')'",
"flag_list : flag_list ',' STRING",
"flag_list : STRING",
"namelist : STRING",
"namelist : namelist ',' STRING",
};
#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 1:
#line 35 "ct.y"
{ write_ct(yyvsp[-3].dynstr, yyvsp[-2].dynstr); }
break;
case 2:
#line 39 "ct.y"
{ yyval.dynstr = yyvsp[-1].dynstr; }
break;
case 3:
#line 43 "ct.y"
{ yyval.dynstr = str_concat3(yyvsp[-1].dynstr, yyvsp[0].dynstr, ""); }
break;
case 4:
#line 45 "ct.y"
{ yyval.dynstr = ""; }
break;
case 5:
#line 49 "ct.y"
{ yyval.dynstr = generate_rqte(yyvsp[-7].dynstr, quote(yyvsp[-5].dynstr), yyvsp[-3].dynstr, yyvsp[-1].flags); }
break;
case 6:
#line 51 "ct.y"
{ yyval.dynstr = generate_rqte(yyvsp[-5].dynstr, quote(yyvsp[-3].dynstr), yyvsp[-1].dynstr, 0); }
break;
case 7:
#line 53 "ct.y"
{ yyval.dynstr = generate_rqte("ss_unknown_request",
					(char *)NULL, yyvsp[-1].dynstr, 0); }
break;
case 8:
#line 56 "ct.y"
{ yyval.dynstr = generate_rqte("ss_unimplemented", quote(yyvsp[-3].dynstr), yyvsp[-1].dynstr, 3); }
break;
case 9:
#line 60 "ct.y"
{ yyval.flags = yyvsp[-1].flags; }
break;
case 10:
#line 62 "ct.y"
{ yyval.flags = 0; }
break;
case 11:
#line 66 "ct.y"
{ yyval.flags = yyvsp[-2].flags | flag_val(yyvsp[0].dynstr); }
break;
case 12:
#line 68 "ct.y"
{ yyval.flags = flag_val(yyvsp[0].dynstr); }
break;
case 13:
#line 72 "ct.y"
{ yyval.dynstr = quote(ds(yyvsp[0].dynstr)); }
break;
case 14:
#line 74 "ct.y"
{ yyval.dynstr = str_concat3(yyvsp[-2].dynstr, quote(yyvsp[0].dynstr), ",\n    "); }
break;
#line 376 "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);
}
