/* A Bison parser, made from parser.y
   by GNU bison 1.35.  */

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

# define	CLASS	257
# define	STRUCT	258
# define	UNION	259
# define	TEMPLATE	260
# define	PUBLIC	261
# define	PRIVATE	262
# define	PROTECTED	263
# define	VIRTUAL	264
# define	IF	265
# define	THEN	266
# define	ELSE	267
# define	STRING	268
# define	ENUM	269
# define	NEW	270
# define	DELETE	271
# define	NUM	272
# define	PLUSPLUS	273
# define	MINUSMINUS	274
# define	EQUALSEQUALS	275
# define	PLUSEQUALS	276
# define	MINUSEQUALS	277
# define	STAREQUALS	278
# define	SLASHEQUALS	279
# define	LEFTEQUALS	280
# define	RIGHTEQUALS	281
# define	LEFTLEFT	282
# define	RIGHTRIGHT	283
# define	ANDAND	284
# define	OROR	285
# define	OREQUALS	286
# define	ANDEQUALS	287
# define	COLONCOLON	288
# define	ELLIPSIS	289
# define	CTEXT	290
# define	TILDE	291
# define	IDENTIFIER	292
# define	INT	293
# define	FLOAT	294
# define	SHORT	295
# define	LONG	296
# define	DOUBLE	297
# define	VOID	298
# define	CHAR	299
# define	BOOL	300
# define	COMMENT	301
# define	CPP_DIRECTIVE	302
# define	CONST	303
# define	VOLATILE	304
# define	REGISTER	305
# define	OPERATOR	306
# define	UNSIGNED	307
# define	FRIEND	308
# define	STATIC	309
# define	SIZEOF	310
# define	TYPEDEF	311
# define	INLINE	312
# define	EXTERN	313
# define	RETURN	314
# define	ARROW	315
# define	NOTEQUALS	316

#line 1 "parser.y"

/*
 * This file is part of cxxwrap
 * Copyright (c) 1998, 1999 David Deaven (deaven@execpc.com)
 *
 *   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 2 of the License, 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.
 *
 * $Author: deaven $
 * $Id: parser.cxx,v 1.31 2004/01/03 22:15:10 deaven Exp $
 */

#include <ctype.h>
#include "Class.h"
#include "CType.h"
#include "PrimitiveCType.h"
#include "ObjectCType.h"
#include "FunctionCType.h"
#include "CreateCType.h"
#include "ArrayCType.h"
#include "VoidCType.h"
#include "EnumCType.h"

#define LEXER_BUFLEN 256
class Lexer {
public:
    enum {SRC_FILE, SRC_STRING} type;
    int last() { return lastc; }
    int get();
    void unget(int c);
    int getNumber(double *d);
    int matchKeyword(char* s);
    union {
      FILE *f;
      char *s;
    } source;
    int ch;		/* chars read */
    int line;	/* lines read */
    int c, lastc;	/* this character, last read character */
    int eof;
    char resultbuf[LEXER_BUFLEN];
    int ungetp;
    int ungetbuf[LEXER_BUFLEN];
};

#define MAX_CLASS_NEST 16

struct locals {
    locals() { }
    Lexer lex;
    int public_scope;
    int saved_public_scope[MAX_CLASS_NEST];
    int class_nest;
    int serial;
    int trace;
    int nerror;
    int nclassdef;
    int eatc;
    int copy_enum;
    const char* source_file;
    TypeMap typedefs;
} local;

#define YYMAXDEPTH 1000
#define yywrap() 1
#define yylex() myyylex()
#define yyerror(STR) myyyerror(STR)
static const char* msg(const char *s);
static void myyyerror(const char *s);
static int myyylex(void);
int yyparse(void);

static void global_reset();
static void push_scope(int);
static void pop_scope();
static int check_new_classdef(Class* c);


#line 91 "parser.y"
#ifndef YYSTYPE
typedef union {
    String* str;
    CType* type;
    ObjectCType* objtype;
    Class* clazz;
    Number* number;
    Method* method;
    Arg* arg;
    int immediate;
    int* immediates;
    int expr;
} yystype;
# define YYSTYPE yystype
# define YYSTYPE_IS_TRIVIAL 1
#endif
#ifndef YYDEBUG
# define YYDEBUG 0
#endif



#define	YYFINAL		433
#define	YYFLAG		-32768
#define	YYNTBASE	86

/* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */
#define YYTRANSLATE(x) ((unsigned)(x) <= 316 ? yytranslate[x] : 169)

/* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */
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,    83,     2,     2,     2,    73,    67,     2,
      74,    82,    71,    69,    79,    70,    85,    72,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,    63,    76,
      77,    61,    78,    62,     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,    75,     2,    84,    66,     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,    80,    65,    81,     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,     2,     1,     3,     4,     5,
       6,     7,     8,     9,    10,    11,    12,    13,    14,    15,
      16,    17,    18,    19,    20,    21,    22,    23,    24,    25,
      26,    27,    28,    29,    30,    31,    32,    33,    34,    35,
      36,    37,    38,    39,    40,    41,    42,    43,    44,    45,
      46,    47,    48,    49,    50,    51,    52,    53,    54,    55,
      56,    57,    58,    59,    60,    64,    68
};

#if YYDEBUG
static const short yyprhs[] =
{
       0,     0,     1,     4,     6,     8,    12,    14,    16,    24,
      31,    34,    38,    42,    46,    48,    52,    55,    57,    58,
      66,    67,    76,    77,    84,    85,    92,    93,    96,    98,
     102,   105,   111,   114,   117,   119,   122,   124,   127,   131,
     133,   135,   137,   141,   146,   148,   149,   152,   153,   155,
     158,   162,   171,   173,   177,   182,   187,   192,   195,   200,
     206,   210,   213,   219,   224,   226,   230,   233,   234,   235,
     239,   242,   246,   248,   251,   255,   262,   271,   280,   282,
     284,   286,   288,   290,   292,   294,   296,   298,   300,   302,
     304,   306,   308,   310,   312,   314,   316,   318,   320,   322,
     324,   326,   328,   330,   332,   334,   336,   338,   340,   342,
     344,   346,   349,   351,   353,   356,   359,   361,   364,   366,
     368,   369,   372,   374,   378,   380,   383,   384,   389,   393,
     394,   396,   397,   400,   402,   406,   411,   412,   414,   418,
     421,   425,   429,   431,   433,   439,   447,   456,   457,   460,
     462,   466,   468,   471,   474,   478,   480,   483,   485,   487,
     489,   491,   493,   495,   498,   501,   503,   506,   510,   512,
     515,   517,   519,   521,   523,   525,   527,   529,   532,   535,
     540,   542,   544,   546,   548,   551,   554,   555,   557,   558,
     560,   562,   564,   566,   568,   569,   571,   573,   577,   578,
     580,   582,   584,   586,   592,   594,   598,   600,   604,   606,
     610,   612,   616,   618,   622,   624,   628,   632,   634,   638,
     642,   646,   650,   652,   656,   660,   662,   666,   670,   672,
     676,   680,   684,   686,   691,   693,   696,   699,   702,   705,
     710,   712,   715,   720,   724,   728,   731,   734,   736,   739,
     741,   743,   747,   749,   753,   754
};
static const short yyrhs[] =
{
      -1,    86,    87,     0,    88,     0,   107,     0,   104,   132,
      76,     0,   113,     0,     1,     0,     6,    77,    89,    78,
       3,   120,    76,     0,     6,    77,    89,    78,    91,    76,
       0,    91,    76,     0,     4,   122,    76,     0,     5,   122,
      76,     0,     3,   122,    76,     0,    90,     0,    90,    79,
      89,     0,     3,   120,     0,   120,     0,     0,     3,   122,
      96,    92,    80,    99,    81,     0,     0,     3,   120,   122,
      96,    93,    80,    99,    81,     0,     0,     4,   103,    94,
      80,    99,    81,     0,     0,     5,   103,    95,    80,    99,
      81,     0,     0,    63,    97,     0,    98,     0,    97,    79,
      98,     0,     7,   122,     0,     7,   122,    77,   133,    78,
       0,     8,   122,     0,     9,   122,     0,   100,     0,    99,
     100,     0,   101,     0,   146,    63,     0,   104,   102,    76,
       0,   113,     0,   107,     0,   106,     0,    91,   103,    76,
       0,    57,    91,   103,    76,     0,     1,     0,     0,    63,
      18,     0,     0,   120,     0,   134,   105,     0,   134,   120,
     138,     0,   134,    74,    71,   120,    82,    74,   115,    82,
       0,   120,     0,   120,    79,   105,     0,    54,     3,   122,
      76,     0,    54,     4,   122,    76,     0,    54,     5,   122,
      76,     0,    54,   113,     0,    57,   134,   120,    76,     0,
      57,   134,   120,   138,    76,     0,    57,   131,    76,     0,
     108,    76,     0,    15,   122,    80,   109,    81,     0,    15,
      80,   109,    81,     0,   110,     0,   109,    79,   110,     0,
     120,   111,     0,     0,     0,    61,   112,    36,     0,    37,
     114,     0,    10,    37,   114,     0,   114,     0,   134,   114,
       0,    10,   134,   114,     0,   122,    74,   115,    82,   125,
     123,     0,   121,    52,   116,    74,   115,    82,   125,   123,
       0,   121,    52,   134,    74,   115,    82,   125,   123,     0,
     129,     0,   117,     0,   118,     0,   119,     0,    19,     0,
      20,     0,    28,     0,    29,     0,    30,     0,    31,     0,
      21,     0,    68,     0,    26,     0,    27,     0,    64,     0,
      16,     0,    17,     0,   139,     0,    67,     0,    71,     0,
      69,     0,    70,     0,    37,     0,    83,     0,    72,     0,
      73,     0,    65,     0,    77,     0,    78,     0,    66,     0,
      61,     0,    24,     0,    25,     0,    73,    61,     0,    22,
       0,    23,     0,    28,    61,     0,    29,    61,     0,    33,
       0,    66,    61,     0,    32,     0,    38,     0,     0,   120,
      34,     0,   120,     0,   120,    34,   122,     0,    76,     0,
     123,    76,     0,     0,   126,    80,   124,    36,     0,    61,
      18,    76,     0,     0,    49,     0,     0,    63,   127,     0,
     128,     0,   127,    79,   128,     0,   134,    74,   149,    82,
       0,     0,   130,     0,   130,    79,   129,     0,   134,   132,
       0,   134,   120,   132,     0,   134,   103,   138,     0,   131,
       0,    35,     0,   134,   120,    74,   115,    82,     0,   134,
      74,   120,    82,    74,   115,    82,     0,   134,    74,    71,
     120,    82,    74,   115,    82,     0,     0,    61,   152,     0,
     134,     0,   134,    79,   133,     0,   137,     0,   135,   137,
       0,   137,   135,     0,   135,   137,   135,     0,   136,     0,
     135,   136,     0,    49,     0,    55,     0,    50,     0,    51,
       0,    58,     0,   140,     0,     3,   137,     0,   137,   142,
       0,   139,     0,   138,   139,     0,    75,   147,    84,     0,
     143,     0,    53,   143,     0,    40,     0,    43,     0,    46,
       0,    44,     0,   141,     0,   108,     0,   122,     0,     4,
     122,     0,     5,   122,     0,   122,    77,   133,    78,     0,
      71,     0,    67,     0,    45,     0,    39,     0,    41,   144,
       0,    42,   145,     0,     0,    39,     0,     0,    39,     0,
      42,     0,     7,     0,     9,     0,     8,     0,     0,   152,
       0,   152,     0,   148,    79,   152,     0,     0,   148,     0,
     151,     0,   152,     0,   153,     0,   153,    62,   150,    63,
     152,     0,   154,     0,   153,    31,   154,     0,   155,     0,
     154,    30,   155,     0,   156,     0,   155,    65,   156,     0,
     157,     0,   156,    66,   157,     0,   158,     0,   157,    67,
     158,     0,   159,     0,   158,    21,   159,     0,   158,    68,
     159,     0,   160,     0,   159,    77,   160,     0,   159,    78,
     160,     0,   159,    26,   160,     0,   159,    27,   160,     0,
     161,     0,   160,    28,   161,     0,   160,    29,   161,     0,
     162,     0,   161,    69,   162,     0,   161,    70,   162,     0,
     163,     0,   162,    71,   163,     0,   162,    72,   163,     0,
     162,    73,   163,     0,   164,     0,    74,   134,    82,   163,
       0,   165,     0,    19,   164,     0,    20,   164,     0,   117,
     163,     0,    56,   164,     0,    56,    74,   134,    82,     0,
     166,     0,   165,   139,     0,   165,    74,   168,    82,     0,
     165,    85,   120,     0,   165,    64,   120,     0,   165,    19,
       0,   165,    20,     0,   122,     0,    16,   122,     0,    18,
       0,    14,     0,    74,   152,    82,     0,   151,     0,   167,
      79,   151,     0,     0,   167,     0
};

#endif

#if YYDEBUG
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const short yyrline[] =
{
       0,   198,   198,   200,   202,   203,   204,   205,   208,   210,
     220,   228,   229,   230,   233,   238,   245,   251,   258,   258,
     274,   274,   290,   290,   305,   305,   322,   324,   327,   329,
     336,   341,   348,   349,   352,   354,   367,   387,   389,   399,
     406,   433,   434,   435,   436,   439,   441,   444,   446,   449,
     466,   491,   497,   502,   510,   512,   513,   514,   528,   536,
     562,   569,   572,   577,   585,   587,   600,   611,   616,   616,
     622,   632,   641,   650,   659,   671,   678,   685,   694,   708,
     715,   721,   722,   722,   723,   723,   724,   724,   725,   725,
     726,   726,   727,   728,   728,   729,   732,   734,   735,   736,
     737,   738,   741,   743,   744,   745,   746,   747,   750,   752,
     753,   754,   755,   756,   757,   758,   759,   760,   761,   764,
     766,   768,   771,   773,   782,   784,   785,   785,   786,   789,
     789,   791,   791,   793,   793,   795,   797,   799,   800,   811,
     822,   830,   859,   863,   870,   877,   883,   891,   896,   904,
     909,   916,   918,   924,   932,   943,   945,   953,   955,   956,
     957,   958,   961,   963,   964,   972,   984,   991,   995,   997,
    1003,  1004,  1005,  1006,  1007,  1008,  1011,  1017,  1022,  1027,
    1036,  1038,  1041,  1046,  1050,  1054,  1060,  1060,  1061,  1061,
    1061,  1063,  1065,  1066,  1069,  1071,  1073,  1075,  1078,  1078,
    1080,  1082,  1084,  1086,  1089,  1091,  1094,  1096,  1099,  1101,
    1104,  1106,  1109,  1111,  1114,  1116,  1117,  1120,  1122,  1123,
    1124,  1125,  1128,  1130,  1131,  1134,  1136,  1137,  1141,  1143,
    1144,  1145,  1148,  1150,  1153,  1155,  1156,  1157,  1188,  1189,
    1192,  1194,  1195,  1196,  1197,  1198,  1199,  1202,  1218,  1219,
    1220,  1227,  1230,  1232,  1235,  1237
};
#endif


#if (YYDEBUG) || defined YYERROR_VERBOSE

/* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */
static const char *const yytname[] =
{
  "$", "error", "$undefined.", "CLASS", "STRUCT", "UNION", "TEMPLATE", 
  "PUBLIC", "PRIVATE", "PROTECTED", "VIRTUAL", "IF", "THEN", "ELSE", 
  "STRING", "ENUM", "NEW", "DELETE", "NUM", "PLUSPLUS", "MINUSMINUS", 
  "EQUALSEQUALS", "PLUSEQUALS", "MINUSEQUALS", "STAREQUALS", 
  "SLASHEQUALS", "LEFTEQUALS", "RIGHTEQUALS", "LEFTLEFT", "RIGHTRIGHT", 
  "ANDAND", "OROR", "OREQUALS", "ANDEQUALS", "COLONCOLON", "ELLIPSIS", 
  "CTEXT", "TILDE", "IDENTIFIER", "INT", "FLOAT", "SHORT", "LONG", 
  "DOUBLE", "VOID", "CHAR", "BOOL", "COMMENT", "CPP_DIRECTIVE", "CONST", 
  "VOLATILE", "REGISTER", "OPERATOR", "UNSIGNED", "FRIEND", "STATIC", 
  "SIZEOF", "TYPEDEF", "INLINE", "EXTERN", "RETURN", "'='", "'?'", "':'", 
  "ARROW", "'|'", "'^'", "'&'", "NOTEQUALS", "'+'", "'-'", "'*'", "'/'", 
  "'%'", "'('", "'['", "';'", "'<'", "'>'", "','", "'{'", "'}'", "')'", 
  "'!'", "']'", "'.'", "module", "file_scope_item", "class_def", 
  "template_par_list", "template_par", "class_decl", "@1", "@2", "@3", 
  "@4", "parent_spec", "parent_list", "parent_decl", "class_def_body", 
  "scoped_class_def_item", "class_def_item", "opt_bitfield", "opt_id", 
  "var_decl", "id_list", "friend_decl", "type_decl", "enum_decl", 
  "enum_item_list", "enum_item", "opt_var_assign_text", "@5", 
  "method_decl", "func", "culled_arg_list", "cpp_operator", 
  "unary_operator", "binary_operator", "assignment_operator", "id", 
  "opt_scoped_id", "scoped_id", "func_end", "@6", "func_mods", 
  "opt_init_list", "init_list", "init_item", "arg_list", "arg", 
  "func_arg", "opt_var_assign", "type_list", "type", "type_mods", 
  "type_mod", "type_red1", "array_type_indirections", 
  "array_type_indirection", "type_primitive", "object_type_primitive", 
  "type_indirection", "integral_type_primitive", "optional_int", 
  "optional_long", "scope_type", "opt_constant_expr", 
  "constant_expr_list", "opt_constant_expr_list", "c_expr", 
  "assignment_expr", "constant_expr", "logic_or_expr", "logic_and_expr", 
  "inclusive_or_expr", "exclusive_or_expr", "and_expr", "equality_expr", 
  "relational_expr", "shift_expr", "additive_expr", "multiplicative_expr", 
  "cast_expr", "unary_expr", "postfix_expr", "primary_expr", 
  "c_expr_list", "opt_c_expr_list", 0
};
#endif

/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
static const short yyr1[] =
{
       0,    86,    86,    87,    87,    87,    87,    87,    88,    88,
      88,    88,    88,    88,    89,    89,    90,    90,    92,    91,
      93,    91,    94,    91,    95,    91,    96,    96,    97,    97,
      98,    98,    98,    98,    99,    99,   100,   101,   101,   101,
     101,   101,   101,   101,   101,   102,   102,   103,   103,   104,
     104,   104,   105,   105,   106,   106,   106,   106,   107,   107,
     107,   107,   108,   108,   109,   109,   110,   111,   112,   111,
     113,   113,   113,   113,   113,   114,   114,   114,   115,   116,
     116,   116,   116,   116,   116,   116,   116,   116,   116,   116,
     116,   116,   116,   116,   116,   116,   117,   117,   117,   117,
     117,   117,   118,   118,   118,   118,   118,   118,   119,   119,
     119,   119,   119,   119,   119,   119,   119,   119,   119,   120,
     121,   121,   122,   122,   123,   123,   124,   123,   123,   125,
     125,   126,   126,   127,   127,   128,   129,   129,   129,   130,
     130,   130,   130,   130,   131,   131,   131,   132,   132,   133,
     133,   134,   134,   134,   134,   135,   135,   136,   136,   136,
     136,   136,   137,   137,   137,   138,   138,   139,   140,   140,
     140,   140,   140,   140,   140,   140,   141,   141,   141,   141,
     142,   142,   143,   143,   143,   143,   144,   144,   145,   145,
     145,   146,   146,   146,   147,   147,   148,   148,   149,   149,
     150,   151,   152,   152,   153,   153,   154,   154,   155,   155,
     156,   156,   157,   157,   158,   158,   158,   159,   159,   159,
     159,   159,   160,   160,   160,   161,   161,   161,   162,   162,
     162,   162,   163,   163,   164,   164,   164,   164,   164,   164,
     165,   165,   165,   165,   165,   165,   165,   166,   166,   166,
     166,   166,   167,   167,   168,   168
};

/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
static const short yyr2[] =
{
       0,     0,     2,     1,     1,     3,     1,     1,     7,     6,
       2,     3,     3,     3,     1,     3,     2,     1,     0,     7,
       0,     8,     0,     6,     0,     6,     0,     2,     1,     3,
       2,     5,     2,     2,     1,     2,     1,     2,     3,     1,
       1,     1,     3,     4,     1,     0,     2,     0,     1,     2,
       3,     8,     1,     3,     4,     4,     4,     2,     4,     5,
       3,     2,     5,     4,     1,     3,     2,     0,     0,     3,
       2,     3,     1,     2,     3,     6,     8,     8,     1,     1,
       1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
       1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
       1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
       1,     2,     1,     1,     2,     2,     1,     2,     1,     1,
       0,     2,     1,     3,     1,     2,     0,     4,     3,     0,
       1,     0,     2,     1,     3,     4,     0,     1,     3,     2,
       3,     3,     1,     1,     5,     7,     8,     0,     2,     1,
       3,     1,     2,     2,     3,     1,     2,     1,     1,     1,
       1,     1,     1,     2,     2,     1,     2,     3,     1,     2,
       1,     1,     1,     1,     1,     1,     1,     2,     2,     4,
       1,     1,     1,     1,     2,     2,     0,     1,     0,     1,
       1,     1,     1,     1,     0,     1,     1,     3,     0,     1,
       1,     1,     1,     5,     1,     3,     1,     3,     1,     3,
       1,     3,     1,     3,     1,     3,     3,     1,     3,     3,
       3,     3,     1,     3,     3,     1,     3,     3,     1,     3,
       3,     3,     1,     4,     1,     2,     2,     2,     2,     4,
       1,     2,     4,     3,     3,     2,     2,     1,     2,     1,
       1,     3,     1,     3,     0,     1
};

/* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
   doesn't specify something else to do.  Zero means the default is an
   error. */
static const short yydefact[] =
{
       1,     0,     7,     0,    47,    47,     0,     0,     0,   120,
     119,   183,   170,   186,   188,   171,   173,   182,   172,   157,
     159,   160,     0,   158,     0,   161,     2,     3,     0,   147,
       4,   175,     6,    72,   122,     0,   176,   120,     0,   155,
     151,   162,   174,   168,     0,     0,     0,   175,   122,   176,
     163,    22,   122,   177,    24,   178,     0,   120,   122,   176,
     120,     0,     0,    70,     0,   187,   184,   189,   190,   185,
     169,     0,     0,    10,     0,     0,    61,   121,     0,   136,
       0,     0,    49,    73,    52,   156,   152,   181,   180,   153,
     164,   177,   178,     0,    26,     0,    13,    18,     0,    11,
       0,    12,     0,     0,    14,    17,    71,    74,     0,    64,
      67,     0,    60,     0,     0,   250,     0,   249,     0,     0,
     100,     0,    96,    98,    99,    97,     0,   101,     0,   247,
     148,   202,   204,   206,   208,   210,   212,   214,   217,   222,
     225,   228,   232,   234,   240,     5,   123,    93,    94,    82,
      83,    88,   112,   113,   109,   110,    90,    91,    84,    85,
      86,    87,   118,   116,   108,    92,   104,   107,    89,   102,
     103,   194,   105,   106,     0,    79,    80,    81,     0,    95,
     143,     0,    78,   137,   142,   147,     0,   149,     0,     0,
      50,   165,   154,    20,     0,     0,     0,    27,    28,     0,
       0,     0,    16,     0,     0,     0,    63,    68,    66,     0,
       0,     0,   136,    58,     0,   248,     0,   235,   236,     0,
     238,   247,     0,     0,   237,     0,     0,     0,     0,     0,
       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
       0,     0,     0,     0,   245,   246,     0,   254,     0,   241,
     114,   115,   117,   111,     0,   195,   136,   136,   129,   136,
       0,   147,   139,   179,     0,     0,    53,    52,   166,     0,
      30,    32,    33,     0,     0,    44,     0,    47,    47,   191,
     193,   192,   120,     0,    47,     0,    34,    36,    45,    41,
      40,    39,     0,     0,     0,    47,    47,     0,    15,    65,
       0,    62,     0,     0,     0,    59,     0,     0,   251,   205,
       0,   200,   201,   207,   209,   211,   213,   215,   216,   220,
     221,   218,   219,   223,   224,   226,   227,   229,   230,   231,
     244,   252,   255,     0,   243,   167,     0,     0,   130,   131,
     138,   141,   140,   150,     0,     0,     0,    29,     0,   176,
       0,     0,     0,    57,   120,    47,     0,    48,    23,    35,
       0,     0,    37,    25,   122,    26,     9,    69,     0,   136,
     144,   239,   233,     0,     0,   242,   129,   129,     0,     0,
     124,    75,     0,   136,     0,     0,    19,   176,   177,   178,
       0,    42,    46,    38,     8,   136,     0,   203,   253,   131,
     131,     0,   132,   133,     0,   125,   126,     0,    21,    31,
      54,    55,    56,    43,     0,   145,    76,    77,   128,     0,
     198,     0,    51,   146,   134,   199,     0,   196,   127,     0,
     135,   197,     0,     0
};

static const short yydefgoto[] =
{
       1,    26,    27,   103,   104,   284,   199,   269,    98,   100,
      97,   197,   198,   285,   286,   287,   361,    51,   288,    82,
     289,   290,    47,   108,   109,   208,   300,   291,    33,   181,
     174,   128,   176,   177,    58,    35,   129,   381,   421,   339,
     382,   402,   403,   182,   183,   184,    75,   186,    37,    38,
      39,    40,   190,   191,    41,    42,    90,    43,    66,    69,
     292,   254,   425,   426,   310,   311,   223,   131,   132,   133,
     134,   135,   136,   137,   138,   139,   140,   141,   142,   143,
     144,   332,   333
};

static const short yypact[] =
{
  -32768,   898,-32768,   201,    10,    10,   -47,  1068,    30,    10,
  -32768,-32768,-32768,    18,   115,-32768,-32768,-32768,-32768,-32768,
  -32768,-32768,    90,-32768,  1145,-32768,-32768,-32768,    -6,    72,
  -32768,    38,-32768,-32768,    55,    89,    82,    22,  1145,-32768,
     111,-32768,-32768,-32768,   201,    10,    10,-32768,     1,    41,
      59,-32768,    19,    73,-32768,    95,    28,    10,   142,   113,
      10,    10,   103,-32768,   138,-32768,-32768,-32768,-32768,-32768,
  -32768,   139,    27,-32768,    53,   141,-32768,    10,   491,  1089,
    1145,   151,-32768,-32768,    69,-32768,   111,-32768,-32768,   180,
  -32768,-32768,-32768,    10,   163,   189,-32768,-32768,   156,-32768,
     173,-32768,    10,    15,   178,-32768,-32768,-32768,    66,-32768,
     205,    10,-32768,    26,   133,-32768,    10,-32768,   154,   154,
  -32768,   851,-32768,-32768,-32768,-32768,   618,-32768,    53,-32768,
  -32768,    51,   241,   209,   214,   216,     6,     7,   223,   190,
     161,-32768,-32768,    31,-32768,-32768,-32768,-32768,-32768,-32768,
  -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,   244,   246,
  -32768,-32768,-32768,-32768,-32768,-32768,-32768,   248,-32768,-32768,
     251,    53,-32768,-32768,   240,-32768,-32768,-32768,   252,-32768,
  -32768,   238,-32768,   249,-32768,    37,   247,   250,    10,    10,
     255,-32768,   180,-32768,    10,    10,    10,   253,-32768,   254,
     956,   956,-32768,   245,    28,    10,-32768,-32768,-32768,    98,
      10,   256,  1089,-32768,   186,-32768,    53,-32768,-32768,   618,
  -32768,   266,   257,   258,-32768,    53,    53,    53,    53,    53,
      53,    53,    53,    53,    53,    53,    53,    53,    53,    53,
      53,    53,    53,    53,-32768,-32768,    10,    53,    10,-32768,
  -32768,-32768,-32768,-32768,   243,-32768,  1089,  1089,   282,  1089,
     255,   106,-32768,-32768,  1145,   259,-32768,   263,-32768,   284,
     285,-32768,-32768,   189,   956,-32768,   201,    10,    10,-32768,
  -32768,-32768,  1012,  1166,    10,   416,-32768,-32768,   272,-32768,
  -32768,-32768,   302,   690,    10,    10,    10,   291,-32768,-32768,
     333,-32768,   288,   300,   293,-32768,   294,    53,-32768,   241,
     310,-32768,-32768,   209,   214,   216,     6,     7,     7,   223,
     223,   223,   223,   190,   190,   161,   161,-32768,-32768,-32768,
  -32768,-32768,   301,   297,-32768,-32768,   303,   304,-32768,    79,
  -32768,   255,-32768,-32768,   307,   956,  1145,-32768,   748,   -22,
     201,    10,    10,-32768,    10,    10,   308,-32768,-32768,-32768,
     370,   313,-32768,-32768,     4,   163,-32768,-32768,   316,  1089,
  -32768,-32768,-32768,    53,    53,-32768,   282,   282,   374,  1145,
  -32768,   317,   315,  1089,   806,   318,-32768,   193,   322,   323,
     324,-32768,-32768,-32768,-32768,  1089,   320,-32768,-32768,    79,
      79,   328,   326,-32768,   332,-32768,-32768,   325,-32768,-32768,
  -32768,-32768,-32768,-32768,   327,-32768,   317,   317,-32768,  1145,
      53,   372,-32768,-32768,-32768,   334,   329,-32768,-32768,    53,
  -32768,-32768,   414,-32768
};

static const short yypgoto[] =
{
  -32768,-32768,-32768,   211,-32768,    16,-32768,-32768,-32768,-32768,
     335,-32768,   143,  -180,  -265,-32768,-32768,    17,   421,   239,
  -32768,   429,    13,   321,   228,-32768,-32768,    12,    -8,  -194,
  -32768,   356,-32768,-32768,   299,-32768,    -1,  -114,-32768,   -88,
  -32768,-32768,    20,   176,-32768,   -15,  -159,  -239,     8,    14,
     -28,     2,  -102,   -62,-32768,-32768,-32768,   415,-32768,-32768,
  -32768,-32768,-32768,-32768,-32768,  -228,   -63,-32768,   213,   215,
     208,   212,   210,    65,   -48,    81,    83,  -104,    32,-32768,
  -32768,-32768,-32768
};


#define	YYLAST		1224


