#define yy_create_buffer plpgsql_base_yy_create_buffer
#define yy_delete_buffer plpgsql_base_yy_delete_buffer
#define yy_scan_buffer plpgsql_base_yy_scan_buffer
#define yy_scan_string plpgsql_base_yy_scan_string
#define yy_scan_bytes plpgsql_base_yy_scan_bytes
#define yy_flex_debug plpgsql_base_yy_flex_debug
#define yy_init_buffer plpgsql_base_yy_init_buffer
#define yy_flush_buffer plpgsql_base_yy_flush_buffer
#define yy_load_buffer_state plpgsql_base_yy_load_buffer_state
#define yy_switch_to_buffer plpgsql_base_yy_switch_to_buffer
#define yyin plpgsql_base_yyin
#define yyleng plpgsql_base_yyleng
#define yylex plpgsql_base_yylex
#define yyout plpgsql_base_yyout
#define yyrestart plpgsql_base_yyrestart
#define yytext plpgsql_base_yytext

#line 19 "pl_scan.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 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 90
#define YY_END_OF_BUFFER 91
static yyconst short int yy_accept[355] =
    {   0,
        0,    0,    0,    0,    0,    0,    0,    0,   91,   89,
       72,   72,   89,   89,   78,   89,   89,   89,   70,   89,
        2,   54,   54,   54,   54,   54,   54,   54,   54,   54,
       54,   54,   54,   54,   54,   54,   54,   54,   89,   84,
       83,   81,   77,   76,   77,   87,   87,   88,   72,   71,
        0,   54,   85,   62,    0,   73,    3,   74,   70,    1,
        0,   54,    0,    0,   54,   54,   54,   54,   54,   54,
       54,   54,   79,   54,   54,   54,   54,   54,   54,   54,
       25,   26,   29,   54,   54,   54,   54,   54,   37,   54,
       54,   54,   54,   54,   54,   47,   54,   54,   54,    0,

       84,   82,   80,   75,   87,   86,    0,   54,    0,    0,
        0,    0,    0,   73,    0,    0,    0,    0,   55,   54,
       54,   54,   54,   54,   54,   54,   54,   54,   54,   54,
       17,   54,   54,   54,   54,   22,   54,   24,   54,   54,
       30,   54,   54,   33,   54,   54,   54,   54,   54,   54,
       54,   54,   54,   54,   54,   54,   54,   54,   54,    0,
        0,    0,    0,    0,    0,   63,    0,    0,    0,   55,
        0,   55,    0,    0,   54,   54,   54,   54,   54,   54,
       54,   54,   54,   54,   53,   14,   54,   54,   54,   20,
       54,   23,   27,   28,   31,   32,   54,   35,   36,   54,

       54,   54,   54,   54,   54,   54,   54,   46,   48,   54,
       50,   54,    0,    0,    0,    0,   63,    0,   63,    0,
        0,    0,    0,    0,    0,    0,    0,   56,    4,    5,
        6,   54,   54,   54,   10,   54,   54,   54,   54,   16,
       54,   54,   21,   54,   54,   39,   54,   54,   54,   54,
       54,   54,   54,   51,    0,    0,    0,    0,    0,    0,
        0,   64,    0,   57,    0,    0,    0,   56,    0,   56,
        0,   54,   54,    9,   54,   54,   54,   15,   54,   54,
       34,   54,   40,   54,   42,   54,   54,   45,   54,    0,
        0,   65,    0,    0,    0,   64,    0,   64,    0,    0,

        0,    0,    0,   54,   54,   11,   12,   54,   54,   19,
       38,   54,   43,   54,   49,   52,    0,    0,    0,    0,
        0,    0,   58,    0,    7,    8,   54,   54,   54,   54,
        0,    0,   66,    0,   60,    0,    0,   54,   18,   54,
       44,   68,    0,    0,    0,   59,   54,   41,    0,   67,
       61,   13,   69,    0
    } ;

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,    1,    5,    6,    7,    8,    1,    9,    1,
        1,   10,    1,    1,   11,   12,   13,   14,   14,   14,
       14,   14,   14,   14,   14,   14,   14,   15,    1,    1,
       16,    1,    1,    1,   19,   20,   21,   22,   23,   24,
       25,   26,   27,   28,   28,   29,   30,   31,   32,   33,
       28,   34,   35,   36,   37,   38,   39,   40,   41,   28,
        1,   17,    1,    1,   18,    1,   19,   20,   21,   22,

       23,   24,   25,   26,   27,   28,   28,   29,   30,   31,
       32,   33,   28,   34,   35,   36,   37,   38,   39,   40,
       41,   28,    1,    1,    1,    1,    1,   28,   28,   28,
       28,   28,   28,   28,   28,   28,   28,   28,   28,   28,
       28,   28,   28,   28,   28,   28,   28,   28,   28,   28,
       28,   28,   28,   28,   28,   28,   28,   28,   28,   28,
       28,   28,   28,   28,   28,   28,   28,   28,   28,   28,
       28,   28,   28,   28,   28,   28,   28,   28,   28,   28,
       28,   28,   28,   28,   28,   28,   28,   28,   28,   28,
       28,   28,   28,   28,   28,   28,   28,   28,   28,   28,

       28,   28,   28,   28,   28,   28,   28,   28,   28,   28,
       28,   28,   28,   28,   28,   28,   28,   28,   28,   28,
       28,   28,   28,   28,   28,   28,   28,   28,   28,   28,
       28,   28,   28,   28,   28,   28,   28,   28,   28,   28,
       28,   28,   28,   28,   28,   28,   28,   28,   28,   28,
       28,   28,   28,   28,   28
    } ;

static yyconst int yy_meta[42] =
    {   0,
        1,    2,    3,    4,    5,    1,    6,    7,    8,    1,
        1,    9,    1,   10,    1,    1,    8,   11,   11,   11,
       11,   11,   11,   11,   11,   11,   11,   11,   11,   11,
       11,   11,   11,   11,   11,   11,   11,   11,   11,   11,
       11
    } ;

static yyconst short int yy_base[381] =
    {   0,
        0,  430,   33,   34,   42,   43,   41,   51,  430, 1439,
       53,   57,   44,   55, 1439,  413,  409,  408,  401,  398,
     1439,   62,   69,   76,   98,   60,   76,   80,   92,  102,
       91,  109,  111,  124,  131,  135,  133,  147,  368,    0,
      390,    0, 1439, 1439,  385,    0,    0,  389,   91,  390,
      384,  178, 1439,  185,  375,    0, 1439, 1439,  367, 1439,
      192,  120,  135,  203,  182,  188,  186,  195,  199,  214,
      210,  220, 1439,  224,  208,  237,  236,  246,  247,  253,
      259,  263,  265,  276,  274,  280,  278,  295,  291,  297,
      306,  315,  325,  293,  326,  308,  336,  338,  351,  346,

        0, 1439, 1439, 1439,    0, 1439,  370,  382,  371,  389,
      141,  400,  364,    0,  334,  320,  404,  355,  408,  394,
      390,  400,  403,  409,  396,  414,  423,  424,  425,  436,
      435,  446,  445,  452,  458,  462,  468,  464,  474,  475,
      481,  487,  485,  496,  497,  506,  507,  513,  522,  520,
      524,  535,  537,  539,  546,  550,  557,  561,  567,  323,
      349,  316,  301,  598,  336,  603,  300,  303,  316,  614,
      621,  628,  167,  639,  616,  618,  629,  627,  633,  639,
      648,  650,  646,  657,  661,  668,  667,  674,  680,  681,
      690,  691,  692,  701,  702,  703,  715,  713,  714,  724,

      725,  734,  736,  738,  745,  755,  757,  751,  761,  768,
      767,  778,  292,  265,  265,  288,  809,  816,  823,  176,
      834,  250,  258,  245,  230,  838,  265,  606,  815,  816,
      817,  831,  827,  833,  837,  843,  844,  850,  854,  856,
      860,  866,  872,  876,  878,  882,  893,  891,  900,  889,
      904,  906,  915,  916,  235,  227,  239,  223,  213,  952,
      243,  956,  203, 1439,  202,  189,  216,  963,  970,  973,
      180,  951,  955,  957,  967,  966,  976,  977,  983,  993,
      989,  999,  995, 1005, 1006, 1016, 1012, 1018, 1027,  171,
      157, 1439,  153,  158,  180, 1058, 1065, 1068,  142,  122,

      115,  119,   95, 1045, 1055, 1051, 1057, 1061, 1067, 1071,
     1073, 1077, 1083, 1087, 1093, 1439,   92,   86,   96,   77,
       88,   63, 1439,   63, 1094, 1100, 1106, 1110, 1117, 1116,
       68,   49, 1439,   53, 1439,   49,   53, 1129, 1127, 1133,
     1131, 1439,   42,   45,   44, 1439, 1140, 1142,   40, 1439,
     1439, 1144, 1439, 1439, 1181, 1192, 1203, 1214, 1220, 1230,
     1241, 1252, 1263, 1269, 1280, 1286, 1297, 1307, 1313, 1323,
     1334, 1344, 1355, 1365, 1375, 1385, 1396, 1406, 1417, 1427
    } ;

