/* A Bison parser, made by GNU Bison 1.875.  */

/* Skeleton parser for Yacc-like parsing with 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.  */

/* Written by Richard Stallman by simplifying the original so called
   ``semantic'' parser.  */

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

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

/* Skeleton name.  */
#define YYSKELETON_NAME "yacc.c"

/* Pure parsers.  */
#define YYPURE 0

/* Using locations.  */
#define YYLSP_NEEDED 0



/* Tokens.  */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
   /* Put the tokens into the symbol table, so that GDB and other debuggers
      know about them.  */
   enum yytokentype {
     TK_DOC = 258,
     TK_EXPORTEDDOC = 259,
     TK_MAKEFILE = 260,
     TK_ACCESSCODE = 261,
     TK_POSTINITCODE = 262,
     TK_MODCODE = 263,
     TK_TYPECODE = 264,
     TK_PREPYCODE = 265,
     TK_COPYING = 266,
     TK_MAPPEDTYPE = 267,
     TK_CODEBLOCK = 268,
     TK_IF = 269,
     TK_END = 270,
     TK_NAME = 271,
     TK_PATHNAME = 272,
     TK_STRING = 273,
     TK_VIRTUALCATCHERCODE = 274,
     TK_METHODCODE = 275,
     TK_FROMTYPE = 276,
     TK_TOTYPE = 277,
     TK_TOSUBCLASS = 278,
     TK_INCLUDE = 279,
     TK_OPTINCLUDE = 280,
     TK_IMPORT = 281,
     TK_MODHEADERCODE = 282,
     TK_TYPEHEADERCODE = 283,
     TK_MODULE = 284,
     TK_CMODULE = 285,
     TK_CLASS = 286,
     TK_STRUCT = 287,
     TK_PUBLIC = 288,
     TK_PROTECTED = 289,
     TK_PRIVATE = 290,
     TK_SIGNALS = 291,
     TK_SLOTS = 292,
     TK_BOOL = 293,
     TK_SHORT = 294,
     TK_INT = 295,
     TK_LONG = 296,
     TK_FLOAT = 297,
     TK_DOUBLE = 298,
     TK_CHAR = 299,
     TK_VOID = 300,
     TK_PYOBJECT = 301,
     TK_PYTUPLE = 302,
     TK_PYLIST = 303,
     TK_PYDICT = 304,
     TK_PYCALLABLE = 305,
     TK_PYSLICE = 306,
     TK_VIRTUAL = 307,
     TK_ENUM = 308,
     TK_UNSIGNED = 309,
     TK_SCOPE = 310,
     TK_LOGICAL_OR = 311,
     TK_CONST = 312,
     TK_STATIC = 313,
     TK_SIPSIGNAL = 314,
     TK_SIPSLOT = 315,
     TK_SIPRXCON = 316,
     TK_SIPRXDIS = 317,
     TK_SIPSLOTCON = 318,
     TK_SIPSLOTDIS = 319,
     TK_NUMBER = 320,
     TK_REAL = 321,
     TK_TYPEDEF = 322,
     TK_NAMESPACE = 323,
     TK_TIMELINE = 324,
     TK_PLATFORMS = 325,
     TK_FEATURE = 326,
     TK_LICENSE = 327,
     TK_QCHAR = 328,
     TK_TRUE = 329,
     TK_FALSE = 330,
     TK_OPERATOR = 331,
     TK_THROW = 332,
     TK_QOBJECT = 333
   };
#endif
#define TK_DOC 258
#define TK_EXPORTEDDOC 259
#define TK_MAKEFILE 260
#define TK_ACCESSCODE 261
#define TK_POSTINITCODE 262
#define TK_MODCODE 263
#define TK_TYPECODE 264
#define TK_PREPYCODE 265
#define TK_COPYING 266
#define TK_MAPPEDTYPE 267
#define TK_CODEBLOCK 268
#define TK_IF 269
#define TK_END 270
#define TK_NAME 271
#define TK_PATHNAME 272
#define TK_STRING 273
#define TK_VIRTUALCATCHERCODE 274
#define TK_METHODCODE 275
#define TK_FROMTYPE 276
#define TK_TOTYPE 277
#define TK_TOSUBCLASS 278
#define TK_INCLUDE 279
#define TK_OPTINCLUDE 280
#define TK_IMPORT 281
#define TK_MODHEADERCODE 282
#define TK_TYPEHEADERCODE 283
#define TK_MODULE 284
#define TK_CMODULE 285
#define TK_CLASS 286
#define TK_STRUCT 287
#define TK_PUBLIC 288
#define TK_PROTECTED 289
#define TK_PRIVATE 290
#define TK_SIGNALS 291
#define TK_SLOTS 292
#define TK_BOOL 293
#define TK_SHORT 294
#define TK_INT 295
#define TK_LONG 296
#define TK_FLOAT 297
#define TK_DOUBLE 298
#define TK_CHAR 299
#define TK_VOID 300
#define TK_PYOBJECT 301
#define TK_PYTUPLE 302
#define TK_PYLIST 303
#define TK_PYDICT 304
#define TK_PYCALLABLE 305
#define TK_PYSLICE 306
#define TK_VIRTUAL 307
#define TK_ENUM 308
#define TK_UNSIGNED 309
#define TK_SCOPE 310
#define TK_LOGICAL_OR 311
#define TK_CONST 312
#define TK_STATIC 313
#define TK_SIPSIGNAL 314
#define TK_SIPSLOT 315
#define TK_SIPRXCON 316
#define TK_SIPRXDIS 317
#define TK_SIPSLOTCON 318
#define TK_SIPSLOTDIS 319
#define TK_NUMBER 320
#define TK_REAL 321
#define TK_TYPEDEF 322
#define TK_NAMESPACE 323
#define TK_TIMELINE 324
#define TK_PLATFORMS 325
#define TK_FEATURE 326
#define TK_LICENSE 327
#define TK_QCHAR 328
#define TK_TRUE 329
#define TK_FALSE 330
#define TK_OPERATOR 331
#define TK_THROW 332
#define TK_QOBJECT 333




/* Copy the first part of user declarations.  */
#line 16 "parser.y"

#include <stdlib.h>
#include <string.h>

#include "sip.h"


#define	MAX_NESTED_IF		10
#define	MAX_NESTED_SCOPE	10

#define	inMainModule()		(currentSpec -> module == currentModule)


/* The different attribute name types. */
typedef enum {
	func_attr,
	var_attr,
	enum_attr,
	class_attr
} attrType;


static sipSpec *currentSpec;		/* The current spec being parsed. */
static stringList *neededQualifiers;	/* The list of required qualifiers. */
static stringList *excludedQualifiers;	/* The list of excluded qualifiers. */
static moduleDef *currentModule;	/* The current module being parsed. */
static mappedTypeDef *currentMappedType;	/* The current mapped type. */
static enumDef *currentEnum;		/* The current enum being parsed. */
static int sectionFlags;		/* The current section flags. */
static int currentOverIsVirt;		/* Set if the overload is virtual. */
static int currentIsStatic;		/* Set if the current is static. */
static char *previousFile;		/* The file just parsed. */
static parserContext newContext;	/* The new pending context. */
static int skipStackPtr;		/* The skip stack pointer. */
static int skipStack[MAX_NESTED_IF];	/* Stack of skip flags. */
static classDef *scopeStack[MAX_NESTED_SCOPE];	/* The scope stack. */
static int sectFlagsStack[MAX_NESTED_SCOPE];	/* The section flags stack. */
static int currentScopeIdx;		/* The scope stack index. */


static nameDef *cacheName(sipSpec *,char *);
static ifaceFileDef *findIfaceFile(sipSpec *,scopedNameDef *,ifaceFileType,
				   argDef *);
static classDef *findClass(sipSpec *,ifaceFileType,scopedNameDef *);
static classDef *newClass(sipSpec *,ifaceFileType,scopedNameDef *);
static void finishClass(sipSpec *,classDef *,optFlags *);
static mappedTypeDef *newMappedType(sipSpec *,argDef *);
static enumDef *newEnum(sipSpec *,moduleDef *,char *,int);
static void newTypedef(sipSpec *,char *,argDef *);
static void newVar(sipSpec *,moduleDef *,char *,int,argDef *,codeBlock *);
static void newCtor(char *,int,signatureDef *,optFlags *,codeBlock *,
		    throwArgs *,signatureDef *);
static void newFunction(sipSpec *,moduleDef *,int,int,int,char *,
			signatureDef *,int,int,optFlags *,codeBlock *,
			codeBlock *,throwArgs *,signatureDef *);
static optFlag *findOptFlag(optFlags *,char *,flagType);
static memberDef *findFunction(sipSpec *,moduleDef *,classDef *,char *,int,int);
static void checkAttributes(sipSpec *,classDef *,nameDef *,attrType);
static void newModule(FILE *,char *);
static void appendCodeBlock(codeBlock **,codeBlock *);
static void parseFile(FILE *,char *,moduleDef *,int);
static void handleEOF(void);
static void handleEOM(void);
static qualDef *findQualifier(char *);
static scopedNameDef *text2scopedName(char *);
static void pushScope(classDef *);
static void popScope(void);
static classDef *currentScope(void);
static void newQualifier(moduleDef *,int,char *,qualType);
static void newImport(char *);
static void usedInMainModule(sipSpec *,ifaceFileDef *);
static int timePeriod(char *,char *);
static int platOrFeature(char *,int);
static int isNeeded(qualDef *);
static int notSkipping(void);
static void getHooks(optFlags *,char **,char **);
static int getReleaseGIL(optFlags *);


/* Enabling traces.  */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif

/* Enabling verbose error messages.  */
#ifdef YYERROR_VERBOSE
# undef YYERROR_VERBOSE
# define YYERROR_VERBOSE 1
#else
# define YYERROR_VERBOSE 0
#endif

#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
#line 95 "parser.y"
typedef union YYSTYPE {
	char		qchar;
	char		*text;
	long		number;
	double		real;
	argDef		memArg;
	signatureDef	signature;
	signatureDef	*optsignature;
	throwArgs	*throwlist;
	codeBlock	*codeb;
	valueDef	value;
	valueDef	*valp;
	optFlags	optflags;
	optFlag		flag;
	scopedNameDef	*scpvalp;
	fcallDef	fcall;
	int		boolean;
} YYSTYPE;
/* Line 191 of yacc.c.  */
#line 329 "parser.c"
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
#endif



/* Copy the second part of user declarations.  */


/* Line 214 of yacc.c.  */
#line 341 "parser.c"

#if ! defined (yyoverflow) || 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) || YYERROR_VERBOSE */


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

/* A type that is properly aligned for any stack member.  */
union yyalloc
{
  short yyss;
  YYSTYPE yyvs;
  };

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

/* The size of an array large to enough to hold all stacks, each with
   N elements.  */
# define YYSTACK_BYTES(N) \
     ((N) * (sizeof (short) + sizeof (YYSTYPE))				\
      + YYSTACK_GAP_MAXIMUM)

/* 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_MAXIMUM; \
	yyptr += yynewbytes / sizeof (*yyptr);				\
      }									\
    while (0)

#endif

#if defined (__STDC__) || defined (__cplusplus)
   typedef signed char yysigned_char;
#else
   typedef short yysigned_char;
#endif

/* YYFINAL -- State number of the termination state. */
#define YYFINAL  4
/* YYLAST -- Last index in YYTABLE.  */
#define YYLAST   691

/* YYNTOKENS -- Number of terminals. */
#define YYNTOKENS  101
/* YYNNTS -- Number of nonterminals. */
#define YYNNTS  106
/* YYNRULES -- Number of rules. */
#define YYNRULES  278
/* YYNRULES -- Number of states. */
#define YYNSTATES  438

/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
#define YYUNDEFTOK  2
#define YYMAXUTOK   333

#define YYTRANSLATE(YYX) 						\
  ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)

/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
static const unsigned 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,    84,     2,     2,     2,    97,    91,     2,
      82,    83,    89,    88,    86,    85,     2,    90,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,    94,    81,
      99,    87,   100,     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,    95,     2,    96,    98,     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,    79,    92,    80,    93,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
       5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
      15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
      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,    61,    62,    63,    64,
      65,    66,    67,    68,    69,    70,    71,    72,    73,    74,
      75,    76,    77,    78
};

#if YYDEBUG
/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
   YYRHS.  */
static const unsigned short yyprhs[] =
{
       0,     0,     3,     5,     8,     9,    12,    14,    16,    18,
      20,    22,    24,    26,    28,    30,    32,    34,    36,    38,
      40,    42,    44,    46,    48,    50,    52,    54,    56,    58,
      60,    62,    64,    66,    68,    69,    77,    79,    82,    84,
      87,    90,    91,    99,   101,   104,   105,   111,   113,   116,
     118,   121,   122,   128,   130,   133,   135,   140,   142,   145,
     149,   154,   156,   160,   162,   165,   169,   171,   173,   174,
     176,   179,   182,   185,   186,   189,   192,   195,   198,   201,
     204,   207,   210,   213,   216,   221,   224,   225,   233,   234,
     236,   237,   239,   240,   242,   244,   247,   249,   251,   255,
     256,   258,   259,   262,   264,   268,   270,   272,   274,   276,
     278,   280,   281,   283,   285,   287,   289,   292,   294,   298,
     300,   302,   307,   309,   311,   313,   315,   317,   319,   320,
     322,   326,   331,   342,   346,   347,   356,   357,   367,   368,
     371,   373,   377,   379,   381,   384,   386,   388,   390,   392,
     394,   396,   398,   400,   402,   404,   406,   408,   410,   413,
     416,   420,   424,   428,   431,   432,   434,   445,   455,   456,
     462,   463,   470,   471,   473,   487,   500,   502,   504,   506,
     508,   510,   512,   514,   516,   519,   522,   525,   528,   531,
     534,   537,   540,   543,   546,   550,   554,   556,   559,   562,
     564,   567,   570,   573,   575,   578,   579,   581,   582,   585,
     586,   590,   592,   596,   598,   602,   604,   606,   608,   609,
     612,   613,   616,   618,   619,   621,   625,   627,   629,   631,
     633,   638,   643,   645,   648,   649,   653,   655,   657,   659,
     660,   664,   666,   671,   676,   680,   683,   684,   686,   687,
     690,   692,   697,   700,   703,   705,   707,   710,   712,   714,
     717,   719,   721,   723,   726,   728,   730,   732,   734,   736,
     738,   740,   742,   744,   748,   749,   754,   755,   757
};

/* YYRHS -- A `-1'-separated list of the rules' RHS. */
static const short yyrhs[] =
{
     102,     0,    -1,   103,    -1,   102,   103,    -1,    -1,   104,
     105,    -1,   128,    -1,   135,    -1,   131,    -1,   132,    -1,
     133,    -1,   119,    -1,   114,    -1,   118,    -1,   127,    -1,
     136,    -1,   138,    -1,   140,    -1,   141,    -1,   142,    -1,
     143,    -1,   144,    -1,   107,    -1,   106,    -1,   123,    -1,
     126,    -1,   111,    -1,   165,    -1,   167,    -1,   164,    -1,
     163,    -1,   146,    -1,   180,    -1,   198,    -1,    -1,    12,
     203,   108,    79,   109,    80,    81,    -1,   110,    -1,   109,
     110,    -1,   137,    -1,    21,   145,    -1,    22,   145,    -1,
      -1,    68,    16,   112,    79,   113,    80,    81,    -1,   106,
      -1,   113,   106,    -1,    -1,    70,   115,    79,   116,    80,
      -1,   117,    -1,   116,   117,    -1,    16,    -1,    71,    16,
      -1,    -1,    69,   120,    79,   121,    80,    -1,   122,    -1,
     121,   122,    -1,    16,    -1,    14,    82,   125,    83,    -1,
      16,    -1,    84,    16,    -1,   124,    56,    16,    -1,   124,
      56,    84,    16,    -1,   124,    -1,   149,    85,   149,    -1,
      15,    -1,    72,   184,    -1,   129,    16,   130,    -1,    29,
      -1,    30,    -1,    -1,    65,    -1,    24,    17,    -1,    25,
      17,    -1,    26,    17,    -1,    -1,     6,   145,    -1,    11,
     145,    -1,    27,   145,    -1,    28,   145,    -1,     8,   145,
      -1,     9,   145,    -1,     7,   145,    -1,    10,   145,    -1,
       3,   145,    -1,     4,   145,    -1,     5,    17,   148,   145,
      -1,    13,    15,    -1,    -1,    53,   149,   147,    79,   150,
      80,    81,    -1,    -1,    17,    -1,    -1,    16,    -1,    -1,
     151,    -1,   152,    -1,   151,   152,    -1,   123,    -1,   126,
      -1,    16,   154,   153,    -1,    -1,    86,    -1,    -1,    87,
     155,    -1,   158,    -1,   155,   156,   158,    -1,    85,    -1,
      88,    -1,    89,    -1,    90,    -1,    91,    -1,    92,    -1,
      -1,    84,    -1,    93,    -1,    85,    -1,    88,    -1,   157,
     161,    -1,   160,    -1,   159,    55,   160,    -1,    16,    -1,
     159,    -1,   159,    82,   162,    83,    -1,    66,    -1,    65,
      -1,    74,    -1,    75,    -1,    18,    -1,    73,    -1,    -1,
     158,    -1,   162,    86,   158,    -1,    67,   199,    16,    81,
      -1,    67,   199,    82,   202,    16,    83,    82,   204,    83,
      81,    -1,    31,   159,    81,    -1,    -1,    32,    16,   166,
     184,    79,   172,    80,    81,    -1,    -1,    31,    16,   168,
     169,   184,    79,   172,    80,    81,    -1,    -1,    94,   170,
      -1,   171,    -1,   170,    86,   171,    -1,   159,    -1,   173,
      -1,   172,   173,    -1,   123,    -1,   126,    -1,   111,    -1,
     165,    -1,   167,    -1,   164,    -1,   163,    -1,   146,    -1,
     139,    -1,   137,    -1,   176,    -1,   175,    -1,   193,    -1,
      23,   145,    -1,    22,   145,    -1,    33,   174,    94,    -1,
      34,   174,    94,    -1,    35,   174,    94,    -1,    36,    94,
      -1,    -1,    37,    -1,   179,    93,    16,    82,    83,   205,
     184,    81,   188,   189,    -1,    16,    82,   190,    83,   205,
     184,   177,    81,   188,    -1,    -1,    95,    82,   190,    83,
      96,    -1,    -1,    95,   199,    82,   190,    83,    96,    -1,
      -1,    52,    -1,   199,    16,    82,   190,    83,   182,   205,
     183,   184,   178,    81,   188,   189,    -1,   199,    76,   181,
      82,   190,    83,   182,   205,   184,   178,    81,   188,    -1,
      88,    -1,    85,    -1,    89,    -1,    90,    -1,    97,    -1,
      91,    -1,    92,    -1,    98,    -1,    99,    99,    -1,   100,
     100,    -1,    88,    87,    -1,    85,    87,    -1,    89,    87,
      -1,    90,    87,    -1,    97,    87,    -1,    91,    87,    -1,
      92,    87,    -1,    98,    87,    -1,    99,    99,    87,    -1,
     100,   100,    87,    -1,    93,    -1,    82,    83,    -1,    95,
      96,    -1,    99,    -1,    99,    87,    -1,    87,    87,    -1,
      84,    87,    -1,   100,    -1,   100,    87,    -1,    -1,    57,
      -1,    -1,    87,    65,    -1,    -1,    90,   185,    90,    -1,
     186,    -1,   185,    86,   186,    -1,    16,    -1,    16,    87,
     187,    -1,    16,    -1,    18,    -1,    65,    -1,    -1,    20,
     145,    -1,    -1,    19,   145,    -1,   191,    -1,    -1,   192,
      -1,   191,    86,   192,    -1,    59,    -1,    60,    -1,    61,
      -1,    62,    -1,    63,    82,   190,    83,    -1,    64,    82,
     190,    83,    -1,    78,    -1,   200,   154,    -1,    -1,    58,
     194,   195,    -1,   195,    -1,   196,    -1,   198,    -1,    -1,
      52,   197,   180,    -1,   180,    -1,   199,    16,    81,   134,
      -1,    57,   203,   202,   201,    -1,   203,   202,   201,    -1,
     199,   184,    -1,    -1,    91,    -1,    -1,   202,    89,    -1,
     159,    -1,   159,    99,   204,   100,    -1,    32,   159,    -1,
      54,    39,    -1,    39,    -1,    54,    -1,    54,    40,    -1,
      40,    -1,    41,    -1,    54,    41,    -1,    42,    -1,    43,
      -1,    38,    -1,    54,    44,    -1,    44,    -1,    45,    -1,
      46,    -1,    47,    -1,    48,    -1,    49,    -1,    50,    -1,
      51,    -1,   199,    -1,   204,    86,   199,    -1,    -1,    77,
      82,   206,    83,    -1,    -1,   159,    -1,   206,    86,   159,
      -1
};

/* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
static const unsigned short yyrline[] =
{
       0,   239,   239,   240,   243,   243,   262,   263,   264,   265,
     266,   267,   268,   269,   270,   271,   275,   279,   280,   281,
     282,   283,   284,   285,   288,   289,   290,   291,   292,   293,
     294,   295,   296,   297,   300,   300,   322,   323,   326,   330,
     339,   350,   350,   374,   375,   378,   378,   405,   406,   409,
     414,   419,   419,   445,   446,   449,   454,   469,   472,   475,
     478,   483,   484,   489,   495,   522,   541,   544,   550,   553,
     556,   561,   566,   571,   574,   579,   585,   590,   595,   600,
     605,   611,   620,   626,   631,   637,   640,   640,   651,   654,
     659,   662,   667,   668,   671,   672,   675,   676,   677,   705,
     706,   709,   712,   717,   718,   736,   739,   742,   745,   748,
     751,   756,   759,   762,   765,   768,   773,   791,   792,   800,
     805,   815,   825,   829,   833,   837,   841,   845,   851,   856,
     862,   880,   884,   907,   929,   929,   951,   951,   976,   977,
     980,   981,   984,   999,  1000,  1003,  1004,  1005,  1006,  1007,
    1008,  1009,  1010,  1011,  1015,  1019,  1020,  1021,  1022,  1033,
    1044,  1051,  1058,  1065,  1074,  1077,  1082,  1114,  1130,  1133,
    1140,  1143,  1151,  1154,  1159,  1176,  1192,  1193,  1194,  1195,
    1196,  1197,  1198,  1199,  1200,  1201,  1202,  1203,  1204,  1205,
    1206,  1207,  1208,  1209,  1210,  1211,  1212,  1213,  1214,  1215,
    1216,  1217,  1218,  1219,  1220,  1223,  1226,  1231,  1234,  1242,
    1245,  1251,  1255,  1267,  1271,  1277,  1281,  1285,  1291,  1294,
    1299,  1302,  1307,  1355,  1360,  1366,  1398,  1405,  1412,  1419,
    1426,  1440,  1454,  1459,  1465,  1465,  1466,  1469,  1470,  1473,
    1473,  1474,  1477,  1498,  1503,  1510,  1563,  1566,  1574,  1577,
    1582,  1586,  1596,  1609,  1612,  1615,  1618,  1621,  1624,  1627,
    1630,  1633,  1636,  1639,  1642,  1645,  1648,  1651,  1654,  1657,
    1660,  1663,  1668,  1674,  1692,  1695,  1710,  1716,  1723
};
#endif

#if YYDEBUG || YYERROR_VERBOSE
/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
   First, the terminals, then, starting at YYNTOKENS, nonterminals. */
static const char *const yytname[] =
{
  "$end", "error", "$undefined", "TK_DOC", "TK_EXPORTEDDOC", "TK_MAKEFILE", 
  "TK_ACCESSCODE", "TK_POSTINITCODE", "TK_MODCODE", "TK_TYPECODE", 
  "TK_PREPYCODE", "TK_COPYING", "TK_MAPPEDTYPE", "TK_CODEBLOCK", "TK_IF", 
  "TK_END", "TK_NAME", "TK_PATHNAME", "TK_STRING", 
  "TK_VIRTUALCATCHERCODE", "TK_METHODCODE", "TK_FROMTYPE", "TK_TOTYPE", 
  "TK_TOSUBCLASS", "TK_INCLUDE", "TK_OPTINCLUDE", "TK_IMPORT", 
  "TK_MODHEADERCODE", "TK_TYPEHEADERCODE", "TK_MODULE", "TK_CMODULE", 
  "TK_CLASS", "TK_STRUCT", "TK_PUBLIC", "TK_PROTECTED", "TK_PRIVATE", 
  "TK_SIGNALS", "TK_SLOTS", "TK_BOOL", "TK_SHORT", "TK_INT", "TK_LONG", 
  "TK_FLOAT", "TK_DOUBLE", "TK_CHAR", "TK_VOID", "TK_PYOBJECT", 
  "TK_PYTUPLE", "TK_PYLIST", "TK_PYDICT", "TK_PYCALLABLE", "TK_PYSLICE", 
  "TK_VIRTUAL", "TK_ENUM", "TK_UNSIGNED", "TK_SCOPE", "TK_LOGICAL_OR", 
  "TK_CONST", "TK_STATIC", "TK_SIPSIGNAL", "TK_SIPSLOT", "TK_SIPRXCON", 
  "TK_SIPRXDIS", "TK_SIPSLOTCON", "TK_SIPSLOTDIS", "TK_NUMBER", "TK_REAL", 
  "TK_TYPEDEF", "TK_NAMESPACE", "TK_TIMELINE", "TK_PLATFORMS", 
  "TK_FEATURE", "TK_LICENSE", "TK_QCHAR", "TK_TRUE", "TK_FALSE", 
  "TK_OPERATOR", "TK_THROW", "TK_QOBJECT", "'{'", "'}'", "';'", "'('", 
  "')'", "'!'", "'-'", "','", "'='", "'+'", "'*'", "'/'", "'&'", "'|'", 
  "'~'", "':'", "'['", "']'", "'%'", "'^'", "'<'", "'>'", "$accept", 
  "specification", "statement", "@1", "modstatement", "nsstatement", 
  "mappedtype", "@2", "mtbody", "mtline", "namespace", "@3", "nsbody", 
  "platforms", "@4", "platformlist", "platform", "feature", "timeline", 
  "@5", "qualifierlist", "qualifiername", "ifstart", "oredqualifiers", 
  "qualifiers", "ifend", "license", "module", "modlang", "optnumber", 
  "include", "optinclude", "import", "optaccesscode", "copying", 
  "modhdrcode", "typehdrcode", "modcode", "typecode", "postinitcode", 
  "prepycode", "doc", "exporteddoc", "makefile", "codeblock", "enum", 
  "@6", "optfilename", "optname", "optenumbody", "enumbody", "enumline", 
  "optcomma", "optassign", "expr", "binop", "optunop", "value", 
  "scopedname", "scopepart", "simplevalue", "valuelist", "typedef", 
  "opaqueclass", "struct", "@7", "class", "@8", "superclasses", 
  "superlist", "superclass", "classbody", "classline", "optslot", "dtor", 
  "ctor", "optctorsig", "optsig", "optvirtual", "function", 
  "operatorname", "optconst", "optabstract", "optflags", "flaglist", 
  "flag", "flagvalue", "methodcode", "virtualcatchercode", "arglist", 
  "rawarglist", "argvalue", "varmember", "@9", "varmem", "member", "@10", 
  "variable", "cpptype", "argtype", "optref", "deref", "basetype", 
  "cpptypelist", "optexceptions", "exceptionlist", 0
};
#endif

# ifdef YYPRINT
/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
   token YYLEX-NUM.  */
static const unsigned short yytoknum[] =
{
       0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
     265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
     275,   276,   277,   278,   279,   280,   281,   282,   283,   284,
     285,   286,   287,   288,   289,   290,   291,   292,   293,   294,
     295,   296,   297,   298,   299,   300,   301,   302,   303,   304,
     305,   306,   307,   308,   309,   310,   311,   312,   313,   314,
     315,   316,   317,   318,   319,   320,   321,   322,   323,   324,
     325,   326,   327,   328,   329,   330,   331,   332,   333,   123,
     125,    59,    40,    41,    33,    45,    44,    61,    43,    42,
      47,    38,   124,   126,    58,    91,    93,    37,    94,    60,
      62
};
# endif

/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
static const unsigned char yyr1[] =
{
       0,   101,   102,   102,   104,   103,   105,   105,   105,   105,
     105,   105,   105,   105,   105,   105,   105,   105,   105,   105,
     105,   105,   105,   105,   106,   106,   106,   106,   106,   106,
     106,   106,   106,   106,   108,   107,   109,   109,   110,   110,
     110,   112,   111,   113,   113,   115,   114,   116,   116,   117,
     118,   120,   119,   121,   121,   122,   123,   124,   124,   124,
     124,   125,   125,   126,   127,   128,   129,   129,   130,   130,
     131,   132,   133,   134,   134,   135,   136,   137,   138,   139,
     140,   141,   142,   143,   144,   145,   147,   146,   148,   148,
     149,   149,   150,   150,   151,   151,   152,   152,   152,   153,
     153,   154,   154,   155,   155,   156,   156,   156,   156,   156,
     156,   157,   157,   157,   157,   157,   158,   159,   159,   160,
     161,   161,   161,   161,   161,   161,   161,   161,   162,   162,
     162,   163,   163,   164,   166,   165,   168,   167,   169,   169,
     170,   170,   171,   172,   172,   173,   173,   173,   173,   173,
     173,   173,   173,   173,   173,   173,   173,   173,   173,   173,
     173,   173,   173,   173,   174,   174,   175,   176,   177,   177,
     178,   178,   179,   179,   180,   180,   181,   181,   181,   181,
     181,   181,   181,   181,   181,   181,   181,   181,   181,   181,
     181,   181,   181,   181,   181,   181,   181,   181,   181,   181,
     181,   181,   181,   181,   181,   182,   182,   183,   183,   184,
     184,   185,   185,   186,   186,   187,   187,   187,   188,   188,
     189,   189,   190,   191,   191,   191,   192,   192,   192,   192,
     192,   192,   192,   192,   194,   193,   193,   195,   195,   197,
     196,   196,   198,   199,   199,   200,   201,   201,   202,   202,
     203,   203,   203,   203,   203,   203,   203,   203,   203,   203,
     203,   203,   203,   203,   203,   203,   203,   203,   203,   203,
     203,   203,   204,   204,   205,   205,   206,   206,   206
};

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

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

/* YYDEFGOTO[NTERM-NUM]. */
static const short yydefgoto[] =
{
      -1,     1,     2,     3,    48,    49,    50,   124,   228,   229,
     287,   137,   247,    52,   111,   187,   188,    53,    54,   110,
     184,   185,   288,   127,   128,   289,    57,    58,    59,   144,
      60,    61,    62,   195,    63,    64,   290,    65,   291,    66,
      67,    68,    69,    70,    83,   292,   133,   123,   102,   242,
     243,   244,   344,   265,   322,   358,   323,   324,    72,    73,
     366,   396,   293,   294,   295,   132,   296,   130,   176,   235,
     236,   297,   298,   334,   299,   300,   416,   404,   301,   302,
     165,   316,   382,   114,   141,   142,   255,   420,   428,   203,
     204,   205,   303,   339,   304,   305,   338,   306,    80,   207,
     168,   120,    81,   147,   351,   392
};

/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
   STATE-NUM.  */
#define YYPACT_NINF -341
static const short yypact[] =
{
    -341,    45,  -341,   392,  -341,  -341,    35,    35,    36,    35,
      35,    35,    35,   330,     0,  -341,  -341,    49,    86,    97,
      35,  -341,  -341,    92,   104,  -341,  -341,  -341,  -341,  -341,
    -341,  -341,  -341,  -341,  -341,  -341,  -341,  -341,  -341,   116,
     235,   330,   620,   139,  -341,  -341,   141,    71,  -341,  -341,
    -341,  -341,  -341,  -341,  -341,  -341,  -341,  -341,  -341,   142,
    -341,  -341,  -341,  -341,  -341,  -341,  -341,  -341,  -341,  -341,
    -341,  -341,   -30,  -341,  -341,  -341,  -341,  -341,  -341,  -341,
      17,  -341,   150,  -341,  -341,   162,  -341,  -341,  -341,  -341,
     165,  -341,    10,  -341,  -341,  -341,  -341,    -8,    -5,   -25,
     128,  -341,  -341,  -341,  -341,  -341,  -341,  -341,    13,  -341,
     105,   111,  -341,   176,  -341,   130,   165,   620,    43,   591,
      75,  -341,  -341,    35,   117,   114,   186,   147,   121,   127,
     119,  -341,    71,   136,    75,   144,  -341,   138,   206,   226,
     157,   -28,  -341,  -341,  -341,  -341,  -341,   -40,   242,   479,
     166,   168,   170,   180,   181,   182,   184,   191,   193,  -341,
     156,   194,   195,   -38,   -44,   171,  -341,  -341,  -341,  -341,
      68,  -341,    14,  -341,   116,   165,    71,   204,    91,  -341,
    -341,     8,   581,  -341,    20,  -341,  -341,    21,  -341,    22,
     176,  -341,   620,  -341,    35,  -341,  -341,  -341,  -341,  -341,
     202,   203,  -341,   208,   200,  -341,    71,   205,  -341,  -341,
    -341,  -341,  -341,  -341,  -341,  -341,  -341,  -341,  -341,  -341,
    -341,   211,  -341,   212,   479,    35,    35,    35,     6,  -341,
    -341,  -341,   271,  -341,   128,   207,  -341,   210,   536,   205,
    -341,  -341,   220,    91,  -341,   218,  -341,   436,  -341,  -341,
    -341,  -341,  -341,  -341,  -341,  -341,  -341,  -341,  -341,   479,
     479,   248,   479,  -341,    66,  -341,  -341,  -341,   223,  -341,
    -341,  -341,   230,  -341,  -341,   165,   536,    35,   225,    35,
      35,   300,   300,   300,   224,   247,  -341,  -341,  -341,  -341,
    -341,  -341,  -341,  -341,  -341,  -341,  -341,    95,  -341,  -341,
    -341,   249,  -341,  -341,  -341,  -341,  -341,   255,   262,  -341,
     263,   266,  -341,   261,   267,  -341,   274,  -341,  -341,  -341,
    -341,  -341,    82,   103,  -341,   248,  -341,  -341,   281,  -341,
     479,  -341,  -341,  -341,   258,   259,   260,  -341,   620,   189,
     275,  -341,   339,  -341,  -341,  -341,   620,  -341,  -341,  -341,
     276,   270,  -341,  -341,  -341,  -341,  -341,  -341,    66,  -341,
    -341,  -341,  -341,  -341,  -341,   -14,  -341,   274,   278,   277,
    -341,  -341,  -341,  -341,    26,  -341,  -341,  -341,   282,   -16,
     165,   298,    71,  -341,   123,    71,  -341,   274,   284,   302,
     307,   128,    -6,  -341,   288,  -341,    29,   288,    71,   274,
    -341,  -341,   165,   620,   308,  -341,    66,   309,   296,    71,
     128,   310,   373,  -341,   373,   312,   317,   320,   479,    35,
     386,  -341,   479,   373,   373,   326,  -341,    35,  -341,   327,
    -341,   386,   315,  -341,   318,  -341,  -341,  -341
};

/* YYPGOTO[NTERM-NUM].  */
static const short yypgoto[] =
{
    -341,  -341,   412,  -341,  -341,  -159,  -341,  -341,  -341,   187,
       9,  -341,  -341,  -341,  -341,  -341,   238,  -341,  -341,  -341,
    -341,   243,     4,  -341,  -341,     7,  -341,  -341,  -341,  -341,
    -341,  -341,  -341,  -341,  -341,  -341,  -150,  -341,  -341,  -341,
    -341,  -341,  -341,  -341,    -7,    11,  -341,  -341,   -75,  -341,
    -341,   183,  -341,   190,  -341,  -341,  -341,  -327,   -15,   328,
    -341,  -341,    12,    15,    16,  -341,    18,  -341,  -341,  -341,
     153,   172,  -265,  -191,  -341,  -341,  -341,    50,  -341,    -2,
    -341,   129,  -341,  -121,  -341,   265,  -341,  -340,    25,  -208,
    -341,   196,  -341,  -341,   118,  -341,  -341,    19,   -36,  -341,
     319,   -72,    31,   120,  -328,  -341
};

/* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
   positive, shift that token.  If negative, reduce the rule which
   number is the opposite.  If zero, do what YYDEFACT says.
   If YYTABLE_NINF, syntax error.  */