static const short yytable[] =
{
      36,    63,    49,    53,    55,    50,    59,    62,    64,    71,
      85,   130,   214,    32,    31,    60,   179,    28,   304,   331,
     359,   293,    54,    59,   224,   343,   262,   231,   359,    83,
      56,   102,    72,   233,   234,    93,    64,    59,    93,    10,
      86,    95,    10,    59,    91,    92,    50,    94,    10,   106,
     244,   245,   107,    93,    89,    80,    64,    65,   -26,    64,
      10,    85,   336,   337,    10,    10,    10,   115,    10,   116,
      73,   117,   118,   119,   232,    10,   146,    59,    59,    59,
     394,   249,   225,   359,   235,   236,   178,   185,   187,    77,
     120,    10,   146,   203,   348,   246,    81,   210,    74,   -48,
     192,   113,   342,    77,    95,   247,   171,   385,   255,   121,
      61,   113,   -47,   226,    76,   215,   248,    96,    80,   359,
     122,   -26,   123,   124,   125,   221,    87,   126,   268,    11,
      88,    13,    14,    74,   222,    17,   127,   327,   328,   329,
     378,    78,   379,  -122,   171,   205,   398,   206,   189,    99,
     217,   218,   268,   220,    67,   380,    79,    68,   341,    80,
      19,    20,    21,   312,    85,   384,    23,    74,   115,    25,
     116,   101,   117,   118,   119,   396,    93,   205,    87,   301,
     212,   -48,    88,   111,   312,   319,   320,   321,   322,   407,
      80,   120,    10,   270,   271,   272,   194,   195,   196,    36,
      36,   414,   260,   372,    44,    45,    46,   212,   171,   213,
     121,    59,    79,    31,    31,   112,     8,   145,   221,   297,
     185,   122,   188,   123,   124,   125,    95,   306,   216,    19,
      20,    21,   241,   242,   243,    23,   200,   127,    25,    10,
      11,    12,    13,    14,    15,    16,    17,    18,   294,   295,
     296,   237,   238,   201,    22,    59,    59,   204,    59,   239,
     240,   171,   305,    59,   185,   185,   207,   185,    71,   410,
      80,   227,   187,    36,   228,   349,    91,    92,    50,   268,
     229,    36,    59,   230,    36,   416,   417,    31,   399,   400,
     354,    72,    36,   365,   353,    54,   317,   318,    31,   355,
      34,   356,    48,    52,    52,   250,    31,   251,    34,   252,
     397,   312,   253,    54,   256,  -176,  -176,  -176,   323,   324,
     258,  -176,   325,   326,  -176,   263,   257,   335,   259,   264,
     171,   338,   273,  -176,   274,   360,    84,  -176,   303,   307,
     308,   344,   189,    80,    36,    59,    83,    36,  -176,   387,
     388,   389,    50,    64,   187,   105,    34,   427,    31,    34,
     110,    31,   346,    94,   345,   362,   431,   366,    59,   367,
     368,   114,   390,   373,   369,   370,   371,   185,    59,   375,
     374,   383,    59,    36,   391,   376,   377,   404,   392,   393,
     395,   185,   401,   405,    59,   406,   409,    31,   411,   412,
     413,   202,   415,   185,   418,   419,   420,   422,   428,   423,
     110,   430,   211,   429,   433,   298,   347,   275,    59,   276,
     277,   278,    29,   279,   280,   281,     7,   404,   266,   193,
      30,     8,   209,   299,   175,   340,   314,    70,   309,   424,
     316,   315,   313,     0,     0,     0,     0,     0,     0,     0,
       0,     0,     0,     9,    10,    11,    12,    13,    14,    15,
      16,    17,    18,     0,     0,    19,    20,    21,  -120,    22,
     282,    23,     0,   283,    25,     0,     0,     0,     0,     0,
       0,     0,     0,     0,   261,     0,     0,   265,   267,     0,
       0,     0,     0,     0,    44,    45,    46,   358,     0,    34,
      34,     0,     0,   105,   110,     0,     8,   147,   148,   302,
     149,   150,   151,   152,   153,   154,   155,   156,   157,   158,
     159,   160,   161,   162,   163,     0,     0,     0,   120,    10,
      11,    12,    13,    14,    15,    16,    17,    18,     0,     0,
      19,    20,    21,     0,    22,   330,    23,   334,     0,    25,
       0,     0,   164,     0,     0,   165,   166,   167,   122,   168,
     123,   124,   125,   169,   170,     0,   171,     0,   172,   173,
       0,     0,     0,    34,   127,    48,    52,    52,     0,     0,
       0,    34,     0,   357,    34,     0,     0,     0,     0,     0,
       0,     0,    34,   364,   357,   357,     0,     0,     0,     0,
       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
       0,    44,    45,    46,     0,     0,     0,     0,     0,     0,
       0,     0,   115,     8,   116,     0,   117,   118,   119,     0,
       0,     0,     0,     0,    34,     0,     0,    34,     0,     0,
       0,     0,     0,    34,   357,   120,    10,    11,    12,    13,
      14,    15,    16,    17,    18,     0,     0,    19,    20,    21,
       0,    22,     0,    23,   121,     0,    25,     0,     0,     0,
       0,     0,     0,    34,     0,   122,     0,   123,   124,   125,
       0,   275,   126,   276,   277,   278,     0,   279,   280,   281,
       7,   127,     0,     0,     0,     8,     0,     0,     0,     0,
       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
       0,     0,     0,     0,     0,     0,     0,     9,    10,    11,
      12,    13,    14,    15,    16,    17,    18,     0,     0,    19,
      20,    21,  -120,    22,   282,    23,     0,   283,    25,   275,
       0,   276,   277,   278,     0,   279,   280,   281,     7,     0,
       0,     0,     0,     8,     0,     0,     0,     0,     0,     0,
       0,   363,     0,     0,     0,     0,     0,     0,     0,     0,
       0,     0,     0,     0,     0,     9,    10,    11,    12,    13,
      14,    15,    16,    17,    18,     0,     0,    19,    20,    21,
    -120,    22,   282,    23,     0,   283,    25,   275,     0,   276,
     277,   278,     0,   279,   280,   281,     7,     0,     0,     0,
       0,     8,     0,     0,     0,     0,     0,     0,     0,   386,
       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
       0,     0,     0,     9,    10,    11,    12,    13,    14,    15,
      16,    17,    18,     0,     0,    19,    20,    21,  -120,    22,
     282,    23,     0,   283,    25,   115,     0,   116,     0,   117,
     118,   119,     0,     0,     0,     0,     0,     0,     0,     0,
       0,     0,     0,     0,     0,     0,     0,   408,   120,    10,
       0,     0,     0,     0,     0,     0,     0,     0,   432,     2,
       0,     3,     4,     5,     6,     0,     0,   121,     7,     0,
       0,     0,     0,     8,     0,     0,     0,     0,   122,     0,
     123,   124,   125,     0,     0,   219,     0,     0,     0,     0,
       0,     0,     0,     0,   127,     9,    10,    11,    12,    13,
      14,    15,    16,    17,    18,     0,     0,    19,    20,    21,
    -120,    22,     0,    23,     0,    24,    25,   275,     0,   276,
     277,   278,     0,   279,   280,   281,     7,     0,     0,     0,
       0,     8,     0,     0,     0,     0,     0,     0,     0,     0,
       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
       0,     0,     0,     9,    10,    11,    12,    13,    14,    15,
      16,    17,    18,     0,     0,    19,    20,    21,  -120,    22,
     282,    23,     0,   283,    25,   350,   351,   352,     0,     0,
       0,     0,     7,     0,     0,     0,     0,     8,     0,     0,
       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
       0,     0,     0,     0,     0,     0,     0,     0,     0,     9,
      10,    11,    12,    13,    14,    15,    16,    17,    18,     0,
       0,    19,    20,    21,     0,    22,     0,    23,     0,     0,
      25,    44,    45,    46,     0,     0,     0,     0,     0,     0,
       0,     0,     0,     8,     0,     0,     0,     0,     0,     0,
       0,     0,    44,    45,    46,     0,     0,     0,     0,     0,
       0,     0,     0,     0,     8,    57,    10,    11,    12,    13,
      14,    15,    16,    17,    18,     0,     0,    19,    20,    21,
       0,    22,     0,    23,   180,     0,    25,    10,    11,    12,
      13,    14,    15,    16,    17,    18,     0,     0,    19,    20,
      21,     0,    22,     0,    23,     0,     0,    25,    44,    45,
      46,     0,     0,     0,     0,     0,     0,     0,     0,     0,
       8,     0,     0,     0,     0,     0,     0,     0,     0,   276,
     277,   278,     0,     0,     0,     0,     0,     0,     0,     0,
       0,     8,     0,    10,    11,    12,    13,    14,    15,    16,
      17,    18,     0,     0,    19,    20,    21,     0,    22,     0,
      23,     0,     0,    25,    10,    11,    12,    13,    14,    15,
      16,    17,    18,     0,     0,    19,    20,    21,     0,    22,
       0,    23,     0,     0,    25
};

static const short yycheck[] =
{
       1,     9,     3,     4,     5,     3,     7,     8,     9,    24,
      38,    74,   114,     1,     1,     7,    78,     1,   212,   247,
     285,   201,     5,    24,   128,   264,   185,    21,   293,    37,
      77,     3,    24,    26,    27,    34,    37,    38,    34,    38,
      38,    63,    38,    44,    45,    46,    44,    48,    38,    57,
      19,    20,    60,    34,    40,    77,    57,    39,    80,    60,
      38,    89,   256,   257,    38,    38,    38,    14,    38,    16,
      76,    18,    19,    20,    68,    38,    77,    78,    79,    80,
      76,   143,    31,   348,    77,    78,    78,    79,    80,    34,
      37,    38,    93,    78,   274,    64,    74,    71,    61,    80,
      86,    74,   261,    34,    63,    74,    75,   346,   171,    56,
      80,    74,    75,    62,    76,   116,    85,    76,    77,   384,
      67,    80,    69,    70,    71,   126,    67,    74,   190,    39,
      71,    41,    42,    61,   126,    45,    83,   241,   242,   243,
      61,    52,    63,    74,    75,    79,   374,    81,    79,    76,
     118,   119,   214,   121,    39,    76,    74,    42,   260,    77,
      49,    50,    51,   226,   192,   345,    55,    61,    14,    58,
      16,    76,    18,    19,    20,   369,    34,    79,    67,    81,
      74,    75,    71,    80,   247,   233,   234,   235,   236,   383,
      77,    37,    38,   194,   195,   196,     7,     8,     9,   200,
     201,   395,   185,   307,     3,     4,     5,    74,    75,    76,
      56,   212,    74,   200,   201,    76,    15,    76,   219,   203,
     212,    67,    71,    69,    70,    71,    63,   219,    74,    49,
      50,    51,    71,    72,    73,    55,    80,    83,    58,    38,
      39,    40,    41,    42,    43,    44,    45,    46,     3,     4,
       5,    28,    29,    80,    53,   256,   257,    79,   259,    69,
      70,    75,    76,   264,   256,   257,    61,   259,   283,    76,
      77,    30,   264,   274,    65,   276,   277,   278,   276,   341,
      66,   282,   283,    67,   285,   399,   400,   274,   376,   377,
     282,   283,   293,   294,   282,   278,   231,   232,   285,   283,
       1,   284,     3,     4,     5,    61,   293,    61,     9,    61,
     373,   374,    61,   296,    74,    49,    50,    51,   237,   238,
      82,    55,   239,   240,    58,    78,    74,    84,    79,    79,
      75,    49,    79,    67,    80,    63,    37,    71,    82,    82,
      82,    82,    79,    77,   345,   346,   354,   348,    82,   350,
     351,   352,   350,   354,   346,    56,    57,   420,   345,    60,
      61,   348,    77,   364,    80,    63,   429,    76,   369,    36,
      82,    72,   355,    63,    74,    82,    82,   369,   379,    82,
      79,    74,   383,   384,    76,    82,    82,   379,    18,    76,
      74,   383,    18,    76,   395,    80,    78,   384,    76,    76,
      76,   102,    82,   395,    76,    79,    74,    82,    36,    82,
     111,    82,   113,    79,     0,   204,   273,     1,   419,     3,
       4,     5,     1,     7,     8,     9,    10,   419,   189,    94,
       1,    15,   111,   205,    78,   259,   228,    22,   225,   419,
     230,   229,   227,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
      -1,    -1,    -1,    37,    38,    39,    40,    41,    42,    43,
      44,    45,    46,    -1,    -1,    49,    50,    51,    52,    53,
      54,    55,    -1,    57,    58,    -1,    -1,    -1,    -1,    -1,
      -1,    -1,    -1,    -1,   185,    -1,    -1,   188,   189,    -1,
      -1,    -1,    -1,    -1,     3,     4,     5,    81,    -1,   200,
     201,    -1,    -1,   204,   205,    -1,    15,    16,    17,   210,
      19,    20,    21,    22,    23,    24,    25,    26,    27,    28,
      29,    30,    31,    32,    33,    -1,    -1,    -1,    37,    38,
      39,    40,    41,    42,    43,    44,    45,    46,    -1,    -1,
      49,    50,    51,    -1,    53,   246,    55,   248,    -1,    58,
      -1,    -1,    61,    -1,    -1,    64,    65,    66,    67,    68,
      69,    70,    71,    72,    73,    -1,    75,    -1,    77,    78,
      -1,    -1,    -1,   274,    83,   276,   277,   278,    -1,    -1,
      -1,   282,    -1,   284,   285,    -1,    -1,    -1,    -1,    -1,
      -1,    -1,   293,   294,   295,   296,    -1,    -1,    -1,    -1,
      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
      -1,     3,     4,     5,    -1,    -1,    -1,    -1,    -1,    -1,
      -1,    -1,    14,    15,    16,    -1,    18,    19,    20,    -1,
      -1,    -1,    -1,    -1,   345,    -1,    -1,   348,    -1,    -1,
      -1,    -1,    -1,   354,   355,    37,    38,    39,    40,    41,
      42,    43,    44,    45,    46,    -1,    -1,    49,    50,    51,
      -1,    53,    -1,    55,    56,    -1,    58,    -1,    -1,    -1,
      -1,    -1,    -1,   384,    -1,    67,    -1,    69,    70,    71,
      -1,     1,    74,     3,     4,     5,    -1,     7,     8,     9,
      10,    83,    -1,    -1,    -1,    15,    -1,    -1,    -1,    -1,
      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
      -1,    -1,    -1,    -1,    -1,    -1,    -1,    37,    38,    39,
      40,    41,    42,    43,    44,    45,    46,    -1,    -1,    49,
      50,    51,    52,    53,    54,    55,    -1,    57,    58,     1,
      -1,     3,     4,     5,    -1,     7,     8,     9,    10,    -1,
      -1,    -1,    -1,    15,    -1,    -1,    -1,    -1,    -1,    -1,
      -1,    81,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
      -1,    -1,    -1,    -1,    -1,    37,    38,    39,    40,    41,
      42,    43,    44,    45,    46,    -1,    -1,    49,    50,    51,
      52,    53,    54,    55,    -1,    57,    58,     1,    -1,     3,
       4,     5,    -1,     7,     8,     9,    10,    -1,    -1,    -1,
      -1,    15,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    81,
      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
      -1,    -1,    -1,    37,    38,    39,    40,    41,    42,    43,
      44,    45,    46,    -1,    -1,    49,    50,    51,    52,    53,
      54,    55,    -1,    57,    58,    14,    -1,    16,    -1,    18,
      19,    20,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
      -1,    -1,    -1,    -1,    -1,    -1,    -1,    81,    37,    38,
      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,     0,     1,
      -1,     3,     4,     5,     6,    -1,    -1,    56,    10,    -1,
      -1,    -1,    -1,    15,    -1,    -1,    -1,    -1,    67,    -1,
      69,    70,    71,    -1,    -1,    74,    -1,    -1,    -1,    -1,
      -1,    -1,    -1,    -1,    83,    37,    38,    39,    40,    41,
      42,    43,    44,    45,    46,    -1,    -1,    49,    50,    51,
      52,    53,    -1,    55,    -1,    57,    58,     1,    -1,     3,
       4,     5,    -1,     7,     8,     9,    10,    -1,    -1,    -1,
      -1,    15,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
      -1,    -1,    -1,    37,    38,    39,    40,    41,    42,    43,
      44,    45,    46,    -1,    -1,    49,    50,    51,    52,    53,
      54,    55,    -1,    57,    58,     3,     4,     5,    -1,    -1,
      -1,    -1,    10,    -1,    -1,    -1,    -1,    15,    -1,    -1,
      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    37,
      38,    39,    40,    41,    42,    43,    44,    45,    46,    -1,
      -1,    49,    50,    51,    -1,    53,    -1,    55,    -1,    -1,
      58,     3,     4,     5,    -1,    -1,    -1,    -1,    -1,    -1,
      -1,    -1,    -1,    15,    -1,    -1,    -1,    -1,    -1,    -1,
      -1,    -1,     3,     4,     5,    -1,    -1,    -1,    -1,    -1,
      -1,    -1,    -1,    -1,    15,    37,    38,    39,    40,    41,
      42,    43,    44,    45,    46,    -1,    -1,    49,    50,    51,
      -1,    53,    -1,    55,    35,    -1,    58,    38,    39,    40,
      41,    42,    43,    44,    45,    46,    -1,    -1,    49,    50,
      51,    -1,    53,    -1,    55,    -1,    -1,    58,     3,     4,
       5,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
      15,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,     3,
       4,     5,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
      -1,    15,    -1,    38,    39,    40,    41,    42,    43,    44,
      45,    46,    -1,    -1,    49,    50,    51,    -1,    53,    -1,
      55,    -1,    -1,    58,    38,    39,    40,    41,    42,    43,
      44,    45,    46,    -1,    -1,    49,    50,    51,    -1,    53,
      -1,    55,    -1,    -1,    58
};
/* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
#line 3 "/usr/local/share/bison/bison.simple"

/* Skeleton output parser for bison,

   Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software
   Foundation, Inc.

   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 2, 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., 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.  */

