#if defined(__STDC__) || defined(__cplusplus)
#define YYCONST const
#define YYPARAMS(x) x
#define YYDEFUN(name, arglist, args) name(args)
#define YYAND ,
#define YYPTR void *
#else
#define YYCONST
#define YYPARAMS(x) ()
#define YYDEFUN(name, arglist, args) name arglist args;
#define YYAND ;
#define YYPTR char *
#endif
#ifndef lint
YYCONST static char yysccsid[] = "@(#)yaccpar	1.8 (Berkeley +Cygnus.28) 01/20/91";
#endif
#define YYBYACC 1
#ifndef YYDONT_INCLUDE_STDIO
#include <stdio.h>
#endif
#ifdef __cplusplus
#include <stdlib.h> /* for malloc/realloc/free */
#endif
#line 7 "sym.y"
#include <stdio.h>
#include <string.h>
#include "SYM.h"

static	int	val_id, yyii, yyij;
static	char	**val_names, *field;
static  int	val_names_size=20;
static	bool	val_fill;
bool	read_prior = FALSE;
static	double	*probs;
static	int	max_prob;
static	int	error_count=0;
static	int	next_ut;
static	double	flt;
static  int     nextattr;
static  int     addattr;
static double	fetch_float();

extern FILE *yyin;
int yylineno=1;

#line 33 "sym.y"
typedef union {
	Context  *tk_context;
	int	 tk_int;
	char 	 *tk_string;
	} YYSTYPE;