#define YYTABLE_NINF -174
static const short yytable[] =
{
      84,    78,    86,    87,    88,    89,   108,    55,    98,   100,
      56,   177,    51,    96,    71,    74,   268,   129,    75,    76,
     230,    77,    79,   246,   245,   116,   125,   225,   226,   135,
     231,   383,   341,   118,   227,   134,   183,   186,   252,   385,
     253,   116,   388,   222,    91,     4,   192,  -119,    82,   220,
     116,   313,   314,    85,  -134,   237,   223,   395,   190,   398,
     193,   221,   191,   341,   181,  -134,    93,   390,   384,   117,
     192,   409,   107,  -119,   421,   100,   131,   401,   230,   413,
     402,   146,    92,   430,   431,   263,   272,   254,   312,   225,
     226,   335,   336,   119,   126,   136,   227,   166,   232,   233,
     248,   250,   119,    94,   277,    14,    15,   239,    97,    14,
      15,   278,   405,   206,    95,   406,   169,   279,   280,    16,
      99,   359,   369,   227,   148,   149,    23,    24,   281,   282,
     283,   284,   101,    25,    26,    27,    28,    29,    30,    31,
      32,    33,    34,    35,    36,    37,    38,   285,    39,    40,
     318,   319,    41,   286,   320,   109,   257,   112,   115,   321,
     234,   113,    42,    43,   166,   121,   167,   352,   360,   361,
     353,   354,   355,   356,   357,   340,   362,   363,   364,   122,
      78,    16,   240,   116,   138,   241,    55,   258,   206,    56,
     139,    51,   140,    71,    74,   143,   170,    75,    76,   -91,
      77,    79,   171,   172,   173,    16,  -128,   318,   319,  -128,
     425,   320,   174,   175,   429,   178,   321,   182,   269,   270,
     271,    90,   183,   206,   206,   180,   206,    25,    26,    27,
      28,    29,    30,    31,    32,    33,    34,    35,    36,    37,
      38,   375,   186,    40,   189,    78,    41,   240,   194,   208,
     241,    55,   217,   224,    56,   209,    51,   210,    71,    74,
     234,   394,    75,    76,   397,    77,    79,   211,   212,   213,
     329,   214,   331,   332,   103,   104,   105,   408,   215,   106,
     216,   218,   219,   238,   259,   260,   262,   274,   417,   276,
     277,   261,   264,   275,   206,    14,    15,   278,   266,   267,
     308,   310,   374,   279,   280,   315,   325,   330,   365,   227,
     146,   326,    23,    24,   281,   282,   283,   284,   337,    25,
      26,    27,    28,    29,    30,    31,    32,    33,    34,    35,
      36,    37,    38,   285,    39,    40,   373,   333,    41,   286,
    -173,   343,   342,   345,   348,   346,    16,   347,    42,    43,
     349,   350,   370,   371,   372,   378,   377,   381,   380,   386,
     387,   368,    90,   393,   389,   391,   149,   411,    25,    26,
      27,    28,    29,    30,    31,    32,    33,    34,    35,    36,
      37,    38,   206,   403,    40,   399,   206,   410,   400,   412,
     414,   415,   418,   419,   422,     6,     7,     8,   423,     9,
      10,   424,    11,    12,    13,   427,    14,    15,    16,   432,
     434,   436,   426,     5,   437,   273,    17,    18,    19,    20,
     433,    21,    22,    23,    24,   251,   309,   249,   327,   307,
      25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
      35,    36,    37,    38,   145,    39,    40,   407,   328,    41,
      14,    15,    16,   179,   367,   256,   435,   376,   317,    42,
      43,    44,    45,    46,    47,     0,   379,    23,    24,     0,
       0,     0,     0,     0,    25,    26,    27,    28,    29,    30,
      31,    32,    33,    34,    35,    36,    37,    38,     0,    39,
      40,     0,     0,    41,     0,    16,     0,     0,     0,     0,
       0,     0,     0,    42,    43,     0,     0,     0,     0,     0,
       0,    90,     0,     0,     0,     0,   311,    25,    26,    27,
      28,    29,    30,    31,    32,    33,    34,    35,    36,    37,
      38,     0,     0,    40,     0,     0,    41,     0,   196,   197,
     198,   199,   200,   201,     0,   277,     0,     0,     0,     0,
      14,    15,   278,     0,     0,     0,     0,   202,   279,   280,
       0,     0,     0,     0,   227,     0,     0,    23,    24,   281,
     282,   283,   284,     0,    25,    26,    27,    28,    29,    30,
      31,    32,    33,    34,    35,    36,    37,    38,   285,    39,
      40,     0,     0,    41,   286,    14,    15,    16,     0,     0,
       0,     0,     0,    42,    43,     0,     0,     0,     0,     0,
       0,     0,    23,    24,     0,     0,     0,     0,     0,    25,
      26,    27,    28,    29,    30,    31,    32,    33,    34,    35,
      36,    37,    38,     0,    39,    40,    16,     0,    41,     0,
       0,     0,     0,     0,     0,     0,     0,     0,    42,    43,
       0,     0,    90,     0,     0,     0,     0,     0,    25,    26,
      27,    28,    29,    30,    31,    32,    33,    34,    35,    36,
      37,    38,     0,   150,    40,   151,   152,    41,   153,   154,
     155,   156,   157,   158,   159,     0,   160,     0,   161,   162,
     163,   164
};

static const short yycheck[] =
{
       7,     3,     9,    10,    11,    12,    42,     3,    23,    24,
       3,   132,     3,    20,     3,     3,   224,    92,     3,     3,
     170,     3,     3,   182,    16,    55,    16,    21,    22,    16,
      16,   358,   297,    16,    28,   107,    16,    16,    16,   367,
      18,    55,    16,    87,    13,     0,    86,    55,    13,    87,
      55,   259,   260,    17,    79,   176,   100,   384,    86,   387,
     100,    99,    90,   328,   136,    90,    17,    83,    82,    99,
      86,   399,    41,    81,   414,    90,    81,    83,   228,   406,
      86,   117,    82,   423,   424,   206,    80,    65,   247,    21,
      22,   282,   283,    76,    84,    82,    28,    89,    84,   174,
      80,    80,    76,    17,     9,    14,    15,    16,    16,    14,
      15,    16,    83,   149,    17,    86,   123,    22,    23,    16,
      16,    18,   330,    28,    81,    82,    31,    32,    33,    34,
      35,    36,    16,    38,    39,    40,    41,    42,    43,    44,
      45,    46,    47,    48,    49,    50,    51,    52,    53,    54,
      84,    85,    57,    58,    88,    16,   192,    16,    16,    93,
     175,    90,    67,    68,    89,    15,    91,    85,    65,    66,
      88,    89,    90,    91,    92,    80,    73,    74,    75,    17,
     182,    16,   178,    55,    79,   178,   182,   194,   224,   182,
      79,   182,    16,   182,   182,    65,    79,   182,   182,    85,
     182,   182,    16,    56,    83,    16,    83,    84,    85,    86,
     418,    88,    85,    94,   422,    79,    93,    79,   225,   226,
     227,    32,    16,   259,   260,    81,   262,    38,    39,    40,
      41,    42,    43,    44,    45,    46,    47,    48,    49,    50,
      51,    52,    16,    54,    87,   247,    57,   243,     6,    83,
     243,   247,    96,    82,   247,    87,   247,    87,   247,   247,
     275,   382,   247,   247,   385,   247,   247,    87,    87,    87,
     277,    87,   279,   280,    39,    40,    41,   398,    87,    44,
      87,    87,    87,    79,    82,    82,    86,    16,   409,    79,
       9,    83,    87,    86,   330,    14,    15,    16,    87,    87,
      80,    83,   338,    22,    23,    57,    83,    82,   323,    28,
     346,    81,    31,    32,    33,    34,    35,    36,    94,    38,
      39,    40,    41,    42,    43,    44,    45,    46,    47,    48,
      49,    50,    51,    52,    53,    54,   338,    37,    57,    58,
      93,    86,    93,    81,    83,    82,    16,    81,    67,    68,
      83,    77,    94,    94,    94,    16,    81,    87,    82,    81,
      83,    80,    32,    65,    82,   380,    82,   403,    38,    39,
      40,    41,    42,    43,    44,    45,    46,    47,    48,    49,
      50,    51,   418,    95,    54,    83,   422,   402,    81,    81,
      81,    95,    82,    20,    82,     3,     4,     5,    81,     7,
       8,    81,    10,    11,    12,    19,    14,    15,    16,    83,
      83,    96,   419,     1,    96,   228,    24,    25,    26,    27,
     427,    29,    30,    31,    32,   187,   243,   184,   275,   239,
      38,    39,    40,    41,    42,    43,    44,    45,    46,    47,
      48,    49,    50,    51,   116,    53,    54,   397,   276,    57,
      14,    15,    16,   134,   325,   190,   431,   339,   262,    67,
      68,    69,    70,    71,    72,    -1,   346,    31,    32,    -1,
      -1,    -1,    -1,    -1,    38,    39,    40,    41,    42,    43,
      44,    45,    46,    47,    48,    49,    50,    51,    -1,    53,
      54,    -1,    -1,    57,    -1,    16,    -1,    -1,    -1,    -1,
      -1,    -1,    -1,    67,    68,    -1,    -1,    -1,    -1,    -1,
      -1,    32,    -1,    -1,    -1,    -1,    80,    38,    39,    40,
      41,    42,    43,    44,    45,    46,    47,    48,    49,    50,
      51,    -1,    -1,    54,    -1,    -1,    57,    -1,    59,    60,
      61,    62,    63,    64,    -1,     9,    -1,    -1,    -1,    -1,
      14,    15,    16,    -1,    -1,    -1,    -1,    78,    22,    23,
      -1,    -1,    -1,    -1,    28,    -1,    -1,    31,    32,    33,
      34,    35,    36,    -1,    38,    39,    40,    41,    42,    43,
      44,    45,    46,    47,    48,    49,    50,    51,    52,    53,
      54,    -1,    -1,    57,    58,    14,    15,    16,    -1,    -1,
      -1,    -1,    -1,    67,    68,    -1,    -1,    -1,    -1,    -1,
      -1,    -1,    31,    32,    -1,    -1,    -1,    -1,    -1,    38,
      39,    40,    41,    42,    43,    44,    45,    46,    47,    48,
      49,    50,    51,    -1,    53,    54,    16,    -1,    57,    -1,
      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    67,    68,
      -1,    -1,    32,    -1,    -1,    -1,    -1,    -1,    38,    39,
      40,    41,    42,    43,    44,    45,    46,    47,    48,    49,
      50,    51,    -1,    82,    54,    84,    85,    57,    87,    88,
      89,    90,    91,    92,    93,    -1,    95,    -1,    97,    98,
      99,   100
};

/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
   symbol of state STATE-NUM.  */
static const unsigned char yystos[] =
{
       0,   102,   103,   104,     0,   103,     3,     4,     5,     7,
       8,    10,    11,    12,    14,    15,    16,    24,    25,    26,
      27,    29,    30,    31,    32,    38,    39,    40,    41,    42,
      43,    44,    45,    46,    47,    48,    49,    50,    51,    53,
      54,    57,    67,    68,    69,    70,    71,    72,   105,   106,
     107,   111,   114,   118,   119,   123,   126,   127,   128,   129,
     131,   132,   133,   135,   136,   138,   140,   141,   142,   143,
     144,   146,   159,   160,   163,   164,   165,   167,   180,   198,
     199,   203,    13,   145,   145,    17,   145,   145,   145,   145,
      32,   203,    82,    17,    17,    17,   145,    16,   159,    16,
     159,    16,   149,    39,    40,    41,    44,   203,   199,    16,
     120,   115,    16,    90,   184,    16,    55,    99,    16,    76,
     202,    15,    17,   148,   108,    16,    84,   124,   125,   149,
     168,    81,   166,   147,   202,    16,    82,   112,    79,    79,
      16,   185,   186,    65,   130,   160,   199,   204,    81,    82,
      82,    84,    85,    87,    88,    89,    90,    91,    92,    93,
      95,    97,    98,    99,   100,   181,    89,    91,   201,   145,
      79,    16,    56,    83,    85,    94,   169,   184,    79,   201,
      81,   202,    79,    16,   121,   122,    16,   116,   117,    87,
      86,    90,    86,   100,     6,   134,    59,    60,    61,    62,
      63,    64,    78,   190,   191,   192,   199,   200,    83,    87,
      87,    87,    87,    87,    87,    87,    87,    96,    87,    87,
      87,    99,    87,   100,    82,    21,    22,    28,   109,   110,
     137,    16,    84,   149,   159,   170,   171,   184,    79,    16,
     123,   126,   150,   151,   152,    16,   106,   113,    80,   122,
      80,   117,    16,    18,    65,   187,   186,   199,   145,    82,
      82,    83,    86,   184,    87,   154,    87,    87,   190,   145,
     145,   145,    80,   110,    16,    86,    79,     9,    16,    22,
      23,    33,    34,    35,    36,    52,    58,   111,   123,   126,
     137,   139,   146,   163,   164,   165,   167,   172,   173,   175,
     176,   179,   180,   193,   195,   196,   198,   154,    80,   152,
      83,    80,   106,   190,   190,    57,   182,   192,    84,    85,
      88,    93,   155,   157,   158,    83,    81,   171,   172,   145,
      82,   145,   145,    37,   174,   174,   174,    94,   197,   194,
      80,   173,    93,    86,   153,    81,    82,    81,    83,    83,
      77,   205,    85,    88,    89,    90,    91,    92,   156,    18,
      65,    66,    73,    74,    75,   159,   161,   182,    80,   190,
      94,    94,    94,   180,   199,    52,   195,    81,    16,   204,
      82,    87,   183,   158,    82,   205,    81,    83,    16,    82,
      83,   159,   206,    65,   184,   158,   162,   184,   205,    83,
      81,    83,    86,    95,   178,    83,    86,   178,   184,   205,
     159,   199,    81,   158,    81,    95,   177,   184,    82,    20,
     188,   188,    82,    81,    81,   190,   145,    19,   189,   190,
     188,   188,    83,   145,    83,   189,    96,    96
};

#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);						\
      yytoken = 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).  */

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

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

#ifdef YYLEX_PARAM
# define YYLEX yylex (YYLEX_PARAM)
#else
# define YYLEX yylex ()
#endif

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

# define YYDSYMPRINT(Args)			\
do {						\
  if (yydebug)					\
    yysymprint Args;				\
} while (0)

# define YYDSYMPRINTF(Title, Token, Value, Location)		\
do {								\
  if (yydebug)							\
    {								\
      YYFPRINTF (stderr, "%s ", Title);				\
      yysymprint (stderr, 					\
                  Token, Value);	\
      YYFPRINTF (stderr, "\n");					\
    }								\
} while (0)

/*------------------------------------------------------------------.
| yy_stack_print -- Print the state stack from its BOTTOM up to its |
| TOP (cinluded).                                                   |
`------------------------------------------------------------------*/

#if defined (__STDC__) || defined (__cplusplus)
static void
yy_stack_print (short *bottom, short *top)
#else
static void
yy_stack_print (bottom, top)
    short *bottom;
    short *top;
#endif
{
  YYFPRINTF (stderr, "Stack now");
  for (/* Nothing. */; bottom <= top; ++bottom)
    YYFPRINTF (stderr, " %d", *bottom);
  YYFPRINTF (stderr, "\n");
}

# define YY_STACK_PRINT(Bottom, Top)				\
do {								\
  if (yydebug)							\
    yy_stack_print ((Bottom), (Top));				\
} while (0)


/*------------------------------------------------.
| Report that the YYRULE is going to be reduced.  |
`------------------------------------------------*/

#if defined (__STDC__) || defined (__cplusplus)
static void
yy_reduce_print (int yyrule)
#else
static void
yy_reduce_print (yyrule)
    int yyrule;
#endif
{
  int yyi;
  unsigned int yylineno = yyrline[yyrule];
  YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
             yyrule - 1, yylineno);
  /* Print the symbols being reduced, and their result.  */
  for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
    YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
  YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]);
}

# define YY_REDUCE_PRINT(Rule)		\
do {					\
  if (yydebug)				\
    yy_reduce_print (Rule);		\
} while (0)

/* Nonzero means print parse trace.  It is left uninitialized so that
   multiple parsers can coexist.  */
int yydebug;
#else /* !YYDEBUG */
# define YYDPRINTF(Args)
# define YYDSYMPRINT(Args)
# define YYDSYMPRINTF(Title, Token, Value, Location)
# define YY_STACK_PRINT(Bottom, Top)
# define YY_REDUCE_PRINT(Rule)
#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



#if 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 /* !YYERROR_VERBOSE */



#if YYDEBUG
/*--------------------------------.
| Print this symbol on YYOUTPUT.  |
`--------------------------------*/

#if defined (__STDC__) || defined (__cplusplus)
static void
yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
#else
static void
yysymprint (yyoutput, yytype, yyvaluep)
    FILE *yyoutput;
    int yytype;
    YYSTYPE *yyvaluep;
#endif
{
  /* Pacify ``unused variable'' warnings.  */
  (void) yyvaluep;

  if (yytype < YYNTOKENS)
    {
      YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
# ifdef YYPRINT
      YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
# endif
    }
  else
    YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);

  switch (yytype)
    {
      default:
        break;
    }
  YYFPRINTF (yyoutput, ")");
}

#endif /* ! YYDEBUG */
/*-----------------------------------------------.
| Release the memory associated to this symbol.  |
`-----------------------------------------------*/

#if defined (__STDC__) || defined (__cplusplus)
static void
yydestruct (int yytype, YYSTYPE *yyvaluep)
#else
static void
yydestruct (yytype, yyvaluep)
    int yytype;
    YYSTYPE *yyvaluep;
#endif
{
  /* Pacify ``unused variable'' warnings.  */
  (void) yyvaluep;

  switch (yytype)
    {

      default:
        break;
    }
}


/* Prevent warnings from -Wmissing-prototypes.  */

#ifdef YYPARSE_PARAM
# if defined (__STDC__) || defined (__cplusplus)
int yyparse (void *YYPARSE_PARAM);
# else
int yyparse ();
# endif
#else /* ! YYPARSE_PARAM */
#if defined (__STDC__) || defined (__cplusplus)
int yyparse (void);
#else
int yyparse ();
#endif
#endif /* ! YYPARSE_PARAM */



/* The lookahead symbol.  */
int yychar;