/* As a special exception, when this file is copied by Bison into a
   Bison output file, you may use that output file without restriction.
   This special exception was added by the Free Software Foundation
   in version 1.24 of Bison.  */

/* 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.  */

/* All symbols defined below should begin with yy or YY, to avoid
   infringing on user name space.  This should be done even for local
   variables, as they might otherwise be expanded by user macros.
   There are some unavoidable exceptions within include files to
   define necessary library symbols; they are noted "INFRINGES ON
   USER NAME SPACE" below.  */

#if ! defined (yyoverflow) || defined (YYERROR_VERBOSE)

/* The parser invokes alloca or malloc; define the necessary symbols.  */

# if YYSTACK_USE_ALLOCA
#  define YYSTACK_ALLOC alloca
# else
#  ifndef YYSTACK_USE_ALLOCA
#   if defined (alloca) || defined (_ALLOCA_H)
#    define YYSTACK_ALLOC alloca
#   else
#    ifdef __GNUC__
#     define YYSTACK_ALLOC __builtin_alloca
#    endif
#   endif
#  endif
# endif

# ifdef YYSTACK_ALLOC
   /* Pacify GCC's `empty if-body' warning. */
#  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
# else
#  if defined (__STDC__) || defined (__cplusplus)
#   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
#   define YYSIZE_T size_t
#  endif
#  define YYSTACK_ALLOC malloc
#  define YYSTACK_FREE free
# endif
#endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */


#if (! defined (yyoverflow) \
     && (! defined (__cplusplus) \
	 || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))

/* A type that is properly aligned for any stack member.  */
union yyalloc
{
  short yyss;
  YYSTYPE yyvs;
# if YYLSP_NEEDED
  YYLTYPE yyls;
# endif
};

/* The size of the maximum gap between one aligned stack and the next.  */
# define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)

/* The size of an array large to enough to hold all stacks, each with
   N elements.  */
# if YYLSP_NEEDED
#  define YYSTACK_BYTES(N) \
     ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE))	\
      + 2 * YYSTACK_GAP_MAX)
# else
#  define YYSTACK_BYTES(N) \
     ((N) * (sizeof (short) + sizeof (YYSTYPE))				\
      + YYSTACK_GAP_MAX)
# endif

/* Copy COUNT objects from FROM to TO.  The source and destination do
   not overlap.  */
# ifndef YYCOPY
#  if 1 < __GNUC__
#   define YYCOPY(To, From, Count) \
      __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
#  else
#   define YYCOPY(To, From, Count)		\
      do					\
	{					\
	  register YYSIZE_T yyi;		\
	  for (yyi = 0; yyi < (Count); yyi++)	\
	    (To)[yyi] = (From)[yyi];		\
	}					\
      while (0)
#  endif
# endif

/* Relocate STACK from its old location to the new one.  The
   local variables YYSIZE and YYSTACKSIZE give the old and new number of
   elements in the stack, and YYPTR gives the new location of the
   stack.  Advance YYPTR to a properly aligned location for the next
   stack.  */
# define YYSTACK_RELOCATE(Stack)					\
    do									\
      {									\
	YYSIZE_T yynewbytes;						\
	YYCOPY (&yyptr->Stack, Stack, yysize);				\
	Stack = &yyptr->Stack;						\
	yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX;	\
	yyptr += yynewbytes / sizeof (*yyptr);				\
      }									\
    while (0)

#endif


#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
# define YYSIZE_T __SIZE_TYPE__
#endif
#if ! defined (YYSIZE_T) && defined (size_t)
# define YYSIZE_T size_t
#endif
#if ! defined (YYSIZE_T)
# if defined (__STDC__) || defined (__cplusplus)
#  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
#  define YYSIZE_T size_t
# endif
#endif
#if ! defined (YYSIZE_T)
# define YYSIZE_T unsigned int
#endif

#define yyerrok		(yyerrstatus = 0)
#define yyclearin	(yychar = YYEMPTY)
#define YYEMPTY		-2
#define YYEOF		0
#define YYACCEPT	goto yyacceptlab
#define YYABORT 	goto yyabortlab
#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


/* YYLLOC_DEFAULT -- Compute the default location (before the actions
   are run).

   When YYLLOC_DEFAULT is run, CURRENT is set the location of the
   first token.  By default, to implement support for ranges, extend
   its range to the last symbol.  */

#ifndef YYLLOC_DEFAULT
# define YYLLOC_DEFAULT(Current, Rhs, N)       	\
   Current.last_line   = Rhs[N].last_line;	\
   Current.last_column = Rhs[N].last_column;
#endif


/* YYLEX -- calling `yylex' with the right arguments.  */

#if YYPURE
# if YYLSP_NEEDED
#  ifdef YYLEX_PARAM
#   define YYLEX		yylex (&yylval, &yylloc, YYLEX_PARAM)
#  else
#   define YYLEX		yylex (&yylval, &yylloc)
#  endif
# else /* !YYLSP_NEEDED */
#  ifdef YYLEX_PARAM
#   define YYLEX		yylex (&yylval, YYLEX_PARAM)
#  else
#   define YYLEX		yylex (&yylval)
#  endif
# endif /* !YYLSP_NEEDED */
#else /* !YYPURE */
# define YYLEX			yylex ()
#endif /* !YYPURE */


/* Enable debugging if requested.  */
#if YYDEBUG

# ifndef YYFPRINTF
#  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
#  define YYFPRINTF fprintf
# endif

# define YYDPRINTF(Args)			\
do {						\
  if (yydebug)					\
    YYFPRINTF Args;				\
} while (0)
/* Nonzero means print parse trace.  It is left uninitialized so that
   multiple parsers can coexist.  */
int yydebug;
#else /* !YYDEBUG */
# define YYDPRINTF(Args)
#endif /* !YYDEBUG */

/* YYINITDEPTH -- initial size of the parser's stacks.  */
#ifndef	YYINITDEPTH
# define YYINITDEPTH 200
#endif

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

   Do not make this value too large; the results are undefined if
   SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
   evaluated with infinite-precision integer arithmetic.  */

#if YYMAXDEPTH == 0
# undef YYMAXDEPTH
#endif

#ifndef YYMAXDEPTH
# define YYMAXDEPTH 10000
#endif

#ifdef YYERROR_VERBOSE

# ifndef yystrlen
#  if defined (__GLIBC__) && defined (_STRING_H)
#   define yystrlen strlen
#  else
/* Return the length of YYSTR.  */
static YYSIZE_T
#   if defined (__STDC__) || defined (__cplusplus)
yystrlen (const char *yystr)
#   else
yystrlen (yystr)
     const char *yystr;
#   endif
{
  register const char *yys = yystr;

  while (*yys++ != '\0')
    continue;

  return yys - yystr - 1;
}
#  endif
# endif

# ifndef yystpcpy
#  if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
#   define yystpcpy stpcpy
#  else
/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
   YYDEST.  */
static char *
#   if defined (__STDC__) || defined (__cplusplus)
yystpcpy (char *yydest, const char *yysrc)
#   else
yystpcpy (yydest, yysrc)
     char *yydest;
     const char *yysrc;
#   endif
{
  register char *yyd = yydest;
  register const char *yys = yysrc;

  while ((*yyd++ = *yys++) != '\0')
    continue;

  return yyd - 1;
}
#  endif
# endif
#endif

#line 315 "/usr/local/share/bison/bison.simple"


/* The user can define YYPARSE_PARAM as the name of an argument to be passed
   into yyparse.  The argument should have type void *.
   It should actually point to an object.
   Grammar actions can access the variable by casting it
   to the proper pointer type.  */

#ifdef YYPARSE_PARAM
# if defined (__STDC__) || defined (__cplusplus)
#  define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
#  define YYPARSE_PARAM_DECL
# else
#  define YYPARSE_PARAM_ARG YYPARSE_PARAM
#  define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
# endif
#else /* !YYPARSE_PARAM */
# define YYPARSE_PARAM_ARG
# define YYPARSE_PARAM_DECL
#endif /* !YYPARSE_PARAM */

/* Prevent warning if -Wstrict-prototypes.  */
#ifdef __GNUC__
# ifdef YYPARSE_PARAM
int yyparse (void *);
# else
int yyparse (void);
# endif
#endif

/* YY_DECL_VARIABLES -- depending whether we use a pure parser,
   variables are global, or local to YYPARSE.  */

#define YY_DECL_NON_LSP_VARIABLES			\
/* The lookahead symbol.  */				\
int yychar;						\
							\
/* The semantic value of the lookahead symbol. */	\
YYSTYPE yylval;						\
							\
/* Number of parse errors so far.  */			\
int yynerrs;

#if YYLSP_NEEDED
# define YY_DECL_VARIABLES			\
YY_DECL_NON_LSP_VARIABLES			\
						\
/* Location data for the lookahead symbol.  */	\
YYLTYPE yylloc;
#else
# define YY_DECL_VARIABLES			\
YY_DECL_NON_LSP_VARIABLES
#endif


/* If nonreentrant, generate the variables here. */

#if !YYPURE
YY_DECL_VARIABLES
#endif  /* !YYPURE */