static yyconst short int yy_def[381] =
    {   0,
      354,    1,  355,  355,  356,  356,  357,  357,  354,  354,
      354,  354,  358,  359,  354,  354,  354,  354,  354,  354,
      354,  360,  360,  360,  360,   25,   25,   25,   25,   25,
       25,   25,   25,   25,   25,   25,   25,   25,  354,  361,
      354,  362,  354,  354,  354,  363,  363,  364,  354,  365,
      365,  354,  354,  354,  366,  367,  354,  354,  354,  354,
      354,   25,  354,  368,   25,   25,   25,   25,   25,   25,
       25,   25,  354,   25,   25,   25,   25,   25,   25,   25,
       25,   25,   25,   25,   25,   25,   25,   25,   25,   25,
       25,   25,   25,   25,   25,   25,   25,   25,   25,  354,

      361,  354,  354,  354,  363,  354,  369,  354,  365,  354,
      354,  370,  366,  367,  354,  354,  368,  371,  372,   25,
       25,   25,   92,   92,   25,   25,   25,   25,   25,   25,
       25,   25,   25,   25,   25,   25,   25,   25,   25,   25,
       25,   25,   25,   25,   25,   25,   25,   25,   25,   25,
       25,   25,   25,   25,   25,   25,   25,   25,   25,  354,
      369,  354,  354,  370,  373,  374,  354,  354,  371,  354,
      354,  372,  354,  375,   25,   25,   25,   25,   25,   25,
       25,   25,   25,   25,   25,   25,   25,   25,   25,   25,
       25,   25,   25,   25,   25,   25,   25,   25,   25,   25,

       25,   25,   25,   25,   25,   25,   25,   25,   25,   25,
       25,   25,  354,  354,  354,  373,  354,  354,  374,  354,
      376,  354,  354,  354,  354,  375,  377,  378,   25,   25,
       25,   25,   25,   25,   25,   25,   25,   25,   25,   25,
       25,   25,   25,   25,   25,   25,   25,   25,   25,   25,
       25,   25,   25,   25,  354,  354,  354,  354,  354,  376,
      379,  380,  354,  354,  354,  354,  377,  354,  354,  378,
      354,   25,   25,   25,   25,   25,   25,   25,   25,   25,
       25,   25,   25,   25,   25,   25,   25,   25,   25,  354,
      354,  354,  354,  354,  379,  354,  354,  380,  354,  354,

      354,  354,  354,   25,   25,   25,   25,   25,   25,   25,
       25,   25,   25,   25,   25,  354,  354,  354,  354,  354,
      354,  354,  354,  354,   25,   25,   25,   25,   25,   25,
      354,  354,  354,  354,  354,  354,  354,   25,   25,   25,
       25,  354,  354,  354,  354,  354,   25,   25,  354,  354,
      354,   25,  354,    0,  354,  354,  354,  354,  354,  354,
      354,  354,  354,  354,  354,  354,  354,  354,  354,  354,
      354,  354,  354,  354,  354,  354,  354,  354,  354,  354
    } ;

