
/*  A Bison parser, made from parse.y with Bison version GNU Bison version 1.22
  */

#define YYBISON 1  /* Identify Bison output.  */

#define	T_CONST	258
#define	T_SYM	259
#define	T_ASSIGN	260
#define	T_DEFVAR	261
#define	T_CHAR	262
#define	T_INT	263
#define	T_SHORT	264
#define	T_LONG	265
#define	T_UNSIGNED	266
#define	T_FLOAT	267
#define	T_DOUBLE	268
#define	T_VOID	269
#define	T_STRUCT	270
#define	T_UNION	271
#define	T_ENUM	272
#define	T_SIZEOF	273
#define	T_TYPEDEF_INDICATOR	274
#define	T_SIGNED	275
#define	T_IF	276
#define	T_ELSE	277
#define	T_FOR	278
#define	T_WHILE	279
#define	T_OR	280
#define	T_AND	281
#define	T_RSH	282
#define	T_LSH	283
#define	T_INC	284
#define	T_DEC	285
#define	T_COUNT	286
#define	T_FRAME	287
#define	T_TO	288
#define	T_DFS	289
#define	T_BFS	290
#define	T_ARROW	291
#define	T_OSEL	292
#define	T_CSEL	293
#define	T_IMP	294
#define	T_ANDL	295
#define	T_ORL	296
#define	T_EQ	297
#define	T_NE	298
#define	T_EQQ	299
#define	T_NEQ	300
#define	T_LE	301
#define	T_GE	302
#define	T_LSQ	303
#define	T_GTQ	304
#define	T_LEQ	305
#define	T_GEQ	306
#define	STMT	307
#define	UNARY	308
#define	T_POS	309

#line 1 "parse.y"

/*   DUEL - A Very High Level Debugging Langauge.  */
/*   Public domain code			           */
/*   Written by Michael Golan mg@cs.princeton.edu  */
/*$Header: /tmp_mnt/n/fs/grad2/mg/duel/RCS/parse.y,v 1.14 93/03/17 11:04:12 mg Exp $*/

/* this module contains the duel parser, in yacc, plus a simple lexer.
 * the lexer is slow, but duel expressions are tiny.
 * the parsing generate an AST with essentially no type checking.
 * names are only looked up when the refer explicitly to types. This forces
 * the use of "T" before user types. You can't parse (x)(y) correctly, if
 * you want the node to contain "cast" or "func", without knowing the x is 
 * not a type. (It is interesting to note that (x *)(y) is clearly a cast,
 * but it can not be parsed without a context sensitive grammer!). 
 *
 * Version 1.1 now accept (x) as a type cast, so (print)("hi") fails, but
 * (uint)z is ok. Also accepted is (uint*)z. T is still required in sizeof
 * and in variable declarations. A side effect was making "sizeof x" illegal
 * (since then sizeof(x)-1 was parsed sizeof((x)-1) with (x) a cast), so
 * now sizeof(x) must be used. Note that in C, sizoef(x)++ is acceptable,
 * and the '++' operate on x (which is optimized out!) This can be confusing.
 *
 * yacc is also not smart enough to recognize e.g. "if(e) e ; else e" as
 * a special case (redundent ';'). I hacked this in the lexer. It should
 * reduce the trouble with C->duel coding. (It can also be done for {e1}e2,
 * in some speical cases, e.g. if e2 is a keyword, or a name or a unary op,
 * but this can confuse some people, e.g. in {i}[5], so I left it alone.)
 * Finally, the %/ operator is accepted as "#/" and "%%" as "#", to those
 * who wish to keep gdb with # comments.
 * memory: nodes are alloc'ed dynamically. a parsing error loose so-far
 * allocated nodes, which is normally acceptable (yyerror can probably hack
 * into the yacc stack to release them.)
 */

/*
 * $Log:	parse.y,v $
 * Revision 1.14  93/03/17  11:04:12  mg
 * fixed (t*)x bug, was parsed as (t**)x 
 * 
 * Revision 1.13  93/03/12  06:15:09  mg
 * modified unary's a bit - cosmetics
 * support (x)y as type cast
 * support (x*)y as type cast
 * replace sizeof exp  with sizeof(exp) to prevent clash with above
 * more cosmetics, including yyerror abort, tuint for uint.
 * takes anything after |> to be comment (pipe command really)
 * 
 * 
 * Revision 1.12  93/02/27  06:06:09  mg
 * added signed char parsing.
 * 
 * Revision 1.11  93/02/23  19:15:38  mg
 * improved escaped char support
 * 
 * Revision 1.10  93/02/03  21:49:34  mg
 * bug fix - yyerror calls now abort parsing (eg called from lex)
 * 
 * Revision 1.9  93/01/12  21:53:07  mg
 * cleanup and set for release
 * 
 * Revision 1.8  93/01/07  00:14:33  mg
 * add &&/ ||/
 * fixed parsing of trailing ';' was a mess.
 * ignore ';' before 'else' and '}' w/warning.
 * 
 * Revision 1.7  93/01/03  07:31:01  mg
 * error reporting
 * 
 * Revision 1.6  92/12/24  23:35:50  mg
 * began src pos support
 * 
 * Revision 1.5  92/10/19  15:08:02  mg
 * frames() added; bug fixed
 * 
 * Revision 1.4  92/10/14  02:06:32  mg
 * misc/change casting parsing/variable def.
 * 
 * Revision 1.3  92/09/16  11:09:39  mg
 * add typedef/struct support, const strings 
 * cleanup s/r conflict by setting ELSE to a token. explained some stuff in
 * comments.
 * 
 * Revision 1.2  92/09/15  06:10:46  mg
 * cosmetics and new ops: x@y, for() while() ..x and x..
 * generic '.' and '_'  support. x@y. '..x' and 'x..'.  while(), for(), ?:
 * 
 */

#include "duel.h"

static char *inputstr ;		/* pointer to string being parsed */
static char *lexptr ;           /* current lexer pointer into input str */
static tnode *root ;		/* result of parsing stored here */

/* pick unique names for globals of yacc. gdb has other parsers! */
#define	yyparse	duel_yyparse
#define	yylex	duel_yylex
#define	yyerror	duel_yyerror
#define	yylval	duel_yylval
#define	yychar	duel_yychar
#define	yydebug	duel_yydebug
#define	yypact	duel_yypact	
#define	yyr1	duel_yyr1			
#define	yyr2	duel_yyr2			
#define	yydef	duel_yydef		
#define	yychk	duel_yychk		
#define	yypgo	duel_yypgo		
#define	yyact	duel_yyact		
#define	yyexca	duel_yyexca
#define yyerrflag duel_yyerrflag
#define yynerrs	duel_yynerrs
#define	yyps	duel_yyps
#define	yypv	duel_yypv
#define	yys	duel_yys
#define	yystate	duel_yystate
#define	yytmp	duel_yytmp
#define	yyv	duel_yyv
#define	yyval	duel_yyval
#define	yylloc	duel_yylloc

typedef struct {                /* token info for operators */
        int src_pos ;            /* source position */
        topcode opcode ;        /* opcode          */
       } topinfo ;

typedef struct {                /* token info for symbols */
        int src_pos ;            /* source position */
        char *name ;             /* symbol          */
       } tnameinfo ;

/* these are used as operators to mknode_... when source location is unknown*/
static topinfo seq_op  = { -1,';' } ; /* sequencing operator, src pos unkown */
static topinfo decl_op = { -1,OP_DECL } ; /* declare var op, src pos unkown */

/* local prototypes. */
LPROC  yyerror(char *msg);
LFUNC  int yylex (void);

LPROC push_type(char desc) ;
LPROC push_type_int(char desc,tnode *n)  ;
LFUNC bool pop_type(char *desc,int *size);

LFUNC tnode* mknode_op(top_kind,topinfo opinfo,tnode*,tnode*,tnode*,tnode*);
LFUNC tnode* mknode_const(int src_pos,tctype *ctype);
LFUNC tnode* mknode_ctype(tctype *ctype);
LFUNC tnode* mknode_name(tnameinfo nameinfo);
LFUNC tnode* mknode_modified_ctype(tctype *base);

#define mknode_post_unary(op,n) (mknode_op(OPK_POST_UNARY,op,n, 0, 0,0))
#define mknode_unary(op,n)      (mknode_op(OPK_UNARY,     op,n, 0, 0,0))
#define mknode_sunary(op,n)     (mknode_op(OPK_SUNARY,    op,n, 0, 0,0))
#define mknode_bin(op,n1,n2)    (mknode_op(OPK_BIN,       op,n1,n2,0,0))
#define mknode_sbin(op,n1,n2)   (mknode_op(OPK_SBIN,      op,n1,n2,0,0))
#define mknode_tri(op,n1,n2,n3) (mknode_op(OPK_TRI,       op,n1,n2,n3,0))

static tctype *decl_tbase ; /* used for variables decl */

/* #define	YYDEBUG	1 */


#line 162 "parse.y"
typedef union
  {
    tnode   *node ;                 /* node pointer for constructed exp tree */
    tctype  *ctype;                 /* type for type nodes                   */
    tnameinfo nameinfo ;            /* a name/symbol + src position */
    topinfo opinfo;                 /* keyword/operator + source position    */
  } YYSTYPE;

#ifndef YYLTYPE
typedef
  struct yyltype
    {
      int timestamp;
      int first_line;
      int first_column;
      int last_line;
      int last_column;
      char *text;
   }
  yyltype;

#define YYLTYPE yyltype
#endif

#include <stdio.h>

#ifndef __cplusplus
#ifndef __STDC__
#define const
#endif
#endif



#define	YYFINAL		234
#define	YYFLAG		-32768
#define	YYNTBASE	81

#define YYTRANSLATE(x) ((unsigned)(x) <= 309 ? yytranslate[x] : 98)

static const char yytranslate[] = {     0,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,    48,     2,    46,     2,    38,    31,     2,    42,
    43,    36,    34,    26,    35,    39,    37,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,    80,    25,    32,
    27,    33,    28,    47,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    40,     2,    41,    30,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,    44,    29,    45,    49,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     1,     2,     3,     4,     5,
     6,     7,     8,     9,    10,    11,    12,    13,    14,    15,
    16,    17,    18,    19,    20,    21,    22,    23,    24,    50,
    51,    52,    53,    54,    55,    56,    57,    58,    59,    60,
    61,    62,    63,    64,    65,    66,    67,    68,    69,    70,
    71,    72,    73,    74,    75,    76,    77,    78,    79
};

#if YYDEBUG != 0
static const short yyprhs[] = {     0,
     0,     2,     4,     7,    11,    13,    15,    18,    20,    24,
    25,    29,    31,    35,    37,    41,    47,    50,    55,    57,
    63,    70,    77,    85,    95,   104,   110,   115,   118,   121,
   124,   127,   130,   133,   136,   139,   142,   145,   148,   151,
   156,   161,   166,   170,   174,   178,   182,   186,   190,   195,
   200,   205,   209,   213,   218,   223,   230,   234,   238,   242,
   246,   250,   254,   258,   262,   266,   270,   274,   278,   282,
   286,   290,   294,   298,   302,   306,   310,   314,   318,   322,
   326,   332,   336,   340,   344,   348,   351,   354,   358,   362,
   366,   368,   370,   371,   373,   375,   377,   380,   384,   390,
   393,   398,   399,   402,   404,   407,   410,   412,   414,   417,
   419,   422,   425,   429,   431,   434,   437,   441,   443,   445,
   447,   450,   453,   456
};