/* The semantic value of the lookahead symbol.  */
YYSTYPE yylval;

/* Number of syntax errors so far.  */
int yynerrs;



/*----------.
| yyparse.  |
`----------*/

#ifdef YYPARSE_PARAM
# if defined (__STDC__) || defined (__cplusplus)
int yyparse (void *YYPARSE_PARAM)
# else
int yyparse (YYPARSE_PARAM)
  void *YYPARSE_PARAM;
# endif
#else /* ! YYPARSE_PARAM */
#if defined (__STDC__) || defined (__cplusplus)
int
yyparse (void)
#else
int
yyparse ()

#endif
#endif
{
  
  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 yytoken = 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;



#define YYPOPSTACK   (yyvsp--, yyssp--)

  YYSIZE_T yystacksize = YYINITDEPTH;

  /* The variables used to return semantic value and location from the
     action routines.  */
  YYSTYPE yyval;


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

  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 (yyss + yystacksize - 1 <= yyssp)
    {
      /* 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.  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),

		    &yystacksize);

	yyss = yyss1;
	yyvs = yyvs1;
      }
#else /* no yyoverflow */
# ifndef YYSTACK_RELOCATE
      goto yyoverflowlab;
# else
      /* Extend the stack our own way.  */
      if (YYMAXDEPTH <= yystacksize)
	goto yyoverflowlab;
      yystacksize *= 2;
      if (YYMAXDEPTH < yystacksize)
	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);

#  undef YYSTACK_RELOCATE
	if (yyss1 != yyssa)
	  YYSTACK_FREE (yyss1);
      }
# endif
#endif /* no yyoverflow */

      yyssp = yyss + yysize - 1;
      yyvsp = yyvs + yysize - 1;


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

      if (yyss + yystacksize - 1 <= yyssp)
	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 == YYPACT_NINF)
    goto yydefault;

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

  /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
  if (yychar == YYEMPTY)
    {
      YYDPRINTF ((stderr, "Reading a token: "));
      yychar = YYLEX;
    }

  if (yychar <= YYEOF)
    {
      yychar = yytoken = YYEOF;
      YYDPRINTF ((stderr, "Now at end of input.\n"));
    }
  else
    {
      yytoken = YYTRANSLATE (yychar);
      YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc);
    }

  /* If the proper action on seeing token YYTOKEN is to reduce or to
     detect an error, take that action.  */
  yyn += yytoken;
  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
    goto yydefault;
  yyn = yytable[yyn];
  if (yyn <= 0)
    {
      if (yyn == 0 || yyn == YYTABLE_NINF)
	goto yyerrlab;
      yyn = -yyn;
      goto yyreduce;
    }

  if (yyn == YYFINAL)
    YYACCEPT;

  /* Shift the lookahead token.  */
  YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken]));

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

  *++yyvsp = yylval;


  /* 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 garbage.
     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];


  YY_REDUCE_PRINT (yyn);
  switch (yyn)
    {
        case 4:
#line 243 "parser.y"
    {
			/*
			 * We don't do these in parserEOF() because the parser
			 * is reading ahead and that would be too early.
			 */

			if (previousFile != NULL)
			{
				handleEOF();

				if (newContext.prevmod != NULL)
					handleEOM();

				free(previousFile);
				previousFile = NULL;
			}
	}
    break;

  case 15:
#line 271 "parser.y"
    {
			if (notSkipping() && inMainModule())
				appendCodeBlock(&currentSpec -> hdrcode,yyvsp[0].codeb);
		}
    break;

  case 16:
#line 275 "parser.y"
    {
			if (notSkipping() && inMainModule())
				appendCodeBlock(&currentSpec -> cppcode,yyvsp[0].codeb);
		}
    break;

  case 34:
#line 300 "parser.y"
    {
			if (notSkipping())
			{
				yyvsp[0].memArg.nrderefs = 0;
				yyvsp[0].memArg.argflags = 0;

				currentMappedType = newMappedType(currentSpec,&yyvsp[0].memArg);
			}
		}
    break;

  case 35:
#line 308 "parser.y"
    {
			if (notSkipping())
			{
				if (currentMappedType -> convfromcode == NULL)
					yyerror("%MappedType must have a %ConvertFromTypeCode directive");

				if (currentMappedType -> convtocode == NULL)
					yyerror("%MappedType must have a %ConvertToTypeCode directive");

				currentMappedType = NULL;
			}
		}
    break;

  case 38:
#line 326 "parser.y"
    {
			if (notSkipping())
				appendCodeBlock(&currentMappedType -> hdrcode,yyvsp[0].codeb);
		}
    break;

  case 39:
#line 330 "parser.y"
    {
			if (notSkipping())
			{
				if (currentMappedType -> convfromcode != NULL)
					yyerror("%MappedType has more than one %ConvertFromTypeCode directive");

				currentMappedType -> convfromcode = yyvsp[0].codeb;
			}
		}
    break;

  case 40:
#line 339 "parser.y"
    {
			if (notSkipping())
			{
				if (currentMappedType -> convtocode != NULL)
					yyerror("%MappedType has more than one %ConvertToTypeCode directive");

				currentMappedType -> convtocode = yyvsp[0].codeb;
			}
		}
    break;

  case 41:
#line 350 "parser.y"
    {
			if (currentSpec -> genc)
				yyerror("namespace definition not allowed in a C module");

			if (notSkipping())
			{
				classDef *ns;

				ns = newClass(currentSpec,namespace_iface,text2scopedName(yyvsp[0].text));

				setCannotCreate(ns);

				pushScope(ns);

				sectionFlags = 0;
			}
		}
    break;

  case 42:
#line 366 "parser.y"
    {
			/* Remove the namespace name. */

			if (notSkipping())
				popScope();
		}
    break;

  case 45:
#line 378 "parser.y"
    {
			qualDef *qd;

			for (qd = currentModule -> qualifiers; qd != NULL; qd = qd -> next)
				if (qd -> qtype == platform_qualifier)
					yyerror("%Platforms has already been defined for this module");
		}
    break;

  case 46:
#line 385 "parser.y"
    {
			qualDef *qd;
			int nrneeded;

			/*
			 * Check that exactly one platform in the set was
			 * requested.
			 */

			nrneeded = 0;

			for (qd = currentModule -> qualifiers; qd != NULL; qd = qd -> next)
				if (qd -> qtype == platform_qualifier && isNeeded(qd))
					++nrneeded;

			if (nrneeded != 1)
				yyerror("Exactly one of these %Platforms must be specified with the -t flag");
		}
    break;

  case 49:
#line 409 "parser.y"
    {
			newQualifier(currentModule,-1,yyvsp[0].text,platform_qualifier);
		}
    break;

  case 50:
#line 414 "parser.y"
    {
			newQualifier(currentModule,-1,yyvsp[0].text,feature_qualifier);
		}
    break;

  case 51:
#line 419 "parser.y"
    {
			if (currentModule -> nrTimeSlots >= 0)
				yyerror("%Timeline has already been defined for this module");

			currentModule -> nrTimeSlots = 0;
		}
    break;

  case 52:
#line 425 "parser.y"
    {
			qualDef *qd;
			int nrneeded;

			/*
			 * Check that exactly one time slot in the set was
			 * requested.
			 */

			nrneeded = 0;

			for (qd = currentModule -> qualifiers; qd != NULL; qd = qd -> next)
				if (qd -> qtype == time_qualifier && isNeeded(qd))
					++nrneeded;

			if (nrneeded != 1)
				yyerror("Exactly one of this %Timeline must be specified with the -t flag");
		}
    break;

  case 55:
#line 449 "parser.y"
    {
			newQualifier(currentModule,currentModule -> nrTimeSlots++,yyvsp[0].text,time_qualifier);
		}
    break;

  case 56:
#line 454 "parser.y"
    {
			int skipNext;

			if (skipStackPtr >= MAX_NESTED_IF)
				yyerror("Internal error: increase the value of MAX_NESTED_IF");

			/* Nested %Ifs are implicit logical ands. */

			if (skipStackPtr > 0)
				yyvsp[-1].boolean = (yyvsp[-1].boolean && skipStack[skipStackPtr - 1]);

			skipStack[skipStackPtr++] = yyvsp[-1].boolean;
		}
    break;

  case 57:
#line 469 "parser.y"
    {
			yyval.boolean = platOrFeature(yyvsp[0].text,FALSE);
		}
    break;

  case 58:
#line 472 "parser.y"
    {
			yyval.boolean = platOrFeature(yyvsp[0].text,TRUE);
		}
    break;

  case 59:
#line 475 "parser.y"
    {
			yyval.boolean = (platOrFeature(yyvsp[0].text,FALSE) || yyvsp[-2].boolean);
		}
    break;

  case 60:
#line 478 "parser.y"
    {
			yyval.boolean = (platOrFeature(yyvsp[0].text,TRUE) || yyvsp[-3].boolean);
		}
    break;

  case 62:
#line 484 "parser.y"
    {
			yyval.boolean = timePeriod(yyvsp[-2].text,yyvsp[0].text);
		}
    break;

  case 63:
#line 489 "parser.y"
    {
			if (skipStackPtr-- <= 0)
				yyerror("Too many %End directives");
		}
    break;

  case 64:
#line 495 "parser.y"
    {
			optFlag *of;

			if (yyvsp[0].optflags.nrFlags == 0)
				yyerror("%License details not specified");

			if ((of = findOptFlag(&yyvsp[0].optflags,"Type",string_flag)) == NULL)
				yyerror("%License type not specified");

			currentModule -> license = sipMalloc(sizeof (licenseDef));

			currentModule -> license -> type = of -> fvalue.sval;

			currentModule -> license -> licensee = 
				((of = findOptFlag(&yyvsp[0].optflags,"Licensee",string_flag)) != NULL)
					? of -> fvalue.sval : NULL;

			currentModule -> license -> timestamp = 
				((of = findOptFlag(&yyvsp[0].optflags,"Timestamp",string_flag)) != NULL)
					? of -> fvalue.sval : NULL;

			currentModule -> license -> sig = 
				((of = findOptFlag(&yyvsp[0].optflags,"Signature",string_flag)) != NULL)
					? of -> fvalue.sval : NULL;
		}
    break;

  case 65:
#line 522 "parser.y"
    {
			/* Check the module hasn't already been defined. */

			moduleDef *mod;

			for (mod = currentSpec -> modules; mod != NULL; mod = mod -> next)
				if (mod -> name != NULL && strcmp(mod -> name,yyvsp[-1].text) == 0)
					yyerror("Module is already defined");

			currentModule -> name = yyvsp[-1].text;
			currentModule -> version = yyvsp[0].number;

			if (currentSpec -> genc < 0)
				currentSpec -> genc = yyvsp[-2].boolean;
			else if (currentSpec -> genc != yyvsp[-2].boolean)
				yyerror("Cannot mix C and C++ modules");
		}
    break;

  case 66:
#line 541 "parser.y"
    {
			yyval.boolean = FALSE;
		}
    break;

  case 67:
#line 544 "parser.y"
    {
			yyval.boolean = TRUE;
		}
    break;

  case 68:
#line 550 "parser.y"
    {
			yyval.number = -1;
		}
    break;

  case 70:
#line 556 "parser.y"
    {
			parseFile(NULL,yyvsp[0].text,NULL,FALSE);
		}
    break;

  case 71:
#line 561 "parser.y"
    {
			parseFile(NULL,yyvsp[0].text,NULL,TRUE);
		}
    break;

  case 72:
#line 566 "parser.y"
    {
			newImport(yyvsp[0].text);
		}
    break;

  case 73:
#line 571 "parser.y"
    {
			yyval.codeb = NULL;
		}
    break;

  case 74:
#line 574 "parser.y"
    {
			yyval.codeb = yyvsp[0].codeb;
		}
    break;

  case 75:
#line 579 "parser.y"
    {
			if (inMainModule())
				appendCodeBlock(&currentSpec -> copying,yyvsp[0].codeb);
		}
    break;

  case 76:
#line 585 "parser.y"
    {
			yyval.codeb = yyvsp[0].codeb;
		}
    break;

  case 77:
#line 590 "parser.y"
    {
			yyval.codeb = yyvsp[0].codeb;
		}
    break;

  case 78:
#line 595 "parser.y"
    {
			yyval.codeb = yyvsp[0].codeb;
		}
    break;

  case 79:
#line 600 "parser.y"
    {
			yyval.codeb = yyvsp[0].codeb;
		}
    break;

  case 80:
#line 605 "parser.y"
    {
			if (inMainModule())
				appendCodeBlock(&currentSpec -> postinitcode,yyvsp[0].codeb);
		}
    break;

  case 81:
#line 611 "parser.y"
    {
			/*
			 * This is a no-op and is retained for compatibility
			 * until the last use of it (by SIP v3) can be removed
			 * from PyQt.
			 */
		}
    break;

  case 82:
#line 620 "parser.y"
    {
			if (inMainModule())
				appendCodeBlock(&currentSpec -> docs,yyvsp[0].codeb);
		}
    break;

  case 83:
#line 626 "parser.y"
    {
			appendCodeBlock(&currentSpec -> docs,yyvsp[0].codeb);
		}
    break;

  case 84:
#line 631 "parser.y"
    {
			if (inMainModule())
				yywarning("%Makefile is ignored, please use the -b flag instead");
		}
    break;

  case 86:
#line 640 "parser.y"
    {
			if (notSkipping())
			{
				if (sectionFlags != 0 && (sectionFlags & ~(SECT_IS_PUBLIC | SECT_IS_PROT)) != 0)
					yyerror("Class enums must be in the public or protected sections");

				currentEnum = newEnum(currentSpec,currentModule,yyvsp[0].text,sectionFlags);
			}
		}
    break;

  case 88:
#line 651 "parser.y"
    {
			yyval.text = NULL;
		}
    break;

  case 89:
#line 654 "parser.y"
    {
			yyval.text = yyvsp[0].text;
		}
    break;

  case 90:
#line 659 "parser.y"
    {
			yyval.text = NULL;
		}
    break;

  case 91:
#line 662 "parser.y"
    {
			yyval.text = yyvsp[0].text;
		}
    break;

  case 98:
#line 677 "parser.y"
    {
			if (notSkipping())
			{
				/*
				 * Note that we don't use the assigned value.
				 * This is a hangover from when enums where
				 * generated in Python.  We can remove it when
				 * we have got around to updating all the .sip
				 * files.
				 */
				enumValueDef *evd;

				evd = sipMalloc(sizeof (enumValueDef));

				evd -> name = cacheName(currentSpec,yyvsp[-2].text);
				evd -> ed = currentEnum;

				checkAttributes(currentSpec,evd -> ed -> ecd,evd -> name,enum_attr);

				evd -> next = currentEnum -> values;
				currentEnum -> values = evd;

				if (inMainModule())
					setIsUsedName(evd -> name);
			}
		}
    break;

  case 101:
#line 709 "parser.y"
    {
			yyval.valp = NULL;
		}
    break;

  case 102:
#line 712 "parser.y"
    {
			yyval.valp = yyvsp[0].valp;
		}
    break;

  case 104:
#line 718 "parser.y"
    {
			valueDef *vd;
 
			if (yyvsp[-2].valp -> vtype == string_value || yyvsp[0].valp -> vtype == string_value)
				yyerror("Invalid binary operator for string");
 
			/* Find the last value in the existing expression. */
 
			for (vd = yyvsp[-2].valp; vd -> next != NULL; vd = vd -> next)
				;
 
			vd -> vbinop = yyvsp[-1].qchar;
			vd -> next = yyvsp[0].valp;

			yyval.valp = yyvsp[-2].valp;
		}
    break;

  case 105:
#line 736 "parser.y"
    {
			yyval.qchar = '-';
		}
    break;

  case 106:
#line 739 "parser.y"
    {
			yyval.qchar = '+';
		}
    break;

  case 107:
#line 742 "parser.y"
    {
			yyval.qchar = '*';
		}
    break;

  case 108:
#line 745 "parser.y"
    {
			yyval.qchar = '/';
		}
    break;

  case 109:
#line 748 "parser.y"
    {
			yyval.qchar = '&';
		}
    break;

  case 110:
#line 751 "parser.y"
    {
			yyval.qchar = '|';
		}
    break;

  case 111:
#line 756 "parser.y"
    {
			yyval.qchar = '\0';
		}
    break;

  case 112:
#line 759 "parser.y"
    {
			yyval.qchar = '!';
		}
    break;

  case 113:
#line 762 "parser.y"
    {
			yyval.qchar = '~';
		}
    break;

  case 114:
#line 765 "parser.y"
    {
			yyval.qchar = '-';
		}
    break;

  case 115:
#line 768 "parser.y"
    {
			yyval.qchar = '+';
		}
    break;

  case 116:
#line 773 "parser.y"
    {
			if (yyvsp[-1].qchar != '\0' && yyvsp[0].value.vtype == string_value)
				yyerror("Invalid unary operator for string");
 
			/*
			 * Convert the value to a simple expression on the
			 * heap.
			 */
 
			yyval.valp = sipMalloc(sizeof (valueDef));
 
			*yyval.valp = yyvsp[0].value;
			yyval.valp -> vunop = yyvsp[-1].qchar;
			yyval.valp -> vbinop = '\0';
			yyval.valp -> next = NULL;
		}
    break;

  case 118:
#line 792 "parser.y"
    {
			if (currentSpec -> genc)
				yyerror("Scoped names are not allowed in a C module");

			appendScopedName(&yyvsp[-2].scpvalp,yyvsp[0].scpvalp);
		}
    break;

  case 119:
#line 800 "parser.y"
    {
			yyval.scpvalp = text2scopePart(yyvsp[0].text);
		}
    break;

  case 120:
#line 805 "parser.y"
    {
			/*
			 * We let the C++ compiler decide if the value is a
			 * valid one - no point in building a full C++ parser
			 * here.
			 */

			yyval.value.vtype = scoped_value;
			yyval.value.u.vscp = yyvsp[0].scpvalp;
		}
    break;

  case 121:
#line 815 "parser.y"
    {
			fcallDef *fcd;

			fcd = sipMalloc(sizeof (fcallDef));
			*fcd = yyvsp[-1].fcall;
			fcd -> name = yyvsp[-3].scpvalp;

			yyval.value.vtype = fcall_value;
			yyval.value.u.fcd = fcd;
		}
    break;

  case 122:
#line 825 "parser.y"
    {
			yyval.value.vtype = real_value;
			yyval.value.u.vreal = yyvsp[0].real;
		}
    break;

  case 123:
#line 829 "parser.y"
    {
			yyval.value.vtype = numeric_value;
			yyval.value.u.vnum = yyvsp[0].number;
		}
    break;

  case 124:
#line 833 "parser.y"
    {
			yyval.value.vtype = numeric_value;
			yyval.value.u.vnum = 1;
		}
    break;

  case 125:
#line 837 "parser.y"
    {
			yyval.value.vtype = numeric_value;
			yyval.value.u.vnum = 0;
		}
    break;

  case 126:
#line 841 "parser.y"
    {
			yyval.value.vtype = string_value;
			yyval.value.u.vstr = yyvsp[0].text;
		}
    break;

  case 127:
#line 845 "parser.y"
    {
			yyval.value.vtype = qchar_value;
			yyval.value.u.vqchar = yyvsp[0].qchar;
		}
    break;

  case 128:
#line 851 "parser.y"
    {
			/* No values. */

			yyval.fcall.nrArgs = 0;
		}
    break;

  case 129:
#line 856 "parser.y"
    {
			/* The single or first value. */

			yyval.fcall.args[0] = yyvsp[0].valp;
			yyval.fcall.nrArgs = 1;
		}
    break;

  case 130:
#line 862 "parser.y"
    {
			/* Check that it wasn't ...(,value...). */

			if (yyval.fcall.nrArgs == 0)
				yyerror("First argument to function call is missing");

			/* Check there is room. */

			if (yyvsp[-2].fcall.nrArgs == MAX_NR_ARGS)
				yyerror("Too many arguments to function call");

			yyval.fcall = yyvsp[-2].fcall;

			yyval.fcall.args[yyval.fcall.nrArgs] = yyvsp[0].valp;
			yyval.fcall.nrArgs++;
		}
    break;

  case 131:
#line 880 "parser.y"
    {
			if (notSkipping())
				newTypedef(currentSpec,yyvsp[-1].text,&yyvsp[-2].memArg);
		}
    break;

  case 132:
#line 884 "parser.y"
    {
			if (notSkipping())
			{
				argDef ftype;
				signatureDef *sig;

				/* Create the full signature on the heap. */
				sig = sipMalloc(sizeof (signatureDef));
				*sig = yyvsp[-2].signature;
				sig -> result = yyvsp[-8].memArg;

				/* Create the full type. */
				ftype.atype = function_type;
				ftype.argflags = 0;
				ftype.nrderefs = yyvsp[-6].number;
				ftype.defval = NULL;
				ftype.u.sa = sig;

				newTypedef(currentSpec,yyvsp[-5].text,&ftype);
			}
		}
    break;

  case 133:
#line 907 "parser.y"
    {
			if (currentSpec -> genc)
				yyerror("class definition not allowed in a C module");

			if (notSkipping())
			{
				classDef *cd;

				cd = newClass(currentSpec,class_iface,yyvsp[-1].scpvalp);

				setCannotCreate(cd);
				setIsOpaque(cd);

				if (inMainModule())
				{
					setIsUsedName(cd -> iff -> name);
					setIsClassName(cd -> iff -> name);
				}
			}
		}
    break;

  case 134:
#line 929 "parser.y"
    {
			if (notSkipping())
			{
				classDef *cd;

				cd = newClass(currentSpec,class_iface,text2scopedName(yyvsp[0].text));

				setCannotCreate(cd);

				pushScope(cd);

				sectionFlags = SECT_IS_PUBLIC;
			}
		}
    break;

  case 135:
#line 942 "parser.y"
    {
			if (notSkipping())
			{
				finishClass(currentSpec,currentScope(),&yyvsp[-4].optflags);
				popScope();
			}
		}
    break;

  case 136:
#line 951 "parser.y"
    {
			if (currentSpec -> genc)
				yyerror("class definition not allowed in a C module");

			if (notSkipping())
			{
				classDef *cd;

				cd = newClass(currentSpec,class_iface,text2scopedName(yyvsp[0].text));

				setCannotCreate(cd);

				pushScope(cd);

				sectionFlags = SECT_IS_PRIVATE;
			}
		}
    break;

  case 137:
#line 967 "parser.y"
    {
			if (notSkipping())
			{
				finishClass(currentSpec,currentScope(),&yyvsp[-4].optflags);
				popScope();
			}
		}
    break;

  case 142:
#line 984 "parser.y"
    {
			if (notSkipping())
			{
				classDef *cd, *super;

				cd = currentScope();

				super = findClass(currentSpec,class_iface,yyvsp[0].scpvalp);

				appendToClassList(&cd -> supers,super);
				addToUsedList(&cd -> iff -> used,super -> iff);
			}
		}
    break;

  case 153:
#line 1011 "parser.y"
    {
			if (notSkipping())
				appendCodeBlock(&currentScope() -> cppcode,yyvsp[0].codeb);
		}
    break;

  case 154:
#line 1015 "parser.y"
    {
			if (notSkipping())
				appendCodeBlock(&currentScope() -> hdrcode,yyvsp[0].codeb);
		}
    break;

  case 158:
#line 1022 "parser.y"
    {
			if (notSkipping())
			{
				classDef *cd = currentScope();

				if (cd -> convtosubcode != NULL)
					yyerror("Class has more than one %ConvertToSubClassCode directive");

				cd -> convtosubcode = yyvsp[0].codeb;
			}
		}
    break;

  case 159:
#line 1033 "parser.y"
    {
			if (notSkipping())
			{
				classDef *cd = currentScope();

				if (cd -> convtocode != NULL)
					yyerror("Class has more than one %ConvertToTypeCode directive");

				cd -> convtocode = yyvsp[0].codeb;
			}
		}
    break;

  case 160:
#line 1044 "parser.y"
    {
			if (currentSpec -> genc)
				yyerror("public section not allowed in a C module");

			if (notSkipping())
				sectionFlags = SECT_IS_PUBLIC | yyvsp[-1].number;
		}
    break;

  case 161:
#line 1051 "parser.y"
    {
			if (currentSpec -> genc)
				yyerror("protected section not allowed in a C module");

			if (notSkipping())
				sectionFlags = SECT_IS_PROT | yyvsp[-1].number;
		}
    break;

  case 162:
#line 1058 "parser.y"
    {
			if (currentSpec -> genc)
				yyerror("private section not allowed in a C module");

			if (notSkipping())
				sectionFlags = SECT_IS_PRIVATE | yyvsp[-1].number;
		}
    break;

  case 163:
#line 1065 "parser.y"
    {
			if (currentSpec -> genc)
				yyerror("signals section not allowed in a C module");

			if (notSkipping())
				sectionFlags = SECT_IS_SIGNAL;
		}
    break;

  case 164:
#line 1074 "parser.y"
    {
			yyval.number = 0;
		}
    break;

  case 165:
#line 1077 "parser.y"
    {
			yyval.number = SECT_IS_SLOT;
		}
    break;

  case 166:
#line 1082 "parser.y"
    {
			if (currentSpec -> genc)
				yyerror("C++ destructor not allowed in a C module");

			if (notSkipping())
			{
				classDef *cd = currentScope();

				if (strcmp(classBaseName(cd),yyvsp[-7].text) != 0)
					yyerror("Destructor doesn't have the same name as its class");

				if (isDtor(cd))
					yyerror("Destructor has already been defined");

				cd -> dealloccode = yyvsp[-1].codeb;
				cd -> dtorcode = yyvsp[0].codeb;
				cd -> dtorexceptions = yyvsp[-4].throwlist;
				cd -> classflags |= sectionFlags;

				/*
				 * Make the class complex if we have a virtual
				 * dtor or some dtor code.
				 */
				if (yyvsp[-9].number || yyvsp[-1].codeb != NULL)
					setIsComplex(cd);

				if (getReleaseGIL(&yyvsp[-3].optflags))
					setIsReleaseGILDtor(cd);
			}
		}
    break;

  case 167:
#line 1114 "parser.y"
    {
			if (currentSpec -> genc)
				yyerror("C++ constructor not allowed in a C module");

			if (notSkipping())
			{
				if ((sectionFlags & (SECT_IS_PUBLIC | SECT_IS_PROT | SECT_IS_PRIVATE)) == 0)
					yyerror("Constructor must be in the public, private or protected sections");

				newCtor(yyvsp[-8].text,sectionFlags,&yyvsp[-6].signature,&yyvsp[-3].optflags,yyvsp[0].codeb,yyvsp[-4].throwlist,yyvsp[-2].optsignature);
			}

			free(yyvsp[-8].text);
		}
    break;

  case 168:
#line 1130 "parser.y"
    {
			yyval.optsignature = NULL;
		}
    break;

  case 169:
#line 1133 "parser.y"
    {
			yyval.optsignature = sipMalloc(sizeof (signatureDef));

			*yyval.optsignature = yyvsp[-2].signature;
		}
    break;

  case 170:
#line 1140 "parser.y"
    {
			yyval.optsignature = NULL;
		}
    break;

  case 171:
#line 1143 "parser.y"
    {
			yyval.optsignature = sipMalloc(sizeof (signatureDef));

			*yyval.optsignature = yyvsp[-2].signature;
			yyval.optsignature -> result = yyvsp[-4].memArg;
		}
    break;

  case 172:
#line 1151 "parser.y"
    {
			yyval.number = FALSE;
		}
    break;

  case 173:
#line 1154 "parser.y"
    {
			yyval.number = TRUE;
		}
    break;

  case 174:
#line 1159 "parser.y"
    {
			if (notSkipping())
			{
				if (sectionFlags != 0 && (sectionFlags & (SECT_IS_PUBLIC | SECT_IS_PROT | SECT_IS_PRIVATE | SECT_IS_SLOT | SECT_IS_SIGNAL)) == 0)
					yyerror("Class function must be in the public, private, protected, slot or signal sections");

				yyvsp[-9].signature.result = yyvsp[-12].memArg;

				newFunction(currentSpec,currentModule,
					    sectionFlags,currentIsStatic,
					    currentOverIsVirt,
					    yyvsp[-11].text,&yyvsp[-9].signature,yyvsp[-7].number,yyvsp[-5].number,&yyvsp[-4].optflags,yyvsp[-1].codeb,yyvsp[0].codeb,yyvsp[-6].throwlist,yyvsp[-3].optsignature);
			}

			currentIsStatic = FALSE;
			currentOverIsVirt = FALSE;
		}
    break;

  case 175:
#line 1176 "parser.y"
    {
			if (notSkipping())
			{
				yyvsp[-7].signature.result = yyvsp[-11].memArg;

				newFunction(currentSpec,currentModule,
					    sectionFlags,currentIsStatic,
					    currentOverIsVirt,
					    yyvsp[-9].text,&yyvsp[-7].signature,yyvsp[-5].number,FALSE,&yyvsp[-3].optflags,yyvsp[0].codeb,NULL,yyvsp[-4].throwlist,yyvsp[-2].optsignature);
			}

			currentIsStatic = FALSE;
			currentOverIsVirt = FALSE;
		}
    break;

  case 176:
#line 1192 "parser.y"
    {yyval.text = "__add__";}
    break;

  case 177:
#line 1193 "parser.y"
    {yyval.text = "__sub__";}
    break;

  case 178:
#line 1194 "parser.y"
    {yyval.text = "__mul__";}
    break;

  case 179:
#line 1195 "parser.y"
    {yyval.text = "__div__";}
    break;

  case 180:
#line 1196 "parser.y"
    {yyval.text = "__mod__";}
    break;

  case 181:
#line 1197 "parser.y"
    {yyval.text = "__and__";}
    break;

  case 182:
#line 1198 "parser.y"
    {yyval.text = "__or__";}
    break;

  case 183:
#line 1199 "parser.y"
    {yyval.text = "__xor__";}
    break;

  case 184:
#line 1200 "parser.y"
    {yyval.text = "__lshift__";}
    break;

  case 185:
#line 1201 "parser.y"
    {yyval.text = "__rshift__";}
    break;

  case 186:
#line 1202 "parser.y"
    {yyval.text = "__iadd__";}
    break;

  case 187:
#line 1203 "parser.y"
    {yyval.text = "__isub__";}
    break;

  case 188:
#line 1204 "parser.y"
    {yyval.text = "__imul__";}
    break;

  case 189:
#line 1205 "parser.y"
    {yyval.text = "__idiv__";}
    break;

  case 190:
#line 1206 "parser.y"
    {yyval.text = "__imod__";}
    break;

  case 191:
#line 1207 "parser.y"
    {yyval.text = "__iand__";}
    break;

  case 192:
#line 1208 "parser.y"
    {yyval.text = "__ior__";}
    break;

  case 193:
#line 1209 "parser.y"
    {yyval.text = "__ixor__";}
    break;

  case 194:
#line 1210 "parser.y"
    {yyval.text = "__ilshift__";}
    break;

  case 195:
#line 1211 "parser.y"
    {yyval.text = "__irshift__";}
    break;

  case 196:
#line 1212 "parser.y"
    {yyval.text = "__invert__";}
    break;

  case 197:
#line 1213 "parser.y"
    {yyval.text = "__call__";}
    break;

  case 198:
#line 1214 "parser.y"
    {yyval.text = "__getitem__";}
    break;

  case 199:
#line 1215 "parser.y"
    {yyval.text = "__lt__";}
    break;

  case 200:
#line 1216 "parser.y"
    {yyval.text = "__le__";}
    break;

  case 201:
#line 1217 "parser.y"
    {yyval.text = "__eq__";}
    break;

  case 202:
#line 1218 "parser.y"
    {yyval.text = "__ne__";}
    break;

  case 203:
#line 1219 "parser.y"
    {yyval.text = "__gt__";}
    break;

  case 204:
#line 1220 "parser.y"
    {yyval.text = "__ge__";}
    break;

  case 205:
#line 1223 "parser.y"
    {
			yyval.number = FALSE;
		}
    break;

  case 206:
#line 1226 "parser.y"
    {
			yyval.number = TRUE;
		}
    break;

  case 207:
#line 1231 "parser.y"
    {
			yyval.number = 0;
		}
    break;

  case 208:
#line 1234 "parser.y"
    {
			if (yyvsp[0].number != 0)
				yyerror("Abstract virtual function '= 0' expected");

			yyval.number = TRUE;
		}
    break;

  case 209:
#line 1242 "parser.y"
    {
			yyval.optflags.nrFlags = 0;
		}
    break;

  case 210:
#line 1245 "parser.y"
    {
			yyval.optflags = yyvsp[-1].optflags;
		}
    break;

  case 211:
#line 1251 "parser.y"
    {
			yyval.optflags.flags[0] = yyvsp[0].flag;
			yyval.optflags.nrFlags = 1;
		}
    break;

  case 212:
#line 1255 "parser.y"
    {
			/* Check there is room. */

			if (yyvsp[-2].optflags.nrFlags == MAX_NR_FLAGS)
				yyerror("Too many optional flags");

			yyval.optflags = yyvsp[-2].optflags;

			yyval.optflags.flags[yyval.optflags.nrFlags++] = yyvsp[0].flag;
		}
    break;

  case 213:
#line 1267 "parser.y"
    {
			yyval.flag.ftype = bool_flag;
			yyval.flag.fname = yyvsp[0].text;
		}
    break;

  case 214:
#line 1271 "parser.y"
    {
			yyval.flag = yyvsp[0].flag;
			yyval.flag.fname = yyvsp[-2].text;
		}
    break;

  case 215:
#line 1277 "parser.y"
    {
			yyval.flag.ftype = name_flag;
			yyval.flag.fvalue.sval = yyvsp[0].text;
		}
    break;

  case 216:
#line 1281 "parser.y"
    {
			yyval.flag.ftype = string_flag;
			yyval.flag.fvalue.sval = yyvsp[0].text;
		}
    break;

  case 217:
#line 1285 "parser.y"
    {
			yyval.flag.ftype = integer_flag;
			yyval.flag.fvalue.ival = yyvsp[0].number;
		}
    break;

  case 218:
#line 1291 "parser.y"
    {
			yyval.codeb = NULL;
		}
    break;

  case 219:
#line 1294 "parser.y"
    {
			yyval.codeb = yyvsp[0].codeb;
		}
    break;

  case 220:
#line 1299 "parser.y"
    {
			yyval.codeb = NULL;
		}
    break;

  case 221:
#line 1302 "parser.y"
    {
			yyval.codeb = yyvsp[0].codeb;
		}
    break;

  case 222:
#line 1307 "parser.y"
    {
			int a, nrrxcon, nrrxdis, nrslotcon, nrslotdis, nrarray, nrarraysize;

			nrrxcon = nrrxdis = nrslotcon = nrslotdis = nrarray = nrarraysize = 0;

			for (a = 0; a < yyvsp[0].signature.nrArgs; ++a)
			{
				argDef *ad = &yyvsp[0].signature.args[a];

				switch (ad -> atype)
				{
				case rxcon_type:
					++nrrxcon;
					break;

				case rxdis_type:
					++nrrxdis;
					break;

				case slotcon_type:
					++nrslotcon;
					break;

				case slotdis_type:
					++nrslotdis;
					break;
				}

				if (isArray(ad))
					++nrarray;

				if (isArraySize(ad))
					++nrarraysize;
			}

			if (nrrxcon != nrslotcon || nrrxcon > 1)
				yyerror("SIP_RXOBJ_CON and SIP_SLOT_CON must both be given and at most once");

			if (nrrxdis != nrslotdis || nrrxdis > 1)
				yyerror("SIP_RXOBJ_DIS and SIP_SLOT_DIS must both be given and at most once");

			if (nrarray != nrarraysize || nrarray > 1)
				yyerror("/Array/ and /ArraySize/ must both be given and at most once");

			yyval.signature = yyvsp[0].signature;
		}
    break;

  case 223:
#line 1355 "parser.y"
    {
			/* No arguments. */

			yyval.signature.nrArgs = 0;
		}
    break;

  case 224:
#line 1360 "parser.y"
    {
			/* The single or first argument. */

			yyval.signature.args[0] = yyvsp[0].memArg;
			yyval.signature.nrArgs = 1;
		}
    break;

  case 225:
#line 1366 "parser.y"
    {
			/* Check that it wasn't ...(,arg...). */

			if (yyvsp[-2].signature.nrArgs == 0)
				yyerror("First argument of list is missing");

			/*
			 * If this argument has no default value, then all
			 * previous ones mustn't either.
			 */

			if (yyvsp[0].memArg.defval == NULL)
			{
				int a;

				for (a = 0; a < yyvsp[-2].signature.nrArgs; ++a)
					if (yyvsp[-2].signature.args[a].defval != NULL)
						yyerror("Compulsory argument given after optional argument");
			}

			/* Check there is room. */

			if (yyvsp[-2].signature.nrArgs == MAX_NR_ARGS)
				yyerror("Internal error - increase the value of MAX_NR_ARGS");

			yyval.signature = yyvsp[-2].signature;

			yyval.signature.args[yyval.signature.nrArgs] = yyvsp[0].memArg;
			yyval.signature.nrArgs++;
		}
    break;

  case 226:
#line 1398 "parser.y"
    {
			yyval.memArg.atype = signal_type;
			yyval.memArg.argflags = 0;
			yyval.memArg.nrderefs = 0;

			currentSpec -> sigslots = TRUE;
		}
    break;

  case 227:
#line 1405 "parser.y"
    {
			yyval.memArg.atype = slot_type;
			yyval.memArg.argflags = 0;
			yyval.memArg.nrderefs = 0;

			currentSpec -> sigslots = TRUE;
		}
    break;

  case 228:
#line 1412 "parser.y"
    {
			yyval.memArg.atype = rxcon_type;
			yyval.memArg.argflags = 0;
			yyval.memArg.nrderefs = 0;

			currentSpec -> sigslots = TRUE;
		}
    break;

  case 229:
#line 1419 "parser.y"
    {
			yyval.memArg.atype = rxdis_type;
			yyval.memArg.argflags = 0;
			yyval.memArg.nrderefs = 0;

			currentSpec -> sigslots = TRUE;
		}
    break;

  case 230:
#line 1426 "parser.y"
    {
			yyval.memArg.atype = slotcon_type;
			yyval.memArg.argflags = 0;
			yyval.memArg.nrderefs = 0;

			yyvsp[-1].signature.result.atype = void_type;
			yyvsp[-1].signature.result.argflags = 0;
			yyvsp[-1].signature.result.nrderefs = 0;

			yyval.memArg.u.sa = sipMalloc(sizeof (signatureDef));
			*yyval.memArg.u.sa = yyvsp[-1].signature;

			currentSpec -> sigslots = TRUE;
		}
    break;

  case 231:
#line 1440 "parser.y"
    {
			yyval.memArg.atype = slotdis_type;
			yyval.memArg.argflags = 0;
			yyval.memArg.nrderefs = 0;

			yyvsp[-1].signature.result.atype = void_type;
			yyvsp[-1].signature.result.argflags = 0;
			yyvsp[-1].signature.result.nrderefs = 0;

			yyval.memArg.u.sa = sipMalloc(sizeof (signatureDef));
			*yyval.memArg.u.sa = yyvsp[-1].signature;

			currentSpec -> sigslots = TRUE;
		}
    break;

  case 232:
#line 1454 "parser.y"
    {
			yyval.memArg.atype = qobject_type;
			yyval.memArg.argflags = 0;
			yyval.memArg.nrderefs = 0;
		}
    break;

  case 233:
#line 1459 "parser.y"
    {
			yyval.memArg = yyvsp[-1].memArg;
			yyval.memArg.defval = yyvsp[0].valp;
		}
    break;

  case 234:
#line 1465 "parser.y"
    {currentIsStatic = TRUE;}
    break;

  case 239:
#line 1473 "parser.y"
    {currentOverIsVirt = TRUE;}
    break;

  case 242:
#line 1477 "parser.y"
    {
			if (notSkipping())
			{
				/* Check the section. */

				if (sectionFlags != 0)
				{
					if ((sectionFlags & SECT_IS_PUBLIC) == 0)
						yyerror("Class variables must be in the public section");

					if (!currentIsStatic && yyvsp[0].codeb != NULL)
						yyerror("%AccessCode cannot be specified for non-static class variables");
				}

				newVar(currentSpec,currentModule,yyvsp[-2].text,currentIsStatic,&yyvsp[-3].memArg,yyvsp[0].codeb);
			}

			currentIsStatic = FALSE;
		}
    break;

  case 243:
#line 1498 "parser.y"
    {
			yyval.memArg = yyvsp[-2].memArg;
			yyval.memArg.nrderefs = yyvsp[-1].number;
			yyval.memArg.argflags = ARG_IS_CONST | yyvsp[0].number;
		}
    break;

  case 244:
#line 1503 "parser.y"
    {
			yyval.memArg = yyvsp[-2].memArg;
			yyval.memArg.nrderefs = yyvsp[-1].number;
			yyval.memArg.argflags = yyvsp[0].number;
		}
    break;

  case 245:
#line 1510 "parser.y"
    {
			yyval.memArg = yyvsp[-1].memArg;

			if (findOptFlag(&yyvsp[0].optflags,"AllowNone",bool_flag) != NULL)
				yyval.memArg.argflags |= ARG_ALLOW_NONE;

			if (findOptFlag(&yyvsp[0].optflags,"GetWrapper",bool_flag) != NULL)
				yyval.memArg.argflags |= ARG_GET_WRAPPER;

			if (findOptFlag(&yyvsp[0].optflags,"Array",bool_flag) != NULL)
				yyval.memArg.argflags |= ARG_ARRAY;

			if (findOptFlag(&yyvsp[0].optflags,"ArraySize",bool_flag) != NULL)
				yyval.memArg.argflags |= ARG_ARRAY_SIZE;

			if (findOptFlag(&yyvsp[0].optflags,"Transfer",bool_flag) != NULL)
				yyval.memArg.argflags |= ARG_XFERRED;

			if (findOptFlag(&yyvsp[0].optflags,"TransferThis",bool_flag) != NULL)
				yyval.memArg.argflags |= ARG_THIS_XFERRED;

			if (findOptFlag(&yyvsp[0].optflags,"TransferBack",bool_flag) != NULL)
				yyval.memArg.argflags |= ARG_XFERRED_BACK;

			if (findOptFlag(&yyvsp[0].optflags,"In",bool_flag) != NULL)
				yyval.memArg.argflags |= ARG_IN;

			if (findOptFlag(&yyvsp[0].optflags,"Out",bool_flag) != NULL)
				yyval.memArg.argflags |= ARG_OUT;

			if (findOptFlag(&yyvsp[0].optflags,"Constrained",bool_flag) != NULL)
			{
				switch (yyval.memArg.atype)
				{
				case int_type:
					yyval.memArg.atype = cint_type;
					break;

				case float_type:
					yyval.memArg.atype = cfloat_type;
					break;

				case double_type:
					yyval.memArg.atype = cdouble_type;
					break;

				default:
					yyerror("/Constrained/ may not be specified for this type");
				}
			}
		}
    break;

  case 246:
#line 1563 "parser.y"
    {
			yyval.number = 0;
		}
    break;

  case 247:
#line 1566 "parser.y"
    {
			if (currentSpec -> genc)
				yyerror("References not allowed in a C module");

			yyval.number = ARG_IS_REF;
		}
    break;

  case 248:
#line 1574 "parser.y"
    {
			yyval.number = 0;
		}
    break;

  case 249:
#line 1577 "parser.y"
    {
			yyval.number = yyvsp[-1].number + 1;
		}
    break;

  case 250:
#line 1582 "parser.y"
    {
			yyval.memArg.atype = defined_type;
			yyval.memArg.u.snd = yyvsp[0].scpvalp;
		}
    break;

  case 251:
#line 1586 "parser.y"
    {
			templateDef *td;

			td = sipMalloc(sizeof(templateDef));
			td -> fqname = yyvsp[-3].scpvalp;
			td -> types = yyvsp[-1].signature;

			yyval.memArg.atype = template_type;
			yyval.memArg.u.td = td;
		}
    break;

  case 252:
#line 1596 "parser.y"
    {
			/* In a C module all structures must be defined. */
			if (currentSpec -> genc)
			{
				yyval.memArg.atype = defined_type;
				yyval.memArg.u.snd = yyvsp[0].scpvalp;
			}
			else
			{
				yyval.memArg.atype = struct_type;
				yyval.memArg.u.sname = yyvsp[0].scpvalp;
			}
		}
    break;

  case 253:
#line 1609 "parser.y"
    {
			yyval.memArg.atype = ushort_type;
		}
    break;

  case 254:
#line 1612 "parser.y"
    {
			yyval.memArg.atype = short_type;
		}
    break;

  case 255:
#line 1615 "parser.y"
    {
			yyval.memArg.atype = uint_type;
		}
    break;

  case 256:
#line 1618 "parser.y"
    {
			yyval.memArg.atype = uint_type;
		}
    break;

  case 257:
#line 1621 "parser.y"
    {
			yyval.memArg.atype = int_type;
		}
    break;

  case 258:
#line 1624 "parser.y"
    {
			yyval.memArg.atype = long_type;
		}
    break;

  case 259:
#line 1627 "parser.y"
    {
			yyval.memArg.atype = ulong_type;
		}
    break;

  case 260:
#line 1630 "parser.y"
    {
			yyval.memArg.atype = float_type;
		}
    break;

  case 261:
#line 1633 "parser.y"
    {
			yyval.memArg.atype = double_type;
		}
    break;

  case 262:
#line 1636 "parser.y"
    {
			yyval.memArg.atype = bool_type;
		}
    break;

  case 263:
#line 1639 "parser.y"
    {
			yyval.memArg.atype = ustring_type;
		}
    break;

  case 264:
#line 1642 "parser.y"
    {
			yyval.memArg.atype = string_type;
		}
    break;

  case 265:
#line 1645 "parser.y"
    {
			yyval.memArg.atype = void_type;
		}
    break;

  case 266:
#line 1648 "parser.y"
    {
			yyval.memArg.atype = pyobject_type;
		}
    break;

  case 267:
#line 1651 "parser.y"
    {
			yyval.memArg.atype = pytuple_type;
		}
    break;

  case 268:
#line 1654 "parser.y"
    {
			yyval.memArg.atype = pylist_type;
		}
    break;

  case 269:
#line 1657 "parser.y"
    {
			yyval.memArg.atype = pydict_type;
		}
    break;

  case 270:
#line 1660 "parser.y"
    {
			yyval.memArg.atype = pycallable_type;
		}
    break;

  case 271:
#line 1663 "parser.y"
    {
			yyval.memArg.atype = pyslice_type;
		}
    break;

  case 272:
#line 1668 "parser.y"
    {
			/* The single or first type. */

			yyval.signature.args[0] = yyvsp[0].memArg;
			yyval.signature.nrArgs = 1;
		}
    break;

  case 273:
#line 1674 "parser.y"
    {
			/* Check that it wasn't ,type... */

			if (yyval.signature.nrArgs == 0)
				yyerror("First type of list is missing");

			/* Check there is room. */

			if (yyvsp[-2].signature.nrArgs == MAX_NR_ARGS)
				yyerror("Internal error - increase the value of MAX_NR_ARGS");

			yyval.signature = yyvsp[-2].signature;

			yyval.signature.args[yyval.signature.nrArgs] = yyvsp[0].memArg;
			yyval.signature.nrArgs++;
		}
    break;

  case 274:
#line 1692 "parser.y"
    {
			yyval.throwlist = NULL;
		}
    break;

  case 275:
#line 1695 "parser.y"
    {
			int e;

			/*
			 * Make sure the exceptions' header files are
			 * included.
			 */

			for (e = 0; e < yyvsp[-1].throwlist -> nrArgs; ++e)
				addToUsedList(&currentScope() -> iff -> used,yyvsp[-1].throwlist -> args[e] -> iff);

			yyval.throwlist = yyvsp[-1].throwlist;
		}
    break;

  case 276:
#line 1710 "parser.y"
    {
			/* Empty list so use a blank. */

			yyval.throwlist = sipMalloc(sizeof (throwArgs));
			yyval.throwlist -> nrArgs = 0;
		}
    break;

  case 277:
#line 1716 "parser.y"
    {
			/* The only or first exception. */

			yyval.throwlist = sipMalloc(sizeof (throwArgs));
			yyval.throwlist -> nrArgs = 1;
			yyval.throwlist -> args[0] = findClass(currentSpec,class_iface,yyvsp[0].scpvalp);
		}
    break;

  case 278:
#line 1723 "parser.y"
    {
			/* Check that it wasn't ...(,arg...). */

			if (yyvsp[-2].throwlist -> nrArgs == 0)
				yyerror("First exception of throw specifier is missing");

			/* Check there is room. */

			if (yyvsp[-2].throwlist -> nrArgs == MAX_NR_ARGS)
				yyerror("Internal error - increase the value of MAX_NR_ARGS");

			yyval.throwlist = yyvsp[-2].throwlist;
			yyval.throwlist -> args[yyval.throwlist -> nrArgs++] = findClass(currentSpec,class_iface,yyvsp[0].scpvalp);
		}
    break;


    }

/* Line 999 of yacc.c.  */
#line 3781 "parser.c"

  yyvsp -= yylen;
  yyssp -= yylen;


  YY_STACK_PRINT (yyss, yyssp);

  *++yyvsp = yyval;


  /* 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 - YYNTOKENS] + *yyssp;
  if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
    yystate = yytable[yystate];
  else
    yystate = yydefgoto[yyn - YYNTOKENS];

  goto yynewstate;


/*------------------------------------.
| yyerrlab -- here on detecting error |
`------------------------------------*/
yyerrlab:
  /* If not already recovering from an error, report this error.  */
  if (!yyerrstatus)
    {
      ++yynerrs;
#if YYERROR_VERBOSE
      yyn = yypact[yystate];

      if (YYPACT_NINF < yyn && yyn < YYLAST)
	{
	  YYSIZE_T yysize = 0;
	  int yytype = YYTRANSLATE (yychar);
	  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 && yyx != YYTERROR)
	      yysize += yystrlen (yytname[yyx]) + 15, yycount++;
	  yysize += yystrlen ("syntax error, unexpected ") + 1;
	  yysize += yystrlen (yytname[yytype]);
	  yymsg = (char *) YYSTACK_ALLOC (yysize);
	  if (yymsg != 0)
	    {
	      char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
	      yyp = yystpcpy (yyp, yytname[yytype]);

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



  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)
        {
	  /* Pop the error token.  */
          YYPOPSTACK;
	  /* Pop the rest of the stack.  */
	  while (yyss < yyssp)
	    {
	      YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
	      yydestruct (yystos[*yyssp], yyvsp);
	      YYPOPSTACK;
	    }
	  YYABORT;
        }

      YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
      yydestruct (yytoken, &yylval);
      yychar = YYEMPTY;

    }

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


/*----------------------------------------------------.
| yyerrlab1 -- error raised explicitly by an action.  |
`----------------------------------------------------*/
yyerrlab1:
  yyerrstatus = 3;	/* Each real token shifted decrements this.  */

  for (;;)
    {
      yyn = yypact[yystate];
      if (yyn != YYPACT_NINF)
	{
	  yyn += YYTERROR;
	  if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
	    {
	      yyn = yytable[yyn];
	      if (0 < yyn)
		break;
	    }
	}

      /* Pop the current state because it cannot handle the error token.  */
      if (yyssp == yyss)
	YYABORT;

      YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
      yydestruct (yystos[yystate], yyvsp);
      yyvsp--;
      yystate = *--yyssp;

      YY_STACK_PRINT (yyss, yyssp);
    }

  if (yyn == YYFINAL)
    YYACCEPT;

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

  *++yyvsp = yylval;


  yystate = yyn;
  goto yynewstate;


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

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

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

yyreturn:
#ifndef yyoverflow
  if (yyss != yyssa)
    YYSTACK_FREE (yyss);
#endif
  return yyresult;
}


#line 1739 "parser.y"



/*
 * Parse the specification.
 */
void parse(sipSpec *spec,FILE *fp,char *filename,stringList *tsl,
	   stringList *xfl)
{
        /* Initialise the spec. */
 
	spec -> modules = NULL;
	spec -> namecache = NULL;
	spec -> ifacefiles = NULL;
	spec -> classes = NULL;
	spec -> mappedtypes = NULL;
	spec -> qobjclass = -1;
	spec -> enums = NULL;
	spec -> vars = NULL;
	spec -> othfuncs = NULL;
	spec -> overs = NULL;
	spec -> typedefs = NULL;
	spec -> copying = NULL;
	spec -> hdrcode = NULL;
	spec -> cppcode = NULL;
	spec -> docs = NULL;
	spec -> postinitcode = NULL;
	spec -> used = NULL;
	spec -> sigargs = NULL;
	spec -> sigslots = FALSE;
	spec -> genc = -1;

	currentSpec = spec;
	neededQualifiers = tsl;
	excludedQualifiers = xfl;
	currentModule = NULL;
	currentMappedType = NULL;
	currentOverIsVirt = FALSE;
	currentIsStatic = FALSE;
	previousFile = NULL;
	skipStackPtr = 0;
	currentScopeIdx = 0;
	sectionFlags = 0;

	newModule(fp,filename);
	spec -> module = currentModule;

	yyparse();

	handleEOF();
	handleEOM();
}


/*
 * Tell the parser that a complete file has now been read.
 */
void parserEOF(char *name,parserContext *pc)
{
	previousFile = sipStrdup(name);
	newContext = *pc;
}


/*
 * Append a class definition to a class list if it doesn't already appear.
 * Append is needed specifically for the list of super-classes because the
 * order is important to Python.
 */
void appendToClassList(classList **clp,classDef *cd)
{
	classList *new;

	/* Find the end of the list. */

	while (*clp != NULL)
	{
		if ((*clp) -> cd == cd)
			return;

		clp = &(*clp) -> next;
	}

	new = sipMalloc(sizeof (classList));

	new -> cd = cd;
	new -> next = NULL;

	*clp = new;
}


/*
 * Create a new module for the current specification and make it current.
 */
