#line 2 "psqlscan.c"
/* A lexical scanner generated by flex */

/* Scanner skeleton version:
 * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.91 96/09/10 16:58:48 vern Exp $
 * $FreeBSD: src/usr.bin/lex/flex.skl,v 1.8 2004/01/06 19:03:44 nectar Exp $
 */

#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5

#include <stdio.h>


/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
#ifdef c_plusplus
#ifndef __cplusplus
#define __cplusplus
#endif
#endif


#ifdef __cplusplus

#include <stdlib.h>
#include <unistd.h>

/* Use prototypes in function declarations. */
#define YY_USE_PROTOS

/* The "const" storage-class-modifier is valid. */
#define YY_USE_CONST

#else	/* ! __cplusplus */

#if __STDC__

#define YY_USE_PROTOS
#define YY_USE_CONST

#endif	/* __STDC__ */
#endif	/* ! __cplusplus */

#ifdef __TURBOC__
 #pragma warn -rch
 #pragma warn -use
#include <io.h>
#include <stdlib.h>
#define YY_USE_CONST
#define YY_USE_PROTOS
#endif

#ifdef YY_USE_CONST
#define yyconst const
#else
#define yyconst
#endif


#ifdef YY_USE_PROTOS
#define YY_PROTO(proto) proto
#else
#define YY_PROTO(proto) ()
#endif

/* Returned upon end-of-file. */
#define YY_NULL 0

/* Promotes a possibly negative, possibly signed char to an unsigned
 * integer for use as an array index.  If the signed char is negative,
 * we want to instead treat it as an 8-bit unsigned char, hence the
 * double cast.
 */
#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)

/* Enter a start condition.  This macro really ought to take a parameter,
 * but we do it the disgusting crufty way forced on us by the ()-less
 * definition of BEGIN.
 */
#define BEGIN yy_start = 1 + 2 *

/* Translate the current start state into a value that can be later handed
 * to BEGIN to return to the state.  The YYSTATE alias is for lex
 * compatibility.
 */
#define YY_START ((yy_start - 1) / 2)
#define YYSTATE YY_START

/* Action number for EOF rule of a given start state. */
#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)

/* Special action meaning "start processing a new file". */
#define YY_NEW_FILE yyrestart( yyin )

#define YY_END_OF_BUFFER_CHAR 0

/* Size of default input buffer. */
#define YY_BUF_SIZE 16384

typedef struct yy_buffer_state *YY_BUFFER_STATE;

extern int yyleng;
extern FILE *yyin, *yyout;

#define EOB_ACT_CONTINUE_SCAN 0
#define EOB_ACT_END_OF_FILE 1
#define EOB_ACT_LAST_MATCH 2

/* The funky do-while in the following #define is used to turn the definition
 * int a single C statement (which needs a semi-colon terminator).  This
 * avoids problems with code like:
 *
 * 	if ( condition_holds )
 *		yyless( 5 );
 *	else
 *		do_something_else();
 *
 * Prior to using the do-while the compiler would get upset at the
 * "else" because it interpreted the "if" statement as being all
 * done when it reached the ';' after the yyless() call.
 */

/* Return all but the first 'n' matched characters back to the input stream. */

#define yyless(n) \
	do \
		{ \
		/* Undo effects of setting up yytext. */ \
		*yy_cp = yy_hold_char; \
		YY_RESTORE_YY_MORE_OFFSET \
		yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \
		YY_DO_BEFORE_ACTION; /* set up yytext again */ \
		} \
	while ( 0 )

#define unput(c) yyunput( c, yytext_ptr )

/* The following is because we cannot portably get our hands on size_t
 * (without autoconf's help, which isn't available because we want
 * flex-generated scanners to compile on their own).
 */
typedef unsigned int yy_size_t;


struct yy_buffer_state
	{
	FILE *yy_input_file;

	char *yy_ch_buf;		/* input buffer */
	char *yy_buf_pos;		/* current position in input buffer */

	/* Size of input buffer in bytes, not including room for EOB
	 * characters.
	 */
	yy_size_t yy_buf_size;

	/* Number of characters read into yy_ch_buf, not including EOB
	 * characters.
	 */
	int yy_n_chars;

	/* Whether we "own" the buffer - i.e., we know we created it,
	 * and can realloc() it to grow it, and should free() it to
	 * delete it.
	 */
	int yy_is_our_buffer;

	/* Whether this is an "interactive" input source; if so, and
	 * if we're using stdio for input, then we want to use getc()
	 * instead of fread(), to make sure we stop fetching input after
	 * each newline.
	 */
	int yy_is_interactive;

	/* Whether we're considered to be at the beginning of a line.
	 * If so, '^' rules will be active on the next match, otherwise
	 * not.
	 */
	int yy_at_bol;

	/* Whether to try to fill the input buffer when we reach the
	 * end of it.
	 */
	int yy_fill_buffer;

	int yy_buffer_status;
#define YY_BUFFER_NEW 0
#define YY_BUFFER_NORMAL 1
	/* When an EOF's been seen but there's still some text to process
	 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
	 * shouldn't try reading from the input source any more.  We might
	 * still have a bunch of tokens to match, though, because of
	 * possible backing-up.
	 *
	 * When we actually see the EOF, we change the status to "new"
	 * (via yyrestart()), so that the user can continue scanning by
	 * just pointing yyin at a new input file.
	 */
#define YY_BUFFER_EOF_PENDING 2
	};

static YY_BUFFER_STATE yy_current_buffer = 0;

/* We provide macros for accessing buffer states in case in the
 * future we want to put the buffer states in a more general
 * "scanner state".
 */
#define YY_CURRENT_BUFFER yy_current_buffer


/* yy_hold_char holds the character lost when yytext is formed. */
static char yy_hold_char;

static int yy_n_chars;		/* number of characters read into yy_ch_buf */


int yyleng;

/* Points to current character in buffer. */
static char *yy_c_buf_p = (char *) 0;
static int yy_init = 1;		/* whether we need to initialize */
static int yy_start = 0;	/* start state number */

/* Flag which is used to allow yywrap()'s to do buffer switches
 * instead of setting up a fresh yyin.  A bit of a hack ...
 */
static int yy_did_buffer_switch_on_eof;

void yyrestart YY_PROTO(( FILE *input_file ));

void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
void yy_load_buffer_state YY_PROTO(( void ));
YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));
#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer )

YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size ));
YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str ));
YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len ));

static void *yy_flex_alloc YY_PROTO(( yy_size_t ));
static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t ));
static void yy_flex_free YY_PROTO(( void * ));

#define yy_new_buffer yy_create_buffer

#define yy_set_interactive(is_interactive) \
	{ \
	if ( ! yy_current_buffer ) \
		yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
	yy_current_buffer->yy_is_interactive = is_interactive; \
	}

#define yy_set_bol(at_bol) \
	{ \
	if ( ! yy_current_buffer ) \
		yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
	yy_current_buffer->yy_at_bol = at_bol; \
	}

#define YY_AT_BOL() (yy_current_buffer->yy_at_bol)