static const short yyrhs[] = {    82,
     0,    84,     0,    84,    25,     0,    84,    25,    83,     0,
    83,     0,    91,     0,    91,    25,     0,    85,     0,    84,
    25,    85,     0,     0,    96,    86,    87,     0,    88,     0,
    87,    26,    88,     0,    89,     0,    42,    89,    43,     0,
    42,    89,    43,    42,    43,     0,    36,    89,     0,    89,
    40,     3,    41,     0,    93,     0,    21,    42,    90,    43,
    90,     0,    21,    42,    90,    43,    90,    22,     0,    21,
    42,    90,    43,    22,    90,     0,    21,    42,    90,    43,
    90,    22,    90,     0,    23,    42,    92,    25,    90,    25,
    92,    43,    90,     0,    23,    42,    92,    25,    90,    25,
    92,    43,     0,    24,    42,    90,    43,    90,     0,    24,
    42,    90,    43,     0,    36,    90,     0,    31,    90,     0,
    35,    90,     0,    48,    90,     0,    49,    90,     0,    56,
    90,     0,    65,    90,     0,    66,    90,     0,    54,    90,
     0,    55,    90,     0,    90,    54,     0,    90,    55,     0,
    18,    42,    94,    43,     0,    18,    42,    90,    43,     0,
    57,    42,    90,    43,     0,    90,    59,    90,     0,    90,
    60,    90,     0,    90,    46,    93,     0,    90,    47,    90,
     0,    90,    61,    90,     0,    90,    39,    90,     0,    90,
    40,    90,    41,     0,    90,    62,    90,    63,     0,    90,
    42,    92,    43,     0,    42,    91,    43,     0,    44,    91,
    45,     0,    42,    94,    43,    90,     0,    42,    97,    43,
    90,     0,    42,    97,    36,    95,    43,    90,     0,    90,
    36,    90,     0,    90,    37,    90,     0,    90,    38,    90,
     0,    90,    34,    90,     0,    90,    35,    90,     0,    90,
    53,    90,     0,    90,    52,    90,     0,    90,    67,    90,
     0,    90,    68,    90,     0,    90,    69,    90,     0,    90,
    70,    90,     0,    90,    71,    90,     0,    90,    72,    90,
     0,    90,    75,    90,     0,    90,    76,    90,     0,    90,
    32,    90,     0,    90,    33,    90,     0,    90,    73,    90,
     0,    90,    74,    90,     0,    90,    31,    90,     0,    90,
    29,    90,     0,    90,    30,    90,     0,    90,    51,    90,
     0,    90,    50,    90,     0,    90,    28,    90,    80,    90,
     0,    90,    27,    90,     0,    90,     5,    90,     0,    93,
     6,    90,     0,    90,    58,    90,     0,    58,    90,     0,
    90,    58,     0,    90,    26,    90,     0,    90,    64,    90,
     0,    91,    25,    90,     0,    90,     0,    90,     0,     0,
     3,     0,    93,     0,    97,     0,    96,    95,     0,    42,
    95,    43,     0,    42,    95,    43,    42,    43,     0,    36,
    95,     0,    95,    40,     3,    41,     0,     0,    19,    97,
     0,     7,     0,    20,     7,     0,    11,     7,     0,     8,
     0,    11,     0,    11,     8,     0,    10,     0,    10,     8,
     0,    11,    10,     0,    11,    10,     8,     0,     9,     0,
     9,     8,     0,    11,     9,     0,    11,     9,     8,     0,
    12,     0,    13,     0,    14,     0,    15,    97,     0,    16,
    97,     0,    17,    97,     0,     4,     0
};

#endif

#if YYDEBUG != 0
static const short yyrline[] = { 0,
   211,   214,   215,   216,   217,   219,   220,   222,   223,   226,
   226,   228,   229,   232,   236,   237,   238,   239,   240,   251,
   252,   254,   256,   259,   261,   263,   265,   271,   272,   273,
   274,   275,   276,   277,   278,   279,   280,   281,   282,   283,
   284,   285,   288,   289,   291,   292,   293,   294,   295,   296,
   297,   298,   299,   302,   313,   317,   326,   327,   328,   329,
   330,   331,   332,   333,   334,   335,   336,   337,   338,   339,
   340,   341,   342,   343,   344,   345,   346,   347,   348,   349,
   352,   356,   357,   358,   363,   364,   365,   366,   367,   370,
   371,   374,   375,   378,   379,   385,   387,   392,   393,   394,
   395,   396,   413,   423,   424,   425,   426,   427,   428,   429,
   430,   431,   432,   433,   434,   435,   436,   437,   438,   439,
   440,   443,   446,   451
};

static const char * const yytname[] = {   "$","error","$illegal.","T_CONST",
"T_SYM","T_ASSIGN","T_DEFVAR","T_CHAR","T_INT","T_SHORT","T_LONG","T_UNSIGNED",
"T_FLOAT","T_DOUBLE","T_VOID","T_STRUCT","T_UNION","T_ENUM","T_SIZEOF","T_TYPEDEF_INDICATOR",
"T_SIGNED","T_IF","T_ELSE","T_FOR","T_WHILE","';'","','","'='","'?'","'|'","'^'",
"'&'","'<'","'>'","'+'","'-'","'*'","'/'","'%'","'.'","'['","']'","'('","')'",
"'{'","'}'","'#'","'@'","'!'","'~'","T_OR","T_AND","T_RSH","T_LSH","T_INC","T_DEC",
"T_COUNT","T_FRAME","T_TO","T_DFS","T_BFS","T_ARROW","T_OSEL","T_CSEL","T_IMP",
"T_ANDL","T_ORL","T_EQ","T_NE","T_EQQ","T_NEQ","T_LE","T_GE","T_LSQ","T_GTQ",
"T_LEQ","T_GEQ","STMT","UNARY","T_POS","':'","start","duel_inp","duel_exp","all_decls",
"vars_decl","@1","var_decl","name_decl1","name_decl","exp","sm_exp","oexp","nameexp",
"type","type_mod","typebase","name",""
};
#endif

static const short yyr1[] = {     0,
    81,    82,    82,    82,    82,    83,    83,    84,    84,    86,
    85,    87,    87,    88,    89,    89,    89,    89,    89,    90,
    90,    90,    90,    90,    90,    90,    90,    90,    90,    90,
    90,    90,    90,    90,    90,    90,    90,    90,    90,    90,
    90,    90,    90,    90,    90,    90,    90,    90,    90,    90,
    90,    90,    90,    90,    90,    90,    90,    90,    90,    90,
    90,    90,    90,    90,    90,    90,    90,    90,    90,    90,
    90,    90,    90,    90,    90,    90,    90,    90,    90,    90,
    90,    90,    90,    90,    90,    90,    90,    90,    90,    91,
    91,    92,    92,    90,    90,    93,    94,    95,    95,    95,
    95,    95,    96,    96,    96,    96,    96,    96,    96,    96,
    96,    96,    96,    96,    96,    96,    96,    96,    96,    96,
    96,    96,    96,    97
};

static const short yyr2[] = {     0,
     1,     1,     2,     3,     1,     1,     2,     1,     3,     0,
     3,     1,     3,     1,     3,     5,     2,     4,     1,     5,
     6,     6,     7,     9,     8,     5,     4,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     4,
     4,     4,     3,     3,     3,     3,     3,     3,     4,     4,
     4,     3,     3,     4,     4,     6,     3,     3,     3,     3,
     3,     3,     3,     3,     3,     3,     3,     3,     3,     3,
     3,     3,     3,     3,     3,     3,     3,     3,     3,     3,
     5,     3,     3,     3,     3,     2,     2,     3,     3,     3,
     1,     1,     0,     1,     1,     1,     2,     3,     5,     2,
     4,     0,     2,     1,     2,     2,     1,     1,     2,     1,
     2,     2,     3,     1,     2,     2,     3,     1,     1,     1,
     2,     2,     2,     1
};

static const short yydefact[] = {     0,
    94,   124,   104,   107,   114,   110,   108,   118,   119,   120,
     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
     0,     0,     0,     1,     5,     2,     8,    91,     6,    95,
    10,    96,   115,   111,   106,   109,   116,   112,   121,   122,
   123,     0,   103,   105,     0,    93,     0,    29,    30,    28,
     0,     0,   102,    96,     0,    31,    32,    36,    37,    33,
     0,    86,    34,    35,     3,     0,     0,     0,     0,     0,
     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
     0,    93,     0,     0,     0,     0,     0,     0,    38,    39,
    87,     0,     0,     0,     0,     0,     0,     0,     0,     0,
     0,     0,     0,     0,     0,     0,     7,     0,     0,   117,
   113,     0,     0,     0,    92,     0,     0,     0,    52,     0,
   102,   102,    97,   102,     0,    53,     0,     4,     9,    83,
    88,    82,     0,    77,    78,    76,    72,    73,    60,    61,
    57,    58,    59,    48,     0,     0,    45,    46,    80,    79,
    63,    62,    85,    43,    44,    47,     0,    89,    64,    65,
    66,    67,    68,    69,    74,    75,    70,    71,    90,    84,
     0,     0,    11,    12,    14,    19,    41,    40,     0,     0,
    27,    54,   100,     0,     0,     0,    55,    42,     0,    49,
    51,    50,    17,     0,     0,     0,     0,    20,     0,    26,
    98,     0,     0,    81,    15,    13,     0,    22,    21,    93,
     0,   101,    56,     0,    18,    23,     0,    99,    16,    25,
    24,     0,     0,     0
};

static const short yydefgoto[] = {   232,
    34,    35,    36,    37,   119,   183,   184,   185,    38,    39,
   126,    40,    62,   133,    41,    42
};

static const short yypact[] = {   837,
-32768,-32768,-32768,-32768,     7,     9,   104,-32768,-32768,-32768,
    25,    25,    25,    -1,    25,    45,    12,    59,    79,   886,
   886,   886,   837,   886,   886,   886,   886,   886,   886,    93,
   886,   886,   886,-32768,-32768,    54,-32768,   661,   113,   123,
-32768,-32768,-32768,-32768,-32768,-32768,   131,   132,-32768,-32768,
-32768,   837,-32768,-32768,   886,   886,   886,   142,   142,   142,
    -9,    98,    13,    37,     2,   142,   142,   142,   142,   142,
   886,  1296,  1070,  1022,   837,   886,   886,   886,   886,   886,
   886,   886,   886,   886,   886,   886,   886,   886,   886,   886,
   886,   886,    25,   886,   886,   886,   886,   886,-32768,-32768,
   935,   886,   886,   886,   886,   886,   886,   886,   886,   886,
   886,   886,   886,   886,   886,   886,   886,   886,     6,-32768,
-32768,   243,    99,   294,   661,   119,   345,   886,-32768,   886,
    13,    13,   106,    13,   886,-32768,   396,-32768,-32768,   763,
   712,   763,   185,  1117,  1163,  1208,  1325,  1325,   926,   926,
   142,   142,   142,-32768,   447,   108,-32768,-32768,  1022,  1070,
   -16,   -16,  1296,-32768,-32768,-32768,   498,   661,  1253,  1253,
  1253,  1253,  1325,  1325,  1325,  1325,  1325,  1325,   661,   763,
     6,     6,   121,-32768,   112,-32768,-32768,-32768,   101,   886,
   886,   142,   106,   -15,   145,    10,   142,-32768,   886,-32768,
-32768,-32768,   112,    87,     6,   150,   886,   558,   610,   661,
   118,   120,   886,   974,   122,-32768,   124,   661,   886,   886,
   111,-32768,   142,   125,-32768,   661,   129,-32768,-32768,   886,
   661,   162,   163,-32768
};

static const short yypgoto[] = {-32768,
-32768,   100,-32768,   102,-32768,-32768,   -32,   -82,   -20,   110,
   -89,   -79,   126,   -25,   -19,   105
};


#define	YYLAST		1387


