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

/* Bison implementation for Yacc-like parsers in C

   Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 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 3 of the License, or
   (at your option) any later version.

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

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

/* As a special exception, you may create a larger work that contains
   part or all of the Bison parser skeleton and distribute that work
   under terms of your choice, so long as that work isn't itself a
   parser generator using the skeleton or a modified version thereof
   as a parser skeleton.  Alternatively, if you modify or redistribute
   the parser skeleton itself, you may (at your option) remove this
   special exception, which will cause the skeleton and the resulting
   Bison output files to be licensed under the GNU General Public
   License without this special exception.

   This special exception was added by the Free Software Foundation in
   version 2.2 of Bison.  */

/* C LALR(1) parser skeleton written by Richard Stallman, by
   simplifying the original so-called "semantic" parser.  */

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

/* Undocumented macros, especially those whose name start with YY_,
   are private implementation details.  Do not rely on them.  */

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

/* Bison version.  */
#define YYBISON_VERSION "3.3.2"

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

/* Pure parsers.  */
#define YYPURE 0

/* Push parsers.  */
#define YYPUSH 0

/* Pull parsers.  */
#define YYPULL 1




/* First part of user prologue.  */
#line 1 "parser.y" /* yacc.c:337  */

/*
 *
 *	The slony_logshipper command language grammar
 *
 *	Copyright (c) 2003-2009, PostgreSQL Global Development Group
 *	Author: Jan Wieck, Afilias USA INC.
 *
 *	
 *-------------------------------------------------------------------------
 */

#include "config.h"
#include "../slonik/types.h"
#include "libpq-fe.h"
#include "slony_logshipper.h"
#include "../parsestatements/scanner.h"

#include "scan.h"

extern int STMTS[MAXSTATEMENTS];


/*
 * Global data
 */
char   *current_file = "<stdin>";
#ifdef DEBUG
int yydebug=1;
#endif



#line 104 "y.tab.c" /* yacc.c:337  */
# ifndef YY_NULLPTR
#  if defined __cplusplus
#   if 201103L <= __cplusplus
#    define YY_NULLPTR nullptr
#   else
#    define YY_NULLPTR 0
#   endif
#  else
#   define YY_NULLPTR ((void*)0)
#  endif
# endif

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

/* In a future release of Bison, this section will be replaced
   by #include "y.tab.h".  */
#ifndef YY_YY_Y_TAB_H_INCLUDED
# define YY_YY_Y_TAB_H_INCLUDED
/* Debug traces.  */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#if YYDEBUG
extern int yydebug;
#endif

/* Token type.  */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
  enum yytokentype
  {
    K_LOGFILE = 258,
    K_MAX = 259,
    K_ARCHIVES = 260,
    K_ANALYZE = 261,
    K_AND = 262,
    K_ARCHIVE = 263,
    K_ARCHIVE_COMMENT = 264,
    K_CASCADE = 265,
    K_CLUSTER = 266,
    K_COMMAND = 267,
    K_COMMIT = 268,
    K_CONF_COMMENT = 269,
    K_COPY = 270,
    K_DATABASE = 271,
    K_DELETE = 272,
    K_DESTINATION = 273,
    K_DIR = 274,
    K_ERROR = 275,
    K_EXEC_DDL = 276,
    K_FROM = 277,
    K_IGNORE = 278,
    K_INSERT = 279,
    K_INTO = 280,
    K_NAME = 281,
    K_NAMESPACE = 282,
    K_NULL = 283,
    K_ONLY = 284,
    K_POST = 285,
    K_PRE = 286,
    K_PROCESSING = 287,
    K_RENAME = 288,
    K_REPLICA = 289,
    K_SELECT = 290,
    K_SESSION_ROLE = 291,
    K_SET = 292,
    K_START = 293,
    K_START_ARCHIVE = 294,
    K_START_CONFIG = 295,
    K_TABLE = 296,
    K_TO = 297,
    K_TRANSACTION = 298,
    K_TRUNCATE = 299,
    K_UPDATE = 300,
    K_VACUUM = 301,
    K_VALUES = 302,
    K_WHERE = 303,
    T_COPYDATA = 304,
    T_COPYDATA_PART = 305,
    T_COPYEND = 306,
    T_IDENT = 307,
    T_LITERAL = 308,
    T_LITERAL_PART = 309,
    T_NUMBER = 310,
    T_TRACKING_FUNCTION = 311,
    T_FINISH_FUNCTION = 312,
    T_SEQSETVAL_FUNCTION = 313,
    T_PGSETVAL_FUNCTION = 314
  };
#endif
/* Tokens.  */
#define K_LOGFILE 258
#define K_MAX 259
#define K_ARCHIVES 260
#define K_ANALYZE 261
#define K_AND 262
#define K_ARCHIVE 263
#define K_ARCHIVE_COMMENT 264
#define K_CASCADE 265
#define K_CLUSTER 266
#define K_COMMAND 267
#define K_COMMIT 268
#define K_CONF_COMMENT 269
#define K_COPY 270
#define K_DATABASE 271
#define K_DELETE 272
#define K_DESTINATION 273
#define K_DIR 274
#define K_ERROR 275
#define K_EXEC_DDL 276
#define K_FROM 277
#define K_IGNORE 278
#define K_INSERT 279
#define K_INTO 280
#define K_NAME 281
#define K_NAMESPACE 282
#define K_NULL 283
#define K_ONLY 284
#define K_POST 285
#define K_PRE 286
#define K_PROCESSING 287
#define K_RENAME 288
#define K_REPLICA 289
#define K_SELECT 290
#define K_SESSION_ROLE 291
#define K_SET 292
#define K_START 293
#define K_START_ARCHIVE 294
#define K_START_CONFIG 295
#define K_TABLE 296
#define K_TO 297
#define K_TRANSACTION 298
#define K_TRUNCATE 299
#define K_UPDATE 300
#define K_VACUUM 301
#define K_VALUES 302
#define K_WHERE 303
#define T_COPYDATA 304
#define T_COPYDATA_PART 305
#define T_COPYEND 306
#define T_IDENT 307
#define T_LITERAL 308
#define T_LITERAL_PART 309
#define T_NUMBER 310
#define T_TRACKING_FUNCTION 311
#define T_FINISH_FUNCTION 312
#define T_SEQSETVAL_FUNCTION 313
#define T_PGSETVAL_FUNCTION 314

/* Value type.  */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED

union YYSTYPE
{
#line 38 "parser.y" /* yacc.c:352  */

	int32		ival;
	char	   *str;
	AttElem	   *att_elem;
	AttElemList	*att_elem_list;
	SlonDString *dstring;

#line 273 "y.tab.c" /* yacc.c:352  */
};

typedef union YYSTYPE YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define YYSTYPE_IS_DECLARED 1
#endif


extern YYSTYPE yylval;

int yyparse (void);

#endif /* !YY_YY_Y_TAB_H_INCLUDED  */



#ifdef short
# undef short
#endif

#ifdef YYTYPE_UINT8
typedef YYTYPE_UINT8 yytype_uint8;
#else
typedef unsigned char yytype_uint8;
#endif

#ifdef YYTYPE_INT8
typedef YYTYPE_INT8 yytype_int8;
#else
typedef signed char yytype_int8;
#endif

#ifdef YYTYPE_UINT16
typedef YYTYPE_UINT16 yytype_uint16;
#else
typedef unsigned short yytype_uint16;
#endif

#ifdef YYTYPE_INT16
typedef YYTYPE_INT16 yytype_int16;
#else
typedef short yytype_int16;
#endif

#ifndef YYSIZE_T
# ifdef __SIZE_TYPE__
#  define YYSIZE_T __SIZE_TYPE__
# elif defined size_t
#  define YYSIZE_T size_t
# elif ! defined YYSIZE_T
#  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
#  define YYSIZE_T size_t
# else
#  define YYSIZE_T unsigned
# endif
#endif

#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)

#ifndef YY_
# if defined YYENABLE_NLS && YYENABLE_NLS
#  if ENABLE_NLS
#   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
#   define YY_(Msgid) dgettext ("bison-runtime", Msgid)
#  endif
# endif
# ifndef YY_
#  define YY_(Msgid) Msgid
# endif
#endif

#ifndef YY_ATTRIBUTE
# if (defined __GNUC__                                               \
      && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__)))  \
     || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
#  define YY_ATTRIBUTE(Spec) __attribute__(Spec)
# else
#  define YY_ATTRIBUTE(Spec) /* empty */
# endif
#endif

#ifndef YY_ATTRIBUTE_PURE
# define YY_ATTRIBUTE_PURE   YY_ATTRIBUTE ((__pure__))
#endif

#ifndef YY_ATTRIBUTE_UNUSED
# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
#endif

/* Suppress unused-variable warnings by "using" E.  */
#if ! defined lint || defined __GNUC__
# define YYUSE(E) ((void) (E))
#else
# define YYUSE(E) /* empty */
#endif

#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
/* Suppress an incorrect diagnostic about yylval being uninitialized.  */
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
    _Pragma ("GCC diagnostic push") \
    _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
    _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
    _Pragma ("GCC diagnostic pop")
#else
# define YY_INITIAL_VALUE(Value) Value
#endif
#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
# define YY_IGNORE_MAYBE_UNINITIALIZED_END
#endif
#ifndef YY_INITIAL_VALUE
# define YY_INITIAL_VALUE(Value) /* Nothing. */
#endif


#if ! defined yyoverflow || YYERROR_VERBOSE

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

# ifdef YYSTACK_USE_ALLOCA
#  if YYSTACK_USE_ALLOCA
#   ifdef __GNUC__
#    define YYSTACK_ALLOC __builtin_alloca
#   elif defined __BUILTIN_VA_ARG_INCR
#    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
#   elif defined _AIX
#    define YYSTACK_ALLOC __alloca
#   elif defined _MSC_VER
#    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
#    define alloca _alloca
#   else
#    define YYSTACK_ALLOC alloca
#    if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
#     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
      /* Use EXIT_SUCCESS as a witness for stdlib.h.  */