#define yywrap() 1
#define YY_SKIP_YYWRAP
typedef unsigned char YY_CHAR;
FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
typedef int yy_state_type;
extern char *yytext;
#define yytext_ptr yytext
static yyconst short yy_nxt[][38] =
    {
    {
        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
        0,    0,    0,    0,    0,    0,    0,    0
    },

    {
       33,   34,   35,   36,   35,   37,   38,   39,   40,   41,
       42,   43,   40,   40,   44,   45,   46,   47,   48,   48,
       49,   50,   51,   52,   53,   51,   54,   55,   56,   37,
       52,   51,   54,   51,   51,   55,   37,   51
    },

    {
       33,   34,   35,   36,   35,   37,   38,   39,   40,   41,
       42,   43,   40,   40,   44,   45,   46,   47,   48,   48,

       49,   50,   51,   52,   53,   51,   54,   55,   56,   37,
       52,   51,   54,   51,   51,   55,   37,   51
    },

    {
       33,   57,   57,   57,   57,   57,   57,   57,   57,   58,
       57,   57,   57,   57,   57,   57,   57,   57,   57,   57,
       57,   57,   57,   57,   57,   57,   57,   57,   57,   57,
       57,   57,   57,   57,   57,   57,   57,   57
    },

    {
       33,   57,   57,   57,   57,   57,   57,   57,   57,   58,
       57,   57,   57,   57,   57,   57,   57,   57,   57,   57,
       57,   57,   57,   57,   57,   57,   57,   57,   57,   57,
       57,   57,   57,   57,   57,   57,   57,   57

    },

    {
       33,   59,   59,   59,   59,   60,   59,   59,   60,   59,
       59,   59,   61,   60,   59,   60,   59,   62,   59,   59,
       59,   59,   59,   59,   59,   59,   59,   59,   59,   60,
       59,   59,   59,   59,   59,   59,   60,   59
    },

    {
       33,   59,   59,   59,   59,   60,   59,   59,   60,   59,
       59,   59,   61,   60,   59,   60,   59,   62,   59,   59,
       59,   59,   59,   59,   59,   59,   59,   59,   59,   60,
       59,   59,   59,   59,   59,   59,   60,   59
    },

    {
       33,   63,   63,   63,   63,   63,   64,   63,   63,   63,
       63,   63,   63,   63,   63,   63,   63,   63,   63,   63,

       63,   63,   63,   63,   63,   63,   63,   63,   63,   63,
       63,   63,   63,   63,   63,   63,   63,   63
    },

    {
       33,   63,   63,   63,   63,   63,   64,   63,   63,   63,
       63,   63,   63,   63,   63,   63,   63,   63,   63,   63,
       63,   63,   63,   63,   63,   63,   63,   63,   63,   63,
       63,   63,   63,   63,   63,   63,   63,   63
    },

    {
       33,   65,   65,   65,   65,   65,   65,   65,   65,   66,
       65,   65,   65,   65,   65,   65,   65,   65,   65,   65,
       65,   65,   65,   65,   65,   65,   65,   65,   65,   65,
       65,   65,   65,   65,   65,   65,   65,   65

    },

    {
       33,   65,   65,   65,   65,   65,   65,   65,   65,   66,
       65,   65,   65,   65,   65,   65,   65,   65,   65,   65,
       65,   65,   65,   65,   65,   65,   65,   65,   65,   65,
       65,   65,   65,   65,   65,   65,   65,   65
    },

    {
       33,   67,   67,   68,   67,   67,   67,   67,   67,   69,
       67,   67,   67,   67,   67,   67,   67,   67,   67,   67,
       67,   67,   67,   67,   67,   67,   67,   67,   70,   67,
       67,   67,   67,   67,   67,   67,   67,   67
    },

    {
       33,   67,   67,   68,   67,   67,   67,   67,   67,   69,
       67,   67,   67,   67,   67,   67,   67,   67,   67,   67,

       67,   67,   67,   67,   67,   67,   67,   67,   70,   67,
       67,   67,   67,   67,   67,   67,   67,   67
    },

    {
       33,   71,   71,   71,   71,   71,   71,   71,   71,   72,
       71,   71,   71,   71,   71,   71,   71,   71,   71,   71,
       71,   71,   71,   71,   71,   71,   71,   71,   71,   71,
       71,   71,   71,   71,   71,   71,   71,   71
    },

    {
       33,   71,   71,   71,   71,   71,   71,   71,   71,   72,
       71,   71,   71,   71,   71,   71,   71,   71,   71,   71,
       71,   71,   71,   71,   71,   71,   71,   71,   71,   71,
       71,   71,   71,   71,   71,   71,   71,   71

    },

    {
       33,   73,   73,   74,   73,   73,   73,   75,   73,   73,
       73,   73,   73,   73,   73,   73,   73,   73,   73,   73,
       73,   73,   73,   73,   73,   73,   73,   73,   73,   73,
       73,   73,   73,   73,   73,   73,   73,   73
    },

    {
       33,   73,   73,   74,   73,   73,   73,   75,   73,   73,
       73,   73,   73,   73,   73,   73,   73,   73,   73,   73,
       73,   73,   73,   73,   73,   73,   73,   73,   73,   73,
       73,   73,   73,   73,   73,   73,   73,   73
    },

    {
       33,   76,   77,   78,   77,   76,   76,   76,   76,   76,
       76,   76,   76,   76,   76,   76,   76,   76,   76,   76,

       76,   76,   76,   76,   76,   76,   76,   76,   77,   76,
       76,   76,   76,   76,   76,   76,   76,   76
    },

    {
       33,   76,   77,   78,   77,   76,   76,   76,   76,   76,
       76,   76,   76,   76,   76,   76,   76,   76,   76,   76,
       76,   76,   76,   76,   76,   76,   76,   76,   77,   76,
       76,   76,   76,   76,   76,   76,   76,   76
    },

    {
       33,   79,   80,   81,   80,   79,   82,   79,   79,   83,
       79,   79,   79,   79,   79,   79,   79,   79,   79,   79,
       84,   79,   79,   79,   79,   79,   79,   79,   85,   86,
       79,   79,   79,   79,   79,   79,   87,   79

    },

    {
       33,   79,   80,   81,   80,   79,   82,   79,   79,   83,
       79,   79,   79,   79,   79,   79,   79,   79,   79,   79,
       84,   79,   79,   79,   79,   79,   79,   79,   85,   86,
       79,   79,   79,   79,   79,   79,   87,   79
    },

    {
       33,   88,   88,   88,   88,   88,   88,   88,   88,   89,
       88,   88,   88,   88,   88,   88,   88,   88,   88,   88,
       88,   88,   88,   88,   88,   88,   88,   88,   90,   88,
       88,   88,   88,   88,   88,   88,   88,   88
    },

    {
       33,   88,   88,   88,   88,   88,   88,   88,   88,   89,
       88,   88,   88,   88,   88,   88,   88,   88,   88,   88,

       88,   88,   88,   88,   88,   88,   88,   88,   90,   88,
       88,   88,   88,   88,   88,   88,   88,   88
    },

    {
       33,   91,   91,   91,   91,   91,   91,   91,   91,   91,
       91,   91,   91,   91,   91,   91,   91,   91,   91,   91,
       91,   91,   91,   91,   91,   91,   91,   91,   91,   92,
       91,   91,   91,   91,   91,   91,   91,   91
    },

    {
       33,   91,   91,   91,   91,   91,   91,   91,   91,   91,
       91,   91,   91,   91,   91,   91,   91,   91,   91,   91,
       91,   91,   91,   91,   91,   91,   91,   91,   91,   92,
       91,   91,   91,   91,   91,   91,   91,   91

    },

    {
       33,   93,   94,   95,   94,   93,   96,   93,   93,   93,
       93,   93,   93,   93,   93,   93,   93,   93,   93,   93,
       93,   93,   93,   93,   93,   93,   93,   93,   97,   93,
       93,   93,   93,   93,   93,   93,   93,   93
    },

    {
       33,   93,   94,   95,   94,   93,   96,   93,   93,   93,
       93,   93,   93,   93,   93,   93,   93,   93,   93,   93,
       93,   93,   93,   93,   93,   93,   93,   93,   97,   93,
       93,   93,   93,   93,   93,   93,   93,   93
    },

    {
       33,   98,   98,   98,   98,   98,   99,   98,   98,   98,
       98,   98,   98,   98,   98,   98,   98,   98,   98,   98,

       98,   98,   98,   98,   98,   98,   98,   98,   98,   98,
       98,   98,   98,   98,   98,   98,   98,   98
    },

    {
       33,   98,   98,   98,   98,   98,   99,   98,   98,   98,
       98,   98,   98,   98,   98,   98,   98,   98,   98,   98,
       98,   98,   98,   98,   98,   98,   98,   98,   98,   98,
       98,   98,   98,   98,   98,   98,   98,   98
    },

    {
       33,  100,  101,  102,  101,  100,  100,  100,  100,  100,
      100,  100,  100,  100,  100,  100,  100,  100,  100,  100,
      100,  100,  100,  100,  100,  100,  100,  100,  100,  100,
      100,  100,  100,  100,  100,  100,  100,  100

    },

    {
       33,  100,  101,  102,  101,  100,  100,  100,  100,  100,
      100,  100,  100,  100,  100,  100,  100,  100,  100,  100,
      100,  100,  100,  100,  100,  100,  100,  100,  100,  100,
      100,  100,  100,  100,  100,  100,  100,  100
    },

    {
       33,  103,  103,  103,  103,  103,  103,  103,  103,  103,
      103,  103,  103,  103,  103,  103,  103,  103,  103,  103,
      103,  103,  103,  103,  103,  103,  103,  103,  104,  103,
      103,  103,  103,  103,  103,  103,  103,  103
    },

    {
       33,  103,  103,  103,  103,  103,  103,  103,  103,  103,
      103,  103,  103,  103,  103,  103,  103,  103,  103,  103,

      103,  103,  103,  103,  103,  103,  103,  103,  104,  103,
      103,  103,  103,  103,  103,  103,  103,  103
    },

    {
      -33,  -33,  -33,  -33,  -33,  -33,  -33,  -33,  -33,  -33,
      -33,  -33,  -33,  -33,  -33,  -33,  -33,  -33,  -33,  -33,
      -33,  -33,  -33,  -33,  -33,  -33,  -33,  -33,  -33,  -33,
      -33,  -33,  -33,  -33,  -33,  -33,  -33,  -33
    },

    {
       33,  -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,
      -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,
      -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,
      -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34

    },

    {
       33,  -35,  105,  105,  105,  -35,  -35,  -35,  -35,  -35,
      -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35,
      -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35,
      -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35
    },

    {
       33,  -36,  105,  105,  105,  -36,  -36,  -36,  -36,  -36,
      -36,  -36,  -36,  -36,  -36,  -36,  -36,  -36,  -36,  -36,
      -36,  -36,  -36,  -36,  -36,  -36,  -36,  -36,  -36,  -36,
      -36,  -36,  -36,  -36,  -36,  -36,  -36,  -36
    },

    {
       33,  -37,  -37,  -37,  -37,  106,  -37,  -37,  106,  -37,
      -37,  -37,  106,  106,  -37,  106,  -37,  106,  -37,  -37,

      -37,  -37,  -37,  -37,  -37,  -37,  -37,  -37,  -37,  106,
      -37,  -37,  -37,  -37,  -37,  -37,  106,  -37
    },

    {
       33,  -38,  -38,  -38,  -38,  -38,  -38,  -38,  -38,  -38,
      -38,  -38,  -38,  -38,  -38,  -38,  -38,  -38,  -38,  -38,
      -38,  -38,  -38,  -38,  -38,  -38,  -38,  -38,  -38,  -38,
      -38,  -38,  -38,  -38,  -38,  -38,  -38,  -38
    },

    {
       33,  -39,  -39,  -39,  -39,  -39,  -39,  107,  -39,  -39,
      -39,  -39,  -39,  -39,  -39,  -39,  -39,  -39,  108,  108,
      -39,  -39,  109,  109,  109,  109,  109,  109,  -39,  -39,
      109,  109,  109,  109,  109,  109,  -39,  109

    },

    {
       33,  -40,  -40,  -40,  -40,  106,  -40,  -40,  106,  -40,
      -40,  -40,  106,  106,  -40,  106,  -40,  106,  -40,  -40,
      -40,  -40,  -40,  -40,  -40,  -40,  -40,  -40,  -40,  106,
      -40,  -40,  -40,  -40,  -40,  -40,  106,  -40
    },

    {
       33,  -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41,
      -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41,
      -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41,
      -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41
    },

    {
       33,  -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,
      -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,

      -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,
      -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42
    },

    {
       33,  -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,
      -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,
      -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,
      -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43
    },

    {
       33,  -44,  -44,  -44,  -44,  -44,  -44,  -44,  -44,  -44,
      -44,  -44,  -44,  -44,  -44,  -44,  -44,  -44,  -44,  -44,
      -44,  -44,  -44,  -44,  -44,  -44,  -44,  -44,  -44,  -44,
      -44,  -44,  -44,  -44,  -44,  -44,  -44,  -44

    },

    {
       33,  -45,  -45,  -45,  -45,  106,  -45,  -45,  106,  -45,
      -45,  -45,  106,  106,  -45,  110,  -45,  106,  -45,  -45,
      -45,  -45,  -45,  -45,  -45,  -45,  -45,  -45,  -45,  106,
      -45,  -45,  -45,  -45,  -45,  -45,  106,  -45
    },

    {
       33,  -46,  -46,  -46,  -46,  -46,  -46,  -46,  -46,  -46,
      -46,  -46,  -46,  -46,  -46,  -46,  -46,  -46,  111,  111,
      -46,  -46,  -46,  -46,  -46,  -46,  -46,  -46,  -46,  -46,
      -46,  -46,  -46,  -46,  -46,  -46,  -46,  -46
    },

    {
       33,  -47,  -47,  -47,  -47,  106,  -47,  -47,  106,  -47,
      -47,  -47,  112,  106,  -47,  106,  -47,  106,  -47,  -47,

      -47,  -47,  -47,  -47,  -47,  -47,  -47,  -47,  -47,  106,
      -47,  -47,  -47,  -47,  -47,  -47,  106,  -47
    },

    {
       33,  -48,  -48,  -48,  -48,  -48,  -48,  -48,  -48,  -48,
      -48,  -48,  -48,  -48,  -48,  -48,  113,  -48,  114,  114,
      -48,  -48,  -48,  -48,  115,  -48,  -48,  -48,  -48,  -48,
      -48,  -48,  -48,  -48,  -48,  -48,  -48,  -48
    },

    {
       33,  -49,  -49,  -49,  -49,  -49,  -49,  -49,  -49,  -49,
      -49,  -49,  -49,  -49,  -49,  -49,  -49,  -49,  116,  116,
      117,  -49,  116,  116,  116,  116,  116,  116,  -49,  -49,
      116,  116,  116,  116,  116,  116,  -49,  -49

    },

    {
       33,  -50,  -50,  -50,  -50,  -50,  -50,  -50,  -50,  -50,
      -50,  -50,  -50,  -50,  -50,  -50,  -50,  -50,  -50,  -50,
      -50,  -50,  -50,  -50,  -50,  -50,  -50,  -50,  -50,  -50,
      -50,  -50,  -50,  -50,  -50,  -50,  -50,  -50
    },

    {
       33,  -51,  -51,  -51,  -51,  -51,  -51,  118,  -51,  -51,
      -51,  -51,  -51,  -51,  -51,  -51,  -51,  -51,  118,  118,
      -51,  -51,  118,  118,  118,  118,  118,  118,  -51,  -51,
      118,  118,  118,  118,  118,  118,  -51,  118
    },

    {
       33,  -52,  -52,  -52,  -52,  -52,  -52,  118,  -52,  119,
      -52,  -52,  -52,  -52,  -52,  -52,  -52,  -52,  118,  118,

      -52,  -52,  118,  118,  118,  118,  118,  118,  -52,  -52,
      118,  118,  118,  118,  118,  118,  -52,  118
    },

    {
       33,  -53,  -53,  -53,  -53,  -53,  -53,  118,  -53,  120,
      -53,  -53,  -53,  -53,  -53,  -53,  -53,  -53,  118,  118,
      -53,  -53,  118,  118,  118,  118,  118,  118,  -53,  -53,
      118,  118,  118,  118,  118,  118,  -53,  118
    },

    {
       33,  -54,  -54,  -54,  -54,  -54,  -54,  118,  -54,  121,
      -54,  -54,  -54,  -54,  -54,  -54,  -54,  -54,  118,  118,
      -54,  -54,  118,  118,  118,  118,  118,  118,  -54,  -54,
      118,  118,  118,  118,  118,  118,  -54,  118

    },

    {
       33,  -55,  -55,  -55,  -55,  -55,  -55,  118,  -55,  122,
      -55,  -55,  -55,  -55,  -55,  -55,  -55,  -55,  118,  118,
      -55,  -55,  118,  118,  118,  118,  118,  118,  -55,  -55,
      118,  118,  118,  118,  118,  118,  -55,  118
    },

    {
       33,  -56,  -56,  -56,  -56,  -56,  -56,  -56,  -56,  -56,
      -56,  -56,  -56,  -56,  -56,  -56,  -56,  -56,  -56,  -56,
      123,  123,  -56,  -56,  -56,  -56,  -56,  -56,  -56,  -56,
      -56,  -56,  -56,  -56,  -56,  -56,  -56,  -56
    },

    {
       33,  124,  124,  124,  124,  124,  124,  124,  124,  -57,
      124,  124,  124,  124,  124,  124,  124,  124,  124,  124,

      124,  124,  124,  124,  124,  124,  124,  124,  124,  124,
      124,  124,  124,  124,  124,  124,  124,  124
    },

    {
       33,  -58,  125,  126,  126,  -58,  -58,  -58,  -58,  -58,
      -58,  -58,  -58,  -58,  -58,  127,  -58,  -58,  -58,  -58,
      -58,  -58,  -58,  -58,  -58,  -58,  -58,  -58,  -58,  -58,
      -58,  -58,  -58,  -58,  -58,  -58,  -58,  -58
    },

    {
       33,  128,  128,  128,  128,  128,  128,  128,  128,  128,
      128,  128,  -59,  128,  128,  128,  128,  -59,  128,  128,
      128,  128,  128,  128,  128,  128,  128,  128,  128,  128,
      128,  128,  128,  128,  128,  128,  128,  128

    },

    {
       33,  128,  128,  128,  128,  128,  128,  128,  128,  128,
      128,  128,  -60,  128,  128,  128,  128,  -60,  128,  128,
      128,  128,  128,  128,  128,  128,  128,  128,  128,  128,
      128,  128,  128,  128,  128,  128,  128,  128
    },

    {
       33,  -61,  -61,  -61,  -61,  -61,  -61,  -61,  -61,  -61,
      -61,  -61,  129,  -61,  -61,  -61,  -61,  130,  -61,  -61,
      -61,  -61,  -61,  -61,  -61,  -61,  -61,  -61,  -61,  -61,
      -61,  -61,  -61,  -61,  -61,  -61,  -61,  -61
    },

    {
       33,  -62,  -62,  -62,  -62,  -62,  -62,  -62,  -62,  -62,
      -62,  -62,  131,  -62,  -62,  -62,  -62,  -62,  -62,  -62,

      -62,  -62,  -62,  -62,  -62,  -62,  -62,  -62,  -62,  -62,
      -62,  -62,  -62,  -62,  -62,  -62,  -62,  -62
    },

    {
       33,  132,  132,  132,  132,  132,  -63,  132,  132,  132,
      132,  132,  132,  132,  132,  132,  132,  132,  132,  132,
      132,  132,  132,  132,  132,  132,  132,  132,  132,  132,
      132,  132,  132,  132,  132,  132,  132,  132
    },

    {
       33,  -64,  -64,  -64,  -64,  -64,  133,  -64,  -64,  -64,
      -64,  -64,  -64,  -64,  -64,  -64,  -64,  -64,  -64,  -64,
      -64,  -64,  -64,  -64,  -64,  -64,  -64,  -64,  -64,  -64,
      -64,  -64,  -64,  -64,  -64,  -64,  -64,  -64

    },

    {
       33,  134,  134,  134,  134,  134,  134,  134,  134,  -65,
      134,  134,  134,  134,  134,  134,  134,  134,  134,  134,
      134,  134,  134,  134,  134,  134,  134,  134,  134,  134,
      134,  134,  134,  134,  134,  134,  134,  134
    },

    {
       33,  -66,  135,  136,  136,  -66,  -66,  -66,  -66,  -66,
      -66,  -66,  -66,  -66,  -66,  137,  -66,  -66,  -66,  -66,
      -66,  -66,  -66,  -66,  -66,  -66,  -66,  -66,  -66,  -66,
      -66,  -66,  -66,  -66,  -66,  -66,  -66,  -66
    },

    {
       33,  138,  138,  138,  138,  138,  138,  138,  138,  -67,
      138,  138,  138,  138,  138,  138,  138,  138,  138,  138,

      138,  138,  138,  138,  138,  138,  138,  138,  -67,  138,
      138,  138,  138,  138,  138,  138,  138,  138
    },

    {
       33,  138,  138,  138,  138,  138,  138,  138,  138,  -68,
      138,  138,  138,  138,  138,  138,  138,  138,  138,  138,
      138,  138,  138,  138,  138,  138,  138,  138,  -68,  138,
      138,  138,  138,  138,  138,  138,  138,  138
    },

    {
       33,  -69,  139,  140,  140,  -69,  -69,  -69,  -69,  141,
      -69,  -69,  -69,  -69,  -69,  142,  -69,  -69,  -69,  -69,
      -69,  -69,  -69,  -69,  -69,  -69,  -69,  -69,  -69,  -69,
      -69,  -69,  -69,  -69,  -69,  -69,  -69,  -69

    },

    {
       33,  143,  143,  143,  143,  143,  143,  143,  143,  143,
      143,  143,  143,  143,  143,  143,  143,  143,  144,  143,
      143,  143,  143,  143,  143,  143,  143,  143,  143,  143,
      143,  143,  143,  143,  143,  145,  143,  143
    },

    {
       33,  146,  146,  146,  146,  146,  146,  146,  146,  -71,
      146,  146,  146,  146,  146,  146,  146,  146,  146,  146,
      146,  146,  146,  146,  146,  146,  146,  146,  146,  146,
      146,  146,  146,  146,  146,  146,  146,  146
    },

    {
       33,  -72,  139,  140,  140,  -72,  -72,  -72,  -72,  141,
      -72,  -72,  -72,  -72,  -72,  142,  -72,  -72,  -72,  -72,

      -72,  -72,  -72,  -72,  -72,  -72,  -72,  -72,  -72,  -72,
      -72,  -72,  -72,  -72,  -72,  -72,  -72,  -72
    },

    {
       33,  147,  147,  147,  147,  147,  147,  -73,  147,  147,
      147,  147,  147,  147,  147,  147,  147,  147,  147,  147,
      147,  147,  147,  147,  147,  147,  147,  147,  147,  147,
      147,  147,  147,  147,  147,  147,  147,  147
    },

    {
       33,  147,  147,  147,  147,  147,  147,  -74,  147,  147,
      147,  147,  147,  147,  147,  147,  147,  147,  147,  147,
      147,  147,  147,  147,  147,  147,  147,  147,  147,  147,
      147,  147,  147,  147,  147,  147,  147,  147

    },

    {
       33,  -75,  -75,  -75,  -75,  -75,  -75,  148,  -75,  -75,
      -75,  -75,  -75,  -75,  -75,  -75,  -75,  -75,  -75,  -75,
      -75,  -75,  149,  149,  149,  149,  149,  149,  -75,  -75,
      149,  149,  149,  149,  149,  149,  -75,  149
    },

    {
       33,  -76,  -76,  -76,  -76,  -76,  -76,  -76,  -76,  -76,
      -76,  -76,  -76,  -76,  -76,  -76,  -76,  -76,  -76,  -76,
      -76,  -76,  -76,  -76,  -76,  -76,  -76,  -76,  -76,  -76,
      -76,  -76,  -76,  -76,  -76,  -76,  -76,  -76
    },

    {
       33,  -77,  -77,  -77,  -77,  -77,  -77,  -77,  -77,  -77,
      -77,  -77,  -77,  -77,  -77,  -77,  -77,  -77,  -77,  -77,

      -77,  -77,  -77,  -77,  -77,  -77,  -77,  -77,  -77,  -77,
      -77,  -77,  -77,  -77,  -77,  -77,  -77,  -77
    },

    {
       33,  -78,  -78,  -78,  -78,  -78,  -78,  -78,  -78,  -78,
      -78,  -78,  -78,  -78,  -78,  -78,  -78,  -78,  -78,  -78,
      -78,  -78,  -78,  -78,  -78,  -78,  -78,  -78,  -78,  -78,
      -78,  -78,  -78,  -78,  -78,  -78,  -78,  -78
    },

    {
       33,  -79,  -79,  -79,  -79,  -79,  -79,  -79,  -79,  -79,
      -79,  -79,  -79,  -79,  -79,  -79,  -79,  -79,  -79,  -79,
      -79,  -79,  -79,  -79,  -79,  -79,  -79,  -79,  -79,  -79,
      -79,  -79,  -79,  -79,  -79,  -79,  -79,  -79

    },

    {
       33,  -80,  150,  150,  150,  -80,  -80,  -80,  -80,  -80,
      -80,  -80,  -80,  -80,  -80,  -80,  -80,  -80,  -80,  -80,
      -80,  -80,  -80,  -80,  -80,  -80,  -80,  -80,  -80,  -80,
      -80,  -80,  -80,  -80,  -80,  -80,  -80,  -80
    },

    {
       33,  -81,  150,  150,  150,  -81,  -81,  -81,  -81,  -81,
      -81,  -81,  -81,  -81,  -81,  -81,  -81,  -81,  -81,  -81,
      -81,  -81,  -81,  -81,  -81,  -81,  -81,  -81,  -81,  -81,
      -81,  -81,  -81,  -81,  -81,  -81,  -81,  -81
    },

    {
       33,  -82,  -82,  -82,  -82,  -82,  -82,  -82,  -82,  -82,
      -82,  -82,  -82,  -82,  -82,  -82,  -82,  -82,  -82,  -82,

      -82,  -82,  -82,  -82,  -82,  -82,  -82,  -82,  -82,  -82,
      -82,  -82,  -82,  -82,  -82,  -82,  -82,  -82
    },

    {
       33,  -83,  -83,  -83,  -83,  -83,  -83,  -83,  -83,  -83,
      -83,  -83,  -83,  -83,  -83,  -83,  -83,  -83,  -83,  -83,
      -83,  -83,  -83,  -83,  -83,  -83,  -83,  -83,  -83,  -83,
      -83,  -83,  -83,  -83,  -83,  -83,  -83,  -83
    },

    {
       33,  -84,  -84,  -84,  -84,  -84,  -84,  -84,  -84,  -84,
      -84,  -84,  -84,  -84,  -84,  -84,  -84,  -84,  151,  151,
      -84,  -84,  151,  151,  151,  151,  151,  151,  -84,  -84,
      151,  151,  151,  151,  151,  151,  -84,  -84

    },

    {
       33,  -85,  -85,  -85,  -85,  -85,  -85,  -85,  -85,  -85,
      -85,  -85,  -85,  -85,  -85,  -85,  -85,  -85,  -85,  -85,
      -85,  -85,  -85,  -85,  -85,  -85,  -85,  -85,  -85,  -85,
      -85,  -85,  -85,  -85,  -85,  -85,  -85,  -85
    },

    {
       33,  -86,  -86,  -86,  -86,  -86,  -86,  -86,  -86,  -86,
      -86,  -86,  -86,  -86,  -86,  -86,  -86,  -86,  -86,  -86,
      -86,  -86,  -86,  -86,  -86,  -86,  -86,  -86,  -86,  -86,
      -86,  -86,  -86,  -86,  -86,  -86,  -86,  -86
    },

    {
       33,  -87,  -87,  -87,  -87,  -87,  -87,  -87,  -87,  -87,
      -87,  -87,  -87,  -87,  -87,  -87,  -87,  -87,  -87,  -87,

      -87,  -87,  -87,  -87,  -87,  -87,  -87,  -87,  -87,  -87,
      -87,  -87,  -87,  -87,  -87,  -87,  -87,  -87
    },

    {
       33,  -88,  -88,  -88,  -88,  -88,  -88,  -88,  -88,  -88,
      -88,  -88,  -88,  -88,  -88,  -88,  -88,  -88,  -88,  -88,
      -88,  -88,  -88,  -88,  -88,  -88,  -88,  -88,  -88,  -88,
      -88,  -88,  -88,  -88,  -88,  -88,  -88,  -88
    },

    {
       33,  -89,  -89,  -89,  -89,  -89,  -89,  -89,  -89,  152,
      -89,  -89,  -89,  -89,  -89,  -89,  -89,  -89,  -89,  -89,
      -89,  -89,  -89,  -89,  -89,  -89,  -89,  -89,  -89,  -89,
      -89,  -89,  -89,  -89,  -89,  -89,  -89,  -89

    },

    {
       33,  153,  153,  -90,  153,  153,  153,  153,  153,  153,
      153,  153,  153,  153,  153,  153,  153,  153,  154,  153,
      153,  153,  153,  153,  153,  153,  153,  153,  153,  153,
      155,  156,  157,  158,  159,  160,  153,  153
    },

    {
       33,  -91,  -91,  -91,  -91,  -91,  -91,  -91,  -91,  -91,
      -91,  -91,  -91,  -91,  -91,  -91,  -91,  -91,  -91,  -91,
      -91,  -91,  -91,  -91,  -91,  -91,  -91,  -91,  -91,  -91,
      -91,  -91,  -91,  -91,  -91,  -91,  -91,  -91
    },

    {
       33,  -92,  -92,  -92,  -92,  -92,  -92,  -92,  -92,  -92,
      -92,  -92,  -92,  -92,  -92,  -92,  -92,  -92,  -92,  -92,

      -92,  -92,  -92,  -92,  -92,  -92,  -92,  -92,  -92,  -92,
      -92,  -92,  -92,  -92,  -92,  -92,  -92,  -92
    },

    {
       33,  -93,  -93,  -93,  -93,  -93,  -93,  -93,  -93,  -93,
      -93,  -93,  -93,  -93,  -93,  -93,  -93,  -93,  -93,  -93,
      -93,  -93,  -93,  -93,  -93,  -93,  -93,  -93,  -93,  -93,
      -93,  -93,  -93,  -93,  -93,  -93,  -93,  -93
    },

    {
       33,  -94,  -94,  -94,  -94,  -94,  -94,  -94,  -94,  -94,
      -94,  -94,  -94,  -94,  -94,  -94,  -94,  -94,  -94,  -94,
      -94,  -94,  -94,  -94,  -94,  -94,  -94,  -94,  -94,  -94,
      -94,  -94,  -94,  -94,  -94,  -94,  -94,  -94

    },

    {
       33,  -95,  -95,  -95,  -95,  -95,  -95,  -95,  -95,  -95,
      -95,  -95,  -95,  -95,  -95,  -95,  -95,  -95,  -95,  -95,
      -95,  -95,  -95,  -95,  -95,  -95,  -95,  -95,  -95,  -95,
      -95,  -95,  -95,  -95,  -95,  -95,  -95,  -95
    },

    {
       33,  -96,  -96,  -96,  -96,  -96,  -96,  -96,  -96,  -96,
      -96,  -96,  -96,  -96,  -96,  -96,  -96,  -96,  -96,  -96,
      -96,  -96,  -96,  -96,  -96,  -96,  -96,  -96,  -96,  -96,
      -96,  -96,  -96,  -96,  -96,  -96,  -96,  -96
    },

    {
       33,  -97,  -97,  -97,  -97,  -97,  -97,  -97,  -97,  -97,
      -97,  -97,  -97,  -97,  -97,  -97,  -97,  -97,  -97,  -97,

      -97,  -97,  -97,  -97,  -97,  -97,  -97,  -97,  -97,  -97,
      -97,  -97,  -97,  -97,  -97,  -97,  -97,  -97
    },

    {
       33,  -98,  -98,  -98,  -98,  -98,  -98,  -98,  -98,  -98,
      -98,  -98,  -98,  -98,  -98,  -98,  -98,  -98,  -98,  -98,
      -98,  -98,  -98,  -98,  -98,  -98,  -98,  -98,  -98,  -98,
      -98,  -98,  -98,  -98,  -98,  -98,  -98,  -98
    },

    {
       33,  -99,  -99,  -99,  -99,  -99,  -99,  -99,  -99,  -99,
      -99,  -99,  -99,  -99,  -99,  -99,  -99,  -99,  -99,  -99,
      -99,  -99,  -99,  -99,  -99,  -99,  -99,  -99,  -99,  -99,
      -99,  -99,  -99,  -99,  -99,  -99,  -99,  -99

    },

    {
       33, -100, -100, -100, -100, -100, -100, -100, -100, -100,
     -100, -100, -100, -100, -100, -100, -100, -100, -100, -100,
     -100, -100, -100, -100, -100, -100, -100, -100, -100, -100,
     -100, -100, -100, -100, -100, -100, -100, -100
    },

    {
       33, -101,  161,  161,  161, -101, -101, -101, -101, -101,
     -101, -101, -101, -101, -101, -101, -101, -101, -101, -101,
     -101, -101, -101, -101, -101, -101, -101, -101, -101, -101,
     -101, -101, -101, -101, -101, -101, -101, -101
    },

    {
       33, -102,  161,  161,  161, -102, -102, -102, -102, -102,
     -102, -102, -102, -102, -102, -102, -102, -102, -102, -102,

     -102, -102, -102, -102, -102, -102, -102, -102, -102, -102,
     -102, -102, -102, -102, -102, -102, -102, -102
    },

    {
       33, -103, -103, -103, -103, -103, -103, -103, -103, -103,
     -103, -103, -103, -103, -103, -103, -103, -103, -103, -103,
     -103, -103, -103, -103, -103, -103, -103, -103, -103, -103,
     -103, -103, -103, -103, -103, -103, -103, -103
    },

    {
       33, -104, -104, -104, -104, -104, -104, -104, -104, -104,
     -104, -104, -104, -104, -104, -104, -104, -104, -104, -104,
     -104, -104, -104, -104, -104, -104, -104, -104,  162, -104,
     -104, -104, -104, -104, -104, -104, -104, -104

    },

    {
       33, -105,  105,  105,  105, -105, -105, -105, -105, -105,
     -105, -105, -105, -105, -105, -105, -105, -105, -105, -105,
     -105, -105, -105, -105, -105, -105, -105, -105, -105, -105,
     -105, -105, -105, -105, -105, -105, -105, -105
    },

    {
       33, -106, -106, -106, -106,  106, -106, -106,  106, -106,
     -106, -106,  106,  106, -106,  106, -106,  106, -106, -106,
     -106, -106, -106, -106, -106, -106, -106, -106, -106,  106,
     -106, -106, -106, -106, -106, -106,  106, -106
    },

    {
       33, -107, -107, -107, -107, -107, -107, -107, -107, -107,
     -107, -107, -107, -107, -107, -107, -107, -107, -107, -107,

     -107, -107, -107, -107, -107, -107, -107, -107, -107, -107,
     -107, -107, -107, -107, -107, -107, -107, -107
    },

    {
       33, -108, -108, -108, -108, -108, -108, -108, -108, -108,
     -108, -108, -108, -108, -108, -108, -108, -108,  108,  108,
     -108, -108, -108, -108, -108, -108, -108, -108, -108, -108,
     -108, -108, -108, -108, -108, -108, -108, -108
    },

    {
       33, -109, -109, -109, -109, -109, -109,  107, -109, -109,
     -109, -109, -109, -109, -109, -109, -109, -109,  163,  163,
     -109, -109,  163,  163,  163,  163,  163,  163, -109, -109,
      163,  163,  163,  163,  163,  163, -109,  163

    },

    {
       33,  164,  164, -110, -110,  165,  164,  164,  165,  164,
      164,  164,  165,  165,  164,  165,  164,  165,  164,  164,
      164,  164,  164,  164,  164,  164,  164,  164,  164,  165,
      164,  164,  164,  164,  164,  164,  165,  164
    },

    {
       33, -111, -111, -111, -111, -111, -111, -111, -111, -111,
     -111, -111, -111, -111, -111, -111, -111, -111,  111,  111,
     -111, -111, -111, -111,  115, -111, -111, -111, -111, -111,
     -111, -111, -111, -111, -111, -111, -111, -111
    },

    {
       33, -112, -112, -112, -112,  166, -112, -112,  166, -112,
     -112, -112,  166,  166, -112,  166, -112,  166, -112, -112,

     -112, -112, -112, -112, -112, -112, -112, -112, -112,  166,
     -112, -112, -112, -112, -112, -112,  166, -112
    },

    {
       33, -113, -113, -113, -113, -113, -113, -113, -113, -113,
     -113, -113, -113, -113, -113, -113, -113, -113,  167,  167,
     -113, -113, -113, -113,  115, -113, -113, -113, -113, -113,
     -113, -113, -113, -113, -113, -113, -113, -113
    },

    {
       33, -114, -114, -114, -114, -114, -114, -114, -114, -114,
     -114, -114, -114, -114, -114, -114,  113, -114,  114,  114,
     -114, -114, -114, -114,  115, -114, -114, -114, -114, -114,
     -114, -114, -114, -114, -114, -114, -114, -114

    },

    {
       33, -115, -115, -115, -115, -115, -115, -115, -115, -115,
     -115, -115, -115,  168, -115,  168, -115, -115,  169,  169,
     -115, -115, -115, -115, -115, -115, -115, -115, -115, -115,
     -115, -115, -115, -115, -115, -115, -115, -115
    },

    {
       33, -116, -116, -116, -116, -116, -116, -116, -116, -116,
     -116, -116, -116, -116, -116, -116, -116, -116,  116,  116,
     -116, -116,  116,  116,  116,  116,  116,  116, -116, -116,
      116,  116,  116,  116,  116,  116, -116, -116
    },

    {
       33, -117, -117, -117, -117, -117, -117, -117, -117, -117,
     -117, -117, -117, -117, -117, -117, -117, -117, -117, -117,

     -117, -117, -117, -117, -117, -117, -117, -117, -117, -117,
     -117, -117, -117, -117, -117, -117, -117, -117
    },

    {
       33, -118, -118, -118, -118, -118, -118,  118, -118, -118,
     -118, -118, -118, -118, -118, -118, -118, -118,  118,  118,
     -118, -118,  118,  118,  118,  118,  118,  118, -118, -118,
      118,  118,  118,  118,  118,  118, -118,  118
    },

    {
       33, -119, -119, -119, -119, -119, -119, -119, -119, -119,
     -119, -119, -119, -119, -119, -119, -119, -119, -119, -119,
     -119, -119, -119, -119, -119, -119, -119, -119, -119, -119,
     -119, -119, -119, -119, -119, -119, -119, -119

    },

    {
       33, -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, -120, -120, -120, -120
    },

    {
       33, -121, -121, -121, -121, -121, -121, -121, -121, -121,
     -121, -121, -121, -121, -121, -121, -121, -121, -121, -121,
     -121, -121, -121, -121, -121, -121, -121, -121, -121, -121,
     -121, -121, -121, -121, -121, -121, -121, -121
    },

    {
       33, -122, -122, -122, -122, -122, -122, -122, -122, -122,
     -122, -122, -122, -122, -122, -122, -122, -122, -122, -122,

     -122, -122, -122, -122, -122, -122, -122, -122, -122, -122,
     -122, -122, -122, -122, -122, -122, -122, -122
    },

    {
       33, -123, -123, -123, -123, -123, -123, -123, -123, -123,
     -123, -123, -123, -123, -123, -123, -123, -123, -123, -123,
     -123, -123, -123, -123, -123, -123, -123, -123, -123, -123,
     -123, -123, -123, -123, -123, -123, -123, -123
    },

    {
       33,  124,  124,  124,  124,  124,  124,  124,  124, -124,
      124,  124,  124,  124,  124,  124,  124,  124,  124,  124,
      124,  124,  124,  124,  124,  124,  124,  124,  124,  124,
      124,  124,  124,  124,  124,  124,  124,  124

    },

    {
       33, -125,  125,  126,  126, -125, -125, -125, -125, -125,
     -125, -125, -125, -125, -125,  127, -125, -125, -125, -125,
     -125, -125, -125, -125, -125, -125, -125, -125, -125, -125,
     -125, -125, -125, -125, -125, -125, -125, -125
    },

    {
       33, -126,  170,  170,  170, -126, -126, -126, -126,  171,
     -126, -126, -126, -126, -126,  172, -126, -126, -126, -126,
     -126, -126, -126, -126, -126, -126, -126, -126, -126, -126,
     -126, -126, -126, -126, -126, -126, -126, -126
    },

    {
       33, -127, -127, -127, -127, -127, -127, -127, -127, -127,
     -127, -127, -127, -127, -127,  173, -127, -127, -127, -127,

     -127, -127, -127, -127, -127, -127, -127, -127, -127, -127,
     -127, -127, -127, -127, -127, -127, -127, -127
    },

    {
       33,  128,  128,  128,  128,  128,  128,  128,  128,  128,
      128,  128, -128,  128,  128,  128,  128, -128,  128,  128,
      128,  128,  128,  128,  128,  128,  128,  128,  128,  128,
      128,  128,  128,  128,  128,  128,  128,  128
    },

    {
       33, -129, -129, -129, -129, -129, -129, -129, -129, -129,
     -129, -129,  129, -129, -129, -129, -129,  130, -129, -129,
     -129, -129, -129, -129, -129, -129, -129, -129, -129, -129,
     -129, -129, -129, -129, -129, -129, -129, -129

    },

    {
       33, -130, -130, -130, -130, -130, -130, -130, -130, -130,
     -130, -130, -130, -130, -130, -130, -130, -130, -130, -130,
     -130, -130, -130, -130, -130, -130, -130, -130, -130, -130,
     -130, -130, -130, -130, -130, -130, -130, -130
    },

    {
       33, -131, -131, -131, -131,  174, -131, -131,  174, -131,
     -131, -131,  174,  174, -131,  174, -131,  174, -131, -131,
     -131, -131, -131, -131, -131, -131, -131, -131, -131,  174,
     -131, -131, -131, -131, -131, -131,  174, -131
    },

    {
       33,  132,  132,  132,  132,  132, -132,  132,  132,  132,
      132,  132,  132,  132,  132,  132,  132,  132,  132,  132,

      132,  132,  132,  132,  132,  132,  132,  132,  132,  132,
      132,  132,  132,  132,  132,  132,  132,  132
    },

    {
       33, -133, -133, -133, -133, -133, -133, -133, -133, -133,
     -133, -133, -133, -133, -133, -133, -133, -133, -133, -133,
     -133, -133, -133, -133, -133, -133, -133, -133, -133, -133,
     -133, -133, -133, -133, -133, -133, -133, -133
    },

    {
       33,  134,  134,  134,  134,  134,  134,  134,  134, -134,
      134,  134,  134,  134,  134,  134,  134,  134,  134,  134,
      134,  134,  134,  134,  134,  134,  134,  134,  134,  134,
      134,  134,  134,  134,  134,  134,  134,  134

    },

    {
       33, -135,  135,  136,  136, -135, -135, -135, -135, -135,
     -135, -135, -135, -135, -135,  137, -135, -135, -135, -135,
     -135, -135, -135, -135, -135, -135, -135, -135, -135, -135,
     -135, -135, -135, -135, -135, -135, -135, -135
    },

    {
       33, -136,  175,  175,  175, -136, -136, -136, -136,  176,
     -136, -136, -136, -136, -136,  177, -136, -136, -136, -136,
     -136, -136, -136, -136, -136, -136, -136, -136, -136, -136,
     -136, -136, -136, -136, -136, -136, -136, -136
    },

    {
       33, -137, -137, -137, -137, -137, -137, -137, -137, -137,
     -137, -137, -137, -137, -137,  178, -137, -137, -137, -137,

     -137, -137, -137, -137, -137, -137, -137, -137, -137, -137,
     -137, -137, -137, -137, -137, -137, -137, -137
    },

    {
       33,  138,  138,  138,  138,  138,  138,  138,  138, -138,
      138,  138,  138,  138,  138,  138,  138,  138,  138,  138,
      138,  138,  138,  138,  138,  138,  138,  138, -138,  138,
      138,  138,  138,  138,  138,  138,  138,  138
    },

    {
       33, -139,  139,  140,  140, -139, -139, -139, -139, -139,
     -139, -139, -139, -139, -139,  142, -139, -139, -139, -139,
     -139, -139, -139, -139, -139, -139, -139, -139, -139, -139,
     -139, -139, -139, -139, -139, -139, -139, -139

    },

    {
       33, -140,  179,  179,  179, -140, -140, -140, -140,  180,
     -140, -140, -140, -140, -140,  181, -140, -140, -140, -140,
     -140, -140, -140, -140, -140, -140, -140, -140, -140, -140,
     -140, -140, -140, -140, -140, -140, -140, -140
    },

    {
       33, -141, -141, -141, -141, -141, -141, -141, -141, -141,
     -141, -141, -141, -141, -141, -141, -141, -141, -141, -141,
     -141, -141, -141, -141, -141, -141, -141, -141, -141, -141,
     -141, -141, -141, -141, -141, -141, -141, -141
    },

    {
       33, -142, -142, -142, -142, -142, -142, -142, -142, -142,
     -142, -142, -142, -142, -142,  182, -142, -142, -142, -142,

     -142, -142, -142, -142, -142, -142, -142, -142, -142, -142,
     -142, -142, -142, -142, -142, -142, -142, -142
    },

    {
       33, -143, -143, -143, -143, -143, -143, -143, -143, -143,
     -143, -143, -143, -143, -143, -143, -143, -143, -143, -143,
     -143, -143, -143, -143, -143, -143, -143, -143, -143, -143,
     -143, -143, -143, -143, -143, -143, -143, -143
    },

    {
       33, -144, -144, -144, -144, -144, -144, -144, -144, -144,
     -144, -144, -144, -144, -144, -144, -144, -144,  183, -144,
     -144, -144, -144, -144, -144, -144, -144, -144, -144, -144,
     -144, -144, -144, -144, -144, -144, -144, -144

    },

    {
       33, -145, -145, -145, -145, -145, -145, -145, -145, -145,
     -145, -145, -145, -145, -145, -145, -145, -145,  184,  184,
     -145, -145,  184,  184,  184, -145, -145, -145, -145, -145,
      184,  184, -145, -145, -145, -145, -145, -145
    },

    {
       33,  146,  146,  146,  146,  146,  146,  146,  146, -146,
      146,  146,  146,  146,  146,  146,  146,  146,  146,  146,
      146,  146,  146,  146,  146,  146,  146,  146,  146,  146,
      146,  146,  146,  146,  146,  146,  146,  146
    },

    {
       33,  147,  147,  147,  147,  147,  147, -147,  147,  147,
      147,  147,  147,  147,  147,  147,  147,  147,  147,  147,

      147,  147,  147,  147,  147,  147,  147,  147,  147,  147,
      147,  147,  147,  147,  147,  147,  147,  147
    },

    {
       33, -148, -148, -148, -148, -148, -148, -148, -148, -148,
     -148, -148, -148, -148, -148, -148, -148, -148, -148, -148,
     -148, -148, -148, -148, -148, -148, -148, -148, -148, -148,
     -148, -148, -148, -148, -148, -148, -148, -148
    },

    {
       33, -149, -149, -149, -149, -149, -149,  148, -149, -149,
     -149, -149, -149, -149, -149, -149, -149, -149,  185,  185,
     -149, -149,  185,  185,  185,  185,  185,  185, -149, -149,
      185,  185,  185,  185,  185,  185, -149,  185

    },

    {
       33, -150,  150,  150,  150, -150, -150, -150, -150, -150,
     -150, -150, -150, -150, -150, -150, -150, -150, -150, -150,
     -150, -150, -150, -150, -150, -150, -150, -150, -150, -150,
     -150, -150, -150, -150, -150, -150, -150, -150
    },

    {
       33, -151, -151, -151, -151, -151, -151, -151, -151, -151,
     -151, -151, -151, -151, -151, -151, -151, -151,  151,  151,
     -151, -151,  151,  151,  151,  151,  151,  151, -151, -151,
      151,  151,  151,  151,  151,  151, -151, -151
    },

    {
       33, -152, -152, -152, -152, -152, -152, -152, -152, -152,
     -152, -152, -152, -152, -152, -152, -152, -152, -152, -152,

     -152, -152, -152, -152, -152, -152, -152, -152, -152, -152,
     -152, -152, -152, -152, -152, -152, -152, -152
    },

    {
       33, -153, -153, -153, -153, -153, -153, -153, -153, -153,
     -153, -153, -153, -153, -153, -153, -153, -153, -153, -153,
     -153, -153, -153, -153, -153, -153, -153, -153, -153, -153,
     -153, -153, -153, -153, -153, -153, -153, -153
    },

    {
       33, -154, -154, -154, -154, -154, -154, -154, -154, -154,
     -154, -154, -154, -154, -154, -154, -154, -154,  186, -154,
     -154, -154, -154, -154, -154, -154, -154, -154, -154, -154,
     -154, -154, -154, -154, -154, -154, -154, -154

    },

    {
       33, -155, -155, -155, -155, -155, -155, -155, -155, -155,
     -155, -155, -155, -155, -155, -155, -155, -155, -155, -155,
     -155, -155, -155, -155, -155, -155, -155, -155, -155, -155,
     -155, -155, -155, -155, -155, -155, -155, -155
    },

    {
       33, -156, -156, -156, -156, -156, -156, -156, -156, -156,
     -156, -156, -156, -156, -156, -156, -156, -156, -156, -156,
     -156, -156, -156, -156, -156, -156, -156, -156, -156, -156,
     -156, -156, -156, -156, -156, -156, -156, -156
    },

    {
       33, -157, -157, -157, -157, -157, -157, -157, -157, -157,
     -157, -157, -157, -157, -157, -157, -157, -157, -157, -157,

     -157, -157, -157, -157, -157, -157, -157, -157, -157, -157,
     -157, -157, -157, -157, -157, -157, -157, -157
    },

    {
       33, -158, -158, -158, -158, -158, -158, -158, -158, -158,
     -158, -158, -158, -158, -158, -158, -158, -158, -158, -158,
     -158, -158, -158, -158, -158, -158, -158, -158, -158, -158,
     -158, -158, -158, -158, -158, -158, -158, -158
    },

    {
       33, -159, -159, -159, -159, -159, -159, -159, -159, -159,
     -159, -159, -159, -159, -159, -159, -159, -159, -159, -159,
     -159, -159, -159, -159, -159, -159, -159, -159, -159, -159,
     -159, -159, -159, -159, -159, -159, -159, -159

    },

    {
       33, -160, -160, -160, -160, -160, -160, -160, -160, -160,
     -160, -160, -160, -160, -160, -160, -160, -160,  187,  187,
     -160, -160,  187,  187,  187, -160, -160, -160, -160, -160,
      187,  187, -160, -160, -160, -160, -160, -160
    },

    {
       33, -161,  161,  161,  161, -161, -161, -161, -161, -161,
     -161, -161, -161, -161, -161, -161, -161, -161, -161, -161,
     -161, -161, -161, -161, -161, -161, -161, -161, -161, -161,
     -161, -161, -161, -161, -161, -161, -161, -161
    },

    {
       33, -162, -162, -162, -162, -162, -162, -162, -162, -162,
     -162, -162, -162, -162, -162, -162, -162, -162, -162, -162,

     -162, -162, -162, -162, -162, -162, -162, -162, -162, -162,
     -162, -162, -162, -162, -162, -162, -162, -162
    },

    {
       33, -163, -163, -163, -163, -163, -163,  107, -163, -163,
     -163, -163, -163, -163, -163, -163, -163, -163,  163,  163,
     -163, -163,  163,  163,  163,  163,  163,  163, -163, -163,
      163,  163,  163,  163,  163,  163, -163,  163
    },

    {
       33,  164,  164, -164, -164,  164,  164,  164,  164,  164,
      164,  164,  164,  164,  164,  164,  164,  164,  164,  164,
      164,  164,  164,  164,  164,  164,  164,  164,  164,  164,
      164,  164,  164,  164,  164,  164,  164,  164

    },

    {
       33,  164,  164, -165, -165,  165,  164,  164,  165,  164,
      164,  164,  165,  165,  164,  165,  164,  165,  164,  164,
      164,  164,  164,  164,  164,  164,  164,  164,  164,  165,
      164,  164,  164,  164,  164,  164,  165,  164
    },

    {
       33, -166, -166, -166, -166,  166, -166, -166,  166, -166,
     -166, -166,  166,  166, -166,  166, -166,  166, -166, -166,
     -166, -166, -166, -166, -166, -166, -166, -166, -166,  166,
     -166, -166, -166, -166, -166, -166,  166, -166
    },

    {
       33, -167, -167, -167, -167, -167, -167, -167, -167, -167,
     -167, -167, -167, -167, -167, -167, -167, -167,  167,  167,

     -167, -167, -167, -167,  115, -167, -167, -167, -167, -167,
     -167, -167, -167, -167, -167, -167, -167, -167
    },

    {
       33, -168, -168, -168, -168, -168, -168, -168, -168, -168,
     -168, -168, -168, -168, -168, -168, -168, -168,  169,  169,
     -168, -168, -168, -168, -168, -168, -168, -168, -168, -168,
     -168, -168, -168, -168, -168, -168, -168, -168
    },

    {
       33, -169, -169, -169, -169, -169, -169, -169, -169, -169,
     -169, -169, -169, -169, -169, -169, -169, -169,  169,  169,
     -169, -169, -169, -169, -169, -169, -169, -169, -169, -169,
     -169, -169, -169, -169, -169, -169, -169, -169

    },

    {
       33, -170,  170,  170,  170, -170, -170, -170, -170,  171,
     -170, -170, -170, -170, -170,  172, -170, -170, -170, -170,
     -170, -170, -170, -170, -170, -170, -170, -170, -170, -170,
     -170, -170, -170, -170, -170, -170, -170, -170
    },

    {
       33, -171, -171, -171, -171, -171, -171, -171, -171, -171,
     -171, -171, -171, -171, -171, -171, -171, -171, -171, -171,
     -171, -171, -171, -171, -171, -171, -171, -171, -171, -171,
     -171, -171, -171, -171, -171, -171, -171, -171
    },

    {
       33, -172, -172, -172, -172, -172, -172, -172, -172, -172,
     -172, -172, -172, -172, -172,  188, -172, -172, -172, -172,

     -172, -172, -172, -172, -172, -172, -172, -172, -172, -172,
     -172, -172, -172, -172, -172, -172, -172, -172
    },

    {
       33,  189,  190,  126,  126,  189,  189,  189,  189,  189,
      189,  189,  189,  189,  189,  191,  189,  189,  189,  189,
      189,  189,  189,  189,  189,  189,  189,  189,  189,  189,
      189,  189,  189,  189,  189,  189,  189,  189
    },

    {
       33, -174, -174, -174, -174,  174, -174, -174,  174, -174,
     -174, -174,  174,  174, -174,  174, -174,  174, -174, -174,
     -174, -174, -174, -174, -174, -174, -174, -174, -174,  174,
     -174, -174, -174, -174, -174, -174,  174, -174

    },

    {
       33, -175,  175,  175,  175, -175, -175, -175, -175,  176,
     -175, -175, -175, -175, -175,  177, -175, -175, -175, -175,
     -175, -175, -175, -175, -175, -175, -175, -175, -175, -175,
     -175, -175, -175, -175, -175, -175, -175, -175
    },

    {
       33, -176, -176, -176, -176, -176, -176, -176, -176, -176,
     -176, -176, -176, -176, -176, -176, -176, -176, -176, -176,
     -176, -176, -176, -176, -176, -176, -176, -176, -176, -176,
     -176, -176, -176, -176, -176, -176, -176, -176
    },

    {
       33, -177, -177, -177, -177, -177, -177, -177, -177, -177,
     -177, -177, -177, -177, -177,  192, -177, -177, -177, -177,

     -177, -177, -177, -177, -177, -177, -177, -177, -177, -177,
     -177, -177, -177, -177, -177, -177, -177, -177
    },

    {
       33,  193,  194,  136,  136,  193,  193,  193,  193,  193,
      193,  193,  193,  193,  193,  195,  193,  193,  193,  193,
      193,  193,  193,  193,  193,  193,  193,  193,  193,  193,
      193,  193,  193,  193,  193,  193,  193,  193
    },

    {
       33, -179,  179,  179,  179, -179, -179, -179, -179,  180,
     -179, -179, -179, -179, -179,  181, -179, -179, -179, -179,
     -179, -179, -179, -179, -179, -179, -179, -179, -179, -179,
     -179, -179, -179, -179, -179, -179, -179, -179

    },

    {
       33, -180, -180, -180, -180, -180, -180, -180, -180, -180,
     -180, -180, -180, -180, -180, -180, -180, -180, -180, -180,
     -180, -180, -180, -180, -180, -180, -180, -180, -180, -180,
     -180, -180, -180, -180, -180, -180, -180, -180
    },

    {
       33, -181, -181, -181, -181, -181, -181, -181, -181, -181,
     -181, -181, -181, -181, -181,  196, -181, -181, -181, -181,
     -181, -181, -181, -181, -181, -181, -181, -181, -181, -181,
     -181, -181, -181, -181, -181, -181, -181, -181
    },

    {
       33,  197,  198,  140,  140,  197,  197,  197,  197,  197,
      197,  197,  197,  197,  197,  199,  197,  197,  197,  197,

      197,  197,  197,  197,  197,  197,  197,  197,  197,  197,
      197,  197,  197,  197,  197,  197,  197,  197
    },

    {
       33, -183, -183, -183, -183, -183, -183, -183, -183, -183,
     -183, -183, -183, -183, -183, -183, -183, -183,  200, -183,
     -183, -183, -183, -183, -183, -183, -183, -183, -183, -183,
     -183, -183, -183, -183, -183, -183, -183, -183
    },

    {
       33, -184, -184, -184, -184, -184, -184, -184, -184, -184,
     -184, -184, -184, -184, -184, -184, -184, -184,  201,  201,
     -184, -184,  201,  201,  201, -184, -184, -184, -184, -184,
      201,  201, -184, -184, -184, -184, -184, -184

    },

    {
       33, -185, -185, -185, -185, -185, -185,  148, -185, -185,
     -185, -185, -185, -185, -185, -185, -185, -185,  185,  185,
     -185, -185,  185,  185,  185,  185,  185,  185, -185, -185,
      185,  185,  185,  185,  185,  185, -185,  185
    },

    {
       33, -186, -186, -186, -186, -186, -186, -186, -186, -186,
     -186, -186, -186, -186, -186, -186, -186, -186,  202, -186,
     -186, -186, -186, -186, -186, -186, -186, -186, -186, -186,
     -186, -186, -186, -186, -186, -186, -186, -186
    },

    {
       33, -187, -187, -187, -187, -187, -187, -187, -187, -187,
     -187, -187, -187, -187, -187, -187, -187, -187,  203,  203,

     -187, -187,  203,  203,  203, -187, -187, -187, -187, -187,
      203,  203, -187, -187, -187, -187, -187, -187
    },

    {
       33,  204,  205,  206,  206,  204,  204,  204,  204,  204,
      204,  204,  204,  204,  204,  207,  204,  204,  204,  204,
      204,  204,  204,  204,  204,  204,  204,  204,  204,  204,
      204,  204,  204,  204,  204,  204,  204,  204
    },

    {
       33,  189,  190,  126,  126,  189,  189,  189,  189,  189,
      189,  189,  189,  189,  189,  191,  189,  189,  189,  189,
      189,  189,  189,  189,  189,  189,  189,  189,  189,  189,
      189,  189,  189,  189,  189,  189,  189,  189

    },

    {
       33,  189,  190,  126,  126,  189,  189,  189,  189,  189,
      189,  189,  189,  189,  189,  191,  189,  189,  189,  189,
      189,  189,  189,  189,  189,  189,  189,  189,  189,  189,
      189,  189,  189,  189,  189,  189,  189,  189
    },

    {
       33,  189,  190,  126,  126,  189,  189,  189,  189,  189,
      189,  189,  189,  189,  189,  208,  189,  189,  189,  189,
      189,  189,  189,  189,  189,  189,  189,  189,  189,  189,
      189,  189,  189,  189,  189,  189,  189,  189
    },

    {
       33,  209,  210,  211,  211,  209,  209,  209,  209,  209,
      209,  209,  209,  209,  209,  212,  209,  209,  209,  209,

      209,  209,  209,  209,  209,  209,  209,  209,  209,  209,
      209,  209,  209,  209,  209,  209,  209,  209
    },

    {
       33,  193,  194,  136,  136,  193,  193,  193,  193,  193,
      193,  193,  193,  193,  193,  195,  193,  193,  193,  193,
      193,  193,  193,  193,  193,  193,  193,  193,  193,  193,
      193,  193,  193,  193,  193,  193,  193,  193
    },

    {
       33,  193,  194,  136,  136,  193,  193,  193,  193,  193,
      193,  193,  193,  193,  193,  195,  193,  193,  193,  193,
      193,  193,  193,  193,  193,  193,  193,  193,  193,  193,
      193,  193,  193,  193,  193,  193,  193,  193

    },

    {
       33,  193,  194,  136,  136,  193,  193,  193,  193,  193,
      193,  193,  193,  193,  193,  213,  193,  193,  193,  193,
      193,  193,  193,  193,  193,  193,  193,  193,  193,  193,
      193,  193,  193,  193,  193,  193,  193,  193
    },

    {
       33,  214,  215,  216,  216,  214,  214,  214,  214,  214,
      214,  214,  214,  214,  214,  217,  214,  214,  214,  214,
      214,  214,  214,  214,  214,  214,  214,  214,  214,  214,
      214,  214,  214,  214,  214,  214,  214,  214
    },

    {
       33,  197,  198,  140,  140,  197,  197,  197,  197,  197,
      197,  197,  197,  197,  197,  199,  197,  197,  197,  197,

      197,  197,  197,  197,  197,  197,  197,  197,  197,  197,
      197,  197,  197,  197,  197,  197,  197,  197
    },

    {
       33,  197,  198,  140,  140,  197,  197,  197,  197,  197,
      197,  197,  197,  197,  197,  199,  197,  197,  197,  197,
      197,  197,  197,  197,  197,  197,  197,  197,  197,  197,
      197,  197,  197,  197,  197,  197,  197,  197
    },

    {
       33,  197,  198,  140,  140,  197,  197,  197,  197,  197,
      197,  197,  197,  197,  197,  218,  197,  197,  197,  197,
      197,  197,  197,  197,  197,  197,  197,  197,  197,  197,
      197,  197,  197,  197,  197,  197,  197,  197

    },

    {
       33, -200, -200, -200, -200, -200, -200, -200, -200, -200,
     -200, -200, -200, -200, -200, -200, -200, -200, -200, -200,
     -200, -200, -200, -200, -200, -200, -200, -200, -200, -200,
     -200, -200, -200, -200, -200, -200, -200, -200
    },

    {
       33, -201, -201, -201, -201, -201, -201, -201, -201, -201,
     -201, -201, -201, -201, -201, -201, -201, -201, -201, -201,
     -201, -201, -201, -201, -201, -201, -201, -201, -201, -201,
     -201, -201, -201, -201, -201, -201, -201, -201
    },

    {
       33, -202, -202, -202, -202, -202, -202, -202, -202, -202,
     -202, -202, -202, -202, -202, -202, -202, -202, -202, -202,

     -202, -202, -202, -202, -202, -202, -202, -202, -202, -202,
     -202, -202, -202, -202, -202, -202, -202, -202
    },

    {
       33, -203, -203, -203, -203, -203, -203, -203, -203, -203,
     -203, -203, -203, -203, -203, -203, -203, -203, -203, -203,
     -203, -203, -203, -203, -203, -203, -203, -203, -203, -203,
     -203, -203, -203, -203, -203, -203, -203, -203
    },

    {
       33,  204,  205,  206,  206,  204,  204,  204,  204,  204,
      204,  204,  204,  204,  204,  207,  204,  204,  204,  204,
      204,  204,  204,  204,  204,  204,  204,  204,  204,  204,
      204,  204,  204,  204,  204,  204,  204,  204

    },

    {
       33,  204,  205,  206,  206,  204,  204,  204,  204,  204,
      204,  204,  204,  204,  204,  207,  204,  204,  204,  204,
      204,  204,  204,  204,  204,  204,  204,  204,  204,  204,
      204,  204,  204,  204,  204,  204,  204,  204
    },

    {
       33, -206,  170,  170,  170, -206, -206, -206, -206,  171,
     -206, -206, -206, -206, -206,  172, -206, -206, -206, -206,
     -206, -206, -206, -206, -206, -206, -206, -206, -206, -206,
     -206, -206, -206, -206, -206, -206, -206, -206
    },

    {
       33,  204,  205,  206,  206,  204,  204,  204,  204,  204,
      204,  204,  204,  204,  204,  219,  204,  204,  204,  204,

      204,  204,  204,  204,  204,  204,  204,  204,  204,  204,
      204,  204,  204,  204,  204,  204,  204,  204
    },

    {
       33,  189,  190,  126,  126,  189,  189,  189,  189,  189,
      189,  189,  189,  189,  189,  208,  189,  189,  189,  189,
      189,  189,  189,  189,  189,  189,  189,  189,  189,  189,
      189,  189,  189,  189,  189,  189,  189,  189
    },

    {
       33,  209,  210,  211,  211,  209,  209,  209,  209,  209,
      209,  209,  209,  209,  209,  212,  209,  209,  209,  209,
      209,  209,  209,  209,  209,  209,  209,  209,  209,  209,
      209,  209,  209,  209,  209,  209,  209,  209

    },

    {
       33,  209,  210,  211,  211,  209,  209,  209,  209,  209,
      209,  209,  209,  209,  209,  212,  209,  209,  209,  209,
      209,  209,  209,  209,  209,  209,  209,  209,  209,  209,
      209,  209,  209,  209,  209,  209,  209,  209
    },

    {
       33, -211,  175,  175,  175, -211, -211, -211, -211,  176,
     -211, -211, -211, -211, -211,  177, -211, -211, -211, -211,
     -211, -211, -211, -211, -211, -211, -211, -211, -211, -211,
     -211, -211, -211, -211, -211, -211, -211, -211
    },

    {
       33,  209,  210,  211,  211,  209,  209,  209,  209,  209,
      209,  209,  209,  209,  209,  220,  209,  209,  209,  209,

      209,  209,  209,  209,  209,  209,  209,  209,  209,  209,
      209,  209,  209,  209,  209,  209,  209,  209
    },

    {
       33,  193,  194,  136,  136,  193,  193,  193,  193,  193,
      193,  193,  193,  193,  193,  213,  193,  193,  193,  193,
      193,  193,  193,  193,  193,  193,  193,  193,  193,  193,
      193,  193,  193,  193,  193,  193,  193,  193
    },

    {
       33,  214,  215,  216,  216,  214,  214,  214,  214,  214,
      214,  214,  214,  214,  214,  217,  214,  214,  214,  214,
      214,  214,  214,  214,  214,  214,  214,  214,  214,  214,
      214,  214,  214,  214,  214,  214,  214,  214

    },

    {
       33,  214,  215,  216,  216,  214,  214,  214,  214,  214,
      214,  214,  214,  214,  214,  217,  214,  214,  214,  214,
      214,  214,  214,  214,  214,  214,  214,  214,  214,  214,
      214,  214,  214,  214,  214,  214,  214,  214
    },

    {
       33, -216,  179,  179,  179, -216, -216, -216, -216,  180,
     -216, -216, -216, -216, -216,  181, -216, -216, -216, -216,
     -216, -216, -216, -216, -216, -216, -216, -216, -216, -216,
     -216, -216, -216, -216, -216, -216, -216, -216
    },

    {
       33,  214,  215,  216,  216,  214,  214,  214,  214,  214,
      214,  214,  214,  214,  214,  221,  214,  214,  214,  214,

      214,  214,  214,  214,  214,  214,  214,  214,  214,  214,
      214,  214,  214,  214,  214,  214,  214,  214
    },

    {
       33,  197,  198,  140,  140,  197,  197,  197,  197,  197,
      197,  197,  197,  197,  197,  218,  197,  197,  197,  197,
      197,  197,  197,  197,  197,  197,  197,  197,  197,  197,
      197,  197,  197,  197,  197,  197,  197,  197
    },

    {
       33,  204,  205,  206,  206,  204,  204,  204,  204,  204,
      204,  204,  204,  204,  204,  219,  204,  204,  204,  204,
      204,  204,  204,  204,  204,  204,  204,  204,  204,  204,
      204,  204,  204,  204,  204,  204,  204,  204

    },

    {
       33,  209,  210,  211,  211,  209,  209,  209,  209,  209,
      209,  209,  209,  209,  209,  220,  209,  209,  209,  209,
      209,  209,  209,  209,  209,  209,  209,  209,  209,  209,
      209,  209,  209,  209,  209,  209,  209,  209
    },

    {
       33,  214,  215,  216,  216,  214,  214,  214,  214,  214,
      214,  214,  214,  214,  214,  221,  214,  214,  214,  214,
      214,  214,  214,  214,  214,  214,  214,  214,  214,  214,
      214,  214,  214,  214,  214,  214,  214,  214
    },

    } ;