static yyconst short int yy_nxt[1481] =
    {   0,
       10,   11,   12,   11,   13,   10,   14,   10,   15,   10,
       16,   17,   18,   19,   20,   21,   10,   22,   23,   24,
       25,   26,   27,   28,   29,   22,   30,   22,   31,   22,
       32,   33,   34,   35,   36,   37,   22,   22,   38,   22,
       22,   41,   41,   47,   44,   44,   51,   48,   52,   42,
       42,   45,   45,   47,   49,   49,   49,   48,   49,   49,
       49,   53,  353,   61,   61,   61,  351,  350,   54,   63,
       61,   61,   61,   64,  349,  346,   63,   61,   61,   61,
       64,  345,   70,   63,   73,  344,   71,   64,   62,  343,
      342,   62,   49,   49,   49,  337,   72,   65,   66,   61,

       61,   61,   77,  336,   74,   63,   75,   62,   62,   64,
      335,   78,   62,   79,   80,   76,   62,  334,  333,   62,
       62,  332,   84,   62,  331,   81,   67,   62,   62,   68,
       62,   85,   82,   62,   69,  324,   83,   62,   62,   62,
       86,  323,   62,   88,   89,   87,   90,   62,   62,   91,
      322,   62,   62,   92,  321,   62,   62,   94,   95,   62,
       62,   62,   93,   62,   96,   98,   62,   62,  115,   62,
      116,   62,   99,   97,  162,   62,  163,  320,   62,   61,
       61,   61,  109,   62,  296,   63,  110,  110,  110,   64,
      319,  318,  111,   61,   61,   61,  112,  317,   54,   63,

      224,  316,  225,   64,  117,  117,  117,  118,  120,  258,
       62,  259,  121,   62,   62,  303,   62,  122,   62,   62,
      268,  302,   62,   62,   62,  123,   62,   62,  128,  131,
       62,   62,  124,  125,  126,   62,   62,  127,   62,   62,
      301,   62,   62,  300,   62,   62,   62,  296,   62,  129,
       62,   62,   62,  294,  293,   62,   62,  132,  130,  133,
       62,  292,  291,  134,   62,   62,  290,   62,   62,  268,
      266,  135,   62,   62,   62,   62,  265,   62,  137,  136,
      264,   62,   62,   62,   62,  263,  139,   62,  138,   62,
       62,   62,  217,   62,   62,   62,   62,  257,  140,   62,

      141,   62,   62,  256,   62,   62,  145,  142,   62,   62,
       62,   62,   62,  143,   62,  144,   62,  146,  255,   62,
      170,  154,   62,   62,   62,   62,   62,   62,   62,   62,
      147,   62,  148,   62,   62,  223,   62,   62,  222,   62,
      217,  215,   62,   62,   62,  149,   62,  214,  155,  150,
      151,   62,  152,   62,   62,  106,   62,   62,  213,  170,
      168,   62,   62,  153,   62,  167,   62,   62,  156,   62,
       53,  157,   62,  158,   62,  108,  106,  159,  160,   62,
       59,   53,   62,   61,   61,   61,  109,   62,  108,   63,
      110,  110,  110,   64,  108,  106,  111,  104,  102,  100,

      112,  164,  164,  164,  165,  117,  117,  117,  118,  171,
      171,  171,  175,   60,   59,  173,  176,   58,   62,  174,
       57,   62,   62,   56,   62,   62,   62,   62,   62,  354,
       62,   62,  181,   62,  177,   39,   62,  178,  179,   62,
       62,  183,  182,  180,   62,   62,   62,  354,  184,  354,
       62,   62,   62,   62,   62,   62,   62,  185,  186,   62,
       62,   62,  187,   62,   62,  189,   62,   62,  188,  354,
      354,   62,   62,   62,   62,  354,   62,   62,  191,  354,
       62,   62,   62,   62,  354,  354,   62,  190,   62,   62,
       62,  354,   62,   62,   62,   62,   62,  192,   62,   62,

       62,  354,   62,   62,   62,  193,  194,  354,  354,   62,
       62,   62,   62,   62,  354,   62,   62,   62,   62,  195,
      196,   62,  197,   62,   62,  198,  354,   62,   62,  354,
      200,  354,   62,   62,   62,   62,  199,   62,   62,  354,
      202,   62,   62,   62,   62,  354,  354,  201,   62,   62,
       62,   62,   62,   62,  206,   62,  203,  205,   62,  354,
      204,  207,  354,   62,  354,   62,   62,   62,   62,  354,
       62,   62,  209,   62,   62,   62,  208,   62,   62,  354,
      354,   62,   62,  354,  354,   62,   62,  210,   62,   62,
      354,  211,   62,   62,  354,  212,  354,   62,   62,  164,

      164,  164,  165,   62,  218,  218,  218,  269,  269,  269,
      220,  354,  354,  271,  221,  171,  171,  171,  118,  354,
      354,  173,  171,  171,  171,  174,  354,  354,  173,  171,
      171,  171,  174,  354,  354,  173,  354,  354,  354,  174,
      226,  226,  226,  227,   62,  354,   62,   62,  230,   62,
      229,  231,   62,  354,   62,   62,  354,   62,   62,  233,
       62,   62,  232,   62,   62,   62,  354,   62,  236,   62,
      234,  354,  235,  354,   62,   62,   62,   62,   62,   62,
      354,   62,  237,  354,   62,   62,   62,  238,   62,   62,
      240,  354,   62,   62,  239,   62,   62,   62,   62,   62,

      354,  354,   62,   62,   62,   62,  241,  354,   62,   62,
       62,   62,   62,  354,  354,  243,  242,   62,   62,   62,
       62,   62,   62,   62,  354,  354,   62,   62,   62,   62,
       62,   62,   62,   62,   62,  244,  354,   62,   62,   62,
      354,   62,   62,   62,   62,   62,   62,  246,  354,   62,
       62,   62,   62,   62,  354,  245,   62,  354,  354,  354,
       62,   62,   62,  247,  248,   62,   62,   62,  354,   62,
       62,  249,   62,   62,   62,  251,   62,  252,  250,   62,
      354,   62,   62,   62,  354,   62,   62,   62,   62,   62,
      354,   62,   62,   62,  253,   62,   62,   62,   62,   62,

      254,  354,  354,   62,   62,  354,   62,  354,  354,   62,
      218,  218,  218,  165,   62,  354,  220,  218,  218,  218,
      221,  354,  354,  220,  218,  218,  218,  221,  354,  354,
      220,  354,  354,  354,  221,  260,  260,  260,  261,  226,
      226,  226,  227,   62,   62,   62,   62,   62,   62,  272,
      354,   62,   62,   62,  354,   62,  354,  273,   62,   62,
      354,   62,   62,   62,   62,   62,  274,   62,   62,   62,
      354,   62,  276,   62,   62,   62,  275,  278,   62,   62,
       62,  277,   62,  354,   62,   62,   62,   62,   62,  354,
       62,   62,   62,  354,   62,  279,   62,   62,  281,  354,

       62,  280,   62,   62,   62,  354,   62,   62,   62,   62,
       62,  282,   62,   62,   62,  283,  354,   62,   62,   62,
       62,   62,   62,  286,   62,   62,  284,   62,   62,   62,
      285,   62,   62,  354,   62,  287,   62,   62,  354,  354,
       62,  288,   62,   62,   62,  289,   62,   62,  354,  354,
      354,   62,   62,  260,  260,  260,  261,  297,  297,  297,
      354,  354,  354,  299,  269,  269,  269,  227,  354,  354,
      271,  269,  269,  269,  269,  269,  269,  271,  354,   62,
      271,  304,   62,   62,  354,   62,   62,   62,   62,  306,
      354,  305,  354,   62,   62,   62,  354,   62,   62,  354,

      354,  307,   62,   62,   62,   62,  354,   62,   62,  309,
      308,   62,   62,   62,   62,  310,  354,   62,  354,   62,
       62,   62,  312,   62,   62,   62,   62,   62,  311,   62,
       62,   62,  354,   62,   62,   62,   62,   62,  313,  354,
       62,   62,   62,   62,   62,  354,   62,   62,  314,   62,
      354,  315,   62,  354,   62,   62,  354,  354,   62,  297,
      297,  297,  261,   62,  354,  299,  297,  297,  297,  297,
      297,  297,  299,   62,  354,  299,   62,  326,  354,   62,
      325,   62,   62,   62,  354,   62,   62,   62,   62,   62,
      354,   62,   62,   62,  354,   62,  327,   62,  328,   62,

      354,   62,   62,   62,   62,   62,  354,   62,  329,   62,
      354,   62,  354,   62,   62,   62,  354,  330,   62,   62,
      354,   62,   62,   62,   62,   62,  354,  354,   62,   62,
       62,   62,  338,  354,   62,  354,   62,   62,   62,  354,
      339,   62,   62,  340,   62,   62,   62,   62,   62,  347,
      354,  341,   62,   62,  348,   62,  354,   62,   62,   62,
       62,   62,   62,   62,   62,   62,  354,   62,   62,   62,
       62,   62,   62,   62,  352,   62,   62,  354,   62,  354,
       62,   40,   40,   40,   40,   40,   40,   40,   40,   40,
       40,   40,   43,   43,   43,   43,   43,   43,   43,   43,

       43,   43,   43,   46,   46,   46,   46,   46,   46,   46,
       46,   46,   46,   46,   50,   50,   50,   50,   50,   50,
       50,   50,   50,   50,   50,   55,  354,  354,  354,   55,
       55,   62,   62,   62,  354,   62,   62,  354,   62,   62,
       62,  101,  101,  101,  101,  101,  101,  101,  354,  101,
      101,  101,  103,  103,  354,  103,  103,  103,  103,  103,
      103,  103,  103,  105,  105,  105,  105,  105,  354,  105,
      105,  105,  105,  105,  107,  354,  354,  354,  354,  107,
       51,   51,   51,   51,   51,   51,   51,   51,   51,   51,
       51,  113,  354,  354,  354,  113,  113,  114,  114,  354,

      354,  114,  114,  114,  114,  114,  114,  114,  119,  119,
      119,  119,  354,  354,  354,  354,  354,  119,  161,  354,
      354,  354,  161,  161,  166,  166,  166,  166,  354,  354,
      354,  354,  354,  166,  169,  169,  169,  169,  169,  169,
      169,  169,  169,  169,  169,  172,  172,  172,  354,  172,
      172,  354,  172,  172,  172,  216,  216,  216,  216,  216,
      216,  216,  216,  216,  216,  216,  219,  219,  219,  354,
      219,  219,  354,  219,  219,  219,  228,  228,  228,  228,
      354,  354,  354,  354,  354,  228,  262,  262,  262,  262,
      354,  354,  354,  354,  354,  262,  267,  267,  267,  267,

      267,  267,  267,  267,  267,  267,  267,  270,  270,  270,
      354,  270,  270,  354,  354,  270,  270,  295,  295,  295,
      295,  295,  295,  295,  295,  295,  295,  295,  298,  298,
      298,  354,  298,  298,  354,  354,  298,  298,    9,  354,
      354,  354,  354,  354,  354,  354,  354,  354,  354,  354,
      354,  354,  354,  354,  354,  354,  354,  354,  354,  354,
      354,  354,  354,  354,  354,  354,  354,  354,  354,  354,
      354,  354,  354,  354,  354,  354,  354,  354,  354,  354
    } ;

