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

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

# define	TK_DOC	257
# define	TK_EXPORTEDDOC	258
# define	TK_MAKEFILE	259
# define	TK_VARCODE	260
# define	TK_POSTINITCODE	261
# define	TK_CPPCODE	262
# define	TK_PREPYCODE	263
# define	TK_PYCODE	264
# define	TK_COPYING	265
# define	TK_MAPPEDTYPE	266
# define	TK_CODEBLOCK	267
# define	TK_IF	268
# define	TK_END	269
# define	TK_NAME	270
# define	TK_FILENAME	271
# define	TK_STRING	272
# define	TK_VIRTUALCODE	273
# define	TK_MEMBERCODE	274
# define	TK_FROMTYPE	275
# define	TK_TOTYPE	276
# define	TK_TOSUBCLASS	277
# define	TK_INCLUDE	278
# define	TK_OPTINCLUDE	279
# define	TK_IMPORT	280
# define	TK_HEADERCODE	281
# define	TK_EXPHEADERCODE	282
# define	TK_MODULE	283
# define	TK_CLASS	284
# define	TK_STRUCT	285
# define	TK_PUBLIC	286
# define	TK_PROTECTED	287
# define	TK_PRIVATE	288
# define	TK_SIGNALS	289
# define	TK_SLOTS	290
# define	TK_BOOL	291
# define	TK_SHORT	292
# define	TK_INT	293
# define	TK_LONG	294
# define	TK_FLOAT	295
# define	TK_DOUBLE	296
# define	TK_CHAR	297
# define	TK_VOID	298
# define	TK_PYOBJECT	299
# define	TK_PYSLICE	300
# define	TK_VIRTUAL	301
# define	TK_ENUM	302
# define	TK_UNSIGNED	303
# define	TK_SCOPE	304
# define	TK_LOGICAL_OR	305
# define	TK_CONST	306
# define	TK_STATIC	307
# define	TK_SIPSIGNAL	308
# define	TK_SIPRXCON	309
# define	TK_SIPRXDIS	310
# define	TK_SIPSLOTCON	311
# define	TK_SIPSLOTDIS	312
# define	TK_NUMBER	313
# define	TK_REAL	314
# define	TK_TYPEDEF	315
# define	TK_NAMESPACE	316
# define	TK_TIMELINE	317
# define	TK_PLATFORMS	318
# define	TK_FEATURE	319
# define	TK_LICENSE	320
# define	TK_EXPOSE	321
# define	TK_QCHAR	322
# define	TK_TRUE	323
# define	TK_FALSE	324
# define	TK_OPERATOR	325
# define	TK_THROW	326

#line 24 "parser.y"

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

#include "sip.h"


#define	MAX_NESTED_IF		10
#define	MAX_NESTED_SCOPE	10

#define	isMainModule(m)		(currentSpec -> module == (m))