static yy_state_type yy_get_previous_state YY_PROTO(( void ));
static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
static int yy_get_next_buffer YY_PROTO(( void ));
static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));

/* Done after the current pattern has been matched and before the
 * corresponding action - sets up yytext.
 */
#define YY_DO_BEFORE_ACTION \
	yytext_ptr = yy_bp; \
	yyleng = (int) (yy_cp - yy_bp); \
	yy_hold_char = *yy_cp; \
	*yy_cp = '\0'; \
	yy_c_buf_p = yy_cp;

#define YY_NUM_RULES 91
#define YY_END_OF_BUFFER 92
static yyconst short int yy_accept[222] =
    {   0,
        0,    0,   12,   12,    0,    0,    0,    0,   11,   11,
        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
        0,    0,   92,   57,    1,    1,   49,   37,   57,   48,
       19,   42,   43,   48,   48,   48,   48,   51,   48,   44,
       56,   56,   56,   56,   56,   46,   12,    9,    5,    5,
        6,    6,   40,   38,   11,   16,   25,   25,   21,   30,
       24,   21,   34,   34,   36,   59,   58,   58,   67,   60,
       60,   66,   62,   64,   61,   63,   65,   78,   68,   78,
       80,   79,   84,   81,   81,   83,   82,   86,   85,   88,

       87,   87,   90,   90,    1,   49,   31,   50,   32,    1,
       52,    2,   52,   51,   54,   47,   41,   56,    8,   20,
       18,   15,   45,   12,    9,    9,   10,    5,    7,    4,
        3,   40,   39,   11,   16,   16,   17,   25,   21,   21,
       23,   22,   26,   27,   26,   24,   34,   33,   35,   60,
       64,   69,   77,   75,   72,   74,   70,   73,   71,   77,
       87,   89,   32,    1,    1,    2,   52,   55,   53,    9,
       14,   10,    9,    3,   16,   13,   17,   16,   21,   29,
       22,   21,   27,   28,   35,   75,   76,    9,    9,    9,
        9,   16,   16,   16,   16,   21,   21,   21,   21,   27,

       28,   75,   76,    9,    9,    9,    9,    9,   16,   16,
       16,   16,   16,   21,   21,   21,   21,   21,    9,   16,
       21
    } ;