#     ifndef EXIT_SUCCESS
#      define EXIT_SUCCESS 0
#     endif
#    endif
#   endif
#  endif
# endif

# ifdef YYSTACK_ALLOC
   /* Pacify GCC's 'empty if-body' warning.  */
#  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
#  ifndef YYSTACK_ALLOC_MAXIMUM
    /* The OS might guarantee only one guard page at the bottom of the stack,
       and a page size can be as small as 4096 bytes.  So we cannot safely
       invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
       to allow for a few compiler-allocated temporary stack slots.  */
#   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
#  endif
# else
#  define YYSTACK_ALLOC YYMALLOC
#  define YYSTACK_FREE YYFREE
#  ifndef YYSTACK_ALLOC_MAXIMUM
#   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
#  endif
#  if (defined __cplusplus && ! defined EXIT_SUCCESS \
       && ! ((defined YYMALLOC || defined malloc) \
             && (defined YYFREE || defined free)))
#   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
#   ifndef EXIT_SUCCESS
#    define EXIT_SUCCESS 0
#   endif
#  endif
#  ifndef YYMALLOC
#   define YYMALLOC malloc
#   if ! defined malloc && ! defined EXIT_SUCCESS
void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
#   endif
#  endif
#  ifndef YYFREE
#   define YYFREE free
#   if ! defined free && ! defined EXIT_SUCCESS
void free (void *); /* INFRINGES ON USER NAME SPACE */
#   endif
#  endif
# endif
#endif /* ! defined yyoverflow || YYERROR_VERBOSE */


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

/* A type that is properly aligned for any stack member.  */
union yyalloc
{
  yytype_int16 yyss_alloc;
  YYSTYPE yyvs_alloc;
};

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

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

# define YYCOPY_NEEDED 1

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

#endif

#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
/* Copy COUNT objects from SRC to DST.  The source and destination do
   not overlap.  */
# ifndef YYCOPY
#  if defined __GNUC__ && 1 < __GNUC__
#   define YYCOPY(Dst, Src, Count) \
      __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
#  else
#   define YYCOPY(Dst, Src, Count)              \
      do                                        \
        {                                       \
          YYSIZE_T yyi;                         \
          for (yyi = 0; yyi < (Count); yyi++)   \
            (Dst)[yyi] = (Src)[yyi];            \
        }                                       \
      while (0)
#  endif
# endif
#endif /* !YYCOPY_NEEDED */

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

/* YYNTOKENS -- Number of terminals.  */
#define YYNTOKENS  66
/* YYNNTS -- Number of nonterminals.  */
#define YYNNTS  59
/* YYNRULES -- Number of rules.  */
#define YYNRULES  134
/* YYNSTATES -- Number of states.  */
#define YYNSTATES  296

#define YYUNDEFTOK  2
#define YYMAXUTOK   314

/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
   as returned by yylex, with out-of-bounds checking.  */
#define YYTRANSLATE(YYX)                                                \
  ((unsigned) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)

/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
   as returned by yylex.  */
static const yytype_uint8 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,
      63,    65,     2,     2,    64,     2,    62,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,    60,
       2,    61,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
       5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
      15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
      25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
      35,    36,    37,    38,    39,    40,    41,    42,    43,    44,
      45,    46,    47,    48,    49,    50,    51,    52,    53,    54,
      55,    56,    57,    58,    59
};

#if YYDEBUG
  /* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
static const yytype_uint16 yyrline[] =
{
       0,   138,   138,   139,   142,   146,   147,   150,   151,   152,
     153,   154,   155,   156,   157,   158,   159,   160,   163,   172,
     181,   190,   199,   205,   214,   225,   237,   249,   265,   279,
     293,   313,   318,   324,   332,   339,   373,   385,   386,   389,
     390,   391,   392,   393,   394,   395,   396,   397,   398,   399,
     400,   401,   402,   403,   406,   413,   454,   468,   484,   524,
     534,   542,   576,   581,   586,   591,   596,   606,   637,   647,
     662,   673,   682,   688,   694,   701,   715,   731,   741,   750,
     762,   791,   820,   837,   849,   867,   879,   898,   910,   958,
     959,   962,   980,   986,   996,  1008,  1008,  1009,  1010,  1011,
    1012,  1013,  1014,  1015,  1016,  1017,  1018,  1019,  1020,  1021,
    1022,  1023,  1024,  1025,  1026,  1027,  1028,  1029,  1030,  1031,
    1032,  1033,  1034,  1035,  1036,  1037,  1038,  1039,  1042,  1046,
    1059,  1065,  1075,  1084,  1089
};
#endif

#if YYDEBUG || YYERROR_VERBOSE || 0
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
   First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
static const char *const yytname[] =
{
  "$end", "error", "$undefined", "K_LOGFILE", "K_MAX", "K_ARCHIVES",
  "K_ANALYZE", "K_AND", "K_ARCHIVE", "K_ARCHIVE_COMMENT", "K_CASCADE",
  "K_CLUSTER", "K_COMMAND", "K_COMMIT", "K_CONF_COMMENT", "K_COPY",
  "K_DATABASE", "K_DELETE", "K_DESTINATION", "K_DIR", "K_ERROR",
  "K_EXEC_DDL", "K_FROM", "K_IGNORE", "K_INSERT", "K_INTO", "K_NAME",
  "K_NAMESPACE", "K_NULL", "K_ONLY", "K_POST", "K_PRE", "K_PROCESSING",
  "K_RENAME", "K_REPLICA", "K_SELECT", "K_SESSION_ROLE", "K_SET",
  "K_START", "K_START_ARCHIVE", "K_START_CONFIG", "K_TABLE", "K_TO",
  "K_TRANSACTION", "K_TRUNCATE", "K_UPDATE", "K_VACUUM", "K_VALUES",
  "K_WHERE", "T_COPYDATA", "T_COPYDATA_PART", "T_COPYEND", "T_IDENT",
  "T_LITERAL", "T_LITERAL_PART", "T_NUMBER", "T_TRACKING_FUNCTION",
  "T_FINISH_FUNCTION", "T_SEQSETVAL_FUNCTION", "T_PGSETVAL_FUNCTION",
  "';'", "'='", "'.'", "'('", "','", "')'", "$accept", "valid_input",
  "configuration_file", "conf_stmts", "conf_stmt", "conf_archive_dir",
  "conf_dest_dir", "conf_dest_database", "conf_logfile",
  "conf_maxarchives", "conf_clustername", "conf_rename_object",
  "conf_preprocess", "conf_postprocess", "conf_errorcommand",
  "archive_file", "arch_hdr", "arch_session_role", "arch_start_trans",
  "arch_tracking", "arch_tracking_func", "arch_stmts", "arch_stmt",
  "arch_commit", "arch_insert", "arch_ins_vals", "arch_update",
  "arch_upd_set", "arch_delete", "arch_delete_only", "arch_delete_qual",
  "arch_truncate", "arch_copy", "arch_copydata", "arch_copydata_parts",
  "arch_copydata_fin", "arch_copydata_part", "arch_copyend",
  "arch_attr_list", "arch_qualification", "arch_ident_eq_lit",
  "arch_vacuum", "arch_analyze", "arch_finishtable", "arch_finish_func",
  "arch_seqsetval", "arch_seqsetval_func", "arch_pgsetval",
  "arch_pgsetval_func", "arch_exec_ddl", "arch_comments", "arch_comment",
  "num", "ident", "ident_keywords", "literal", "literal_parts",
  "literal_part", "literal_final", YY_NULLPTR
};
#endif

# ifdef YYPRINT
/* YYTOKNUM[NUM] -- (External) token number corresponding to the
   (internal) symbol number NUM (which must be that of a token).  */
static const yytype_uint16 yytoknum[] =
{
       0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
     265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
     275,   276,   277,   278,   279,   280,   281,   282,   283,   284,
     285,   286,   287,   288,   289,   290,   291,   292,   293,   294,
     295,   296,   297,   298,   299,   300,   301,   302,   303,   304,
     305,   306,   307,   308,   309,   310,   311,   312,   313,   314,
      59,    61,    46,    40,    44,    41
};
# endif

#define YYPACT_NINF -242

#define yypact_value_is_default(Yystate) \
  (!!((Yystate) == (-242)))

#define YYTABLE_NINF -1

#define yytable_value_is_error(Yytable_value) \
  0

  /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
     STATE-NUM.  */
static const yytype_int16 yypact[] =
{
     -23,   -49,   -42,    20,  -242,  -242,    24,    77,  -242,  -242,
      25,    -5,  -242,   -24,    34,    22,    19,  -242,    -4,    41,
     -22,    26,    27,   -19,    77,  -242,  -242,  -242,  -242,  -242,
    -242,  -242,  -242,  -242,  -242,  -242,   170,    -3,   170,    39,
    -242,    42,   170,    38,    37,    62,  -242,  -242,  -242,    25,
    -242,  -242,  -242,  -242,  -242,  -242,  -242,  -242,   -25,  -242,
    -242,  -242,  -242,  -242,  -242,  -242,  -242,  -242,  -242,    46,
      45,  -242,   -18,    23,    29,    33,    35,    40,    43,   170,
     170,    74,    75,   170,   170,  -242,  -242,  -242,  -242,  -242,
    -242,  -242,  -242,  -242,  -242,  -242,  -242,  -242,  -242,  -242,
    -242,  -242,  -242,  -242,  -242,  -242,  -242,  -242,  -242,  -242,
    -242,  -242,  -242,  -242,  -242,  -242,  -242,  -242,  -242,  -242,
      44,  -242,  -242,    47,    73,   170,    49,    76,   170,   170,
    -242,  -242,  -242,    61,    69,    78,  -242,  -242,  -242,    54,
       2,  -242,  -242,    60,   -18,   -18,   -18,   -18,   -18,    56,
      55,    57,    63,    79,    64,   170,   170,  -242,   170,    65,
      -7,   170,    66,    67,    89,    80,   170,  -242,  -242,  -242,
    -242,  -242,    81,    82,    84,    85,    88,    92,  -242,   170,
     -18,   -18,   170,   170,    93,    70,    72,   170,  -242,  -242,
    -242,    86,    91,    94,   100,   170,   170,    95,  -242,   101,
    -242,  -242,  -242,  -242,  -242,  -242,    96,   105,   106,   107,
      97,  -242,   170,   170,   108,    60,   -18,   -18,   170,    98,
     109,  -242,   112,  -242,  -242,  -242,  -242,   170,     0,  -242,
     122,   170,    71,   115,   116,   127,   170,   -41,  -242,  -242,
     121,   130,   170,   176,   170,   139,   197,     8,   145,   -18,
     -18,   151,  -242,   157,   170,    -6,   -18,   170,  -242,   170,
    -242,  -242,   170,   165,  -242,   155,   159,  -242,   -18,  -242,
    -242,   156,   171,   172,  -242,   162,   -18,   173,  -242,   -18,
    -242,  -242,   -18,   169,  -242,   174,    13,  -242,   175,   177,
     -18,   178,  -242,  -242,  -242,  -242
};

  /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
     Performed when YYTABLE does not specify something else to do.  Zero
     means the default is an error.  */