/* 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 *,moduleDef *,char *);
static ifaceFileDef *findIfaceFile(sipSpec *,scopedNameDef *,ifaceFileType,
				   argDef *);
static classDef *findClass(sipSpec *,ifaceFileType,scopedNameDef *);
static classDef *newClass(sipSpec *,ifaceFileType,scopedNameDef *);
static void finishClass(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,funcArgs *,codeBlock *,throwArgs *);
static void newFunction(sipSpec *,moduleDef *,int,int,int,
			argDef *,char *,funcArgs *,int,int,optFlags *,
			codeBlock *,codeBlock *,throwArgs *);
static optFlag *findOptFlag(optFlags *,char *,flagType);
static memberDef *findFunction(sipSpec *,moduleDef *,classDef *,char *,
			       slotType);
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(sipSpec *,char *);
static scopedNameDef *text2scopedName(char *);
static void pushScope(classDef *);
static void popScope(void);
static classDef *currentScope(void);
static void newQualifier(sipSpec *,moduleDef *,int,char *,qualType);
static void newImport(sipSpec *,char *);
static void usedInMainModule(sipSpec *,ifaceFileDef *);
static int timePeriod(sipSpec *,char *,char *);
static int platOrFeature(sipSpec *,char *,int);
static int isExcluded(qualDef *qd);
static int isNeeded(qualDef *);
static int notSkipping(void);
static void appendToClassList(classList **,classDef *);

#line 104 "parser.y"
typedef union {
	char		qchar;
	char		*text;
	long		number;
	double		real;
	argDef		memArg;
	funcArgs	arglist;
	throwArgs	*throwlist;
	codeBlock	*codeb;
	valueDef	value;
	valueDef	*valp;
	optFlags	optflags;
	optFlag		flag;
	scopedNameDef	*scpvalp;
	fcallDef	fcall;
	int		boolean;
} YYSTYPE;
#include <stdio.h>



#define	YYFINAL		407
#define	YYFLAG		-32768
#define	YYNTBASE	95

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

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

#if YYDEBUG != 0
static const short yyprhs[] =
{
       0,     0,     2,     5,     6,     9,    11,    13,    15,    17,
      19,    21,    23,    25,    27,    29,    31,    33,    35,    37,
      39,    41,    43,    45,    47,    49,    51,    53,    55,    57,
      59,    61,    63,    65,    67,    69,    71,    72,    80,    82,
      85,    87,    90,    93,    94,   102,   104,   107,   108,   114,
     116,   119,   121,   124,   125,   131,   133,   136,   138,   143,
     145,   148,   152,   157,   159,   163,   165,   168,   171,   175,
     176,   178,   181,   184,   187,   188,   191,   194,   197,   200,
     203,   206,   209,   212,   215,   218,   223,   226,   227,   235,
     236,   238,   239,   241,   243,   246,   248,   250,   254,   255,
     257,   258,   261,   263,   267,   269,   271,   273,   274,   276,
     278,   280,   282,   285,   287,   291,   293,   295,   300,   302,
     304,   306,   308,   310,   312,   313,   315,   319,   324,   328,
     329,   338,   339,   349,   350,   353,   355,   359,   361,   363,
     366,   368,   370,   372,   374,   376,   378,   380,   382,   384,
     386,   388,   390,   393,   396,   400,   404,   408,   411,   412,
     414,   424,   425,   427,   436,   449,   461,   463,   465,   467,
     469,   471,   473,   475,   477,   480,   483,   486,   489,   492,
     495,   498,   501,   504,   507,   511,   515,   517,   520,   523,
     525,   528,   531,   534,   536,   539,   540,   542,   543,   546,
     547,   551,   553,   557,   559,   563,   565,   567,   569,   570,
     573,   574,   577,   579,   580,   582,   586,   588,   590,   592,
     597,   602,   605,   606,   610,   612,   614,   616,   617,   621,
     623,   628,   633,   637,   640,   641,   643,   644,   647,   649,
     654,   657,   660,   662,   664,   667,   669,   671,   674,   676,
     678,   680,   683,   685,   687,   689,   691,   693,   697,   698,
     703,   704,   706
};
static const short yyrhs[] =
{
      96,     0,    95,    96,     0,     0,    97,    98,     0,   122,
       0,   128,     0,   124,     0,   125,     0,   126,     0,   112,
       0,   107,     0,   111,     0,   120,     0,   121,     0,   129,
       0,   130,     0,   131,     0,   132,     0,   133,     0,   134,
       0,   135,     0,   136,     0,   137,     0,   100,     0,    99,
       0,   116,     0,   119,     0,   104,     0,   157,     0,   159,
       0,   156,     0,   155,     0,   139,     0,   170,     0,   188,
       0,     0,    12,   193,   101,    73,   102,    74,    75,     0,
     103,     0,   102,   103,     0,   129,     0,    21,   138,     0,
      22,   138,     0,     0,    62,    16,   105,    73,   106,    74,
      75,     0,    99,     0,   106,    99,     0,     0,    64,   108,
      73,   109,    74,     0,   110,     0,   109,   110,     0,    16,
       0,    65,    16,     0,     0,    63,   113,    73,   114,    74,
       0,   115,     0,   114,   115,     0,    16,     0,    14,    76,
     118,    77,     0,    16,     0,    78,    16,     0,   117,    51,
      16,     0,   117,    51,    78,    16,     0,   117,     0,   142,
      79,   142,     0,    15,     0,    66,   174,     0,    67,    16,
       0,    29,    16,   123,     0,     0,    59,     0,    24,    17,
       0,    25,    17,     0,    26,    17,     0,     0,     6,   138,
       0,    11,   138,     0,    27,   138,     0,    28,   138,     0,
       8,   138,     0,     7,   138,     0,     9,   138,     0,    10,
     138,     0,     3,   138,     0,     4,   138,     0,     5,    17,
     141,   138,     0,    13,    15,     0,     0,    48,   142,   140,
      73,   143,    74,    75,     0,     0,    17,     0,     0,    16,
       0,   144,     0,   143,   144,     0,   116,     0,   119,     0,
      16,   146,   145,     0,     0,    80,     0,     0,    81,   147,
       0,   150,     0,   147,   148,   150,     0,    79,     0,    82,
       0,    83,     0,     0,    78,     0,    84,     0,    79,     0,
      82,     0,   149,   153,     0,   152,     0,   151,    50,   152,
       0,    16,     0,   151,     0,   151,    76,   154,    77,     0,
      60,     0,    59,     0,    69,     0,    70,     0,    18,     0,
      68,     0,     0,   150,     0,   154,    80,   150,     0,    61,
     189,    16,    75,     0,    30,   151,    75,     0,     0,    31,
      16,   158,   174,    73,   164,    74,    75,     0,     0,    30,
      16,   160,   161,   174,    73,   164,    74,    75,     0,     0,
      85,   162,     0,   163,     0,   162,    80,   163,     0,   151,
       0,   165,     0,   164,   165,     0,   116,     0,   119,     0,
     104,     0,   159,     0,   156,     0,   155,     0,   139,     0,
     131,     0,   129,     0,   169,     0,   167,     0,   183,     0,
      23,   138,     0,    22,   138,     0,    32,   166,    85,     0,
      33,   166,    85,     0,    34,   166,    85,     0,    35,    85,
       0,     0,    36,     0,   168,    84,    16,    76,    77,   195,
      75,   178,   179,     0,     0,    47,     0,    16,    76,   180,
      77,   195,   174,    75,   178,     0,   189,    16,    76,   180,
      77,   172,   195,   173,   174,    75,   178,   179,     0,   189,
      71,   171,    76,   180,    77,   172,   195,   174,    75,   178,
       0,    82,     0,    79,     0,    86,     0,    87,     0,    88,
       0,    89,     0,    83,     0,    90,     0,    91,    91,     0,
      92,    92,     0,    82,    81,     0,    79,    81,     0,    86,
      81,     0,    87,    81,     0,    88,    81,     0,    89,    81,
       0,    83,    81,     0,    90,    81,     0,    91,    91,    81,
       0,    92,    92,    81,     0,    84,     0,    76,    77,     0,
      93,    94,     0,    91,     0,    91,    81,     0,    81,    81,
       0,    78,    81,     0,    92,     0,    92,    81,     0,     0,
      52,     0,     0,    81,    59,     0,     0,    87,   175,    87,
       0,   176,     0,   175,    80,   176,     0,    16,     0,    16,
      81,   177,     0,    16,     0,    18,     0,    59,     0,     0,
      20,   138,     0,     0,    19,   138,     0,   181,     0,     0,
     182,     0,   181,    80,   182,     0,    54,     0,    55,     0,
      56,     0,    57,    76,   180,    77,     0,    58,    76,   180,
      77,     0,   190,   146,     0,     0,    53,   184,   185,     0,
     185,     0,   186,     0,   188,     0,     0,    47,   187,   170,
       0,   170,     0,   189,    16,    75,   127,     0,    52,   193,
     192,   191,     0,   193,   192,   191,     0,   189,   174,     0,
       0,    89,     0,     0,   192,    86,     0,   151,     0,   151,
      91,   194,    92,     0,    31,   151,     0,    49,    38,     0,
      38,     0,    49,     0,    49,    39,     0,    39,     0,    40,
       0,    49,    40,     0,    41,     0,    42,     0,    37,     0,
      49,    43,     0,    43,     0,    44,     0,    45,     0,    46,
       0,   189,     0,   194,    80,   189,     0,     0,    72,    76,
     196,    77,     0,     0,   151,     0,   196,    80,   151,     0
};

#endif

#if YYDEBUG != 0
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const short yyrline[] =
{
       0,   236,   237,   240,   257,   259,   260,   261,   262,   263,
     264,   265,   266,   267,   268,   269,   273,   274,   278,   279,
     280,   281,   282,   283,   284,   285,   288,   289,   290,   291,
     292,   293,   294,   295,   296,   297,   300,   309,   323,   324,
     327,   331,   340,   351,   364,   372,   373,   376,   383,   403,
     404,   407,   412,   417,   423,   443,   444,   447,   452,   467,
     470,   473,   476,   481,   482,   487,   493,   520,   543,   556,
     559,   562,   567,   572,   577,   580,   585,   591,   596,   601,
     606,   612,   618,   624,   630,   635,   657,   660,   668,   671,
     674,   679,   682,   687,   688,   691,   692,   693,   720,   721,
     724,   727,   732,   733,   751,   754,   757,   762,   765,   768,
     771,   774,   779,   797,   798,   803,   808,   818,   828,   832,
     836,   840,   844,   848,   854,   859,   865,   883,   889,   903,
     917,   926,   940,   949,   950,   953,   954,   957,   972,   973,
     976,   977,   978,   979,   980,   981,   982,   983,   987,   991,
     992,   993,   994,  1005,  1016,  1020,  1024,  1028,  1034,  1037,
    1042,  1068,  1071,  1076,  1089,  1104,  1116,  1117,  1118,  1119,
    1120,  1121,  1122,  1123,  1124,  1125,  1126,  1127,  1128,  1129,
    1130,  1131,  1132,  1133,  1134,  1135,  1136,  1137,  1138,  1139,
    1140,  1141,  1142,  1143,  1144,  1147,  1150,  1155,  1158,  1166,
    1169,  1175,  1179,  1191,  1195,  1201,  1205,  1209,  1215,  1218,
    1223,  1226,  1231,  1289,  1294,  1300,  1330,  1337,  1344,  1351,
    1361,  1371,  1377,  1378,  1378,  1381,  1382,  1385,  1386,  1386,
    1389,  1410,  1415,  1422,  1463,  1466,  1471,  1474,  1479,  1483,
    1493,  1497,  1500,  1503,  1506,  1509,  1512,  1515,  1518,  1521,
    1524,  1527,  1530,  1533,  1536,  1539,  1544,  1550,  1568,  1571,
    1586,  1592,  1599
};
#endif


#if YYDEBUG != 0 || defined YYERROR_VERBOSE

/* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */
static const char *const yytname[] =
{
  "$", "error", "$undefined.", "TK_DOC", "TK_EXPORTEDDOC", "TK_MAKEFILE", 
  "TK_VARCODE", "TK_POSTINITCODE", "TK_CPPCODE", "TK_PREPYCODE", 
  "TK_PYCODE", "TK_COPYING", "TK_MAPPEDTYPE", "TK_CODEBLOCK", "TK_IF", 
  "TK_END", "TK_NAME", "TK_FILENAME", "TK_STRING", "TK_VIRTUALCODE", 
  "TK_MEMBERCODE", "TK_FROMTYPE", "TK_TOTYPE", "TK_TOSUBCLASS", 
  "TK_INCLUDE", "TK_OPTINCLUDE", "TK_IMPORT", "TK_HEADERCODE", 
  "TK_EXPHEADERCODE", "TK_MODULE", "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_PYSLICE", "TK_VIRTUAL", "TK_ENUM", 
  "TK_UNSIGNED", "TK_SCOPE", "TK_LOGICAL_OR", "TK_CONST", "TK_STATIC", 
  "TK_SIPSIGNAL", "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_EXPOSE", 
  "TK_QCHAR", "TK_TRUE", "TK_FALSE", "TK_OPERATOR", "TK_THROW", "'{'", 
  "'}'", "';'", "'('", "')'", "'!'", "'-'", "','", "'='", "'+'", "'|'", 
  "'~'", "':'", "'*'", "'/'", "'%'", "'&'", "'^'", "'<'", "'>'", "'['", 
  "']'", "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", "expose", 
  "module", "optnumber", "include", "optinclude", "import", "optvarcode", 
  "copying", "hdrcode", "exphdrcode", "cppcode", "postinitcode", 
  "prepycode", "pycode", "doc", "exporteddoc", "makefile", "codeblock", 
  "enum", "@6", "optfilename", "optname", "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", 
  "optvirtual", "ctor", "function", "operatorname", "optconst", 
  "optabstract", "optflags", "flaglist", "flag", "flagvalue", 
  "membercode", "optvirtualcode", "arglist", "rawarglist", "argvalue", 
  "varmember", "@9", "varmem", "member", "@10", "variable", "cpptype", 
  "argtype", "optref", "deref", "basetype", "cpptypelist", 
  "optexceptions", "exceptionlist", NULL
};
#endif

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

/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
static const short yyr2[] =
{
       0,     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,     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,     2,     3,     0,
       1,     2,     2,     2,     0,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     4,     2,     0,     7,     0,
       1,     0,     1,     1,     2,     1,     1,     3,     0,     1,
       0,     2,     1,     3,     1,     1,     1,     0,     1,     1,
       1,     1,     2,     1,     3,     1,     1,     4,     1,     1,
       1,     1,     1,     1,     0,     1,     3,     4,     3,     0,
       8,     0,     9,     0,     2,     1,     3,     1,     1,     2,
       1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
       1,     1,     2,     2,     3,     3,     3,     2,     0,     1,
       9,     0,     1,     8,    12,    11,     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,     4,
       4,     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,     3,     0,     4,
       0,     1,     3
};

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

static const short yydefgoto[] =
{
       1,     2,     3,    45,    46,    47,   126,   225,   226,   280,
     140,   242,    49,   113,   187,   188,    50,    51,   112,   184,
     185,   281,   129,   130,   282,    54,    55,    56,   133,    57,
      58,    59,   195,    60,   283,    62,   284,    64,    65,    66,
      67,    68,    69,    82,   285,   137,   125,   104,   239,   240,
     334,   260,   313,   344,   314,   315,    71,    72,   352,   380,
     286,   287,    75,   136,   288,   134,   177,   232,   233,   289,
     290,   324,   291,   292,   293,   294,   166,   307,   367,   116,
     144,   145,   250,   394,   401,   201,   202,   203,   295,   329,
     296,   297,   328,   298,    79,   205,   169,   122,    80,   148,
     340,   376
};