#line 53 "y.tab.c"
#define IDENTIFIER 257
#define STRING 258
#define CONTINUOUS 259
#define AND 260
#define ONLYIF 261
#define NEVER 262
#define CONTEXTS 263
#define STRATIFY 264
#define UTILITIES 265
#define ASFOR 266
#define PRIOR 267
#define YYERRCODE 256
static YYCONST short yylhs[] = {                                        -1,
    6,    0,    5,    5,    5,    5,    5,    4,    4,   13,
   11,   11,   12,   12,   15,   15,   16,   16,   17,   17,
   17,   14,   14,   20,   14,   14,   19,   19,   19,   18,
   18,   18,   18,    7,    7,   21,   21,   21,    2,    2,
    3,    1,    1,    1,    1,   23,    8,   10,    9,   24,
   24,   22,   22,
};
static YYCONST short yylen[] = {                                         2,
    0,    3,    0,    2,    2,    2,    2,    1,    2,    0,
    6,    2,    2,    0,    3,    0,    3,    1,    1,    1,
    3,    1,    3,    0,    3,    2,    4,    1,    0,    1,
    3,    3,    1,    3,    2,    4,    3,    2,    1,    3,
    1,    3,    3,    3,    1,    0,    7,    4,    4,    1,
    3,    3,    3,
};
static YYCONST short yydefred[] = {                                      0,
    0,    0,    0,    8,   14,   12,    3,    9,    0,    0,
   13,    0,    0,    0,    0,    0,    0,    5,    6,    7,
   30,   24,    0,   33,    0,    0,    0,    0,    0,    0,
    0,    0,   41,    0,   35,    0,   26,    0,    0,    0,
    0,   34,    0,    0,    0,    0,    0,   38,    0,    0,
    0,   28,   25,   23,    0,   19,    0,    0,   11,   31,
   32,    0,    0,   46,   49,    0,   48,   39,    0,    0,
   37,    0,    0,   15,    0,   52,   53,    0,    0,    0,
   36,    0,    0,    0,    0,   21,   17,    0,   40,   42,
   43,   44,   27,   47,
};
static YYCONST short yydgoto[] = {                                       2,
   68,   69,   34,    3,   10,    7,   17,   18,   19,   20,
    4,    9,    5,   26,   40,   57,   58,   27,   53,   36,
   35,   44,   78,   46,
};
static YYCONST short yysindex[] = {                                   -232,
  -19,    0, -232,    0,    0,    0,    0,    0,  -54, -231,
    0,  -60,  -17,  -11,  -10,   -9, -236,    0,    0,    0,
    0,    0, -222,    0,  -56,   10,    7, -236, -205, -205,
 -204,    9,    0, -217,    0,  -55,    0,  -35,  -52,   11,
  -50,    0,   12,  -30,   16,  -31,   15,    0, -195,   18,
   19,    0,    0,    0,   -8,    0,   25,   23,    0,    0,
    0, -189, -188,    0,    0, -205,    0,    0,  -46,  -23,
    0,   24, -186,    0,  -52,    0,    0, -205,   16, -195,
    0, -185, -184, -183, -182,    0,    0,   -4,    0,    0,
    0,    0,    0,    0,
};
static YYCONST short yyrindex[] = {                                    -53,
    0,    0,    1,    0,    0,    0,    0,    0,    0,   76,
    0,    0,    0,    0,    0,    0,    6,    0,    0,    0,
    0,    0,    0,    0,    0,   31,  -24,    0,    0,    0,
    0,    0,    0,    0,    0,  -21,    0,    0,    0,    0,
    0,    0,    0,    0,  -29,    0,    0,    0,    0,    0,
    0,    0,    0,    0,  -18,    0,    0,   37,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,  -44,
    0,    0,    0,    0,    0,    0,    0,    0,  -28,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,
};
static YYCONST short yygindex[] = {                                      0,
   -1,    0,  -37,    0,    0,    0,    0,    0,    0,    0,
   77,    0,    0,    0,    0,    8,    0,   56,    0,    0,
   54,  -20,    0,    0,
};
#define YYTABLESIZE 273
static YYCONST short yytable[] = {                                      81,
    1,   45,   24,   12,   10,    4,   24,   52,   41,   45,
   56,   70,   61,   63,   65,   22,   50,   51,   29,   32,
   33,   22,   20,    1,   29,   20,    6,   66,   64,   50,
   51,   13,   14,   15,   37,   16,   83,   82,   84,   63,
   28,   94,   70,   49,   50,   79,   29,   30,   31,   39,
   41,   43,   73,   47,   48,   62,   59,   88,   10,   63,
   67,   33,   25,   71,   72,   74,   75,   76,   77,   85,
   86,   90,   91,   92,   93,    2,   16,   18,   89,    8,
   38,   42,   87,    0,    0,    0,    0,    0,    0,   54,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,   21,    0,   22,    0,
   21,   51,   11,   10,   55,   23,   60,    0,    0,    0,
    0,    0,    0,   80,    0,   45,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,   10,    0,    0,
    0,    0,    0,    1,    1,    1,    0,    1,    4,    4,
    4,    0,    4,
};
static YYCONST short yycheck[] = {                                      46,
    0,   46,   63,   58,   58,    0,   63,   63,   44,   30,
   63,   49,   63,   44,   46,   40,   46,   46,   40,  256,
  257,   46,   41,  256,   46,   44,   46,   59,   59,   59,
   59,  263,  264,  265,  257,  267,   60,   61,   62,   44,
   58,   46,   80,  261,  262,   66,   58,   58,   58,   40,
   44,  257,   61,  258,   46,   44,   46,   78,   58,   44,
   46,  257,  123,   46,   46,   41,   44,  257,  257,   46,
  257,  257,  257,  257,  257,    0,   46,   41,   80,    3,
   25,   28,   75,   -1,   -1,   -1,   -1,   -1,   -1,  125,
   -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,  257,   -1,  259,   -1,
  257,  257,  257,  257,  257,  266,  257,   -1,   -1,   -1,
   -1,   -1,   -1,  260,   -1,  260,   -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,  257,   -1,   -1,
   -1,   -1,   -1,  263,  264,  265,   -1,  267,  263,  264,
  265,   -1,  267,
};
#define YYFINAL 2
#ifndef YYDEBUG
#define YYDEBUG 0
#endif
#define YYMAXTOKEN 267
#if YYDEBUG
static YYCONST char *YYCONST 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,"IDENTIFIER","STRING","CONTINUOUS","AND","ONLYIF","NEVER",
"CONTEXTS","STRATIFY","UTILITIES","ASFOR","PRIOR",
};
static YYCONST char *YYCONST yyrule[] = {
"$accept : symbols",
"$$1 :",
"symbols : attribute_defs $$1 other_defs",
"other_defs :",
"other_defs : other_defs contexts",
"other_defs : other_defs stratify",
"other_defs : other_defs utilities",
"other_defs : other_defs prior",
"attribute_defs : attribute_def",
"attribute_defs : attribute_defs attribute_def",
"$$2 :",
"attribute_def : $$2 identifier_list ':' attribute_vals attr_qualifiers '.'",
"attribute_def : error '.'",
"identifier_list : identifier_list IDENTIFIER",
"identifier_list :",
"attr_qualifiers : '(' attr_qualifier_list ')'",
"attr_qualifiers :",
"attr_qualifier_list : attr_qualifier ',' attr_qualifier_list",
"attr_qualifier_list : attr_qualifier",
"attr_qualifier : '?'",
"attr_qualifier : IDENTIFIER",
"attr_qualifier : IDENTIFIER '=' IDENTIFIER",
"attribute_vals : discrete_vals",
"attribute_vals : '{' discrete_vals '}'",
"$$3 :",
"attribute_vals : CONTINUOUS $$3 min_max",
"attribute_vals : ASFOR IDENTIFIER",
"min_max : IDENTIFIER '.' '.' IDENTIFIER",
"min_max : '?'",
"min_max :",
"discrete_vals : IDENTIFIER",
"discrete_vals : discrete_vals ',' IDENTIFIER",
"discrete_vals : discrete_vals ',' '?'",
"discrete_vals : '?'",
"contexts : CONTEXTS ':' context_defn",
"contexts : contexts context_defn",
"context_defn : attrid ONLYIF context '.'",
"context_defn : attrid NEVER '.'",
"context_defn : error '.'",
"context : context_lit",
"context : context AND context_lit",
"attrid : IDENTIFIER",
"context_lit : attrid '=' IDENTIFIER",
"context_lit : attrid '<' IDENTIFIER",
"context_lit : attrid '>' IDENTIFIER",
"context_lit : attrid",
"$$4 :",
"stratify : STRATIFY ':' probabilities ';' $$4 probabilities '.'",
"prior : PRIOR ':' STRING '.'",
"utilities : UTILITIES ':' utility_list '.'",
"utility_list : probabilities",
"utility_list : utility_list ';' probabilities",
"probabilities : IDENTIFIER ',' IDENTIFIER",
"probabilities : probabilities ',' IDENTIFIER",
};
#endif
#define YYLEX yylex()
#define YYEMPTY -1
#define yyclearin (yychar=(YYEMPTY))
#define yyerrok (yyerrflag=0)
#ifndef YYINITDEPTH
#define YYINITDEPTH 200
#endif
#ifdef YYSTACKSIZE
#ifndef YYMAXDEPTH
#define YYMAXDEPTH YYSTACKSIZE
#endif
#else
#ifdef YYMAXDEPTH
#define YYSTACKSIZE YYMAXDEPTH
#else
#define YYSTACKSIZE 500
#define YYMAXDEPTH 500
#endif
#endif
#ifndef YYMAXSTACKSIZE
#define YYMAXSTACKSIZE 10000
#endif
int yydebug;
int yynerrs;
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
static short *yyss;
static YYSTYPE *yyvs;
static int yystacksize;
#define yyfree(x) free(x)
extern int yylex();