static yyconst short int yy_chk[1481] =
    {   0,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    3,    4,    7,    5,    6,   13,    7,   13,    3,
        4,    5,    6,    8,   11,   11,   11,    8,   12,   12,
       12,   14,  349,   22,   22,   22,  345,  344,   14,   22,
       23,   23,   23,   22,  343,  337,   23,   24,   24,   24,
       23,  336,   26,   24,   27,  334,   26,   24,   26,  332,
      331,   26,   49,   49,   49,  324,   26,   23,   24,   25,

       25,   25,   28,  322,   27,   25,   27,   27,   28,   25,
      321,   28,   27,   28,   29,   27,   28,  320,  319,   31,
       29,  318,   31,   29,  317,   30,   25,   31,   29,   25,
       30,   32,   30,   30,   25,  303,   30,   32,   30,   33,
       32,  302,   33,   33,   33,   32,   34,   33,   62,   35,
      301,   62,   34,   35,  300,   34,   62,   36,   37,   35,
       34,   37,   35,   36,   37,   38,   36,   35,   63,   37,
       63,   36,   38,   37,  111,   38,  111,  299,   38,   52,
       52,   52,   52,   38,  295,   52,   54,   54,   54,   52,
      294,  293,   54,   61,   61,   61,   54,  291,   54,   61,

      173,  290,  173,   61,   64,   64,   64,   64,   65,  220,
       65,  220,   66,   65,   67,  271,   66,   67,   65,   66,
      267,  266,   67,   68,   66,   68,   68,   69,   71,   75,
       69,   68,   69,   70,   70,   69,   75,   70,   71,   75,
      265,   71,   70,  263,   75,   70,   71,  261,   72,   72,
       70,   72,   74,  259,  258,   74,   72,   76,   74,   76,
       74,  257,  256,   76,   77,   76,  255,   77,   76,  227,
      225,   77,   77,   76,   78,   79,  224,   78,   79,   78,
      223,   80,   78,   79,   80,  222,   82,   81,   80,   80,
       81,   82,  216,   83,   82,   81,   83,  215,   82,   82,

       84,   83,   85,  214,   84,   85,   87,   84,   86,   87,
       85,   86,   84,   85,   87,   86,   86,   88,  213,   89,
      169,   94,   89,   88,   94,   90,   88,   89,   90,   94,
       90,   88,   91,   90,   91,  168,   96,   91,  167,   96,
      165,  163,   91,   92,   96,   92,   92,  162,   95,   92,
       92,   92,   92,   93,   95,  161,   93,   95,  160,  118,
      116,   93,   95,   93,   97,  115,   98,   97,   97,   98,
      113,   98,   97,   99,   98,  109,  107,   99,  100,   99,
       59,   55,   99,  108,  108,  108,  108,   99,   51,  108,
      110,  110,  110,  108,   50,   48,  110,   45,   41,   39,

      110,  112,  112,  112,  112,  117,  117,  117,  117,  119,
      119,  119,  120,   20,   19,  119,  121,   18,  121,  119,
       17,  121,  120,   16,  125,  120,  121,  125,  122,    9,
      120,  122,  125,  123,  122,    2,  122,  123,  123,  124,
      123,  127,  126,  124,  124,  126,  124,    0,  128,    0,
      126,  127,  128,  129,  127,  128,  129,  129,  130,  127,
      128,  129,  130,  131,  130,  133,  131,  130,  132,    0,
        0,  131,  130,  133,  132,    0,  133,  132,  135,    0,
      134,  133,  132,  134,    0,    0,  135,  134,  134,  135,
      136,    0,  138,  136,  135,  138,  137,  137,  136,  137,

      138,    0,  139,  140,  137,  139,  140,    0,    0,  141,
      139,  140,  141,  143,    0,  142,  143,  141,  142,  142,
      143,  143,  144,  142,  144,  145,    0,  144,  145,    0,
      147,    0,  144,  145,  146,  147,  146,  146,  147,    0,
      149,  148,  146,  147,  148,    0,    0,  148,  150,  148,
      149,  150,  151,  149,  153,  151,  150,  152,  149,    0,
      151,  154,    0,  152,    0,  153,  152,  154,  153,    0,
      154,  152,  156,  153,  155,  154,  155,  155,  156,    0,
        0,  156,  155,    0,    0,  157,  156,  157,  157,  158,
        0,  158,  158,  157,    0,  159,    0,  158,  159,  164,

      164,  164,  164,  159,  166,  166,  166,  228,  228,  228,
      166,    0,    0,  228,  166,  170,  170,  170,  170,    0,
        0,  170,  171,  171,  171,  170,    0,    0,  171,  172,
      172,  172,  171,    0,    0,  172,    0,    0,    0,  172,
      174,  174,  174,  174,  175,    0,  176,  175,  176,  176,
      175,  177,  175,    0,  176,  178,    0,  177,  178,  179,
      177,  179,  178,  178,  179,  177,    0,  180,  182,  179,
      180,    0,  181,    0,  183,  180,  181,  183,  182,  181,
        0,  182,  183,    0,  181,  184,  182,  184,  184,  185,
      187,    0,  185,  184,  186,  187,  186,  185,  187,  186,

        0,    0,  188,  187,  186,  188,  188,    0,  189,  190,
      188,  189,  190,    0,    0,  191,  189,  190,  191,  192,
      193,  191,  192,  193,    0,    0,  191,  192,  193,  194,
      195,  196,  194,  195,  196,  197,    0,  194,  195,  196,
        0,  198,  199,  197,  198,  199,  197,  201,    0,  198,
      199,  197,  200,  201,    0,  200,  201,    0,    0,    0,
      200,  201,  202,  202,  203,  202,  204,  203,    0,  204,
      202,  204,  203,  205,  204,  206,  205,  207,  205,  208,
        0,  205,  208,  206,    0,  207,  206,  208,  207,  209,
        0,  206,  209,  207,  210,  211,  210,  209,  211,  210,

      212,    0,    0,  211,  210,    0,  212,    0,    0,  212,
      217,  217,  217,  217,  212,    0,  217,  218,  218,  218,
      217,    0,    0,  218,  219,  219,  219,  218,    0,    0,
      219,    0,    0,    0,  219,  221,  221,  221,  221,  226,
      226,  226,  226,  229,  230,  231,  229,  230,  231,  232,
        0,  229,  230,  231,    0,  233,    0,  233,  233,  232,
        0,  234,  232,  233,  234,  235,  234,  232,  235,  234,
        0,  236,  237,  235,  236,  237,  236,  239,  238,  236,
      237,  238,  239,    0,  240,  239,  238,  240,  241,    0,
      239,  241,  240,    0,  242,  241,  241,  242,  244,    0,

      243,  242,  242,  243,  244,    0,  245,  244,  243,  245,
      246,  245,  244,  246,  245,  247,    0,  250,  246,  248,
      250,  247,  248,  250,  247,  250,  248,  248,  249,  247,
      249,  249,  251,    0,  252,  251,  249,  252,    0,    0,
      251,  252,  252,  253,  254,  253,  253,  254,    0,    0,
        0,  253,  254,  260,  260,  260,  260,  262,  262,  262,
        0,    0,    0,  262,  268,  268,  268,  268,    0,    0,
      268,  269,  269,  269,  270,  270,  270,  269,    0,  272,
      270,  272,  272,  273,    0,  274,  273,  272,  274,  275,
        0,  273,    0,  274,  276,  275,    0,  276,  275,    0,

        0,  276,  276,  275,  277,  278,    0,  277,  278,  279,
      277,  279,  277,  278,  279,  280,    0,  281,    0,  279,
      281,  280,  284,  283,  280,  281,  283,  282,  282,  280,
      282,  283,    0,  284,  285,  282,  284,  285,  286,    0,
      287,  284,  285,  287,  286,    0,  288,  286,  287,  288,
        0,  289,  286,    0,  288,  289,    0,    0,  289,  296,
      296,  296,  296,  289,    0,  296,  297,  297,  297,  298,
      298,  298,  297,  304,    0,  298,  304,  305,    0,  306,
      304,  304,  306,  305,    0,  307,  305,  306,  307,  308,
        0,  305,  308,  307,    0,  309,  308,  308,  309,  310,

        0,  311,  310,  309,  311,  312,    0,  310,  312,  311,
        0,  313,    0,  312,  313,  314,    0,  314,  314,  313,
        0,  315,  325,  314,  315,  325,    0,    0,  326,  315,
      325,  326,  327,    0,  327,    0,  326,  327,  328,    0,
      328,  328,  327,  329,  330,  329,  328,  330,  329,  338,
        0,  330,  330,  329,  340,  339,    0,  338,  339,  341,
      338,  340,  341,  339,  340,  338,    0,  341,  347,  340,
      348,  347,  352,  348,  347,  352,  347,    0,  348,    0,
      352,  355,  355,  355,  355,  355,  355,  355,  355,  355,
      355,  355,  356,  356,  356,  356,  356,  356,  356,  356,

      356,  356,  356,  357,  357,  357,  357,  357,  357,  357,
      357,  357,  357,  357,  358,  358,  358,  358,  358,  358,
      358,  358,  358,  358,  358,  359,    0,    0,    0,  359,
      359,  360,  360,  360,    0,  360,  360,    0,  360,  360,
      360,  361,  361,  361,  361,  361,  361,  361,    0,  361,
      361,  361,  362,  362,    0,  362,  362,  362,  362,  362,
      362,  362,  362,  363,  363,  363,  363,  363,    0,  363,
      363,  363,  363,  363,  364,    0,    0,    0,    0,  364,
      365,  365,  365,  365,  365,  365,  365,  365,  365,  365,
      365,  366,    0,    0,    0,  366,  366,  367,  367,    0,

        0,  367,  367,  367,  367,  367,  367,  367,  368,  368,
      368,  368,    0,    0,    0,    0,    0,  368,  369,    0,
        0,    0,  369,  369,  370,  370,  370,  370,    0,    0,
        0,    0,    0,  370,  371,  371,  371,  371,  371,  371,
      371,  371,  371,  371,  371,  372,  372,  372,    0,  372,
      372,    0,  372,  372,  372,  373,  373,  373,  373,  373,
      373,  373,  373,  373,  373,  373,  374,  374,  374,    0,
      374,  374,    0,  374,  374,  374,  375,  375,  375,  375,
        0,    0,    0,    0,    0,  375,  376,  376,  376,  376,
        0,    0,    0,    0,    0,  376,  377,  377,  377,  377,

      377,  377,  377,  377,  377,  377,  377,  378,  378,  378,
        0,  378,  378,    0,    0,  378,  378,  379,  379,  379,
      379,  379,  379,  379,  379,  379,  379,  379,  380,  380,
      380,    0,  380,  380,    0,    0,  380,  380,  354,  354,
      354,  354,  354,  354,  354,  354,  354,  354,  354,  354,
      354,  354,  354,  354,  354,  354,  354,  354,  354,  354,
      354,  354,  354,  354,  354,  354,  354,  354,  354,  354,
      354,  354,  354,  354,  354,  354,  354,  354,  354,  354
    } ;