static const short yypact[] =
{
  -32768,    34,-32768,   374,-32768,    59,    59,    25,    59,    59,
      59,    59,    59,   133,     1,-32768,-32768,    68,    70,    76,
      59,    59,    79,   100,   107,-32768,-32768,-32768,-32768,-32768,
  -32768,-32768,-32768,-32768,-32768,   108,   115,   133,   170,   134,
  -32768,-32768,   136,    44,   143,-32768,-32768,-32768,-32768,-32768,
  -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
  -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
  -32768,   -25,-32768,-32768,-32768,-32768,-32768,-32768,-32768,    23,
  -32768,   151,-32768,-32768,   166,-32768,-32768,-32768,-32768,-32768,
     178,-32768,    11,-32768,-32768,-32768,-32768,-32768,   109,   -18,
      -7,   -11,   146,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
     188,-32768,   147,   148,-32768,   207,-32768,-32768,   178,   170,
      39,   519,   116,-32768,-32768,    59,   154,   145,   217,   184,
     160,   159,-32768,-32768,   157,-32768,    44,   172,   116,   168,
     173,   232,   238,   180,   -54,-32768,-32768,-32768,   -19,   256,
     536,   186,   183,   187,   189,   190,   191,-32768,   192,   193,
     194,   195,   196,   -10,   -12,   171,   203,-32768,-32768,-32768,
  -32768,   124,-32768,    19,-32768,   108,   178,    44,   208,    49,
  -32768,-32768,   502,-32768,    12,-32768,-32768,    24,-32768,    29,
     207,-32768,   170,-32768,    59,-32768,-32768,-32768,-32768,   204,
     206,   210,   209,-32768,    44,   202,-32768,-32768,-32768,-32768,
  -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,   213,-32768,
     214,-32768,   536,    59,    59,    31,-32768,-32768,-32768,   253,
  -32768,   146,   216,-32768,   215,   462,   202,-32768,-32768,    22,
  -32768,-32768,   413,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
  -32768,-32768,-32768,-32768,   536,   536,   254,   536,-32768,    83,
  -32768,-32768,-32768,   243,-32768,-32768,   246,-32768,-32768,   178,
     462,   248,    59,    59,   289,   289,   289,   205,   244,-32768,
  -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,    95,
  -32768,-32768,   245,-32768,-32768,-32768,-32768,-32768,-32768,   247,
     258,-32768,   259,-32768,   260,   261,-32768,   263,-32768,-32768,
  -32768,-32768,-32768,     0,    32,-32768,   254,-32768,-32768,   270,
     536,-32768,-32768,-32768,   251,   255,   257,-32768,   170,   314,
     264,-32768,   325,-32768,-32768,-32768,-32768,-32768,-32768,   267,
     265,-32768,-32768,-32768,    83,-32768,-32768,-32768,-32768,-32768,
  -32768,    -9,-32768,   263,   272,   271,-32768,-32768,-32768,-32768,
      28,-32768,-32768,-32768,   274,   178,   303,    44,-32768,   152,
      44,-32768,   263,   288,   290,   146,   104,-32768,   293,-32768,
     126,   295,    44,   263,-32768,   178,   345,-32768,    83,   345,
     296,   297,   146,    59,   354,-32768,-32768,   345,   345,-32768,
      59,-32768,-32768,   354,-32768,-32768,   375,-32768
};

static const short yypgoto[] =
{
  -32768,   373,-32768,-32768,  -158,-32768,-32768,-32768,   155,     9,
  -32768,-32768,-32768,-32768,-32768,   219,-32768,-32768,-32768,-32768,
     211,     8,-32768,-32768,    10,-32768,-32768,-32768,-32768,-32768,
  -32768,-32768,-32768,-32768,    14,-32768,   388,-32768,-32768,-32768,
  -32768,-32768,-32768,    -6,    13,-32768,-32768,   -69,-32768,   137,
  -32768,   156,-32768,-32768,-32768,  -313,   -16,   275,-32768,-32768,
      15,    16,-32768,-32768,    17,-32768,-32768,-32768,   127,   138,
    -260,  -168,-32768,-32768,-32768,    -2,-32768,    81,-32768,  -126,
  -32768,   220,-32768,  -285,     4,  -200,-32768,   164,-32768,-32768,
      80,-32768,-32768,    18,   -29,-32768,   286,   316,    33,-32768,
    -323,-32768
};


#define	YYLAST		612


static const short yytable[] =
{
      83,    77,    85,    86,    87,    88,    89,   100,   102,   110,
     178,    52,    48,    53,    96,    97,    70,    61,    73,    74,
      76,    78,   263,   131,   241,   118,   190,   127,   183,   331,
     370,   368,  -115,   191,   406,   228,    14,    15,   236,   120,
     186,   118,    84,   118,   373,   247,    91,   248,    16,   382,
     345,   234,   223,   224,   304,   305,   379,  -115,    20,   331,
     391,   192,  -129,    14,    15,   236,   119,   369,   135,   219,
     109,   217,    81,   193,   102,   395,  -129,    92,   258,   341,
     220,   218,   342,   343,   303,    93,   243,    94,   249,   128,
     147,   346,   347,    95,   121,    98,   300,   229,   245,   121,
     348,   349,   350,     9,   396,   266,   230,   325,   326,    14,
      15,   271,   402,   403,   149,   150,    99,   272,   273,   170,
     355,   204,    20,   101,   103,    23,    90,   274,   275,   276,
     277,   115,    25,    26,    27,    28,    29,    30,    31,    32,
      33,    34,   278,    35,    36,   223,   224,    37,   279,    16,
     111,    20,   114,   105,   106,   107,    38,    39,   108,   117,
     231,   309,   310,   252,    90,   311,   123,   312,   132,   330,
      25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
      77,   384,    36,   124,   385,   227,    16,   237,   253,   238,
      52,    48,    53,   204,    16,    70,   118,    73,    74,    76,
      78,    90,   167,   387,   139,   168,   388,    25,    26,    27,
      28,    29,    30,    31,    32,    33,    34,   264,   265,    36,
     141,   142,    37,   143,   -92,   204,   204,   171,   204,  -124,
     309,   310,  -124,   172,   311,   173,   312,   174,   175,   227,
      77,   378,   176,   181,   381,   179,   182,   237,   183,   238,
      52,    48,    53,   231,   186,    70,   390,    73,    74,    76,
      78,   189,   194,   206,   207,   221,   321,   322,   208,   268,
     209,   210,   211,   212,   213,   214,   215,   216,     9,   222,
     254,   235,   255,   259,    14,    15,   271,   256,   270,   257,
     327,   204,   272,   273,   261,   262,   269,    20,   351,   360,
      23,    90,   274,   275,   276,   277,   306,    25,    26,    27,
      28,    29,    30,    31,    32,    33,    34,   278,    35,    36,
     316,   317,    37,   279,   320,   323,   359,   333,  -162,   332,
      16,    38,    39,   335,   336,   339,   356,   337,   338,   363,
     357,   364,   358,   365,   354,    90,   366,   371,   372,   375,
     374,    25,    26,    27,    28,    29,    30,    31,    32,    33,
      34,   361,   377,    36,   150,   393,    37,   383,   386,   392,
     389,   397,   398,   400,     4,   407,   301,     5,     6,     7,
     267,     8,     9,    10,    11,    12,    13,   399,    14,    15,
      16,    63,   299,   146,   404,   244,   318,   353,    17,    18,
      19,    20,    21,    22,    23,    24,   246,   405,   319,   362,
     251,    25,    26,    27,    28,    29,    30,    31,    32,    33,
      34,   308,    35,    36,   180,   138,    37,    14,    15,    16,
       0,     0,     0,     0,     0,    38,    39,    40,    41,    42,
      43,    44,     0,    23,    24,     0,     0,     0,     0,     0,
      25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
       0,    35,    36,     0,     0,    37,     0,     0,     0,     0,
       9,     0,     0,     0,    38,    39,    14,    15,   271,     0,
       0,     0,     0,     0,   272,   273,     0,   302,     0,    20,
       0,     0,    23,    90,   274,   275,   276,   277,     0,    25,
      26,    27,    28,    29,    30,    31,    32,    33,    34,   278,
      35,    36,     0,     0,    37,   279,    14,    15,    16,     0,
       0,     0,     0,    38,    39,     0,     0,     0,     0,     0,
       0,     0,    23,    24,     0,     0,     0,     0,     0,    25,
      26,    27,    28,    29,    30,    31,    32,    33,    34,     0,
      35,    36,    16,     0,    37,     0,     0,     0,     0,     0,
       0,     0,     0,    38,    39,     0,     0,    90,     0,     0,
       0,     0,     0,    25,    26,    27,    28,    29,    30,    31,
      32,    33,    34,     0,     0,    36,     0,     0,    37,     0,
     196,   197,   198,   199,   200,   151,     0,   152,   153,     0,
     154,   155,   156,   157,     0,   158,   159,   160,   161,   162,
     163,   164,   165
};