static const yytype_uint8 yydefact[] =
{
       0,     0,     0,     0,     2,     3,     0,     0,     1,    91,
       0,     0,    89,     0,     0,     0,     0,     7,     0,     0,
       0,     0,     0,     0,     4,     5,     8,     9,    10,    11,
      12,    13,    14,    15,    16,    17,     0,     0,     0,     0,
      88,     0,     0,     0,     0,     0,    72,    73,    74,    31,
      37,    40,    41,    42,    43,    53,    44,    45,     0,    68,
      70,    46,    51,    52,    47,    48,    49,    50,    39,     0,
       0,    90,     0,     0,     0,     0,     0,     0,     0,     0,
       0,     0,     0,     0,     0,     6,   109,   110,    98,    97,
      99,   100,   101,   102,   103,   104,   105,   106,   107,   108,
     111,   112,   113,   114,   115,   116,   117,   118,    96,    95,
     119,   120,   121,   122,   123,    93,   124,   125,   126,   127,
       0,    94,    54,     0,    63,     0,     0,     0,     0,     0,
      38,    69,    71,     0,     0,     0,   130,   134,   133,     0,
       0,   131,   128,     0,     0,     0,     0,     0,     0,     0,
       0,     0,     0,     0,     0,     0,     0,    62,     0,     0,
       0,     0,     0,     0,     0,     0,     0,    32,    21,   132,
     129,    92,     0,     0,     0,     0,     0,     0,    24,     0,
       0,     0,     0,     0,     0,     0,     0,     0,    83,    85,
      87,     0,     0,     0,     0,     0,     0,     0,    34,     0,
      22,    18,    23,    20,    19,    30,     0,     0,     0,     0,
       0,    81,     0,     0,     0,     0,     0,     0,     0,     0,
       0,    33,     0,    25,    29,    28,    26,     0,     0,    75,
      65,     0,     0,     0,     0,     0,     0,     0,    80,    36,
       0,     0,     0,     0,     0,     0,    64,     0,     0,     0,
       0,     0,    59,     0,     0,     0,     0,     0,    76,     0,
      77,    61,     0,     0,    82,     0,     0,    66,     0,    60,
      58,     0,     0,     0,    78,     0,     0,     0,    79,     0,
      27,    67,     0,     0,    86,     0,     0,    56,     0,     0,
       0,     0,    84,    35,    57,    55
};

  /* YYPGOTO[NTERM-NUM].  */
static const yytype_int16 yypgoto[] =
{
    -242,  -242,  -242,  -242,   206,  -242,  -242,  -242,  -242,  -242,
    -242,  -242,  -242,  -242,  -242,  -242,  -242,  -242,  -242,  -242,
    -242,  -242,   187,  -242,  -242,  -242,  -242,  -242,  -242,  -242,
    -242,  -242,  -242,  -242,  -242,   182,   183,  -242,    11,     6,
    -241,  -242,  -242,  -242,  -242,  -242,  -242,  -242,  -242,  -242,
    -242,     3,    30,   -36,  -242,  -118,  -242,   104,   110
};

  /* YYDEFGOTO[NTERM-NUM].  */
static const yytype_int16 yydefgoto[] =
{
      -1,     3,     4,    24,    25,    26,    27,    28,    29,    30,
      31,    32,    33,    34,    35,     5,    10,    70,   135,   167,
     240,    49,    50,    51,    52,   286,    53,   237,    54,   158,
     245,    55,    56,    57,    58,    59,    60,    61,   228,   246,
     252,    62,    63,    64,   191,    65,   192,    66,   193,    67,
      11,    68,   172,   253,   121,   139,   140,   141,   142
};

  /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM.  If
     positive, shift that token.  If negative, reduce the rule whose
     number is the opposite.  If YYTABLE_NINF, syntax error.  */
static const yytype_uint16 yytable[] =
{
     120,   262,   123,   260,     9,    79,   126,   244,    83,    12,
     136,     6,    76,   269,    71,    77,     1,     2,     7,    80,
       8,   274,    84,   254,    46,    47,   173,   174,   175,   176,
     177,    36,    69,     9,     9,   137,   138,    72,    37,    73,
      38,    74,    39,   149,   150,    75,    40,   153,   154,    41,
     188,   189,   190,    78,   270,   137,   138,   122,    81,    82,
      42,   124,   207,   208,   242,   243,   128,   125,   129,    43,
      44,    45,   242,   263,    46,    47,    48,   290,   291,   127,
      13,    14,   133,   134,   143,    15,   151,   152,    16,   159,
     144,    17,   162,   163,   145,    18,   146,    19,   233,   234,
      20,   147,   157,   164,   148,   161,   155,    21,    22,   156,
      23,   160,   165,   166,   168,   171,   178,   179,   180,   184,
     185,   182,   186,   197,   181,   194,   183,   187,   195,   196,
     199,   265,   266,   212,   213,   236,   248,   251,   271,   227,
     198,   200,   201,   206,   202,   203,   209,   210,   204,   215,
     278,   214,   205,   211,   216,   221,   223,   217,   283,   219,
     220,   285,   218,   222,   287,   224,   225,   226,   239,   238,
     244,   231,   294,    86,    87,    88,   229,   230,    89,   249,
     250,    90,   235,    91,   256,    92,    93,    94,    95,    96,
      97,   241,   257,    98,    99,   229,   100,   101,   259,   261,
     102,   103,   104,   105,   262,   264,   258,   106,   107,   108,
     109,   267,   275,   110,   111,   112,   113,   114,   268,   276,
     279,   272,   115,   273,   277,   282,   116,   117,   118,   119,
      85,   280,   281,   284,   288,   292,   130,   293,   295,   289,
     131,   132,   247,   255,   169,   232,     0,     0,     0,     0,
     170
};

static const yytype_int16 yycheck[] =
{
      36,     7,    38,   244,     9,    27,    42,    48,    27,     6,
      28,    60,    16,   254,    11,    19,    39,    40,    60,    41,
       0,   262,    41,    64,    49,    50,   144,   145,   146,   147,
     148,     6,    37,     9,     9,    53,    54,    61,    13,     5,
      15,    19,    17,    79,    80,    26,    21,    83,    84,    24,
      57,    58,    59,    12,    60,    53,    54,    60,    32,    32,
      35,    22,   180,   181,    64,    65,    29,    25,     6,    44,
      45,    46,    64,    65,    49,    50,    51,    64,    65,    41,
       3,     4,    36,    38,    61,     8,    12,    12,    11,   125,
      61,    14,   128,   129,    61,    18,    61,    20,   216,   217,
      23,    61,    29,    42,    61,    29,    62,    30,    31,    62,
      33,    62,    43,    35,    60,    55,    60,    62,    61,   155,
     156,    42,   158,    34,    61,   161,    62,    62,    62,    62,
     166,   249,   250,    63,    62,    37,    65,    10,   256,    42,
      60,    60,    60,   179,    60,    60,   182,   183,    60,    63,
     268,   187,    60,    60,    63,    60,    60,    63,   276,   195,
     196,   279,    62,    62,   282,    60,    60,    60,    56,    60,
      48,    63,   290,     3,     4,     5,   212,   213,     8,    64,
      64,    11,   218,    13,    63,    15,    16,    17,    18,    19,
      20,   227,    62,    23,    24,   231,    26,    27,    22,    60,
      30,    31,    32,    33,     7,    60,   242,    37,    38,    39,
      40,    60,    47,    43,    44,    45,    46,    47,    61,    64,
      64,   257,    52,   259,    65,    63,    56,    57,    58,    59,
      24,    60,    60,    60,    65,    60,    49,    60,    60,    65,
      58,    58,   231,   237,   140,   215,    -1,    -1,    -1,    -1,
     140
};

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

  /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
static const yytype_uint8 yyr1[] =
{
       0,    66,    67,    67,    68,    69,    69,    70,    70,    70,
      70,    70,    70,    70,    70,    70,    70,    70,    71,    72,
      73,    74,    75,    76,    77,    77,    77,    77,    78,    79,
      80,    81,    82,    83,    84,    85,    86,    87,    87,    88,
      88,    88,    88,    88,    88,    88,    88,    88,    88,    88,
      88,    88,    88,    88,    89,    90,    91,    91,    92,    93,
      93,    94,    95,    95,    96,    96,    97,    98,    99,    99,
     100,   100,   101,   102,   103,   104,   104,   105,   105,   106,
     107,   108,   109,   110,   111,   112,   113,   114,   115,   116,
     116,   117,   118,   119,   119,   120,   120,   120,   120,   120,
     120,   120,   120,   120,   120,   120,   120,   120,   120,   120,
     120,   120,   120,   120,   120,   120,   120,   120,   120,   120,
     120,   120,   120,   120,   120,   120,   120,   120,   121,   121,
     121,   122,   122,   123,   124
};

  /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.  */