static yy_state_type yy_last_accepting_state;
static char *yy_last_accepting_cpos;

/* 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 "scan.l"
#define INITIAL 0
#line 2 "scan.l"
/**********************************************************************
 * scan.l		- Scanner for the PL/pgSQL
 *			  procedural language
 *
 * IDENTIFICATION
 *    $PostgreSQL: pgsql/src/pl/plpgsql/src/scan.l,v 1.42 2005/06/26 19:16:07 tgl Exp $
 *
 *    This software is copyrighted by Jan Wieck - Hamburg.
 *
 *    The author hereby grants permission  to  use,  copy,  modify,
 *    distribute,  and  license this software and its documentation
 *    for any purpose, provided that existing copyright notices are
 *    retained  in  all  copies  and  that  this notice is included
 *    verbatim in any distributions. No written agreement, license,
 *    or  royalty  fee  is required for any of the authorized uses.
 *    Modifications to this software may be  copyrighted  by  their
 *    author  and  need  not  follow  the licensing terms described
 *    here, provided that the new terms are  clearly  indicated  on
 *    the first page of each file where they apply.
 *
 *    IN NO EVENT SHALL THE AUTHOR OR DISTRIBUTORS BE LIABLE TO ANY
 *    PARTY  FOR  DIRECT,   INDIRECT,   SPECIAL,   INCIDENTAL,   OR
 *    CONSEQUENTIAL   DAMAGES  ARISING  OUT  OF  THE  USE  OF  THIS
 *    SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF, EVEN
 *    IF  THE  AUTHOR  HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH
 *    DAMAGE.
 *
 *    THE  AUTHOR  AND  DISTRIBUTORS  SPECIFICALLY   DISCLAIM   ANY
 *    WARRANTIES,  INCLUDING,  BUT  NOT  LIMITED  TO,  THE  IMPLIED
 *    WARRANTIES  OF  MERCHANTABILITY,  FITNESS  FOR  A  PARTICULAR
 *    PURPOSE,  AND NON-INFRINGEMENT.  THIS SOFTWARE IS PROVIDED ON
 *    AN "AS IS" BASIS, AND THE AUTHOR  AND  DISTRIBUTORS  HAVE  NO
 *    OBLIGATION   TO   PROVIDE   MAINTENANCE,   SUPPORT,  UPDATES,
 *    ENHANCEMENTS, OR MODIFICATIONS.
 *
 **********************************************************************/

#include "plpgsql.h"

#include "mb/pg_wchar.h"


/* No reason to constrain amount of data slurped */
#define YY_READ_BUF_SIZE 16777216

/* Avoid exit() on fatal scanner errors (a bit ugly -- see yy_fatal_error) */
#undef fprintf
#define fprintf(file, fmt, msg)  ereport(ERROR, (errmsg_internal("%s", msg)))

/* Handles to the buffer that the lexer uses internally */
static YY_BUFFER_STATE scanbufhandle;
static char *scanbuf;

static const char *scanstr;		/* original input string */

static int	scanner_functype;
static bool	scanner_typereported;
static int	pushback_token;
static bool have_pushback_token;
static int	lookahead_token;	
static bool have_lookahead_token;
static const char *cur_line_start;
static int	cur_line_num;
static char    *dolqstart;      /* current $foo$ quote start string */
static int	dolqlen;			/* signal to plpgsql_get_string_value */

bool plpgsql_SpaceScanned = false;
#define YY_NEVER_INTERACTIVE 1
#define YY_NO_UNPUT 1
#define IN_STRING 1

#define IN_COMMENT 2

#define IN_DOLLARQUOTE 3

/* $foo$ style quotes ("dollar quoting")
 * copied straight from the backend SQL parser
 */
#line 908 "pl_scan.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 \
	if ( yyleng > 0 ) \
		yy_current_buffer->yy_at_bol = \
				(yytext[yyleng - 1] == '\n'); \
	YY_USER_ACTION

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

#line 104 "scan.l"

    /* ----------
     * Local variables in scanner to remember where
     * a string or comment started
     * ----------
     */
    int	start_lineno = 0;
	char *start_charpos = NULL;

    /* ----------
     * Reset the state when entering the scanner
     * ----------
     */
    BEGIN(INITIAL);
    plpgsql_SpaceScanned = false;

    /* ----------
     * On the first call to a new source report the
     * function's type (T_FUNCTION or T_TRIGGER)
     * ----------
     */
	if (!scanner_typereported)
	{
		scanner_typereported = true;
		return scanner_functype;
	}

    /* ----------
     * The keyword rules
     * ----------
     */
#line 1094 "pl_scan.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_current_state += YY_AT_BOL();
yy_match:
		do
			{
			register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
			if ( yy_accept[yy_current_state] )
				{
				yy_last_accepting_state = yy_current_state;
				yy_last_accepting_cpos = yy_cp;
				}
			while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
				{
				yy_current_state = (int) yy_def[yy_current_state];
				if ( yy_current_state >= 355 )
					yy_c = yy_meta[(unsigned int) yy_c];
				}
			yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
			++yy_cp;
			}
		while ( yy_base[yy_current_state] != 1439 );

