
/*  A Bison parser, made from ddl.y
    by GNU Bison version 1.28  */

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

#define	T_DATABASE	257
#define	T_KEY	258
#define	T_DATA	259
#define	T_FILE	260
#define	T_CONTAINS	261
#define	T_RECORD	262
#define	T_UNIQUE	263
#define	T_DEFINE	264
#define	T_CONTROLLED	265
#define	T_MAP	266
#define	T_ARROW	267
#define	T_PRIMARY	268
#define	T_ALTERNATE	269
#define	T_FOREIGN	270
#define	T_ON	271
#define	T_DELETE	272
#define	T_RESTRICT	273
#define	T_REFERENCES	274
#define	T_UPDATE	275
#define	T_CASCADE	276
#define	T_NULL	277
#define	T_SEQUENCE	278
#define	T_CHAR	279
#define	T_SHORT	280
#define	T_INT	281
#define	T_LONG	282
#define	T_SIGNED	283
#define	T_UNSIGNED	284
#define	T_FLOAT	285
#define	T_DOUBLE	286
#define	T_UCHAR	287
#define	T_USHORT	288
#define	T_ULONG	289
#define	T_STRUCT	290
#define	T_UNION	291
#define	T_COMPOUND	292
#define	T_ASC	293
#define	T_DESC	294
#define	T_VARIABLE	295
#define	T_BY	296
#define	T_IDENT	297
#define	T_STRING	298
#define	T_NUMBER	299
#define	T_CHARCONST	300

#line 35 "ddl.y"


#include <sys/types.h>
#include <string.h>
#include <stdarg.h>
#include "typhoon.h"
#include "ty_dbd.h"
#include "ty_type.h"

#include "ddlp.h"
#include "ddlpsym.h"
#include "ddlpglob.h"

/*--------------------------- Function prototypes --------------------------*/
int yylex				PRM( (void); )
static void add_keymember               PRM( (sym_struct *, char *, int); )

/*---------------------------- Global variables ----------------------------*/
static unsigned type;               /* Holds FT_.. flags of current field	*/
static sym_member *control_field;	/* Field that controls current union	*/



#line 59 "ddl.y"
typedef union {
	int 	val;
	char	is_union;
	char	s[IDENT_LEN+1];
} YYSTYPE;
#include <stdio.h>

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



#define	YYFINAL		173
#define	YYFLAG		-32768
#define	YYNTBASE	61

#define YYTRANSLATE(x) ((unsigned)(x) <= 300 ? yytranslate[x] : 103)

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,     2,     2,     2,     2,     2,     2,     2,    59,
    60,    57,    55,    52,    56,    53,    58,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,    51,     2,
     2,    54,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    47,     2,    48,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,    49,     2,    50,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     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
};

#if YYDEBUG != 0
static const short yyprhs[] = {     0,
     0,     6,     7,    11,    13,    16,    24,    34,    40,    44,
    46,    51,    54,    56,    58,    60,    63,    68,    71,    72,
    75,    77,    80,    84,    85,    89,    93,    94,    98,    99,
   101,   103,   106,   112,   113,   115,   117,   120,   133,   135,
   137,   138,   142,   146,   149,   153,   155,   159,   162,   163,
   165,   166,   168,   170,   172,   174,   177,   179,   181,   184,
   186,   188,   190,   192,   194,   196,   198,   200,   202,   204,
   206,   210,   214,   218,   222,   226,   228,   235,   240,   243,
   245,   250,   251,   253,   261,   263,   266,   271,   273
};

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

#endif

#if YYDEBUG != 0
static const short yyrline[] = { 0,
    89,    93,    95,   107,   108,   111,   116,   123,   129,   130,
   131,   134,   139,   140,   143,   144,   147,   161,   164,   165,
   168,   169,   172,   177,   178,   193,   203,   204,   216,   217,
   221,   222,   226,   238,   239,   243,   244,   249,   262,   263,
   273,   277,   298,   310,   327,   344,   345,   349,   355,   356,
   360,   361,   362,   369,   370,   372,   373,   374,   375,   378,
   379,   380,   381,   384,   385,   388,   389,   392,   393,   394,
   397,   398,   399,   400,   401,   402,   410,   439,   453,   472,
   476,   485,   486,   494,   502,   503,   506,   509,   510
};
#endif