static const short yytable[] = {    58,
    59,    60,   156,    63,    66,    67,    68,    69,    70,     2,
    72,    73,    74,   157,    43,   128,    44,    85,    86,    87,
    88,    89,    90,    91,   195,    92,   128,   211,     2,    93,
    94,   122,    63,   129,   124,   125,   127,    99,   100,   186,
    52,   181,   102,   103,   104,   105,   136,   182,   131,   195,
   137,    54,   213,    55,   132,   140,   141,   142,   143,   144,
   145,   146,   147,   148,   149,   150,   151,   152,   153,   154,
   155,   125,   134,   158,   159,   160,   161,   162,    75,   135,
   163,   164,   165,   166,   167,   168,   169,   170,   171,   172,
   173,   174,   175,   176,   177,   178,   179,   180,   203,   204,
    56,   186,   186,     1,     2,   193,   194,   179,   196,   192,
    45,    46,    47,    48,   197,    49,    50,    51,    14,    53,
    57,    17,   207,    18,    19,   186,   206,    64,   118,   215,
   227,    20,    61,    65,    71,    21,    22,   117,   120,   121,
   130,   188,    23,   190,    24,   195,   205,   212,    25,    26,
   201,   206,   217,   228,    27,    28,    29,    30,    31,   221,
   222,   233,   234,   224,   225,    32,    33,   229,   208,   209,
   210,   230,   216,     0,   138,     0,   139,   123,   214,     0,
    90,    91,     0,    92,     0,     0,   218,    93,    94,    76,
     0,     0,   223,     0,     0,    99,   100,     0,   226,   125,
   102,   103,   104,   105,     0,     0,     0,     0,     0,   231,
    77,    78,    79,    80,    81,    82,    83,    84,    85,    86,
    87,    88,    89,    90,    91,     0,    92,     0,     0,     0,
    93,    94,     0,     0,    95,    96,    97,    98,    99,   100,
     0,     0,   101,   102,   103,   104,   105,    76,   106,     0,
     0,   107,   108,   109,   110,   111,   112,   113,   114,   115,
   116,     0,     0,     0,   199,     0,     0,     0,    77,    78,
    79,    80,    81,    82,    83,    84,    85,    86,    87,    88,
    89,    90,    91,     0,    92,   187,     0,     0,    93,    94,
     0,     0,    95,    96,    97,    98,    99,   100,    76,     0,
   101,   102,   103,   104,   105,     0,   106,     0,     0,   107,
   108,   109,   110,   111,   112,   113,   114,   115,   116,    77,
    78,    79,    80,    81,    82,    83,    84,    85,    86,    87,
    88,    89,    90,    91,     0,    92,   189,     0,     0,    93,
    94,     0,     0,    95,    96,    97,    98,    99,   100,    76,
     0,   101,   102,   103,   104,   105,     0,   106,     0,     0,
   107,   108,   109,   110,   111,   112,   113,   114,   115,   116,
    77,    78,    79,    80,    81,    82,    83,    84,    85,    86,
    87,    88,    89,    90,    91,     0,    92,   191,     0,     0,
    93,    94,     0,     0,    95,    96,    97,    98,    99,   100,
    76,     0,   101,   102,   103,   104,   105,     0,   106,     0,
     0,   107,   108,   109,   110,   111,   112,   113,   114,   115,
   116,    77,    78,    79,    80,    81,    82,    83,    84,    85,
    86,    87,    88,    89,    90,    91,     0,    92,   198,     0,
     0,    93,    94,     0,     0,    95,    96,    97,    98,    99,
   100,    76,     0,   101,   102,   103,   104,   105,     0,   106,
     0,     0,   107,   108,   109,   110,   111,   112,   113,   114,
   115,   116,    77,    78,    79,    80,    81,    82,    83,    84,
    85,    86,    87,    88,    89,    90,    91,   200,    92,     0,
     0,     0,    93,    94,     0,     0,    95,    96,    97,    98,
    99,   100,    76,     0,   101,   102,   103,   104,   105,     0,
   106,     0,     0,   107,   108,   109,   110,   111,   112,   113,
   114,   115,   116,    77,    78,    79,    80,    81,    82,    83,
    84,    85,    86,    87,    88,    89,    90,    91,     0,    92,
     0,     0,     0,    93,    94,     0,     0,    95,    96,    97,
    98,    99,   100,     0,     0,   101,   102,   103,   104,   105,
   202,   106,    76,     0,   107,   108,   109,   110,   111,   112,
   113,   114,   115,   116,     0,     0,     0,     0,     0,   219,
     0,     0,     0,    77,    78,    79,    80,    81,    82,    83,
    84,    85,    86,    87,    88,    89,    90,    91,     0,    92,
     0,     0,     0,    93,    94,     0,     0,    95,    96,    97,
    98,    99,   100,     0,    76,   101,   102,   103,   104,   105,
     0,   106,     0,     0,   107,   108,   109,   110,   111,   112,
   113,   114,   115,   116,   220,    77,    78,    79,    80,    81,
    82,    83,    84,    85,    86,    87,    88,    89,    90,    91,
     0,    92,     0,     0,     0,    93,    94,     0,     0,    95,
    96,    97,    98,    99,   100,    76,     0,   101,   102,   103,
   104,   105,     0,   106,     0,     0,   107,   108,   109,   110,
   111,   112,   113,   114,   115,   116,    77,    78,    79,    80,
    81,    82,    83,    84,    85,    86,    87,    88,    89,    90,
    91,     0,    92,     0,     0,     0,    93,    94,     0,     0,
    95,    96,    97,    98,    99,   100,    76,     0,   101,   102,
   103,   104,   105,     0,   106,     0,     0,   107,   108,   109,
   110,   111,   112,   113,   114,   115,   116,    77,    78,    79,
    80,    81,    82,    83,    84,    85,    86,    87,    88,    89,
    90,    91,     0,    92,     0,     0,     0,    93,    94,     0,
     0,    95,    96,    97,    98,    99,   100,    76,     0,   101,
   102,   103,   104,   105,     0,     0,     0,     0,   107,   108,
   109,   110,   111,   112,   113,   114,   115,   116,     0,    78,
    79,    80,    81,    82,    83,    84,    85,    86,    87,    88,
    89,    90,    91,     0,    92,     0,     0,     0,    93,    94,
     0,     0,    95,    96,    97,    98,    99,   100,     0,     0,
   101,   102,   103,   104,   105,     0,     0,     0,     0,   107,
   108,   109,   110,   111,   112,   113,   114,   115,   116,     1,
     2,     0,     0,     3,     4,     5,     6,     7,     8,     9,
    10,    11,    12,    13,    14,    15,    16,    17,     0,    18,
    19,     0,     0,     0,     0,     0,     0,    20,     0,     0,
     0,    21,    22,     0,     0,     0,     0,     0,    23,     0,
    24,     0,     0,     0,    25,    26,     0,     0,     1,     2,
    27,    28,    29,    30,    31,     0,     0,     0,     0,     0,
     0,    32,    33,    14,     0,     0,    17,     0,    18,    19,
     0,     0,     0,     0,     0,     0,    20,     0,     0,     0,
    21,    22,     0,     0,     0,     0,     0,    23,     0,    24,
     0,     0,     0,    25,    26,     0,     0,     1,     2,    27,
    28,    29,    30,    31,     0,     0,     0,     0,     0,     0,
    32,    33,    14,     0,     0,    17,     0,    18,    19,     0,
     0,    87,    88,    89,    90,    91,     0,    92,     0,    21,
    22,    93,    94,     0,     0,     0,    23,     0,    24,    99,
   100,     0,    25,    26,   102,   103,   104,   105,    27,    28,
    29,    30,-32768,     0,     0,     0,     0,     0,     0,    32,
    33,    79,    80,    81,    82,    83,    84,    85,    86,    87,
    88,    89,    90,    91,     0,    92,     0,     0,     0,    93,
    94,     0,     0,    95,    96,    97,    98,    99,   100,     0,
     0,   101,   102,   103,   104,   105,     0,     0,     0,     0,
   107,   108,   109,   110,   111,   112,   113,   114,   115,   116,
    80,    81,    82,    83,    84,    85,    86,    87,    88,    89,
    90,    91,     0,    92,     0,     0,     0,    93,    94,     0,
     0,     0,    96,    97,    98,    99,   100,     0,     0,   101,
   102,   103,   104,   105,     0,     0,     0,     0,   107,   108,
   109,   110,   111,   112,   113,   114,   115,   116,    80,    81,
    82,    83,    84,    85,    86,    87,    88,    89,    90,    91,
     0,    92,     0,     0,     0,    93,    94,     0,     0,     0,
     0,    97,    98,    99,   100,     0,     0,   101,   102,   103,
   104,   105,     0,     0,     0,     0,   107,   108,   109,   110,
   111,   112,   113,   114,   115,   116,    81,    82,    83,    84,
    85,    86,    87,    88,    89,    90,    91,     0,    92,     0,
     0,     0,    93,    94,     0,     0,     0,     0,    97,    98,
    99,   100,     0,     0,   101,   102,   103,   104,   105,     0,
     0,     0,     0,   107,   108,   109,   110,   111,   112,   113,
   114,   115,   116,    82,    83,    84,    85,    86,    87,    88,
    89,    90,    91,     0,    92,     0,     0,     0,    93,    94,
     0,     0,     0,     0,    97,    98,    99,   100,     0,     0,
   101,   102,   103,   104,   105,     0,     0,     0,     0,   107,
   108,   109,   110,   111,   112,   113,   114,   115,   116,    83,
    84,    85,    86,    87,    88,    89,    90,    91,     0,    92,
     0,     0,     0,    93,    94,     0,     0,     0,     0,    97,
    98,    99,   100,     0,     0,   101,   102,   103,   104,   105,
     0,     0,     0,     0,   107,   108,   109,   110,   111,   112,
   113,   114,   115,   116,    83,    84,    85,    86,    87,    88,
    89,    90,    91,     0,    92,     0,     0,     0,    93,    94,
     0,     0,     0,     0,    97,    98,    99,   100,     0,     0,
   101,   102,   103,   104,   105,     0,     0,     0,     0,     0,
     0,     0,     0,   111,   112,   113,   114,   115,   116,    85,
    86,    87,    88,    89,    90,    91,     0,    92,     0,     0,
     0,    93,    94,     0,     0,     0,     0,    97,    98,    99,
   100,     0,     0,-32768,   102,   103,   104,   105,    85,    86,
    87,    88,    89,    90,    91,     0,    92,     0,     0,     0,
    93,    94,     0,     0,     0,     0,    97,    98,    99,   100,
     0,     0,   101,   102,   103,   104,   105
};