yy_find_action:
		yy_act = yy_accept[yy_current_state];
		if ( yy_act == 0 )
			{ /* have to back up */
			yy_cp = yy_last_accepting_cpos;
			yy_current_state = yy_last_accepting_state;
			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 0: /* must back up */
			/* undo the effects of YY_DO_BEFORE_ACTION */
			*yy_cp = yy_hold_char;
			yy_cp = yy_last_accepting_cpos;
			yy_current_state = yy_last_accepting_state;
			goto yy_find_action;

case 1:
YY_RULE_SETUP
#line 135 "scan.l"
{ return K_ASSIGN;			}
	YY_BREAK
case 2:
YY_RULE_SETUP
#line 136 "scan.l"
{ return K_ASSIGN;			}
	YY_BREAK
case 3:
YY_RULE_SETUP
#line 137 "scan.l"
{ return K_DOTDOT;			}
	YY_BREAK
case 4:
YY_RULE_SETUP
#line 138 "scan.l"
{ return K_ALIAS;			}
	YY_BREAK
case 5:
YY_RULE_SETUP
#line 139 "scan.l"
{ return K_BEGIN;			}
	YY_BREAK
case 6:
YY_RULE_SETUP
#line 140 "scan.l"
{ return K_CLOSE;			}
	YY_BREAK
case 7:
YY_RULE_SETUP
#line 141 "scan.l"
{ return K_CONSTANT;		}
	YY_BREAK
case 8:
YY_RULE_SETUP
#line 142 "scan.l"
{ return K_CONTINUE;		}
	YY_BREAK
case 9:
YY_RULE_SETUP
#line 143 "scan.l"
{ return K_CURSOR;			}
	YY_BREAK
case 10:
YY_RULE_SETUP
#line 144 "scan.l"
{ return K_DEBUG;			}
	YY_BREAK
case 11:
YY_RULE_SETUP
#line 145 "scan.l"
{ return K_DECLARE;			}
	YY_BREAK
case 12:
YY_RULE_SETUP
#line 146 "scan.l"
{ return K_DEFAULT;			}
	YY_BREAK
case 13:
YY_RULE_SETUP
#line 147 "scan.l"
{ return K_DIAGNOSTICS;		}
	YY_BREAK
case 14:
YY_RULE_SETUP
#line 148 "scan.l"
{ return K_ELSE;			}
	YY_BREAK
case 15:
YY_RULE_SETUP
#line 149 "scan.l"
{ return K_ELSIF;           }
	YY_BREAK
case 16:
YY_RULE_SETUP
#line 150 "scan.l"
{ return K_ELSIF;           }
	YY_BREAK
case 17:
YY_RULE_SETUP
#line 151 "scan.l"
{ return K_END;				}
	YY_BREAK
case 18:
YY_RULE_SETUP
#line 152 "scan.l"
{ return K_EXCEPTION;		}
	YY_BREAK
case 19:
YY_RULE_SETUP
#line 153 "scan.l"
{ return K_EXECUTE;			}
	YY_BREAK
case 20:
YY_RULE_SETUP
#line 154 "scan.l"
{ return K_EXIT;			}
	YY_BREAK
case 21:
YY_RULE_SETUP
#line 155 "scan.l"
{ return K_FETCH;			}
	YY_BREAK
case 22:
YY_RULE_SETUP
#line 156 "scan.l"
{ return K_FOR;				}
	YY_BREAK
case 23:
YY_RULE_SETUP
#line 157 "scan.l"
{ return K_FROM;			}
	YY_BREAK
case 24:
YY_RULE_SETUP
#line 158 "scan.l"
{ return K_GET;				}
	YY_BREAK
case 25:
YY_RULE_SETUP
#line 159 "scan.l"
{ return K_IF;				}
	YY_BREAK
case 26:
YY_RULE_SETUP
#line 160 "scan.l"
{ return K_IN;				}
	YY_BREAK
case 27:
YY_RULE_SETUP
#line 161 "scan.l"
{ return K_INFO;			}
	YY_BREAK
case 28:
YY_RULE_SETUP
#line 162 "scan.l"
{ return K_INTO;			}
	YY_BREAK
case 29:
YY_RULE_SETUP
#line 163 "scan.l"
{ return K_IS;				}
	YY_BREAK
case 30:
YY_RULE_SETUP
#line 164 "scan.l"
{ return K_LOG;				}
	YY_BREAK
case 31:
YY_RULE_SETUP
#line 165 "scan.l"
{ return K_LOOP;			}
	YY_BREAK
case 32:
YY_RULE_SETUP
#line 166 "scan.l"
{ return K_NEXT;			}
	YY_BREAK
case 33:
YY_RULE_SETUP
#line 167 "scan.l"
{ return K_NOT;				}
	YY_BREAK
case 34:
YY_RULE_SETUP
#line 168 "scan.l"
{ return K_NOTICE;			}
	YY_BREAK
case 35:
YY_RULE_SETUP
#line 169 "scan.l"
{ return K_NULL;			}
	YY_BREAK
case 36:
YY_RULE_SETUP
#line 170 "scan.l"
{ return K_OPEN;			}
	YY_BREAK
case 37:
YY_RULE_SETUP
#line 171 "scan.l"
{ return K_OR;				}
	YY_BREAK
case 38:
YY_RULE_SETUP
#line 172 "scan.l"
{ return K_PERFORM;			}
	YY_BREAK
case 39:
YY_RULE_SETUP
#line 173 "scan.l"
{ return K_RAISE;			}
	YY_BREAK
case 40:
YY_RULE_SETUP
#line 174 "scan.l"
{ return K_RENAME;			}
	YY_BREAK
case 41:
YY_RULE_SETUP
#line 175 "scan.l"
{ return K_RESULT_OID;		}
	YY_BREAK
case 42:
YY_RULE_SETUP
#line 176 "scan.l"
{ return K_RETURN;			}
	YY_BREAK
case 43:
YY_RULE_SETUP
#line 177 "scan.l"
{ return K_REVERSE;			}
	YY_BREAK
case 44:
YY_RULE_SETUP
#line 178 "scan.l"
{ return K_ROW_COUNT;		}
	YY_BREAK
case 45:
YY_RULE_SETUP
#line 179 "scan.l"
{ return K_SELECT;			}
	YY_BREAK
case 46:
YY_RULE_SETUP
#line 180 "scan.l"
{ return K_THEN;			}
	YY_BREAK
case 47:
YY_RULE_SETUP
#line 181 "scan.l"
{ return K_TO;				}
	YY_BREAK
case 48:
YY_RULE_SETUP
#line 182 "scan.l"
{ return K_TYPE;			}
	YY_BREAK
case 49:
YY_RULE_SETUP
#line 183 "scan.l"
{ return K_WARNING;			}
	YY_BREAK
case 50:
YY_RULE_SETUP
#line 184 "scan.l"
{ return K_WHEN;			}
	YY_BREAK
case 51:
YY_RULE_SETUP
#line 185 "scan.l"
{ return K_WHILE;			}
	YY_BREAK
case 52:
YY_RULE_SETUP
#line 187 "scan.l"
{ return O_OPTION;			}
	YY_BREAK
case 53:
YY_RULE_SETUP
#line 188 "scan.l"
{ return O_DUMP;			}
	YY_BREAK
/* ----------
     * Special word rules
	 *
	 * We set plpgsql_error_lineno in each rule so that errors reported
	 * in the pl_comp.c subroutines will point to the right place.
     * ----------
     */
case 54:
YY_RULE_SETUP
#line 198 "scan.l"
{
	plpgsql_error_lineno = plpgsql_scanner_lineno();
	return plpgsql_parse_word(yytext); }
	YY_BREAK
case 55:
YY_RULE_SETUP
#line 201 "scan.l"
{
	plpgsql_error_lineno = plpgsql_scanner_lineno();
	return plpgsql_parse_dblword(yytext); }
	YY_BREAK
case 56:
YY_RULE_SETUP
#line 204 "scan.l"
{
	plpgsql_error_lineno = plpgsql_scanner_lineno();
	return plpgsql_parse_tripword(yytext); }
	YY_BREAK
case 57:
YY_RULE_SETUP
#line 207 "scan.l"
{
	plpgsql_error_lineno = plpgsql_scanner_lineno();
	return plpgsql_parse_wordtype(yytext); }
	YY_BREAK
case 58:
YY_RULE_SETUP
#line 210 "scan.l"
{
	plpgsql_error_lineno = plpgsql_scanner_lineno();
	return plpgsql_parse_dblwordtype(yytext); }
	YY_BREAK
case 59:
YY_RULE_SETUP
#line 213 "scan.l"
{
	plpgsql_error_lineno = plpgsql_scanner_lineno();
	return plpgsql_parse_tripwordtype(yytext); }
	YY_BREAK
case 60:
YY_RULE_SETUP
#line 216 "scan.l"
{
	plpgsql_error_lineno = plpgsql_scanner_lineno();
	return plpgsql_parse_wordrowtype(yytext); }
	YY_BREAK
case 61:
YY_RULE_SETUP
#line 219 "scan.l"
{
	plpgsql_error_lineno = plpgsql_scanner_lineno();
	return plpgsql_parse_dblwordrowtype(yytext); }
	YY_BREAK
case 62:
YY_RULE_SETUP
#line 222 "scan.l"
{
	plpgsql_error_lineno = plpgsql_scanner_lineno();
	return plpgsql_parse_word(yytext); }
	YY_BREAK
case 63:
YY_RULE_SETUP
#line 225 "scan.l"
{
	plpgsql_error_lineno = plpgsql_scanner_lineno();
	return plpgsql_parse_dblword(yytext); }
	YY_BREAK
case 64:
YY_RULE_SETUP
#line 228 "scan.l"
{
	plpgsql_error_lineno = plpgsql_scanner_lineno();
	return plpgsql_parse_tripword(yytext); }
	YY_BREAK
case 65:
YY_RULE_SETUP
#line 231 "scan.l"
{
	plpgsql_error_lineno = plpgsql_scanner_lineno();
	return plpgsql_parse_wordtype(yytext); }
	YY_BREAK
case 66:
YY_RULE_SETUP
#line 234 "scan.l"
{
	plpgsql_error_lineno = plpgsql_scanner_lineno();
	return plpgsql_parse_dblwordtype(yytext); }
	YY_BREAK
case 67:
YY_RULE_SETUP
#line 237 "scan.l"
{
	plpgsql_error_lineno = plpgsql_scanner_lineno();
	return plpgsql_parse_tripwordtype(yytext); }
	YY_BREAK
case 68:
YY_RULE_SETUP
#line 240 "scan.l"
{
	plpgsql_error_lineno = plpgsql_scanner_lineno();
	return plpgsql_parse_wordrowtype(yytext); }
	YY_BREAK
case 69:
YY_RULE_SETUP
#line 243 "scan.l"
{
	plpgsql_error_lineno = plpgsql_scanner_lineno();
	return plpgsql_parse_dblwordrowtype(yytext); }
	YY_BREAK
case 70:
YY_RULE_SETUP
#line 247 "scan.l"
{ return T_NUMBER;			}
	YY_BREAK
case 71:
YY_RULE_SETUP
#line 249 "scan.l"
{
				plpgsql_error_lineno = plpgsql_scanner_lineno();
				ereport(ERROR,
						(errcode(ERRCODE_DATATYPE_MISMATCH),
						 errmsg("unterminated quoted identifier")));
			}
	YY_BREAK
/* ----------
     * Ignore whitespaces but remember this happened
     * ----------
     */
case 72:
YY_RULE_SETUP
#line 260 "scan.l"
{ plpgsql_SpaceScanned = true;		}
	YY_BREAK
/* ----------
     * Eat up comments
     * ----------
     */
case 73:
YY_RULE_SETUP
#line 266 "scan.l"
;
	YY_BREAK
case 74:
YY_RULE_SETUP
#line 268 "scan.l"
{ start_lineno = plpgsql_scanner_lineno();
			  BEGIN(IN_COMMENT);
			}
	YY_BREAK
case 75:
YY_RULE_SETUP
#line 271 "scan.l"
{ BEGIN(INITIAL); plpgsql_SpaceScanned = true; }
	YY_BREAK
case 76:
YY_RULE_SETUP
#line 272 "scan.l"
;
	YY_BREAK
case 77:
YY_RULE_SETUP
#line 273 "scan.l"
;
	YY_BREAK
case YY_STATE_EOF(IN_COMMENT):
#line 274 "scan.l"
{
				plpgsql_error_lineno = start_lineno;
				ereport(ERROR,
						(errcode(ERRCODE_DATATYPE_MISMATCH),
						 errmsg("unterminated comment")));
			}
	YY_BREAK
/* ----------
     * Collect anything inside of ''s and return one STRING token
	 *
	 * Hacking yytext/yyleng here lets us avoid using yymore(), which is
	 * a win for performance.  It's safe because we know the underlying
	 * input buffer is not changing.
     * ----------
     */
case 78:
YY_RULE_SETUP
#line 289 "scan.l"
{
			  start_lineno = plpgsql_scanner_lineno();
			  start_charpos = yytext;
			  BEGIN(IN_STRING);
			}
	YY_BREAK
case 79:
YY_RULE_SETUP
#line 294 "scan.l"
{
			  /* for now, treat the same as a regular literal */
			  start_lineno = plpgsql_scanner_lineno();
			  start_charpos = yytext;
			  BEGIN(IN_STRING);
			}
	YY_BREAK
case 80:
YY_RULE_SETUP
#line 300 "scan.l"
{ }
	YY_BREAK
case 81:
YY_RULE_SETUP
#line 301 "scan.l"
{ /* can only happen with \ at EOF */ }
	YY_BREAK
case 82:
YY_RULE_SETUP
#line 302 "scan.l"
{ }
	YY_BREAK
case 83:
YY_RULE_SETUP
#line 303 "scan.l"
{
			  /* tell plpgsql_get_string_value it's not a dollar quote */
			  dolqlen = 0;
			  /* adjust yytext/yyleng to describe whole string token */
			  yyleng += (yytext - start_charpos);
			  yytext = start_charpos;
			  BEGIN(INITIAL);
			  return T_STRING;
			}
	YY_BREAK
case 84:
YY_RULE_SETUP
#line 312 "scan.l"
{ }
	YY_BREAK
case YY_STATE_EOF(IN_STRING):
#line 313 "scan.l"
{
				plpgsql_error_lineno = start_lineno;
				ereport(ERROR,
						(errcode(ERRCODE_DATATYPE_MISMATCH),
						 errmsg("unterminated string")));
			}
	YY_BREAK
case 85:
YY_RULE_SETUP
#line 320 "scan.l"
{
			  start_lineno = plpgsql_scanner_lineno();
			  start_charpos = yytext;
			  dolqstart = pstrdup(yytext);
			  BEGIN(IN_DOLLARQUOTE);
			}
	YY_BREAK
case 86:
YY_RULE_SETUP
#line 326 "scan.l"
{
			  if (strcmp(yytext, dolqstart) == 0)
			  {
					pfree(dolqstart);
					/* tell plpgsql_get_string_value it is a dollar quote */
					dolqlen = yyleng;
					/* adjust yytext/yyleng to describe whole string token */
					yyleng += (yytext - start_charpos);
					yytext = start_charpos;
					BEGIN(INITIAL);
					return T_STRING;
			  }
			  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);
			  }
			}
	YY_BREAK