#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)

static const char * const yytname[] = {   "$","error","$undefined.","T_DATABASE",
"T_KEY","T_DATA","T_FILE","T_CONTAINS","T_RECORD","T_UNIQUE","T_DEFINE","T_CONTROLLED",
"T_MAP","T_ARROW","T_PRIMARY","T_ALTERNATE","T_FOREIGN","T_ON","T_DELETE","T_RESTRICT",
"T_REFERENCES","T_UPDATE","T_CASCADE","T_NULL","T_SEQUENCE","T_CHAR","T_SHORT",
"T_INT","T_LONG","T_SIGNED","T_UNSIGNED","T_FLOAT","T_DOUBLE","T_UCHAR","T_USHORT",
"T_ULONG","T_STRUCT","T_UNION","T_COMPOUND","T_ASC","T_DESC","T_VARIABLE","T_BY",
"T_IDENT","T_STRING","T_NUMBER","T_CHARCONST","'['","']'","'{'","'}'","';'",
"','","'.'","'>'","'+'","'-'","'*'","'/'","'('","')'","database","pagesize",
"decl_list","decl","record_head","key_type","member_list","member","opt_dimen",
"dimension","array","opt_varlen_decl","opt_key_list","opt_primary_key_decl",
"opt_alternate_key_decl_list","alternate_key_decl_list","alternate_key_decl",
"opt_foreign_key_decl_list","foreign_key_decl_list","foreign_key_decl","action",
"opt_null","key_decl","key_decl_head","comkey_member_list","comkey_member","opt_unique",
"opt_sortorder","membertype","int_type","int_sign","float_type","u_type","expr",
"struct_specifier","struct_or_union_opt_ident","struct_or_union","opt_ident",
"sequence","map_list","map","map_id", NULL
};
#endif

static const short yyr1[] = {     0,
    61,    62,    62,    63,    63,    64,    64,    64,    64,    64,
    64,    65,    66,    66,    67,    67,    68,    68,    69,    69,
    70,    70,    71,    72,    72,    73,    74,    74,    75,    75,
    76,    76,    77,    78,    78,    79,    79,    80,    81,    81,
    82,    82,    83,    83,    84,    85,    85,    86,    87,    87,
    88,    88,    88,    89,    89,    89,    89,    89,    89,    90,
    90,    90,    90,    91,    91,    92,    92,    93,    93,    93,
    94,    94,    94,    94,    94,    94,    95,    95,    96,    97,
    97,    98,    98,    99,   100,   100,   101,   102,   102
};

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

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

static const short yydefgoto[] = {   171,
    24,    10,    11,    12,   149,    48,    49,   105,   106,   107,
   131,    76,    77,   101,   102,   103,   123,   124,   125,   165,
   152,    97,    98,   118,   119,   121,    71,    50,    51,    52,
    53,    54,    28,    55,    56,    57,    84,    13,    31,    32,
    33
};

static const short yypact[] = {    10,
   -22,   -11,    72,    50,    69,     0,    40,    70,    46,    -2,
-32768,    71,-32768,    74,    74,-32768,   -40,   -28,    77,-32768,
-32768,    73,   -40,    79,    80,-32768,   -40,    36,-32768,-32768,
   -34,-32768,   112,     7,-32768,-32768,-32768,    47,-32768,-32768,
-32768,-32768,-32768,-32768,-32768,-32768,   115,    37,-32768,    84,
-32768,    86,-32768,-32768,    78,    81,    85,    -3,   124,   125,
    30,   -40,   -40,   -40,   -40,-32768,-32768,   -28,-32768,-32768,
    91,-32768,    92,   131,-32768,    87,   121,    93,-32768,-32768,
-32768,    73,    95,-32768,-32768,    96,    98,-32768,    58,    58,
-32768,-32768,    94,    97,   100,   101,    99,   103,-32768,   138,
   132,   121,-32768,   -40,   102,   -32,-32768,    -1,    93,   104,
   105,-32768,   107,-32768,   106,-32768,     7,    45,-32768,-32768,
   131,   131,-32768,   132,-32768,-32768,     2,-32768,   109,-32768,
-32768,   111,-32768,    -6,-32768,-32768,-32768,-32768,-32768,   103,
   126,   139,-32768,-32768,   117,    93,-32768,-32768,   110,-32768,
   120,   113,   122,-32768,-32768,-32768,   123,-32768,   135,-32768,
   142,     1,-32768,-32768,   150,   151,     1,   126,   119,-32768,
   168,   171,-32768
};