static YYPTR
YYDEFUN (yymalloc, (bytes), unsigned bytes)
{
    YYPTR ptr = (YYPTR) malloc (bytes);
    if (ptr != 0) return (ptr);
    yyerror ("yyparse: memory exhausted");
    return (0);
}

static YYPTR
YYDEFUN (yyrealloc, (old, bytes), YYPTR old YYAND unsigned bytes)
{
    YYPTR ptr = (YYPTR) realloc (old, bytes);
    if (ptr != 0) return (ptr);
    yyerror ("yyparse: memory exhausted");
    return (0);
}

static int
#ifdef __GNUC__
__inline__
#endif
yygrow ()
{
    int old_stacksize = yystacksize;
    short *new_yyss;
    YYSTYPE *new_yyvs;

    if (yystacksize == YYMAXSTACKSIZE)
        return (1);
    yystacksize += (yystacksize + 1 ) / 2;
    if (yystacksize > YYMAXSTACKSIZE)
        yystacksize = YYMAXSTACKSIZE;
#if YYDEBUG
    if (yydebug)
        printf("yydebug: growing stack size from %d to %d\n",
               old_stacksize, yystacksize);
#endif
    new_yyss = (short *) yyrealloc ((char *)yyss, yystacksize * sizeof (short));
    if (new_yyss == 0)
        return (1);
    new_yyvs = (YYSTYPE *) yyrealloc ((char *)yyvs, yystacksize * sizeof (YYSTYPE));
    if (new_yyvs == 0)
    {
        yyfree (new_yyss);
        return (1);
    }
    yyss = new_yyss;
    yyvs = new_yyvs;
    return (0);
}
#line 509 "sym.y"