static const short yycheck[] = {    20,
    21,    22,    92,    23,    25,    26,    27,    28,    29,     4,
    31,    32,    33,    93,     8,    25,     8,    34,    35,    36,
    37,    38,    39,    40,    40,    42,    25,    43,     4,    46,
    47,    52,    52,    43,    55,    56,    57,    54,    55,   119,
    42,    36,    59,    60,    61,    62,    45,    42,    36,    40,
    71,     7,    43,    42,    42,    76,    77,    78,    79,    80,
    81,    82,    83,    84,    85,    86,    87,    88,    89,    90,
    91,    92,    36,    94,    95,    96,    97,    98,    25,    43,
   101,   102,   103,   104,   105,   106,   107,   108,   109,   110,
   111,   112,   113,   114,   115,   116,   117,   118,   181,   182,
    42,   181,   182,     3,     4,   131,   132,   128,   134,   130,
     7,     8,     9,    10,   135,    11,    12,    13,    18,    15,
    42,    21,    22,    23,    24,   205,    40,    23,     6,    43,
   220,    31,    23,    24,    42,    35,    36,    25,     8,     8,
    43,    43,    42,    25,    44,    40,    26,     3,    48,    49,
    43,    40,     3,    43,    54,    55,    56,    57,    58,    42,
    41,     0,     0,    42,    41,    65,    66,    43,   189,   190,
   191,    43,   205,    -1,    75,    -1,    75,    52,   199,    -1,
    39,    40,    -1,    42,    -1,    -1,   207,    46,    47,     5,
    -1,    -1,   213,    -1,    -1,    54,    55,    -1,   219,   220,
    59,    60,    61,    62,    -1,    -1,    -1,    -1,    -1,   230,
    26,    27,    28,    29,    30,    31,    32,    33,    34,    35,
    36,    37,    38,    39,    40,    -1,    42,    -1,    -1,    -1,
    46,    47,    -1,    -1,    50,    51,    52,    53,    54,    55,
    -1,    -1,    58,    59,    60,    61,    62,     5,    64,    -1,
    -1,    67,    68,    69,    70,    71,    72,    73,    74,    75,
    76,    -1,    -1,    -1,    80,    -1,    -1,    -1,    26,    27,
    28,    29,    30,    31,    32,    33,    34,    35,    36,    37,
    38,    39,    40,    -1,    42,    43,    -1,    -1,    46,    47,
    -1,    -1,    50,    51,    52,    53,    54,    55,     5,    -1,
    58,    59,    60,    61,    62,    -1,    64,    -1,    -1,    67,
    68,    69,    70,    71,    72,    73,    74,    75,    76,    26,
    27,    28,    29,    30,    31,    32,    33,    34,    35,    36,
    37,    38,    39,    40,    -1,    42,    43,    -1,    -1,    46,
    47,    -1,    -1,    50,    51,    52,    53,    54,    55,     5,
    -1,    58,    59,    60,    61,    62,    -1,    64,    -1,    -1,
    67,    68,    69,    70,    71,    72,    73,    74,    75,    76,
    26,    27,    28,    29,    30,    31,    32,    33,    34,    35,
    36,    37,    38,    39,    40,    -1,    42,    43,    -1,    -1,
    46,    47,    -1,    -1,    50,    51,    52,    53,    54,    55,
     5,    -1,    58,    59,    60,    61,    62,    -1,    64,    -1,
    -1,    67,    68,    69,    70,    71,    72,    73,    74,    75,
    76,    26,    27,    28,    29,    30,    31,    32,    33,    34,
    35,    36,    37,    38,    39,    40,    -1,    42,    43,    -1,
    -1,    46,    47,    -1,    -1,    50,    51,    52,    53,    54,
    55,     5,    -1,    58,    59,    60,    61,    62,    -1,    64,
    -1,    -1,    67,    68,    69,    70,    71,    72,    73,    74,
    75,    76,    26,    27,    28,    29,    30,    31,    32,    33,
    34,    35,    36,    37,    38,    39,    40,    41,    42,    -1,
    -1,    -1,    46,    47,    -1,    -1,    50,    51,    52,    53,
    54,    55,     5,    -1,    58,    59,    60,    61,    62,    -1,
    64,    -1,    -1,    67,    68,    69,    70,    71,    72,    73,
    74,    75,    76,    26,    27,    28,    29,    30,    31,    32,
    33,    34,    35,    36,    37,    38,    39,    40,    -1,    42,
    -1,    -1,    -1,    46,    47,    -1,    -1,    50,    51,    52,
    53,    54,    55,    -1,    -1,    58,    59,    60,    61,    62,
    63,    64,     5,    -1,    67,    68,    69,    70,    71,    72,
    73,    74,    75,    76,    -1,    -1,    -1,    -1,    -1,    22,
    -1,    -1,    -1,    26,    27,    28,    29,    30,    31,    32,
    33,    34,    35,    36,    37,    38,    39,    40,    -1,    42,
    -1,    -1,    -1,    46,    47,    -1,    -1,    50,    51,    52,
    53,    54,    55,    -1,     5,    58,    59,    60,    61,    62,
    -1,    64,    -1,    -1,    67,    68,    69,    70,    71,    72,
    73,    74,    75,    76,    25,    26,    27,    28,    29,    30,
    31,    32,    33,    34,    35,    36,    37,    38,    39,    40,
    -1,    42,    -1,    -1,    -1,    46,    47,    -1,    -1,    50,
    51,    52,    53,    54,    55,     5,    -1,    58,    59,    60,
    61,    62,    -1,    64,    -1,    -1,    67,    68,    69,    70,
    71,    72,    73,    74,    75,    76,    26,    27,    28,    29,
    30,    31,    32,    33,    34,    35,    36,    37,    38,    39,
    40,    -1,    42,    -1,    -1,    -1,    46,    47,    -1,    -1,
    50,    51,    52,    53,    54,    55,     5,    -1,    58,    59,
    60,    61,    62,    -1,    64,    -1,    -1,    67,    68,    69,
    70,    71,    72,    73,    74,    75,    76,    26,    27,    28,
    29,    30,    31,    32,    33,    34,    35,    36,    37,    38,
    39,    40,    -1,    42,    -1,    -1,    -1,    46,    47,    -1,
    -1,    50,    51,    52,    53,    54,    55,     5,    -1,    58,
    59,    60,    61,    62,    -1,    -1,    -1,    -1,    67,    68,
    69,    70,    71,    72,    73,    74,    75,    76,    -1,    27,
    28,    29,    30,    31,    32,    33,    34,    35,    36,    37,
    38,    39,    40,    -1,    42,    -1,    -1,    -1,    46,    47,
    -1,    -1,    50,    51,    52,    53,    54,    55,    -1,    -1,
    58,    59,    60,    61,    62,    -1,    -1,    -1,    -1,    67,
    68,    69,    70,    71,    72,    73,    74,    75,    76,     3,
     4,    -1,    -1,     7,     8,     9,    10,    11,    12,    13,
    14,    15,    16,    17,    18,    19,    20,    21,    -1,    23,
    24,    -1,    -1,    -1,    -1,    -1,    -1,    31,    -1,    -1,
    -1,    35,    36,    -1,    -1,    -1,    -1,    -1,    42,    -1,
    44,    -1,    -1,    -1,    48,    49,    -1,    -1,     3,     4,
    54,    55,    56,    57,    58,    -1,    -1,    -1,    -1,    -1,
    -1,    65,    66,    18,    -1,    -1,    21,    -1,    23,    24,
    -1,    -1,    -1,    -1,    -1,    -1,    31,    -1,    -1,    -1,
    35,    36,    -1,    -1,    -1,    -1,    -1,    42,    -1,    44,
    -1,    -1,    -1,    48,    49,    -1,    -1,     3,     4,    54,
    55,    56,    57,    58,    -1,    -1,    -1,    -1,    -1,    -1,
    65,    66,    18,    -1,    -1,    21,    -1,    23,    24,    -1,
    -1,    36,    37,    38,    39,    40,    -1,    42,    -1,    35,
    36,    46,    47,    -1,    -1,    -1,    42,    -1,    44,    54,
    55,    -1,    48,    49,    59,    60,    61,    62,    54,    55,
    56,    57,    58,    -1,    -1,    -1,    -1,    -1,    -1,    65,
    66,    28,    29,    30,    31,    32,    33,    34,    35,    36,
    37,    38,    39,    40,    -1,    42,    -1,    -1,    -1,    46,
    47,    -1,    -1,    50,    51,    52,    53,    54,    55,    -1,
    -1,    58,    59,    60,    61,    62,    -1,    -1,    -1,    -1,
    67,    68,    69,    70,    71,    72,    73,    74,    75,    76,
    29,    30,    31,    32,    33,    34,    35,    36,    37,    38,
    39,    40,    -1,    42,    -1,    -1,    -1,    46,    47,    -1,
    -1,    -1,    51,    52,    53,    54,    55,    -1,    -1,    58,
    59,    60,    61,    62,    -1,    -1,    -1,    -1,    67,    68,
    69,    70,    71,    72,    73,    74,    75,    76,    29,    30,
    31,    32,    33,    34,    35,    36,    37,    38,    39,    40,
    -1,    42,    -1,    -1,    -1,    46,    47,    -1,    -1,    -1,
    -1,    52,    53,    54,    55,    -1,    -1,    58,    59,    60,
    61,    62,    -1,    -1,    -1,    -1,    67,    68,    69,    70,
    71,    72,    73,    74,    75,    76,    30,    31,    32,    33,
    34,    35,    36,    37,    38,    39,    40,    -1,    42,    -1,
    -1,    -1,    46,    47,    -1,    -1,    -1,    -1,    52,    53,
    54,    55,    -1,    -1,    58,    59,    60,    61,    62,    -1,
    -1,    -1,    -1,    67,    68,    69,    70,    71,    72,    73,
    74,    75,    76,    31,    32,    33,    34,    35,    36,    37,
    38,    39,    40,    -1,    42,    -1,    -1,    -1,    46,    47,
    -1,    -1,    -1,    -1,    52,    53,    54,    55,    -1,    -1,
    58,    59,    60,    61,    62,    -1,    -1,    -1,    -1,    67,
    68,    69,    70,    71,    72,    73,    74,    75,    76,    32,
    33,    34,    35,    36,    37,    38,    39,    40,    -1,    42,
    -1,    -1,    -1,    46,    47,    -1,    -1,    -1,    -1,    52,
    53,    54,    55,    -1,    -1,    58,    59,    60,    61,    62,
    -1,    -1,    -1,    -1,    67,    68,    69,    70,    71,    72,
    73,    74,    75,    76,    32,    33,    34,    35,    36,    37,
    38,    39,    40,    -1,    42,    -1,    -1,    -1,    46,    47,
    -1,    -1,    -1,    -1,    52,    53,    54,    55,    -1,    -1,
    58,    59,    60,    61,    62,    -1,    -1,    -1,    -1,    -1,
    -1,    -1,    -1,    71,    72,    73,    74,    75,    76,    34,
    35,    36,    37,    38,    39,    40,    -1,    42,    -1,    -1,
    -1,    46,    47,    -1,    -1,    -1,    -1,    52,    53,    54,
    55,    -1,    -1,    58,    59,    60,    61,    62,    34,    35,
    36,    37,    38,    39,    40,    -1,    42,    -1,    -1,    -1,
    46,    47,    -1,    -1,    -1,    -1,    52,    53,    54,    55,
    -1,    -1,    58,    59,    60,    61,    62
};
/* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
#line 3 "bison.simple"

/* Skeleton output parser for bison,
   Copyright (C) 1984, 1989, 1990 Bob Corbett and Richard Stallman

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 1, or (at your option)
   any later version.

   This program 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 this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */


#ifndef alloca
#ifdef __GNUC__
#define alloca __builtin_alloca
#else /* not GNU C.  */
#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
#include <alloca.h>
#else /* not sparc */
#if defined (MSDOS) && !defined (__TURBOC__)
#include <malloc.h>
#else /* not MSDOS, or __TURBOC__ */
#if defined(_AIX)
#include <malloc.h>
 #pragma alloca
#else /* not MSDOS, __TURBOC__, or _AIX */
#ifdef __hpux
#ifdef __cplusplus
extern "C" {
void *alloca (unsigned int);
};
#else /* not __cplusplus */
void *alloca ();
#endif /* not __cplusplus */
#endif /* __hpux */
#endif /* not _AIX */
#endif /* not MSDOS, or __TURBOC__ */
#endif /* not sparc.  */
#endif /* not GNU C.  */
#endif /* alloca not defined.  */

/* This is the parser code that is written into each bison parser
  when the %semantic_parser declaration is not specified in the grammar.
  It was written by Richard Stallman by simplifying the hairy parser
  used when %semantic_parser is specified.  */

/* Note: there must be only one dollar sign in this file.
   It is replaced by the list of actions, each action
   as one case of the switch.  */

#define yyerrok		(yyerrstatus = 0)
#define yyclearin	(yychar = YYEMPTY)
#define YYEMPTY		-2
#define YYEOF		0
#define YYACCEPT	return(0)
#define YYABORT 	return(1)
#define YYERROR		goto yyerrlab1
/* Like YYERROR except do call yyerror.
   This remains here temporarily to ease the
   transition to the new meaning of YYERROR, for GCC.
   Once GCC version 2 has supplanted version 1, this can go.  */
#define YYFAIL		goto yyerrlab
#define YYRECOVERING()  (!!yyerrstatus)
#define YYBACKUP(token, value) \
do								\
  if (yychar == YYEMPTY && yylen == 1)				\
    { yychar = (token), yylval = (value);			\
      yychar1 = YYTRANSLATE (yychar);				\
      YYPOPSTACK;						\
      goto yybackup;						\
    }								\
  else								\
    { yyerror ("syntax error: cannot back up"); YYERROR; }	\
while (0)

#define YYTERROR	1
#define YYERRCODE	256

#ifndef YYPURE
#define YYLEX		yylex()
#endif

#ifdef YYPURE
#ifdef YYLSP_NEEDED
#define YYLEX		yylex(&yylval, &yylloc)
#else
#define YYLEX		yylex(&yylval)
#endif
#endif

/* If nonreentrant, generate the variables here */

#ifndef YYPURE

int	yychar;			/*  the lookahead symbol		*/
YYSTYPE	yylval;			/*  the semantic value of the		*/
				/*  lookahead symbol			*/

#ifdef YYLSP_NEEDED
YYLTYPE yylloc;			/*  location data for the lookahead	*/
				/*  symbol				*/
#endif

int yynerrs;			/*  number of parse errors so far       */
#endif  /* not YYPURE */

#if YYDEBUG != 0
int yydebug;			/*  nonzero means print parse trace	*/
/* Since this is uninitialized, it does not stop multiple parsers
   from coexisting.  */
#endif

/*  YYINITDEPTH indicates the initial size of the parser's stacks	*/

#ifndef	YYINITDEPTH
#define YYINITDEPTH 200
#endif

/*  YYMAXDEPTH is the maximum size the stacks can grow to
    (effective only if the built-in stack extension method is used).  */

#if YYMAXDEPTH == 0
#undef YYMAXDEPTH
#endif

#ifndef YYMAXDEPTH
#define YYMAXDEPTH 10000
#endif

/* Prevent warning if -Wstrict-prototypes.  */
#ifdef __GNUC__
int yyparse (void);
#endif

#if __GNUC__ > 1		/* GNU C and GNU C++ define this.  */
#define __yy_bcopy(FROM,TO,COUNT)	__builtin_memcpy(TO,FROM,COUNT)
#else				/* not GNU C or C++ */
#ifndef __cplusplus

/* This is the most reliable way to avoid incompatibilities
   in available built-in functions on various systems.  */