static yyconst int yy_ec[256] =
    {   0,
        1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
        1,    2,    4,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    2,    5,    6,    5,    7,    8,    5,    9,   10,
       11,   12,   13,   14,   15,   16,   17,   18,   18,   18,
       18,   18,   18,   18,   18,   19,   19,   20,   21,    8,
        8,    8,    5,    5,   22,   23,   22,   22,   24,   22,
       25,   25,   25,   25,   25,   25,   25,   26,   25,   25,
       25,   25,   25,   25,   25,   25,   25,   27,   25,   25,
       14,   28,   14,    8,   25,   29,   22,   30,   22,   22,

       24,   31,   25,   25,   25,   25,   25,   25,   25,   32,
       25,   25,   25,   33,   25,   34,   25,   25,   25,   35,
       25,   25,    1,   36,    1,    5,    1,   37,   37,   37,
       37,   37,   37,   37,   37,   37,   37,   37,   37,   37,
       37,   37,   37,   37,   37,   37,   37,   37,   37,   37,
       37,   37,   37,   37,   37,   37,   37,   37,   37,   37,
       37,   37,   37,   37,   37,   37,   37,   37,   37,   37,
       37,   37,   37,   37,   37,   37,   37,   37,   37,   37,
       37,   37,   37,   37,   37,   37,   37,   37,   37,   37,
       37,   37,   37,   37,   37,   37,   37,   37,   37,   37,

       37,   37,   37,   37,   37,   37,   37,   37,   37,   37,
       37,   37,   37,   37,   37,   37,   37,   37,   37,   37,
       37,   37,   37,   37,   37,   37,   37,   37,   37,   37,
       37,   37,   37,   37,   37,   37,   37,   37,   37,   37,
       37,   37,   37,   37,   37,   37,   37,   37,   37,   37,
       37,   37,   37,   37,   37
    } ;