static const short yypgoto[] = {-32768,
   157,-32768,   163,-32768,-32768,   108,   -47,  -102,-32768,    68,
-32768,-32768,-32768,-32768,-32768,    75,-32768,-32768,    51,     9,
    11,    -4,-32768,-32768,    38,-32768,    63,-32768,   129,-32768,
   144,-32768,   -23,-32768,-32768,-32768,-32768,-32768,-32768,   152,
   116
};


#define	YYLAST		190


static const short yytable[] = {    58,
    75,     4,     5,    61,    26,     6,   133,     7,   129,     8,
    29,    30,     1,   147,   104,    66,    29,    30,    27,   163,
     2,     9,   164,    35,    36,    37,    38,    39,    40,    41,
    42,    43,    44,    45,    46,    47,   148,     3,    89,    90,
    91,    92,    16,   155,    85,    69,    70,    20,   132,   144,
    74,    62,    63,    64,    65,    14,    62,    63,    64,    65,
    75,    35,    36,    37,    38,    39,    40,    41,    42,    43,
    44,    45,    46,    47,    15,     4,     5,    41,    42,     6,
   127,     7,    17,     8,    62,    63,    64,    65,    19,    88,
    62,    63,    64,    65,   139,     9,   140,    35,    36,    37,
    38,    39,    40,    41,    42,    43,    44,    45,    46,    47,
    35,    36,    37,    79,    64,    65,   141,   142,    18,    22,
    23,    34,    59,    60,    68,    73,    78,    83,    81,    82,
    86,    87,    94,    95,    96,   100,    99,   109,   110,   104,
   111,   113,   114,   115,   112,   117,   120,   122,   151,   116,
   145,   161,   128,   146,   137,   135,   134,   136,   153,   154,
   156,   157,   162,   158,   159,   160,   166,   172,   167,   170,
   173,    25,    21,   130,   143,   168,   126,   150,   169,   138,
    80,    72,    67,    93,     0,     0,     0,     0,     0,   108
};

static const short yycheck[] = {    23,
    48,     4,     5,    27,    45,     8,   109,    10,    41,    12,
    45,    46,     3,    20,    47,    50,    45,    46,    59,    19,
    43,    24,    22,    25,    26,    27,    28,    29,    30,    31,
    32,    33,    34,    35,    36,    37,    43,    49,    62,    63,
    64,    65,    43,   146,    48,    39,    40,    50,    50,    48,
    14,    55,    56,    57,    58,     6,    55,    56,    57,    58,
   108,    25,    26,    27,    28,    29,    30,    31,    32,    33,
    34,    35,    36,    37,     6,     4,     5,    31,    32,     8,
   104,    10,    43,    12,    55,    56,    57,    58,    43,    60,
    55,    56,    57,    58,    50,    24,    52,    25,    26,    27,
    28,    29,    30,    31,    32,    33,    34,    35,    36,    37,
    25,    26,    27,    28,    57,    58,   121,   122,    49,    49,
    47,    45,    44,    44,    13,    11,    43,    43,    51,    49,
     7,     7,    42,    42,     4,    15,    50,    43,    43,    47,
    43,    45,    43,    43,    51,    43,     9,    16,    23,    51,
    42,    17,    51,    43,    49,    51,    53,    51,    20,    43,
    51,    42,    21,    51,    43,    43,    17,     0,    18,    51,
     0,    15,    10,   106,   124,   167,   102,   140,   168,   117,
    52,    38,    31,    68,    -1,    -1,    -1,    -1,    -1,    82
};
/* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
#line 3 "/usr/share/misc/bison.simple"
/* This file comes from bison-1.28.  */