int
yyparse (YYPARSE_PARAM_ARG)
     YYPARSE_PARAM_DECL
{
  /* If reentrant, generate the variables here. */
#if YYPURE
  YY_DECL_VARIABLES
#endif  /* !YYPURE */

  register int yystate;
  register int yyn;
  int yyresult;
  /* Number of tokens to shift before error messages enabled.  */
  int yyerrstatus;
  /* Lookahead token as an internal (translated) token number.  */
  int yychar1 = 0;

  /* Three stacks and their tools:
     `yyss': related to states,
     `yyvs': related to semantic values,
     `yyls': related to locations.

     Refer to the stacks thru separate pointers, to allow yyoverflow
     to reallocate them elsewhere.  */

  /* The state stack. */
  short	yyssa[YYINITDEPTH];
  short *yyss = yyssa;
  register short *yyssp;

  /* The semantic value stack.  */
  YYSTYPE yyvsa[YYINITDEPTH];
  YYSTYPE *yyvs = yyvsa;
  register YYSTYPE *yyvsp;

#if YYLSP_NEEDED
  /* The location stack.  */
  YYLTYPE yylsa[YYINITDEPTH];
  YYLTYPE *yyls = yylsa;
  YYLTYPE *yylsp;
#endif

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

  YYSIZE_T yystacksize = YYINITDEPTH;


  /* The variables used to return semantic value and location from the
     action routines.  */
  YYSTYPE yyval;
#if YYLSP_NEEDED
  YYLTYPE yyloc;
#endif

  /* When reducing, the number of symbols on the RHS of the reduced
     rule. */
  int yylen;

  YYDPRINTF ((stderr, "Starting parse\n"));

  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;
  yyvsp = yyvs;
#if YYLSP_NEEDED
  yylsp = yyls;
#endif
  goto yysetstate;

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

 yysetstate:
  *yyssp = yystate;

  if (yyssp >= yyss + yystacksize - 1)
    {
      /* Get the current used size of the three stacks, in elements.  */
      YYSIZE_T yysize = yyssp - yyss + 1;

#ifdef yyoverflow
      {
	/* 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;

	/* Each stack pointer address is followed by the size of the
	   data in use in that stack, in bytes.  */
# if YYLSP_NEEDED
	YYLTYPE *yyls1 = yyls;
	/* 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, yysize * sizeof (*yyssp),
		    &yyvs1, yysize * sizeof (*yyvsp),
		    &yyls1, yysize * sizeof (*yylsp),
		    &yystacksize);
	yyls = yyls1;
# else
	yyoverflow ("parser stack overflow",
		    &yyss1, yysize * sizeof (*yyssp),
		    &yyvs1, yysize * sizeof (*yyvsp),
		    &yystacksize);
# endif
	yyss = yyss1;
	yyvs = yyvs1;
      }
#else /* no yyoverflow */
# ifndef YYSTACK_RELOCATE
      goto yyoverflowlab;
# else
      /* Extend the stack our own way.  */
      if (yystacksize >= YYMAXDEPTH)
	goto yyoverflowlab;
      yystacksize *= 2;
      if (yystacksize > YYMAXDEPTH)
	yystacksize = YYMAXDEPTH;

      {
	short *yyss1 = yyss;
	union yyalloc *yyptr =
	  (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
	if (! yyptr)
	  goto yyoverflowlab;
	YYSTACK_RELOCATE (yyss);
	YYSTACK_RELOCATE (yyvs);
# if YYLSP_NEEDED
	YYSTACK_RELOCATE (yyls);
# endif
# undef YYSTACK_RELOCATE
	if (yyss1 != yyssa)
	  YYSTACK_FREE (yyss1);
      }
# endif
#endif /* no yyoverflow */

      yyssp = yyss + yysize - 1;
      yyvsp = yyvs + yysize - 1;
#if YYLSP_NEEDED
      yylsp = yyls + yysize - 1;
#endif

      YYDPRINTF ((stderr, "Stack size increased to %lu\n",
		  (unsigned long int) yystacksize));

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

  YYDPRINTF ((stderr, "Entering state %d\n", yystate));

  goto yybackup;


/*-----------.
| 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)
    {
      YYDPRINTF ((stderr, "Reading a token: "));
      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 */

      YYDPRINTF ((stderr, "Now at end of input.\n"));
    }
  else
    {
      yychar1 = YYTRANSLATE (yychar);

#if YYDEBUG
     /* We have to keep this `#if YYDEBUG', since we use variables
	which are defined only if `YYDEBUG' is set.  */
      if (yydebug)
	{
	  YYFPRINTF (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
	  YYFPRINTF (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.  */
  YYDPRINTF ((stderr, "Shifting token %d (%s), ",
	      yychar, yytname[yychar1]));

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

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

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

  yystate = yyn;
  goto yynewstate;


/*-----------------------------------------------------------.
| yydefault -- do the default action for the current state.  |
`-----------------------------------------------------------*/
yydefault:
  yyn = yydefact[yystate];
  if (yyn == 0)
    goto yyerrlab;
  goto yyreduce;


/*-----------------------------.
| yyreduce -- Do a reduction.  |
`-----------------------------*/
yyreduce:
  /* yyn is the number of a rule to reduce with.  */
  yylen = yyr2[yyn];

  /* If YYLEN is nonzero, implement the default value of the action:
     `$$ = $1'.

     Otherwise, the following line sets YYVAL to the semantic value of
     the lookahead token.  This behavior is undocumented and Bison
     users should not rely upon it.  Assigning to YYVAL
     unconditionally makes the parser a bit smaller, and it avoids a
     GCC warning that YYVAL may be used uninitialized.  */
  yyval = yyvsp[1-yylen];

#if YYLSP_NEEDED
  /* Similarly for the default location.  Let the user run additional
     commands if for instance locations are ranges.  */
  yyloc = yylsp[1-yylen];
  YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
#endif

#if YYDEBUG
  /* We have to keep this `#if YYDEBUG', since we use variables which
     are defined only if `YYDEBUG' is set.  */
  if (yydebug)
    {
      int yyi;

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

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

  switch (yyn) {

case 3:
#line 201 "parser.y"
{ }
    break;
case 4:
#line 202 "parser.y"
{ if (yyvsp[0].type->alias) global.typedefs.put(yyvsp[0].type->alias, yyvsp[0].type); }
    break;
case 5:
#line 203 "parser.y"
{ }
    break;
case 6:
#line 204 "parser.y"
{ }
    break;
case 7:
#line 205 "parser.y"
{ /* best recovery is with no action */ }
    break;
case 8:
#line 209 "parser.y"
{ }
    break;
case 9:
#line 211 "parser.y"
{
	    yyvsp[-1].clazz->comment = yyvsp[-5].str->comment;
	    yyvsp[-1].clazz->setParameters(yyvsp[-3].arg);
	    if (0 == check_new_classdef(yyvsp[-1].clazz))
	    {
		global.classJar.add(yyvsp[-1].clazz);
		local.nclassdef++;
	    }
	}
    break;
case 10:
#line 221 "parser.y"
{
	    if (0 == check_new_classdef(yyvsp[-1].clazz))
	    {
		global.classJar.add(yyvsp[-1].clazz);
		local.nclassdef++;
	    }
	}
    break;
case 11:
#line 228 "parser.y"
{ }
    break;
case 12:
#line 229 "parser.y"
{ }
    break;
case 13:
#line 230 "parser.y"
{ }
    break;
case 14:
#line 235 "parser.y"
{
	    yyval.arg = yyvsp[0].arg;
	}
    break;
case 15:
#line 239 "parser.y"
{
	    yyval.arg = yyvsp[-2].arg;
	    yyval.arg->next = yyvsp[0].arg;
	}
    break;
case 16:
#line 247 "parser.y"
{
	    CType* t = new ObjectCType(yyvsp[-1].str->comment, yyvsp[0].str->val, NULL);
	    yyval.arg = new Arg(yyvsp[-1].str->comment, yyvsp[0].str->val, t);
	}
    break;
case 17:
#line 252 "parser.y"
{
	    CType* t = new ObjectCType(yyvsp[0].str->comment, yyvsp[0].str->val, NULL);
	    yyval.arg = new Arg(yyvsp[0].str->comment, yyvsp[0].str->val, t);
	}
    break;
case 18:
#line 259 "parser.y"
{
	    push_scope(PRIVATE); local.typedefs.clear();
	    }
    break;
case 19:
#line 262 "parser.y"
{
	    ObjectCType* t = new ObjectCType(NULL, yyvsp[-5].str->val,
		global.pool.add(local.source_file));
	    yyval.clazz = new Class(yyvsp[-6].str->comment, t, yyvsp[-4].objtype, yyvsp[-1].method);
	    yyval.clazz->typedefs.copy(local.typedefs);
	    if (global.verbose)
	    {
		printf("  class %s\n", yyval.clazz->name());
	    }
	    pop_scope();
	    local.typedefs.clear();
	}
    break;
case 20:
#line 274 "parser.y"
{
	    push_scope(PRIVATE); local.typedefs.clear();
	    }
    break;
case 21:
#line 277 "parser.y"
{
	    /* assume first id is an export spec */
	    ObjectCType* t = new ObjectCType(NULL, yyvsp[-5].str->val,
		global.pool.add(local.source_file));
	    yyval.clazz = new Class(yyvsp[-7].str->comment, t, yyvsp[-4].objtype, yyvsp[-1].method);
	    yyval.clazz->typedefs.copy(local.typedefs);
	    if (global.verbose)
	    {
		printf("  class %s %s\n", yyvsp[-6].str->val, yyval.clazz->name());
	    }
	    pop_scope();
	    local.typedefs.clear();
	}
    break;
case 22:
#line 290 "parser.y"
{
	    push_scope(PUBLIC); local.typedefs.clear();
	    }
    break;
case 23:
#line 293 "parser.y"
{
	    ObjectCType* t = new ObjectCType(NULL, yyvsp[-4].str->val,
		global.pool.add(local.source_file));
	    yyval.clazz = new Class(yyvsp[-5].str->comment, t, NULL, yyvsp[-1].method);
	    yyval.clazz->typedefs.copy(local.typedefs);
	    if (global.verbose)
	    {
		printf("  struct %s\n", yyval.clazz->name());
	    }
	    pop_scope();
	    local.typedefs.clear();
	}
    break;
case 24:
#line 305 "parser.y"
{
	    push_scope(PUBLIC); local.typedefs.clear();
	    }
    break;
case 25:
#line 308 "parser.y"
{
	    ObjectCType* t = new ObjectCType(NULL, yyvsp[-4].str->val,
		global.pool.add(local.source_file));
	    yyval.clazz = new Class(yyvsp[-5].str->comment, t, NULL, yyvsp[-1].method);
	    yyval.clazz->typedefs.copy(local.typedefs);
	    if (global.verbose)
	    {
		printf("  union %s\n", yyval.clazz->name());
	    }
	    pop_scope();
	    local.typedefs.clear();
	}
    break;
case 26:
#line 323 "parser.y"
{ yyval.objtype = NULL; }
    break;
case 27:
#line 324 "parser.y"
{ yyval.objtype = yyvsp[0].objtype; }
    break;
case 28:
#line 328 "parser.y"
{ yyval.objtype = yyvsp[0].objtype; }
    break;
case 29:
#line 330 "parser.y"
{
	    warning(msg("multiple class inheritance ignored"));
	    yyval.objtype = yyvsp[-2].objtype;
	}
    break;
case 30:
#line 338 "parser.y"
{
	    yyval.objtype = new ObjectCType(NULL, yyvsp[0].str->val, NULL);
	}
    break;
case 31:
#line 342 "parser.y"
{
	    yyval.objtype = new ObjectCType(NULL, yyvsp[-3].str->val, NULL);
	    yyval.objtype->args = yyvsp[-1].arg;
	}
    break;
case 32:
#line 348 "parser.y"
{ yyval.objtype = NULL; }
    break;
case 33:
#line 349 "parser.y"
{ yyval.objtype = NULL; }
    break;
case 34:
#line 353 "parser.y"
{ yyval.method = yyvsp[0].method; }
    break;
case 35:
#line 355 "parser.y"
{
	    yyval.method = yyvsp[0].method;
	    if (yyvsp[-1].method)
	    {
	        Method* m = yyvsp[-1].method;
		while (m->next) m = m->next;
		m->next = yyvsp[0].method;
		yyval.method = yyvsp[-1].method;
	    }
	}
    break;
case 36:
#line 369 "parser.y"
{
	    yyval.method = yyvsp[0].method;
	    while (yyval.method)
	    {
		if (local.public_scope == PROTECTED)
		{
		    yyval.method->type->modifiers |= CType::M_PROTECTED;
		}
		if (local.public_scope == PRIVATE)
		{
		    yyval.method->type->modifiers |= CType::M_PRIVATE;
		}
		yyval.method = yyval.method->next;
	    }
	    yyval.method = yyvsp[0].method;
	}
    break;
case 37:
#line 388 "parser.y"
{ yyval.method = NULL; }
    break;
case 38:
#line 390 "parser.y"
{
	    yyval.method = yyvsp[-2].method;
	    while (yyval.method)
	    {
		yyval.method->type->modifiers |= CType::M_ATTRIBUTE;
		yyval.method = yyval.method->next;
	    }
	    yyval.method = yyvsp[-2].method;
	}
    break;
case 39:
#line 400 "parser.y"
{
	    yyval.method = yyvsp[0].method;
	}
    break;
case 40:
#line 407 "parser.y"
{
	    if (yyvsp[0].type && (yyvsp[0].type->modifiers & CType::M_ENUM))
	    {
		yyval.method = new Method(yyvsp[0].type->comment, yyvsp[0].type->CTypeName(), NULL);
		yyval.method->type = yyvsp[0].type;
		yyval.method->notes |= Method::ENUM_DEFINE;
	    }
	    else if (yyvsp[0].type && (yyvsp[0].type->modifiers & CType::M_TYPEDEF))
	    {
                CType *ct = local.typedefs.get(yyvsp[0].type->alias);
                if (ct)
		{
		    char buf[512];
		    sprintf(buf, "overriding old typedef %s (%s) with %s (%s)\n",
			ct->alias, ct->CTypeName(), yyvsp[0].type->alias, yyvsp[0].type->CTypeName());
		    warning(msg(buf));
                }
                local.typedefs.put(yyvsp[0].type->alias, yyvsp[0].type);
		yyval.method = new Method(yyvsp[0].type->comment, yyvsp[0].type->alias, NULL);
		yyval.method->type = yyvsp[0].type;
	    }
	    else
	    {
		yyval.method = NULL;
	    }
	}
    break;
case 41:
#line 433 "parser.y"
{ yyval.method = yyvsp[0].method; }
    break;
case 42:
#line 434 "parser.y"
{ yyval.method = NULL; }
    break;
case 43:
#line 435 "parser.y"
{ yyval.method = NULL; }
    break;
case 44:
#line 436 "parser.y"
{ yyval.method = NULL; }
    break;
case 45:
#line 440 "parser.y"
{ yyval.immediate = 0; }
    break;
case 46:
#line 441 "parser.y"
{ yyval.immediate = (int) yyvsp[0].number->val; }
    break;
case 47:
#line 445 "parser.y"
{ yyval.str = new String(NULL, ""); }
    break;
case 48:
#line 446 "parser.y"
{ yyval.str = yyvsp[0].str; }
    break;
case 49:
#line 451 "parser.y"
{
	    char* sep = "|";
	    const char* p = strtok((char*) yyvsp[0].str->val, sep);
	    Method* last = NULL;
	    yyval.method = NULL;
	    while (p)
	    {
		Method* m = new Method(yyvsp[-1].type->comment, p, NULL);
		m->type = yyvsp[-1].type;
		if (!(yyval.method)) yyval.method = m;
		if (last) last->next = m;
		last = m;
		p = strtok(NULL, sep);
	    }
	}
    break;
case 50:
#line 467 "parser.y"
{
	    yyval.method = new Method(yyvsp[-2].type->comment, yyvsp[-1].str->val, NULL);
	    if (yyvsp[0].immediates >= 0)
	    {
                yyval.method->type = yyvsp[-2].type;
                while (--yyvsp[0].immediates[0]) yyval.method->type = new ArrayCType(yyval.method->type, yyvsp[0].immediates[yyvsp[0].immediates[0]+1]);
                
                if (yyvsp[0].immediates[1] >= 0)
                {
                    yyval.method->type = new ArrayCType(yyval.method->type, yyvsp[0].immediates[yyvsp[0].immediates[0]+1]);
                }
                else
                {
                    yyval.method->type->indirection_count++;
                    yyval.method->type->modifiers |= CType::M_POINTER;
                }
	    }
	    else
	    {
		yyval.method->type = yyvsp[-2].type;
		yyval.method->type->indirection_count++;
		yyval.method->type->modifiers |= CType::M_POINTER;
	    }
	}
    break;
case 51:
#line 492 "parser.y"
{
            yyval.method = NULL;
        }
    break;
case 52:
#line 499 "parser.y"
{
	    yyval.str = yyvsp[0].str;
	}
    break;
case 53:
#line 503 "parser.y"
{
	    char buf[TOKEN_BUFFER_SIZE];
	    sprintf(buf, "%s|%s", yyvsp[-2].str->val, yyvsp[0].str->val);
	    yyval.str = new String(yyvsp[-2].str->comment, buf);
	}
    break;
case 54:
#line 511 "parser.y"
{ yyval.method = NULL; }
    break;
case 55:
#line 512 "parser.y"
{ yyval.method = NULL; }
    break;
case 56:
#line 513 "parser.y"
{ yyval.method = NULL; }
    break;
case 57:
#line 515 "parser.y"
{
            if (yyvsp[0].method->is_operator)
            {
                yyval.method = yyvsp[0].method;
                yyval.method->type->modifiers |= CType::M_STATIC;
            }
            else
            {
                yyval.method = NULL;
            }
        }
    break;
case 58:
#line 530 "parser.y"
{
	    yyval.type = yyvsp[-2].type;
	    yyval.type->comment = yyvsp[-3].str->comment;
	    yyval.type->alias = yyvsp[-1].str->val;
	    yyval.type->modifiers |= CType::M_TYPEDEF;
	}
    break;
case 59:
#line 537 "parser.y"
{
	    if (yyvsp[-1].immediates != NULL)
	    {
                yyval.type = yyvsp[-3].type;
                while (--yyvsp[-1].immediates[0]) yyval.type = new ArrayCType(yyval.type, yyvsp[-1].immediates[yyvsp[-1].immediates[0]+1]);
                
                if (yyvsp[-1].immediates[1] >= 0)
                {
                    yyval.type = new ArrayCType(yyval.type, yyvsp[-1].immediates[yyvsp[-1].immediates[0]+1]);
                }
                else
                {
                    yyval.type->indirection_count++;
                    yyval.type->modifiers |= CType::M_POINTER;
                }
	    }
	    else
	    {
		yyvsp[-3].type->indirection_count++;
		yyvsp[-3].type->modifiers |= CType::M_POINTER;
                yyval.type = yyvsp[-3].type;
	    }
            yyval.type->alias = yyvsp[-2].str->val;
            yyval.type->modifiers |= CType::M_TYPEDEF;
	}
    break;
case 60:
#line 563 "parser.y"
{
            yyval.type = yyvsp[-1].arg->type;
	    yyval.type->comment = yyvsp[-2].str->comment;
	    yyval.type->alias = yyvsp[-1].arg->name;
	    yyval.type->modifiers |= CType::M_TYPEDEF;
	}
    break;
case 61:
#line 569 "parser.y"
{ yyval.type = yyvsp[-1].type; }
    break;
case 62:
#line 574 "parser.y"
{
	    yyval.type = new EnumCType(yyvsp[-4].str->comment, yyvsp[-3].str->val, yyvsp[-1].arg);
	}
    break;
case 63:
#line 578 "parser.y"
{
	    char buf[32];
	    sprintf(buf, "anon%d", local.serial++);
	    yyval.type = new EnumCType(yyvsp[-3].str->comment, global.pool.add(buf), yyvsp[-1].arg);
	}
    break;
case 64:
#line 586 "parser.y"
{ yyval.arg = yyvsp[0].arg; }
    break;
case 65:
#line 588 "parser.y"
{
	    yyval.arg = yyvsp[0].arg;
	    if (yyvsp[-2].arg)
	    {
	        Arg* a = yyvsp[-2].arg;
		while (a->next) a = a->next;
		a->next = yyvsp[0].arg;
		yyval.arg = yyvsp[-2].arg;
	    }
	}
    break;
case 66:
#line 602 "parser.y"
{
	    yyval.arg = new Arg(yyvsp[-1].str->comment, yyvsp[-1].str->val, NULL);
	    if (yyvsp[0].str)
	    {
		yyval.arg->default_value = yyvsp[0].str->val;
	    }
	}
    break;
case 67:
#line 613 "parser.y"
{
	    yyval.str = NULL;
	}
    break;
case 68:
#line 616 "parser.y"
{ local.copy_enum = 1; }
    break;
case 69:
#line 617 "parser.y"
{
            yyval.str = yyvsp[0].str;
        }
    break;
case 70:
#line 624 "parser.y"
{
	    yyval.method = yyvsp[0].method;
	    if (yyval.method)
	    {
		yyval.method->type = new CreateCType(yyvsp[-1].str->comment, CType::M_DTOR);
		yyval.method->comment = yyvsp[-1].str->comment;
	    }
	}
    break;
case 71:
#line 633 "parser.y"
{
	    yyval.method = yyvsp[0].method;
	    if (yyval.method)
	    {
		yyval.method->type = new CreateCType(yyvsp[-2].str->comment, CType::M_DTOR, CType::M_VIRTUAL);
		yyval.method->comment = yyvsp[-2].str->comment;
	    }
	}
    break;
case 72:
#line 642 "parser.y"
{
	    yyval.method = yyvsp[0].method;
	    if (yyval.method && !yyval.method->is_operator)
	    {
		yyval.method->type = new CreateCType(yyvsp[0].method->comment);
		yyval.method->comment = yyvsp[0].method->comment;
	    }
	}
    break;
case 73:
#line 651 "parser.y"
{
	    yyval.method = yyvsp[0].method;
	    if (yyval.method)
	    {
		yyval.method->type = yyvsp[-1].type;
		yyval.method->comment = yyvsp[-1].type->comment;
	    }
	}
    break;
case 74:
#line 660 "parser.y"
{
	    yyval.method = yyvsp[0].method;
	    if (yyval.method)
	    {
		yyval.method->type = yyvsp[-1].type;
		yyval.method->type->modifiers |= CType::M_VIRTUAL;
		yyval.method->comment = yyvsp[-2].str->comment;
	    }
	}
    break;
case 75:
#line 673 "parser.y"
{
	    yyval.method = new Method(yyvsp[-5].str->comment, yyvsp[-5].str->val, yyvsp[-3].arg);
	    if (yyvsp[-1].immediate) yyval.method->is_const = 1;
	    if (yyvsp[0].immediate) yyval.method->is_pure = 1;
	}
    break;
case 76:
#line 679 "parser.y"
{
            char buf[TOKEN_BUFFER_SIZE];
            sprintf(buf, "op%s", yyvsp[-5].str->val);
	    yyval.method = new Method("", global.pool.add(buf), yyvsp[-3].arg);
            yyval.method->is_operator = 1;
	}
    break;
case 77:
#line 686 "parser.y"
{
	    yyval.method = new Method("", "opCast", yyvsp[-3].arg);
            yyval.method->type = yyvsp[-5].type;
            yyval.method->comment = yyvsp[-5].type->comment;
            yyval.method->is_operator = 1;
	}
    break;
case 78:
#line 696 "parser.y"
{
	    /* remove an arg list which contains a single "void".
	     */
	    yyval.arg = yyvsp[0].arg;
	    if (yyval.arg && yyval.arg->next == NULL &&
		0 == strcmp(yyval.arg->type->CTypeName(), "void"))
	    {
		yyval.arg = NULL;
	    }
	}
    break;
case 79:
#line 710 "parser.y"
{
	    char buf[2];
	    sprintf(buf, "%c", yyvsp[0].immediate);
	    yyval.str = new String(buf);
        }
    break;
case 80:
#line 716 "parser.y"
{
	    char buf[2];
	    sprintf(buf, "%c", yyvsp[0].immediate);
	    yyval.str = new String(buf);
        }
    break;
case 81:
#line 721 "parser.y"
{ yyval.str = yyvsp[0].str; }
    break;
case 82:
#line 722 "parser.y"
{ yyval.str = new String("++"); }
    break;
case 83:
#line 722 "parser.y"
{ yyval.str = new String("--"); }
    break;
case 84:
#line 723 "parser.y"
{ yyval.str = new String("<<"); }
    break;
case 85:
#line 723 "parser.y"
{ yyval.str = new String(">>"); }
    break;
case 86:
#line 724 "parser.y"
{ yyval.str = new String("&&"); }
    break;
case 87:
#line 724 "parser.y"
{ yyval.str = new String("||"); }
    break;
case 88:
#line 725 "parser.y"
{ yyval.str = new String("=="); }
    break;
case 89:
#line 725 "parser.y"
{ yyval.str = new String("!="); }
    break;
case 90:
#line 726 "parser.y"
{ yyval.str = new String("<="); }
    break;
case 91:
#line 726 "parser.y"
{ yyval.str = new String(">="); }
    break;
case 92:
#line 727 "parser.y"
{ yyval.str = new String("->"); }
    break;
case 93:
#line 728 "parser.y"
{ yyval.str = new String("new"); }
    break;
case 94:
#line 728 "parser.y"
{ yyval.str = new String("delete"); }
    break;
case 95:
#line 729 "parser.y"
{ yyval.str = new String("[]"); }
    break;
case 96:
#line 733 "parser.y"
{ yyval.immediate = '&'; }
    break;
case 97:
#line 734 "parser.y"
{ yyval.immediate = '*'; }
    break;
case 98:
#line 735 "parser.y"
{ yyval.immediate = '+'; }
    break;
case 99:
#line 736 "parser.y"
{ yyval.immediate = '-'; }
    break;
case 100:
#line 737 "parser.y"
{ yyval.immediate = '~'; }
    break;
case 101:
#line 738 "parser.y"
{ yyval.immediate = '!'; }
    break;
case 102:
#line 742 "parser.y"
{ yyval.immediate = '/'; }
    break;
case 103:
#line 743 "parser.y"
{ yyval.immediate = '%'; }
    break;
case 104:
#line 744 "parser.y"
{ yyval.immediate = '|'; }
    break;
case 105:
#line 745 "parser.y"
{ yyval.immediate = '<'; }
    break;
case 106:
#line 746 "parser.y"
{ yyval.immediate = '>'; }
    break;
case 107:
#line 747 "parser.y"
{ yyval.immediate = '^'; }
    break;
case 108:
#line 751 "parser.y"
{ yyval.str = new String("="); }
    break;
case 109:
#line 752 "parser.y"
{ yyval.str = new String("*="); }
    break;
case 110:
#line 753 "parser.y"
{ yyval.str = new String("/="); }
    break;
case 111:
#line 754 "parser.y"
{ yyval.str = new String("%="); }
    break;
case 112:
#line 755 "parser.y"
{ yyval.str = new String("+="); }
    break;
case 113:
#line 756 "parser.y"
{ yyval.str = new String("-="); }
    break;
case 114:
#line 757 "parser.y"
{ yyval.str = new String("<<="); }
    break;
case 115:
#line 758 "parser.y"
{ yyval.str = new String(">>="); }
    break;
case 116:
#line 759 "parser.y"
{ yyval.str = new String("&="); }
    break;
case 117:
#line 760 "parser.y"
{ yyval.str = new String("^="); }
    break;
case 118:
#line 761 "parser.y"
{ yyval.str = new String("|="); }
    break;
case 119:
#line 764 "parser.y"
{ yyval.str = yyvsp[0].str; }
    break;
case 120:
#line 767 "parser.y"
{ yyval.str = NULL; }
    break;
case 121:
#line 768 "parser.y"
{ yyval.str = yyvsp[-1].str; }
    break;
case 122:
#line 772 "parser.y"
{ yyval.str = yyvsp[0].str; }
    break;
case 123:
#line 774 "parser.y"
{
	    char* buf = new char[8 + strlen(yyvsp[-2].str->val) + strlen(yyvsp[0].str->val)];
	    sprintf(buf, "%s::%s", yyvsp[-2].str->val, yyvsp[0].str->val);
	    yyval.str = new String(yyvsp[-2].str->comment, buf);
	    delete[] buf;
	}
    break;
case 124:
#line 783 "parser.y"
{ yyval.immediate = 0; }
    break;
case 125:
#line 784 "parser.y"
{ yyval.immediate = yyvsp[-1].immediate; }
    break;
case 126:
#line 785 "parser.y"
{ local.eatc = 1; }
    break;
case 127:
#line 785 "parser.y"
{ yyval.immediate = 0; }
    break;
case 128:
#line 786 "parser.y"
{ yyval.immediate = 1; }
    break;
case 129:
#line 789 "parser.y"
{ yyval.immediate = 0; }
    break;
case 130:
#line 789 "parser.y"
{ yyval.immediate = 1; }
    break;
case 135:
#line 795 "parser.y"
{ }
    break;
case 136:
#line 798 "parser.y"
{ yyval.arg = NULL; }
    break;
case 137:
#line 799 "parser.y"
{ yyval.arg = yyvsp[0].arg; }
    break;
case 138:
#line 801 "parser.y"
{
	    yyval.arg = yyvsp[0].arg;
	    if (yyvsp[-2].arg)
	    {
		yyvsp[-2].arg->next = yyval.arg;
		yyval.arg = yyvsp[-2].arg;
	    }
	}
    break;
case 139:
#line 813 "parser.y"
{
	    char buf[32];
	    sprintf(buf, "temp%d", local.serial++);
	    yyval.arg = new Arg(yyvsp[-1].type->comment, global.pool.add(buf), yyvsp[-1].type);
	    if (yyvsp[0].str)
	    {
		yyval.arg->default_value = yyvsp[0].str->val;
	    }
	}
    break;
case 140:
#line 823 "parser.y"
{
	    yyval.arg = new Arg(yyvsp[-2].type->comment, yyvsp[-1].str->val, yyvsp[-2].type);
	    if (yyvsp[0].str)
	    {
		yyval.arg->default_value = yyvsp[0].str->val;
	    }
	}
    break;
case 141:
#line 831 "parser.y"
{
	    if (yyvsp[0].immediates != NULL)
	    {
                while (--yyvsp[0].immediates[0]) yyvsp[-2].type = new ArrayCType(yyvsp[-2].type, yyvsp[0].immediates[yyvsp[0].immediates[0]+1]);
                
                if (yyvsp[0].immediates[1] >= 0)
                {
                    yyvsp[-2].type = new ArrayCType(yyvsp[-2].type, yyvsp[0].immediates[yyvsp[0].immediates[0]+1]);
                }
                else
                {
                    yyvsp[-2].type->indirection_count++;
                    yyvsp[-2].type->modifiers |= CType::M_POINTER;
                }
	    }
	    else
	    {
		yyvsp[-2].type->indirection_count++;
		yyvsp[-2].type->modifiers |= CType::M_POINTER;
	    }
            if (strlen(yyvsp[-1].str->val) == 0)
            {
                char buf[32];
                sprintf(buf, "temp%d", local.serial++);
                yyvsp[-1].str->val = global.pool.add(buf);
            }
            yyval.arg = new Arg(yyvsp[-2].type->comment, yyvsp[-1].str->val, yyvsp[-2].type);
	}
    break;
case 142:
#line 860 "parser.y"
{
	    yyval.arg = yyvsp[0].arg;
	}
    break;
case 143:
#line 864 "parser.y"
{
	    CType* ct = new CType("", CType::M_VARARG);
	    yyval.arg = new Arg("", "...", ct);
	}
    break;
case 144:
#line 872 "parser.y"
{
	    FunctionCType* ct = new FunctionCType(yyvsp[-4].type, yyvsp[-1].arg);
            ct->indirection_count -= yyvsp[-4].type->indirection_count;
	    yyval.arg = new Arg(yyvsp[-4].type->comment, yyvsp[-3].str->val, ct);
	}
    break;
case 145:
#line 878 "parser.y"
{
	    FunctionCType* ct = new FunctionCType(yyvsp[-6].type, yyvsp[-1].arg);
            ct->indirection_count -= yyvsp[-6].type->indirection_count;
	    yyval.arg = new Arg(yyvsp[-6].type->comment, yyvsp[-4].str->val, ct);
	}
    break;
case 146:
#line 884 "parser.y"
{
	    FunctionCType* ct = new FunctionCType(yyvsp[-7].type, yyvsp[-1].arg);
            ct->indirection_count -= yyvsp[-7].type->indirection_count - 1;
	    yyval.arg = new Arg(yyvsp[-7].type->comment, yyvsp[-4].str->val, ct);
	}
    break;
case 147:
#line 893 "parser.y"
{
	    yyval.str = NULL;
	}
    break;
case 148:
#line 897 "parser.y"
{
	    char buf[128];
	    sprintf(buf, "%d", yyvsp[0].expr);
	    yyval.str = new String(NULL, buf);
	}
    break;
case 149:
#line 906 "parser.y"
{
	    yyval.arg = new Arg(yyvsp[0].type->comment, "", yyvsp[0].type);
	}
    break;
case 150:
#line 910 "parser.y"
{
	    yyval.arg = new Arg(yyvsp[-2].type->comment, "", yyvsp[-2].type);
	    yyval.arg->next = yyvsp[0].arg;
	}
    break;
case 151:
#line 917 "parser.y"
{ yyval.type = yyvsp[0].type; }
    break;
case 152:
#line 919 "parser.y"
{
	    yyval.type = yyvsp[0].type;
	    yyval.type->comment = yyvsp[-1].type->comment;
	    yyval.type->modifiers |= yyvsp[-1].type->modifiers;
	}
    break;
case 153:
#line 925 "parser.y"
{
	    yyval.type = yyvsp[-1].type;
	    if ( (yyval.type->modifiers && CType::M_POINTER) && (yyvsp[0].type->modifiers & CType::M_CONST) )
		yyval.type->modifiers |= CType::M_PTR_CONST;
	    else
		yyval.type->modifiers |= yyvsp[0].type->modifiers;
	}
    break;
case 154:
#line 933 "parser.y"
{
	    yyval.type = yyvsp[-1].type;
	    yyval.type->comment = yyvsp[-2].type->comment;
	    if ( (yyval.type->modifiers && CType::M_POINTER) && (yyvsp[0].type->modifiers & CType::M_CONST) )
		yyval.type->modifiers |= CType::M_PTR_CONST;
	    else
		yyval.type->modifiers |= yyvsp[0].type->modifiers;
	}
    break;
case 155:
#line 944 "parser.y"
{ yyval.type = yyvsp[0].type; }
    break;
case 156:
#line 946 "parser.y"
{
	    yyval.type = yyvsp[0].type;
	    yyval.type->comment = yyvsp[-1].type->comment;
	    yyval.type->modifiers |= yyvsp[-1].type->modifiers;
	}
    break;
case 157:
#line 954 "parser.y"
{ yyval.type = new CType(yyvsp[0].str->comment, CType::M_CONST); }
    break;
case 158:
#line 955 "parser.y"
{ yyval.type = new CType(yyvsp[0].str->comment, CType::M_STATIC); }
    break;
case 159:
#line 956 "parser.y"
{ yyval.type = new CType(yyvsp[0].str->comment, CType::M_VOLATILE); }
    break;
case 160:
#line 957 "parser.y"
{ yyval.type = new CType(yyvsp[0].str->comment, CType::M_REGISTER); }
    break;
case 161:
#line 958 "parser.y"
{ yyval.type = new CType(yyvsp[0].str->comment); }
    break;
case 162:
#line 962 "parser.y"
{ yyval.type = yyvsp[0].type; }
    break;
case 163:
#line 963 "parser.y"
{ yyval.type = yyvsp[0].type; }
    break;
case 164:
#line 965 "parser.y"
{
	    yyval.type = yyvsp[-1].type;
	    yyval.type->modifiers |= yyvsp[0].immediate;
	    yyval.type->indirection_count++;
	}
    break;
case 165:
#line 974 "parser.y"
{
            /* Array_type_indirections is a pointer to an array of
             * ints specifying the size of each dimension of the
             * array; the number of dimensions is stored in the first
             * element.
             */
            yyval.immediates = (int*)malloc(sizeof(int)*2);
            yyval.immediates[0] = 1;
            yyval.immediates[1] = yyvsp[0].immediate;
        }
    break;
case 166:
#line 985 "parser.y"
{
            yyval.immediates = (int*)realloc(yyvsp[-1].immediates, sizeof(int)*(1+(++yyvsp[-1].immediates[0])));
            yyval.immediates[yyval.immediates[0]] = yyvsp[0].immediate;
        }
    break;
case 167:
#line 992 "parser.y"
{ yyval.immediate = yyvsp[-1].expr; }
    break;
case 168:
#line 996 "parser.y"
{ yyval.type = yyvsp[0].type; }
    break;
case 169:
#line 998 "parser.y"
{
	    yyval.type = yyvsp[0].type;
	    yyval.type->comment = yyvsp[-1].str->comment;
	    yyval.type->modifiers |= CType::M_UNSIGNED;
	}
    break;
case 170:
#line 1003 "parser.y"
{ yyval.type = new PrimitiveCType(yyvsp[0].str->comment, PrimitiveCType::T_FLOAT); }
    break;
case 171:
#line 1004 "parser.y"
{ yyval.type = new PrimitiveCType(yyvsp[0].str->comment, PrimitiveCType::T_DOUBLE); }
    break;
case 172:
#line 1005 "parser.y"
{ yyval.type = new PrimitiveCType(yyvsp[0].str->comment, PrimitiveCType::T_BOOL); }
    break;
case 173:
#line 1006 "parser.y"
{ yyval.type = new VoidCType(yyvsp[0].str->comment); }
    break;
case 174:
#line 1007 "parser.y"
{ yyval.type = yyvsp[0].type; }
    break;
case 175:
#line 1008 "parser.y"
{ yyval.type = yyvsp[0].type; }
    break;
case 176:
#line 1013 "parser.y"
{
	    yyval.type = new ObjectCType(yyvsp[0].str->comment, yyvsp[0].str->val,
		global.pool.add(local.source_file));
	}
    break;
case 177:
#line 1018 "parser.y"
{
	    yyval.type = new ObjectCType(yyvsp[0].str->comment, yyvsp[0].str->val,
		global.pool.add(local.source_file));
	}
    break;
case 178:
#line 1023 "parser.y"
{
	    yyval.type = new ObjectCType(yyvsp[0].str->comment, yyvsp[0].str->val,
		global.pool.add(local.source_file));
	}
    break;
case 179:
#line 1028 "parser.y"
{
	    ObjectCType* t = new ObjectCType(yyvsp[-3].str->comment, yyvsp[-3].str->val,
		global.pool.add(local.source_file));
	    t->args = yyvsp[-1].arg; // make it a template expansion
	    yyval.type = t;
	}
    break;
case 180:
#line 1037 "parser.y"
{ yyval.immediate = CType::M_POINTER; }
    break;
case 181:
#line 1038 "parser.y"
{ yyval.immediate = CType::M_REFERENCE; }
    break;
case 182:
#line 1043 "parser.y"
{
	    yyval.type = new PrimitiveCType(yyvsp[0].str->comment, PrimitiveCType::T_CHAR);
	}
    break;
case 183:
#line 1047 "parser.y"
{
	    yyval.type = new PrimitiveCType(yyvsp[0].str->comment, PrimitiveCType::T_INT);
	}
    break;
case 184:
#line 1051 "parser.y"
{
	    yyval.type = new PrimitiveCType(yyvsp[-1].str->comment, PrimitiveCType::T_SHORT);
	}
    break;
case 185:
#line 1055 "parser.y"
{
	    yyval.type = new PrimitiveCType(yyvsp[-1].str->comment, PrimitiveCType::T_LONG);
	}
    break;
case 187:
#line 1060 "parser.y"
{}
    break;
case 189:
#line 1061 "parser.y"
{}
    break;
case 190:
#line 1061 "parser.y"
{}
    break;
case 191:
#line 1064 "parser.y"
{ local.public_scope = PUBLIC; }
    break;
case 192:
#line 1065 "parser.y"
{ local.public_scope = PROTECTED; }
    break;
case 193:
#line 1066 "parser.y"
{ local.public_scope = PRIVATE; }
    break;
case 194:
#line 1070 "parser.y"
{ yyval.expr = -1; }
    break;
case 195:
#line 1071 "parser.y"
{ yyval.expr = yyvsp[0].expr; }
    break;
case 196:
#line 1074 "parser.y"
{}
    break;
case 197:
#line 1075 "parser.y"
{}
    break;
case 203:
#line 1086 "parser.y"
{ yyval.expr = -1; }
    break;
case 205:
#line 1091 "parser.y"
{ yyval.expr = yyvsp[-2].expr || yyvsp[0].expr ? 1 : 0; }
    break;
case 207:
#line 1096 "parser.y"
{ yyval.expr = yyvsp[-2].expr && yyvsp[0].expr ? 1 : 0; }
    break;
case 209:
#line 1101 "parser.y"
{ yyval.expr = yyvsp[-2].expr | yyvsp[0].expr; }
    break;
case 211:
#line 1106 "parser.y"
{ yyval.expr = yyvsp[-2].expr ^ yyvsp[0].expr; }
    break;
case 213:
#line 1111 "parser.y"
{ yyval.expr = yyvsp[-2].expr & yyvsp[0].expr; }
    break;
case 215:
#line 1116 "parser.y"
{ yyval.expr = yyvsp[-2].expr == yyvsp[0].expr ? 1 : 0; }
    break;
case 216:
#line 1117 "parser.y"
{ yyval.expr = yyvsp[-2].expr != yyvsp[0].expr ? 1 : 0; }
    break;
case 218:
#line 1122 "parser.y"
{ yyval.expr = yyvsp[-2].expr < yyvsp[0].expr ? 1 : 0; }
    break;
case 219:
#line 1123 "parser.y"
{ yyval.expr = yyvsp[-2].expr > yyvsp[0].expr ? 1 : 0; }
    break;
case 220:
#line 1124 "parser.y"
{ yyval.expr = yyvsp[-2].expr << yyvsp[0].expr; }
    break;
case 221:
#line 1125 "parser.y"
{ yyval.expr = yyvsp[-2].expr >> yyvsp[0].expr; }
    break;
case 223:
#line 1130 "parser.y"
{ yyval.expr = yyvsp[-2].expr << yyvsp[0].expr; }
    break;
case 224:
#line 1131 "parser.y"
{ yyval.expr = yyvsp[-2].expr >> yyvsp[0].expr; }
    break;
case 226:
#line 1136 "parser.y"
{ yyval.expr = yyvsp[-2].expr + yyvsp[0].expr; }
    break;
case 227:
#line 1137 "parser.y"
{ yyval.expr = yyvsp[-2].expr - yyvsp[0].expr; }
    break;
case 229:
#line 1143 "parser.y"
{ yyval.expr = yyvsp[-2].expr * yyvsp[0].expr; }
    break;
case 230:
#line 1144 "parser.y"
{ yyval.expr = yyvsp[-2].expr / yyvsp[0].expr; }
    break;
case 231:
#line 1145 "parser.y"
{ yyval.expr = yyvsp[-2].expr % yyvsp[0].expr; }
    break;
case 233:
#line 1150 "parser.y"
{ yyval.expr = yyvsp[0].expr; }
    break;
case 235:
#line 1155 "parser.y"
{ yyval.expr = yyvsp[0].expr++; }
    break;
case 236:
#line 1156 "parser.y"
{ yyval.expr = yyvsp[0].expr--; }
    break;
case 237:
#line 1158 "parser.y"
{
	    switch(yyvsp[-1].immediate) {
		case '&':
		case '*':
		    yyval.expr = -1;
		    break;

		case TILDE:
		    yyval.expr = ~ yyvsp[0].expr;
		    break;

		case '!':
		    yyval.expr = ! yyvsp[0].expr;
		    break;

		case '+':
		    yyval.expr = yyvsp[0].expr;
		    break;

		case '-':
		    yyval.expr = - yyvsp[0].expr;
		    break;
		
		default:
		    printf("  cxxwrap internal error at \"%s\":%d, token %c\n",
			__FILE__, __LINE__, yyvsp[-1].immediate);
		    yyval.expr = -1;
		    break;
	    }
	}
    break;
case 238:
#line 1188 "parser.y"
{ yyval.expr = -1; }
    break;
case 239:
#line 1189 "parser.y"
{ yyval.expr = -1; }
    break;
case 241:
#line 1194 "parser.y"
{ yyval.expr = -1; }
    break;
case 242:
#line 1195 "parser.y"
{ yyval.expr = -1; }
    break;
case 243:
#line 1196 "parser.y"
{ yyval.expr = -1; }
    break;
case 244:
#line 1197 "parser.y"
{ yyval.expr = -1; }
    break;
case 245:
#line 1198 "parser.y"
{ yyval.expr = yyvsp[-1].expr++; }
    break;
case 246:
#line 1199 "parser.y"
{ yyval.expr = yyvsp[-1].expr--; }
    break;
case 247:
#line 1204 "parser.y"
{
	    /* handle NULL as "0", even though this is not
	       strictly true by ANSI rules, it is always the case
	       on "all" systems. */

	    if (0 == strcmp(yyvsp[0].str->val, "NULL"))
	    {
		yyval.expr = 0;
	    }
	    else
	    {
		yyval.expr = -1;
	    }
	}
    break;
case 248:
#line 1218 "parser.y"
{ yyval.expr = -1; }
    break;
case 249:
#line 1219 "parser.y"
{ yyval.expr = (int) yyvsp[0].number->val; }
    break;
case 250:
#line 1221 "parser.y"
{
	    /* Map string constants to NULL, as well...
	       Not much useful we can do with them here. */

	    yyval.expr = 0;
	}
    break;
case 251:
#line 1227 "parser.y"
{ yyval.expr = yyvsp[-1].expr; }
    break;
case 252:
#line 1231 "parser.y"
{}
    break;
case 253:
#line 1232 "parser.y"
{}
    break;
}

#line 705 "/usr/local/share/bison/bison.simple"


  yyvsp -= yylen;
  yyssp -= yylen;
#if YYLSP_NEEDED
  yylsp -= yylen;
#endif

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

  *++yyvsp = yyval;
#if YYLSP_NEEDED
  *++yylsp = yyloc;
#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 |
`------------------------------------*/
yyerrlab:
  /* If not already recovering from an error, report this error.  */
  if (!yyerrstatus)
    {
      ++yynerrs;

#ifdef YYERROR_VERBOSE
      yyn = yypact[yystate];

      if (yyn > YYFLAG && yyn < YYLAST)
	{
	  YYSIZE_T yysize = 0;
	  char *yymsg;
	  int yyx, yycount;

	  yycount = 0;
	  /* Start YYX at -YYN if negative to avoid negative indexes in
	     YYCHECK.  */
	  for (yyx = yyn < 0 ? -yyn : 0;
	       yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
	    if (yycheck[yyx + yyn] == yyx)
	      yysize += yystrlen (yytname[yyx]) + 15, yycount++;
	  yysize += yystrlen ("parse error, unexpected ") + 1;
	  yysize += yystrlen (yytname[YYTRANSLATE (yychar)]);
	  yymsg = (char *) YYSTACK_ALLOC (yysize);
	  if (yymsg != 0)
	    {
	      char *yyp = yystpcpy (yymsg, "parse error, unexpected ");
	      yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]);

	      if (yycount < 5)
		{
		  yycount = 0;
		  for (yyx = yyn < 0 ? -yyn : 0;
		       yyx < (int) (sizeof (yytname) / sizeof (char *));
		       yyx++)
		    if (yycheck[yyx + yyn] == yyx)
		      {
			const char *yyq = ! yycount ? ", expecting " : " or ";
			yyp = yystpcpy (yyp, yyq);
			yyp = yystpcpy (yyp, yytname[yyx]);
			yycount++;
		      }
		}
	      yyerror (yymsg);
	      YYSTACK_FREE (yymsg);
	    }
	  else
	    yyerror ("parse error; also virtual memory exhausted");
	}
      else
#endif /* defined (YYERROR_VERBOSE) */
	yyerror ("parse error");
    }
  goto yyerrlab1;


/*--------------------------------------------------.
| yyerrlab1 -- error raised explicitly by an action |
`--------------------------------------------------*/
yyerrlab1:
  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;
      YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
		  yychar, yytname[yychar1]));
      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.                                                       |
`-------------------------------------------------------------------*/
yyerrdefault:
#if 0
  /* This is wrong; only states that explicitly want error tokens
     should shift them.  */

  /* If its default is to accept any token, ok.  Otherwise pop it.  */
  yyn = yydefact[yystate];
  if (yyn)
    goto yydefault;
#endif


/*---------------------------------------------------------------.
| yyerrpop -- pop the current state because it cannot handle the |
| error token                                                    |
`---------------------------------------------------------------*/
yyerrpop:
  if (yyssp == yyss)
    YYABORT;
  yyvsp--;
  yystate = *--yyssp;
#if YYLSP_NEEDED
  yylsp--;
#endif

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

/*--------------.
| yyerrhandle.  |
`--------------*/
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;

  YYDPRINTF ((stderr, "Shifting error token, "));

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

  yystate = yyn;
  goto yynewstate;


/*-------------------------------------.
| yyacceptlab -- YYACCEPT comes here.  |
`-------------------------------------*/
yyacceptlab:
  yyresult = 0;
  goto yyreturn;

/*-----------------------------------.
| yyabortlab -- YYABORT comes here.  |
`-----------------------------------*/
yyabortlab:
  yyresult = 1;
  goto yyreturn;

/*---------------------------------------------.
| yyoverflowab -- parser overflow comes here.  |
`---------------------------------------------*/
yyoverflowlab:
  yyerror ("parser stack overflow");
  yyresult = 2;
  /* Fall through.  */

yyreturn:
#ifndef yyoverflow
  if (yyss != yyssa)
    YYSTACK_FREE (yyss);
#endif
  return yyresult;
}
#line 1240 "parser.y"


static struct {
  char *s;
  int n;
} lextable[] = {
  {"if", IF},
  {"else", ELSE},
  {"then", THEN},
  {"enum", ENUM},
  {"class", CLASS},
  {"public", PUBLIC},
  {"private", PRIVATE},
  {"protected", PROTECTED},
  {"new", NEW},
  {"delete", DELETE},
  {"virtual", VIRTUAL},
  {"volatile", VOLATILE},
  {"register", REGISTER},
  {"template", TEMPLATE},
  {"int", INT},
  {"float", FLOAT},
  {"short", SHORT},
  {"long", LONG},
  {"double", DOUBLE},
  {"void", VOID},
  {"char", CHAR},
  {"bool", BOOL},
  {"const", CONST},
  {"operator", OPERATOR},
  {"typedef", TYPEDEF},
  {"unsigned", UNSIGNED},
  {"friend", FRIEND},
  {"static", STATIC},
  {"sizeof", SIZEOF},
  {"struct", STRUCT},
  {"union", UNION},
  {"return", RETURN},
  {"inline", INLINE},
  {"extern", EXTERN},
  {NULL, 0}
};

/* Get the next character from the lexical source.
 */
int Lexer::get()
{
      lastc = c;
      c = EOF;

      switch(type)
      {
	case SRC_FILE:
	  if (ungetp > 0)
	  {
	    c = ungetbuf[--ungetp];
	  }
	  else
	  {
	    c = fgetc(source.f);
	  }
	  if(c != EOF) (ch)++;
	  break;

	case SRC_STRING:
	  if(eof || source.s[ch] == '\0') {
	    if(eof)
	      c = EOF;
	    else {
	      /* add an extra newline the first time */
	      c = '\n';
	      eof = 1;
	    }
	  }
	  else {
	    c = source.s[(ch)++];
	  }
	  break;
      }

      if(c == '\n') (line)++;

    return c;
}

void Lexer::unget(int cc)
{
	if(type == SRC_FILE)
	{
	    ungetbuf[ungetp++] = cc;
	    //ungetc(cc, source.f);
	}

	if(cc == '\n') --(line);

	if (eof) 
	  eof = 0;
	else
	  --(ch);
}

int Lexer::getNumber(double *d)
{
	int cc, occ = 0, l = 0;

	static const char* base10 = "+-.e01234567890fFuUlL";
	static const char* base16 = "+-01234567890ABCDEFabcdef";
	const char* ok = base10;

	while((cc = get()) != EOF && l < (LEXER_BUFLEN - 2))
	{
	    if (l == 1 && occ == '0' && (cc == 'x' || cc == 'X'))
	    {
		ok = base16;
	    }
	    else if (!strchr(ok, cc))
	    {
		break;
	    }

	    resultbuf[l++] = cc;
	    resultbuf[l] = '\0'; // always keep it terminated
	    if (l == 3 && strcmp("...", resultbuf) == 0)
		return 0;

	    occ = cc;
	}

	if (cc != EOF) unget(cc);

	resultbuf[l] = '\0';

	if (ok == base10)
	{
	    if (sscanf(resultbuf, "%lf", d) == 1) return 1;
	}
	else 
	{
	    int r;
	    if (sscanf(resultbuf, "%x", &r) == 1)
	    {
		*d = r;
		return 1;
	    }
	}

	return 0;
}

int Lexer::matchKeyword(char *keyword)
{
	int i;
	unsigned int l = strlen(keyword);

	for (i = 0; lextable[i].s != NULL; i++)
	{
	    unsigned int tl = strlen(lextable[i].s);
	    if (l == tl && strncmp(keyword, lextable[i].s, l) == 0)
	    {
		return i;
	    }
	}

	return -1;
}

#define isokforid(CHAR) (isalnum(CHAR) || (CHAR) == '_' || (CHAR) == '.')

static int lex_kernel(YYSTYPE* val)
{
    int i, c, which;
    double sign = 1.0;

    static int buflen = 0;
    static char *buf = NULL;

    /* eat white space */
    while ((c = local.lex.get()) == ' ' || c == '\t' || c == '\n');

    val->str = NULL;

    if (c == EOF) return 0;

    if (c == '#' && local.lex.last() == '\n')
    {
	i = 0;
	while ((c = local.lex.get()) != EOF && c != '\n')
	{
	    if (i >= (buflen - 2)) {
		buflen += 64;
		buf = (char*) realloc(buf, buflen * sizeof(char));
	    }
	    buf[i++] = c;
	}
	buf[i] = '\0';
	val->str = new String(NULL, buf);
	return CPP_DIRECTIVE;
    }

    // lexical tie-in for generating CTEXT operand...

    if (local.eatc)
    {
	int depth = 1;
	while (depth > 0 && c != EOF)
	{
	    if (c == '{') depth++;
	    if (c == '}') depth--;
	    c = local.lex.get();
	}

	local.eatc = 0; // automatically shut it off

	val->str = NULL;
	return CTEXT;
    }

    // Get enums as text
    if (local.copy_enum)
    {
        int i = 0, last = 0;
        char enum_buf[TOKEN_BUFFER_SIZE];
        while (c != '}' && c != ',' && c != EOF)
        {
            // Replace '\n' and '\t' with ' '
            if (c == '\n' || c == '\t') c = ' ';

            // Skip consecutive spaces
            if (last == ' ' && c == ' ')
            {
                c = local.lex.get();
                continue;
            }

            enum_buf[i++] = c;
            last = c;
            c = local.lex.get();
        }

        // If there is a trailing space, remove it
        if (i > 0 && enum_buf[i-1] == ' ') i--;
        
        enum_buf[i] = '\0'; // Strings are NULL-terminated
        local.lex.unget(c); // The parser also needs to see the terminating char
        local.copy_enum = 0; // automatically shut it off

        val->str = new String(NULL, global.pool.add(enum_buf));
        return CTEXT;
    }

    // oh, I need these to get comments on destructors, kachunk...

    if (c == '~')
    {
	val->str = new String(NULL, "~");
	return TILDE;
    }

    /* These can start a number, or be codes of their own.
     */
    if (c == '+' || c == '-') 
    {
        int csave = c;
        c = local.lex.get();
        if(c == '.' || isdigit(c)) {
	    sign = (csave == '-' ? -1.0 : + 1.0);
        }
	else if (csave == '-' && c == '>')
	{
	    // the arrow can be detected lexically
	    return ARROW;
	}
	else if (csave == c)
	{
	    return (c == '+' ? PLUSPLUS : MINUSMINUS);
	}
	else if (c == '=')
	{
	    return (csave == '+' ? PLUSEQUALS : MINUSEQUALS);
	}
        else
	{
	    local.lex.unget(c);
	    return csave;
        }
    }

    if (c == '>' || c == '<')
    {
	int csave = c;
	c = local.lex.get();
	if (c == csave)
	{
	    return (c == '<' ? LEFTLEFT : RIGHTRIGHT);
	}
	if (c == '=')
	{
	    return (csave == '<' ? LEFTEQUALS : RIGHTEQUALS);
	}
	local.lex.unget(c);
	return csave;
    }

    if (c == '&' || c == '|')
    {
	int csave = c;
	c = local.lex.get();
	if (c == csave)
	{
	    return (c == '&' ? ANDAND : OROR);
	}
	if (c == '=')
	{
	    return (csave == '&' ? ANDEQUALS : OREQUALS);
	}
	local.lex.unget(c);
	return csave;
    }

    if (c == '=')
    {
	int csave = c;
	c = local.lex.get();
	if (c == '=')
	{
	    return EQUALSEQUALS;
	}
	local.lex.unget(c);
	return csave;
    }

    if (c == ':')
    {
	int csave = c;
	c = local.lex.get();
	if (c == ':')
	{
	    return COLONCOLON;
	}
	local.lex.unget(c);
	return csave;
    }

    if (c == '!')
    {
	int csave = c;
	c = local.lex.get();
	if (c == '=')
	{
	    return NOTEQUALS;
	}
	local.lex.unget(c);
	return csave;
    }

    if (c == '.' || isdigit(c))
    {
	local.lex.unget(c);
	double d;
	if(local.lex.getNumber(&d) == 1)
	{
	    d *= sign;
	    val->number = new Number(NULL, d, local.lex.resultbuf);
	    return NUM;
	}
	else if (strcmp("...", local.lex.resultbuf) == 0)
	{
	    return ELLIPSIS;
	}
	return c; // try to revover...
    }

    if (c == '/')
    {
	int csave = c;
	c = local.lex.get();
	if (c == '=')
	{
	    return SLASHEQUALS;
	}
	if (c == '/')
	{
	    i = 0;
	    for(;;)
	    {
		// build comment text from the line
		while ((c = local.lex.get()) != EOF && c != '\n')
		{
		    if (i >= (buflen - 2)) {
			buflen += 64;
			buf = (char*) realloc(buf, buflen * sizeof(char));
		    }
		    buf[i++] = c;
		}

		// eat white space to see if we get another slash-slash
		while ((c = local.lex.get()) == ' ' || c == '\t');
		if (c != '/')
		{
		    local.lex.unget(c);
		    break;
		}
		else
		{
		    if ((c = local.lex.get()) != '/')
		    {
			local.lex.unget(c);
			local.lex.unget('/');
			break;
		    }
		    if (i >= (buflen - 2)) {
			buflen += 64;
			buf = (char*) realloc(buf, buflen * sizeof(char));
		    }
		    buf[i++] = '\n';
		}
	    }
	    local.lex.unget('\n'); // put back to help parsing cpp directives
	    buf[i] = '\0';
	    val->str = new String(NULL, buf);
	    return COMMENT;
	}
	else if (c == '*')
	{
	    i = 0;
	    int sawstar = 0;
	    while ((c = local.lex.get()) != EOF)
	    {
		if (sawstar && c == '/') break;
		if (i >= buflen) {
		    buflen += 64;
		    buf = (char*) realloc(buf, buflen * sizeof(char));
		}
		buf[i++] = c;
		sawstar = c == '*' ? 1 : 0;
	    }
	    buf[i - 1] = '\0';
	    val->str = new String(NULL, buf);
	    return COMMENT;
	}
	else
	{
	    local.lex.unget(c);
	    return csave;
	}
    }

    if (c == '*')
    {
	int csave = c;
	c = local.lex.get();
	if (c == '=')
	{
	    return STAREQUALS;
	}
	local.lex.unget(c);
	return csave;
    }

    if(isalpha(c) || c == '_')
    {
	i = 0;
	while (c != EOF && isokforid(c))
	{
	    if (i >= buflen) {
		buflen += 64;
		buf = (char*) realloc(buf, buflen * sizeof(char));
	    }
	    buf[i++] = c;
	    c = local.lex.get();
	}

	local.lex.unget(c);
	buf[i] = '\0';

	/* If this is a keyword, return the proper code */
	if ((which = local.lex.matchKeyword(buf)) >= 0) {
	    val->str = new String(NULL, buf);
	    return lextable[which].n;
	}

	/* Finally, it must be a new identifier */
	val->str = new String(NULL, buf);
	return IDENTIFIER;
    }

    if(c == '"')
    {
	i = 0;
	do {
	    c = local.lex.get();
	    if(i >= buflen) {
		buflen += 64;
		buf = (char*) realloc(buf, buflen * sizeof(char));
	    }

	    if(c == '\\') {
		int cc = local.lex.get();
		switch(cc) {
		    case 't': cc = '\t'; break;
		    case 'n': cc = '\n'; break;
		    default: break;
		}
		buf[i++] = cc;
	    }
	    else
	    {
		buf[i++] = c;
	    }

	} while(c != EOF && c != '"');

	buf[i - 1] = '\0';
	val->str = new String(NULL, buf);
	return STRING;
    }

    return c;
}

static int lex_no_context(YYSTYPE* val)
{
    String* latest_comment = NULL;
    int s;
    while ((s = lex_kernel(val)) == COMMENT || s == CPP_DIRECTIVE) 
    {
	if (s == COMMENT)
	{
	    latest_comment = val->str;
	    if (local.trace)
	    {
		printf("{comment} ");
	    }
	}
    }

    if (local.trace)
    {
	int i;
	int found = 0;
	for (i = 0; lextable[i].s != NULL; i++) {
	    if(s == lextable[i].n) {
		printf("[%s] ", lextable[i].s);
		found = 1;
		break;
	    }
	}
	
	if (!found) {
	    switch (s) {
	    case STRING: printf("[\"%s\"] ", val->str->val); break;
	    case IDENTIFIER: printf("<%s> ", val->str->val); break;
	    case NUM: printf("#%s=%.2f ", val->number->strval, val->number->val); break;
	    case TILDE: printf("(~) "); break;
	    case ARROW: printf("(->) "); break;
	    case ELLIPSIS: printf("(...) "); break;
	    case COMMENT: printf("{comment} "); break;
	    case CPP_DIRECTIVE: printf("[cpp %s] ", val->str->val); break;
	    case CTEXT: printf("[ctext] "); break;
	    case COLONCOLON: printf("(::) "); break;
	    case PLUSEQUALS: printf("(+=) "); break;
	    case MINUSEQUALS: printf("(-=) "); break;
	    case PLUSPLUS: printf("(++) "); break;
	    case MINUSMINUS: printf("(--) "); break;
	    case STAREQUALS: printf("(*=)"); break;
	    case SLASHEQUALS: printf("(/=)"); break;
	    case LEFTEQUALS: printf("(<=)"); break;
	    case RIGHTEQUALS: printf("(>=)"); break;
	    case LEFTLEFT: printf("(<<)"); break;
	    case RIGHTRIGHT: printf("(>>)"); break;
	    case ANDAND: printf("(&&)"); break;
	    case OROR: printf("(||)"); break;
	    case OREQUALS: printf("(|=)"); break;
	    case ANDEQUALS: printf("(&=)"); break;
	    default: printf("(%c) ", s); break;
	    }
	}
	fflush(stdout);
    }

    if (latest_comment)
    {
	switch(s) {
	    case NUM:
		val->number->comment = latest_comment->val;
		break;

	    default:
		if (val->str)
		    val->str->comment = latest_comment->val; 
		break;
	}
	if (local.trace) printf("{assigned comment} ");
    }

    return s;
}

static int myyylex(void)
{ 
    return lex_no_context(&yylval);
}

static const char* msg(const char *s)
{
    static char buf[256];

    if (local.lex.type == Lexer::SRC_STRING)
    {
        int first, last, c;
        first = local.lex.ch - 16;
        if(first < 0) first = 0;
        for(last = first; last < first + 32; last++)
	    if (local.lex.source.s[last] == '\0' ||
		local.lex.source.s[last] == '\n') break;
        c = local.lex.source.s[last];
        local.lex.source.s[last] = '\0';

        sprintf(buf, "%s (line %d) near \"%s\"\n",
	    s, local.lex.line + 1, local.lex.source.s + first);
        local.lex.source.s[last] = c;
    }
    else
    {
        sprintf(buf, "%s (\"%s\":%d)\n",
	    s, local.source_file, local.lex.line + 1);
    }

    return buf;
}

static void myyyerror(const char* /* s */)
{
    local.nerror++;
    if (global.verbose || local.trace)
    {
	/* ignore the passed string, which says "parse error"
	 * or some such.
	 */
	printf("  %s", msg("syntax not parsed correctly"));
    }
}

static void global_reset()
{
    local.public_scope = PRIVATE;
    local.class_nest = 0;
}

static void push_scope(int s)
{
    if (local.class_nest > MAX_CLASS_NEST)
    {
	printf("  %s", msg("classes nested too deep"));
    }
    else
    {
	local.saved_public_scope[local.class_nest++] = local.public_scope;
	local.public_scope = s;
    }
}

static void pop_scope()
{
    if (local.class_nest < 1)
    {
	printf("  cxxwrap internal error \"%s\":%d\n", __FILE__, __LINE__);
    }
    else
    {
	local.public_scope = local.saved_public_scope[--local.class_nest];
    }
}

static int check_new_classdef(Class* c)
{
    const char* fn = c->fullName();
    if (global.classJar.findClassByName(fn))
    {
	char buf[256];
	sprintf(buf, "duplicate definition for class \"%s\" ignored.\n", fn);
	warning(msg(buf));
	return -1;
    }
    return 0;
}

static int do_scan_cxx_file(FILE *f)
{
    local.serial = 1;
    local.lex.type = Lexer::SRC_FILE;
    local.lex.source.f = f;
    local.lex.line = local.lex.ch = 0;
    local.lex.eof = 0;
    local.lex.c = '\n'; /* to be stored as the last read character */
    local.lex.ungetp = 0;
    local.nerror = 0;
    local.nclassdef = 0;
    local.eatc = 0;
    local.copy_enum = 0;
    local.typedefs.clear();

    global_reset();
    set_warning_context("parsing");

    yyparse();

    set_warning_context(NULL);

    if (local.nclassdef == 0)
	return -1;

    return 0;
}

int scan_cxx_file(const char* root, const char* fn, int trace)
{
    char ffn[FILENAME_MAX];
    if (root)
    {
	sprintf(ffn, "%s%c%s", root, PATHSEP, fn);
    }
    else
    {
	strcpy(ffn, fn);
    }
    FILE* f = fopen(ffn, "r");
    if (!f)
    {
	printf("cannot open file \"%s\"\n", ffn);
	return -1;
    }

    local.trace = trace;

    if (global.verbose)
    {
	printf("scanning \"%s\":\n", fn);
    }
    local.source_file = fn;
    if (do_scan_cxx_file(f) != 0)
    {
	if (global.verbose)
	{
	    printf("  %s", msg("no classes found"));
	}
    }
    fclose(f);
    fflush(stdout);
    return 0;
}