/* The intent behind this definition is that it'll catch
 * any uses of REJECT which flex missed.
 */
#define REJECT reject_used_but_not_detected
#define yymore() yymore_used_but_not_detected
#define YY_MORE_ADJ 0
#define YY_RESTORE_YY_MORE_OFFSET
char *yytext;
#line 1 "psqlscan.l"
#define INITIAL 0
#line 2 "psqlscan.l"
/*-------------------------------------------------------------------------
 *
 * psqlscan.l
 *	  lexical scanner for psql
 *
 * This code is mainly needed to determine where the end of a SQL statement
 * is: we are looking for semicolons that are not within quotes, comments,
 * or parentheses.  The most reliable way to handle this is to borrow the
 * backend's flex lexer rules, lock, stock, and barrel.  The rules below
 * are (except for a few) the same as the backend's, but their actions are
 * just ECHO whereas the backend's actions generally do other things.
 *
 * XXX The rules in this file must be kept in sync with the backend lexer!!!
 *
 * XXX Avoid creating backtracking cases --- see the backend lexer for info.
 *
 * The most difficult aspect of this code is that we need to work in multibyte
 * encodings that are not ASCII-safe.  A "safe" encoding is one in which each
 * byte of a multibyte character has the high bit set (it's >= 0x80).  Since
 * all our lexing rules treat all high-bit-set characters alike, we don't
 * really need to care whether such a byte is part of a sequence or not.
 * In an "unsafe" encoding, we still expect the first byte of a multibyte
 * sequence to be >= 0x80, but later bytes might not be.  If we scan such
 * a sequence as-is, the lexing rules could easily be fooled into matching
 * such bytes to ordinary ASCII characters.  Our solution for this is to
 * substitute 0xFF for each non-first byte within the data presented to flex.
 * The flex rules will then pass the FF's through unmolested.  The emit()
 * subroutine is responsible for looking back to the original string and
 * replacing FF's with the corresponding original bytes.
 *
 * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
 * Portions Copyright (c) 1994, Regents of the University of California
 *
 * IDENTIFICATION
 *	  $PostgreSQL: pgsql/src/bin/psql/psqlscan.l,v 1.20 2006/05/31 22:11:44 tgl Exp $
 *
 *-------------------------------------------------------------------------
 */
#include "postgres_fe.h"

#include "psqlscan.h"

#include <ctype.h>

#include "mb/pg_wchar.h"

#include "common.h"
#include "settings.h"
#include "variables.h"


/*
 * We use a stack of flex buffers to handle substitution of psql variables.
 * Each stacked buffer contains the as-yet-unread text from one psql variable.
 * When we pop the stack all the way, we resume reading from the outer buffer
 * identified by scanbufhandle.
 */
typedef struct StackElem
{
	YY_BUFFER_STATE buf;		/* flex input control structure */
	char	   *bufstring;		/* data actually being scanned by flex */
	char	   *origstring;		/* copy of original data, if needed */
	struct StackElem *next;
} StackElem;

/*
 * All working state of the lexer must be stored in PsqlScanStateData
 * between calls.  This allows us to have multiple open lexer operations,
 * which is needed for nested include files.  The lexer itself is not
 * recursive, but it must be re-entrant.
 */
typedef struct PsqlScanStateData
{
	StackElem  *buffer_stack;	/* stack of variable expansion buffers */
	/*
	 * These variables always refer to the outer buffer, never to any
	 * stacked variable-expansion buffer.
	 */
	YY_BUFFER_STATE scanbufhandle;
	char	   *scanbuf;		/* start of outer-level input buffer */
	const char *scanline;		/* current input line at outer level */

	/* safe_encoding, curline, refline are used by emit() to replace FFs */
	int			encoding;		/* encoding being used now */
	bool		safe_encoding;	/* is current encoding "safe"? */
	const char *curline;		/* actual flex input string for cur buf */
	const char *refline;		/* original data for cur buffer */

	/*
	 * All this state lives across successive input lines, until explicitly
	 * reset by psql_scan_reset.
	 */
	int			start_state;	/* saved YY_START */
	int			paren_depth;	/* depth of nesting in parentheses */
	int			xcdepth;		/* depth of nesting in slash-star comments */
	char	   *dolqstart;		/* current $foo$ quote start string */
} PsqlScanStateData;

static PsqlScanState cur_state;	/* current state while active */

static PQExpBuffer output_buf;	/* current output buffer */

/* these variables do not need to be saved across calls */
static enum slash_option_type option_type;
static char *option_quote;


/* Return values from yylex() */
#define LEXRES_EOL			0	/* end of input */
#define LEXRES_SEMI			1	/* command-terminating semicolon found */
#define LEXRES_BACKSLASH	2	/* backslash command start */
#define LEXRES_OK			3	/* OK completion of backslash argument */


int	yylex(void);

static void push_new_buffer(const char *newstr);
static YY_BUFFER_STATE prepare_buffer(const char *txt, int len,
									  char **txtcopy);
static void emit(const char *txt, int len);

#define ECHO emit(yytext, yyleng)

#define YY_NEVER_INTERACTIVE 1
#define YY_NO_UNPUT 1
/*
 * All of the following definitions and rules should exactly match
 * src/backend/parser/scan.l so far as the flex patterns are concerned.
 * The rule bodies are just ECHO as opposed to what the backend does,
 * however.  (But be sure to duplicate code that affects the lexing process,
 * such as BEGIN().)  Also, psqlscan uses a single <<EOF>> rule whereas
 * scan.l has a separate one for each exclusive state.
 */
/*
 * OK, here is a short description of lex/flex rules behavior.
 * The longest pattern which matches an input string is always chosen.
 * For equal-length patterns, the first occurring in the rules list is chosen.
 * INITIAL is the starting state, to which all non-conditional rules apply.
 * Exclusive states change parsing rules while the state is active.  When in
 * an exclusive state, only those rules defined for that state apply.
 *
 * We use exclusive states for quoted strings, extended comments,
 * and to eliminate parsing troubles for numeric strings.
 * Exclusive states:
 *  <xb> bit string literal
 *  <xc> extended C-style comments
 *  <xd> delimited identifiers (double-quoted identifiers)
 *  <xh> hexadecimal numeric string
 *  <xq> standard quoted strings
 *  <xe> extended quoted strings (support backslash escape sequences)
 *  <xdolq> $foo$ quoted strings
 */
#define xb 1

#define xc 2

#define xd 3

#define xh 4

#define xe 5

#define xq 6

#define xdolq 7

/* Additional exclusive states for psql only: lex backslash commands */
#define xslashcmd 8

#define xslasharg 9

#define xslashquote 10

#define xslashbackquote 11

#define xslashdefaultarg 12

#define xslashquotedarg 13

#define xslashwholeline 14

#define xslashend 15

/*
 * In order to make the world safe for Windows and Mac clients as well as
 * Unix ones, we accept either \n or \r as a newline.  A DOS-style \r\n
 * sequence will be seen as two successive newlines, but that doesn't cause
 * any problems.  Comments that start with -- and extend to the next
 * newline are treated as equivalent to a single whitespace character.
 *
 * NOTE a fine point: if there is no newline following --, we will absorb
 * everything to the end of the input as a comment.  This is correct.  Older
 * versions of Postgres failed to recognize -- as a comment if the input
 * did not end with a newline.
 *
 * XXX perhaps \f (formfeed) should be treated as a newline as well?
 */
/*
 * SQL requires at least one newline in the whitespace separating
 * string literals that are to be concatenated.  Silly, but who are we
 * to argue?  Note that {whitespace_with_newline} should not have * after
 * it, whereas {whitespace} should generally have a * after it...
 */
/*
 * To ensure that {quotecontinue} can be scanned without having to back up
 * if the full pattern isn't matched, we include trailing whitespace in
 * {quotestop}.  This matches all cases where {quotecontinue} fails to match,
 * except for {quote} followed by whitespace and just one "-" (not two,
 * which would start a {comment}).  To cover that we have {quotefail}.
 * The actions for {quotestop} and {quotefail} must throw back characters
 * beyond the quote proper.
 */
/* Bit string
 * It is tempting to scan the string for only those characters
 * which are allowed. However, this leads to silently swallowed
 * characters if illegal characters are included in the string.
 * For example, if xbinside is [01] then B'ABCD' is interpreted
 * as a zero-length string, and the ABCD' is lost!
 * Better to pass the string forward and let the input routines
 * validate the contents.
 */
/* Hexadecimal number */
/* National character */
/* Quoted string that allows backslash escapes */
/* Extended quote
 * xqdouble implements embedded quote, ''''
 */
/* $foo$ style quotes ("dollar quoting")
 * The quoted string starts with $foo$ where "foo" is an optional string
 * in the form of an identifier, except that it may not contain "$", 
 * and extends to the first occurrence of an identical string.  
 * There is *no* processing of the quoted text.
 *
 * {dolqfailed} is an error rule to avoid scanner backup when {dolqdelim}
 * fails to match its trailing "$".
 */
/* Double quote
 * Allows embedded spaces and other special characters into identifiers.
 */
/* C-style comments
 *
 * The "extended comment" syntax closely resembles allowable operator syntax.
 * The tricky part here is to get lex to recognize a string starting with
 * slash-star as a comment, when interpreting it as an operator would produce
 * a longer match --- remember lex will prefer a longer match!  Also, if we
 * have something like plus-slash-star, lex will think this is a 3-character
 * operator whereas we want to see it as a + operator and a comment start.
 * The solution is two-fold:
 * 1. append {op_chars}* to xcstart so that it matches as much text as
 *    {operator} would. Then the tie-breaker (first matching rule of same
 *    length) ensures xcstart wins.  We put back the extra stuff with yyless()
 *    in case it contains a star-slash that should terminate the comment.
 * 2. In the operator rule, check for slash-star within the operator, and
 *    if found throw it back with yyless().  This handles the plus-slash-star
 *    problem.
 * Dash-dash comments have similar interactions with the operator rule.
 */
/*
 * "self" is the set of chars that should be returned as single-character
 * tokens.  "op_chars" is the set of chars that can make up "Op" tokens,
 * which can be one or more characters long (but if a single-char token
 * appears in the "self" set, it is not to be returned as an Op).  Note
 * that the sets overlap, but each has some chars that are not in the other.
 *
 * If you change either set, adjust the character lists appearing in the
 * rule for "operator"!
 */
/* we no longer allow unary minus in numbers. 
 * instead we pass it separately to parser. there it gets
 * coerced via doNegate() -- Leon aug 20 1999
 *
 * {realfail1} and {realfail2} are added to prevent the need for scanner
 * backup when the {real} rule fails to match completely.
 */
/*
 * Dollar quoted strings are totally opaque, and no escaping is done on them.
 * Other quoted strings must allow some special characters such as single-quote
 *  and newline.
 * Embedded single-quotes are implemented both in the SQL standard
 *  style of two adjacent single quotes "''" and in the Postgres/Java style
 *  of escaped-quote "\'".
 * Other embedded escaped characters are matched explicitly and the leading
 *  backslash is dropped from the string.
 * Note that xcstart must appear before operator, as explained above!
 *  Also whitespace (comment) must appear before operator.
 */
#line 2297 "psqlscan.c"

/* Macros after this point can all be overridden by user definitions in
 * section 1.
 */

#ifndef YY_SKIP_YYWRAP
#ifdef __cplusplus
extern "C" int yywrap YY_PROTO(( void ));
#else
extern int yywrap YY_PROTO(( void ));
#endif
#endif

#ifndef YY_NO_UNPUT
static void yyunput YY_PROTO(( int c, char *buf_ptr ));
#endif

#ifndef yytext_ptr
static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));
#endif

#ifdef YY_NEED_STRLEN
static int yy_flex_strlen YY_PROTO(( yyconst char * ));
#endif

#ifndef YY_NO_INPUT
#ifdef __cplusplus
static int yyinput YY_PROTO(( void ));
#else
static int input YY_PROTO(( void ));
#endif
#endif

#if YY_STACK_USED
static int yy_start_stack_ptr = 0;
static int yy_start_stack_depth = 0;
static int *yy_start_stack = 0;
#ifndef YY_NO_PUSH_STATE
static void yy_push_state YY_PROTO(( int new_state ));
#endif
#ifndef YY_NO_POP_STATE
static void yy_pop_state YY_PROTO(( void ));
#endif
#ifndef YY_NO_TOP_STATE
static int yy_top_state YY_PROTO(( void ));
#endif

#else
#define YY_NO_PUSH_STATE 1
#define YY_NO_POP_STATE 1
#define YY_NO_TOP_STATE 1
#endif

#ifdef YY_MALLOC_DECL
YY_MALLOC_DECL
#else
#if __STDC__
#ifndef __cplusplus
#include <stdlib.h>
#endif
#else
/* Just try to get by without declaring the routines.  This will fail
 * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
 * or sizeof(void*) != sizeof(int).
 */
#endif
#endif

/* Amount of stuff to slurp up with each read. */
#ifndef YY_READ_BUF_SIZE
#define YY_READ_BUF_SIZE 8192
#endif

/* Copy whatever the last rule matched to the standard output. */

#ifndef ECHO
/* This used to be an fputs(), but since the string might contain NUL's,
 * we now use fwrite().
 */
#define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
#endif

/* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
 * is returned in "result".
 */