/* Skeleton output parser for bison,
   Copyright (C) 1984, 1989, 1990 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
#else /* alloca not defined */
#ifdef __GNUC__
#define YYSTACK_USE_ALLOCA
#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
#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
#else /* not MSDOS, or __TURBOC__, or _AIX */
#if 0
#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
		 and on HPUX 10.  Eventually we can turn this on.  */
#define YYSTACK_USE_ALLOCA
#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 */

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

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

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

#ifndef YYPURE
#define YYLEX		yylex()
#endif

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

/* If nonreentrant, generate the variables here */

#ifndef YYPURE

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

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

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

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

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

#ifndef	YYINITDEPTH
#define YYINITDEPTH 200
#endif

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

#if YYMAXDEPTH == 0
#undef YYMAXDEPTH
#endif

#ifndef YYMAXDEPTH
#define YYMAXDEPTH 10000
#endif

/* 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++ */
#ifndef __cplusplus

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

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

#else /* __cplusplus */

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

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

#endif
#endif

#line 217 "/usr/share/misc/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 /* not __cplusplus */
#define YYPARSE_PARAM_ARG YYPARSE_PARAM
#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
#endif /* not __cplusplus */
#else /* not YYPARSE_PARAM */
#define YYPARSE_PARAM_ARG
#define YYPARSE_PARAM_DECL
#endif /* not YYPARSE_PARAM */

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