case 87:
YY_RULE_SETUP
#line 348 "scan.l"
{ }
	YY_BREAK
case 88:
YY_RULE_SETUP
#line 349 "scan.l"
{ /* needed for $ inside the quoted text */ }
	YY_BREAK
case YY_STATE_EOF(IN_DOLLARQUOTE):
#line 350 "scan.l"
{ 
				plpgsql_error_lineno = start_lineno;
				ereport(ERROR,
						(errcode(ERRCODE_DATATYPE_MISMATCH),
						 errmsg("unterminated dollar-quoted string")));
			}
	YY_BREAK
/* ----------
     * Any unmatched character is returned as is
     * ----------
     */
case 89:
YY_RULE_SETUP
#line 361 "scan.l"
{ return yytext[0];			}
	YY_BREAK
case 90:
YY_RULE_SETUP
#line 363 "scan.l"
YY_FATAL_ERROR( "flex scanner jammed" );
	YY_BREAK
#line 1764 "pl_scan.c"
case YY_STATE_EOF(INITIAL):
	yyterminate();

	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;
	yy_current_state += YY_AT_BOL();

	for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
		{
		register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
		if ( yy_accept[yy_current_state] )
			{
			yy_last_accepting_state = yy_current_state;
			yy_last_accepting_cpos = yy_cp;
			}
		while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
			{
			yy_current_state = (int) yy_def[yy_current_state];
			if ( yy_current_state >= 355 )
				yy_c = yy_meta[(unsigned int) yy_c];
			}
		yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
		}

	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;
	register char *yy_cp = yy_c_buf_p;

	register YY_CHAR yy_c = 1;
	if ( yy_accept[yy_current_state] )
		{
		yy_last_accepting_state = yy_current_state;
		yy_last_accepting_cpos = yy_cp;
		}
	while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
		{
		yy_current_state = (int) yy_def[yy_current_state];
		if ( yy_current_state >= 355 )
			yy_c = yy_meta[(unsigned int) yy_c];
		}
	yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
	yy_is_jam = (yy_current_state == 354);

	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;

	yy_current_buffer->yy_at_bol = (c == '\n');

	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 363 "scan.l"