static const short yycheck[] =
{
       6,     3,     8,     9,    10,    11,    12,    23,    24,    38,
     136,     3,     3,     3,    20,    21,     3,     3,     3,     3,
       3,     3,   222,    92,   182,    50,    80,    16,    16,   289,
     353,   344,    50,    87,     0,    16,    14,    15,    16,    16,
      16,    50,    17,    50,    16,    16,    13,    18,    16,   372,
      18,   177,    21,    22,   254,   255,   369,    75,    27,   319,
     383,    80,    73,    14,    15,    16,    91,    76,    75,    81,
      37,    81,    13,    92,    90,   388,    87,    76,   204,    79,
      92,    91,    82,    83,   242,    17,    74,    17,    59,    78,
     119,    59,    60,    17,    71,    16,    74,    78,    74,    71,
      68,    69,    70,     8,   389,    74,   175,   275,   276,    14,
      15,    16,   397,   398,    75,    76,    16,    22,    23,   125,
     320,   150,    27,    16,    16,    30,    31,    32,    33,    34,
      35,    87,    37,    38,    39,    40,    41,    42,    43,    44,
      45,    46,    47,    48,    49,    21,    22,    52,    53,    16,
      16,    27,    16,    38,    39,    40,    61,    62,    43,    16,
     176,    78,    79,   192,    31,    82,    15,    84,    59,    74,
      37,    38,    39,    40,    41,    42,    43,    44,    45,    46,
     182,    77,    49,    17,    80,   171,    16,   179,   194,   179,
     182,   182,   182,   222,    16,   182,    50,   182,   182,   182,
     182,    31,    86,    77,    16,    89,    80,    37,    38,    39,
      40,    41,    42,    43,    44,    45,    46,   223,   224,    49,
      73,    73,    52,    16,    79,   254,   255,    73,   257,    77,
      78,    79,    80,    16,    82,    51,    84,    77,    79,   225,
     242,   367,    85,    75,   370,    73,    73,   239,    16,   239,
     242,   242,   242,   269,    16,   242,   382,   242,   242,   242,
     242,    81,     6,    77,    81,    94,   272,   273,    81,    16,
      81,    81,    81,    81,    81,    81,    81,    81,     8,    76,
      76,    73,    76,    81,    14,    15,    16,    77,    73,    80,
      85,   320,    22,    23,    81,    81,    80,    27,   314,   328,
      30,    31,    32,    33,    34,    35,    52,    37,    38,    39,
      40,    41,    42,    43,    44,    45,    46,    47,    48,    49,
      77,    75,    52,    53,    76,    36,   328,    80,    84,    84,
      16,    61,    62,    75,    75,    72,    85,    77,    77,    75,
      85,    16,    85,    76,    74,    31,    81,    75,    77,   365,
      76,    37,    38,    39,    40,    41,    42,    43,    44,    45,
      46,    47,    59,    49,    76,    20,    52,    77,    75,   385,
      75,    75,    75,    19,     1,     0,   239,     3,     4,     5,
     225,     7,     8,     9,    10,    11,    12,   393,    14,    15,
      16,     3,   236,   118,   400,   184,   269,   316,    24,    25,
      26,    27,    28,    29,    30,    31,   187,   403,   270,   329,
     190,    37,    38,    39,    40,    41,    42,    43,    44,    45,
      46,   257,    48,    49,   138,   109,    52,    14,    15,    16,
      -1,    -1,    -1,    -1,    -1,    61,    62,    63,    64,    65,
      66,    67,    -1,    30,    31,    -1,    -1,    -1,    -1,    -1,
      37,    38,    39,    40,    41,    42,    43,    44,    45,    46,
      -1,    48,    49,    -1,    -1,    52,    -1,    -1,    -1,    -1,
       8,    -1,    -1,    -1,    61,    62,    14,    15,    16,    -1,
      -1,    -1,    -1,    -1,    22,    23,    -1,    74,    -1,    27,
      -1,    -1,    30,    31,    32,    33,    34,    35,    -1,    37,
      38,    39,    40,    41,    42,    43,    44,    45,    46,    47,
      48,    49,    -1,    -1,    52,    53,    14,    15,    16,    -1,
      -1,    -1,    -1,    61,    62,    -1,    -1,    -1,    -1,    -1,
      -1,    -1,    30,    31,    -1,    -1,    -1,    -1,    -1,    37,
      38,    39,    40,    41,    42,    43,    44,    45,    46,    -1,
      48,    49,    16,    -1,    52,    -1,    -1,    -1,    -1,    -1,
      -1,    -1,    -1,    61,    62,    -1,    -1,    31,    -1,    -1,
      -1,    -1,    -1,    37,    38,    39,    40,    41,    42,    43,
      44,    45,    46,    -1,    -1,    49,    -1,    -1,    52,    -1,
      54,    55,    56,    57,    58,    76,    -1,    78,    79,    -1,
      81,    82,    83,    84,    -1,    86,    87,    88,    89,    90,
      91,    92,    93
};
/* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
#line 3 "/usr/share/bison/bison.simple"

/* Skeleton output parser for bison,
   Copyright 1984, 1989, 1990, 2000, 2001 Free Software Foundation, Inc.

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

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.  */

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

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

#ifndef YYSTACK_USE_ALLOCA
# ifdef alloca
#  define YYSTACK_USE_ALLOCA 1
# else /* alloca not defined */
#  ifdef __GNUC__
#   define YYSTACK_USE_ALLOCA 1
#   define alloca __builtin_alloca
#  else /* not GNU C.  */
#   if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
#    define YYSTACK_USE_ALLOCA 1
#    include <alloca.h>
#   else /* not sparc */
     /* We think this test detects Watcom and Microsoft C.  */
     /* This used to test MSDOS, but that is a bad idea since that
	symbol is in the user namespace.  */
#    if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
#     if 0
       /* No need for malloc.h, which pollutes the namespace; instead,
	  just don't use alloca.  */
#      include <malloc.h>
#     endif
#    else /* not MSDOS, or __TURBOC__ */
#     if defined(_AIX)
       /* I don't know what this was needed for, but it pollutes the
	  namespace.  So I turned it off.  rms, 2 May 1997.  */
       /* #include <malloc.h>  */
 #pragma alloca
#      define YYSTACK_USE_ALLOCA 1
#     else /* not MSDOS, or __TURBOC__, or _AIX */
#      if 0
	/* haible@ilog.fr says this works for HPUX 9.05 and up, and on
	   HPUX 10.  Eventually we can turn this on.  */
#       ifdef __hpux
#        define YYSTACK_USE_ALLOCA 1
#        define alloca __builtin_alloca
#  	endif /* __hpux */
#      endif
#     endif /* not _AIX */
#    endif /* not MSDOS, or __TURBOC__ */
#   endif /* not sparc */
#  endif /* not GNU C */
# endif /* alloca not defined */
#endif /* YYSTACK_USE_ALLOCA not defined */

#if YYSTACK_USE_ALLOCA
# define YYSTACK_ALLOC alloca
#else
# define YYSTACK_ALLOC malloc
#endif

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

#define YYTERROR	1
#define YYERRCODE	256


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

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

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


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

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


/* Enable debugging if requested.  */
#if YYDEBUG
# define YYDPRINTF(Args)			\
do {						\
  if (yydebug)					\
    fprintf Args;				\
} while (0)
/* Nonzero means print parse trace. [The following comment makes no
   sense to me.  Could someone clarify it?  --akim] Since this is
   uninitialized, it does not stop multiple parsers from coexisting.
   */
int yydebug;
#else /* !YYDEBUG */
# define YYDPRINTF(Args)
#endif /* !YYDEBUG */

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

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

#ifndef YYMAXDEPTH
# define YYMAXDEPTH 10000
#endif

/* Define __yy_memcpy.  Note that the size argument
   should be passed with type unsigned int, because that is what the non-GCC
   definitions require.  With GCC, __builtin_memcpy takes an arg
   of type size_t, but it can handle unsigned int.  */

#if __GNUC__ > 1		/* GNU C and GNU C++ define this.  */
# define __yy_memcpy(To, From, Count)	__builtin_memcpy (To, From, Count)
#else				/* not GNU C or C++ */

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

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

#endif

#line 212 "/usr/share/bison/bison.simple"


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

#ifdef YYPARSE_PARAM
# ifdef __cplusplus
#  define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
#  define YYPARSE_PARAM_DECL
# else /* !__cplusplus */
#  define YYPARSE_PARAM_ARG YYPARSE_PARAM
#  define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
# endif /* !__cplusplus */
#else /* !YYPARSE_PARAM */
# define YYPARSE_PARAM_ARG
# define YYPARSE_PARAM_DECL
#endif /* !YYPARSE_PARAM */

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

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

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

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


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

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

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

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

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

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

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

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

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

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

  int yystacksize = YYINITDEPTH;
  int yyfree_stacks = 0;


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

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

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

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

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

  yyssp = yyss;
  yyvsp = yyvs;
#if YYLSP_NEEDED
  yylsp = yyls;