static void
__yy_bcopy (from, to, count)
     char *from;
     char *to;
     int count;
{
  register char *f = from;
  register char *t = to;
  register int i = count;

  while (i-- > 0)
    *t++ = *f++;
}

#else /* __cplusplus */

/* This is the most reliable way to avoid incompatibilities
   in available built-in functions on various systems.  */
static void
__yy_bcopy (char *from, char *to, int count)
{
  register char *f = from;
  register char *t = to;
  register int i = count;

  while (i-- > 0)
    *t++ = *f++;
}

#endif
#endif

#line 184 "bison.simple"
int
yyparse()
{
  register int yystate;
  register int yyn;
  register short *yyssp;
  register YYSTYPE *yyvsp;
  int yyerrstatus;	/*  number of tokens to shift before error messages enabled */
  int yychar1 = 0;		/*  lookahead token as an internal (translated) token number */

  short	yyssa[YYINITDEPTH];	/*  the state stack			*/
  YYSTYPE yyvsa[YYINITDEPTH];	/*  the semantic value stack		*/

  short *yyss = yyssa;		/*  refer to the stacks thru separate pointers */
  YYSTYPE *yyvs = yyvsa;	/*  to allow yyoverflow to reallocate them elsewhere */

#ifdef YYLSP_NEEDED
  YYLTYPE yylsa[YYINITDEPTH];	/*  the location stack			*/
  YYLTYPE *yyls = yylsa;
  YYLTYPE *yylsp;

#define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
#else
#define YYPOPSTACK   (yyvsp--, yyssp--)
#endif

  int yystacksize = YYINITDEPTH;

#ifdef YYPURE
  int yychar;
  YYSTYPE yylval;
  int yynerrs;
#ifdef YYLSP_NEEDED
  YYLTYPE yylloc;
#endif
#endif

  YYSTYPE yyval;		/*  the variable used to return		*/
				/*  semantic values from the action	*/
				/*  routines				*/

  int yylen;

#if YYDEBUG != 0
  if (yydebug)
    fprintf(stderr, "Starting parse\n");
#endif

  yystate = 0;
  yyerrstatus = 0;
  yynerrs = 0;
  yychar = YYEMPTY;		/* Cause a token to be read.  */

  /* Initialize stack pointers.
     Waste one element of value and location stack
     so that they stay on the same level as the state stack.
     The wasted elements are never initialized.  */

  yyssp = yyss - 1;
  yyvsp = yyvs;
#ifdef YYLSP_NEEDED
  yylsp = yyls;
#endif

/* Push a new state, which is found in  yystate  .  */
/* In all cases, when you get here, the value and location stacks
   have just been pushed. so pushing a state here evens the stacks.  */
yynewstate:

  *++yyssp = yystate;

  if (yyssp >= yyss + yystacksize - 1)
    {
      /* Give user a chance to reallocate the stack */
      /* Use copies of these so that the &'s don't force the real ones into memory. */
      YYSTYPE *yyvs1 = yyvs;
      short *yyss1 = yyss;
#ifdef YYLSP_NEEDED
      YYLTYPE *yyls1 = yyls;
#endif

      /* Get the current used size of the three stacks, in elements.  */
      int size = yyssp - yyss + 1;

#ifdef yyoverflow
      /* Each stack pointer address is followed by the size of
	 the data in use in that stack, in bytes.  */
#ifdef YYLSP_NEEDED
      /* This used to be a conditional around just the two extra args,
	 but that might be undefined if yyoverflow is a macro.  */
      yyoverflow("parser stack overflow",
		 &yyss1, size * sizeof (*yyssp),
		 &yyvs1, size * sizeof (*yyvsp),
		 &yyls1, size * sizeof (*yylsp),
		 &yystacksize);
#else
      yyoverflow("parser stack overflow",
		 &yyss1, size * sizeof (*yyssp),
		 &yyvs1, size * sizeof (*yyvsp),
		 &yystacksize);
#endif

      yyss = yyss1; yyvs = yyvs1;
#ifdef YYLSP_NEEDED
      yyls = yyls1;
#endif
#else /* no yyoverflow */
      /* Extend the stack our own way.  */
      if (yystacksize >= YYMAXDEPTH)
	{
	  yyerror("parser stack overflow");
	  return 2;
	}
      yystacksize *= 2;
      if (yystacksize > YYMAXDEPTH)
	yystacksize = YYMAXDEPTH;
      yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
      __yy_bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
      yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
      __yy_bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
#ifdef YYLSP_NEEDED
      yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
      __yy_bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
#endif
#endif /* no yyoverflow */

      yyssp = yyss + size - 1;
      yyvsp = yyvs + size - 1;
#ifdef YYLSP_NEEDED
      yylsp = yyls + size - 1;
#endif

#if YYDEBUG != 0
      if (yydebug)
	fprintf(stderr, "Stack size increased to %d\n", yystacksize);
#endif

      if (yyssp >= yyss + yystacksize - 1)
	YYABORT;
    }

#if YYDEBUG != 0
  if (yydebug)
    fprintf(stderr, "Entering state %d\n", yystate);
#endif

  goto yybackup;
 yybackup:

/* Do appropriate processing given the current state.  */
/* Read a lookahead token if we need one and don't already have one.  */
/* yyresume: */

  /* First try to decide what to do without reference to lookahead token.  */

  yyn = yypact[yystate];
  if (yyn == YYFLAG)
    goto yydefault;

  /* Not known => get a lookahead token if don't already have one.  */

  /* yychar is either YYEMPTY or YYEOF
     or a valid token in external form.  */

  if (yychar == YYEMPTY)
    {
#if YYDEBUG != 0
      if (yydebug)
	fprintf(stderr, "Reading a token: ");
#endif
      yychar = YYLEX;
    }

  /* Convert token to internal form (in yychar1) for indexing tables with */

  if (yychar <= 0)		/* This means end of input. */
    {
      yychar1 = 0;
      yychar = YYEOF;		/* Don't call YYLEX any more */

#if YYDEBUG != 0
      if (yydebug)
	fprintf(stderr, "Now at end of input.\n");
#endif
    }
  else
    {
      yychar1 = YYTRANSLATE(yychar);

#if YYDEBUG != 0
      if (yydebug)
	{
	  fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
	  /* Give the individual parser a way to print the precise meaning
	     of a token, for further debugging info.  */
#ifdef YYPRINT
	  YYPRINT (stderr, yychar, yylval);
#endif
	  fprintf (stderr, ")\n");
	}
#endif
    }

  yyn += yychar1;
  if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
    goto yydefault;

  yyn = yytable[yyn];

  /* yyn is what to do for this token type in this state.
     Negative => reduce, -yyn is rule number.
     Positive => shift, yyn is new state.
       New state is final state => don't bother to shift,
       just return success.
     0, or most negative number => error.  */

  if (yyn < 0)
    {
      if (yyn == YYFLAG)
	goto yyerrlab;
      yyn = -yyn;
      goto yyreduce;
    }
  else if (yyn == 0)
    goto yyerrlab;

  if (yyn == YYFINAL)
    YYACCEPT;

  /* Shift the lookahead token.  */

#if YYDEBUG != 0
  if (yydebug)
    fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
#endif

  /* Discard the token being shifted unless it is eof.  */
  if (yychar != YYEOF)
    yychar = YYEMPTY;

  *++yyvsp = yylval;
#ifdef YYLSP_NEEDED
  *++yylsp = yylloc;
#endif

  /* count tokens shifted since error; after three, turn off error status.  */
  if (yyerrstatus) yyerrstatus--;

  yystate = yyn;
  goto yynewstate;

/* Do the default action for the current state.  */
yydefault:

  yyn = yydefact[yystate];
  if (yyn == 0)
    goto yyerrlab;

/* Do a reduction.  yyn is the number of a rule to reduce with.  */
yyreduce:
  yylen = yyr2[yyn];
  if (yylen > 0)
    yyval = yyvsp[1-yylen]; /* implement default value of the action */

#if YYDEBUG != 0
  if (yydebug)
    {
      int i;

      fprintf (stderr, "Reducing via rule %d (line %d), ",
	       yyn, yyrline[yyn]);

      /* Print the symbols being reduced, and their result.  */
      for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
	fprintf (stderr, "%s ", yytname[yyrhs[i]]);
      fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
    }
#endif


  switch (yyn) {

case 1:
#line 211 "parse.y"
{ root=yyvsp[0].node ; ;
    break;}
case 4:
#line 216 "parse.y"
{ yyval.node=mknode_sbin(yyvsp[-1].opinfo,yyvsp[-2].node,yyvsp[0].node);;
    break;}
case 7:
#line 220 "parse.y"
{ yyval.node=mknode_sbin(yyvsp[0].opinfo,yyvsp[-1].node,0); ;
    break;}
case 9:
#line 223 "parse.y"
{ yyval.node=mknode_sbin(yyvsp[-1].opinfo,yyvsp[-2].node,yyvsp[0].node); ;
    break;}
case 10:
#line 226 "parse.y"
{ decl_tbase=yyvsp[0].ctype ; ;
    break;}
case 11:
#line 226 "parse.y"
{ yyval.node=yyvsp[0].node ; ;
    break;}
case 13:
#line 229 "parse.y"
{ yyval.node=mknode_sbin(seq_op,yyvsp[-2].node,yyvsp[0].node); ;
    break;}
case 14:
#line 232 "parse.y"
{ yyval.node=mknode_sbin(decl_op,yyvsp[0].node,
 				   mknode_modified_ctype(decl_tbase)); ;
    break;}
case 15:
#line 236 "parse.y"
{ yyval.node=yyvsp[-1].node ; ;
    break;}
case 16:
#line 237 "parse.y"
{ yyval.node=yyvsp[-3].node ; push_type('('); ;
    break;}
case 17:
#line 238 "parse.y"
{ yyval.node=yyvsp[0].node ; push_type('*'); ;
    break;}
case 18:
#line 239 "parse.y"
{ yyval.node=yyvsp[-3].node ; push_type_int('[',yyvsp[-1].node); ;
    break;}
case 20:
#line 251 "parse.y"
{ yyval.node=mknode_tri(yyvsp[-4].opinfo,yyvsp[-2].node,yyvsp[0].node,0); ;
    break;}
case 21:
#line 253 "parse.y"
{ yyval.node=mknode_tri(yyvsp[-5].opinfo,yyvsp[-3].node,yyvsp[-1].node,0); ;
    break;}
case 22:
#line 255 "parse.y"
{ yyval.node=mknode_tri(yyvsp[-5].opinfo,yyvsp[-3].node,0,yyvsp[0].node); ;
    break;}
case 23:
#line 257 "parse.y"
{ yyval.node=mknode_tri(yyvsp[-6].opinfo,yyvsp[-4].node,yyvsp[-2].node,yyvsp[0].node); ;
    break;}
case 24:
#line 260 "parse.y"
{  yyval.node=mknode_op(OPK_QUAD,yyvsp[-8].opinfo,yyvsp[-6].node,yyvsp[-4].node,yyvsp[-2].node,yyvsp[0].node); ;
    break;}
case 25:
#line 262 "parse.y"
{  yyval.node=mknode_op(OPK_QUAD,yyvsp[-7].opinfo,yyvsp[-5].node,yyvsp[-3].node,yyvsp[-1].node,0); ;
    break;}
case 26:
#line 264 "parse.y"
{  yyval.node=mknode_sbin(yyvsp[-4].opinfo,yyvsp[-2].node,yyvsp[0].node); ;
    break;}
case 27:
#line 266 "parse.y"
{  yyval.node=mknode_sbin(yyvsp[-3].opinfo,yyvsp[-1].node,0); ;
    break;}
case 28:
#line 271 "parse.y"
{ yyval.node=mknode_unary( yyvsp[-1].opinfo,yyvsp[0].node); ;
    break;}
case 29:
#line 272 "parse.y"
{ yyval.node=mknode_unary( yyvsp[-1].opinfo,yyvsp[0].node); ;
    break;}
case 30:
#line 273 "parse.y"
{ yyval.node=mknode_unary( yyvsp[-1].opinfo,yyvsp[0].node); ;
    break;}
case 31:
#line 274 "parse.y"
{ yyval.node=mknode_unary( yyvsp[-1].opinfo,yyvsp[0].node); ;
    break;}
case 32:
#line 275 "parse.y"
{ yyval.node=mknode_unary( yyvsp[-1].opinfo,yyvsp[0].node); ;
    break;}
case 33:
#line 276 "parse.y"
{ yyval.node=mknode_sunary(yyvsp[-1].opinfo,yyvsp[0].node); ;
    break;}
case 34:
#line 277 "parse.y"
{ yyval.node=mknode_sunary(yyvsp[-1].opinfo,yyvsp[0].node); ;
    break;}
case 35:
#line 278 "parse.y"
{ yyval.node=mknode_sunary(yyvsp[-1].opinfo,yyvsp[0].node); ;
    break;}
case 36:
#line 279 "parse.y"
{ yyval.node=mknode_unary( yyvsp[-1].opinfo,yyvsp[0].node); ;
    break;}
case 37:
#line 280 "parse.y"
{ yyval.node=mknode_unary( yyvsp[-1].opinfo,yyvsp[0].node); ;
    break;}
case 38:
#line 281 "parse.y"
{ yyval.node=mknode_post_unary(yyvsp[0].opinfo,yyvsp[-1].node); ;
    break;}
case 39:
#line 282 "parse.y"
{ yyval.node=mknode_post_unary(yyvsp[0].opinfo,yyvsp[-1].node); ;
    break;}
case 40:
#line 283 "parse.y"
{ yyval.node=mknode_sunary(yyvsp[-3].opinfo,yyvsp[-1].node); ;
    break;}
case 41:
#line 284 "parse.y"
{ yyval.node=mknode_unary(yyvsp[-3].opinfo,yyvsp[-1].node); ;
    break;}
case 42:
#line 285 "parse.y"
{ yyval.node=mknode_unary( yyvsp[-3].opinfo,yyvsp[-1].node); ;
    break;}
case 43:
#line 288 "parse.y"
{ yyval.node=mknode_sbin(yyvsp[-1].opinfo,yyvsp[-2].node,yyvsp[0].node); ;
    break;}
case 44:
#line 289 "parse.y"
{ yyval.node=mknode_sbin(yyvsp[-1].opinfo,yyvsp[-2].node,yyvsp[0].node); ;
    break;}
case 45:
#line 291 "parse.y"
{ yyval.node=mknode_sbin(yyvsp[-1].opinfo,yyvsp[-2].node,yyvsp[0].node); ;
    break;}
case 46:
#line 292 "parse.y"
{ yyval.node=mknode_sbin(yyvsp[-1].opinfo,yyvsp[-2].node,yyvsp[0].node); ;
    break;}
case 47:
#line 293 "parse.y"
{ yyval.node=mknode_sbin(yyvsp[-1].opinfo,yyvsp[-2].node,yyvsp[0].node); ;
    break;}
case 48:
#line 294 "parse.y"
{ yyval.node=mknode_sbin(yyvsp[-1].opinfo,yyvsp[-2].node,yyvsp[0].node); ;
    break;}
case 49:
#line 295 "parse.y"
{ yyval.node=mknode_bin( yyvsp[-2].opinfo,yyvsp[-3].node,yyvsp[-1].node); ;
    break;}
case 50:
#line 296 "parse.y"
{ yyval.node=mknode_sbin(yyvsp[-2].opinfo,yyvsp[-3].node,yyvsp[-1].node); ;
    break;}
case 51:
#line 297 "parse.y"
{ yyval.node=mknode_op(OPK_FUNC,yyvsp[-2].opinfo,yyvsp[-3].node,yyvsp[-1].node,0,0); ;
    break;}
case 52:
#line 298 "parse.y"
{ yyval.node=mknode_unary(yyvsp[-2].opinfo,yyvsp[-1].node); ;
    break;}
case 53:
#line 299 "parse.y"
{ yyval.node=mknode_unary(yyvsp[-2].opinfo,yyvsp[-1].node); ;
    break;}
case 54:
#line 303 "parse.y"
{ yyval.node=mknode_op(OPK_CAST,yyvsp[-3].opinfo,yyvsp[-2].node,yyvsp[0].node,0,0); ;
    break;}
case 55:
#line 313 "parse.y"
{ 
                  tctype *t=duel_get_target_typedef(yyvsp[-2].nameinfo.name);
                  if(t==NULL) yyerror("not a typedef name"); 
                  yyval.node=mknode_op(OPK_CAST,yyvsp[-3].opinfo,mknode_ctype(t),yyvsp[0].node,0,0); ;
    break;}
case 56:
#line 317 "parse.y"
{ 
                 tctype *t=duel_get_target_typedef(yyvsp[-4].nameinfo.name);
                 if(t==NULL) yyerror("not a typedef name"); 
                 push_type('*');
                 yyval.node=mknode_op(OPK_CAST,yyvsp[-5].opinfo,mknode_modified_ctype(t),yyvsp[0].node,0,0); ;
    break;}
case 57:
#line 326 "parse.y"
{ yyval.node=mknode_bin(yyvsp[-1].opinfo,yyvsp[-2].node,yyvsp[0].node); ;
    break;}
case 58:
#line 327 "parse.y"
{ yyval.node=mknode_bin(yyvsp[-1].opinfo,yyvsp[-2].node,yyvsp[0].node); ;
    break;}
case 59:
#line 328 "parse.y"
{ yyval.node=mknode_bin(yyvsp[-1].opinfo,yyvsp[-2].node,yyvsp[0].node); ;
    break;}
case 60:
#line 329 "parse.y"
{ yyval.node=mknode_bin(yyvsp[-1].opinfo,yyvsp[-2].node,yyvsp[0].node); ;
    break;}
case 61:
#line 330 "parse.y"
{ yyval.node=mknode_bin(yyvsp[-1].opinfo,yyvsp[-2].node,yyvsp[0].node); ;
    break;}
case 62:
#line 331 "parse.y"
{ yyval.node=mknode_bin(yyvsp[-1].opinfo,yyvsp[-2].node,yyvsp[0].node); ;
    break;}
case 63:
#line 332 "parse.y"
{ yyval.node=mknode_bin(yyvsp[-1].opinfo,yyvsp[-2].node,yyvsp[0].node); ;
    break;}
case 64:
#line 333 "parse.y"
{ yyval.node=mknode_bin(yyvsp[-1].opinfo,yyvsp[-2].node,yyvsp[0].node); ;
    break;}
case 65:
#line 334 "parse.y"
{ yyval.node=mknode_bin(yyvsp[-1].opinfo,yyvsp[-2].node,yyvsp[0].node); ;
    break;}
case 66:
#line 335 "parse.y"
{ yyval.node=mknode_bin(yyvsp[-1].opinfo,yyvsp[-2].node,yyvsp[0].node); ;
    break;}
case 67:
#line 336 "parse.y"
{ yyval.node=mknode_bin(yyvsp[-1].opinfo,yyvsp[-2].node,yyvsp[0].node); ;
    break;}
case 68:
#line 337 "parse.y"
{ yyval.node=mknode_bin(yyvsp[-1].opinfo,yyvsp[-2].node,yyvsp[0].node); ;
    break;}
case 69:
#line 338 "parse.y"
{ yyval.node=mknode_bin(yyvsp[-1].opinfo,yyvsp[-2].node,yyvsp[0].node); ;
    break;}
case 70:
#line 339 "parse.y"
{ yyval.node=mknode_bin(yyvsp[-1].opinfo,yyvsp[-2].node,yyvsp[0].node); ;
    break;}
case 71:
#line 340 "parse.y"
{ yyval.node=mknode_bin(yyvsp[-1].opinfo,yyvsp[-2].node,yyvsp[0].node); ;
    break;}
case 72:
#line 341 "parse.y"
{ yyval.node=mknode_bin(yyvsp[-1].opinfo,yyvsp[-2].node,yyvsp[0].node); ;
    break;}
case 73:
#line 342 "parse.y"
{ yyval.node=mknode_bin(yyvsp[-1].opinfo,yyvsp[-2].node,yyvsp[0].node); ;
    break;}
case 74:
#line 343 "parse.y"
{ yyval.node=mknode_bin(yyvsp[-1].opinfo,yyvsp[-2].node,yyvsp[0].node); ;
    break;}
case 75:
#line 344 "parse.y"
{ yyval.node=mknode_bin(yyvsp[-1].opinfo,yyvsp[-2].node,yyvsp[0].node); ;
    break;}
case 76:
#line 345 "parse.y"
{ yyval.node=mknode_bin(yyvsp[-1].opinfo,yyvsp[-2].node,yyvsp[0].node); ;
    break;}
case 77:
#line 346 "parse.y"
{ yyval.node=mknode_bin(yyvsp[-1].opinfo,yyvsp[-2].node,yyvsp[0].node); ;
    break;}
case 78:
#line 347 "parse.y"
{ yyval.node=mknode_bin(yyvsp[-1].opinfo,yyvsp[-2].node,yyvsp[0].node); ;
    break;}
case 79:
#line 348 "parse.y"
{ yyval.node=mknode_sbin(yyvsp[-1].opinfo,yyvsp[-2].node,yyvsp[0].node); ;
    break;}
case 80:
#line 349 "parse.y"
{ yyval.node=mknode_sbin(yyvsp[-1].opinfo,yyvsp[-2].node,yyvsp[0].node); ;
    break;}
case 81:
#line 353 "parse.y"
{ yyval.node=mknode_tri(yyvsp[-3].opinfo,yyvsp[-4].node,yyvsp[-2].node,yyvsp[0].node); ;
    break;}
case 82:
#line 356 "parse.y"
{ yyval.node=mknode_bin(yyvsp[-1].opinfo,yyvsp[-2].node,yyvsp[0].node); ;
    break;}
case 83:
#line 357 "parse.y"
{ yyval.node=mknode_op(OPK_ASSIGN,yyvsp[-1].opinfo, yyvsp[-2].node,yyvsp[0].node,0,0);  ;
    break;}
case 84:
#line 358 "parse.y"
{ yyval.node=mknode_sbin(yyvsp[-1].opinfo,yyvsp[-2].node,yyvsp[0].node);  ;
    break;}
case 85:
#line 363 "parse.y"
{ yyval.node=mknode_sbin(yyvsp[-1].opinfo,yyvsp[-2].node,yyvsp[0].node); ;
    break;}
case 86:
#line 364 "parse.y"
{ yyval.node=mknode_sbin(yyvsp[-1].opinfo, 0,yyvsp[0].node); ;
    break;}
case 87:
#line 365 "parse.y"
{ yyval.node=mknode_sbin(yyvsp[0].opinfo,yyvsp[-1].node, 0); ;
    break;}
case 88:
#line 366 "parse.y"
{ yyval.node=mknode_sbin(yyvsp[-1].opinfo,yyvsp[-2].node,yyvsp[0].node); ;
    break;}
case 89:
#line 367 "parse.y"
{ yyval.node=mknode_sbin(yyvsp[-1].opinfo,yyvsp[-2].node,yyvsp[0].node); ;
    break;}
case 90:
#line 370 "parse.y"
{ yyval.node=mknode_sbin(yyvsp[-1].opinfo,yyvsp[-2].node,yyvsp[0].node); ;
    break;}
case 93:
#line 375 "parse.y"
{ yyval.node=0 ; ;
    break;}
case 96:
#line 385 "parse.y"
{ yyval.node=mknode_name(yyvsp[0].nameinfo) ; ;
    break;}
case 97:
#line 387 "parse.y"
{ yyval.node=mknode_modified_ctype(yyvsp[-1].ctype); ;
    break;}
case 99:
#line 393 "parse.y"
{  push_type('('); ;
    break;}
case 100:
#line 394 "parse.y"
{  push_type('*'); ;
    break;}
case 101:
#line 395 "parse.y"
{  push_type_int('[',yyvsp[-1].node); ;
    break;}
case 103:
#line 413 "parse.y"
{
                    yyval.ctype=duel_get_target_typedef(yyvsp[0].nameinfo.name);
		    if(yyval.ctype==NULL) {
		       tvalue v;
		       if(duel_get_target_variable(yyvsp[0].nameinfo.name,-1,&v)) yyval.ctype=v.ctype;
		       else  yyerror("not a typedef name"); 
		    }
		;
    break;}
case 104:
#line 423 "parse.y"
{ yyval.ctype = ctype_char;  ;
    break;}
case 105:
#line 424 "parse.y"
{ yyval.ctype = ctype_schar; ;
    break;}
case 106:
#line 425 "parse.y"
{ yyval.ctype = ctype_uchar; ;
    break;}
case 107:
#line 426 "parse.y"
{ yyval.ctype = ctype_int;   ;
    break;}
case 108:
#line 427 "parse.y"
{ yyval.ctype = ctype_uint;  ;
    break;}
case 109:
#line 428 "parse.y"
{ yyval.ctype = ctype_uint;  ;
    break;}
case 110:
#line 429 "parse.y"
{ yyval.ctype = ctype_long;  ;
    break;}
case 111:
#line 430 "parse.y"
{ yyval.ctype = ctype_long;  ;
    break;}
case 112:
#line 431 "parse.y"
{ yyval.ctype = ctype_ulong; ;
    break;}
case 113:
#line 432 "parse.y"
{ yyval.ctype = ctype_ulong; ;
    break;}
case 114:
#line 433 "parse.y"
{ yyval.ctype = ctype_short; ;
    break;}
case 115:
#line 434 "parse.y"
{ yyval.ctype = ctype_short; ;
    break;}
case 116:
#line 435 "parse.y"
{ yyval.ctype = ctype_ushort; ;
    break;}
case 117:
#line 436 "parse.y"
{ yyval.ctype = ctype_ushort; ;
    break;}
case 118:
#line 437 "parse.y"
{ yyval.ctype = ctype_float ; ;
    break;}
case 119:
#line 438 "parse.y"
{ yyval.ctype = ctype_double; ;
    break;}
case 120:
#line 439 "parse.y"
{ yyval.ctype = ctype_void;   ;
    break;}
case 121:
#line 441 "parse.y"
{ yyval.ctype = duel_get_target_struct_tag(yyvsp[0].nameinfo.name);
		     if(yyval.ctype==NULL) yyerror("not a struct tag"); ;
    break;}
case 122:
#line 444 "parse.y"
{ yyval.ctype = duel_get_target_union_tag(yyvsp[0].nameinfo.name);
		     if(yyval.ctype==NULL) yyerror("not a union tag"); ;
    break;}
case 123:
#line 447 "parse.y"
{ yyval.ctype = duel_get_target_enum_tag(yyvsp[0].nameinfo.name);
		     if(yyval.ctype==NULL) yyerror("not an enum tag"); ;
    break;}
}
   /* the action file gets copied in in place of this dollarsign */
#line 465 "bison.simple"

  yyvsp -= yylen;
  yyssp -= yylen;
#ifdef YYLSP_NEEDED
  yylsp -= yylen;
#endif

#if YYDEBUG != 0
  if (yydebug)
    {
      short *ssp1 = yyss - 1;
      fprintf (stderr, "state stack now");
      while (ssp1 != yyssp)
	fprintf (stderr, " %d", *++ssp1);
      fprintf (stderr, "\n");
    }
#endif

  *++yyvsp = yyval;

#ifdef YYLSP_NEEDED
  yylsp++;
  if (yylen == 0)
    {
      yylsp->first_line = yylloc.first_line;
      yylsp->first_column = yylloc.first_column;
      yylsp->last_line = (yylsp-1)->last_line;
      yylsp->last_column = (yylsp-1)->last_column;
      yylsp->text = 0;
    }
  else
    {
      yylsp->last_line = (yylsp+yylen-1)->last_line;
      yylsp->last_column = (yylsp+yylen-1)->last_column;
    }
#endif

  /* Now "shift" the result of the reduction.
     Determine what state that goes to,
     based on the state we popped back to
     and the rule number reduced by.  */

  yyn = yyr1[yyn];

  yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
  if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
    yystate = yytable[yystate];
  else
    yystate = yydefgoto[yyn - YYNTBASE];

  goto yynewstate;

yyerrlab:   /* here on detecting error */

  if (! yyerrstatus)
    /* If not already recovering from an error, report this error.  */
    {
      ++yynerrs;

#ifdef YYERROR_VERBOSE
      yyn = yypact[yystate];

      if (yyn > YYFLAG && yyn < YYLAST)
	{
	  int size = 0;
	  char *msg;
	  int x, count;

	  count = 0;
	  /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
	  for (x = (yyn < 0 ? -yyn : 0);
	       x < (sizeof(yytname) / sizeof(char *)); x++)
	    if (yycheck[x + yyn] == x)
	      size += strlen(yytname[x]) + 15, count++;
	  msg = (char *) malloc(size + 15);
	  if (msg != 0)
	    {
	      strcpy(msg, "parse error");

	      if (count < 5)
		{
		  count = 0;
		  for (x = (yyn < 0 ? -yyn : 0);
		       x < (sizeof(yytname) / sizeof(char *)); x++)
		    if (yycheck[x + yyn] == x)
		      {
			strcat(msg, count == 0 ? ", expecting `" : " or `");
			strcat(msg, yytname[x]);
			strcat(msg, "'");
			count++;
		      }
		}
	      yyerror(msg);
	      free(msg);
	    }
	  else
	    yyerror ("parse error; also virtual memory exceeded");
	}
      else
#endif /* YYERROR_VERBOSE */
	yyerror("parse error");
    }

  goto yyerrlab1;
yyerrlab1:   /* here on error raised explicitly by an action */

  if (yyerrstatus == 3)
    {
      /* if just tried and failed to reuse lookahead token after an error, discard it.  */

      /* return failure if at end of input */
      if (yychar == YYEOF)
	YYABORT;

#if YYDEBUG != 0
      if (yydebug)
	fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
#endif

      yychar = YYEMPTY;
    }

  /* Else will try to reuse lookahead token
     after shifting the error token.  */

  yyerrstatus = 3;		/* Each real token shifted decrements this */

  goto yyerrhandle;

yyerrdefault:  /* current state does not do anything special for the error token. */

#if 0
  /* This is wrong; only states that explicitly want error tokens
     should shift them.  */
  yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
  if (yyn) goto yydefault;
#endif

yyerrpop:   /* pop the current state because it cannot handle the error token */

  if (yyssp == yyss) YYABORT;
  yyvsp--;
  yystate = *--yyssp;
#ifdef YYLSP_NEEDED
  yylsp--;
#endif

#if YYDEBUG != 0
  if (yydebug)
    {
      short *ssp1 = yyss - 1;
      fprintf (stderr, "Error: state stack now");
      while (ssp1 != yyssp)
	fprintf (stderr, " %d", *++ssp1);
      fprintf (stderr, "\n");
    }
#endif

yyerrhandle:

  yyn = yypact[yystate];
  if (yyn == YYFLAG)
    goto yyerrdefault;

  yyn += YYTERROR;
  if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
    goto yyerrdefault;

  yyn = yytable[yyn];
  if (yyn < 0)
    {
      if (yyn == YYFLAG)
	goto yyerrpop;
      yyn = -yyn;
      goto yyreduce;
    }
  else if (yyn == 0)
    goto yyerrpop;

  if (yyn == YYFINAL)
    YYACCEPT;

#if YYDEBUG != 0
  if (yydebug)
    fprintf(stderr, "Shifting error token, ");
#endif

  *++yyvsp = yylval;
#ifdef YYLSP_NEEDED
  *++yylsp = yylloc;
#endif

  yystate = yyn;
  goto yynewstate;
}
#line 452 "parse.y"