static void newModule(FILE *fp,char *filename)
{
	moduleDef *newmod;

	parseFile(fp,filename,currentModule,FALSE);

	newmod = sipMalloc(sizeof (moduleDef));
	newmod -> name = NULL;
	newmod -> version = -1;
	newmod -> modulenr = -1;
	newmod -> file = filename;
	newmod -> qualifiers = NULL;
	newmod -> root.cd = NULL;
	newmod -> root.child = NULL;
	newmod -> nrTimeSlots = -1;
	newmod -> nrclasses = 0;
	newmod -> nrmappedtypes = 0;
	newmod -> nrvirthandlers = 0;
	newmod -> virthandlers = NULL;
	newmod -> license = NULL;
	newmod -> imports = NULL;
	newmod -> next = currentSpec -> modules;

	currentSpec -> modules = newmod;

	/*
	 * If there is a current module then append the new one to its list of
	 * imports.  We know by this time that it hasn't already been imported.
	 */
	if (currentModule != NULL)
	{
		moduleListDef *mld, **tailp;

		/* Find the tail. */
		tailp = &currentModule -> imports;

		while (*tailp != NULL)
			tailp = &(*tailp) -> next;

		mld = sipMalloc(sizeof (moduleListDef));
		mld -> module = newmod;
		mld -> next = NULL;

		*tailp = mld;
	}

	currentModule = newmod;
}


/*
 * Switch to parsing a new file.
 */
static void parseFile(FILE *fp,char *name,moduleDef *prevmod,int optional)
{
	parserContext pc;

	pc.ifdepth = skipStackPtr;
	pc.prevmod = prevmod;

	setInputFile(fp,name,&pc,optional);
}


/*
 * Find an interface file, or create a new one.
 */
static ifaceFileDef *findIfaceFile(sipSpec *pt,scopedNameDef *fqname,
				   ifaceFileType iftype,argDef *ad)
{
	ifaceFileDef *iff;

	/* See if the name is already used. */

	for (iff = pt -> ifacefiles; iff != NULL; iff = iff -> next)
	{
		if (!sameScopedName(iff -> fqname,fqname))
			continue;

		/* They must be the same type. */

		if (iff -> type != iftype)
			yyerror("A class, namespace or mapped type has already been defined with the same name");

		/*
		 * If this is a mapped type with the same name defined in a
		 * different module, then check that this type isn't the same
		 * as any of the mapped types defined in that module.
		 */

		if (iftype == mappedtype_iface && iff -> module != currentModule)
		{
			mappedTypeDef *mtd;

			for (mtd = pt -> mappedtypes; mtd != NULL; mtd = mtd -> next)
			{
				if (mtd -> iff != iff)
					continue;

				if (ad -> atype != template_type ||
				    mtd -> type.atype != template_type ||
				    sameBaseType(ad,&mtd -> type,TRUE))
					yyerror("Mapped type has already been defined in another module");
			}

			/*
			 * If we got here then we have a mapped type based on
			 * an existing template, but with unique parameters.
			 * We don't want to use interface files from other
			 * modules, so skip this one.
			 */

			continue;
		}

		return iff;
	}

	iff = sipMalloc(sizeof (ifaceFileDef));

	iff -> name = cacheName(pt,scopedNameTail(fqname));
	iff -> type = iftype;
	iff -> fqname = fqname;
	iff -> module = NULL;
	iff -> used = NULL;
	iff -> next = pt -> ifacefiles;

	pt -> ifacefiles = iff;

	return iff;
}


/*
 * Find a class definition in a parse tree.
 */
static classDef *findClass(sipSpec *pt,ifaceFileType iftype,
			   scopedNameDef *fqname)
{
	classDef *cd;
	ifaceFileDef *iff;

	/* See if the name is already used. */
	iff = findIfaceFile(pt,fqname,iftype,NULL);

	for (cd = pt -> classes; cd != NULL; cd = cd -> next)
		if (cd -> iff == iff)
			return cd;

	/* Create a new one. */
	cd = sipMalloc(sizeof (classDef));

	cd -> dtorexceptions = NULL;
	cd -> iff = iff;
	cd -> next = pt -> classes;

	pt -> classes = cd;

	return cd;
}


/*
 * Add an interface file to an interface file list if it isn't already there.
 */
void addToUsedList(ifaceFileList **ifflp,ifaceFileDef *iff)
{
	ifaceFileList *iffl;

	while ((iffl = *ifflp) != NULL)
	{
		/* Don't bother if it is already there. */

		if (iffl -> iff == iff)
			return;

		ifflp = &iffl -> next;
	}

	iffl = sipMalloc(sizeof (ifaceFileList));

	iffl -> iff = iff;
	iffl -> next = NULL;

	*ifflp = iffl;
}


/*
 * Find an undefined (or create a new) class definition in a parse tree.
 */
static classDef *newClass(sipSpec *pt,ifaceFileType iftype,
			  scopedNameDef *fqname)
{
	int flags;
	classDef *cd, *scope;
	codeBlock *hdrcode;

	if (sectionFlags & SECT_IS_PRIVATE)
		yyerror("Classes, structs and namespaces must be in the public or or protected sections");

	flags = 0;

	if ((scope = currentScope()) != NULL)
	{
		if (sectionFlags & SECT_IS_PROT)
			flags = CLASS_IS_PROTECTED;

		hdrcode = scope -> hdrcode;
	}
	else
		hdrcode = NULL;

	if (pt -> genc)
	{
		/* C structs are always global types. */
		while (fqname -> next != NULL)
			fqname = fqname -> next;

		scope = NULL;
	}

	cd = findClass(pt,iftype,fqname);

	/* Check it hasn't already been defined. */

	if (cd -> iff -> module != NULL)
	{
		/*
		 * Namespaces can be defined any number of times in the same
		 * module.
		 */

		if (iftype == namespace_iface && cd -> iff -> module == currentModule)
			return cd;

		yyerror(iftype == class_iface ?
			"The struct/class has already been defined" :
			"The namespace has already been defined in another module");
	}

	cd -> iff -> module = currentModule;

	/* Complete the initialisation. */

	cd -> classflags = flags;
	cd -> classnr = -1;
	cd -> ecd = scope;
	cd -> node = NULL;
	cd -> supers = NULL;
	cd -> mro = NULL;
	cd -> ctors = NULL;
	cd -> defctor = NULL;
	cd -> dealloccode = NULL;
	cd -> dtorcode = NULL;
	cd -> members = NULL;
	cd -> overs = NULL;
	cd -> vmembers = NULL;
	cd -> visible = NULL;
	cd -> cppcode = NULL;
	cd -> hdrcode = hdrcode;
	cd -> convtosubcode = NULL;
	cd -> subbase = NULL;
	cd -> convtocode = NULL;

	return cd;
}


/*
 * Tidy up after finishing a class definition.
 */
static void finishClass(sipSpec *pt,classDef *cd,optFlags *of)
{
	int seq_might, seq_not;
	memberDef *md;

	if (cd -> ctors == NULL)
	{
		if (!pt -> genc)
		{
			/* Provide a default ctor. */

			cd -> ctors = sipMalloc(sizeof (ctorDef));
 
			cd -> ctors -> ctorflags = SECT_IS_PUBLIC;
			cd -> ctors -> pysig.nrArgs = 0;
			cd -> ctors -> cppsig = &cd -> ctors -> pysig;
			cd -> ctors -> exceptions = NULL;
			cd -> ctors -> methodcode = NULL;
			cd -> ctors -> prehook = NULL;
			cd -> ctors -> posthook = NULL;
			cd -> ctors -> next = NULL;

			cd -> defctor = cd -> ctors;
		}

		resetCannotCreate(cd);
	}
	else if (cd -> defctor == NULL)
	{
		ctorDef *ct;

		for (ct = cd -> ctors; ct != NULL; ct = ct -> next)
			if (ct -> pysig.nrArgs == 0 || ct -> pysig.args[0].defval != NULL)
			{
				cd -> defctor = ct;
				break;
			}
	}

	/*
	 * We can't create this class if it has private abstract functions or
	 * if it is explicitly annotated as abstract.
	 */
	if (findOptFlag(of,"Abstract",bool_flag) != NULL)
		setCannotCreate(cd);
	else
	{
		overDef *od;

		for (od = cd -> overs; od != NULL; od = od -> next)
			if (isAbstract(od) && isPrivate(od))
			{
				setCannotCreate(cd);
				break;
			}
	}

	/* We assume a public dtor if nothing specific was provided. */
	if (!isDtor(cd))
		setIsPublicDtor(cd);

	if (inMainModule())
	{
		setIsUsedName(cd -> iff -> name);
		setIsClassName(cd -> iff -> name);
	}

	/*
	 * There are subtle differences between the add and concat methods and
	 * the multiply and repeat methods.  The number versions can have their
	 * operands swapped and may return NotImplemented.  If the user has
	 * used the /Numeric/ annotation or there are other numeric operators
	 * then we use add/multiply.  Otherwise, if there are indexing
	 * operators then we use concat/repeat.
	 */
	seq_might = seq_not = FALSE;

	for (md = cd -> members; md != NULL; md = md -> next)
		switch (md -> slot)
		{
		case getitem_slot:
		case setitem_slot:
		case delitem_slot:
			/* This might be a sequence. */
			seq_might = TRUE;
			break;

		case sub_slot:
		case isub_slot:
		case div_slot:
		case idiv_slot:
		case mod_slot:
		case imod_slot:
			/* This is definately not a sequence. */
			seq_not = TRUE;
			break;
		}

	if (!seq_not && seq_might)
		for (md = cd -> members; md != NULL; md = md -> next)
		{
			/* Ignore if the user has been explicit. */
			if (isNumeric(md))
				continue;

			switch (md -> slot)
			{
			case add_slot:
				md -> slot = concat_slot;
				break;

			case iadd_slot:
				md -> slot = iconcat_slot;
				break;

			case mul_slot:
				md -> slot = repeat_slot;
				break;

			case imul_slot:
				md -> slot = irepeat_slot;
				break;
			}
		}
}


/*
 * Create a new mapped type.
 */
static mappedTypeDef *newMappedType(sipSpec *pt,argDef *ad)
{
	mappedTypeDef *mtd;
	scopedNameDef *snd;
	ifaceFileDef *iff;

	/* Check that the type is one we want to map. */
	switch (ad -> atype)
	{
	case defined_type:
		snd = ad -> u.snd;
		break;

	case template_type:
		snd = ad -> u.td -> fqname;
		break;

	case struct_type:
		snd = ad -> u.sname;
		break;

	default:
		yyerror("Invalid type for %MappedType");
	}

	iff = findIfaceFile(pt,snd,mappedtype_iface,ad);

	if (inMainModule())
		setIsUsedName(iff -> name);

	/* Check it hasn't already been defined. */
	for (mtd = pt -> mappedtypes; mtd != NULL; mtd = mtd -> next)
		if (mtd -> iff == iff)
		{
			/*
			 * We allow types based on the same template but with
			 * different arguments.
			 */

			if (ad -> atype != template_type ||
			    sameBaseType(ad,&mtd -> type,TRUE))
				yyerror("Mapped type has already been defined in this module");
		}

	/* The module may not have been set yet. */
	iff -> module = currentModule;

	/* Create a new mapped type. */
	mtd = sipMalloc(sizeof (mappedTypeDef));

	mtd -> type = *ad;
	mtd -> mappednr = -1;
	mtd -> iff = iff;
	mtd -> hdrcode = NULL;
	mtd -> convfromcode = NULL;
	mtd -> convtocode = NULL;
	mtd -> next = pt -> mappedtypes;

	pt -> mappedtypes = mtd;

	return mtd;
}


/*
 * Create a new enum.
 */
static enumDef *newEnum(sipSpec *pt,moduleDef *mod,char *name,int flags)
{
	enumDef *ed;
	classDef *escope = currentScope();

	ed = sipMalloc(sizeof (enumDef));

	ed -> fqname = (name != NULL ? text2scopedName(name) : NULL);
	ed -> ecd = escope;
	ed -> pcd = (flags & SECT_IS_PROT) ? escope : NULL;
	ed -> module = mod;
	ed -> values = NULL;
	ed -> next = pt -> enums;

	pt -> enums = ed;

	if (escope != NULL)
		setHasEnums(escope);

	return ed;
}


/*
 * Create a new typedef.
 */
static void newTypedef(sipSpec *pt,char *name,argDef *type)
{
	typedefDef *td;
	scopedNameDef *fqname = text2scopedName(name);

	/* Check it doesn't already exist. */

	for (td = pt -> typedefs; td != NULL; td = td -> next)
		if (sameScopedName(td -> fqname,fqname))
		{
			fatalScopedName(fqname);
			fatal(" already defined\n");
		}

	td = sipMalloc(sizeof (typedefDef));

	td -> fqname = fqname;
	td -> ecd = currentScope();
	td -> type = *type;
	td -> next = pt -> typedefs;

	pt -> typedefs = td;
}


/*
 * Create a new variable.
 */
static void newVar(sipSpec *pt,moduleDef *mod,char *name,int isstatic,
		   argDef *type,codeBlock *code)
{
	varDef *var;
	classDef *escope = currentScope();
	nameDef *nd = cacheName(pt,name);

	if (inMainModule())
		setIsUsedName(nd);

	checkAttributes(pt,escope,nd,var_attr);

	var = sipMalloc(sizeof (varDef));

	var -> name = nd;
	var -> fqname = text2scopedName(name);
	var -> ecd = escope;
	var -> module = mod;
	var -> varflags = 0;
	var -> type = *type;
	var -> accessfunc = code;
	var -> next = pt -> vars;

	if (isstatic)
		setIsStaticVar(var);

	pt -> vars = var;
}


/*
 * Create a new ctor.
 */
static void newCtor(char *name,int sectFlags,signatureDef *args,
		    optFlags *optflgs,codeBlock *methodcode,
		    throwArgs *exceptions,signatureDef *cppsig)
{
	ctorDef *ct, **ctp;
	classDef *cd = currentScope();

	/* Check the name of the constructor. */
	if (strcmp(classBaseName(cd),name) != 0)
		yyerror("Constructor doesn't have the same name as its class");

	/*
	 * Find the end of the list and, at the same time, check for any
	 * existing one with the same signature.
	 */
	for (ctp = &cd -> ctors; *ctp != NULL; ctp = &(*ctp) -> next)
		if (sameSignature(&(*ctp) -> pysig,args,FALSE))
			yyerror("A constructor with the same Python signature has already been defined");

	/* Add to the list of constructors. */
	ct = sipMalloc(sizeof (ctorDef));

	ct -> ctorflags = sectFlags;
	ct -> pysig = *args;
	ct -> cppsig = (cppsig != NULL ? cppsig : &ct -> pysig);
	ct -> exceptions = exceptions;
	ct -> methodcode = methodcode;
	ct -> next = NULL;

	if (isProtectedCtor(ct))
		setIsComplex(cd);

	if (!isPrivateCtor(ct))
		resetCannotCreate(cd);

	getHooks(optflgs,&ct -> prehook,&ct -> posthook);

	if (getReleaseGIL(optflgs))
		setIsReleaseGILCtor(ct);

	if (findOptFlag(optflgs,"Default",bool_flag) != NULL)
	{
		if (cd -> defctor != NULL)
			yyerror("A constructor with the /Default/ flag has already been defined");

		cd -> defctor = ct;
	}

	*ctp = ct;
}


/*
 * Create a new function.
 */
static void newFunction(sipSpec *pt,moduleDef *mod,int sflags,int isstatic,
			int isvirt,char *name,signatureDef *sig,int isconst,
			int isabstract,optFlags *optflgs,codeBlock *methodcode,
			codeBlock *vcode,throwArgs *exceptions,
			signatureDef *cppsig)
{
	classDef *cd = currentScope();
	char *pname;
	int factory, xferback;
	overDef *od, **odp, **headp;
	optFlag *of;
	virtHandlerDef *vhd;

	/* Extra checks for a C module. */
	if (pt -> genc)
	{
		if (cd != NULL)
			yyerror("Function declaration not allowed in a struct in a C module");

		if (isstatic)
			yyerror("Static functions not allowed in a C module");

		if (exceptions != NULL)
			yyerror("Exceptions not allowed in a C module");
	}

	headp = (cd != NULL ?  &cd -> overs : &pt -> overs);

	/* See if it is a factory method. */
	if (findOptFlag(optflgs,"Factory",bool_flag) != NULL)
		factory = TRUE;
	else
	{
		int a;

		factory = FALSE;

		/* Check /TransferThis/ wasn't specified. */
		for (a = 0; a < sig -> nrArgs; ++a)
			if (isThisTransferred(&sig -> args[a]))
				yyerror("/TransferThis/ may only be specified in constructors and /Factory/ methods");
	}

	/* See if the result is to be returned to Python ownership. */

	xferback = (findOptFlag(optflgs,"TransferBack",bool_flag) != NULL);

	if (factory && xferback)
		yyerror("/TransferBack/ and /Factory/ cannot both be specified");

	/* Use the C++ name if a Python name wasn't given. */

	if ((of = findOptFlag(optflgs,"PyName",name_flag)) != NULL)
		pname = of -> fvalue.sval;
	else
		pname = name;

	/* Create a new overload definition. */

	od = sipMalloc(sizeof (overDef));

	/* Set the overload flags. */

	od -> overflags = sflags;

	if (factory)
		setIsFactory(od);

	if (xferback)
		setIsResultTransferredBack(od);

	if (isProtected(od))
		setIsComplex(cd);

	if ((isSlot(od) || isSignal(od)) && !isPrivate(od))
	{
		if (isSignal(od))
			setIsComplex(cd);

		pt -> sigslots = TRUE;
	}

	if (isSignal(od) && (methodcode != NULL || vcode != NULL))
		yyerror("Cannot provide code for signals");

	if (isstatic)
	{
		if (isSlot(od) || isSignal(od))
			yyerror("Static functions cannot be slots or signals");

		if (isvirt)
			yyerror("Static functions cannot be virtual");

		setIsStatic(od);
	}

	if (isconst)
		setIsConst(od);

	if (isabstract)
	{
		if (sflags == 0)
			yyerror("Non-class function specified as abstract");

		setIsAbstract(od);
	}

	if ((of = findOptFlag(optflgs,"AutoGen",opt_name_flag)) != NULL)
	{
		setIsAutoGen(od);

		if (of -> fvalue.sval != NULL)
		{
			qualDef *qd;

			if ((qd = findQualifier(of -> fvalue.sval)) == NULL || qd -> qtype != feature_qualifier)
				yyerror("No such feature");

			if (excludedFeature(excludedQualifiers,qd))
				resetIsAutoGen(od);
		}
	}

	if (isvirt)
	{
		if (isSignal(od))
			yyerror("Virtual signals aren't supported");

		setIsVirtual(od);
		setIsComplex(cd);

		vhd = sipMalloc(sizeof (virtHandlerDef));

		vhd -> virthandlernr = -1;
		vhd -> vhflags = 0;
		vhd -> sd = (cppsig != NULL ? cppsig : &od -> pysig);
		vhd -> module = currentModule;
		vhd -> virtcode = vcode;
		vhd -> next = currentModule -> virthandlers;

		if (factory || xferback)
			setIsTransferVH(vhd);

		currentModule -> virthandlers = vhd;
	}
	else
	{
		if (vcode != NULL)
			yyerror("%VirtualCatcherCode provided for non-virtual function");

		vhd = NULL;
	}

	od -> cppname = name;
	od -> pysig = *sig;
	od -> cppsig = (cppsig != NULL ? cppsig : &od -> pysig);
	od -> exceptions = exceptions;
	od -> methodcode = methodcode;
	od -> virthandler = vhd;
	od -> common = findFunction(pt,mod,cd,pname,(methodcode != NULL),sig -> nrArgs);

	if (findOptFlag(optflgs,"Numeric",bool_flag) != NULL)
		setIsNumeric(od -> common);

	/* Methods that run in new threads must be virtual. */
	if (findOptFlag(optflgs,"NewThread",bool_flag) != NULL)
	{
		argDef *res;

		if (!isvirt)
			yyerror("/NewThread/ may only be specified for virtual functions");

		/*
		 * This is an arbitary limitation to make the code generator
		 * slightly easier - laziness on my part.
		 */
		res = &od -> cppsig -> result;

		if (res -> atype != void_type || res -> nrderefs != 0)
			yyerror("/NewThread/ may only be specified for void functions");

		setIsNewThread(od);
	}

	getHooks(optflgs,&od -> prehook,&od -> posthook);

	if (getReleaseGIL(optflgs))
		setIsReleaseGIL(od);

	od -> next = NULL;

	/*
	 * Find the end of the list and, at the same time, check for any
	 * existing one with the same signature.
	 */

	for (odp = headp; *odp != NULL; odp = &(*odp) -> next)
	{
		if ((*odp) -> common != od -> common)
			continue;

		if (isConst(*odp) != isConst(od))
			continue;

		if (!sameSignature(&(*odp) -> pysig,&od -> pysig,FALSE))
			continue;

		yyerror("A function with the same Python signature has already been defined");
	}

	*odp = od;
}