static const yytype_uint8 yyr2[] =
{
       0,     2,     1,     1,     3,     1,     2,     1,     1,     1,
       1,     1,     1,     1,     1,     1,     1,     1,     5,     5,
       5,     4,     5,     5,     4,     6,     6,    10,     6,     6,
       5,     4,     4,     5,     3,    10,     1,     1,     2,     1,
       1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
       1,     1,     1,     1,     2,    13,     1,     3,     8,     2,
       3,     8,     1,     0,     1,     0,     8,    10,     1,     2,
       1,     2,     1,     1,     1,     1,     3,     2,     3,     3,
       6,     5,     8,     1,    12,     1,    10,     1,     1,     1,
       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,     1,     1,     1,     1,     1,     1,     1,     2,
       1,     1,     2,     1,     1
};


#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 yyerrorlab


#define YYRECOVERING()  (!!yyerrstatus)

#define YYBACKUP(Token, Value)                                    \
  do                                                              \
    if (yychar == YYEMPTY)                                        \
      {                                                           \
        yychar = (Token);                                         \
        yylval = (Value);                                         \
        YYPOPSTACK (yylen);                                       \
        yystate = *yyssp;                                         \
        goto yybackup;                                            \
      }                                                           \
    else                                                          \
      {                                                           \
        yyerror (YY_("syntax error: cannot back up")); \
        YYERROR;                                                  \
      }                                                           \
  while (0)

/* Error token number */
#define YYTERROR        1
#define YYERRCODE       256



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

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

# define YYDPRINTF(Args)                        \
do {                                            \
  if (yydebug)                                  \
    YYFPRINTF Args;                             \
} while (0)

/* This macro is provided for backward compatibility. */
#ifndef YY_LOCATION_PRINT
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
#endif


# define YY_SYMBOL_PRINT(Title, Type, Value, Location)                    \
do {                                                                      \
  if (yydebug)                                                            \
    {                                                                     \
      YYFPRINTF (stderr, "%s ", Title);                                   \
      yy_symbol_print (stderr,                                            \
                  Type, Value); \
      YYFPRINTF (stderr, "\n");                                           \
    }                                                                     \
} while (0)


/*-----------------------------------.
| Print this symbol's value on YYO.  |
`-----------------------------------*/

static void
yy_symbol_value_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep)
{
  FILE *yyoutput = yyo;
  YYUSE (yyoutput);
  if (!yyvaluep)
    return;
# ifdef YYPRINT
  if (yytype < YYNTOKENS)
    YYPRINT (yyo, yytoknum[yytype], *yyvaluep);
# endif
  YYUSE (yytype);
}


/*---------------------------.
| Print this symbol on YYO.  |
`---------------------------*/

static void
yy_symbol_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep)
{
  YYFPRINTF (yyo, "%s %s (",
             yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);

  yy_symbol_value_print (yyo, yytype, yyvaluep);
  YYFPRINTF (yyo, ")");
}

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

static void
yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
{
  YYFPRINTF (stderr, "Stack now");
  for (; yybottom <= yytop; yybottom++)
    {
      int yybot = *yybottom;
      YYFPRINTF (stderr, " %d", yybot);
    }
  YYFPRINTF (stderr, "\n");
}

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


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

static void
yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule)
{
  unsigned long yylno = yyrline[yyrule];
  int yynrhs = yyr2[yyrule];
  int yyi;
  YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
             yyrule - 1, yylno);
  /* The symbols being reduced.  */
  for (yyi = 0; yyi < yynrhs; yyi++)
    {
      YYFPRINTF (stderr, "   $%d = ", yyi + 1);
      yy_symbol_print (stderr,
                       yystos[yyssp[yyi + 1 - yynrhs]],
                       &yyvsp[(yyi + 1) - (yynrhs)]
                                              );
      YYFPRINTF (stderr, "\n");
    }
}

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

/* Nonzero means print parse trace.  It is left uninitialized so that
   multiple parsers can coexist.  */
int yydebug;
#else /* !YYDEBUG */
# define YYDPRINTF(Args)
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
# define YY_STACK_PRINT(Bottom, Top)
# define YY_REDUCE_PRINT(Rule)
#endif /* !YYDEBUG */


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

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

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

#ifndef YYMAXDEPTH
# define YYMAXDEPTH 10000
#endif


#if YYERROR_VERBOSE

# ifndef yystrlen
#  if defined __GLIBC__ && defined _STRING_H
#   define yystrlen strlen
#  else
/* Return the length of YYSTR.  */
static YYSIZE_T
yystrlen (const char *yystr)
{
  YYSIZE_T yylen;
  for (yylen = 0; yystr[yylen]; yylen++)
    continue;
  return yylen;
}
#  endif
# endif

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

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

  return yyd - 1;
}
#  endif
# endif

# ifndef yytnamerr
/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
   quotes and backslashes, so that it's suitable for yyerror.  The
   heuristic is that double-quoting is unnecessary unless the string
   contains an apostrophe, a comma, or backslash (other than
   backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
   null, do not copy; instead, return the length of what the result
   would have been.  */
static YYSIZE_T
yytnamerr (char *yyres, const char *yystr)
{
  if (*yystr == '"')
    {
      YYSIZE_T yyn = 0;
      char const *yyp = yystr;

      for (;;)
        switch (*++yyp)
          {
          case '\'':
          case ',':
            goto do_not_strip_quotes;

          case '\\':
            if (*++yyp != '\\')
              goto do_not_strip_quotes;
            else
              goto append;

          append:
          default:
            if (yyres)
              yyres[yyn] = *yyp;
            yyn++;
            break;

          case '"':
            if (yyres)
              yyres[yyn] = '\0';
            return yyn;
          }
    do_not_strip_quotes: ;
    }

  if (! yyres)
    return yystrlen (yystr);

  return (YYSIZE_T) (yystpcpy (yyres, yystr) - yyres);
}
# endif

/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
   about the unexpected token YYTOKEN for the state stack whose top is
   YYSSP.

   Return 0 if *YYMSG was successfully written.  Return 1 if *YYMSG is
   not large enough to hold the message.  In that case, also set
   *YYMSG_ALLOC to the required number of bytes.  Return 2 if the
   required number of bytes is too large to store.  */
static int
yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
                yytype_int16 *yyssp, int yytoken)
{
  YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
  YYSIZE_T yysize = yysize0;
  enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
  /* Internationalized format string. */
  const char *yyformat = YY_NULLPTR;
  /* Arguments of yyformat. */
  char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
  /* Number of reported tokens (one for the "unexpected", one per
     "expected"). */
  int yycount = 0;

  /* There are many possibilities here to consider:
     - If this state is a consistent state with a default action, then
       the only way this function was invoked is if the default action
       is an error action.  In that case, don't check for expected
       tokens because there are none.
     - The only way there can be no lookahead present (in yychar) is if
       this state is a consistent state with a default action.  Thus,
       detecting the absence of a lookahead is sufficient to determine
       that there is no unexpected or expected token to report.  In that
       case, just report a simple "syntax error".
     - Don't assume there isn't a lookahead just because this state is a
       consistent state with a default action.  There might have been a
       previous inconsistent state, consistent state with a non-default
       action, or user semantic action that manipulated yychar.
     - Of course, the expected token list depends on states to have
       correct lookahead information, and it depends on the parser not
       to perform extra reductions after fetching a lookahead from the
       scanner and before detecting a syntax error.  Thus, state merging
       (from LALR or IELR) and default reductions corrupt the expected
       token list.  However, the list is correct for canonical LR with
       one exception: it will still contain any token that will not be
       accepted due to an error action in a later state.
  */
  if (yytoken != YYEMPTY)
    {
      int yyn = yypact[*yyssp];
      yyarg[yycount++] = yytname[yytoken];
      if (!yypact_value_is_default (yyn))
        {
          /* Start YYX at -YYN if negative to avoid negative indexes in
             YYCHECK.  In other words, skip the first -YYN actions for
             this state because they are default actions.  */
          int yyxbegin = yyn < 0 ? -yyn : 0;
          /* Stay within bounds of both yycheck and yytname.  */
          int yychecklim = YYLAST - yyn + 1;
          int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
          int yyx;

          for (yyx = yyxbegin; yyx < yyxend; ++yyx)
            if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
                && !yytable_value_is_error (yytable[yyx + yyn]))
              {
                if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
                  {
                    yycount = 1;
                    yysize = yysize0;
                    break;
                  }
                yyarg[yycount++] = yytname[yyx];
                {
                  YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
                  if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
                    yysize = yysize1;
                  else
                    return 2;
                }
              }
        }
    }

  switch (yycount)
    {
# define YYCASE_(N, S)                      \
      case N:                               \
        yyformat = S;                       \
      break
    default: /* Avoid compiler warnings. */
      YYCASE_(0, YY_("syntax error"));
      YYCASE_(1, YY_("syntax error, unexpected %s"));
      YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
      YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
      YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
      YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
# undef YYCASE_
    }

  {
    YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
    if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
      yysize = yysize1;
    else
      return 2;
  }

  if (*yymsg_alloc < yysize)
    {
      *yymsg_alloc = 2 * yysize;
      if (! (yysize <= *yymsg_alloc
             && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
        *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
      return 1;
    }

  /* Avoid sprintf, as that infringes on the user's name space.
     Don't have undefined behavior even if the translation
     produced a string with the wrong number of "%s"s.  */
  {
    char *yyp = *yymsg;
    int yyi = 0;
    while ((*yyp = *yyformat) != '\0')
      if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
        {
          yyp += yytnamerr (yyp, yyarg[yyi++]);
          yyformat += 2;
        }
      else
        {
          yyp++;
          yyformat++;
        }
  }
  return 0;
}
#endif /* YYERROR_VERBOSE */

/*-----------------------------------------------.
| Release the memory associated to this symbol.  |
`-----------------------------------------------*/

static void
yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
{
  YYUSE (yyvaluep);
  if (!yymsg)
    yymsg = "Deleting";
  YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);

  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  YYUSE (yytype);
  YY_IGNORE_MAYBE_UNINITIALIZED_END
}