#ifndef YY_INPUT
#define YY_INPUT(buf,result,max_size) \
	if ( yy_current_buffer->yy_is_interactive ) \
		{ \
		int c = '*', n; \
		for ( n = 0; n < max_size && \
			     (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
			buf[n] = (char) c; \
		if ( c == '\n' ) \
			buf[n++] = (char) c; \
		if ( c == EOF && ferror( yyin ) ) \
			YY_FATAL_ERROR( "input in flex scanner failed" ); \
		result = n; \
		} \
	else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \
		  && ferror( yyin ) ) \
		YY_FATAL_ERROR( "input in flex scanner failed" );
#endif

/* No semi-colon after return; correct usage is to write "yyterminate();" -
 * we don't want an extra ';' after the "return" because that will cause
 * some compilers to complain about unreachable statements.
 */
#ifndef yyterminate
#define yyterminate() return YY_NULL
#endif

/* Number of entries by which start-condition stack grows. */
#ifndef YY_START_STACK_INCR
#define YY_START_STACK_INCR 25
#endif

/* Report a fatal error. */
#ifndef YY_FATAL_ERROR
#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
#endif

/* Default declaration of generated scanner - a define so the user can
 * easily add parameters.
 */
#ifndef YY_DECL
#define YY_DECL int yylex YY_PROTO(( void ))
#endif

/* Code executed at the beginning of each rule, after yytext and yyleng
 * have been set up.
 */
#ifndef YY_USER_ACTION
#define YY_USER_ACTION
#endif

/* Code executed at the end of each rule. */
#ifndef YY_BREAK
#define YY_BREAK break;
#endif

#define YY_RULE_SETUP \
	YY_USER_ACTION

YY_DECL
	{
	register yy_state_type yy_current_state;
	register char *yy_cp, *yy_bp;
	register int yy_act;

#line 360 "psqlscan.l"


#line 2451 "psqlscan.c"

	if ( yy_init )
		{
		yy_init = 0;

#ifdef YY_USER_INIT
		YY_USER_INIT;
#endif

		if ( ! yy_start )
			yy_start = 1;	/* first start state */

		if ( ! yyin )
			yyin = stdin;

		if ( ! yyout )
			yyout = stdout;

		if ( ! yy_current_buffer )
			yy_current_buffer =
				yy_create_buffer( yyin, YY_BUF_SIZE );

		yy_load_buffer_state();
		}

	while ( 1 )		/* loops until end-of-file is reached */
		{
		yy_cp = yy_c_buf_p;

		/* Support of yytext. */
		*yy_cp = yy_hold_char;

		/* yy_bp points to the position in yy_ch_buf of the start of
		 * the current run.
		 */
		yy_bp = yy_cp;

		yy_current_state = yy_start;
yy_match:
		while ( (yy_current_state = yy_nxt[yy_current_state][yy_ec[YY_SC_TO_UI(*yy_cp)]]) > 0 )
			++yy_cp;

		yy_current_state = -yy_current_state;

yy_find_action:
		yy_act = yy_accept[yy_current_state];

		YY_DO_BEFORE_ACTION;


do_action:	/* This label is used only to access EOF actions. */


		switch ( yy_act )
	{ /* beginning of action switch */
case 1:
YY_RULE_SETUP
#line 362 "psqlscan.l"
{
					/*
					 * Note that the whitespace rule includes both true
					 * whitespace and single-line ("--" style) comments.
					 * We suppress whitespace at the start of the query
					 * buffer.  We also suppress all single-line comments,
					 * which is pretty dubious but is the historical
					 * behavior.
					 */
					if (!(output_buf->len == 0 || yytext[0] == '-'))
						ECHO;
				}
	YY_BREAK
case 2:
YY_RULE_SETUP
#line 375 "psqlscan.l"
{
					cur_state->xcdepth = 0;
					BEGIN(xc);
					/* Put back any characters past slash-star; see above */
					yyless(2);
					ECHO;
				}
	YY_BREAK
case 3:
YY_RULE_SETUP
#line 383 "psqlscan.l"
{
					cur_state->xcdepth++;
					/* Put back any characters past slash-star; see above */
					yyless(2);
					ECHO;
				}
	YY_BREAK
case 4:
YY_RULE_SETUP
#line 390 "psqlscan.l"
{
					if (cur_state->xcdepth <= 0)
					{
						BEGIN(INITIAL);
					}
					else
						cur_state->xcdepth--;
					ECHO;
				}
	YY_BREAK
case 5:
YY_RULE_SETUP
#line 400 "psqlscan.l"
{
					ECHO;
				}
	YY_BREAK
case 6:
YY_RULE_SETUP
#line 404 "psqlscan.l"
{
					ECHO;
				}
	YY_BREAK
case 7:
YY_RULE_SETUP
#line 408 "psqlscan.l"
{
					ECHO;
				}
	YY_BREAK
case 8:
YY_RULE_SETUP
#line 412 "psqlscan.l"
{
					BEGIN(xb);
					ECHO;
				}
	YY_BREAK
case 9:
#line 417 "psqlscan.l"
case 10:
YY_RULE_SETUP
#line 417 "psqlscan.l"
{
					yyless(1);
					BEGIN(INITIAL);
					ECHO;
				}
	YY_BREAK
case 11:
#line 423 "psqlscan.l"
case 12:
YY_RULE_SETUP
#line 423 "psqlscan.l"
{
					ECHO;
				}
	YY_BREAK
case 13:
#line 427 "psqlscan.l"
case 14:
YY_RULE_SETUP
#line 427 "psqlscan.l"
{
					ECHO;
				}
	YY_BREAK
case 15:
YY_RULE_SETUP
#line 431 "psqlscan.l"
{
					/* Hexadecimal bit type.
					 * At some point we should simply pass the string
					 * forward to the parser and label it there.
					 * In the meantime, place a leading "x" on the string
					 * to mark it for the input routine as a hex string.
					 */
					BEGIN(xh);
					ECHO;
				}
	YY_BREAK
case 16:
#line 442 "psqlscan.l"
case 17:
YY_RULE_SETUP
#line 442 "psqlscan.l"
{
					yyless(1);
					BEGIN(INITIAL);
					ECHO;
				}
	YY_BREAK
case 18:
YY_RULE_SETUP
#line 448 "psqlscan.l"
{
					yyless(1);				/* eat only 'n' this time */
					ECHO;
				}
	YY_BREAK
case 19:
YY_RULE_SETUP
#line 453 "psqlscan.l"
{
					if (standard_strings())
						BEGIN(xq);
					else
						BEGIN(xe);
					ECHO;
				}
	YY_BREAK
case 20:
YY_RULE_SETUP
#line 460 "psqlscan.l"
{
					BEGIN(xe);
					ECHO;
				}
	YY_BREAK
case 21:
#line 465 "psqlscan.l"
case 22:
YY_RULE_SETUP
#line 465 "psqlscan.l"
{
					yyless(1);
					BEGIN(INITIAL);
					ECHO;
				}
	YY_BREAK
case 23:
YY_RULE_SETUP
#line 470 "psqlscan.l"
{
					ECHO;
				}
	YY_BREAK
case 24:
YY_RULE_SETUP
#line 473 "psqlscan.l"
{
					ECHO;
				}
	YY_BREAK
case 25:
YY_RULE_SETUP
#line 476 "psqlscan.l"
{
					ECHO;
				}
	YY_BREAK
case 26:
YY_RULE_SETUP
#line 479 "psqlscan.l"
{
					ECHO;
				}
	YY_BREAK
case 27:
YY_RULE_SETUP
#line 482 "psqlscan.l"
{
					ECHO;
				}
	YY_BREAK
case 28:
YY_RULE_SETUP
#line 485 "psqlscan.l"
{
					ECHO;
				}
	YY_BREAK
case 29:
YY_RULE_SETUP
#line 488 "psqlscan.l"
{
					ECHO;
				}
	YY_BREAK
case 30:
YY_RULE_SETUP
#line 491 "psqlscan.l"
{
					/* This is only needed for \ just before EOF */
					ECHO;
				}
	YY_BREAK
case 31:
YY_RULE_SETUP
#line 496 "psqlscan.l"
{
					cur_state->dolqstart = pg_strdup(yytext);
					BEGIN(xdolq);
					ECHO;
				}
	YY_BREAK
case 32:
YY_RULE_SETUP
#line 501 "psqlscan.l"
{
					/* throw back all but the initial "$" */
					yyless(1);
					ECHO;
				}
	YY_BREAK
case 33:
YY_RULE_SETUP
#line 506 "psqlscan.l"
{
					if (strcmp(yytext, cur_state->dolqstart) == 0)
					{
						free(cur_state->dolqstart);
						cur_state->dolqstart = NULL;
						BEGIN(INITIAL);
					}
					else
					{
						/*
						 * When we fail to match $...$ to dolqstart, transfer
						 * the $... part to the output, but put back the final
						 * $ for rescanning.  Consider $delim$...$junk$delim$
						 */
						yyless(yyleng-1);
					}
					ECHO;
				}
	YY_BREAK
case 34:
YY_RULE_SETUP
#line 524 "psqlscan.l"
{
					ECHO;
				}
	YY_BREAK
case 35:
YY_RULE_SETUP
#line 527 "psqlscan.l"
{
					ECHO;
				}
	YY_BREAK
case 36:
YY_RULE_SETUP
#line 530 "psqlscan.l"
{
					/* This is only needed for $ inside the quoted text */
					ECHO;
				}
	YY_BREAK
case 37:
YY_RULE_SETUP
#line 535 "psqlscan.l"
{
					BEGIN(xd);
					ECHO;
				}
	YY_BREAK
case 38:
YY_RULE_SETUP
#line 539 "psqlscan.l"
{
					BEGIN(INITIAL);
					ECHO;
				}
	YY_BREAK
case 39:
YY_RULE_SETUP
#line 543 "psqlscan.l"
{
					ECHO;
				}
	YY_BREAK
case 40:
YY_RULE_SETUP
#line 546 "psqlscan.l"
{
					ECHO;
				}
	YY_BREAK
case 41:
YY_RULE_SETUP
#line 550 "psqlscan.l"
{
					ECHO;
				}
	YY_BREAK
/*
	 * These rules are specific to psql --- they implement parenthesis
	 * counting and detection of command-ending semicolon.  These must
	 * appear before the {self} rule so that they take precedence over it.
	 */
case 42:
YY_RULE_SETUP
#line 560 "psqlscan.l"
{
					cur_state->paren_depth++;
					ECHO;
				}
	YY_BREAK
case 43:
YY_RULE_SETUP
#line 565 "psqlscan.l"
{
					if (cur_state->paren_depth > 0)
						cur_state->paren_depth--;
					ECHO;
				}
	YY_BREAK
case 44:
YY_RULE_SETUP
#line 571 "psqlscan.l"
{
					ECHO;
					if (cur_state->paren_depth == 0)
					{
						/* Terminate lexing temporarily */
						return LEXRES_SEMI;
					}
				}
	YY_BREAK
/*
	 * psql-specific rules to handle backslash commands and variable
	 * substitution.  We want these before {self}, also.
	 */
case 45:
YY_RULE_SETUP
#line 585 "psqlscan.l"
{
					/* Force a semicolon or colon into the query buffer */
					emit(yytext + 1, 1);
				}
	YY_BREAK
case 46:
YY_RULE_SETUP
#line 590 "psqlscan.l"
{
					/* Terminate lexing temporarily */
					return LEXRES_BACKSLASH;
				}
	YY_BREAK
case 47:
YY_RULE_SETUP
#line 595 "psqlscan.l"
{
					/* Possible psql variable substitution */
					const char *value;

					value = GetVariable(pset.vars, yytext + 1);

					if (value)
					{
						/* It is a variable, perform substitution */
						push_new_buffer(value);
						/* yy_scan_string already made buffer active */
					}
					else
					{
						/*
						 * if the variable doesn't exist we'll copy the
						 * string as is
						 */
						ECHO;
					}
				}
	YY_BREAK
/*
	 * Back to backend-compatible rules.
	 */
case 48:
YY_RULE_SETUP
#line 621 "psqlscan.l"
{
					ECHO;
				}
	YY_BREAK
case 49:
YY_RULE_SETUP
#line 625 "psqlscan.l"
{
					/*
					 * Check for embedded slash-star or dash-dash; those
					 * are comment starts, so operator must stop there.
					 * Note that slash-star or dash-dash at the first
					 * character will match a prior rule, not this one.
					 */
					int		nchars = yyleng;
					char   *slashstar = strstr(yytext, "/*");
					char   *dashdash = strstr(yytext, "--");

					if (slashstar && dashdash)
					{
						/* if both appear, take the first one */
						if (slashstar > dashdash)
							slashstar = dashdash;
					}
					else if (!slashstar)
						slashstar = dashdash;
					if (slashstar)
						nchars = slashstar - yytext;

					/*
					 * For SQL compatibility, '+' and '-' cannot be the
					 * last char of a multi-char operator unless the operator
					 * contains chars that are not in SQL operators.
					 * The idea is to lex '=-' as two operators, but not
					 * to forbid operator names like '?-' that could not be
					 * sequences of SQL operators.
					 */
					while (nchars > 1 &&
						   (yytext[nchars-1] == '+' ||
							yytext[nchars-1] == '-'))
					{
						int		ic;

						for (ic = nchars-2; ic >= 0; ic--)
						{
							if (strchr("~!@#^&|`?%", yytext[ic]))
								break;
						}
						if (ic >= 0)
							break; /* found a char that makes it OK */
						nchars--; /* else remove the +/-, and check again */
					}

					if (nchars < yyleng)
					{
						/* Strip the unwanted chars from the token */
						yyless(nchars);
					}
					ECHO;
				}
	YY_BREAK
case 50:
YY_RULE_SETUP
#line 679 "psqlscan.l"
{
					ECHO;
				}
	YY_BREAK
case 51:
YY_RULE_SETUP
#line 683 "psqlscan.l"
{
					ECHO;
				}
	YY_BREAK
case 52:
YY_RULE_SETUP
#line 686 "psqlscan.l"
{
					ECHO;
				}
	YY_BREAK
case 53:
YY_RULE_SETUP
#line 689 "psqlscan.l"
{
					ECHO;
				}
	YY_BREAK
case 54:
YY_RULE_SETUP
#line 692 "psqlscan.l"
{
					/*
					 * throw back the [Ee], and treat as {decimal}.  Note
					 * that it is possible the input is actually {integer},
					 * but since this case will almost certainly lead to a
					 * syntax error anyway, we don't bother to distinguish.
					 */
					yyless(yyleng-1);
					ECHO;
				}
	YY_BREAK
case 55:
YY_RULE_SETUP
#line 702 "psqlscan.l"
{
					/* throw back the [Ee][+-], and proceed as above */
					yyless(yyleng-2);
					ECHO;
				}
	YY_BREAK
case 56:
YY_RULE_SETUP
#line 709 "psqlscan.l"
{
					ECHO;
				}
	YY_BREAK
case 57:
YY_RULE_SETUP
#line 713 "psqlscan.l"
{
					ECHO;
				}
	YY_BREAK
/*
	 * Everything from here down is psql-specific.
	 */
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(xb):
case YY_STATE_EOF(xc):
case YY_STATE_EOF(xd):
case YY_STATE_EOF(xh):
case YY_STATE_EOF(xe):
case YY_STATE_EOF(xq):
case YY_STATE_EOF(xdolq):
case YY_STATE_EOF(xslashcmd):
case YY_STATE_EOF(xslasharg):
case YY_STATE_EOF(xslashquote):
case YY_STATE_EOF(xslashbackquote):
case YY_STATE_EOF(xslashdefaultarg):
case YY_STATE_EOF(xslashquotedarg):
case YY_STATE_EOF(xslashwholeline):
case YY_STATE_EOF(xslashend):
#line 722 "psqlscan.l"
{
					StackElem  *stackelem = cur_state->buffer_stack;

					if (stackelem == NULL)
						return LEXRES_EOL; /* end of input reached */

					/*
					 * We were expanding a variable, so pop the inclusion
					 * stack and keep lexing
					 */
					cur_state->buffer_stack = stackelem->next;
					yy_delete_buffer(stackelem->buf);
					free(stackelem->bufstring);
					if (stackelem->origstring)
						free(stackelem->origstring);
					free(stackelem);

					stackelem = cur_state->buffer_stack;
					if (stackelem != NULL)
					{
						yy_switch_to_buffer(stackelem->buf);
						cur_state->curline = stackelem->bufstring;
						cur_state->refline = stackelem->origstring ? stackelem->origstring : stackelem->bufstring;
					}
					else
					{
						yy_switch_to_buffer(cur_state->scanbufhandle);
						cur_state->curline = cur_state->scanbuf;
						cur_state->refline = cur_state->scanline;
					}
				}
	YY_BREAK
/*
	 * Exclusive lexer states to handle backslash command lexing
	 */

/* command name ends at whitespace or backslash; eat all else */
case 58:
YY_RULE_SETUP
#line 761 "psqlscan.l"
{
					yyless(0);
					return LEXRES_OK;
				}
	YY_BREAK
case 59:
YY_RULE_SETUP
#line 766 "psqlscan.l"
{ ECHO; }
	YY_BREAK


/* eat any whitespace, then decide what to do at first nonblank */
case 60:
YY_RULE_SETUP
#line 773 "psqlscan.l"
{ }
	YY_BREAK
case 61:
YY_RULE_SETUP
#line 775 "psqlscan.l"
{
					/*
					 * backslash is end of command or next command, do not eat
					 *
					 * XXX this means we can't conveniently accept options
					 * that start with a backslash; therefore, option
					 * processing that encourages use of backslashes is rather
					 * broken.
					 */
					yyless(0);
					return LEXRES_OK;
				}
	YY_BREAK
case 62:
YY_RULE_SETUP
#line 788 "psqlscan.l"
{
					*option_quote = '\'';
					BEGIN(xslashquote);
				}
	YY_BREAK
case 63:
YY_RULE_SETUP
#line 793 "psqlscan.l"
{
					if (option_type == OT_VERBATIM)
					{
						/* in verbatim mode, backquote is not special */
						ECHO;
						BEGIN(xslashdefaultarg);
					}
					else
					{
						*option_quote = '`';
						BEGIN(xslashbackquote);
					}
				}
	YY_BREAK
case 64:
YY_RULE_SETUP
#line 807 "psqlscan.l"
{
					/* Possible psql variable substitution */
					if (option_type == OT_VERBATIM)
						ECHO;
					else
					{
						const char *value;

						value = GetVariable(pset.vars, yytext + 1);

						/*
						 * The variable value is just emitted without any
						 * further examination.  This is consistent with the
						 * pre-8.0 code behavior, if not with the way that
						 * variables are handled outside backslash commands.
						 */
						if (value)
							appendPQExpBufferStr(output_buf, value);
					}

					*option_quote = ':';

					return LEXRES_OK;
				}
	YY_BREAK
case 65:
YY_RULE_SETUP
#line 832 "psqlscan.l"
{
					ECHO;
					if (option_type == OT_FILEPIPE)
					{
						/* treat like whole-string case */
						BEGIN(xslashwholeline);
					}
					else
					{
						/* treat like default case */
						BEGIN(xslashdefaultarg);
					}
				}
	YY_BREAK
case 66:
YY_RULE_SETUP
#line 846 "psqlscan.l"
{
					*option_quote = '"';
					ECHO;
					BEGIN(xslashquotedarg);
				}
	YY_BREAK
case 67:
YY_RULE_SETUP
#line 852 "psqlscan.l"
{
					ECHO;
					BEGIN(xslashdefaultarg);
				}
	YY_BREAK


/*
	 * single-quoted text: copy literally except for '' and backslash
	 * sequences
	 */
case 68:
YY_RULE_SETUP
#line 865 "psqlscan.l"
{ return LEXRES_OK; }
	YY_BREAK
case 69:
YY_RULE_SETUP
#line 867 "psqlscan.l"
{ appendPQExpBufferChar(output_buf, '\''); }
	YY_BREAK
case 70:
YY_RULE_SETUP
#line 869 "psqlscan.l"
{ appendPQExpBufferChar(output_buf, '\n'); }
	YY_BREAK
case 71:
YY_RULE_SETUP
#line 870 "psqlscan.l"
{ appendPQExpBufferChar(output_buf, '\t'); }
	YY_BREAK
case 72:
YY_RULE_SETUP
#line 871 "psqlscan.l"
{ appendPQExpBufferChar(output_buf, '\b'); }
	YY_BREAK
case 73:
YY_RULE_SETUP
#line 872 "psqlscan.l"
{ appendPQExpBufferChar(output_buf, '\r'); }
	YY_BREAK
case 74:
YY_RULE_SETUP
#line 873 "psqlscan.l"
{ appendPQExpBufferChar(output_buf, '\f'); }
	YY_BREAK
case 75:
YY_RULE_SETUP
#line 875 "psqlscan.l"
{
					/* octal case */
					appendPQExpBufferChar(output_buf,
										  (char) strtol(yytext + 1, NULL, 8));
				}
	YY_BREAK
case 76:
YY_RULE_SETUP
#line 881 "psqlscan.l"
{
					/* hex case */
					appendPQExpBufferChar(output_buf,
										  (char) strtol(yytext + 2, NULL, 16));
				}
	YY_BREAK
case 77:
YY_RULE_SETUP
#line 887 "psqlscan.l"
{ emit(yytext + 1, 1); }
	YY_BREAK
case 78:
YY_RULE_SETUP
#line 889 "psqlscan.l"
{ ECHO; }
	YY_BREAK


/*
	 * backticked text: copy everything until next backquote or end of line.
	 * Invocation of the command will happen in psql_scan_slash_option.
	 */
case 79:
YY_RULE_SETUP
#line 899 "psqlscan.l"
{ return LEXRES_OK; }
	YY_BREAK
case 80:
YY_RULE_SETUP
#line 901 "psqlscan.l"
{ ECHO; }
	YY_BREAK


/*
	 * Copy everything until unquoted whitespace or end of line.  Quotes
	 * do not get stripped yet.
	 */
case 81:
YY_RULE_SETUP
#line 911 "psqlscan.l"
{
					yyless(0);
					return LEXRES_OK;
				}
	YY_BREAK
case 82:
YY_RULE_SETUP
#line 916 "psqlscan.l"
{
					/*
					 * unquoted backslash is end of command or next command,
					 * do not eat
					 *
					 * (this was not the behavior pre-8.0, but it seems
					 * consistent)
					 */
					yyless(0);
					return LEXRES_OK;
				}
	YY_BREAK
case 83:
YY_RULE_SETUP
#line 928 "psqlscan.l"
{
					*option_quote = '"';
					ECHO;
					BEGIN(xslashquotedarg);
				}
	YY_BREAK
case 84:
YY_RULE_SETUP
#line 934 "psqlscan.l"
{ ECHO; }
	YY_BREAK


/* double-quoted text within a default-type argument: copy */
case 85:
YY_RULE_SETUP
#line 941 "psqlscan.l"
{
					ECHO;
					BEGIN(xslashdefaultarg);
				}
	YY_BREAK
case 86:
YY_RULE_SETUP
#line 946 "psqlscan.l"
{ ECHO; }
	YY_BREAK


/* copy everything until end of input line */
/* but suppress leading whitespace */
case 87:
YY_RULE_SETUP
#line 954 "psqlscan.l"
{
					if (output_buf->len > 0)
						ECHO;
				}
	YY_BREAK
case 88:
YY_RULE_SETUP
#line 959 "psqlscan.l"
{ ECHO; }
	YY_BREAK


/* at end of command, eat a double backslash, but not anything else */
case 89:
YY_RULE_SETUP
#line 966 "psqlscan.l"
{ return LEXRES_OK; }
	YY_BREAK
case 90:
YY_RULE_SETUP
#line 968 "psqlscan.l"
{
					yyless(0);
					return LEXRES_OK;
				}
	YY_BREAK

case 91:
YY_RULE_SETUP
#line 975 "psqlscan.l"
YY_FATAL_ERROR( "flex scanner jammed" );
	YY_BREAK
#line 3409 "psqlscan.c"

	case YY_END_OF_BUFFER:
		{
		/* Amount of text matched not including the EOB char. */
		int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1;

		/* Undo the effects of YY_DO_BEFORE_ACTION. */
		*yy_cp = yy_hold_char;
		YY_RESTORE_YY_MORE_OFFSET

		if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
			{
			/* We're scanning a new file or input source.  It's
			 * possible that this happened because the user
			 * just pointed yyin at a new source and called
			 * yylex().  If so, then we have to assure
			 * consistency between yy_current_buffer and our
			 * globals.  Here is the right place to do so, because
			 * this is the first action (other than possibly a
			 * back-up) that will match for the new input source.
			 */
			yy_n_chars = yy_current_buffer->yy_n_chars;
			yy_current_buffer->yy_input_file = yyin;
			yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL;
			}

		/* Note that here we test for yy_c_buf_p "<=" to the position
		 * of the first EOB in the buffer, since yy_c_buf_p will
		 * already have been incremented past the NUL character
		 * (since all states make transitions on EOB to the
		 * end-of-buffer state).  Contrast this with the test
		 * in input().
		 */
		if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
			{ /* This was really a NUL. */
			yy_state_type yy_next_state;

			yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;

			yy_current_state = yy_get_previous_state();

			/* Okay, we're now positioned to make the NUL
			 * transition.  We couldn't have
			 * yy_get_previous_state() go ahead and do it
			 * for us because it doesn't know how to deal
			 * with the possibility of jamming (and we don't
			 * want to build jamming into it because then it
			 * will run more slowly).
			 */

			yy_next_state = yy_try_NUL_trans( yy_current_state );

			yy_bp = yytext_ptr + YY_MORE_ADJ;

			if ( yy_next_state )
				{
				/* Consume the NUL. */
				yy_cp = ++yy_c_buf_p;
				yy_current_state = yy_next_state;
				goto yy_match;
				}

			else
				{
				yy_cp = yy_c_buf_p;
				goto yy_find_action;
				}
			}

		else switch ( yy_get_next_buffer() )
			{
			case EOB_ACT_END_OF_FILE:
				{
				yy_did_buffer_switch_on_eof = 0;

				if ( yywrap() )
					{
					/* Note: because we've taken care in
					 * yy_get_next_buffer() to have set up
					 * yytext, we can now set up
					 * yy_c_buf_p so that if some total
					 * hoser (like flex itself) wants to
					 * call the scanner after we return the
					 * YY_NULL, it'll still work - another
					 * YY_NULL will get returned.
					 */
					yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;

					yy_act = YY_STATE_EOF(YY_START);
					goto do_action;
					}

				else
					{
					if ( ! yy_did_buffer_switch_on_eof )
						YY_NEW_FILE;
					}
				break;
				}

			case EOB_ACT_CONTINUE_SCAN:
				yy_c_buf_p =
					yytext_ptr + yy_amount_of_matched_text;

				yy_current_state = yy_get_previous_state();

				yy_cp = yy_c_buf_p;
				yy_bp = yytext_ptr + YY_MORE_ADJ;
				goto yy_match;

			case EOB_ACT_LAST_MATCH:
				yy_c_buf_p =
				&yy_current_buffer->yy_ch_buf[yy_n_chars];

				yy_current_state = yy_get_previous_state();

				yy_cp = yy_c_buf_p;
				yy_bp = yytext_ptr + YY_MORE_ADJ;
				goto yy_find_action;
			}
		break;
		}

	default:
		YY_FATAL_ERROR(
			"fatal flex scanner internal error--no action found" );
	} /* end of action switch */
		} /* end of scanning one token */
	} /* end of yylex */


/* yy_get_next_buffer - try to read in a new buffer
 *
 * Returns a code representing an action:
 *	EOB_ACT_LAST_MATCH -
 *	EOB_ACT_CONTINUE_SCAN - continue scanning from current position
 *	EOB_ACT_END_OF_FILE - end of file
 */

static int yy_get_next_buffer()
	{
	register char *dest = yy_current_buffer->yy_ch_buf;
	register char *source = yytext_ptr;
	register int number_to_move, i;
	int ret_val;

	if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
		YY_FATAL_ERROR(
		"fatal flex scanner internal error--end of buffer missed" );

	if ( yy_current_buffer->yy_fill_buffer == 0 )
		{ /* Don't try to fill the buffer, so this is an EOF. */
		if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )
			{
			/* We matched a single character, the EOB, so
			 * treat this as a final EOF.
			 */
			return EOB_ACT_END_OF_FILE;
			}

		else
			{
			/* We matched some text prior to the EOB, first
			 * process it.
			 */
			return EOB_ACT_LAST_MATCH;
			}
		}

	/* Try to read more data. */

	/* First move last chars to start of buffer. */
	number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1;

	for ( i = 0; i < number_to_move; ++i )
		*(dest++) = *(source++);

	if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING )
		/* don't do the read, it's not guaranteed to return an EOF,
		 * just force an EOF
		 */
		yy_current_buffer->yy_n_chars = yy_n_chars = 0;

	else
		{
		int num_to_read =
			yy_current_buffer->yy_buf_size - number_to_move - 1;

		while ( num_to_read <= 0 )
			{ /* Not enough room in the buffer - grow it. */
#ifdef YY_USES_REJECT
			YY_FATAL_ERROR(
"input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
#else

			/* just a shorter name for the current buffer */
			YY_BUFFER_STATE b = yy_current_buffer;

			int yy_c_buf_p_offset =
				(int) (yy_c_buf_p - b->yy_ch_buf);

			if ( b->yy_is_our_buffer )
				{
				int new_size = b->yy_buf_size * 2;

				if ( new_size <= 0 )
					b->yy_buf_size += b->yy_buf_size / 8;
				else
					b->yy_buf_size *= 2;

				b->yy_ch_buf = (char *)
					/* Include room in for 2 EOB chars. */
					yy_flex_realloc( (void *) b->yy_ch_buf,
							 b->yy_buf_size + 2 );
				}
			else
				/* Can't grow it, we don't own it. */
				b->yy_ch_buf = 0;

			if ( ! b->yy_ch_buf )
				YY_FATAL_ERROR(
				"fatal error - scanner input buffer overflow" );

			yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];

			num_to_read = yy_current_buffer->yy_buf_size -
						number_to_move - 1;
#endif
			}

		if ( num_to_read > YY_READ_BUF_SIZE )
			num_to_read = YY_READ_BUF_SIZE;

		/* Read in more data. */
		YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
			yy_n_chars, num_to_read );

		yy_current_buffer->yy_n_chars = yy_n_chars;
		}

	if ( yy_n_chars == 0 )
		{
		if ( number_to_move == YY_MORE_ADJ )
			{
			ret_val = EOB_ACT_END_OF_FILE;
			yyrestart( yyin );
			}

		else
			{
			ret_val = EOB_ACT_LAST_MATCH;
			yy_current_buffer->yy_buffer_status =
				YY_BUFFER_EOF_PENDING;
			}
		}

	else
		ret_val = EOB_ACT_CONTINUE_SCAN;

	yy_n_chars += number_to_move;
	yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
	yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;

	yytext_ptr = &yy_current_buffer->yy_ch_buf[0];

	return ret_val;
	}