/*
 * Cache a name in a module.
 */
static nameDef *cacheName(sipSpec *pt,char *name)
{
	nameDef *nd;

	/* See if it already exists. */
	for (nd = pt -> namecache; nd != NULL; nd = nd -> next)
		if (strcmp(nd -> text,name) == 0)
			return nd;

	/* Create a new one. */
	nd = sipMalloc(sizeof (nameDef));

	nd -> nameflags = 0;
	nd -> module = currentSpec -> module;
	nd -> text = name;
	nd -> next = pt -> namecache;

	pt -> namecache = nd;

	return nd;
}


/*
 * Find (or create) an overloaded function name.
 */
static memberDef *findFunction(sipSpec *pt,moduleDef *mod,classDef *cd,
			       char *pname,int hwcode,int nrargs)
{
	static struct slot_map {
		char *name;		/* The slot name. */
		slotType type;		/* The corresponding type. */
		int needs_hwcode;	/* If handwritten code is required. */
		int nrargs;		/* Nr. of arguments. */
	} slot_table[] = {
		{"__str__", str_slot, TRUE, 0},
		{"__unicode__", unicode_slot, TRUE, 0},
		{"__int__", int_slot, FALSE, 0},
		{"__len__", len_slot, TRUE, 0},
		{"__contains__", contains_slot, TRUE, 1},
		{"__add__", add_slot, FALSE, 1},
		{"__sub__", sub_slot, FALSE, 1},
		{"__mul__", mul_slot, FALSE, 1},
		{"__div__", div_slot, FALSE, 1},
		{"__mod__", mod_slot, FALSE, 1},
		{"__and__", and_slot, FALSE, 1},
		{"__or__", or_slot, FALSE, 1},
		{"__xor__", xor_slot, FALSE, 1},
		{"__lshift__", lshift_slot, FALSE, 1},
		{"__rshift__", rshift_slot, FALSE, 1},
		{"__iadd__", iadd_slot, FALSE, 1},
		{"__isub__", isub_slot, FALSE, 1},
		{"__imul__", imul_slot, FALSE, 1},
		{"__idiv__", idiv_slot, FALSE, 1},
		{"__imod__", imod_slot, FALSE, 1},
		{"__iand__", iand_slot, FALSE, 1},
		{"__ior__", ior_slot, FALSE, 1},
		{"__ixor__", ixor_slot, FALSE, 1},
		{"__ilshift__", ilshift_slot, FALSE, 1},
		{"__irshift__", irshift_slot, FALSE, 1},
		{"__invert__", invert_slot, FALSE, 0},
		{"__call__", call_slot, TRUE, -1},
		{"__getitem__", getitem_slot, TRUE, -1},
		{"__setitem__", setitem_slot, TRUE, -1},
		{"__delitem__", delitem_slot, TRUE, -1},
		{"__lt__", lt_slot, FALSE, 1},
		{"__le__", le_slot, FALSE, 1},
		{"__eq__", eq_slot, FALSE, 1},
		{"__ne__", ne_slot, FALSE, 1},
		{"__gt__", gt_slot, FALSE, 1},
		{"__ge__", ge_slot, FALSE, 1},
		{"__cmp__", cmp_slot, FALSE, 1},
		{"__nonzero__", nonzero_slot, TRUE, 0},
		{"__neg__", neg_slot, FALSE, 0},
		{"__repr__", repr_slot, TRUE, 0},
		{NULL}
	};

	memberDef *md, **flist;
	nameDef *pnd;
	struct slot_map *sm;
	slotType st;

	/* Get the slot type. */
	st = no_slot;

	for (sm = slot_table; sm -> name != NULL; ++sm)
		if (strcmp(sm -> name,pname) == 0)
		{
			if (cd == NULL)
				yyerror("Python slots must be class methods");

			if (sm -> needs_hwcode && !hwcode)
				yyerror("This Python slot requires %MethodCode");

			if (sm -> nrargs < 0)
			{
				int min_nr;

				/* These require a minimum number. */
				switch (sm -> type)
				{
				case getitem_slot:
				case delitem_slot:
					min_nr = 1;
					break;

				case setitem_slot:
					min_nr = 2;
					break;

				default:
					min_nr = 0;
				}

				if (nrargs < min_nr)
					yyerror("Insufficient number of arguments to Python slot");
			}
			else if (sm -> nrargs != nrargs)
				yyerror("Incorrect number of arguments to Python slot");

			st = sm -> type;

			break;
		}

	/* Cache the name. */
	pnd = cacheName(pt,pname);

	if (inMainModule())
		setIsUsedName(pnd);

	/* Check there is no name clash. */
	checkAttributes(pt,cd,pnd,func_attr);

	/* See if it already exists. */
	flist = (cd != NULL ? &cd -> members : &pt -> othfuncs);

	for (md = *flist; md != NULL; md = md -> next)
		if (md -> pyname == pnd)
			return md;

	/* Create a new one. */
	md = sipMalloc(sizeof (memberDef));

	md -> pyname = pnd;
	md -> memberflags = 0;
	md -> slot = st;
	md -> module = mod;
	md -> next = *flist;

	*flist = md;

	return md;
}


/*
 * Search a set of flags for a particular one and check its type.
 */
static optFlag *findOptFlag(optFlags *flgs,char *name,flagType ft)
{
	int f;

	for (f = 0; f < flgs -> nrFlags; ++f)
	{
		optFlag *of = &flgs -> flags[f];

		if (strcmp(of -> fname,name) == 0)
		{
			/*
			 * An optional name can look like a boolean or a name.
			 */

			if (ft == opt_name_flag)
			{
				if (of -> ftype == bool_flag)
				{
					of -> ftype = opt_name_flag;
					of -> fvalue.sval = NULL;
				}
				else if (of -> ftype == name_flag)
					of -> ftype = opt_name_flag;
			}

			if (ft != of -> ftype)
				yyerror("Optional flag has a value of the wrong type");

			return of;
		}
	}

	return NULL;
}


/*
 * A name is going to be used as a Python attribute name within a Python scope
 * (ie. a Python dictionary), so check against what we already know is going in
 * the same scope in case there is a clash.
 */
static void checkAttributes(sipSpec *pt,classDef *pyscope,nameDef *attr,
			    attrType at)
{
	enumDef *ed;
	varDef *vd;
	classDef *cd;

	/* Check the enum values. */

	for (ed = pt -> enums; ed != NULL; ed = ed -> next)
	{
		enumValueDef *evd;

		if (ed -> ecd != pyscope)
			continue;

		for (evd = ed -> values; evd != NULL; evd = evd -> next)
			if (evd -> name == attr)
				yyerror("There is already an enum value in scope with the same Python name");
	}

	/* Check the variables. */

	for (vd = pt -> vars; vd != NULL; vd = vd -> next)
	{
		if (vd -> ecd != pyscope)
			continue;

		if (vd -> name != attr)
			continue;

		yyerror("There is already a variable in scope with the same Python name");
	}

	/*
	 * Only check the members if this attribute isn't a member because we
	 * can handle members with the same name in the same scope.
	 */

	if (at != func_attr)
	{
		memberDef *md, *membs;

		membs = (pyscope != NULL ? pyscope -> members : pt -> othfuncs);

		for (md = membs; md != NULL; md = md -> next)
		{
			overDef *od, *overs;

			if (md -> pyname != attr)
				continue;

			/* Check for a conflict with all overloads. */

			overs = (pyscope != NULL ? pyscope -> overs : pt -> overs);

			for (od = overs; od != NULL; od = od -> next)
			{
				if (od -> common != md)
					continue;

				yyerror("There is already a function in scope with the same Python name");
			}
		}
	}

	/* Check the classes. */

	for (cd = pt -> classes; cd != NULL; cd = cd -> next)
	{
		if (cd -> ecd != pyscope)
			continue;

		if (cd -> iff -> name != attr)
			continue;

		yyerror("There is already a class or namespace in scope with the same Python name");
	}
}


/*
 * Append a code block to a list of them.  Append is needed to give the
 * specifier easy control over the order of the documentation.
 */
static void appendCodeBlock(codeBlock **headp,codeBlock *new)
{
	while (*headp != NULL)
		headp = &(*headp) -> next;

	*headp = new;
}


/*
 * Handle the end of a fully parsed a file.
 */
static void handleEOF()
{
	/*
	 * Check that the number of nested if's is the same as when we started
	 * the file.
	 */

	if (skipStackPtr > newContext.ifdepth)
		fatal("Too many %%If statements in %s\n",previousFile);

	if (skipStackPtr < newContext.ifdepth)
		fatal("Too many %%End statements in %s\n",previousFile);
}


/*
 * Handle the end of a fully parsed a module.
 */
static void handleEOM()
{
	/* Check it has been named. */

	if (currentModule -> name == NULL)
		fatal("No %%Module has been specified for module defined in %s\n",previousFile);

	/* The previous module is now current. */

	currentModule = newContext.prevmod;
}


/*
 * Find an existing qualifier.
 */
static qualDef *findQualifier(char *name)
{
	moduleDef *mod;

	for (mod = currentSpec -> modules; mod != NULL; mod = mod -> next)
	{
		qualDef *qd;

		for (qd = mod -> qualifiers; qd != NULL; qd = qd -> next)
			if (strcmp(qd -> name,name) == 0)
				return qd;
	}

	return NULL;
}


/*
 * Return a copy of a scoped name.
 */
scopedNameDef *copyScopedName(scopedNameDef *snd)
{
	scopedNameDef *head;

	head = NULL;

	while (snd != NULL)
	{
		appendScopedName(&head,text2scopePart(snd -> name));
		snd = snd -> next;
	}

	return head;
}


/*
 * Append a name to a list of scopes.
 */
void appendScopedName(scopedNameDef **headp,scopedNameDef *newsnd)
{
	while (*headp != NULL)
		headp = &(*headp) -> next;

	*headp = newsnd;
}


/*
 * Free a scoped name - but not the text itself.
 */
void freeScopedName(scopedNameDef *snd)
{
	while (snd != NULL)
	{
		scopedNameDef *next = snd -> next;

		free(snd);

		snd = next;
	}
}


/*
 * Convert a text string to a scope part structure.
 */
scopedNameDef *text2scopePart(char *text)
{
	scopedNameDef *snd;

	snd = sipMalloc(sizeof (scopedNameDef));

	snd -> name = text;
	snd -> next = NULL;

	return snd;
}


/*
 * Convert a text string to a fully scoped name.
 */
static scopedNameDef *text2scopedName(char *text)
{
	classDef *cd = currentScope();
	scopedNameDef *snd;

	snd = (cd != NULL ? copyScopedName(cd -> iff -> fqname) : NULL);

	appendScopedName(&snd,text2scopePart(text));

	return snd;
}


/*
 * Return a pointer to the tail part of a scoped name.
 */
char *scopedNameTail(scopedNameDef *snd)
{
	if (snd == NULL)
		return NULL;

	while (snd -> next != NULL)
		snd = snd -> next;

	return snd -> name;
}


/*
 * Push the given scope onto the scope stack.
 */
static void pushScope(classDef *scope)
{
	if (currentScopeIdx >= MAX_NESTED_SCOPE)
		fatal("Internal error: increase the value of MAX_NESTED_SCOPE\n");

	scopeStack[currentScopeIdx] = scope;
	sectFlagsStack[currentScopeIdx] = sectionFlags;

	++currentScopeIdx;
}


/*
 * Pop the scope stack.
 */
static void popScope(void)
{
	if (currentScopeIdx > 0)
		sectionFlags = sectFlagsStack[--currentScopeIdx];
}


/*
 * Return non-zero if the current input should be parsed rather than be
 * skipped.
 */
static int notSkipping()
{
	return (skipStackPtr == 0 ? TRUE : skipStack[skipStackPtr - 1]);
}


/*
 * Return the value of an expression involving a time period.
 */
static int timePeriod(char *lname,char *uname)
{
	int this;
	qualDef *qd, *lower, *upper;
	moduleDef *mod;

	if (lname == NULL)
		lower = NULL;
	else if ((lower = findQualifier(lname)) == NULL || lower -> qtype != time_qualifier)
		yyerror("Lower bound is not a time version");

	if (uname == NULL)
		upper = NULL;
	else if ((upper = findQualifier(uname)) == NULL || upper -> qtype != time_qualifier)
		yyerror("Upper bound is not a time version");

	/* Sanity checks on the bounds. */

	if (lower == NULL && upper == NULL)
		yyerror("Lower and upper bounds cannot both be omitted");

	if (lower != NULL && upper != NULL)
	{
		if (lower -> module != upper -> module)
			yyerror("Lower and upper bounds are from different timelines");

		if (lower == upper)
			yyerror("Lower and upper bounds must be different");

		if (lower -> order > upper -> order)
			yyerror("Later version specified as lower bound");
	}

	/* Go through each slot in the relevant timeline. */

	if (lower != NULL)
		mod = lower -> module;
	else
		mod = upper -> module;

	this = FALSE;

	for (qd = mod -> qualifiers; qd != NULL; qd = qd -> next)
	{
		if (qd -> qtype != time_qualifier)
			continue;

		if (lower != NULL && qd -> order < lower -> order)
			continue;

		if (upper != NULL && qd -> order >= upper -> order)
			continue;

		/*
		 * This is within the required range so if it is also needed
		 * then the expression is true.
		 */

		if (isNeeded(qd))
		{
			this = TRUE;
			break;
		}
	}

	return this;
}


/*
 * Return the value of an expression involving a single platform or feature.
 */
static int platOrFeature(char *name,int optnot)
{
	int this;
	qualDef *qd;

	if ((qd = findQualifier(name)) == NULL || qd -> qtype == time_qualifier)
		yyerror("No such platform or feature");

	/* Assume this sub-expression is false. */

	this = FALSE;

	if (qd -> qtype == feature_qualifier)
	{
		if (!excludedFeature(excludedQualifiers,qd))
			this = TRUE;
	}
	else if (isNeeded(qd))
		this = TRUE;

	if (optnot)
		this = !this;

	return this;
}


/*
 * Return TRUE if the given qualifier is excluded.
 */
int excludedFeature(stringList *xsl,qualDef *qd)
{
	while (xsl != NULL)
	{
		if (strcmp(qd -> name,xsl -> s) == 0)
			return TRUE;

		xsl = xsl -> next;
	}

	return FALSE;
}


/*
 * Return TRUE if the given qualifier is needed.
 */
static int isNeeded(qualDef *qd)
{
	stringList *sl;

	for (sl = neededQualifiers; sl != NULL; sl = sl -> next)
		if (strcmp(qd -> name,sl -> s) == 0)
			return TRUE;

	return FALSE;
}


/*
 * Return the current scope.  currentScope() is only valid if notSkipping()
 * returns non-zero.
 */
static classDef *currentScope(void)
{
	return (currentScopeIdx > 0 ? scopeStack[currentScopeIdx - 1] : NULL);
}


/*
 * Create a new qualifier.
 */
static void newQualifier(moduleDef *mod,int order,char *name,qualType qt)
{
	qualDef *qd;

	/* Check it doesn't already exist. */

	if (findQualifier(name) != NULL)
		yyerror("Version is already defined");

	qd = sipMalloc(sizeof (qualDef));
	qd -> name = name;
	qd -> qtype = qt;
	qd -> module = mod;
	qd -> order = order;
	qd -> next = mod -> qualifiers;
	mod -> qualifiers = qd;
}


/*
 * Create a new imported module.
 */
static void newImport(char *name)
{
	/* Ignore if the file has already been imported. */

	moduleDef *mod;

	for (mod = currentSpec -> modules; mod != NULL; mod = mod -> next)
		if (strcmp(mod -> file,name) == 0)
			return;

	newModule(NULL,name);
}


/*
 * Set up pointers to hook names.
 */
static void getHooks(optFlags *optflgs,char **pre,char **post)
{
	optFlag *of;

	if ((of = findOptFlag(optflgs,"PreHook",name_flag)) != NULL)
		*pre = of -> fvalue.sval;
	else
		*pre = NULL;

	if ((of = findOptFlag(optflgs,"PostHook",name_flag)) != NULL)
		*post = of -> fvalue.sval;
	else
		*post = NULL;
}


/*
 * Get the /ReleaseGIL/ option flag.
 */
static int getReleaseGIL(optFlags *optflgs)
{
	return (findOptFlag(optflgs,"ReleaseGIL",bool_flag) != NULL);
}