/* The lookahead symbol.  */
int yychar;

/* The semantic value of the lookahead symbol.  */
YYSTYPE yylval;
/* Number of syntax errors so far.  */
int yynerrs;


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

int
yyparse (void)
{
    int yystate;
    /* Number of tokens to shift before error messages enabled.  */
    int yyerrstatus;

    /* The stacks and their tools:
       'yyss': related to states.
       'yyvs': related to semantic values.

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

    /* The state stack.  */
    yytype_int16 yyssa[YYINITDEPTH];
    yytype_int16 *yyss;
    yytype_int16 *yyssp;

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

    YYSIZE_T yystacksize;

  int yyn;
  int yyresult;
  /* Lookahead token as an internal (translated) token number.  */
  int yytoken = 0;
  /* The variables used to return semantic value and location from the
     action routines.  */
  YYSTYPE yyval;

#if YYERROR_VERBOSE
  /* Buffer for error messages, and its allocated size.  */
  char yymsgbuf[128];
  char *yymsg = yymsgbuf;
  YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
#endif

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

  /* The number of symbols on the RHS of the reduced rule.
     Keep to zero when no symbol should be popped.  */
  int yylen = 0;

  yyssp = yyss = yyssa;
  yyvsp = yyvs = yyvsa;
  yystacksize = YYINITDEPTH;

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

  yystate = 0;
  yyerrstatus = 0;
  yynerrs = 0;
  yychar = YYEMPTY; /* Cause a token to be read.  */
  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++;


/*--------------------------------------------------------------------.
| yynewstate -- set current state (the top of the stack) to yystate.  |
`--------------------------------------------------------------------*/
yysetstate:
  *yyssp = (yytype_int16) yystate;

  if (yyss + yystacksize - 1 <= yyssp)
#if !defined yyoverflow && !defined YYSTACK_RELOCATE
    goto yyexhaustedlab;
#else
    {
      /* Get the current used size of the three stacks, in elements.  */
      YYSIZE_T yysize = (YYSIZE_T) (yyssp - yyss + 1);

# if defined yyoverflow
      {
        /* Give user a chance to reallocate the stack.  Use copies of
           these so that the &'s don't force the real ones into
           memory.  */
        YYSTYPE *yyvs1 = yyvs;
        yytype_int16 *yyss1 = yyss;

        /* Each stack pointer address is followed by the size of the
           data in use in that stack, in bytes.  This used to be a
           conditional around just the two extra args, but that might
           be undefined if yyoverflow is a macro.  */
        yyoverflow (YY_("memory exhausted"),
                    &yyss1, yysize * sizeof (*yyssp),
                    &yyvs1, yysize * sizeof (*yyvsp),
                    &yystacksize);
        yyss = yyss1;
        yyvs = yyvs1;
      }
# else /* defined YYSTACK_RELOCATE */
      /* Extend the stack our own way.  */
      if (YYMAXDEPTH <= yystacksize)
        goto yyexhaustedlab;
      yystacksize *= 2;
      if (YYMAXDEPTH < yystacksize)
        yystacksize = YYMAXDEPTH;

      {
        yytype_int16 *yyss1 = yyss;
        union yyalloc *yyptr =
          (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
        if (! yyptr)
          goto yyexhaustedlab;
        YYSTACK_RELOCATE (yyss_alloc, yyss);
        YYSTACK_RELOCATE (yyvs_alloc, yyvs);
# undef YYSTACK_RELOCATE
        if (yyss1 != yyssa)
          YYSTACK_FREE (yyss1);
      }
# endif

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

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

      if (yyss + yystacksize - 1 <= yyssp)
        YYABORT;
    }
#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */

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

  if (yystate == YYFINAL)
    YYACCEPT;

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

  /* First try to decide what to do without reference to lookahead token.  */
  yyn = yypact[yystate];
  if (yypact_value_is_default (yyn))
    goto yydefault;

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

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

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

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

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

  /* Shift the lookahead token.  */
  YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);

  /* Discard the shifted token.  */
  yychar = YYEMPTY;

  yystate = yyn;
  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  *++yyvsp = yylval;
  YY_IGNORE_MAYBE_UNINITIALIZED_END

  goto yynewstate;


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


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

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

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


  YY_REDUCE_PRINT (yyn);
  switch (yyn)
    {
        case 18:
#line 164 "parser.y" /* yacc.c:1652  */
    {
						if (archive_dir != NULL)
							parse_error("duplicate archive dir specification");
						else
							archive_dir = strdup((yyvsp[-1].str));
					}
#line 1583 "y.tab.c" /* yacc.c:1652  */
    break;

  case 19:
#line 173 "parser.y" /* yacc.c:1652  */
    {
						if (destination_dir != NULL)
							parse_error("duplicate destination dir specification");
						else
							destination_dir = strdup((yyvsp[-1].str));
					}
#line 1594 "y.tab.c" /* yacc.c:1652  */
    break;

  case 20:
#line 182 "parser.y" /* yacc.c:1652  */
    {
						if (destination_conninfo != NULL)
							parse_error("duplicate destination database specification");
						else
							destination_conninfo = strdup((yyvsp[-1].str));
					}
#line 1605 "y.tab.c" /* yacc.c:1652  */
    break;

  case 21:
#line 191 "parser.y" /* yacc.c:1652  */
    {
						if (logfile_path != NULL)
							parse_error("duplicate logfile path specification");
						else
							logfile_path = strdup((yyvsp[-1].str));
					}
#line 1616 "y.tab.c" /* yacc.c:1652  */
    break;

  case 22:
#line 200 "parser.y" /* yacc.c:1652  */
    {
						max_archives = (yyvsp[-1].ival);
					}
#line 1624 "y.tab.c" /* yacc.c:1652  */
    break;

  case 23:
#line 206 "parser.y" /* yacc.c:1652  */
    {
						if (cluster_name != NULL)
							parse_error("duplicate cluster name specification");
						else
							cluster_name = strdup((yyvsp[-1].str));
					}
#line 1635 "y.tab.c" /* yacc.c:1652  */
    break;

  case 24:
#line 215 "parser.y" /* yacc.c:1652  */
    {
						RenameObject *new;

						new = (RenameObject *)malloc(sizeof(RenameObject));
						memset(new, 0, sizeof(RenameObject));

						new->old_namespace = (yyvsp[-1].str);

						config_add_rename(new);
					}
#line 1650 "y.tab.c" /* yacc.c:1652  */
    break;

  case 25:
#line 226 "parser.y" /* yacc.c:1652  */
    {
						RenameObject *new;

						new = (RenameObject *)malloc(sizeof(RenameObject));
						memset(new, 0, sizeof(RenameObject));

						new->old_namespace = (yyvsp[-3].str);
						new->old_name      = (yyvsp[-1].str);

						config_add_rename(new);
					}
#line 1666 "y.tab.c" /* yacc.c:1652  */
    break;

  case 26:
#line 238 "parser.y" /* yacc.c:1652  */
    {
						RenameObject *new;

						new = (RenameObject *)malloc(sizeof(RenameObject));
						memset(new, 0, sizeof(RenameObject));

						new->old_namespace = (yyvsp[-3].str);
						new->new_namespace = (yyvsp[-1].str);

						config_add_rename(new);
					}
#line 1682 "y.tab.c" /* yacc.c:1652  */
    break;

  case 27:
#line 250 "parser.y" /* yacc.c:1652  */
    {
						RenameObject *new;

						new = (RenameObject *)malloc(sizeof(RenameObject));
						memset(new, 0, sizeof(RenameObject));

						new->old_namespace = (yyvsp[-7].str);
						new->old_name      = (yyvsp[-5].str);
						new->new_namespace = (yyvsp[-3].str);
						new->new_name      = (yyvsp[-1].str);

						config_add_rename(new);
					}
#line 1700 "y.tab.c" /* yacc.c:1652  */
    break;

  case 28:
#line 266 "parser.y" /* yacc.c:1652  */
    {
						ProcessingCommand	  **pptr;

						pptr = &pre_processing_commands;
						while (*pptr != NULL)
							pptr = &((*pptr)->next);
						
						*pptr = (ProcessingCommand *)malloc(sizeof(ProcessingCommand));
						(*pptr)->command = (yyvsp[-1].str);
						(*pptr)->next = NULL;
					}
#line 1716 "y.tab.c" /* yacc.c:1652  */
    break;

  case 29:
#line 280 "parser.y" /* yacc.c:1652  */
    {
						ProcessingCommand	  **pptr;

						pptr = &post_processing_commands;
						while (*pptr != NULL)
							pptr = &((*pptr)->next);
						
						*pptr = (ProcessingCommand *)malloc(sizeof(ProcessingCommand));
						(*pptr)->command = (yyvsp[-1].str);
						(*pptr)->next = NULL;
					}
#line 1732 "y.tab.c" /* yacc.c:1652  */
    break;

  case 30:
#line 294 "parser.y" /* yacc.c:1652  */
    {
						ProcessingCommand	  **pptr;

						pptr = &error_commands;
						while (*pptr != NULL)
							pptr = &((*pptr)->next);
						
						*pptr = (ProcessingCommand *)malloc(sizeof(ProcessingCommand));
						(*pptr)->command = (yyvsp[-1].str);
						(*pptr)->next = NULL;
					}
#line 1748 "y.tab.c" /* yacc.c:1652  */
    break;

  case 33:
#line 325 "parser.y" /* yacc.c:1652  */
    {
						if (process_simple_sql(
							"set session_replication_role to replica;") < 0)
							YYABORT;
					}
#line 1758 "y.tab.c" /* yacc.c:1652  */
    break;

  case 34:
#line 333 "parser.y" /* yacc.c:1652  */
    {
						if (process_start_transaction("start transaction;") < 0)
							YYABORT;
					}
#line 1767 "y.tab.c" /* yacc.c:1652  */
    break;

  case 35:
#line 340 "parser.y" /* yacc.c:1652  */
    {
						SlonDString	ds;
						int			rc;

						dstring_init(&ds);
						slon_mkquery(&ds, "select %s.%s('%s', '%s');",
								(yyvsp[-8].str), (yyvsp[-6].str), (yyvsp[-4].str), (yyvsp[-2].str));
						rc = process_check_at_counter((yyvsp[-4].str));
						free((yyvsp[-8].str));
						free((yyvsp[-6].str));
						free((yyvsp[-4].str));
						free((yyvsp[-2].str));

						if (rc < 0)
						{
							dstring_free(&ds);
							YYABORT;
						}
						if (rc == 1)
						{
							dstring_free(&ds);
							YYACCEPT;
						}
						
						if (process_simple_sql(dstring_data(&ds)) < 0)
						{
							dstring_free(&ds);
							YYABORT;
						}
						else
							dstring_free(&ds);
					}
#line 1804 "y.tab.c" /* yacc.c:1652  */
    break;

  case 36:
#line 374 "parser.y" /* yacc.c:1652  */
    {
						char   *ret;
						size_t toklen=yyget_leng();
						ret = malloc(toklen + 1);
						memcpy(ret, yytext, toklen);
						ret[toklen] = '\0';

						(yyval.str) = ret;
					}
#line 1818 "y.tab.c" /* yacc.c:1652  */
    break;

  case 54:
#line 407 "parser.y" /* yacc.c:1652  */
    {
						if (process_end_transaction("commit;") < 0)
							YYABORT;
					}
#line 1827 "y.tab.c" /* yacc.c:1652  */
    break;

  case 55:
#line 414 "parser.y" /* yacc.c:1652  */
    {
						InsertStmt	stmt;
						AttElem	   *nelem;
						AttElem	   *velem;
						AttElem	   *next;
						int			rc;

						stmt.namespace	= (yyvsp[-10].str);
						stmt.tablename	= (yyvsp[-8].str);
						stmt.attributes	= (yyvsp[-6].att_elem_list);

						for (nelem = (yyvsp[-6].att_elem_list)->list_head, velem = (yyvsp[-2].att_elem_list)->list_head;
								nelem != NULL && velem != NULL;
								nelem = nelem->next, velem = next)
						{
							nelem->attvalue = velem->attvalue;
							next = velem->next;
							free(velem);
						}
						free((yyvsp[-2].att_elem_list));

						rc = process_insert(&stmt);

						for (nelem = (yyvsp[-6].att_elem_list)->list_head; nelem != NULL; nelem = next)
						{
							next = nelem->next;
							free(nelem->attname);
							if (nelem->attvalue != NULL)
								free(nelem->attvalue);
							free(nelem);
						}
						free(stmt.namespace);
						free(stmt.tablename);
						free(stmt.attributes);

						if (rc < 0)
							YYABORT;
					}
#line 1870 "y.tab.c" /* yacc.c:1652  */
    break;

  case 56:
#line 455 "parser.y" /* yacc.c:1652  */
    {
						AttElemList	   *new;
						new = (AttElemList *)malloc(sizeof(AttElemList));

						new->list_head = (AttElem *)malloc(sizeof(AttElem));
						new->list_tail = new->list_head;

						new->list_head->attname = NULL;
						new->list_head->attvalue = (yyvsp[0].str);
						new->list_head->next = NULL;

						(yyval.att_elem_list) = new;
					}
#line 1888 "y.tab.c" /* yacc.c:1652  */
    break;

  case 57:
#line 469 "parser.y" /* yacc.c:1652  */
    {
						AttElem		   *new;
						new = (AttElem *)malloc(sizeof(AttElem));

						new->attname = NULL;
						new->attvalue = (yyvsp[0].str);
						new->next = NULL;

						(yyvsp[-2].att_elem_list)->list_tail->next = new;
						(yyvsp[-2].att_elem_list)->list_tail = new;

						(yyval.att_elem_list) = (yyvsp[-2].att_elem_list);
					}
#line 1906 "y.tab.c" /* yacc.c:1652  */
    break;

  case 58:
#line 485 "parser.y" /* yacc.c:1652  */
    {
						UpdateStmt		stmt;
						AttElem		   *elem;
						AttElem		   *next;
						int				rc;

						stmt.namespace		= (yyvsp[-5].str);
						stmt.tablename		= (yyvsp[-3].str);
						stmt.changes		= (yyvsp[-2].att_elem_list);
						stmt.qualification	= (yyvsp[-1].att_elem_list);

						rc = process_update(&stmt);

						for (elem = stmt.changes->list_head; elem != NULL; elem = next)
						{
							next = elem->next;
							free(elem->attname);
							if (elem->attvalue != NULL)
								free(elem->attvalue);
							free(elem);
						}
						free(stmt.changes);
						for (elem = stmt.qualification->list_head; elem != NULL; elem = next)
						{
							next = elem->next;
							free(elem->attname);
							if (elem->attvalue != NULL)
								free(elem->attvalue);
							free(elem);
						}
						free(stmt.namespace);
						free(stmt.tablename);
						free(stmt.qualification);

						if (rc < 0)
							YYABORT;
					}
#line 1948 "y.tab.c" /* yacc.c:1652  */
    break;

  case 59:
#line 525 "parser.y" /* yacc.c:1652  */
    {
						AttElemList	   *new;
						new = (AttElemList *)malloc(sizeof(AttElemList));

						new->list_head = (yyvsp[0].att_elem);
						new->list_tail = (yyvsp[0].att_elem);

						(yyval.att_elem_list) = new;
					}
#line 1962 "y.tab.c" /* yacc.c:1652  */
    break;

  case 60:
#line 535 "parser.y" /* yacc.c:1652  */
    { 
						(yyvsp[-2].att_elem_list)->list_tail->next = (yyvsp[0].att_elem);
						(yyvsp[-2].att_elem_list)->list_tail = (yyvsp[0].att_elem);

						(yyval.att_elem_list) = (yyvsp[-2].att_elem_list);
					}
#line 1973 "y.tab.c" /* yacc.c:1652  */
    break;

  case 61:
#line 543 "parser.y" /* yacc.c:1652  */
    {
						DeleteStmt		stmt;
						AttElem		   *elem;
						AttElem		   *next;
						int				rc;

						stmt.namespace		= (yyvsp[-4].str);
						stmt.tablename		= (yyvsp[-2].str);
						stmt.only			= (yyvsp[-5].ival);
						stmt.qualification	= (yyvsp[-1].att_elem_list);

						rc = process_delete(&stmt);

						if (stmt.qualification != NULL)
						{
							for (elem = stmt.qualification->list_head; elem != NULL; elem = next)
							{
								next = elem->next;
								free(elem->attname);
								if (elem->attvalue != NULL)
									free(elem->attvalue);
								free(elem);
							}
							free(stmt.qualification);
						}
						free(stmt.namespace);
						free(stmt.tablename);

						if (rc < 0)
							YYABORT;
					}
#line 2009 "y.tab.c" /* yacc.c:1652  */
    break;

  case 62:
#line 577 "parser.y" /* yacc.c:1652  */
    {
						(yyval.ival) = 1;
					}
#line 2017 "y.tab.c" /* yacc.c:1652  */
    break;

  case 63:
#line 581 "parser.y" /* yacc.c:1652  */
    {
						(yyval.ival) = 0;
					}
#line 2025 "y.tab.c" /* yacc.c:1652  */
    break;

  case 64:
#line 587 "parser.y" /* yacc.c:1652  */
    {
						(yyval.att_elem_list) = (yyvsp[0].att_elem_list);
					}
#line 2033 "y.tab.c" /* yacc.c:1652  */
    break;

  case 65:
#line 591 "parser.y" /* yacc.c:1652  */
    {
						(yyval.att_elem_list) = NULL;
					}
#line 2041 "y.tab.c" /* yacc.c:1652  */
    break;

  case 66:
#line 597 "parser.y" /* yacc.c:1652  */
    {
						
						TruncateStmt stmt;
						stmt.namespace=(yyvsp[-4].str);
						stmt.tablename=(yyvsp[-2].str);
						process_truncate(&stmt);

					}
#line 2054 "y.tab.c" /* yacc.c:1652  */
    break;

  case 67:
#line 607 "parser.y" /* yacc.c:1652  */
    {
						CopyStmt		stmt;
						AttElem		   *elem;
						AttElem		   *next;
						int				rc;

						stmt.namespace		= (yyvsp[-8].str);
						stmt.tablename		= (yyvsp[-6].str);
						stmt.attributes		= (yyvsp[-4].att_elem_list);
						stmt.from			= (yyvsp[-1].str);

						rc = process_copy(&stmt);

						for (elem = stmt.attributes->list_head; elem != NULL; elem = next)
						{
							next = elem->next;
							free(elem->attname);
							if (elem->attvalue != NULL)
								free(elem->attvalue);
							free(elem);
						}
						free(stmt.attributes);
						free(stmt.namespace);
						free(stmt.tablename);

						if (rc < 0)
							YYABORT;
					}
#line 2087 "y.tab.c" /* yacc.c:1652  */
    break;

  case 68:
#line 638 "parser.y" /* yacc.c:1652  */
    {
						int rc;

						rc = process_copydata((yyvsp[0].str));
						free((yyvsp[0].str));

						if (rc < 0)
							YYABORT;
					}
#line 2101 "y.tab.c" /* yacc.c:1652  */
    break;

  case 69:
#line 648 "parser.y" /* yacc.c:1652  */
    {
						int rc;

						dstring_append((yyvsp[-1].dstring), (yyvsp[0].str));
						dstring_terminate((yyvsp[-1].dstring));
						free((yyvsp[0].str));
						rc = process_copydata(dstring_data((yyvsp[-1].dstring)));
						dstring_free((yyvsp[-1].dstring));

						if (rc < 0)
							YYABORT;
					}
#line 2118 "y.tab.c" /* yacc.c:1652  */
    break;

  case 70:
#line 663 "parser.y" /* yacc.c:1652  */
    {
						SlonDString	*new;

						new = (SlonDString *)malloc(sizeof(SlonDString));
						dstring_init(new);
						dstring_append(new, (yyvsp[0].str));
						free((yyvsp[0].str));

						(yyval.dstring) = new;
					}
#line 2133 "y.tab.c" /* yacc.c:1652  */
    break;

  case 71:
#line 674 "parser.y" /* yacc.c:1652  */
    {
						dstring_append((yyvsp[-1].dstring), (yyvsp[0].str));
						free((yyvsp[0].str));

						(yyval.dstring) = (yyvsp[-1].dstring);
					}
#line 2144 "y.tab.c" /* yacc.c:1652  */
    break;

  case 72:
#line 683 "parser.y" /* yacc.c:1652  */
    {
						(yyval.str) = strdup(yychunk);
					}
#line 2152 "y.tab.c" /* yacc.c:1652  */
    break;

  case 73:
#line 689 "parser.y" /* yacc.c:1652  */
    {
						(yyval.str) = strdup(yychunk);
					}
#line 2160 "y.tab.c" /* yacc.c:1652  */
    break;

  case 74:
#line 695 "parser.y" /* yacc.c:1652  */
    {
						if (process_copyend() < 0)
							YYABORT;
					}
#line 2169 "y.tab.c" /* yacc.c:1652  */
    break;

  case 75:
#line 702 "parser.y" /* yacc.c:1652  */
    {
						AttElemList	   *new;
						new = (AttElemList *)malloc(sizeof(AttElemList));

						new->list_head = (AttElem *)malloc(sizeof(AttElem));
						new->list_tail = new->list_head;

						new->list_head->attname = (yyvsp[0].str);
						new->list_head->attvalue = NULL;
						new->list_head->next = NULL;

						(yyval.att_elem_list) = new;
					}
#line 2187 "y.tab.c" /* yacc.c:1652  */
    break;

  case 76:
#line 716 "parser.y" /* yacc.c:1652  */
    {
						AttElem		   *new;
						new = (AttElem *)malloc(sizeof(AttElem));

						new->attname = (yyvsp[0].str);
						new->attvalue = NULL;
						new->next = NULL;

						(yyvsp[-2].att_elem_list)->list_tail->next = new;
						(yyvsp[-2].att_elem_list)->list_tail = new;

						(yyval.att_elem_list) = (yyvsp[-2].att_elem_list);
					}
#line 2205 "y.tab.c" /* yacc.c:1652  */
    break;

  case 77:
#line 732 "parser.y" /* yacc.c:1652  */
    {
						AttElemList	   *new;
						new = (AttElemList *)malloc(sizeof(AttElemList));

						new->list_head = (yyvsp[0].att_elem);
						new->list_tail = (yyvsp[0].att_elem);

						(yyval.att_elem_list) = new;
					}
#line 2219 "y.tab.c" /* yacc.c:1652  */
    break;

  case 78:
#line 742 "parser.y" /* yacc.c:1652  */
    {
						(yyvsp[-2].att_elem_list)->list_tail->next = (yyvsp[0].att_elem);
						(yyvsp[-2].att_elem_list)->list_tail = (yyvsp[0].att_elem);

						(yyval.att_elem_list) = (yyvsp[-2].att_elem_list);
					}
#line 2230 "y.tab.c" /* yacc.c:1652  */
    break;

  case 79:
#line 751 "parser.y" /* yacc.c:1652  */
    {
						AttElem	   *new = (AttElem *)malloc(sizeof(AttElem));

						new->attname = (yyvsp[-2].str);
						new->attvalue = (yyvsp[0].str);
						new->next = NULL;

						(yyval.att_elem) = new;
					}
#line 2244 "y.tab.c" /* yacc.c:1652  */
    break;

  case 80:
#line 763 "parser.y" /* yacc.c:1652  */
    {
						SlonDString	ds;
						char	   *namespace;
						char	   *tablename;

						if (lookup_rename((yyvsp[-3].str), (yyvsp[-1].str), &namespace, &tablename) == 1)
						{
							dstring_init(&ds);
							slon_mkquery(&ds, "vacuum analyze %s.%s;",
									(yyvsp[-3].str), (yyvsp[-1].str));
							free((yyvsp[-3].str));
							free((yyvsp[-1].str));
							if (process_simple_sql(dstring_data(&ds)) < 0)
							{
								dstring_free(&ds);
								YYABORT;
							}
							else
								dstring_free(&ds);
						}
						else
						{
							free((yyvsp[-3].str));
							free((yyvsp[-1].str));
						}
					}
#line 2275 "y.tab.c" /* yacc.c:1652  */
    break;

  case 81:
#line 792 "parser.y" /* yacc.c:1652  */
    {
						SlonDString	ds;
						char	   *namespace;
						char	   *tablename;

						if (lookup_rename((yyvsp[-3].str), (yyvsp[-1].str), &namespace, &tablename) == 1)
						{
							dstring_init(&ds);
							slon_mkquery(&ds, "analyze %s.%s;",
									namespace, tablename);
							free((yyvsp[-3].str));
							free((yyvsp[-1].str));
							if (process_simple_sql(dstring_data(&ds)) < 0)
							{
								dstring_free(&ds);
								YYABORT;
							}
							else
								dstring_free(&ds);
						}
						else
						{
							free((yyvsp[-3].str));
							free((yyvsp[-1].str));
						}
					}
#line 2306 "y.tab.c" /* yacc.c:1652  */
    break;

  case 82:
#line 821 "parser.y" /* yacc.c:1652  */
    {
						SlonDString	ds;
						dstring_init(&ds);
						slon_mkquery(&ds, "select %s.%s(%d);",
								(yyvsp[-6].str), (yyvsp[-4].str), (yyvsp[-2].ival));
						free((yyvsp[-6].str));
						free((yyvsp[-4].str));
						if (process_simple_sql(dstring_data(&ds)) < 0)
						{
							dstring_free(&ds);
							YYABORT;
						}
						else
							dstring_free(&ds);
					}
#line 2326 "y.tab.c" /* yacc.c:1652  */
    break;

  case 83:
#line 838 "parser.y" /* yacc.c:1652  */
    {
						char   *ret;
						size_t toklen = yyget_leng();
						ret = malloc(toklen + 1);
						memcpy(ret, yytext, toklen);
						ret[toklen] = '\0';

						(yyval.str) = ret;
					}
#line 2340 "y.tab.c" /* yacc.c:1652  */
    break;

  case 84:
#line 850 "parser.y" /* yacc.c:1652  */
    {
						SlonDString	ds;
						dstring_init(&ds);
						slon_mkquery(&ds, "select %s.%s('%s', '%s', '%s');",
									 (yyvsp[-10].str), (yyvsp[-8].str), (yyvsp[-6].str), (yyvsp[-4].str),(yyvsp[-2].str));
						free((yyvsp[-10].str));
						free((yyvsp[-8].str));
						free((yyvsp[-4].str));
						if (process_simple_sql(dstring_data(&ds)) < 0)
						{
							dstring_free(&ds);
							YYABORT;
						}
						else
							dstring_free(&ds);
					}
#line 2361 "y.tab.c" /* yacc.c:1652  */
    break;

  case 85:
#line 868 "parser.y" /* yacc.c:1652  */
    {
						char   *ret;
						size_t toklen= yyget_leng();
						ret = malloc(toklen + 1);
						memcpy(ret, yytext, toklen);
						ret[toklen] = '\0';

						(yyval.str) = ret;
					}
#line 2375 "y.tab.c" /* yacc.c:1652  */
    break;

  case 86:
#line 880 "parser.y" /* yacc.c:1652  */
    {
						SlonDString	ds;
						dstring_init(&ds);
						slon_mkquery(&ds, "select %s.%s('%s', '%s');",
									 (yyvsp[-8].str), (yyvsp[-6].str), (yyvsp[-4].str), (yyvsp[-2].str));
						free((yyvsp[-8].str));
						free((yyvsp[-6].str));
						free((yyvsp[-4].str));
						free((yyvsp[-2].str));
						if (process_simple_sql(dstring_data(&ds)) < 0)
						{
							dstring_free(&ds);
							YYABORT;
						}
						else
							dstring_free(&ds);
					}
#line 2397 "y.tab.c" /* yacc.c:1652  */
    break;

  case 87:
#line 899 "parser.y" /* yacc.c:1652  */
    {
						char   *ret;
						size_t toklen = yyget_leng();
						ret = malloc(toklen + 1);
						memcpy(ret, yytext, toklen);
						ret[toklen] = '\0';

						(yyval.str) = ret;
					}
#line 2411 "y.tab.c" /* yacc.c:1652  */
    break;

  case 88:
#line 911 "parser.y" /* yacc.c:1652  */
    {
						SlonDString	ds;
						int			c;
						int			nstmts;
						int			i;

						if (process_simple_sql("-- DDL_SCRIPT") < 0)
							YYABORT;

						dstring_init(&ds);
						while ((c = scan_yyinput()) != EOF)
						{
							dstring_addchar(&ds, c);
						}
						dstring_terminate(&ds);

						if ((nstmts = scan_for_statements(dstring_data(&ds))) < 0)
						{
							errlog(LOG_ERROR, "scan_for_statements failed\n");
							dstring_free(&ds);
							YYABORT;
						}

						for (i = 0; i < nstmts; i++)
						{
							int start = (i == 0) ? 0 : STMTS[i - 1] + 1;
							int end = STMTS[i];

							dstring_data(&ds)[end] = '\0';

							if (process_simple_sql(dstring_data(&ds) + start) < 0)
							{
								dstring_free(&ds);
								YYABORT;
							}
						}
						dstring_free(&ds);

						/*
						 * Just in case
						 */
						process_end_transaction("rollback;");

						YYACCEPT;
					}
#line 2461 "y.tab.c" /* yacc.c:1652  */
    break;

  case 91:
#line 963 "parser.y" /* yacc.c:1652  */
    {
						char   *str;
						size_t toklen = yyget_leng();
						str = malloc(toklen + 1);
						memcpy(str, yytext, toklen);
						str[toklen] = '\0';

						if (process_simple_sql(str) < 0)
						{
							free(str);
							YYABORT;
						}
						else
							free(str);
					}
#line 2481 "y.tab.c" /* yacc.c:1652  */
    break;

  case 92:
#line 981 "parser.y" /* yacc.c:1652  */
    {
						(yyval.ival) = strtol(yytext, NULL, 10);
					}
#line 2489 "y.tab.c" /* yacc.c:1652  */
    break;

  case 93:
#line 987 "parser.y" /* yacc.c:1652  */
    {
						char   *ret;
						size_t toklen = yyget_leng();
						ret = malloc(toklen + 1);
						memcpy(ret, yytext, toklen);
						ret[toklen] = '\0';

						(yyval.str) = ret;
					}
#line 2503 "y.tab.c" /* yacc.c:1652  */
    break;

  case 94:
#line 997 "parser.y" /* yacc.c:1652  */
    {
						char   *ret;
						size_t toklen = yyget_leng();
						ret = malloc(toklen + 1);
						memcpy(ret, yytext, toklen);
						ret[toklen] = '\0';

						(yyval.str) = ret;
					}
#line 2517 "y.tab.c" /* yacc.c:1652  */
    break;

  case 128:
#line 1043 "parser.y" /* yacc.c:1652  */
    {
						(yyval.str) = (yyvsp[0].str);
					}
#line 2525 "y.tab.c" /* yacc.c:1652  */
    break;

  case 129:
#line 1047 "parser.y" /* yacc.c:1652  */
    {
						char   *ret;

						dstring_append((yyvsp[-1].dstring), (yyvsp[0].str));
						dstring_terminate((yyvsp[-1].dstring));
						free((yyvsp[0].str));

						ret = strdup(dstring_data((yyvsp[-1].dstring)));
						dstring_free((yyvsp[-1].dstring));
						
						(yyval.str) = ret;
					}
#line 2542 "y.tab.c" /* yacc.c:1652  */
    break;

  case 130:
#line 1060 "parser.y" /* yacc.c:1652  */
    {
						(yyval.str) = NULL;
					}
#line 2550 "y.tab.c" /* yacc.c:1652  */
    break;

  case 131:
#line 1066 "parser.y" /* yacc.c:1652  */
    {
						SlonDString	   *dsp = (SlonDString *)malloc(sizeof(SlonDString));

						dstring_init(dsp);
						dstring_append(dsp, (yyvsp[0].str));
						free((yyvsp[0].str));

						(yyval.dstring) = dsp;
					}
#line 2564 "y.tab.c" /* yacc.c:1652  */
    break;

  case 132:
#line 1076 "parser.y" /* yacc.c:1652  */
    {
						dstring_append((yyvsp[-1].dstring), (yyvsp[0].str));
						free((yyvsp[0].str));

						(yyval.dstring) = (yyvsp[-1].dstring);
					}
#line 2575 "y.tab.c" /* yacc.c:1652  */
    break;

  case 133:
#line 1085 "parser.y" /* yacc.c:1652  */
    {
						(yyval.str) = strdup(yychunk);
					}
#line 2583 "y.tab.c" /* yacc.c:1652  */
    break;

  case 134:
#line 1090 "parser.y" /* yacc.c:1652  */
    {
						(yyval.str) = strdup(yychunk);
					}
#line 2591 "y.tab.c" /* yacc.c:1652  */
    break;


#line 2595 "y.tab.c" /* yacc.c:1652  */
      default: break;
    }
  /* User semantic actions sometimes alter yychar, and that requires
     that yytoken be updated with the new translation.  We take the
     approach of translating immediately before every use of yytoken.
     One alternative is translating here after every semantic action,
     but that translation would be missed if the semantic action invokes
     YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
     if it invokes YYBACKUP.  In the case of YYABORT or YYACCEPT, an
     incorrect destructor might then be invoked immediately.  In the
     case of YYERROR or YYBACKUP, subsequent parser actions might lead
     to an incorrect destructor call or verbose syntax error message
     before the lookahead is translated.  */
  YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);

  YYPOPSTACK (yylen);
  yylen = 0;
  YY_STACK_PRINT (yyss, yyssp);

  *++yyvsp = yyval;

  /* Now 'shift' the result of the reduction.  Determine what state
     that goes to, based on the state we popped back to and the rule
     number reduced by.  */
  {
    const int yylhs = yyr1[yyn] - YYNTOKENS;
    const int yyi = yypgoto[yylhs] + *yyssp;
    yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
               ? yytable[yyi]
               : yydefgoto[yylhs]);
  }

  goto yynewstate;