/*
 * This is the yylex routine called from outside. It exists to provide
 * a pushback facility, as well as to allow us to parse syntax that
 * requires more than one token of lookahead.
 */
int
plpgsql_yylex(void)
{
	int cur_token;

	if (have_pushback_token)
	{
		have_pushback_token = false;
		cur_token = pushback_token;
	}
	else if (have_lookahead_token)
	{
		have_lookahead_token = false;
		cur_token = lookahead_token;
	}
	else
		cur_token = yylex();

	/* Do we need to look ahead for a possible multiword token? */
	switch (cur_token)
	{
		/* RETURN NEXT must be reduced to a single token */
		case K_RETURN:
			if (!have_lookahead_token)
			{
				lookahead_token = yylex();
				have_lookahead_token = true;
			}
			if (lookahead_token == K_NEXT)
			{
				have_lookahead_token = false;
				cur_token = K_RETURN_NEXT;
			}
			break;

		default:
			break;
	}

	return cur_token;
}

/*
 * Push back a single token to be re-read by next plpgsql_yylex() call.
 */
void
plpgsql_push_back_token(int token)
{
	if (have_pushback_token)
		elog(ERROR, "cannot push back multiple tokens");
	pushback_token = token;
	have_pushback_token = true;
}

/*
 * Report a syntax error.
 */
void
plpgsql_yyerror(const char *message)
{
	const char *loc = yytext;
	int			cursorpos;

	plpgsql_error_lineno = plpgsql_scanner_lineno();

	/* in multibyte encodings, return index in characters not bytes */
	cursorpos = pg_mbstrlen_with_len(scanbuf, loc - scanbuf) + 1;

	if (*loc == YY_END_OF_BUFFER_CHAR)
	{
		ereport(ERROR,
				(errcode(ERRCODE_SYNTAX_ERROR),
				 /* translator: %s is typically "syntax error" */
				 errmsg("%s at end of input", message),
				 internalerrposition(cursorpos),
				 internalerrquery(scanstr)));
	}
	else
	{
		ereport(ERROR,
				(errcode(ERRCODE_SYNTAX_ERROR),
				 /* translator: first %s is typically "syntax error" */
				 errmsg("%s at or near \"%s\"", message, loc),
				 internalerrposition(cursorpos),
				 internalerrquery(scanstr)));
	}
}

/*
 * Get the line number at which the current token ends.  This substitutes
 * for flex's very poorly implemented yylineno facility.
 *
 * We assume that flex has written a '\0' over the character following the
 * current token in scanbuf.  So, we just have to count the '\n' characters
 * before that.  We optimize this a little by keeping track of the last
 * '\n' seen so far.
 */
int
plpgsql_scanner_lineno(void)
{
	const char *c;

	while ((c = strchr(cur_line_start, '\n')) != NULL)
	{
		cur_line_start = c + 1;
		cur_line_num++;
	}
	return cur_line_num;
}

/*
 * Called before any actual parsing is done
 *
 * Note: the passed "str" must remain valid until plpgsql_scanner_finish().
 * Although it is not fed directly to flex, we need the original string
 * to cite in error messages.
 */
void
plpgsql_scanner_init(const char *str, int functype)
{
	Size	slen;

	slen = strlen(str);

	/*
	 * Might be left over after ereport()
	 */
	if (YY_CURRENT_BUFFER)
		yy_delete_buffer(YY_CURRENT_BUFFER);

	/*
	 * Make a scan buffer with special termination needed by flex.
	 */
	scanbuf = palloc(slen + 2);
	memcpy(scanbuf, str, slen);
	scanbuf[slen] = scanbuf[slen + 1] = YY_END_OF_BUFFER_CHAR;
	scanbufhandle = yy_scan_buffer(scanbuf, slen + 2);

	/* Other setup */
	scanstr = str;

    scanner_functype = functype;
    scanner_typereported = false;

	have_pushback_token = false;
	have_lookahead_token = false;

	cur_line_start = scanbuf;
	cur_line_num = 1;

	/*----------
	 * Hack: skip any initial newline, so that in the common coding layout
	 *		CREATE FUNCTION ... AS '
	 *			code body
	 *		' LANGUAGE 'plpgsql';
	 * we will think "line 1" is what the programmer thinks of as line 1.
	 *----------
	 */
    if (*cur_line_start == '\r')
        cur_line_start++;
    if (*cur_line_start == '\n')
        cur_line_start++;

	BEGIN(INITIAL);
}

/*
 * Called after parsing is done to clean up after plpgsql_scanner_init()
 */
void
plpgsql_scanner_finish(void)
{
	yy_delete_buffer(scanbufhandle);
	pfree(scanbuf);
}

/*
 * Called after a T_STRING token is read to get the string literal's value
 * as a palloc'd string.  (We make this a separate call because in many
 * scenarios there's no need to get the decoded value.)
 *
 * Note: we expect the literal to be the most recently lexed token.  This
 * would not work well if we supported multiple-token pushback or if 
 * plpgsql_yylex() wanted to read ahead beyond a T_STRING token.
 */
char *
plpgsql_get_string_value(void)
{
	char	   *result;
	const char *cp;
	int			len;

	if (dolqlen > 0)
	{
		/* Token is a $foo$...$foo$ string */
		len = yyleng - 2 * dolqlen;
		Assert(len >= 0);
		result = (char *) palloc(len + 1);
		memcpy(result, yytext + dolqlen, len);
		result[len] = '\0';
	}
	else if (*yytext == 'E' || *yytext == 'e')
	{
		/* Token is an E'...' string */
		result = (char *) palloc(yyleng + 1);	/* more than enough room */
		len = 0;
		for (cp = yytext + 2; *cp; cp++)
		{
			if (*cp == '\'')
			{
				if (cp[1] == '\'')
					result[len++] = *cp++;
				/* else it must be string end quote */
			}
			else if (*cp == '\\')
			{
				if (cp[1] != '\0')	/* just a paranoid check */
					result[len++] = *(++cp);
			}
			else
				result[len++] = *cp;
		}
		result[len] = '\0';
	}
	else
	{
		/* Token is a '...' string */
		result = (char *) palloc(yyleng + 1);	/* more than enough room */
		len = 0;
		for (cp = yytext + 1; *cp; cp++)
		{
			if (*cp == '\'')
			{
				if (cp[1] == '\'')
					result[len++] = *cp++;
				/* else it must be string end quote */
			}
			else if (*cp == '\\')
			{
				if (cp[1] != '\0')	/* just a paranoid check */
					result[len++] = *(++cp);
			}
			else
				result[len++] = *cp;
		}
		result[len] = '\0';
	}
	return result;
}