parse_symbols(fp)
FILE *fp;
{
	nextattr = 0;
	ncattrs = 0;
	nsattrs = 0;
	ndattrs = 0;
	decattr = -1;
	yyin = fp;
	val_names = mems_alloc(char *, val_names_size+1);
	return !yyparse();
}

yyerror(s,a1,a2,a3)
char *s,*a1,*a2,*a3;
{
	char errstr[256];

	error_count++;
	sprintf(errstr,s,a1,a2,a3);
	fprintf(stderr,".attr file line %3d: %s\n",yylineno,errstr);
}

static double	fetch_float(str)
char	*str;
{
	double	temp, strtod();
	char	*ptr;
	temp = strtod(str,&ptr);
	if (!ptr) 
		yyerror("float expected instead of %s",str);
	return temp;
}

static assign_val_id_to_unord()
{	
	st[nextattr].u.unord = mem_alloc(unord_sym);
	st[nextattr].u.unord->vals = val_id;
	st[nextattr].u.unord->subsetting = SB_OFF;
	sym_fill(nextattr) = val_fill;
	if ( val_id ) {
    	    unordstrs(nextattr) = mems_alloc(char *,val_id);
   	    for (yyii=0; yyii<val_id; yyii++) {
	        unordstrs(nextattr)[yyii] = val_names[yyii];
	      }
	    unordhash(nextattr) =
		fill_hash(&unordstrs(nextattr), val_id);
	    if ( used_hash(unordhash(nextattr)) != val_id )
		yyerror("duplicate attribute value names");
	} else {
    	    unordstrs(nextattr) = 0;
    	    unordhash(nextattr) = 0;
	}
	for (yyii=1; yyii<addattr; yyii++) {
	    st[nextattr+yyii].u.unord = 
	        st[nextattr].u.unord ;
	    st[nextattr+yyii].sflags = st[nextattr].sflags;
	}	
}
#line 409 "y.tab.c"
#define YYABORT goto yyabort
#define YYACCEPT goto yyaccept
#define YYERROR goto yyerrlab

#if YYDEBUG
#ifdef __cplusplus
extern "C" char *getenv();
#else
extern char *getenv();
#endif
#endif