/*--------------------------------------.
| yyerrlab -- here on detecting error.  |
`--------------------------------------*/
yyerrlab:
  /* Make sure we have latest lookahead translation.  See comments at
     user semantic actions for why this is necessary.  */
  yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);

  /* If not already recovering from an error, report this error.  */
  if (!yyerrstatus)
    {
      ++yynerrs;
#if ! YYERROR_VERBOSE
      yyerror (YY_("syntax error"));
#else
# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
                                        yyssp, yytoken)
      {
        char const *yymsgp = YY_("syntax error");
        int yysyntax_error_status;
        yysyntax_error_status = YYSYNTAX_ERROR;
        if (yysyntax_error_status == 0)
          yymsgp = yymsg;
        else if (yysyntax_error_status == 1)
          {
            if (yymsg != yymsgbuf)
              YYSTACK_FREE (yymsg);
            yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
            if (!yymsg)
              {
                yymsg = yymsgbuf;
                yymsg_alloc = sizeof yymsgbuf;
                yysyntax_error_status = 2;
              }
            else
              {
                yysyntax_error_status = YYSYNTAX_ERROR;
                yymsgp = yymsg;
              }
          }
        yyerror (yymsgp);
        if (yysyntax_error_status == 2)
          goto yyexhaustedlab;
      }