#endif
  goto yysetstate;

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

  if (yyssp >= yyss + yystacksize - 1)
    {
      /* 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;
#if YYLSP_NEEDED
      YYLTYPE *yyls1 = yyls;
#endif

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

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

      yyss = yyss1; yyvs = yyvs1;
# if YYLSP_NEEDED
      yyls = yyls1;
# endif
#else /* no yyoverflow */
      /* Extend the stack our own way.  */
      if (yystacksize >= YYMAXDEPTH)
	{
	  yyerror ("parser stack overflow");
	  if (yyfree_stacks)
	    {
	      free (yyss);
	      free (yyvs);
# if YYLSP_NEEDED
	      free (yyls);
# endif
	    }
	  return 2;
	}
      yystacksize *= 2;
      if (yystacksize > YYMAXDEPTH)
	yystacksize = YYMAXDEPTH;
# ifndef YYSTACK_USE_ALLOCA
      yyfree_stacks = 1;
# endif
      yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
      __yy_memcpy ((char *)yyss, (char *)yyss1,
		   size * (unsigned int) sizeof (*yyssp));
      yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
      __yy_memcpy ((char *)yyvs, (char *)yyvs1,
		   size * (unsigned int) sizeof (*yyvsp));
# if YYLSP_NEEDED
      yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
      __yy_memcpy ((char *)yyls, (char *)yyls1,
		   size * (unsigned int) sizeof (*yylsp));
# endif
#endif /* no yyoverflow */

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

      YYDPRINTF ((stderr, "Stack size increased to %d\n", yystacksize));

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

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

  goto yybackup;


/*-----------.
| yybackup.  |
`-----------*/
yybackup:

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

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

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

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

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

  if (yychar == YYEMPTY)
    {
      YYDPRINTF ((stderr, "Reading a token: "));
      yychar = YYLEX;
    }

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

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

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

#if YYDEBUG
     /* We have to keep this `#if YYDEBUG', since we use variables
	which are defined only if `YYDEBUG' is set.  */
      if (yydebug)
	{
	  fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
	  /* Give the individual parser a way to print the precise
	     meaning of a token, for further debugging info.  */
# ifdef YYPRINT
	  YYPRINT (stderr, yychar, yylval);
# endif
	  fprintf (stderr, ")\n");
	}
#endif
    }

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

  yyn = yytable[yyn];

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

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

  if (yyn == YYFINAL)
    YYACCEPT;

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

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

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

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

  yystate = yyn;
  goto yynewstate;


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


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

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

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

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

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

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

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

  switch (yyn) {

case 3:
#line 240 "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 269 "parser.y"
{
			if (notSkipping() && isMainModule(currentModule))
				appendCodeBlock(&currentSpec -> hdrcode,yyvsp[0].codeb);
		;
    break;}
case 17:
#line 274 "parser.y"
{
			if (notSkipping() && isMainModule(currentModule))
				appendCodeBlock(&currentSpec -> cppcode,yyvsp[0].codeb);
		;
    break;}
case 36:
#line 300 "parser.y"
{
			if (notSkipping())
			{
				yyvsp[0].memArg.nrderefs = 0;
				yyvsp[0].memArg.argflags = 0;

				currentMappedType = newMappedType(currentSpec,&yyvsp[0].memArg);
				usedInMainModule(currentSpec,currentMappedType -> iff);
			}
		;
    break;}
case 37:
#line 309 "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 40:
#line 327 "parser.y"
{
			if (notSkipping())
				appendCodeBlock(&currentMappedType -> hdrcode,yyvsp[0].codeb);
		;
    break;}
case 41:
#line 331 "parser.y"
{
			if (notSkipping())
			{
				if (currentMappedType -> convfromcode != NULL)
					yyerror("%MappedType has more than one %ConvertFromTypeCode directive");

				currentMappedType -> convfromcode = yyvsp[0].codeb;
			}
		;
    break;}
case 42:
#line 340 "parser.y"
{
			if (notSkipping())
			{
				if (currentMappedType -> convtocode != NULL)
					yyerror("%MappedType has more than one %ConvertToTypeCode directive");

				currentMappedType -> convtocode = yyvsp[0].codeb;
			}
		;
    break;}
case 43:
#line 351 "parser.y"
{
			if (notSkipping())
			{
				classDef *ns;

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

				pushScope(ns);

				sectionFlags = 0;
			}
		;
    break;}
case 44:
#line 364 "parser.y"
{
			/* Remove the namespace name. */

			if (notSkipping())
				popScope();
		;
    break;}
case 47:
#line 376 "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 48:
#line 383 "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 51:
#line 407 "parser.y"
{
			newQualifier(currentSpec,currentModule,-1,yyvsp[0].text,platform_qualifier);
		;
    break;}
case 52:
#line 412 "parser.y"
{
			newQualifier(currentSpec,currentModule,-1,yyvsp[0].text,feature_qualifier);
		;
    break;}
case 53:
#line 417 "parser.y"
{
			if (currentModule -> nrTimeSlots >= 0)
				yyerror("%Timeline has already been defined for this module");

			currentModule -> nrTimeSlots = 0;
		;
    break;}
case 54:
#line 423 "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 57:
#line 447 "parser.y"
{
			newQualifier(currentSpec,currentModule,currentModule -> nrTimeSlots++,yyvsp[0].text,time_qualifier);
		;
    break;}
case 58:
#line 452 "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 59:
#line 467 "parser.y"
{
			yyval.boolean = platOrFeature(currentSpec,yyvsp[0].text,FALSE);
		;
    break;}
case 60:
#line 470 "parser.y"
{
			yyval.boolean = platOrFeature(currentSpec,yyvsp[0].text,TRUE);
		;
    break;}
case 61:
#line 473 "parser.y"
{
			yyval.boolean = (platOrFeature(currentSpec,yyvsp[0].text,FALSE) || yyvsp[-2].boolean);
		;
    break;}
case 62:
#line 476 "parser.y"
{
			yyval.boolean = (platOrFeature(currentSpec,yyvsp[0].text,TRUE) || yyvsp[-3].boolean);
		;
    break;}
case 64:
#line 482 "parser.y"
{
			yyval.boolean = timePeriod(currentSpec,yyvsp[-2].text,yyvsp[0].text);
		;
    break;}
case 65:
#line 487 "parser.y"
{
			if (skipStackPtr-- <= 0)
				yyerror("Too many %End directives");
		;
    break;}
case 66:
#line 493 "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 67:
#line 520 "parser.y"
{
			/* Only bother if this is the main module. */

			if (isMainModule(currentModule))
			{
				expFuncDef *ef;

				/* Check it isn't already there. */

				for (ef = currentSpec -> exposed; ef != NULL; ef = ef -> next)
					if (strcmp(ef -> name,yyvsp[0].text) == 0)
						yyerror("Function has already been exposed in this module");

				ef = sipMalloc(sizeof (expFuncDef));

				ef -> name = yyvsp[0].text;
				ef -> next = currentSpec -> exposed;

				currentSpec -> exposed = ef;
			}
		;
    break;}
case 68:
#line 543 "parser.y"
{
			/* Check the module hasn't already been defined. */

			moduleDef *mod;

			for (mod = currentSpec -> moduleList; 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;
		;
    break;}
case 69:
#line 556 "parser.y"
{
			yyval.number = -1;
		;
    break;}
case 71:
#line 562 "parser.y"
{
			parseFile(NULL,yyvsp[0].text,NULL,FALSE);
		;
    break;}
case 72:
#line 567 "parser.y"
{
			parseFile(NULL,yyvsp[0].text,NULL,TRUE);
		;
    break;}
case 73:
#line 572 "parser.y"
{
			newImport(currentSpec,yyvsp[0].text);
		;
    break;}
case 74:
#line 577 "parser.y"
{
			yyval.codeb = NULL;
		;
    break;}
case 75:
#line 580 "parser.y"
{
			yyval.codeb = yyvsp[0].codeb;
		;
    break;}
case 76:
#line 585 "parser.y"
{
			if (isMainModule(currentModule))
				appendCodeBlock(&currentSpec -> copying,yyvsp[0].codeb);
		;
    break;}
case 77:
#line 591 "parser.y"
{
			yyval.codeb = yyvsp[0].codeb;
		;
    break;}
case 78:
#line 596 "parser.y"
{
			appendCodeBlock(&currentSpec -> exphdrcode,yyvsp[0].codeb);
		;
    break;}
case 79:
#line 601 "parser.y"
{
			yyval.codeb = yyvsp[0].codeb;
		;
    break;}
case 80:
#line 606 "parser.y"
{
			if (isMainModule(currentModule))
				appendCodeBlock(&currentSpec -> postinitcode,yyvsp[0].codeb);
		;
    break;}
case 81:
#line 612 "parser.y"
{
			if (isMainModule(currentModule))
				appendCodeBlock(&currentSpec -> prepycode,yyvsp[0].codeb);
		;
    break;}
case 82:
#line 618 "parser.y"
{
			if (isMainModule(currentModule))
				appendCodeBlock(&currentSpec -> pycode,yyvsp[0].codeb);
		;
    break;}
case 83:
#line 624 "parser.y"
{
			if (isMainModule(currentModule))
				appendCodeBlock(&currentSpec -> docs,yyvsp[0].codeb);
		;
    break;}
case 84:
#line 630 "parser.y"
{
			appendCodeBlock(&currentSpec -> docs,yyvsp[0].codeb);
		;
    break;}
case 85:
#line 635 "parser.y"
{
			if (isMainModule(currentModule))
			{
				mkTemplateDef *mtd;

				mtd = sipMalloc(sizeof (mkTemplateDef));

				mtd -> name = yyvsp[-2].text;

				if ((mtd -> objext = yyvsp[-1].text) == NULL)
					mtd -> objext = DEFAULT_OFILE_EXT;

				mtd -> templ = NULL;

				appendCodeBlock(&mtd -> templ,yyvsp[0].codeb);

				mtd -> next = currentSpec -> mktemplates;
				currentSpec -> mktemplates = mtd;
			}
		;
    break;}
case 87:
#line 660 "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 89:
#line 671 "parser.y"
{
			yyval.text = NULL;
		;
    break;}
case 90:
#line 674 "parser.y"
{
			yyval.text = yyvsp[0].text;
		;
    break;}
case 91:
#line 679 "parser.y"
{
			yyval.text = NULL;
		;
    break;}
case 92:
#line 682 "parser.y"
{
			yyval.text = yyvsp[0].text;
		;
    break;}
case 97:
#line 693 "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,currentModule,yyvsp[-2].text);
				evd -> ed = currentEnum;

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

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

			}
		;
    break;}
case 100:
#line 724 "parser.y"
{
			yyval.valp = NULL;
		;
    break;}
case 101:
#line 727 "parser.y"
{
			yyval.valp = yyvsp[0].valp;
		;
    break;}
case 103:
#line 733 "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 104:
#line 751 "parser.y"
{
			yyval.qchar = '-';
		;
    break;}
case 105:
#line 754 "parser.y"
{
			yyval.qchar = '+';
		;
    break;}
case 106:
#line 757 "parser.y"
{
			yyval.qchar = '|';
		;
    break;}
case 107:
#line 762 "parser.y"
{
			yyval.qchar = '\0';
		;
    break;}
case 108:
#line 765 "parser.y"
{
			yyval.qchar = '!';
		;
    break;}
case 109:
#line 768 "parser.y"
{
			yyval.qchar = '~';
		;
    break;}
case 110:
#line 771 "parser.y"
{
			yyval.qchar = '-';
		;
    break;}
case 111:
#line 774 "parser.y"
{
			yyval.qchar = '+';
		;
    break;}
case 112:
#line 779 "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 114:
#line 798 "parser.y"
{
			appendScopedName(&yyvsp[-2].scpvalp,yyvsp[0].scpvalp);
		;
    break;}
case 115:
#line 803 "parser.y"
{
			yyval.scpvalp = text2scopePart(yyvsp[0].text);
		;
    break;}
case 116:
#line 808 "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 117:
#line 818 "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 118:
#line 828 "parser.y"
{
			yyval.value.vtype = real_value;
			yyval.value.u.vreal = yyvsp[0].real;
		;
    break;}