int
yyparse(YYPARSE_PARAM_ARG)
     YYPARSE_PARAM_DECL
{
  register int yystate;
  register int yyn;
  register short *yyssp;
  register YYSTYPE *yyvsp;
  int yyerrstatus;	/*  number of tokens to shift before error messages enabled */
  int yychar1 = 0;		/*  lookahead token as an internal (translated) token number */

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

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

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

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

  int yystacksize = YYINITDEPTH;
  int yyfree_stacks = 0;

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

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

  int yylen;

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

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

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

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

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

  *++yyssp = yystate;

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

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

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

      yyss = yyss1; yyvs = yyvs1;
#ifdef YYLSP_NEEDED
      yyls = yyls1;
#endif
#else /* no yyoverflow */
      /* Extend the stack our own way.  */
      if (yystacksize >= YYMAXDEPTH)
	{
	  yyerror("parser stack overflow");
	  if (yyfree_stacks)
	    {
	      free (yyss);
	      free (yyvs);
#ifdef 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));
#ifdef 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;
#ifdef YYLSP_NEEDED
      yylsp = yyls + size - 1;
#endif

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

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

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

  goto yybackup;
 yybackup:

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

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

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

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

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

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

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

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

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

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

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

  yyn = yytable[yyn];

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

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

  if (yyn == YYFINAL)
    YYACCEPT;

  /* Shift the lookahead token.  */

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

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

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

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

  yystate = yyn;
  goto yynewstate;

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

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

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

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

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

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


  switch (yyn) {

case 1:
#line 90 "ddl.y"
{ strcpy(dbname, yyvsp[-3].s); ;
    break;}
case 2:
#line 94 "ddl.y"
{ yyval.val = 512;       ;
    break;}
case 3:
#line 96 "ddl.y"
{
					if( yyvsp[-1].val < 512 )
					{
						printf("Page size too small\n");
						yyval.val = 512;
					}
					else
						yyval.val = yyvsp[-1].val;
				;
    break;}
case 6:
#line 112 "ddl.y"
{
					add_contains('d', yyvsp[-1].s, "");
					add_file('d', yyvsp[-3].s, (unsigned) yyvsp[-4].val);
				;
    break;}
case 7:
#line 117 "ddl.y"
{
					char type = strcmp(yyvsp[-1].s, "<ref>") ? 'k' : 'r';

					add_contains(type, yyvsp[-3].s, yyvsp[-1].s);
					add_file(type, yyvsp[-5].s, (unsigned) yyvsp[-6].val);
				;
    break;}
case 8:
#line 124 "ddl.y"
{
					sym_endstruct();
					record[records-1].size = structnest[curnest+1]->size;
					structdef[record[records-1].structid].size = record[records-1].size;
				;
    break;}
case 9:
#line 129 "ddl.y"
{ add_define(yyvsp[-1].s, yyvsp[0].val);					;
    break;}
case 12:
#line 134 "ddl.y"
{ add_record(yyvsp[0].s);
									  add_structdef(yyvsp[0].s, 0, 0);
									  sym_addstruct(yyvsp[0].s, 0);					;
    break;}
case 13:
#line 139 "ddl.y"
{ strcpy(yyval.s, yyvsp[0].s);     					;
    break;}
case 14:
#line 140 "ddl.y"
{ strcpy(yyval.s, "<ref>");					;
    break;}
case 17:
#line 148 "ddl.y"
{
					sym_addmember(yyvsp[-2].s, (int) type, NULL);
					cur_str->last_member->id = fields;

					if( type != FT_STRUCT )
						add_field(yyvsp[-2].s, (int) type);

					/* Increase the number of level-0 fields of the record */
					if( curnest == 0 )
						structdef[record[records-1].structid].members++;

					type = 0;
				;
    break;}
case 23:
#line 172 "ddl.y"
{ dim[dims++] = yyvsp[-1].val;						;
    break;}
case 25:
#line 179 "ddl.y"
{ 
/*					if( curnest != 1 )
						yyerror("variable size fields cannot be nested");*/

					if( !(size_field = sym_findmember(structnest[0], yyvsp[0].s)) )
						yyerror("unknown struct member '%s'", yyvsp[0].s);
				;
    break;}
case 28:
#line 205 "ddl.y"
{
					key[keys-1].type = KT_PRIMARY|KT_UNIQUE;
				;
    break;}
case 33:
#line 227 "ddl.y"
{
					key[keys-1].type = KT_ALTERNATE | yyvsp[-3].val | yyvsp[-1].val;
				;
    break;}
case 38:
#line 252 "ddl.y"
{
					/* Set the record's first_foreign field */
					if( record[records-1].first_foreign == -1 )
						record[records-1].first_foreign = keys-1;

					key[keys-1].type = KT_FOREIGN | yyvsp[-5].val | yyvsp[-2].val | yyvsp[-1].val;
					check_foreign_key(yyvsp[-8].s, &key[keys-1]);
				;
    break;}
case 39:
#line 262 "ddl.y"
{ yyval.val = KT_RESTRICT;					;
    break;}
case 40:
#line 263 "ddl.y"
{ yyval.val = KT_CASCADE;
									  yyerror("'cascade' not supported");
				 					;
    break;}
case 41:
#line 274 "ddl.y"
{
					yyval.val = 0;
				;
    break;}
case 42:
#line 278 "ddl.y"
{
					sym_member *mem;
					int type;

					if( !(mem = sym_findmember(cur_str, yyvsp[0].s)) )
						yyerror("'%s' is not a member the record", yyvsp[0].s);
					else
					{
						key[keys-1].null_indicator = mem->id;
						type = FT_GETBASIC(field[mem->id].type);

						if( type != FT_CHAR && type != FT_CHARSTR )
							yyerror("field determiner must be char or string");
					}

					yyval.val = KT_OPTIONAL;
				;
    break;}
case 43:
#line 299 "ddl.y"
{
					sym_endstruct();

					/* Set the size of the compound key.
					* Foreign keys have special size.
					*/
					if( KT_GETBASIC(key[keys-1].type) == KT_FOREIGN )
						key[keys-1].size = sizeof(REF_ENTRY);
					else
						key[keys-1].size = last_str->size;
				;
    break;}
case 44:
#line 311 "ddl.y"
{
					sym_member *mem;

					if( !(mem = sym_findmember(cur_str, yyvsp[0].s)) )
						yyerror("unknown field '%s'", yyvsp[0].s);

					add_key(yyvsp[0].s);
					add_keyfield(mem->id, 1);

					key[keys-1].size = mem->size;
					field[mem->id].type |= FT_KEY;
					field[mem->id].keyid = keys-1;
				;
    break;}
case 45:
#line 328 "ddl.y"
{
					/* Ensure that the key name is not also a field name */
					if( sym_findmember(cur_str, yyvsp[-1].s) ) 
						yyerror("the key '%s' is already a field name", yyvsp[-1].s);

					sym_addstruct(yyvsp[-1].s, 0);
					add_key(yyvsp[-1].s);
				;
    break;}
case 48:
#line 350 "ddl.y"
{
					add_keymember(structnest[curnest-1], yyvsp[-1].s, yyvsp[0].val);   
				;
    break;}
case 49:
#line 355 "ddl.y"
{ yyval.val = 0;		  	/* Not unique */;
    break;}
case 50:
#line 356 "ddl.y"
{ yyval.val = KT_UNIQUE; 	/* Unique */	;
    break;}
case 51:
#line 360 "ddl.y"
{ yyval.val = 1;		/* Ascending */ 	;
    break;}
case 52:
#line 361 "ddl.y"
{ yyval.val = 1;		/* Ascending */ 	;
    break;}
case 53:
#line 362 "ddl.y"
{ yyval.val = 0;		/* Descending */	;
    break;}
case 55:
#line 370 "ddl.y"
{ if( type == FT_UNSIGNED )
									      type |= FT_INT;				;
    break;}
case 59:
#line 375 "ddl.y"
{ type |= FT_LONG;					;
    break;}
case 60:
#line 378 "ddl.y"
{ type |= FT_CHAR; 					;
    break;}
case 61:
#line 379 "ddl.y"
{ type |= FT_SHORT;					;
    break;}
case 62:
#line 380 "ddl.y"
{ type |= FT_INT;  					;
    break;}
case 63:
#line 381 "ddl.y"
{ type |= FT_LONG; 					;
    break;}
case 65:
#line 385 "ddl.y"
{ type |= FT_UNSIGNED;				;
    break;}
case 66:
#line 388 "ddl.y"
{ type |= FT_FLOAT; 				;
    break;}
case 67:
#line 389 "ddl.y"
{ type |= FT_DOUBLE;				;
    break;}
case 68:
#line 392 "ddl.y"
{ type |= FT_UNSIGNED|FT_CHAR; 		;
    break;}
case 69:
#line 393 "ddl.y"
{ type |= FT_UNSIGNED|FT_SHORT;		;
    break;}
case 70:
#line 394 "ddl.y"
{ type |= FT_UNSIGNED|FT_LONG; 		;
    break;}
case 71:
#line 397 "ddl.y"
{ yyval.val = yyvsp[-2].val + yyvsp[0].val; ;
    break;}
case 72:
#line 398 "ddl.y"
{ yyval.val = yyvsp[-2].val - yyvsp[0].val; ;
    break;}
case 73:
#line 399 "ddl.y"
{ yyval.val = yyvsp[-2].val * yyvsp[0].val; ;
    break;}
case 74:
#line 400 "ddl.y"
{ yyval.val = yyvsp[-2].val / yyvsp[0].val; ;
    break;}
case 75:
#line 401 "ddl.y"
{ yyval.val = yyvsp[-1].val;      ;
    break;}
case 77:
#line 411 "ddl.y"
{
					sym_struct *str;
					Field *fld;
					Structdef *strdef;

					sym_endstruct();

					str     = structnest[curnest + 1];
					fld     = &field[str->fieldid];
					strdef  = &structdef[ fld->structid ];

					strcpy(fld->name, yyvsp[-1].s);
					strdef->size    = str->size;
					strdef->members = str->members;

					sym_addmember(yyvsp[-1].s, FT_STRUCT, structnest[curnest+1]);

					fld->size		= cur_str->last_member->size;
					fld->elemsize	= cur_str->last_member->elemsize;
					fld->offset		= cur_str->last_member->offset;

					if( size_field )
					{
						fld->type |= FT_VARIABLE;
						fld->keyid = size_field->id;
						size_field = NULL;
					}
				;
    break;}
case 78:
#line 440 "ddl.y"
{												  
					sym_struct *str = sym_findstruct(yyvsp[-2].s, yyvsp[-3].is_union);

					if( str )
					{
						sym_addmember(yyvsp[-1].s, FT_STRUCT, str);
/*						add_field($3, FT_STRUCT);*/
					}
					/* else error message */
				;
    break;}
case 79:
#line 454 "ddl.y"
{
					add_field("<struct>", FT_STRUCT);
					sym_addstruct(yyvsp[0].s, yyvsp[-1].is_union);          
					cur_str->fieldid = fields-1;
					field[fields-1].structid = structdefs;

					add_structdef(yyvsp[0].s, yyvsp[-1].is_union, (int) (yyvsp[-1].is_union ? control_field->id : 0));

					/* Increase the number of level-0 field of the record.
					 * Actually, at this point the grammar we have moved to
					 * level 1.
					 */
					if( curnest == 1 )
						structdef[record[records-1].structid].members++;
				;
    break;}
case 80:
#line 473 "ddl.y"
{
					yyval.is_union = 0;
				;
    break;}
case 81:
#line 477 "ddl.y"
{
					yyval.is_union = 1;                                                               
					if( !(control_field = sym_findmember(cur_str, yyvsp[0].s)) )
						yyerror("'%s' is not a member of the union/struct '%s'",
						yyvsp[0].s, cur_str->name);
				;
    break;}
case 82:
#line 485 "ddl.y"
{ *yyval.s = 0;       					;
    break;}
case 83:
#line 486 "ddl.y"
{ strcpy(yyval.s, yyvsp[0].s);					;
    break;}
case 84:
#line 495 "ddl.y"
{ add_sequence(yyvsp[-5].s, (unsigned long) yyvsp[-4].val,yyvsp[-3].val, (unsigned long) yyvsp[-1].val);							;
    break;}
case 87:
#line 506 "ddl.y"
{ header.sorttable[yyvsp[-3].val] = yyvsp[-1].val;	;
    break;}
case 88:
#line 509 "ddl.y"
{ yyval.val = yyvsp[0].val;						;
    break;}
case 89:
#line 510 "ddl.y"
{ yyval.val = yyvsp[0].val;						;
    break;}
}
   /* the action file gets copied in in place of this dollarsign */
#line 543 "/usr/share/misc/bison.simple"

  yyvsp -= yylen;
  yyssp -= yylen;
#ifdef YYLSP_NEEDED
  yylsp -= yylen;
#endif

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

  *++yyvsp = yyval;

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

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

  yyn = yyr1[yyn];

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

  goto yynewstate;

yyerrlab:   /* here on detecting error */

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

#ifdef YYERROR_VERBOSE
      yyn = yypact[yystate];

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

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

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

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

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

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

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

      yychar = YYEMPTY;
    }

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

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

  goto yyerrhandle;

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

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

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

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

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

yyerrhandle:

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

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

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

  if (yyn == YYFINAL)
    YYACCEPT;

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

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

  yystate = yyn;
  goto yynewstate;

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

 yyabortlab:
  /* YYABORT comes here.  */
  if (yyfree_stacks)
    {
      free (yyss);
      free (yyvs);
#ifdef YYLSP_NEEDED
      free (yyls);
#endif
    }
  return 1;
}
#line 514 "ddl.y"


#include <stdio.h>



static void add_keymember(str, name, sortorder)
sym_struct *str;
char *name;
int sortorder;
{
	sym_member *mem;

	if( ( mem = sym_findmember(str, name) ) )
	{
		dims = mem->dims;
		memcpy(dim, mem->dim, sizeof(*dim) * dims);
		sym_addmember(name, mem->type, mem->struc);
		add_keyfield(mem->id, sortorder);
	}
	else
		yyerror("unknown struct member '%s'", name);
}




extern int errors;

int yyerror(char *fmt CONFIG_ELLIPSIS)
{
	va_list ap;

	printf("%s %d: ", ddlname, lex_lineno);
	va_start(ap, fmt);
	vprintf(fmt, ap);
	puts("");
	va_end(ap);
	errors++;
	return 0;
}

/* end-of-file */