# undef YYSYNTAX_ERROR
#endif
    }



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

      if (yychar <= YYEOF)
        {
          /* Return failure if at end of input.  */
          if (yychar == YYEOF)
            YYABORT;
        }
      else
        {
          yydestruct ("Error: discarding",
                      yytoken, &yylval);
          yychar = YYEMPTY;
        }
    }

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


/*---------------------------------------------------.
| yyerrorlab -- error raised explicitly by YYERROR.  |
`---------------------------------------------------*/
yyerrorlab:
  /* Pacify compilers when the user code never invokes YYERROR and the
     label yyerrorlab therefore never appears in user code.  */
  if (0)
    YYERROR;

  /* Do not reclaim the symbols of the rule whose action triggered
     this YYERROR.  */
  YYPOPSTACK (yylen);
  yylen = 0;
  YY_STACK_PRINT (yyss, yyssp);
  yystate = *yyssp;
  goto yyerrlab1;


/*-------------------------------------------------------------.
| yyerrlab1 -- common code for both syntax error and YYERROR.  |
`-------------------------------------------------------------*/
yyerrlab1:
  yyerrstatus = 3;      /* Each real token shifted decrements this.  */

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

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


      yydestruct ("Error: popping",
                  yystos[yystate], yyvsp);
      YYPOPSTACK (1);
      yystate = *yyssp;
      YY_STACK_PRINT (yyss, yyssp);
    }

  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  *++yyvsp = yylval;
  YY_IGNORE_MAYBE_UNINITIALIZED_END


  /* Shift the error token.  */
  YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);

  yystate = yyn;
  goto yynewstate;


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


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