static struct stoken {    /* all opcodes we recognize */
  char *opstr ;                 /* op code as a string      */
  int token ;                   /* token to return to yacc  */
  int opcode ;                  /* opcode value associated with the token */
 } tokens[] =  {                /* the special tokens, longer ones 1st! */
    {">>=",T_ASSIGN, OP_RSH},
    {"<<=",T_ASSIGN, OP_LSH},
    {"-->",T_DFS,    OP_DFS},
    {"->>",T_BFS,    OP_BFS},
    {"==?", T_EQQ,   OP_EQQ},
    {"!=?", T_NEQ,   OP_NEQ},
    {"<=?", T_LEQ,   OP_LEQ},
    {">=?", T_GEQ,   OP_GEQ},
    {"&&/", T_ANDL,  OP_AND},
    {"||/", T_ORL,   OP_OR},

    {"<?", T_LSQ,    OP_LSQ},
    {">?", T_GTQ,    OP_GTQ},
    {"#/", T_COUNT,  '#' },
    {"%/", T_COUNT,  '#' }, /* gdb insists to recognize # as start of comma!*/
    {"%%", '#',      '#' }, /* same. so %/ for #/ and %% for #. not doc!*/
    {"+=", T_ASSIGN,  '+'},
    {"-=", T_ASSIGN,  '-'},
    {"*=", T_ASSIGN,  '*'},
    {"/=", T_ASSIGN,  '/'},
    {"%=", T_ASSIGN,  '%'},
    {"|=", T_ASSIGN,  '|'},
    {"&=", T_ASSIGN,  '&'},
    {"^=", T_ASSIGN,  '^'},
    {":=", T_DEFVAR,OP_DEF},
    {"++", T_INC,   OP_INC },
    {"--", T_DEC,   OP_DEC },
    {"->", T_ARROW, OP_ARR },
    {"&&", T_AND,   OP_AND },
    {"||", T_OR,    OP_OR  },
    {"<<", T_LSH,   OP_LSH },
    {">>", T_RSH,   OP_RSH },
    {"==", T_EQ,    OP_EQ  },
    {"!=", T_NE,    OP_NE  },
    {"<=", T_LE,    OP_LE  },
    {">=", T_GE,    OP_GE  },
    {"..", T_TO,    OP_TO  },
    {"=>", T_IMP,   OP_IMP },
    {"[[", T_OSEL,  OP_SEL },
    {"]]", T_CSEL,  OP_SEL },
  };