/* yy_get_previous_state - get the state just before the EOB char was reached */

static yy_state_type yy_get_previous_state()
	{
	register yy_state_type yy_current_state;
	register char *yy_cp;

	yy_current_state = yy_start;

	for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
		{
		yy_current_state = yy_nxt[yy_current_state][(*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1)];
		}

	return yy_current_state;
	}


/* yy_try_NUL_trans - try to make a transition on the NUL character
 *
 * synopsis
 *	next_state = yy_try_NUL_trans( current_state );
 */

#ifdef YY_USE_PROTOS
static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state )
#else
static yy_state_type yy_try_NUL_trans( yy_current_state )
yy_state_type yy_current_state;
#endif
	{
	register int yy_is_jam;

	yy_current_state = yy_nxt[yy_current_state][1];
	yy_is_jam = (yy_current_state <= 0);

	return yy_is_jam ? 0 : yy_current_state;
	}


#ifndef YY_NO_UNPUT
#ifdef YY_USE_PROTOS
static void yyunput( int c, register char *yy_bp )
#else
static void yyunput( c, yy_bp )
int c;
register char *yy_bp;
#endif
	{
	register char *yy_cp = yy_c_buf_p;

	/* undo effects of setting up yytext */
	*yy_cp = yy_hold_char;

	if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
		{ /* need to shift things up to make room */
		/* +2 for EOB chars. */
		register int number_to_move = yy_n_chars + 2;
		register char *dest = &yy_current_buffer->yy_ch_buf[
					yy_current_buffer->yy_buf_size + 2];
		register char *source =
				&yy_current_buffer->yy_ch_buf[number_to_move];

		while ( source > yy_current_buffer->yy_ch_buf )
			*--dest = *--source;

		yy_cp += (int) (dest - source);
		yy_bp += (int) (dest - source);
		yy_current_buffer->yy_n_chars =
			yy_n_chars = yy_current_buffer->yy_buf_size;

		if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
			YY_FATAL_ERROR( "flex scanner push-back overflow" );
		}

	*--yy_cp = (char) c;


	yytext_ptr = yy_bp;
	yy_hold_char = *yy_cp;
	yy_c_buf_p = yy_cp;
	}
#endif	/* ifndef YY_NO_UNPUT */


#ifdef __cplusplus
static int yyinput()
#else
static int input()
#endif
	{
	int c;

	*yy_c_buf_p = yy_hold_char;

	if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
		{
		/* yy_c_buf_p now points to the character we want to return.
		 * If this occurs *before* the EOB characters, then it's a
		 * valid NUL; if not, then we've hit the end of the buffer.
		 */
		if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
			/* This was really a NUL. */
			*yy_c_buf_p = '\0';

		else
			{ /* need more input */
			int offset = yy_c_buf_p - yytext_ptr;
			++yy_c_buf_p;

			switch ( yy_get_next_buffer() )
				{
				case EOB_ACT_LAST_MATCH:
					/* This happens because yy_g_n_b()
					 * sees that we've accumulated a
					 * token and flags that we need to
					 * try matching the token before
					 * proceeding.  But for input(),
					 * there's no matching to consider.
					 * So convert the EOB_ACT_LAST_MATCH
					 * to EOB_ACT_END_OF_FILE.
					 */

					/* Reset buffer status. */
					yyrestart( yyin );

					/* fall through */

				case EOB_ACT_END_OF_FILE:
					{
					if ( yywrap() )
						return EOF;

					if ( ! yy_did_buffer_switch_on_eof )
						YY_NEW_FILE;
#ifdef __cplusplus
					return yyinput();
#else
					return input();
#endif
					}

				case EOB_ACT_CONTINUE_SCAN:
					yy_c_buf_p = yytext_ptr + offset;
					break;
				}
			}
		}

	c = *(unsigned char *) yy_c_buf_p;	/* cast for 8-bit char's */
	*yy_c_buf_p = '\0';	/* preserve yytext */
	yy_hold_char = *++yy_c_buf_p;


	return c;
	}


#ifdef YY_USE_PROTOS
void yyrestart( FILE *input_file )
#else
void yyrestart( input_file )
FILE *input_file;
#endif
	{
	if ( ! yy_current_buffer )
		yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );

	yy_init_buffer( yy_current_buffer, input_file );
	yy_load_buffer_state();
	}


#ifdef YY_USE_PROTOS
void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
#else
void yy_switch_to_buffer( new_buffer )
YY_BUFFER_STATE new_buffer;
#endif
	{
	if ( yy_current_buffer == new_buffer )
		return;

	if ( yy_current_buffer )
		{
		/* Flush out information for old buffer. */
		*yy_c_buf_p = yy_hold_char;
		yy_current_buffer->yy_buf_pos = yy_c_buf_p;
		yy_current_buffer->yy_n_chars = yy_n_chars;
		}

	yy_current_buffer = new_buffer;
	yy_load_buffer_state();

	/* We don't actually know whether we did this switch during
	 * EOF (yywrap()) processing, but the only time this flag
	 * is looked at is after yywrap() is called, so it's safe
	 * to go ahead and always set it.
	 */
	yy_did_buffer_switch_on_eof = 1;
	}


#ifdef YY_USE_PROTOS
void yy_load_buffer_state( void )
#else
void yy_load_buffer_state()
#endif
	{
	yy_n_chars = yy_current_buffer->yy_n_chars;
	yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
	yyin = yy_current_buffer->yy_input_file;
	yy_hold_char = *yy_c_buf_p;
	}


#ifdef YY_USE_PROTOS
YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
#else
YY_BUFFER_STATE yy_create_buffer( file, size )
FILE *file;
int size;
#endif
	{
	YY_BUFFER_STATE b;

	b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
	if ( ! b )
		YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );

	b->yy_buf_size = size;

	/* yy_ch_buf has to be 2 characters longer than the size given because
	 * we need to put in 2 end-of-buffer characters.
	 */
	b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 );
	if ( ! b->yy_ch_buf )
		YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );

	b->yy_is_our_buffer = 1;

	yy_init_buffer( b, file );

	return b;
	}


#ifdef YY_USE_PROTOS
void yy_delete_buffer( YY_BUFFER_STATE b )
#else
void yy_delete_buffer( b )
YY_BUFFER_STATE b;
#endif
	{
	if ( ! b )
		return;

	if ( b == yy_current_buffer )
		yy_current_buffer = (YY_BUFFER_STATE) 0;

	if ( b->yy_is_our_buffer )
		yy_flex_free( (void *) b->yy_ch_buf );

	yy_flex_free( (void *) b );
	}


#ifndef YY_ALWAYS_INTERACTIVE
#ifndef YY_NEVER_INTERACTIVE
extern int isatty YY_PROTO(( int ));
#endif
#endif

#ifdef YY_USE_PROTOS
void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
#else
void yy_init_buffer( b, file )
YY_BUFFER_STATE b;
FILE *file;
#endif


	{
	yy_flush_buffer( b );

	b->yy_input_file = file;
	b->yy_fill_buffer = 1;

#if YY_ALWAYS_INTERACTIVE
	b->yy_is_interactive = 1;
#else
#if YY_NEVER_INTERACTIVE
	b->yy_is_interactive = 0;
#else
	b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
#endif
#endif
	}


#ifdef YY_USE_PROTOS
void yy_flush_buffer( YY_BUFFER_STATE b )
#else
void yy_flush_buffer( b )
YY_BUFFER_STATE b;
#endif

	{
	if ( ! b )
		return;

	b->yy_n_chars = 0;

	/* We always need two end-of-buffer characters.  The first causes
	 * a transition to the end-of-buffer state.  The second causes
	 * a jam in that state.
	 */
	b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
	b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;

	b->yy_buf_pos = &b->yy_ch_buf[0];

	b->yy_at_bol = 1;
	b->yy_buffer_status = YY_BUFFER_NEW;

	if ( b == yy_current_buffer )
		yy_load_buffer_state();
	}


#ifndef YY_NO_SCAN_BUFFER
#ifdef YY_USE_PROTOS
YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )
#else
YY_BUFFER_STATE yy_scan_buffer( base, size )
char *base;
yy_size_t size;
#endif
	{
	YY_BUFFER_STATE b;

	if ( size < 2 ||
	     base[size-2] != YY_END_OF_BUFFER_CHAR ||
	     base[size-1] != YY_END_OF_BUFFER_CHAR )
		/* They forgot to leave room for the EOB's. */
		return 0;

	b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
	if ( ! b )
		YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );

	b->yy_buf_size = size - 2;	/* "- 2" to take care of EOB's */
	b->yy_buf_pos = b->yy_ch_buf = base;
	b->yy_is_our_buffer = 0;
	b->yy_input_file = 0;
	b->yy_n_chars = b->yy_buf_size;
	b->yy_is_interactive = 0;
	b->yy_at_bol = 1;
	b->yy_fill_buffer = 0;
	b->yy_buffer_status = YY_BUFFER_NEW;

	yy_switch_to_buffer( b );

	return b;
	}
#endif


#ifndef YY_NO_SCAN_STRING
#ifdef YY_USE_PROTOS
YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str )
#else
YY_BUFFER_STATE yy_scan_string( yy_str )
yyconst char *yy_str;
#endif
	{
	int len;
	for ( len = 0; yy_str[len]; ++len )
		;

	return yy_scan_bytes( yy_str, len );
	}
#endif


#ifndef YY_NO_SCAN_BYTES
#ifdef YY_USE_PROTOS
YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len )
#else
YY_BUFFER_STATE yy_scan_bytes( bytes, len )
yyconst char *bytes;
int len;
#endif
	{
	YY_BUFFER_STATE b;
	char *buf;
	yy_size_t n;
	int i;

	/* Get memory for full buffer, including space for trailing EOB's. */
	n = len + 2;
	buf = (char *) yy_flex_alloc( n );
	if ( ! buf )
		YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );

	for ( i = 0; i < len; ++i )
		buf[i] = bytes[i];

	buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;

	b = yy_scan_buffer( buf, n );
	if ( ! b )
		YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );

	/* It's okay to grow etc. this buffer, and we should throw it
	 * away when we're done.
	 */
	b->yy_is_our_buffer = 1;

	return b;
	}
#endif


#ifndef YY_NO_PUSH_STATE
#ifdef YY_USE_PROTOS
static void yy_push_state( int new_state )
#else
static void yy_push_state( new_state )
int new_state;
#endif
	{
	if ( yy_start_stack_ptr >= yy_start_stack_depth )
		{
		yy_size_t new_size;

		yy_start_stack_depth += YY_START_STACK_INCR;
		new_size = yy_start_stack_depth * sizeof( int );

		if ( ! yy_start_stack )
			yy_start_stack = (int *) yy_flex_alloc( new_size );

		else
			yy_start_stack = (int *) yy_flex_realloc(
					(void *) yy_start_stack, new_size );

		if ( ! yy_start_stack )
			YY_FATAL_ERROR(
			"out of memory expanding start-condition stack" );
		}

	yy_start_stack[yy_start_stack_ptr++] = YY_START;

	BEGIN(new_state);
	}
#endif


#ifndef YY_NO_POP_STATE
static void yy_pop_state()
	{
	if ( --yy_start_stack_ptr < 0 )
		YY_FATAL_ERROR( "start-condition stack underflow" );

	BEGIN(yy_start_stack[yy_start_stack_ptr]);
	}
#endif


#ifndef YY_NO_TOP_STATE
static int yy_top_state()
	{
	return yy_start_stack[yy_start_stack_ptr - 1];
	}
#endif

#ifndef YY_EXIT_FAILURE
#define YY_EXIT_FAILURE 2
#endif

#ifdef YY_USE_PROTOS
static void yy_fatal_error( yyconst char msg[] )
#else
static void yy_fatal_error( msg )
char msg[];
#endif
	{
	(void) fprintf( stderr, "%s\n", msg );
	exit( YY_EXIT_FAILURE );
	}



/* Redefine yyless() so it works in section 3 code. */

#undef yyless
#define yyless(n) \
	do \
		{ \
		/* Undo effects of setting up yytext. */ \
		yytext[yyleng] = yy_hold_char; \
		yy_c_buf_p = yytext + n; \
		yy_hold_char = *yy_c_buf_p; \
		*yy_c_buf_p = '\0'; \
		yyleng = n; \
		} \
	while ( 0 )


/* Internal utility routines. */

#ifndef yytext_ptr
#ifdef YY_USE_PROTOS
static void yy_flex_strncpy( char *s1, yyconst char *s2, int n )
#else
static void yy_flex_strncpy( s1, s2, n )
char *s1;
yyconst char *s2;
int n;
#endif
	{
	register int i;
	for ( i = 0; i < n; ++i )
		s1[i] = s2[i];
	}
#endif

#ifdef YY_NEED_STRLEN
#ifdef YY_USE_PROTOS
static int yy_flex_strlen( yyconst char *s )
#else
static int yy_flex_strlen( s )
yyconst char *s;
#endif
	{
	register int n;
	for ( n = 0; s[n]; ++n )
		;

	return n;
	}
#endif