case 119:
#line 832 "parser.y"
{
			yyval.value.vtype = numeric_value;
			yyval.value.u.vnum = yyvsp[0].number;
		;
    break;}
case 120:
#line 836 "parser.y"
{
			yyval.value.vtype = numeric_value;
			yyval.value.u.vnum = 1;
		;
    break;}
case 121:
#line 840 "parser.y"
{
			yyval.value.vtype = numeric_value;
			yyval.value.u.vnum = 0;
		;
    break;}
case 122:
#line 844 "parser.y"
{
			yyval.value.vtype = string_value;
			yyval.value.u.vstr = yyvsp[0].text;
		;
    break;}
case 123:
#line 848 "parser.y"
{
			yyval.value.vtype = qchar_value;
			yyval.value.u.vqchar = yyvsp[0].qchar;
		;
    break;}
case 124:
#line 854 "parser.y"
{
			/* No values. */

			yyval.fcall.nrArgs = 0;
		;
    break;}
case 125:
#line 859 "parser.y"
{
			/* The single or first value. */

			yyval.fcall.args[0] = yyvsp[0].valp;
			yyval.fcall.nrArgs = 1;
		;
    break;}
case 126:
#line 865 "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 127:
#line 883 "parser.y"
{
			if (notSkipping())
				newTypedef(currentSpec,yyvsp[-1].text,&yyvsp[-2].memArg);
		;
    break;}
case 128:
#line 889 "parser.y"
{
			if (notSkipping())
			{
				classDef *cd;

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

				usedInMainModule(currentSpec,cd -> iff);
				setCannotCreate(cd);
				setIsOpaque(cd);
			}
		;
    break;}
case 129:
#line 903 "parser.y"
{
			if (notSkipping())
			{
				classDef *cd;

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

				usedInMainModule(currentSpec,cd -> iff);
				setCannotCreate(cd);

				pushScope(cd);

				sectionFlags = SECT_IS_PUBLIC;
			}
		;
    break;}
case 130:
#line 917 "parser.y"
{
			if (notSkipping())
			{
				finishClass(currentScope(),&yyvsp[-4].optflags);
				popScope();
			}
		;
    break;}
case 131:
#line 926 "parser.y"
{
			if (notSkipping())
			{
				classDef *cd;

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

				usedInMainModule(currentSpec,cd -> iff);
				setCannotCreate(cd);

				pushScope(cd);

				sectionFlags = SECT_IS_PRIVATE;
			}
		;
    break;}
case 132:
#line 940 "parser.y"
{
			if (notSkipping())
			{
				finishClass(currentScope(),&yyvsp[-4].optflags);
				popScope();
			}
		;
    break;}
case 137:
#line 957 "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 147:
#line 983 "parser.y"
{
			if (notSkipping())
				appendCodeBlock(&currentScope() -> cppcode,yyvsp[0].codeb);
		;
    break;}
case 148:
#line 987 "parser.y"
{
			if (notSkipping())
				appendCodeBlock(&currentScope() -> hdrcode,yyvsp[0].codeb);
		;
    break;}
case 152:
#line 994 "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 153:
#line 1005 "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 154:
#line 1016 "parser.y"
{
			if (notSkipping())
				sectionFlags = SECT_IS_PUBLIC | yyvsp[-1].number;
		;
    break;}
case 155:
#line 1020 "parser.y"
{
			if (notSkipping())
				sectionFlags = SECT_IS_PROT | yyvsp[-1].number;
		;
    break;}
case 156:
#line 1024 "parser.y"
{
			if (notSkipping())
				sectionFlags = SECT_IS_PRIVATE | yyvsp[-1].number;
		;
    break;}
case 157:
#line 1028 "parser.y"
{
			if (notSkipping())
				sectionFlags = SECT_IS_SIGNAL;
		;
    break;}
case 158:
#line 1034 "parser.y"
{
			yyval.number = 0;
		;
    break;}
case 159:
#line 1037 "parser.y"
{
			yyval.number = SECT_IS_SLOT;
		;
    break;}
case 160:
#line 1042 "parser.y"
{
			if (notSkipping())
			{
				classDef *cd = currentScope();

				if (strcmp(classBaseName(cd),yyvsp[-6].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[-3].throwlist;
				cd -> classflags |= sectionFlags;

				/*
				 * Make the class complex if we have a virtual
				 * dtor or some dtor code.
				 */
				if (yyvsp[-8].number || yyvsp[0].codeb != NULL)
					setIsComplex(cd);
			}
		;
    break;}
case 161:
#line 1068 "parser.y"
{
			yyval.number = FALSE;
		;
    break;}
case 162:
#line 1071 "parser.y"
{
			yyval.number = TRUE;
		;
    break;}
case 163:
#line 1076 "parser.y"
{
			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[-7].text,sectionFlags,&yyvsp[-5].arglist,yyvsp[0].codeb,yyvsp[-3].throwlist);
			}

			free(yyvsp[-7].text);
		;
    break;}
case 164:
#line 1089 "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");

				newFunction(currentSpec,currentModule,
					    sectionFlags,currentIsStatic,
					    currentOverIsVirt,
					    &yyvsp[-11].memArg,yyvsp[-10].text,&yyvsp[-8].arglist,yyvsp[-6].number,yyvsp[-4].number,&yyvsp[-3].optflags,yyvsp[-1].codeb,yyvsp[0].codeb,yyvsp[-5].throwlist);
			}

			currentIsStatic = FALSE;
			currentOverIsVirt = FALSE;
		;
    break;}
case 165:
#line 1104 "parser.y"
{
			if (notSkipping())
				newFunction(currentSpec,currentModule,
					    sectionFlags,currentIsStatic,
					    currentOverIsVirt,
					    &yyvsp[-10].memArg,yyvsp[-8].text,&yyvsp[-6].arglist,yyvsp[-4].number,FALSE,&yyvsp[-2].optflags,yyvsp[0].codeb,NULL,yyvsp[-3].throwlist);

			currentIsStatic = FALSE;
			currentOverIsVirt = FALSE;
		;
    break;}
case 166:
#line 1116 "parser.y"
{yyval.text = "__add__";;
    break;}
case 167:
#line 1117 "parser.y"
{yyval.text = "__sub__";;
    break;}
case 168:
#line 1118 "parser.y"
{yyval.text = "__mul__";;
    break;}
case 169:
#line 1119 "parser.y"
{yyval.text = "__div__";;
    break;}
case 170:
#line 1120 "parser.y"
{yyval.text = "__mod__";;
    break;}
case 171:
#line 1121 "parser.y"
{yyval.text = "__and__";;
    break;}
case 172:
#line 1122 "parser.y"
{yyval.text = "__or__";;
    break;}
case 173:
#line 1123 "parser.y"
{yyval.text = "__xor__";;
    break;}
case 174:
#line 1124 "parser.y"
{yyval.text = "__lshift__";;
    break;}
case 175:
#line 1125 "parser.y"
{yyval.text = "__rshift__";;
    break;}
case 176:
#line 1126 "parser.y"
{yyval.text = "__iadd__";;
    break;}
case 177:
#line 1127 "parser.y"
{yyval.text = "__isub__";;
    break;}
case 178:
#line 1128 "parser.y"
{yyval.text = "__imul__";;
    break;}
case 179:
#line 1129 "parser.y"
{yyval.text = "__idiv__";;
    break;}
case 180:
#line 1130 "parser.y"
{yyval.text = "__imod__";;
    break;}
case 181:
#line 1131 "parser.y"
{yyval.text = "__iand__";;
    break;}
case 182:
#line 1132 "parser.y"
{yyval.text = "__ior__";;
    break;}
case 183:
#line 1133 "parser.y"
{yyval.text = "__ixor__";;
    break;}
case 184:
#line 1134 "parser.y"
{yyval.text = "__ilshift__";;
    break;}
case 185:
#line 1135 "parser.y"
{yyval.text = "__irshift__";;
    break;}
case 186:
#line 1136 "parser.y"
{yyval.text = "__invert__";;
    break;}
case 187:
#line 1137 "parser.y"
{yyval.text = "__call__";;
    break;}
case 188:
#line 1138 "parser.y"
{yyval.text = "__getitem__";;
    break;}
case 189:
#line 1139 "parser.y"
{yyval.text = "__lt__";;
    break;}
case 190:
#line 1140 "parser.y"
{yyval.text = "__le__";;
    break;}
case 191:
#line 1141 "parser.y"
{yyval.text = "__eq__";;
    break;}
case 192:
#line 1142 "parser.y"
{yyval.text = "__ne__";;
    break;}
case 193:
#line 1143 "parser.y"
{yyval.text = "__gt__";;
    break;}
case 194:
#line 1144 "parser.y"
{yyval.text = "__ge__";;
    break;}
case 195:
#line 1147 "parser.y"
{
			yyval.number = FALSE;
		;
    break;}
case 196:
#line 1150 "parser.y"
{
			yyval.number = TRUE;
		;
    break;}
case 197:
#line 1155 "parser.y"
{
			yyval.number = 0;
		;
    break;}
case 198:
#line 1158 "parser.y"
{
			if (yyvsp[0].number != 0)
				yyerror("Abstract virtual function '= 0' expected");

			yyval.number = TRUE;
		;
    break;}
case 199:
#line 1166 "parser.y"
{
			yyval.optflags.nrFlags = 0;
		;
    break;}
case 200:
#line 1169 "parser.y"
{
			yyval.optflags = yyvsp[-1].optflags;
		;
    break;}
case 201:
#line 1175 "parser.y"
{
			yyval.optflags.flags[0] = yyvsp[0].flag;
			yyval.optflags.nrFlags = 1;
		;
    break;}
case 202:
#line 1179 "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 203:
#line 1191 "parser.y"
{
			yyval.flag.ftype = bool_flag;
			yyval.flag.fname = yyvsp[0].text;
		;
    break;}