#if !defined yyoverflow || YYERROR_VERBOSE
/*-------------------------------------------------.
| yyexhaustedlab -- memory exhaustion comes here.  |
`-------------------------------------------------*/
yyexhaustedlab:
  yyerror (YY_("memory exhausted"));
  yyresult = 2;
  /* Fall through.  */
#endif


/*-----------------------------------------------------.
| yyreturn -- parsing is finished, return the result.  |
`-----------------------------------------------------*/
yyreturn:
  if (yychar != YYEMPTY)
    {
      /* Make sure we have latest lookahead translation.  See comments at
         user semantic actions for why this is necessary.  */
      yytoken = YYTRANSLATE (yychar);
      yydestruct ("Cleanup: discarding lookahead",
                  yytoken, &yylval);
    }
  /* Do not reclaim the symbols of the rule whose action triggered
     this YYABORT or YYACCEPT.  */
  YYPOPSTACK (yylen);
  YY_STACK_PRINT (yyss, yyssp);
  while (yyssp != yyss)
    {
      yydestruct ("Cleanup: popping",
                  yystos[*yyssp], yyvsp);
      YYPOPSTACK (1);
    }
#ifndef yyoverflow
  if (yyss != yyssa)
    YYSTACK_FREE (yyss);
#endif
#if YYERROR_VERBOSE
  if (yymsg != yymsgbuf)
    YYSTACK_FREE (yymsg);
#endif
  return yyresult;
}
#line 1094 "parser.y" /* yacc.c:1918  */



void
yyerror(const char *msg)
{
	errlog(LOG_ERROR, "%s:%d: ERROR %s at or near %s\n", current_file,
				yylineno, msg, yytext);
	parse_errors++;
}
void

parse_error(const char *msg)
{
	errlog(LOG_ERROR, "%s:%d: ERROR %s\n", current_file,
				yylineno, msg);
	parse_errors++;
}




/*
 * Local Variables:
 *  tab-width: 4
 *  c-indent-level: 4
 *  c-basic-offset: 4
 * End:
 */