#ifdef YY_USE_PROTOS
static void *yy_flex_alloc( yy_size_t size )
#else
static void *yy_flex_alloc( size )
yy_size_t size;
#endif
	{
	return (void *) malloc( size );
	}

#ifdef YY_USE_PROTOS
static void *yy_flex_realloc( void *ptr, yy_size_t size )
#else
static void *yy_flex_realloc( ptr, size )
void *ptr;
yy_size_t size;
#endif
	{
	/* The cast to (char *) in the following accommodates both
	 * implementations that use char* generic pointers, and those
	 * that use void* generic pointers.  It works with the latter
	 * because both ANSI C and C++ allow castless assignment from
	 * any pointer type to void*, and deal with argument conversions
	 * as though doing an assignment.
	 */
	return (void *) realloc( (char *) ptr, size );
	}

#ifdef YY_USE_PROTOS
static void yy_flex_free( void *ptr )
#else
static void yy_flex_free( ptr )
void *ptr;
#endif
	{
	free( ptr );
	}

#if YY_MAIN
int main()
	{
	yylex();
	return 0;
	}
#endif
#line 975 "psqlscan.l"


/*
 * Create a lexer working state struct.
 */
PsqlScanState
psql_scan_create(void)
{
	PsqlScanState state;

	state = (PsqlScanStateData *) pg_malloc_zero(sizeof(PsqlScanStateData));

	psql_scan_reset(state);

	return state;
}

/*
 * Destroy a lexer working state struct, releasing all resources.
 */
void
psql_scan_destroy(PsqlScanState state)
{
	psql_scan_finish(state);

	psql_scan_reset(state);

	free(state);
}

/*
 * Set up to perform lexing of the given input line.
 *
 * The text at *line, extending for line_len bytes, will be scanned by
 * subsequent calls to the psql_scan routines.  psql_scan_finish should
 * be called when scanning is complete.  Note that the lexer retains
 * a pointer to the storage at *line --- this string must not be altered
 * or freed until after psql_scan_finish is called.
 */
void
psql_scan_setup(PsqlScanState state,
				const char *line, int line_len)
{
	/* Mustn't be scanning already */
	psql_assert(state->scanbufhandle == NULL);
	psql_assert(state->buffer_stack == NULL);

	/* Do we need to hack the character set encoding? */
	state->encoding = pset.encoding;
	state->safe_encoding = PG_VALID_BE_ENCODING(state->encoding);

	/* needed for prepare_buffer */
	cur_state = state;

	/* Set up flex input buffer with appropriate translation and padding */
	state->scanbufhandle = prepare_buffer(line, line_len,
										  &state->scanbuf);
	state->scanline = line;

	/* Set lookaside data in case we have to map unsafe encoding */
	state->curline = state->scanbuf;
	state->refline = state->scanline;
}

/*
 * Do lexical analysis of SQL command text.
 *
 * The text previously passed to psql_scan_setup is scanned, and appended
 * (possibly with transformation) to query_buf.
 *
 * The return value indicates the condition that stopped scanning:
 *
 * PSCAN_SEMICOLON: found a command-ending semicolon.  (The semicolon is
 * transferred to query_buf.)  The command accumulated in query_buf should
 * be executed, then clear query_buf and call again to scan the remainder
 * of the line.
 *
 * PSCAN_BACKSLASH: found a backslash that starts a psql special command.
 * Any previous data on the line has been transferred to query_buf.
 * The caller will typically next call psql_scan_slash_command(),
 * perhaps psql_scan_slash_option(), and psql_scan_slash_command_end().
 *
 * PSCAN_INCOMPLETE: the end of the line was reached, but we have an
 * incomplete SQL command.  *prompt is set to the appropriate prompt type.
 *
 * PSCAN_EOL: the end of the line was reached, and there is no lexical
 * reason to consider the command incomplete.  The caller may or may not
 * choose to send it.  *prompt is set to the appropriate prompt type if
 * the caller chooses to collect more input.
 *
 * In the PSCAN_INCOMPLETE and PSCAN_EOL cases, psql_scan_finish() should
 * be called next, then the cycle may be repeated with a fresh input line.
 *
 * In all cases, *prompt is set to an appropriate prompt type code for the
 * next line-input operation.
 */
PsqlScanResult
psql_scan(PsqlScanState state,
		  PQExpBuffer query_buf,
		  promptStatus_t *prompt)
{
	PsqlScanResult result;
	int			lexresult;

	/* Must be scanning already */
	psql_assert(state->scanbufhandle);

	/* Set up static variables that will be used by yylex */
	cur_state = state;
	output_buf = query_buf;

	if (state->buffer_stack != NULL)
		yy_switch_to_buffer(state->buffer_stack->buf);
	else
		yy_switch_to_buffer(state->scanbufhandle);

	BEGIN(state->start_state);

	/* And lex. */
	lexresult = yylex();

	/* Update static vars back to the state struct */
	state->start_state = YY_START;

	/*
	 * Check termination state and return appropriate result info.
	 */
	switch (lexresult)
	{
		case LEXRES_EOL:		/* end of input */
			switch (state->start_state)
			{
				case INITIAL:
					if (state->paren_depth > 0)
					{
						result = PSCAN_INCOMPLETE;
						*prompt = PROMPT_PAREN;
					}
					else if (query_buf->len > 0)
					{
						result = PSCAN_EOL;
						*prompt = PROMPT_CONTINUE;
					}
					else
					{
						/* never bother to send an empty buffer */
						result = PSCAN_INCOMPLETE;
						*prompt = PROMPT_READY;
					}
					break;
				case xb:
					result = PSCAN_INCOMPLETE;
					*prompt = PROMPT_SINGLEQUOTE;
					break;
				case xc:
					result = PSCAN_INCOMPLETE;
					*prompt = PROMPT_COMMENT;
					break;
				case xd:
					result = PSCAN_INCOMPLETE;
					*prompt = PROMPT_DOUBLEQUOTE;
					break;
				case xh:
					result = PSCAN_INCOMPLETE;
					*prompt = PROMPT_SINGLEQUOTE;
					break;
				case xq:
					result = PSCAN_INCOMPLETE;
					*prompt = PROMPT_SINGLEQUOTE;
					break;
				case xe:
					result = PSCAN_INCOMPLETE;
					*prompt = PROMPT_SINGLEQUOTE;
					break;
				case xdolq:
					result = PSCAN_INCOMPLETE;
					*prompt = PROMPT_DOLLARQUOTE;
					break;
				default:
					/* can't get here */
					fprintf(stderr, "invalid YY_START\n");
					exit(1);
			}
			break;
		case LEXRES_SEMI:		/* semicolon */
			result = PSCAN_SEMICOLON;
			*prompt = PROMPT_READY;
			break;
		case LEXRES_BACKSLASH:	/* backslash */
			result = PSCAN_BACKSLASH;
			*prompt = PROMPT_READY;
			break;
		default:
			/* can't get here */
			fprintf(stderr, "invalid yylex result\n");
			exit(1);
	}

	return result;
}

/*
 * Clean up after scanning a string.  This flushes any unread input and
 * releases resources (but not the PsqlScanState itself).  Note however
 * that this does not reset the lexer scan state; that can be done by
 * psql_scan_reset(), which is an orthogonal operation.
 *
 * It is legal to call this when not scanning anything (makes it easier
 * to deal with error recovery).
 */
void
psql_scan_finish(PsqlScanState state)
{
	/* Drop any incomplete variable expansions. */
	while (state->buffer_stack != NULL)
	{
		StackElem  *stackelem = state->buffer_stack;

		state->buffer_stack = stackelem->next;
		yy_delete_buffer(stackelem->buf);
		free(stackelem->bufstring);
		if (stackelem->origstring)
			free(stackelem->origstring);
		free(stackelem);
	}

	/* Done with the outer scan buffer, too */
	if (state->scanbufhandle)
		yy_delete_buffer(state->scanbufhandle);
	state->scanbufhandle = NULL;
	if (state->scanbuf)
		free(state->scanbuf);
	state->scanbuf = NULL;
}

/*
 * Reset lexer scanning state to start conditions.  This is appropriate
 * for executing \r psql commands (or any other time that we discard the
 * prior contents of query_buf).  It is not, however, necessary to do this
 * when we execute and clear the buffer after getting a PSCAN_SEMICOLON or
 * PSCAN_EOL scan result, because the scan state must be INITIAL when those
 * conditions are returned.
 *
 * Note that this is unrelated to flushing unread input; that task is
 * done by psql_scan_finish().
 */
void
psql_scan_reset(PsqlScanState state)
{
	state->start_state = INITIAL;
	state->paren_depth = 0;
	state->xcdepth = 0;			/* not really necessary */
	if (state->dolqstart)
		free(state->dolqstart);
	state->dolqstart = NULL;
}

/*
 * Return true if lexer is currently in an "inside quotes" state.
 *
 * This is pretty grotty but is needed to preserve the old behavior
 * that mainloop.c drops blank lines not inside quotes without even
 * echoing them.
 */
bool
psql_scan_in_quote(PsqlScanState state)
{
	return state->start_state != INITIAL;
}

/*
 * Scan the command name of a psql backslash command.  This should be called
 * after psql_scan() returns PSCAN_BACKSLASH.  It is assumed that the input
 * has been consumed through the leading backslash.
 *
 * The return value is a malloc'd copy of the command name, as parsed off
 * from the input.
 */
char *
psql_scan_slash_command(PsqlScanState state)
{
	PQExpBufferData mybuf;
	int			lexresult;

	/* Must be scanning already */
	psql_assert(state->scanbufhandle);

	/* Build a local buffer that we'll return the data of */
	initPQExpBuffer(&mybuf);

	/* Set up static variables that will be used by yylex */
	cur_state = state;
	output_buf = &mybuf;

	if (state->buffer_stack != NULL)
		yy_switch_to_buffer(state->buffer_stack->buf);
	else
		yy_switch_to_buffer(state->scanbufhandle);

	BEGIN(xslashcmd);

	/* And lex. */
	lexresult = yylex();

	/* There are no possible errors in this lex state... */

	return mybuf.data;
}

/*
 * Parse off the next argument for a backslash command, and return it as a
 * malloc'd string.  If there are no more arguments, returns NULL.
 *
 * type tells what processing, if any, to perform on the option string;
 * for example, if it's a SQL identifier, we want to downcase any unquoted
 * letters.
 *
 * if quote is not NULL, *quote is set to 0 if no quoting was found, else
 * the quote symbol.
 *
 * if semicolon is true, unquoted trailing semicolon(s) that would otherwise
 * be taken as part of the option string will be stripped.
 *
 * NOTE: the only possible syntax errors for backslash options are unmatched
 * quotes, which are detected when we run out of input.  Therefore, on a
 * syntax error we just throw away the string and return NULL; there is no
 * need to worry about flushing remaining input.
 */
char *
psql_scan_slash_option(PsqlScanState state,
					   enum slash_option_type type,
					   char *quote,
					   bool semicolon)
{
	PQExpBufferData mybuf;
	int			lexresult;
	char		local_quote;
	bool		badarg;

	/* Must be scanning already */
	psql_assert(state->scanbufhandle);

	if (quote == NULL)
		quote = &local_quote;
	*quote = 0;

	/* Build a local buffer that we'll return the data of */
	initPQExpBuffer(&mybuf);

	/* Set up static variables that will be used by yylex */
	cur_state = state;
	output_buf = &mybuf;
	option_type = type;
	option_quote = quote;

	if (state->buffer_stack != NULL)
		yy_switch_to_buffer(state->buffer_stack->buf);
	else
		yy_switch_to_buffer(state->scanbufhandle);

	if (type == OT_WHOLE_LINE)
		BEGIN(xslashwholeline);
	else
		BEGIN(xslasharg);

	/* And lex. */
	lexresult = yylex();

	/*
	 * Check the lex result: we should have gotten back either LEXRES_OK
	 * or LEXRES_EOL (the latter indicating end of string).  If we were inside
	 * a quoted string, as indicated by YY_START, EOL is an error.
	 */
	psql_assert(lexresult == LEXRES_EOL || lexresult == LEXRES_OK);
	badarg = false;
	switch (YY_START)
	{
		case xslasharg:
			/* empty arg, or possibly a psql variable substitution */
			break;
		case xslashquote:
			if (lexresult != LEXRES_OK)
				badarg = true;		/* hit EOL not ending quote */
			break;
		case xslashbackquote:
			if (lexresult != LEXRES_OK)
				badarg = true;		/* hit EOL not ending quote */
			else
			{
				/* Perform evaluation of backticked command */
				char	   *cmd = mybuf.data;
				FILE	   *fd;
				bool		error = false;
				PQExpBufferData output;
				char		buf[512];
				size_t		result;

				fd = popen(cmd, PG_BINARY_R);
				if (!fd)
				{
					psql_error("%s: %s\n", cmd, strerror(errno));
					error = true;
				}

				initPQExpBuffer(&output);

				if (!error)
				{
					do
					{
						result = fread(buf, 1, sizeof(buf), fd);
						if (ferror(fd))
						{
							psql_error("%s: %s\n", cmd, strerror(errno));
							error = true;
							break;
						}
						appendBinaryPQExpBuffer(&output, buf, result);
					} while (!feof(fd));
				}

				if (fd && pclose(fd) == -1)
				{
					psql_error("%s: %s\n", cmd, strerror(errno));
					error = true;
				}

				/* Now done with cmd, transfer result to mybuf */
				resetPQExpBuffer(&mybuf);

				if (!error)
				{
					/* strip any trailing newline */
					if (output.len > 0 &&
						output.data[output.len - 1] == '\n')
						output.len--;
					appendBinaryPQExpBuffer(&mybuf, output.data, output.len);
				}

				termPQExpBuffer(&output);
			}
			break;
		case xslashdefaultarg:
			/* Strip any trailing semi-colons if requested */
			if (semicolon)
			{
				while (mybuf.len > 0 &&
					   mybuf.data[mybuf.len - 1] == ';')
				{
					mybuf.data[--mybuf.len] = '\0';
				}
			}

			/*
			 * If SQL identifier processing was requested, then we strip out
			 * excess double quotes and downcase unquoted letters.
			 * Doubled double-quotes become output double-quotes, per spec.
			 *
			 * Note that a string like FOO"BAR"BAZ will be converted to
			 * fooBARbaz; this is somewhat inconsistent with the SQL spec,
			 * which would have us parse it as several identifiers.  But
			 * for psql's purposes, we want a string like "foo"."bar" to
			 * be treated as one option, so there's little choice.
			 */
			if (type == OT_SQLID || type == OT_SQLIDHACK)
			{
				bool		inquotes = false;
				char	   *cp = mybuf.data;

				while (*cp)
				{
					if (*cp == '"')
					{
						if (inquotes && cp[1] == '"')
						{
							/* Keep the first quote, remove the second */
							cp++;
						}
						inquotes = !inquotes;
						/* Collapse out quote at *cp */
						memmove(cp, cp + 1, strlen(cp));
						mybuf.len--;
						/* do not advance cp */
					}
					else
					{
						if (!inquotes && type == OT_SQLID)
							*cp = pg_tolower((unsigned char) *cp);
						cp += PQmblen(cp, pset.encoding);
					}
				}
			}
			break;
		case xslashquotedarg:
			/* must have hit EOL inside double quotes */
			badarg = true;
			break;
		case xslashwholeline:
			/* always okay */
			break;
		default:
			/* can't get here */
			fprintf(stderr, "invalid YY_START\n");
			exit(1);
	}

	if (badarg)
	{
		psql_error("unterminated quoted string\n");
		termPQExpBuffer(&mybuf);
		return NULL;
	}

	/*
	 * An unquoted empty argument isn't possible unless we are at end of
	 * command.  Return NULL instead.
	 */
	if (mybuf.len == 0 && *quote == 0)
	{
		termPQExpBuffer(&mybuf);
		return NULL;
	}

	/* Else return the completed string. */
	return mybuf.data;
}

/*
 * Eat up any unused \\ to complete a backslash command.
 */
void
psql_scan_slash_command_end(PsqlScanState state)
{
	int			lexresult;

	/* Must be scanning already */
	psql_assert(state->scanbufhandle);

	/* Set up static variables that will be used by yylex */
	cur_state = state;
	output_buf = NULL;

	if (state->buffer_stack != NULL)
		yy_switch_to_buffer(state->buffer_stack->buf);
	else
		yy_switch_to_buffer(state->scanbufhandle);

	BEGIN(xslashend);

	/* And lex. */
	lexresult = yylex();

	/* There are no possible errors in this lex state... */
}

/*
 * "Push back" the passed string so that it will be rescanned by subsequent
 * psql_scan_slash_option calls.  This is presently only used in the case
 * where a single-letter command has been concatenated with its argument.
 *
 * We use the same buffer stack mechanism as for variable expansion.
 */
void
psql_scan_slash_pushback(PsqlScanState state, const char *str)
{
	/* needed for push_new_buffer */
	cur_state = state;

	push_new_buffer(str);
}


/*
 * Push the given string onto the stack of stuff to scan.
 *
 * cur_state must point to the active PsqlScanState.
 *
 * NOTE SIDE EFFECT: the new buffer is made the active flex input buffer.
 */
static void
push_new_buffer(const char *newstr)
{
	StackElem  *stackelem;

	stackelem = (StackElem *) pg_malloc(sizeof(StackElem));
	stackelem->buf = prepare_buffer(newstr, strlen(newstr),
									&stackelem->bufstring);
	cur_state->curline = stackelem->bufstring;
	if (cur_state->safe_encoding)
	{
		stackelem->origstring = NULL;
		cur_state->refline = stackelem->bufstring;
	}
	else
	{
		stackelem->origstring = pg_strdup(newstr);
		cur_state->refline = stackelem->origstring;
	}
	stackelem->next = cur_state->buffer_stack;
	cur_state->buffer_stack = stackelem;
}

/*
 * Set up a flex input buffer to scan the given data.  We always make a
 * copy of the data.  If working in an unsafe encoding, the copy has
 * multibyte sequences replaced by FFs to avoid fooling the lexer rules.
 *
 * cur_state must point to the active PsqlScanState.
 *
 * NOTE SIDE EFFECT: the new buffer is made the active flex input buffer.
 */
static YY_BUFFER_STATE
prepare_buffer(const char *txt, int len, char **txtcopy)
{
	char	   *newtxt;

	/* Flex wants two \0 characters after the actual data */
	newtxt = pg_malloc(len + 2);
	*txtcopy = newtxt;
	newtxt[len] = newtxt[len + 1] = YY_END_OF_BUFFER_CHAR;

	if (cur_state->safe_encoding)
		memcpy(newtxt, txt, len);
	else
	{
		/* Gotta do it the hard way */
		int		i = 0;

		while (i < len)
		{
			int		thislen = PQmblen(txt + i, cur_state->encoding);

			/* first byte should always be okay... */
			newtxt[i] = txt[i];
			i++;
			while (--thislen > 0)
				newtxt[i++] = (char) 0xFF;
		}
	}

	return yy_scan_buffer(newtxt, len + 2);
}

/*
 * emit() --- body for ECHO macro
 *
 * NB: this must be used for ALL and ONLY the text copied from the flex
 * input data.  If you pass it something that is not part of the yytext
 * string, you are making a mistake.  Internally generated text can be
 * appended directly to output_buf.
 */
static void
emit(const char *txt, int len)
{
	if (cur_state->safe_encoding)
		appendBinaryPQExpBuffer(output_buf, txt, len);
	else
	{
		/* Gotta do it the hard way */
		const char *reference = cur_state->refline;
		int		i;

		reference += (txt - cur_state->curline);

		for (i = 0; i < len; i++)
		{
			char	ch = txt[i];

			if (ch == (char) 0xFF)
				ch = reference[i];
			appendPQExpBufferChar(output_buf, ch);
		}
	}
}