case 204:
#line 1195 "parser.y"
{
			yyval.flag = yyvsp[0].flag;
			yyval.flag.fname = yyvsp[-2].text;
		;
    break;}
case 205:
#line 1201 "parser.y"
{
			yyval.flag.ftype = name_flag;
			yyval.flag.fvalue.sval = yyvsp[0].text;
		;
    break;}
case 206:
#line 1205 "parser.y"
{
			yyval.flag.ftype = string_flag;
			yyval.flag.fvalue.sval = yyvsp[0].text;
		;
    break;}
case 207:
#line 1209 "parser.y"
{
			yyval.flag.ftype = integer_flag;
			yyval.flag.fvalue.ival = yyvsp[0].number;
		;
    break;}
case 208:
#line 1215 "parser.y"
{
			yyval.codeb = NULL;
		;
    break;}
case 209:
#line 1218 "parser.y"
{
			yyval.codeb = yyvsp[0].codeb;
		;
    break;}
case 210:
#line 1223 "parser.y"
{
			yyval.codeb = NULL;
		;
    break;}
case 211:
#line 1226 "parser.y"
{
			yyval.codeb = yyvsp[0].codeb;
		;
    break;}
case 212:
#line 1231 "parser.y"
{
			int a, nrsigs, nrrxcon, nrrxdis, nrslotcon, nrslotdis, nrarray, nrarraysize;

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

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

				switch (ad -> atype)
				{
				case signal_type:
					++nrsigs;
					break;

				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 (nrsigs == 1 && nrrxcon == 0)
				yyerror("SIP_SIGNAL can only be used with SIP_RXOBJ_CON");

			if (nrsigs > 1)
				yyerror("SIP_SIGNAL can only be given once");

			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.arglist = yyvsp[0].arglist;
		;
    break;}
case 213:
#line 1289 "parser.y"
{
			/* No arguments. */

			yyval.arglist.nrArgs = 0;
		;
    break;}
case 214:
#line 1294 "parser.y"
{
			/* The single or first argument. */

			yyval.arglist.args[0] = yyvsp[0].memArg;
			yyval.arglist.nrArgs = 1;
		;
    break;}
case 215:
#line 1300 "parser.y"
{
			/* Check that it wasn't ...(,arg...). */

			if (yyvsp[-2].arglist.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].arglist.nrArgs; ++a)
					if (yyvsp[-2].arglist.args[a].defval != NULL)
						yyerror("Compulsory argument given after optional argument");
			}

			/* Check there is room. */

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

			yyval.arglist = yyvsp[-2].arglist;
			yyval.arglist.args[yyval.arglist.nrArgs++] = yyvsp[0].memArg;
		;
    break;}
case 216:
#line 1330 "parser.y"
{
			yyval.memArg.atype = signal_type;
			yyval.memArg.argflags = 0;
			yyval.memArg.nrderefs = 0;

			currentSpec -> sigslots = TRUE;
		;
    break;}
case 217:
#line 1337 "parser.y"
{
			yyval.memArg.atype = rxcon_type;
			yyval.memArg.argflags = 0;
			yyval.memArg.nrderefs = 0;

			currentSpec -> sigslots = TRUE;
		;
    break;}
case 218:
#line 1344 "parser.y"
{
			yyval.memArg.atype = rxdis_type;
			yyval.memArg.argflags = 0;
			yyval.memArg.nrderefs = 0;

			currentSpec -> sigslots = TRUE;
		;
    break;}
case 219:
#line 1351 "parser.y"
{
			yyval.memArg.atype = slotcon_type;
			yyval.memArg.argflags = 0;
			yyval.memArg.nrderefs = 0;

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

			currentSpec -> sigslots = TRUE;
		;
    break;}
case 220:
#line 1361 "parser.y"
{
			yyval.memArg.atype = slotdis_type;
			yyval.memArg.argflags = 0;
			yyval.memArg.nrderefs = 0;

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

			currentSpec -> sigslots = TRUE;
		;
    break;}
case 221:
#line 1371 "parser.y"
{
			yyval.memArg = yyvsp[-1].memArg;
			yyval.memArg.defval = yyvsp[0].valp;
		;
    break;}
case 222:
#line 1377 "parser.y"
{currentIsStatic = TRUE;;
    break;}
case 227:
#line 1385 "parser.y"
{currentOverIsVirt = TRUE;;
    break;}
case 230:
#line 1389 "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("%VariableCode 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 231:
#line 1410 "parser.y"
{
			yyval.memArg = yyvsp[-2].memArg;
			yyval.memArg.nrderefs = yyvsp[-1].number;
			yyval.memArg.argflags = ARG_IS_CONST | yyvsp[0].number;
		;
    break;}
case 232:
#line 1415 "parser.y"
{
			yyval.memArg = yyvsp[-2].memArg;
			yyval.memArg.nrderefs = yyvsp[-1].number;
			yyval.memArg.argflags = yyvsp[0].number;
		;
    break;}
case 233:
#line 1422 "parser.y"
{
			yyval.memArg = yyvsp[-1].memArg;

			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,"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 234:
#line 1463 "parser.y"
{
			yyval.number = 0;
		;
    break;}
case 235:
#line 1466 "parser.y"
{
			yyval.number = ARG_IS_REF;
		;
    break;}
case 236:
#line 1471 "parser.y"
{
			yyval.number = 0;
		;
    break;}
case 237:
#line 1474 "parser.y"
{
			yyval.number = yyvsp[-1].number + 1;
		;
    break;}
case 238:
#line 1479 "parser.y"
{
			yyval.memArg.atype = defined_type;
			yyval.memArg.u.snd = yyvsp[0].scpvalp;
		;
    break;}
case 239:
#line 1483 "parser.y"
{
			templateDef *td;

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

			yyval.memArg.atype = template_type;
			yyval.memArg.u.td = td;
		;
    break;}
case 240:
#line 1493 "parser.y"
{
			yyval.memArg.atype = struct_type;
			yyval.memArg.u.sname = yyvsp[0].scpvalp;
		;
    break;}
case 241:
#line 1497 "parser.y"
{
			yyval.memArg.atype = ushort_type;
		;
    break;}
case 242:
#line 1500 "parser.y"
{
			yyval.memArg.atype = short_type;
		;
    break;}
case 243:
#line 1503 "parser.y"
{
			yyval.memArg.atype = uint_type;
		;
    break;}
case 244:
#line 1506 "parser.y"
{
			yyval.memArg.atype = uint_type;
		;
    break;}
case 245:
#line 1509 "parser.y"
{
			yyval.memArg.atype = int_type;
		;
    break;}
case 246:
#line 1512 "parser.y"
{
			yyval.memArg.atype = long_type;
		;
    break;}
case 247:
#line 1515 "parser.y"
{
			yyval.memArg.atype = ulong_type;
		;
    break;}
case 248:
#line 1518 "parser.y"
{
			yyval.memArg.atype = float_type;
		;
    break;}
case 249:
#line 1521 "parser.y"
{
			yyval.memArg.atype = double_type;
		;
    break;}
case 250:
#line 1524 "parser.y"
{
			yyval.memArg.atype = bool_type;
		;
    break;}
case 251:
#line 1527 "parser.y"
{
			yyval.memArg.atype = ustring_type;
		;
    break;}
case 252:
#line 1530 "parser.y"
{
			yyval.memArg.atype = string_type;
		;
    break;}
case 253:
#line 1533 "parser.y"
{
			yyval.memArg.atype = voidptr_type;
		;
    break;}
case 254:
#line 1536 "parser.y"
{
			yyval.memArg.atype = pyobject_type;
		;
    break;}
case 255:
#line 1539 "parser.y"
{
			yyval.memArg.atype = pyslice_type;
		;
    break;}
case 256:
#line 1544 "parser.y"
{
			/* The single or first type. */

			yyval.arglist.args[0] = yyvsp[0].memArg;
			yyval.arglist.nrArgs = 1;
		;
    break;}
case 257:
#line 1550 "parser.y"
{
			/* Check that it wasn't ,type... */

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

			/* Check there is room. */

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

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

			yyval.arglist.args[yyval.arglist.nrArgs] = yyvsp[0].memArg;
			yyval.arglist.nrArgs++;
		;
    break;}
case 258:
#line 1568 "parser.y"
{
			yyval.throwlist = NULL;
		;
    break;}
case 259:
#line 1571 "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 260:
#line 1586 "parser.y"
{
			/* Empty list so use a blank. */

			yyval.throwlist = sipMalloc(sizeof (throwArgs));
			yyval.throwlist -> nrArgs = 0;
		;
    break;}
case 261:
#line 1592 "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 262:
#line 1599 "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 606 "/usr/share/bison/bison.simple"

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

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

  *++yyvsp = yyval;
#if YYLSP_NEEDED
  *++yylsp = yyloc;
#endif

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

  yyn = yyr1[yyn];

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

  goto yynewstate;


/*------------------------------------.
| yyerrlab -- here on detecting error |
`------------------------------------*/
yyerrlab:
  /* If not already recovering from an error, report this error.  */
  if (!yyerrstatus)
    {
      ++yynerrs;

#ifdef YYERROR_VERBOSE
      yyn = yypact[yystate];

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

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

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


/*--------------------------------------------------.
| yyerrlab1 -- error raised explicitly by an action |
`--------------------------------------------------*/
yyerrlab1:
  if (yyerrstatus == 3)
    {
      /* If just tried and failed to reuse lookahead token after an
	 error, discard it.  */

      /* return failure if at end of input */
      if (yychar == YYEOF)
	YYABORT;
      YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
		  yychar, yytname[yychar1]));
      yychar = YYEMPTY;
    }

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

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

  goto yyerrhandle;