static struct skeyword {  /* all keywords we recognize */
  char *keyword_str ;           /* keyword as a string       */
  int token ;                   /* token to return to yacc   */
  topcode opcode ;              /* opcode associated w/keyword */
 } keywords[] = {
    {"if",	T_IF	   , OP_IF},
    {"else",	T_ELSE	   },
    {"for",	T_FOR	   , OP_FOR},
    {"while",	T_WHILE	   , OP_WHILE},
    {"sizeof",  T_SIZEOF   , OP_SIZ},
    {"frame",	T_FRAME	   , OP_FRAME},

    {"T", 	T_TYPEDEF_INDICATOR  },
    {"struct",  T_STRUCT   },
    {"union",   T_UNION    },
    {"enum",    T_ENUM     },

    {"unsigned",T_UNSIGNED },
    {"signed",  T_SIGNED   },
    {"short",   T_SHORT    },
    {"long",    T_LONG     },
    {"char",    T_CHAR     },
    {"int",     T_INT      },
    {"double",  T_DOUBLE   },
    {"float",   T_FLOAT    },
    {"void",	T_VOID	   },
   } ;


LFUNC tnode* duel_lex_int(void)    /* parse next token as integer num */
{
   tnode *n ;
   tulong val=0 ;
   char *p=lexptr ;
   bool is_l=0,is_u=0 ;
   int base=10 ;
   int src_pos=lexptr-inputstr ;
   
   if(*p=='0') {                        /* figure out the base */
      p++ ;
      if(*p=='x' || *p=='X') base=16,p++ ;
      else 
      if(isdigit(*p)) base=8 ; /* avoid having '0' as a base 8 (uint) */
   }

   while(isdigit(*p) || base==16 && isxdigit(*p)) {  /* get the value */
      val*=base ;
      if(isupper(*p)) val+= *p-'A'+10 ;
      else if(islower(*p)) val+= *p-'a'+10 ;
      else val+= *p-'0' ;
      p++ ;
   }
   if(*p=='l' || *p=='L') is_l=1,p++ ;          /* yuk. figure 0L etc */
   if(*p=='u' || *p=='U') is_u=1,p++ ;
   if(!is_l && (*p=='l' || *p=='L')) is_l=1,p++ ;
   is_u=is_u || base!=10 ;

   if(is_l && is_u || (long) val < 0 || ((tuint) val != val && is_u)) {
        n=mknode_const(src_pos,ctype_ulong);
        n->cnst.u.rval_ulong=val ;
   }
   else
   if(is_l || (tuint) val != val) {
        n=mknode_const(src_pos,ctype_long) ; 
        n->cnst.u.rval_long=(long) val ; 
   }
   else
   if(is_u || (int) val < 0) {
        n=mknode_const(src_pos,ctype_uint) ; 
        n->cnst.u.rval_uint=(tuint) val ; 
   }
   else {
        n=mknode_const(src_pos,ctype_int) ; 
        n->cnst.u.rval_int=(int) val ; 
   }
   strncpyz(n->cnst.symb_val,lexptr,p-lexptr); /* save the symbolic val*/
   lexptr=p ;
   return n ;
}