int
yyparse()
{
    register int yym, yyn, yystate;
    register YYSTYPE *yyvsp;
    register short *yyssp;
    short *yysse;
#if YYDEBUG
    register YYCONST char *yys;

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

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

    if (yyss == 0)
    {
        yyss = (short *) yymalloc (YYSTACKSIZE * sizeof (short));
        if (yyss == 0)
          goto yyabort;
        yyvs = (YYSTYPE *) yymalloc (YYSTACKSIZE * sizeof (YYSTYPE));
        if (yyvs == 0)
        {
            yyfree (yyss);
            goto yyabort;
        }
        yystacksize = YYSTACKSIZE;
    }
    yysse = yyss + yystacksize - 1;
    yyssp = yyss;
    yyvsp = yyvs;
    *yyssp = yystate = 0;
    goto yyloop;

yypush_lex:
    yyval = yylval;
    yystate = yytable[yyn];
yypush:
    if (yyssp >= yysse)
    {
        int depth = yyssp - yyss;
        if (yygrow() != 0)
             goto yyoverflow;
        yysse = yyss + yystacksize -1;
        yyssp = depth + yyss;
        yyvsp = depth + yyvs;
    }
    *++yyssp = yystate;
    *++yyvsp = yyval;

yyloop:
    if (yyn = yydefred[yystate]) goto yyreduce;
    yyn = yysindex[yystate];
    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 != 0
        && ((yyn += yychar), ((unsigned)yyn <= (unsigned)YYTABLESIZE))
        && yycheck[yyn] == yychar)
    {
#if YYDEBUG
        if (yydebug)
            printf("yydebug: state %d, shifting to state %d\n",
                    yystate, yytable[yyn]);
#endif
        if (yyerrflag > 0)  --yyerrflag;
        yychar = (-1);
        goto yypush_lex;
    }
    yyn = yyrindex[yystate];
    if (yyn != 0
        && ((yyn += yychar), ((unsigned)yyn <= (unsigned)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 (;;)
        {
            yyn = yysindex[*yyssp];
            if (yyn != 0
                && ((yyn += YYERRCODE), ((unsigned)yyn <= (unsigned)YYTABLESIZE))
                && yycheck[yyn] == YYERRCODE)
            {
#if YYDEBUG
                if (yydebug)
                    printf("yydebug: state %d, error recovery shifting\
 to state %d\n", *yyssp, yytable[yyn]);
#endif
                goto yypush_lex;
            }
            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 49 "sym.y"
{
		  if ( decattr < 0 ) {
                	yyerror("no decision attribute found");
			decattr = 0;
		  }
        	  nvalsattr = 2;
        	  foraattrs(yyii)
                      if ( !num_type(yyii)  && unordvals(yyii) > nvalsattr )
                        nvalsattr = unordvals(yyii);
        	  st_ndecs = unordvals(decattr);
		}
break;
case 2:
#line 61 "sym.y"
{
		  sfree(val_names);
		  if (error_count>0)
			return 1;
		}
break;
case 10:
#line 79 "sym.y"
{
			addattr = 0;
		}
break;
case 11:
#line 83 "sym.y"
{
		        nextattr += addattr;
		}
break;
case 12:
#line 87 "sym.y"
{
	    	    	yyerror("can't read attribute definition");
		}
break;
case 13:
#line 93 "sym.y"
{
			/*
			 *     attribute called "class" is the 
			 *     decision attribute
			 */
			if ( nextattr+addattr>=MAXATTRS ) {
	    	    		yyerror("too many attributes");
				return 1;
			}
			name(nextattr+addattr) = yyvsp[0].tk_string;
			if ( strcmp(yyvsp[0].tk_string, "class") == 0 ||
				 strcmp(yyvsp[0].tk_string, "Class") == 0 ) {
                            type(nextattr+addattr) = DECISION;
                            decattr = nextattr+addattr;
			} else
                            type(nextattr+addattr) = DISCRETE;
			unkns(nextattr+addattr) = FALSE;
			sym_fill(nextattr+addattr) = FALSE;
			onlyif(nextattr+addattr) = Cnil;
			addattr++;
		}
break;
case 19:
#line 125 "sym.y"
{
		        for ( yyii=0; yyii<addattr; yyii++)
				unkns(nextattr+yyii) = TRUE;
		}
break;
case 20:
#line 131 "sym.y"
{
		        if ( strcmp(yyvsp[0].tk_string,"class") )
			       yyerror("unrecognized attribute qualifier");
			sfree(yyvsp[0].tk_string);
			if ( addattr > 1 )
				yyerror("multiple class attributes");
	    	    	if ( type(nextattr)== DISCRETE )
			        /* assigned as discrete, so decrement */
				ndattrs--;
	    	    	if ( type(nextattr)!= DISCRETE  &&
	    	    			type(nextattr)!= DECISION )
				yyerror("class attribute must be discrete");
                        type(nextattr) = DECISION;
			sindex(nextattr) = 0;
			decattr = nextattr;
		}
break;
case 21:
#line 149 "sym.y"
{
		        if ( !strcmp(yyvsp[-2].tk_string,"subset") && !sym_fill(nextattr) ) {
			  if ( unordvals(nextattr) == 2 )
			    yyerror("subsetting meaningless for binary attr.");
			  if ( !strcmp(yyvsp[0].tk_string,SB_FULL_STR) ) 
			    st[nextattr].u.unord->subsetting = SB_FULL; 
			  else if ( !strcmp(yyvsp[0].tk_string,SB_ONE_STR) ) 
			    st[nextattr].u.unord->subsetting = SB_ONE; 
			  else if ( !strcmp(yyvsp[0].tk_string,SB_REST_STR) ) 
			    st[nextattr].u.unord->subsetting = SB_REST; 
			  else
			    yyerror("unknown option for subset flag");
			} else
			    yyerror("unknown flag in attribute qualifier");
			sfree(yyvsp[-2].tk_string);
			sfree(yyvsp[0].tk_string);
		}
break;
case 22:
#line 169 "sym.y"
{	
			for ( yyii=0; yyii<addattr; yyii++) {
			    if ( type(nextattr+yyii) == DECISION ) {
                                sindex(nextattr+yyii) = 0;
                            } else
                                sindex(nextattr+yyii) = (ndattrs++) + 1;
			}
			assign_val_id_to_unord();
		}
break;
case 23:
#line 179 "sym.y"
{	
			if ( val_id > SYMSETMAX )
				/*
				 *   keeps the final bit for SDKNOW
				 */
				yyerror("too many values for set type");
			for ( yyii=0; yyii<addattr; yyii++) {
                                type(nextattr+yyii) = SETTYPE;
				sindex(nextattr+yyii) = nsattrs++;
			}
			assign_val_id_to_unord();
		}
break;
case 24:
#line 192 "sym.y"
{
			st[nextattr].u.ord = mem_alloc(ord_sym);
		}
break;
case 25:
#line 196 "sym.y"
{	
			sindex(nextattr) = ncattrs++;
			type(nextattr) = yyvsp[-2].tk_int;
			for (yyii=1; yyii<addattr; yyii++) {
				sindex(nextattr+yyii) = ncattrs++;
				type(nextattr+yyii) = yyvsp[-2].tk_int;
			        st[nextattr+yyii].u.ord = st[val_id].u.ord;
				st[nextattr+yyii].sflags = st[nextattr].sflags;
			}
		}
break;
case 26:
#line 207 "sym.y"
{	
		        val_id = getattribute(yyvsp[0].tk_string);
			if ( val_id < 0 ) {
				yyerror("identifier %s not already seen",yyvsp[0].tk_string);
				val_id = 0;
			}
			sfree(yyvsp[0].tk_string);
			for ( yyii=0; yyii<addattr; yyii++) {
			  st[nextattr+yyii].sflags = st[val_id].sflags;
			  if ( num_type(val_id) ) {
			    sindex(nextattr+yyii) = ncattrs++;
			    type(nextattr+yyii) = type(val_id);
			    st[nextattr+yyii].u.ord = st[val_id].u.ord;
			  } else {
			    if ( type(val_id) == SETTYPE )
				sindex(nextattr) = nsattrs++;
			    else
				sindex(nextattr) = (ndattrs++) + 1;
			    type(nextattr+yyii) = type(val_id);
			    if ( type(val_id) == DECISION  )
				 type(nextattr+yyii) = DISCRETE;
			    st[nextattr+yyii].u.unord = 
				st[val_id].u.unord;
			  }
			}
		}
break;
case 27:
#line 236 "sym.y"
{	
	    		getmin(nextattr) = fetch_float(yyvsp[-3].tk_string); sfree(yyvsp[-3].tk_string);
	    		getmax(nextattr) = fetch_float(yyvsp[0].tk_string); sfree(yyvsp[0].tk_string);
		}
break;
case 28:
#line 241 "sym.y"
{	
			sym_fill(nextattr) = TRUE;
	    		getmin(nextattr) = FLOATMAX;
	    		getmax(nextattr) = -FLOATMAX;
		}
break;
case 29:
#line 247 "sym.y"
{	
	    		getmin(nextattr) = -FLOATMAX;
	    		getmax(nextattr) = FLOATMAX;
		}
break;
case 30:
#line 255 "sym.y"
{
			val_id = 1; 
			val_fill = FALSE;
			val_names[0] = (char *) yyvsp[0].tk_string; 
		 }
break;
case 31:
#line 261 "sym.y"
{
			if ( val_id >= val_names_size  ) {
				val_names_size += 20;
				val_names = mems_realloc(val_names,char *, 
						val_names_size+1);
			}
	    		val_names[val_id++] = (char *) yyvsp[0].tk_string; 
		}
break;
case 32:
#line 270 "sym.y"
{
			val_fill = TRUE;
		}
break;
case 33:
#line 274 "sym.y"
{
			val_fill = TRUE;
			val_id = 0;
		}
break;
case 36:
#line 284 "sym.y"
{
			  onlyif(yyvsp[-3].tk_int) = yyvsp[-1].tk_context;
			}
break;
case 37:
#line 288 "sym.y"
{
			  onlyif(yyvsp[-2].tk_int) = mem_alloc(Context);
			  onlyif(yyvsp[-2].tk_int)->coutcome = DONTKNOW;
			  onlyif(yyvsp[-2].tk_int)->ctest.attr = decattr;
			}
break;
case 38:
#line 294 "sym.y"
{
	    	    	yyerror("can't read context definition");
		}
break;
case 39:
#line 300 "sym.y"
{ yyval.tk_context = yyvsp[0].tk_context; 
		  yyvsp[0].tk_context->cnext = 0; }
break;
case 40:
#line 303 "sym.y"
{
                  yyval.tk_context = yyvsp[0].tk_context;
                  yyvsp[0].tk_context->cnext = yyvsp[-2].tk_context;
                }
break;
case 41:
#line 310 "sym.y"
{ if ( (yyval.tk_int = getattribute(yyvsp[0].tk_string)) == -1)
		  {
			yyerror("Unknown attribute %s",yyvsp[0].tk_string);
			yyval.tk_int = 0;
		  }
		  sfree(yyvsp[0].tk_string);
		}
break;
case 42:
#line 320 "sym.y"
{ int d;
		  if ( (d = lookupval(yyvsp[0].tk_string,yyvsp[-2].tk_int)) == DONTKNOW) {
			yyerror("illegal value of %s for %s",
				yyvsp[0].tk_string,name(yyvsp[-2].tk_int));
			d = DONTKNOW;
		  }
		  sfree(yyvsp[0].tk_string);
		  if (type(yyvsp[-2].tk_int) != DISCRETE)
		      yyerror("Attribute %s shouldn't be in an equality test",
				name(yyvsp[-2].tk_int));
		  yyval.tk_context = mem_alloc(Context);
		  yyval.tk_context->ctest.attr = yyvsp[-2].tk_int;
		  yyval.tk_context->ctest.no = unordvals(yyvsp[-2].tk_int);
		  null_flags(yyval.tk_context->ctest.tsflags);
		  set_flag(yyval.tk_context->ctest.tsflags,attr);
		  yyval.tk_context->coutcome = d;
		}
break;
case 43:
#line 338 "sym.y"
{ if (!num_type(yyvsp[-2].tk_int))
			yyerror("attribute %s cannot compare",name(yyvsp[-2].tk_int));
		  flt = fetch_float(yyvsp[0].tk_string); sfree(yyvsp[0].tk_string);
		  if (flt < getmin(yyvsp[-2].tk_int) || flt > getmax(yyvsp[-2].tk_int)) {
			yyerror("Value of %g out of range for %s",
					flt,name(yyvsp[-2].tk_int));
		  }
		  yyval.tk_context = mem_alloc(Context);
		  yyval.tk_context->ctest.attr = yyvsp[-2].tk_int;
		  yyval.tk_context->ctest.no = 2;
                  null_flags(yyval.tk_context->ctest.tsflags);
                  set_flag(yyval.tk_context->ctest.tsflags,cut);
		  yyval.tk_context->ctest.tval.cut = flt;
		  yyval.tk_context->coutcome = LESSTHAN;
		}
break;
case 44:
#line 354 "sym.y"
{ if (!num_type(yyvsp[-2].tk_int))
			yyerror("attribute %s cannot compare",name(yyvsp[-2].tk_int));
		  flt = fetch_float(yyvsp[0].tk_string); sfree(yyvsp[0].tk_string);
		  if (flt < getmin(yyvsp[-2].tk_int) || flt > getmax(yyvsp[-2].tk_int))
				yyerror("Value of %g out of range for %s",
					flt,name(yyvsp[-2].tk_int));
		  yyval.tk_context = mem_alloc(Context);
	          yyval.tk_context = mem_alloc(Context);
                  yyval.tk_context->ctest.attr = yyvsp[-2].tk_int;
                  yyval.tk_context->ctest.no = 2;
		  null_flags(yyval.tk_context->ctest.tsflags);
                  set_flag(yyval.tk_context->ctest.tsflags,cut);
                  yyval.tk_context->ctest.tval.cut = flt;
                  yyval.tk_context->coutcome = GREATERTHAN;
		}
break;
case 45:
#line 370 "sym.y"
{ yyval.tk_context = mem_alloc(Context);
		  yyval.tk_context->ctest.attr = yyvsp[0].tk_int;
		  yyval.tk_context->coutcome = DONTKNOW;
		}
break;
case 46:
#line 377 "sym.y"
{
			if (max_prob != ndecs ) 
	    	 	     yyerror("incorrect number of true probabilities");
			true_prob = (double *) salloc(ndecs*sizeof(double));
			flt = 0.0;
			fordecs(yyii) {
			    if ( probs[yyii] <= 0.0 )
	    	 	        yyerror("true probabilities must be positive");
			    flt += true_prob[yyii] = probs[yyii];
			}
			if ( 0.99999 > flt || 1.00001 < flt )
	    	 	    yyerror("true probabilities sum to %lg", flt);
			else
			    fordecs(yyii) 
				probs[yyii] /= flt;
		}
break;
case 47:
#line 394 "sym.y"
{
			if (max_prob != ndecs ) 
	    	 	     yyerror("incorrect number of stratified probabilities");
			strat_prob = (double *) salloc(ndecs*sizeof(double));
			flt = 0.0;
			fordecs(yyii) {
			    if ( probs[yyii] <= 0.0 )
	    	 	        yyerror("stratified probabilities must be positive");
			    flt += strat_prob[yyii] = probs[yyii];
			}
			if ( 0.99999 > flt || 1.00001 < flt )
	    	 	     yyerror("stratified probabilities sum to %lg", flt);
			else
			    fordecs(yyii)
				strat_prob[yyii] /= flt;
		}
break;
case 48:
#line 413 "sym.y"
{
#define nextfield()   {  if ( field[2] ) field = field+2; else field = strtok((char*)0," \t"); }
			if ( read_prior )
			    for (   field = strtok(yyvsp[-1].tk_string," \t");
                		field;
                		field = strtok((char*)0," \t")   ) {
				if ( field[0] != '-' || !field[1] ) {	
					yyerror("prior option %s not preceeded with a '-'",field);
					continue;
				}
				switch ( field[1] ) {
				case 'N' :
					if ( field[2] )
						yyerror("prior option overlaid on -N");
					prior_opts((int)'N',"");
					break;
				case 'A' :
					nextfield();
					prior_opts((int)'A',field);
					break;
				case 'P' :
					nextfield();
					prior_opts((int)'P',field);
					break;
				case 'd' :
					nextfield();
					prior_opts((int)'d',field);
					break;
				}
			}
		}
break;
case 49:
#line 446 "sym.y"
{	
			if ( next_ut != ndecs ) 
	    	 	     yyerror("incorrect number of utilities");
			/*
			 * 	for binary class case
			 *	utilities transform to cut-off probabilities
			 */
			if (ndecs == 2) 
			    cut_prob = (utilities[0][0]-utilities[1][0]) /
				( utilities[0][0]-utilities[1][0] +
				  utilities[1][1]-utilities[0][1] );
			util_max = -FLOATMAX;
			util_min = FLOATMAX;
			fordecs(yyii) fordecs(yyij) {
				if ( utilities[yyii][yyij] > util_max )
					util_max = utilities[yyii][yyij];
				if ( utilities[yyii][yyij] < util_min )
                                        util_min = utilities[yyii][yyij];
			}
			
		}
break;
case 50:
#line 468 "sym.y"
{
			if (max_prob != ndecs ) 
	    	 	     yyerror("incorrect number of utilities");
			utilities = (float **) salloc(ndecs*sizeof(float*));
			utilities[0] = (float *) salloc(ndecs*sizeof(float));
			fordecs(yyii)
				utilities[0][yyii] = probs[yyii];
			next_ut = 1;
		}
break;
case 51:
#line 478 "sym.y"
{
			if ( max_prob != ndecs || next_ut>=ndecs ) 
	    	 	     yyerror("incorrect number of utilities");
			utilities[next_ut] = (float *) salloc(ndecs*sizeof(float));
			fordecs(yyii)
				utilities[next_ut][yyii] = probs[yyii];
			next_ut++;
		}
break;
case 52:
#line 490 "sym.y"
{
			if ( !probs )
				probs = mems_alloc(double,ndecs);
			max_prob = 2; 
			probs[0] = fetch_float(yyvsp[-2].tk_string);  sfree(yyvsp[-2].tk_string);
	    	 	probs[1] = fetch_float(yyvsp[0].tk_string);  sfree(yyvsp[0].tk_string);
		 }
break;
case 53:
#line 498 "sym.y"
{
			if ( max_prob >= ndecs ) {
	    	    		yyerror("too many probabilities");
				val_id = ndecs-1;
			}
	    		probs[max_prob++] = fetch_float(yyvsp[0].tk_string);  
			sfree(yyvsp[0].tk_string);
		}
break;
#line 1069 "y.tab.c"
    }
    yyssp -= yym;
    yyvsp -= yym;
    yym = yylhs[yyn];
    yystate = *yyssp;
    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;
    }
    yyn = yygindex[yym];
	 if (yyn != 0
        && ((yyn += yystate), ((unsigned)yyn <= (unsigned)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
    goto yypush;
yyoverflow:
    yyerror("yacc stack overflow");
yyabort:
    return (1);
yyaccept:
    return (0);
}