/*-------------------------------------------------------------------.
| yyerrdefault -- current state does not do anything special for the |
| error token.                                                       |
`-------------------------------------------------------------------*/
yyerrdefault:
#if 0
  /* This is wrong; only states that explicitly want error tokens
     should shift them.  */

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


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

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

/*--------------.
| yyerrhandle.  |
`--------------*/
yyerrhandle:
  yyn = yypact[yystate];
  if (yyn == YYFLAG)
    goto yyerrdefault;

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

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

  if (yyn == YYFINAL)
    YYACCEPT;

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

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

  yystate = yyn;
  goto yynewstate;


/*-------------------------------------.
| yyacceptlab -- YYACCEPT comes here.  |
`-------------------------------------*/
yyacceptlab:
  if (yyfree_stacks)
    {
      free (yyss);
      free (yyvs);
#if YYLSP_NEEDED
      free (yyls);
#endif
    }
  return 0;


/*-----------------------------------.
| yyabortlab -- YYABORT comes here.  |
`-----------------------------------*/
yyabortlab:
  if (yyfree_stacks)
    {
      free (yyss);
      free (yyvs);
#if YYLSP_NEEDED
      free (yyls);
#endif
    }
  return 1;
}
#line 1615 "parser.y"



/*
 * Parse the specification.
 */

void parse(sipSpec *spec,FILE *fp,char *filename,char *cppMName,
	   stringList *tsl,stringList *xfl)
{
        /* Initialise the spec. */
 
	spec -> cppmname = cppMName;
	spec -> namecache = NULL;
	spec -> moduleList = NULL;
	spec -> ifacefiles = NULL;
	spec -> classes = NULL;
	spec -> mappedtypes = NULL;
	spec -> used = NULL;
	spec -> qobjclass = -1;
	spec -> exposed = NULL;
	spec -> enums = NULL;
	spec -> vars = NULL;
	spec -> othfuncs = NULL;
	spec -> overs = NULL;
	spec -> typedefs = NULL;
	spec -> copying = NULL;
	spec -> hdrcode = NULL;
	spec -> exphdrcode = NULL;
	spec -> cppcode = NULL;
	spec -> prepycode = NULL;
	spec -> pycode = NULL;
	spec -> docs = NULL;
	spec -> postinitcode = NULL;
	spec -> mktemplates = NULL;
	spec -> sigargs = NULL;
	spec -> sigslots = FALSE;

	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 exist.
 * Append is needed specifically for the list of super-classes because the
 * order is important to Python.
 */

static 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)
{
	parseFile(fp,filename,currentModule,FALSE);

	currentModule = sipMalloc(sizeof (moduleDef));

	currentModule -> name = NULL;
	currentModule -> file = filename;
	currentModule -> qualifiers = NULL;
	currentModule -> nrTimeSlots = -1;
	currentModule -> license = NULL;
	currentModule -> next = currentSpec -> moduleList;

	currentSpec -> moduleList = currentModule;
}


/*
 * 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,currentModule,scopedNameTail(fqname));
	iff -> type = iftype;
	iff -> fqname = fqname;
	iff -> module = NULL;
	iff -> ifacefileflags = 0;
	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;
	}

	setIsUsed(iff);

	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)
{
	classDef *cd;

	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 class has already been defined" :
			"The namespace has already been defined in another module");
	}

	cd -> iff -> module = currentModule;

	/* Complete the initialisation. */

	cd -> classflags = 0;
	cd -> classnr = -1;
	cd -> ecd = currentScope();
	cd -> node = NULL;
	cd -> supers = NULL;
	cd -> mro = NULL;
	cd -> ctors = NULL;
	cd -> dealloccode = NULL;
	cd -> dtorcode = NULL;
	cd -> members = NULL;
	cd -> overs = NULL;
	cd -> vmembers = NULL;
	cd -> visible = NULL;
	cd -> cppcode = NULL;
	cd -> hdrcode = (cd -> ecd != NULL ? cd -> ecd -> hdrcode : NULL);
	cd -> convtosubcode = NULL;
	cd -> subbase = NULL;
	cd -> convtocode = NULL;

	return cd;
}


/*
 * Tidy up after finishing a class definition.
 */

static void finishClass(classDef *cd,optFlags *optflgs)
{
	overDef *od;

	/* Handle any optional flags. */

	if (findOptFlag(optflgs,"CreatesThread",bool_flag) != NULL)
		setCreatesThread(cd);

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

		cd -> ctors = sipMalloc(sizeof (ctorDef));
 
		cd -> ctors -> ctorflags = SECT_IS_PUBLIC;
		cd -> ctors -> args.nrArgs = 0;
		cd -> ctors -> exceptions = NULL;
		cd -> ctors -> cppcode = NULL;
		cd -> ctors -> next = NULL;

		resetCannotCreate(cd);
	}

	/* We can't create this class if it has private abstract functions. */

	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);
}


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

	/* 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 -> 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 -> enumflags = flags;
	ed -> fqname = (name != NULL ? text2scopedName(name) : NULL);
	ed -> ecd = escope;
	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,mod,name);

	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,funcArgs *args,codeBlock *code,
		    throwArgs *exceptions)
{
	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 (sameFuncArgs(&(*ctp) -> args,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 -> args = *args;
	ct -> exceptions = exceptions;
	ct -> cppcode = code;
	ct -> next = NULL;

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

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

	*ctp = ct;
}


/*
 * Create a new function.
 */

static void newFunction(sipSpec *pt,moduleDef *mod,int sflags,int isstatic,
			int isvirt,argDef *type,char *name,funcArgs *args,
			int isconst,int isabstract,optFlags *optflgs,
			codeBlock *mcode,codeBlock *vcode,
			throwArgs *exceptions)
{
	static struct slot_map {
		char *name;		/* The slot name. */
		slotType type;		/* The corresponding type. */
		int hwcode;		/* If handwritten code is required. */
		int nrargs;		/* Nr. of arguments, -1 allows any. */
	} 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, 2},
		{"__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},
		{NULL}
	};

	classDef *cd = currentScope();
	char *pname;
	int factory;
	overDef *od, **odp, **headp;
	optFlag *of;
	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,name) == 0)
		{
			/* Apply the restrictions on operators. */

			if (cd == NULL || (sflags & SECT_IS_PUBLIC) == 0)
				yyerror("Operators must be defined in the public section of a class");

			if (sm -> hwcode && mcode == NULL)
				yyerror("This operator requires %MemberCode");

			if (sm -> nrargs >= 0 && sm -> nrargs != args -> nrArgs)
				yyerror("Incorrect number of arguments to operator");

			if (isvirt)
				yyerror("Operators cannot be virtual");

			if (isabstract)
				yyerror("Operators cannot be abstract");

			st = sm -> type;

			break;
		}

	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 < args -> nrArgs; ++a)
			if (isThisTransferred(&args -> args[a]))
				yyerror("/TransferThis/ may only be specified in constructors and /Factory/ methods");
	}

	/* 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 (isProtected(od))
		setIsComplex(cd);

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

		pt -> sigslots = TRUE;
	}

	if (isSignal(od) && (mcode != 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(pt,of -> fvalue.sval)) == NULL || qd -> qtype != feature_qualifier)
				yyerror("No such feature");

			if (isExcluded(qd))
				resetIsAutoGen(od);
		}
	}

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

		setIsVirtual(od);
		setIsComplex(cd);
	}
	else if (vcode != NULL)
		yyerror("%VirtualCode provided for non-virtual function");

	od -> cppname = name;
	od -> args = *args;
	od -> exceptions = exceptions;
	od -> cppcode = mcode;
	od -> virtcode = vcode;
	od -> common = findFunction(pt,mod,cd,pname,st);

	/* Methods that run in new threads must be virtual. */

	if (findOptFlag(optflgs,"NewThread",bool_flag) != NULL)
	{
		if (!isvirt)
			yyerror("/NewThread/ may only be specified for virtual methods");

		setIsNewThread(od);
	}

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

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

	if (type -> atype == voidptr_type && type -> nrderefs == 0)
		od -> result = NULL;
	else
	{
		od -> result = sipMalloc(sizeof (argDef));
		*od -> result = *type;
	}

	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 (!sameOverload(*odp,od,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,moduleDef *mod,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 -> text = name;
	nd -> module = mod;
	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,slotType st)
{
	memberDef *md, **flist;
	nameDef *pnd;

	/* Cache the name. */

	pnd = cacheName(pt,mod,pname);

	/* 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 -> 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(sipSpec *pt,char *name)
{
	moduleDef *mod;

	for (mod = pt -> moduleList; 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(sipSpec *pt,char *lname,char *uname)
{
	int this;
	qualDef *qd, *lower, *upper;
	moduleDef *mod;

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

	if (uname == NULL)
		upper = NULL;
	else if ((upper = findQualifier(pt,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(sipSpec *pt,char *name,int optnot)
{
	int this;
	qualDef *qd;

	if ((qd = findQualifier(pt,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 (!isExcluded(qd))
			this = TRUE;
	}
	else if (isNeeded(qd))
		this = TRUE;

	if (optnot)
		this = !this;

	return this;
}


/*
 * Return TRUE if the given qualifier is excluded.
 */

static int isExcluded(qualDef *qd)
{
	stringList *sl;

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

	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(sipSpec *pt,moduleDef *mod,int order,char *name,
			 qualType qt)
{
	qualDef *qd;

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

	if (findQualifier(pt,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(sipSpec *pt,char *name)
{
	/* Ignore if the file has already been imported. */

	moduleDef *mod;

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

	newModule(NULL,name);
}


/*
 * If the use of an interface is by the main module, add it to the used list.
 */

static void usedInMainModule(sipSpec *pt,ifaceFileDef *iff)
{
	if (isMainModule(iff -> module))
		addToUsedList(&pt -> used,iff);
}