LFUNC tnode* duel_lex_float(void)    /* parse next token as float num */
{
  tnode *n=0 ;
  char *p=lexptr ;
  double val ;
  char c,tmpc ;
  bool ok=TRUE;
  int src_pos = lexptr - inputstr ;

  /* this is disgusting.. why isnt there a lib call to recognize floats?! */
  while(isdigit(*p)) p++ ;
  if(*p=='.') p++ ;
  while(isdigit(*p)) p++ ;
  if(*p=='e' || *p=='E') {
     p++ ;
     if(*p=='+' || *p=='-') p++ ;
     if(!isdigit(*p)) ok=FALSE ;     /* force digit (scanf allows 1e-.2 ?!) */
     while(isdigit(*p)) p++ ;
  }
  tmpc= *p ; *p=0 ;
  ok=ok && sscanf(lexptr,"%lf%c",&val,&c)==1 ;
  *p=tmpc ;
  if(!ok) yyerror("Invalid float constant.");

  n=mknode_const(src_pos,ctype_double); 
  n->cnst.u.rval_double=val ; 
  strncpyz(n->cnst.symb_val,lexptr,p-lexptr); /* save the symbolic val*/
  lexptr=p ;
  return(n);
}

/* parse_escaped_char -- parse an escaped char (e.g. '\n'). 
 * lexptr expected to point to text right after the '\'. 
 * return: actual char value (e.g. 012 if 'n' or '012' is found.)
 *         lexptr is advanced after the espaced char.
 */

LFUNC char parse_escaped_char(void)
{
  char retc ;
  switch(lexptr[0]) { 
   /*case 'a': retc='\a' ; break ;	/* some compilers don't support it. */
   case 'b': retc='\b' ; break ;
   case 'f': retc='\f' ; break ;
   case 'n': retc='\n' ; break ;
   case 'r': retc='\r' ; break ;
   case 't': retc='\t' ; break ;
   case 'v': retc='\v' ; break ;
   case 'x': yyerror("hex char const not yet suppported");
   case '0': case '1': case '2': case '3': 
	     retc= lexptr[0] - '0' ;
	     if(lexptr[1]>='0' && lexptr[1]<='7') 
		retc= retc* 010 +  *++lexptr - '0' ;
	     if(lexptr[1]>='0' && lexptr[1]<='7') 
		retc= retc* 010 +  *++lexptr - '0' ;
             break ;
   default:  retc=lexptr[0] ;     /* default also takes care of '\'' '\\' */
  }
  lexptr++ ;
  return retc ;
}

/* FUNC yylex -- return the next token to yacc. 
 * GLOBALS: lexptr point to the string we are parsing next. it is updated.
 */

LFUNC int yylex (void)
{
  int c,i,src_pos ;
  char *p ;

  for(c= *lexptr; c==' ' || c=='\t' || c=='\n' ; c= *++lexptr); /* skip blank*/

  src_pos = lexptr - inputstr ;	/* current char being parsed */
  yylval.opinfo.src_pos = src_pos ;

  if(*lexptr=='\0' || strncmp(lexptr,"|>",2)==0) return 0 ; /* end of expr */

  for (i = 0;  i < sizeof(tokens)/sizeof(struct stoken) ; i++) { 
    int l=strlen(tokens[i].opstr) ;             /* check next token vs table */
    if(strncmp(lexptr,tokens[i].opstr,l)==0) {
	lexptr+=l ;
	yylval.opinfo.opcode = tokens[i].opcode;
	return tokens[i].token ;
    }
  }

  switch (c = *lexptr) {
    case '\'':                /* char constant, but stored as int (ansi-c) */
      p=lexptr++ ;
      c = *lexptr++ ;
      if (c == '\\') c=parse_escaped_char();
      if( *lexptr++ != '\'') yyerror("Invalid character constant.");
      yylval.node=mknode_const(src_pos,ctype_int) ;
      yylval.node->cnst.u.rval_int=c ;
      strncpyz(yylval.node->cnst.symb_val,p,lexptr-p); /*save the symbol. val*/
      return T_CONST ;
    
    case '0':                           /* chk hex  */
        if(lexptr[1]=='x' || lexptr[1]=='X') {
           yylval.node=duel_lex_int(); 
           return T_CONST ;
        }
        /* fall thru for other numbers */
    case '1': case '2': case '3':      /* decimal or floating point number */
    case '4': case '5': case '6': case '7': case '8': case '9':
          for(p=lexptr ; *p>='0' && *p<='9' ; p++ ) ;  /*find next non digit*/
          if(*p=='.' && p[1]!='.' || *p=='e' || *p=='E') 
               yylval.node=duel_lex_float();
          else yylval.node=duel_lex_int();
          return T_CONST ;

    case '(':  case ')':
    case '<':  case '>':
    case '[':  case ']':
    case '{':  case '}':
    case '+':  case '-':  case '*':  case '/':  case '%':
    case '|':  case '&':  case '^':  case '~':  case '!':
    case ',':  case '?':  case ':':  case '=':  
    case '.':  case '@':  case '$':  case '#':  case '`': case '\\': 
      lexptr++;
      yylval.opinfo.opcode=c ;
      return c;
    case ';': { /* hack, ignore ';' before '}' and else. for C compatability*/
	        char *save_lexptr= ++lexptr ;
		int tok=yylex()	;	/* hack, call myself for next token */
		if(tok=='}' || tok==T_ELSE) {
		    duel_printf("warning: useless ';' ignored\n");
		    return tok ;
		}
		/* else restore position and return the ';' */
		lexptr=save_lexptr ;
		yylval.opinfo.opcode=';' ;
		yylval.opinfo.src_pos = src_pos ;
		return ';';
    }
    case '"': {
          char s[512] ;
	  size_t len=0 ;
	  ttarget_ptr dptr ;
	  tnode *n ;

	  p=lexptr++ ; 
	  while((c= *lexptr++)!='"') {
	       if (c == '\\') c=parse_escaped_char();
	       s[len++]=c ;
	  }
	  s[len++]=0 ;
	  dptr=duel_alloc_target_space(len);
	  duel_put_target_bytes(dptr,s,len);
	  
	  n=mknode_const(src_pos,ctype_charptr); 
	  n->cnst.u.rval_ptr=dptr ; 
	  len=lexptr-p ;
	  if(len>60) len=60 ;
	  strncpyz(n->cnst.symb_val,p,len); /* save the symbolic val*/
          yylval.node=n ;
          return T_CONST ;
      }
    }

  if(c != '_' && !isalpha(c))
     yyerror ("Invalid character in expression.");

  p=lexptr ;
  do { c= *++lexptr ; } while(c=='_' || isalnum(c));
  
  for (i = 0;  i < sizeof(keywords)/sizeof(struct skeyword) ; i++) { 
    int l=strlen(keywords[i].keyword_str) ;   /* check next token vs keywords*/
    if(l==lexptr-p && strncmp(p,keywords[i].keyword_str,l)==0) {
        yylval.opinfo.opcode=keywords[i].opcode ;
	return keywords[i].token ;
    }
  }

  /* the symbol/name found is not a reserved word, so return it as a T_SYM
   */
    
  i=lexptr-p ;          /* length of string found (symbol/name) */
  yylval.nameinfo.src_pos=src_pos ;
  yylval.nameinfo.name=duel_malloc(i+1);
  strncpyz(yylval.nameinfo.name,p,i);
  return T_SYM;
}

LPROC yyerror(char *msg)
{
  int i,n=lexptr-inputstr ;
  duel_printf("%s\n",inputstr);
  for(i=0 ; i<n ; i++) duel_printf("-");
  duel_printf("^ %s\n",msg);
  duel_abort();		/* terminate parsing. some callers depend on this*/
}

/*************************************************************************/
/* utility functions used to parse the expression and build it as a tree */
/*************************************************************************/

/* mknode_op -- make a tree node of type op with given opcode and kids
 */

LFUNC tnode* mknode_op(top_kind op_kind,topinfo opinfo,
                       tnode *k1,tnode *k2,tnode *k3,tnode *k4)
{
   tnode *n ;
   duel_assert(opinfo.opcode>' ');
   n=(tnode *) duel_malloc(sizeof(tnode));
   duel_bzero((char*) n,sizeof(tnode));
   n->node_kind=NK_OP ;
   n->op_kind=op_kind ;
   n->op=opinfo.opcode ;
   n->src_pos=opinfo.src_pos ;
   n->kids[0]=k1 ;  n->kids[1]=k2 ;  n->kids[2]=k3 ; n->kids[3]=k4 ;
   return n ;
}


 /* mknode_const -- make a constant node for the given type. 
  */

LFUNC tnode* mknode_const(int src_pos,tctype *ctype)
{
   tnode *n ;
   n=(tnode *) duel_malloc(sizeof(tnode));
   duel_bzero((char*) n,sizeof(tnode));
   n->node_kind=NK_CONST ;
   n->src_pos=src_pos ;
   n->cnst.val_kind=VK_RVALUE ;
   n->cnst.ctype=ctype ;
   return n ;
}

 /* mknode_ctype -- make a node of the given c-type. 
  */

LFUNC tnode* mknode_ctype(tctype *ctype)
{
   tnode *n ;
   n=(tnode *) duel_malloc(sizeof(tnode));
   duel_bzero((char*) n,sizeof(tnode));
   n->node_kind=NK_CTYPE ;
   n->ctype=ctype ;
   return n ;
}

 /* mknode_name -- make a node of the given name/symbol.
  * input is pointer to the saved name (on heap)
  */

LFUNC tnode* mknode_name(tnameinfo nameinfo)
{
   tnode *n ;
   n=(tnode *) duel_malloc(sizeof(tnode));
   duel_bzero((char*) n,sizeof(tnode));
   n->node_kind=NK_NAME ;
   n->name=nameinfo.name ;
   n->src_pos=nameinfo.src_pos ;
   return n ;
}

/* In order to parse C types, which are 'reversed' in the parser, a stack
 * is used to push abstract declarators, e.g. in (*)() we first push a func
 * indicator '(' and then push a pointer indicator '*'. for arrays we push
 * a '[' and the array size. 
 * This stack is popped and a ctype is constructed at the end of the 
 * abstract type parsing. The following functions implement the stack
 */

typedef struct stype_desc {  /* stack of type descriptors is made of these */
        char desc ; 
        int size ;
        struct stype_desc *next ;       /* next on stack */
      } ttype_desc ;

ttype_desc *top = 0 ;


LPROC push_type(char desc)     /* put desc on the types stack */
{
    ttype_desc *p = (ttype_desc* ) duel_malloc(sizeof(ttype_desc));
    p->desc=desc ;
    p->size=0 ;
    p->next=top ;
    top=p ;
}

/* push_type_int -- same as push_type but also set the size parameter, which
 *                  is given as a constant node (which is expected to be int)
 */

LPROC push_type_int(char desc,tnode *n)  
{
   duel_assert(n->node_kind==NK_CONST);
   if(n->cnst.ctype != ctype_int || 
      n->cnst.u.rval_int <=0 ) duel_gen_error("Illegal array size",0);
   push_type(desc);
   top->size=n->cnst.u.rval_int ;
}

LFUNC bool pop_type(char *desc,int *size)  /* pop item from stack. */
{
   ttype_desc *p = top ;
   if(p==0) return FALSE ;
   *desc=p->desc ;
   *size=p->size ;
   top=p->next ;
   duel_free(p) ;
   return TRUE ;
}


/* abstract type-modifiers were pushed on a stack. Retrieve
 * them (reversed) creating type nodes as we go 
 * input: base type (e.g. 'long'). 
 * returns: node of the modified type. 
 * modification is based on the stack of things pushed while parsing.
 */

LFUNC tnode* mknode_modified_ctype(tctype *base)
{  
    int size;
    char tdesc ;           /* descriptor of abs decl eg '*' */
    tctype *t=base ;       /* type under construction       */
    
    while(pop_type(&tdesc,&size))    /* pop next abs decl    */
	switch (tdesc) {
	  case '*':  t=duel_mkctype_ptr(t);         break ;
	  case '(':  t=duel_mkctype_func(t);        break ;
	  case '[':  t=duel_mkctype_array(t,size);  break ;
	}	
    return mknode_ctype(t) ;
}

/* entry point for parsing. the given expression is parsed into the given
 * node as root.
 */

FUNC tnode* duel_parse(char *s)
{
  lexptr=inputstr=s ;
  top=0 ; 				/* reset the types stack */
  if(duel_yyparse()) root=NULL ;
  return root ;
}
