#line 2 "src/mapfile/mapfile.c"

#line 4 "src/mapfile/mapfile.c"

#define  YY_INT_ALIGNED short int

/* A lexical scanner generated by flex */

#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5
#define YY_FLEX_SUBMINOR_VERSION 33
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif

/* First, we deal with  platform-specific or compiler-specific issues. */

/* begin standard C headers. */
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>

/* end standard C headers. */

/* flex integer type definitions */

#ifndef FLEXINT_H
#define FLEXINT_H

/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */

#if __STDC_VERSION__ >= 199901L

/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
 * if you want the limit (max/min) macros for int types. 
 */
#ifndef __STDC_LIMIT_MACROS
#define __STDC_LIMIT_MACROS 1
#endif

#include <inttypes.h>
typedef int8_t flex_int8_t;
typedef uint8_t flex_uint8_t;
typedef int16_t flex_int16_t;
typedef uint16_t flex_uint16_t;
typedef int32_t flex_int32_t;
typedef uint32_t flex_uint32_t;
#else
typedef signed char flex_int8_t;
typedef short int flex_int16_t;
typedef int flex_int32_t;
typedef unsigned char flex_uint8_t; 
typedef unsigned short int flex_uint16_t;
typedef unsigned int flex_uint32_t;
#endif /* ! C99 */

/* Limits of integral types. */
#ifndef INT8_MIN
#define INT8_MIN               (-128)
#endif
#ifndef INT16_MIN
#define INT16_MIN              (-32767-1)
#endif
#ifndef INT32_MIN
#define INT32_MIN              (-2147483647-1)
#endif
#ifndef INT8_MAX
#define INT8_MAX               (127)
#endif
#ifndef INT16_MAX
#define INT16_MAX              (32767)
#endif
#ifndef INT32_MAX
#define INT32_MAX              (2147483647)
#endif
#ifndef UINT8_MAX
#define UINT8_MAX              (255U)
#endif
#ifndef UINT16_MAX
#define UINT16_MAX             (65535U)
#endif
#ifndef UINT32_MAX
#define UINT32_MAX             (4294967295U)
#endif

#endif /* ! FLEXINT_H */

#ifdef __cplusplus

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

#else	/* ! __cplusplus */

#if __STDC__

#define YY_USE_CONST

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

#ifdef YY_USE_CONST
#define yyconst const
#else
#define yyconst
#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. */
#ifndef YY_BUF_SIZE
#define YY_BUF_SIZE 16384
#endif

/* The state buf must be large enough to hold one state per character in the main buffer.
 */
#define YY_STATE_BUF_SIZE   ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))

#ifndef YY_TYPEDEF_YY_BUFFER_STATE
#define YY_TYPEDEF_YY_BUFFER_STATE
typedef struct yy_buffer_state *YY_BUFFER_STATE;
#endif

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

    #define YY_LESS_LINENO(n)
    
/* Return all but the first "n" matched characters back to the input stream. */
#define yyless(n) \
	do \
		{ \
		/* Undo effects of setting up yytext. */ \
        int yyless_macro_arg = (n); \
        YY_LESS_LINENO(yyless_macro_arg);\
		*yy_cp = (yy_hold_char); \
		YY_RESTORE_YY_MORE_OFFSET \
		(yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - 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).
 */

#ifndef YY_TYPEDEF_YY_SIZE_T
#define YY_TYPEDEF_YY_SIZE_T
typedef unsigned int yy_size_t;
#endif

#ifndef YY_STRUCT_YY_BUFFER_STATE
#define YY_STRUCT_YY_BUFFER_STATE
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;

    int yy_bs_lineno; /**< The line count. */
    int yy_bs_column; /**< The column count. */
    
	/* 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

	};
#endif /* !YY_STRUCT_YY_BUFFER_STATE */

/* Stack of input buffers. */
static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */

/* 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".
 *
 * Returns the top of the stack, or NULL.
 */
#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
                          ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
                          : NULL)

/* Same as previous macro, but useful when we know that the buffer stack is not
 * NULL or when we need an lvalue. For internal use only.
 */
#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]

/* 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 = 0;		/* 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 (FILE *input_file  );
void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer  );
YY_BUFFER_STATE yy_create_buffer (FILE *file,int size  );
void yy_delete_buffer (YY_BUFFER_STATE b  );
void yy_flush_buffer (YY_BUFFER_STATE b  );
void yypush_buffer_state (YY_BUFFER_STATE new_buffer  );
void yypop_buffer_state (void );

static void yyensure_buffer_stack (void );
static void yy_load_buffer_state (void );
static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file  );

#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER )

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

void *yyalloc (yy_size_t  );
void *yyrealloc (void *,yy_size_t  );
void yyfree (void *  );

#define yy_new_buffer yy_create_buffer

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

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

#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)

/* Begin user sect3 */

#define yywrap(n) 1
#define YY_SKIP_YYWRAP

typedef unsigned char YY_CHAR;

FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;

typedef int yy_state_type;

extern int yylineno;

int yylineno = 1;

extern char *yytext;
#define yytext_ptr yytext

static yy_state_type yy_get_previous_state (void );
static yy_state_type yy_try_NUL_trans (yy_state_type current_state  );
static int yy_get_next_buffer (void );
static void yy_fatal_error (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 = (size_t) (yy_cp - yy_bp); \
	(yy_hold_char) = *yy_cp; \
	*yy_cp = '\0'; \
	(yy_c_buf_p) = yy_cp;

#define YY_NUM_RULES 107
#define YY_END_OF_BUFFER 108
/* This struct is not used in this scanner,
   but its presence is necessary. */
struct yy_trans_info
	{
	flex_int32_t yy_verify;
	flex_int32_t yy_nxt;
	};
static yyconst flex_int16_t yy_accept[677] =
    {   0,
        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
      101,  101,  103,  103,    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,    0,    0,    0,    0,    0,    0,  108,  105,
      105,  106,  105,    1,  105,  105,  105,  105,  105,  105,
      105,  105,  105,  105,  105,  105,  105,  105,  105,  105,
      105,  105,  105,  105,  105,  105,  105,  105,   94,   94,
      105,  105,  105,  105,  101,  101,  101,  101,  101,  103,

      103,  103,  103,  103,  105,  105,  105,  105,   90,   90,
       90,   93,   93,   93,  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,  105,  105,  105,  105,  105,  105,  105,    0,  104,
        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,
       95,    0,    0,   96,    0,  101,  101,    0,  100,  101,

        0,  101,  103,  103,    0,  102,  103,    0,  103,    0,
       97,    0,    0,   98,    0,   90,   90,   90,   93,   93,
       93,    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,    0,
        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
        0,   99,    0,    4,    0,    5,    0,    0,    0,    0,
        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
        0,    6,    0,    0,    0,    0,    0,   65,    0,    0,

        0,  100,    4,  102,    4,    4,   90,    4,   93,    0,
        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
        0,    0,    0,    0,    0,   23,    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,    0,    0,    0,   85,    0,    0,
        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
        0,    0,    0,    0,   90,   92,    0,    0,   34,   91,
        0,    0,    0,   73,    0,    0,   74,    0,    0,   86,

        0,   22,    0,    0,    0,    0,    0,    0,    0,   20,
        0,    0,    0,    0,    0,   52,    0,    0,    0,    0,
        0,   27,    0,    0,   30,   31,    0,    0,    0,    0,
        0,   43,   56,    0,   58,    0,    0,    0,    0,    0,
        0,   83,    0,    0,    0,    0,    0,    0,    0,    0,
        0,   59,   60,    0,    0,    0,    0,    0,    0,   90,
       76,    0,    0,    0,    0,   38,    0,    0,    0,   21,
        0,   16,    0,   78,   77,    0,    0,   47,   49,    0,
        0,    0,    0,    0,   55,   24,   25,    0,    0,    0,
       82,    0,   45,    0,    0,   57,    0,    0,    9,    0,

        0,    0,    3,    0,    0,    0,    0,    0,    0,   68,
        0,   61,   62,    0,    0,    0,    0,    0,   90,    0,
        0,    0,    0,   35,   37,   39,    0,    0,    0,    0,
        0,   18,    0,    0,    0,    0,    0,    0,   54,    0,
        0,    0,    0,   46,    0,   81,    2,    0,   12,    0,
        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
        0,    0,    0,   89,    0,    0,    0,   84,    0,    0,
        0,    0,    0,    0,    0,    0,   50,    0,   80,    0,
        0,    0,    0,    0,    0,    0,    0,    0,    0,    7,
        0,   69,    0,    0,    0,    0,   64,    0,   72,   67,

        0,    0,    0,    0,    0,    0,   75,    0,   17,   19,
        0,    0,   53,   26,    0,   29,   42,    0,    0,   13,
        0,    0,   70,   14,    8,    0,   63,    0,    0,   32,
        0,    0,    0,   41,    0,   48,    0,    0,    0,    0,
        0,   79,    0,    0,   33,   87,   36,    0,   15,    0,
        0,    0,   10,    0,    0,   66,    0,    0,    0,    0,
        0,   71,    0,    0,    0,   51,   28,   44,    0,    0,
        0,    0,   88,   40,   11,    0
    } ;

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

       12,   13,   14,   15,   16,   17,   18,   19,   20,   21,
       22,   23,   24,   25,   26,   27,   28,   29,   30,   31,
       32,   33,    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,    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,    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,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1
    } ;

static yyconst flex_int32_t yy_meta[34] =
    {   0,
        1,    2,    2,    1,    1,    1,    1,    3,    3,    3,
        3,    3,    3,    3,    3,    3,    3,    3,    3,    3,
        3,    3,    3,    3,    3,    3,    3,    3,    3,    3,
        3,    3,    3
    } ;

static yyconst flex_int16_t yy_base[706] =
    {   0,
        0,   19,   30,    0,   56,    0,   82,  101,  120,  131,
      142,  153,  164,  175,  186,  205,  224,  235,  247,  270,
      293,  320,  338,    0,  357,  383,   12,   13,   14,   22,
      409,    0,  432,    0,   42,   43,  455,    0,   61,   62,
       74,   75,   92,   94,  481,  504,  120,  142,  527,  544,
      561,  580,  164,  178,  180,  181,  600,  617,  912,  913,
      913,  913,  907,  913,  904,  888,  887,  899,  884,  897,
      882,   16,    1,  895,  874,  876,  872,  887,   55,  886,
      885,   95,  874,  883,  874,  871,    2,  880,  913,  913,
      887,  884,  885,  882,    0,  115,   90,    0,  866,    0,

      126,  210,    0,  865,  881,  878,  879,  876,    0,  860,
      858,    0,  858,  853,   79,   36,  183,  852,  864,  853,
      866,  861,  864,  844,  858,  851,  110,  843,  855,  858,
      183,  853,  843,  841,  191,  854,   57,  845,  839,  837,
      837,  835,  828,  830,  838,  828,  844,  839,  830,  841,
      826,  839,  824,  825,  836,  131,  839,  836,  837,  913,
      834,  828,  828,  814,  815,  808,  813,  825,  800,  817,
      810,  802,  806,  815,  813,  817,  816,  803,  802,  812,
      797,  794,  796,  809,  808,  801,  783,  786,  792,  807,
      913,  804,  805,  913,  802,    0,  148,  803,    0,  215,

      800,  794,    0,  170,  800,    0,  254,  797,  791,  797,
      913,  794,  795,  913,  792,    0,  786,  770,    0,  784,
      766,  785,  771,  764,  770,  781,  769,  765,   84,  778,
      769,  775,  756,  762,  769,  749,  752,  755,  755,  744,
      766,  742,  753,  144,  758,  752,  762,  742,  741,  734,
      746,  754,  750,  744,  192,  741,  734,  744,  726,  750,
      748,  736,  747,  729,  728,  732,  730,  742,  729,  732,
      743,  913,  740,  913,  726,  913,  731,  735,  715,  727,
      728,  727,  726,  714,  719,  710,  722,  714,  709,  722,
      707,  913,  702,  706,  700,  715,  711,  913,  697,  715,

      699,  913,    0,  913,    0,    0,  694,    0,  708,  693,
      660,  664,  613,  608,  607,  605,  620,  602,  618,  607,
      615,  618,  613,  604,  592,  913,  593,  589,  599,  602,
      594,  603,  588,  583,  590,  586,  597,  583,  572,  586,
      588,  568,  575,  570,  569,  563,  570,  566,  575,  563,
      571,  557,  565,  560,  556,  563,  546,  558,  559,  549,
      541,  552,  544,  537,  550,  536,  538,  913,  530,  544,
      523,  529,  541,  540,  529,  531,  514,  520,  532,  530,
      529,  527,  527,  518,  522,    0,  509,  522,  913,  913,
      505,  518,  517,  913,  505,  515,  913,  507,  514,  913,

      496,  913,  509,  496,  498,  498,  504,  493,  495,  913,
      501,  487,  495,  494,  495,  490,  483,  489,  491,  477,
      488,  913,  482,  471,  913,  913,  476,  475,  481,  480,
      483,  913,  913,  478,  913,  462,  477,  473,  476,  471,
      455,  913,  469,  452,  466,  455,  462,  464,  449,  452,
      462,  913,  913,  444,  441,  201,  444,  453,  452,  443,
      147,  447,  431,  428,  426,  913,  425,  224,  441,  913,
      421,  913,  438,  913,  913,  426,  436,  427,  913,  414,
      418,  413,  407,  414,  913,  913,  913,  416,  410,  414,
      913,  418,  913,  399,  395,  913,  394,  407,  913,  391,

      390,  384,  913,  402,  385,  403,  388,  400,  399,  380,
      378,  913,  913,  396,  377,  378,  373,  371,  371,  371,
      368,  367,  381,  376,  913,  913,  370,  363,  362,  360,
      371,  913,  356,  355,  349,  368,  358,  366,  913,  355,
      363,  347,  345,  913,  349,  913,  913,  343,  913,  346,
      346,  351,  343,  355,  339,  336,  348,  344,  327,  331,
      327,  337,  332,    0,  321,  330,  325,  913,  313,  325,
      326,  329,  320,  323,  322,  321,  913,  321,  913,  310,
      315,  318,  287,  306,  294,  304,  303,  289,  291,  913,
      300,  913,  296,  283,  286,  293,  913,  299,  913,  913,

      278,  284,  281,  290,  282,  272,  913,  269,  913,  913,
      270,  267,  913,  913,  266,  913,  913,  260,  261,  913,
      265,  263,  913,  913,  913,  275,  913,  254,  257,  913,
      258,  258,  257,  913,  247,  913,  248,  247,  249,  243,
      255,  913,  235,  249,  913,  231,  913,  239,  913,  224,
      223,  222,  913,  216,  208,  913,  202,  206,  198,  197,
      199,  913,  192,  170,  179,  913,  913,  913,  117,   97,
       54,   24,  913,  913,  913,  913,  637,  640,  643,  646,
      649,  652,  655,  658,  661,  664,  667,  670,  673,  676,
      679,  682,  685,  688,  691,  694,  697,    8,    5,  700,

      703,  706,  709,  712,  715
    } ;

static yyconst flex_int16_t yy_def[706] =
    {   0,
      677,  677,    2,    3,    2,    5,    2,    2,  677,  677,
      678,  678,  679,  679,    2,    2,  677,  677,  680,  680,
      681,  681,    2,   23,    2,    2,    2,    2,    2,    2,
        2,   31,    2,   33,    2,    2,   33,   37,    2,    2,
        2,    2,    2,    2,    2,    2,    2,    2,    2,    2,
        2,    2,    2,    2,    2,    2,    2,    2,  676,  676,
      676,  676,  682,  676,  683,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      684,  685,  686,  687,  688,  689,  690,  688,  688,  691,

      692,  693,  691,  691,  694,  695,  696,  697,  698,  698,
      698,  699,  699,  699,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  700,  701,  682,  676,
      683,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  684,
      676,  685,  686,  676,  687,  688,  689,  702,  688,  690,

      703,  688,  691,  692,  704,  691,  693,  705,  691,  694,
      676,  695,  696,  676,  697,  698,  698,  698,  699,  699,
      699,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      700,  676,  701,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,

      676,  676,  688,  676,  691,  698,  698,  699,  699,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  698,  699,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,

      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  698,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,

      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  698,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  698,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,

      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,    0,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,

      676,  676,  676,  676,  676
    } ;

static yyconst flex_int16_t yy_nxt[947] =
    {   0,
      676,   61,   62,   63,   64,   65,   61,  219,  169,  187,
      216,   66,  170,  188,  676,   67,   60,   60,   60,   68,
       61,   62,   63,   64,   65,   61,   60,   60,   60,   60,
       66,   60,   60,   60,   67,  168,  163,   60,   68,   69,
       70,   60,   71,  224,  675,   72,   60,   60,   73,   60,
       74,   75,   76,   77,   78,   79,   80,   60,   60,   81,
       60,   60,   60,  225,  176,   60,   60,   82,   83,  177,
       84,   85,  250,  674,   86,   87,   60,   60,   60,   60,
       60,   60,   88,   89,   90,   91,  178,   92,  251,   60,
       60,  201,  201,   60,   60,  199,   60,  222,   60,  317,

      223,   60,   89,   90,   91,  318,   92,   60,  673,   60,
      147,   60,  147,   60,  181,  162,  198,  198,  199,  182,
       60,   89,   90,   93,   60,   94,   61,  205,  205,  206,
      162,   66,   89,   90,   93,  149,   94,   61,  249,  150,
      238,  672,   66,   61,   62,   96,   60,   97,   98,  198,
      198,  199,  270,   99,   61,   62,   96,  149,   97,   98,
      520,  150,  521,  333,   99,   89,   90,  101,   60,  102,
      103,  205,  205,  206,  334,  104,   89,   90,  101,   60,
      102,  103,   60,   60,   60,   60,  104,   89,   90,  105,
      671,  106,  670,   60,  226,   60,   60,   60,  227,   60,

       60,  345,  274,  669,  228,   60,   89,   90,  105,  242,
      106,  208,  208,  247,  243,  206,  201,  201,  248,  668,
      199,  667,  666,  514,   60,   89,   90,  107,  515,  108,
       61,  527,  665,  664,  663,   66,   89,   90,  107,  528,
      108,   61,  662,  661,  660,  659,   66,   60,   61,   62,
       63,   60,   65,   61,  658,  208,  208,  657,  110,  206,
      656,  655,  654,  653,  652,  651,  650,  649,  648,  111,
       60,   61,   62,   63,   60,   65,   61,  647,  646,  645,
      644,  110,  643,  642,  641,  640,  639,  638,  637,  636,
      635,  634,  111,   60,   61,   62,   63,   60,   65,   61,

      633,  632,  631,  630,  113,  629,  628,  627,  626,  625,
      624,  623,  622,  621,  620,  619,  618,  617,  616,  114,
       60,   61,   62,   63,   60,   65,   61,  615,  614,  613,
      612,  113,  611,  610,  609,  608,  607,  606,  605,  604,
      603,  602,  601,  600,  599,  598,  114,  115,  116,  597,
      117,  118,  119,  596,  120,  595,  121,  122,  123,  594,
       76,   60,  593,  592,  591,  590,  589,  588,  587,  586,
      585,  584,  124,  583,  582,  581,   60,  580,  579,  578,
      577,  576,  575,  125,  574,  573,  126,   60,  572,  571,
      570,  569,  568,  567,  566,  565,  564,  563,  124,  562,

      561,  560,   60,  559,  558,  557,  556,  555,  554,  125,
      553,  552,  126,   60,  551,  550,  549,  548,  547,  546,
      127,  545,  128,  544,   60,  543,  129,  130,   60,  542,
      541,  540,  539,  538,  131,  132,   60,  537,  536,  133,
      535,  134,  534,  533,  532,  531,  530,   60,  529,  526,
      525,   60,  524,  135,  136,  523,  522,  137,  519,  518,
      517,  138,  139,  516,  140,  513,  141,  142,  512,  511,
      510,  509,  508,  507,  506,  505,  143,  144,  504,  503,
      145,  502,  501,  500,  146,   60,  499,  498,  497,  496,
      495,  494,  493,  492,  491,  490,   60,  489,  488,  147,

       60,  487,  486,  485,  484,  483,  482,  148,   60,  481,
      480,  479,  478,  477,  476,  475,  474,  473,  472,   60,
      471,  470,  147,   60,  469,  468,  467,  466,  465,  464,
      148,   60,  463,  462,  461,  460,  459,  458,  457,  151,
      456,  455,   60,  454,  453,  452,   60,  152,   60,  451,
      450,  449,  448,  447,  446,  445,  151,  444,  443,   60,
      442,  441,  440,   60,  152,   60,  439,  438,  437,  436,
      435,  434,  433,  153,  432,  431,  154,  430,  429,  428,
       60,  155,  427,  156,   60,  426,  425,  424,  423,  422,
      421,  420,  153,  419,  418,  154,  417,  416,  415,   60,

      155,  414,  156,  157,   60,  158,  413,  412,  411,  410,
      409,  408,  407,  406,  405,   60,  404,  403,  402,   60,
      157,   60,  158,  401,  400,  399,  398,  397,  396,  395,
      394,  393,   60,  392,  391,  390,   60,   60,   60,   60,
       95,   95,   95,  100,  100,  100,  109,  109,  109,  112,
      112,  112,  159,  159,  159,  161,  161,  161,  190,  190,
      190,  192,  192,  192,  193,  193,  193,  195,  195,  195,
      196,  389,  196,  197,  197,  197,  200,  200,  200,  203,
      388,  203,  204,  204,  204,  207,  207,  207,  210,  210,
      210,  212,  212,  212,  213,  213,  213,  215,  215,  215,

      271,  271,  271,  273,  273,  273,  198,  198,  198,  201,
      201,  201,  205,  205,  205,  208,  208,  208,  387,  386,
      385,  384,  383,  382,  381,  380,  379,  378,  377,  376,
      375,  374,  373,  372,  371,  370,  369,  368,  367,  366,
      365,  364,  363,  362,  361,  272,  272,  360,  359,  358,
      357,  356,  355,  354,  353,  352,  351,  350,  349,  348,
      347,  346,  344,  343,  342,  341,  340,  339,  338,  337,
      336,  335,  332,  331,  330,  329,  328,  327,  326,  325,
      324,  323,  322,  321,  320,  319,  316,  315,  314,  313,
      312,  311,  310,  309,  308,  307,  306,  214,  214,  211,

      211,  305,  304,  304,  303,  302,  302,  194,  194,  191,
      191,  301,  300,  299,  298,  297,  296,  295,  294,  293,
      292,  291,  290,  289,  288,  287,  286,  285,  284,  283,
      282,  281,  280,  279,  278,  277,  276,  275,  274,  160,
      160,  272,  272,  269,  268,  267,  266,  265,  264,  263,
      262,  261,  260,  259,  258,  257,  256,  255,  254,  253,
      252,  249,  246,  245,  244,  241,  240,  239,  237,  236,
      235,  234,  233,  232,  231,  230,  229,  221,  220,  218,
      217,  214,  214,  211,  211,  209,  202,  194,  194,  191,
      191,  189,  186,  185,  184,  183,  180,  179,  175,  174,

      173,  172,  171,  167,  166,  165,  164,  163,  162,  160,
      160,  676,   59,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676
    } ;

static yyconst flex_int16_t yy_chk[947] =
    {   0,
        0,    1,    1,    1,    1,    1,    1,  699,   73,   87,
      698,    1,   73,   87,    0,    1,   27,   28,   29,    1,
        2,    2,    2,    2,    2,    2,   30,   27,   28,   29,
        2,   27,   28,   29,    2,   72,   72,   30,    2,    3,
        3,   30,    3,  116,  672,    3,   35,   36,    3,    3,
        3,    3,    3,    3,    3,    3,    3,   35,   36,    3,
        5,   35,   36,  116,   79,   39,   40,    5,    5,   79,
        5,    5,  137,  671,    5,    5,   39,   40,   41,   42,
       39,   40,    5,    7,    7,    7,   79,    7,  137,   41,
       42,   97,   97,   41,   42,   97,   43,  115,   44,  229,

      115,    7,    8,    8,    8,  229,    8,   43,  670,   44,
       43,   43,   44,   44,   82,   82,   96,   96,   96,   82,
        8,    9,    9,    9,   47,    9,    9,  101,  101,  101,
      127,    9,   10,   10,   10,   47,   10,   10,  156,   47,
      127,  669,   10,   11,   11,   11,   48,   11,   11,  197,
      197,  197,  156,   11,   12,   12,   12,   48,   12,   12,
      461,   48,  461,  244,   12,   13,   13,   13,   53,   13,
       13,  204,  204,  204,  244,   13,   14,   14,   14,   53,
       14,   14,   54,   53,   55,   56,   14,   15,   15,   15,
      665,   15,  664,   54,  117,   55,   56,   54,  117,   55,

       56,  255,  255,  663,  117,   15,   16,   16,   16,  131,
       16,  102,  102,  135,  131,  102,  200,  200,  135,  661,
      200,  660,  659,  456,   16,   17,   17,   17,  456,   17,
       17,  468,  658,  657,  655,   17,   18,   18,   18,  468,
       18,   18,  654,  652,  651,  650,   18,   19,   19,   19,
       19,   19,   19,   19,  648,  207,  207,  646,   19,  207,
      644,  643,  641,  640,  639,  638,  637,  635,  633,   19,
       20,   20,   20,   20,   20,   20,   20,  632,  631,  629,
      628,   20,  626,  622,  621,  619,  618,  615,  612,  611,
      608,  606,   20,   21,   21,   21,   21,   21,   21,   21,

      605,  604,  603,  602,   21,  601,  598,  596,  595,  594,
      593,  591,  589,  588,  587,  586,  585,  584,  583,   21,
       22,   22,   22,   22,   22,   22,   22,  582,  581,  580,
      578,   22,  576,  575,  574,  573,  572,  571,  570,  569,
      567,  566,  565,  563,  562,  561,   22,   23,   23,  560,
       23,   23,   23,  559,   23,  558,   23,   23,   23,  557,
       23,   25,  556,  555,  554,  553,  552,  551,  550,  548,
      545,  543,   25,  542,  541,  540,   25,  538,  537,  536,
      535,  534,  533,   25,  531,  530,   25,   26,  529,  528,
      527,  524,  523,  522,  521,  520,  519,  518,   26,  517,

      516,  515,   26,  514,  511,  510,  509,  508,  507,   26,
      506,  505,   26,   31,  504,  502,  501,  500,  498,  497,
       31,  495,   31,  494,   31,  492,   31,   31,   31,  490,
      489,  488,  484,  483,   31,   31,   33,  482,  481,   33,
      480,   33,  478,  477,  476,  473,  471,   33,  469,  467,
      465,   33,  464,   33,   33,  463,  462,   33,  460,  459,
      458,   33,   37,  457,   37,  455,   37,   37,  454,  451,
      450,  449,  448,  447,  446,  445,   37,   37,  444,  443,
       37,  441,  440,  439,   37,   45,  438,  437,  436,  434,
      431,  430,  429,  428,  427,  424,   45,  423,  421,   45,

       45,  420,  419,  418,  417,  416,  415,   45,   46,  414,
      413,  412,  411,  409,  408,  407,  406,  405,  404,   46,
      403,  401,   46,   46,  399,  398,  396,  395,  393,  392,
       46,   49,  391,  388,  387,  385,  384,  383,  382,   49,
      381,  380,   49,  379,  378,  377,   49,   49,   50,  376,
      375,  374,  373,  372,  371,  370,   50,  369,  367,   50,
      366,  365,  364,   50,   50,   51,  363,  362,  361,  360,
      359,  358,  357,   51,  356,  355,   51,  354,  353,  352,
       51,   51,  351,   51,   52,  350,  349,  348,  347,  346,
      345,  344,   52,  343,  342,   52,  341,  340,  339,   52,

       52,  338,   52,   57,   57,   57,  337,  336,  335,  334,
      333,  332,  331,  330,  329,   57,  328,  327,  325,   57,
       58,   58,   58,  324,  323,  322,  321,  320,  319,  318,
      317,  316,   58,  315,  314,  313,   58,  677,  677,  677,
      678,  678,  678,  679,  679,  679,  680,  680,  680,  681,
      681,  681,  682,  682,  682,  683,  683,  683,  684,  684,
      684,  685,  685,  685,  686,  686,  686,  687,  687,  687,
      688,  312,  688,  689,  689,  689,  690,  690,  690,  691,
      311,  691,  692,  692,  692,  693,  693,  693,  694,  694,
      694,  695,  695,  695,  696,  696,  696,  697,  697,  697,

      700,  700,  700,  701,  701,  701,  702,  702,  702,  703,
      703,  703,  704,  704,  704,  705,  705,  705,  310,  309,
      307,  301,  300,  299,  297,  296,  295,  294,  293,  291,
      290,  289,  288,  287,  286,  285,  284,  283,  282,  281,
      280,  279,  278,  277,  275,  273,  271,  270,  269,  268,
      267,  266,  265,  264,  263,  262,  261,  260,  259,  258,
      257,  256,  254,  253,  252,  251,  250,  249,  248,  247,
      246,  245,  243,  242,  241,  240,  239,  238,  237,  236,
      235,  234,  233,  232,  231,  230,  228,  227,  226,  225,
      224,  223,  222,  221,  220,  218,  217,  215,  213,  212,

      210,  209,  208,  205,  202,  201,  198,  195,  193,  192,
      190,  189,  188,  187,  186,  185,  184,  183,  182,  181,
      180,  179,  178,  177,  176,  175,  174,  173,  172,  171,
      170,  169,  168,  167,  166,  165,  164,  163,  162,  161,
      159,  158,  157,  155,  154,  153,  152,  151,  150,  149,
      148,  147,  146,  145,  144,  143,  142,  141,  140,  139,
      138,  136,  134,  133,  132,  130,  129,  128,  126,  125,
      124,  123,  122,  121,  120,  119,  118,  114,  113,  111,
      110,  108,  107,  106,  105,  104,   99,   94,   93,   92,
       91,   88,   86,   85,   84,   83,   81,   80,   78,   77,

       76,   75,   74,   71,   70,   69,   68,   67,   66,   65,
       63,   59,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676
    } ;

static yy_state_type yy_last_accepting_state;
static char *yy_last_accepting_cpos;

extern int yy_flex_debug;
int yy_flex_debug = 0;

/* 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 "src/mapfile/mapfile.l"
#line 2 "src/mapfile/mapfile.l"


#include <assert.h>
#include <string.h>
#include <stdio.h>
#include <libpq-fe.h>
#include <libxml/xmlreader.h>
#include "../ows_define.h"
#include "../ows_struct.h"
#include "../ows_api.h"

#define OWS_MAP_EATLINE char c ; for (c=input() ; c && c != '\n' ; c=input());
#define OWS_MAP_MAX_INCLUDE_DEPTH 5

#if 0
#define OWS_MAP_DBG fprintf(stderr, "State: {%i} %i \n", yy_top_state(), YY_START);
#else
#define OWS_MAP_DBG 
#endif


static buffer * mapfile_build_path(ows * o, char * fpath)
{
	buffer * path;
	
	assert(fpath);

	/* Path is absolute */
	if ((fpath[0] == '/') || (fpath[0] == '\\') || (strlen(fpath) && (fpath[1] == ':')))
		return buffer_from_str(fpath);

	/* Path is relative */
	path = buffer_init();
	buffer_copy(path, o->config_file);

 	for ( /* empty */ ; path->use ; path->use--) 
		if ((path->buf[path->use] == '/') || (path->buf[path->use] == '\\')) { path->use++ ; break; }	
	
	buffer_add_str(path, fpath);

	return path;
}

enum map_md_state {
    MAP_MD_UPDATESEQUENCE,
    MAP_MD_SCHEMAS_LOCATION,
    MAP_MD_ABSTRACT,
    MAP_MD_ACCESSCONSTRAINTS,
    MAP_MD_ENCODING,
    MAP_MD_FEES,
    MAP_MD_KEYWORDLIST,
    MAP_MD_MAXFEATURES,
    MAP_MD_NAMESPACE_PREFIX,
    MAP_MD_NAMESPACE_URI,
    MAP_MD_TITLE,
    MAP_MD_SRS,
    MAP_MD_FEATURE_COLLECTION,
    MAP_MD_CONTACT_NAME,
    MAP_MD_CONTACT_EMAIL,
    MAP_MD_CONTACT_INDIVIDUAL,
    MAP_MD_CONTACT_POSITION,
    MAP_MD_CONTACT_PHONE,
    MAP_MD_CONTACT_FAX,
    MAP_MD_CONTACT_ADDRESS,
    MAP_MD_CONTACT_CITY,
    MAP_MD_CONTACT_COUNTRY,
    MAP_MD_TOWS_ONLINERESOURCE,
    MAP_MD_TOWS_SCHEMA_DIR,
    MAP_MD_TOWS_DB_ENCODING,
    MAP_MD_TOWS_LOG,
    MAP_MD_TOWS_LOG_LEVEL,
    MAP_MD_TOWS_WFS_DEFAULT_VERSION,
    MAP_MD_TOWS_METER_PRECISION,
    MAP_MD_TOWS_DEGREE_PRECISION,
    MAP_MD_TOWS_DISPLAY_BBOX,
    MAP_MD_TOWS_ESTIMATED_EXTENT,
    MAP_MD_TOWS_CHECK_SCHEMA,
    MAP_MD_TOWS_CHECK_VALID_GEOM,
    MAP_MD_TOWS_EXPOSE_PK,
    MAP_MD_TOWS_GEOBBOX,
    MAP_MD_SKIP
};

enum map_lmd_state {
    MAP_LMD_EXCLUDE_ITEMS,
    MAP_LMD_FEATURE_ID,
    MAP_LMD_INCLUDE_ITEMS,
    MAP_LMD_XML_ITEMS,
    MAP_LMD_ABSTRACT,
    MAP_LMD_EXTENT,
    MAP_LMD_KEYWORDLIST,
    MAP_LMD_METADATAURL_FORMAT,
    MAP_LMD_METADATAURL_HREF,
    MAP_LMD_METADATAURL_TYPE,
    MAP_LMD_NAMESPACE_PREFIX,
    MAP_LMD_NAMESPACE_URI,
    MAP_LMD_SRS,
    MAP_LMD_TITLE,
    MAP_LMD_TOWS_TABLE,
    MAP_LMD_TOWS_SCHEMA,
    MAP_LMD_TOWS_RETRIEVABLE,
    MAP_LMD_TOWS_WRITABLE,
    MAP_LMD_TOWS_GEOBBOX,
    MAP_LMD_TOWS_GML_NS_LIST,
    MAP_LMD_SKIP
};

enum map_prop_state {
    MAP_NAME
};

enum map_layer_prop_state {
    MAP_LAYER_NAME,
    MAP_LAYER_CONNECTION
	
};

/*
 * Global Vars 
 */
ows *map_o = NULL;
ows_layer *map_l = NULL;
list * map_srid = NULL;
buffer *map_ns_prefix = NULL;
buffer *map_ns_uri = NULL;
bool map_is_postgis = false;
bool map_is_dump = false;
YY_BUFFER_STATE map_include_stack[OWS_MAP_MAX_INCLUDE_DEPTH];
int map_include_stack_ptr = 0;
enum map_md_state map_md_state;
enum map_lmd_state map_lmd_state;
enum map_prop_state map_prop_state;
enum map_layer_prop_state map_layer_prop_state;


static void metadata_key(char *yytext, bool quotes)
{
	char *p;

	/* remove surrounding quotes */
	if (quotes) {
		 for (p = yytext; *p ; p++); *(--p) = 0; yytext++;
	}

	if     (!strncmp("ows_updatesequence", yytext, 18))
		map_md_state = MAP_MD_UPDATESEQUENCE;
	else if(!strncmp("ows_schemas_location", yytext, 20))
		map_md_state = MAP_MD_SCHEMAS_LOCATION;
	else if(!strncmp("wfs_abstract", yytext, 12))
		map_md_state = MAP_MD_ABSTRACT;
	else if(!strncmp("wfs_accessconstraints", yytext, 21))
		map_md_state = MAP_MD_ACCESSCONSTRAINTS;
	else if(!strncmp("wfs_encoding", yytext, 12))
		map_md_state = MAP_MD_ENCODING;
	else if(!strncmp("wfs_fees", yytext, 8))
		map_md_state = MAP_MD_FEES;
	else if(!strncmp("wfs_keywordlist", yytext, 15))
		map_md_state = MAP_MD_KEYWORDLIST;
	else if(!strncmp("wfs_maxfeatures", yytext, 15))
		map_md_state = MAP_MD_MAXFEATURES;
	else if(!strncmp("wfs_namespace_prefix", yytext, 20))
		map_md_state = MAP_MD_NAMESPACE_PREFIX;
	else if(!strncmp("wfs_namespace_uri", yytext, 17))
		map_md_state = MAP_MD_NAMESPACE_URI;
	else if(!strncmp("wfs_title", yytext, 9))
		map_md_state = MAP_MD_TITLE;
	else if(!strncmp("wfs_srs", yytext, 7))
		map_md_state = MAP_MD_SRS;
	else if(!strncmp("wfs_feature_collection", yytext, 22))
		map_md_state = MAP_MD_FEATURE_COLLECTION;
	else if(!strncmp("ows_contactorganization", yytext, 23))
		map_md_state = MAP_MD_CONTACT_NAME;
	else if(!strncmp("ows_contactelectronicmailaddress", yytext, 32))
		map_md_state = MAP_MD_CONTACT_EMAIL;
	else if(!strncmp("ows_contactperson", yytext, 17))
		map_md_state = MAP_MD_CONTACT_INDIVIDUAL;
	else if(!strncmp("ows_contactposition", yytext, 19))
		map_md_state = MAP_MD_CONTACT_POSITION;
	else if(!strncmp("ows_contactphone", yytext, 16))
		map_md_state = MAP_MD_CONTACT_PHONE;
	else if(!strncmp("ows_address", yytext, 11))
		map_md_state = MAP_MD_CONTACT_ADDRESS;
	else if(!strncmp("ows_city", yytext, 8))
		map_md_state = MAP_MD_CONTACT_CITY;
	else if(!strncmp("ows_country", yytext, 11))
		map_md_state = MAP_MD_CONTACT_COUNTRY;
	else if(!strncmp("ows_contactfacsimiletelephone", yytext, 29))
		map_md_state = MAP_MD_CONTACT_FAX;
	else if(!strncmp("tinyows_onlineresource", yytext, 21))
		map_md_state = MAP_MD_TOWS_ONLINERESOURCE;
	else if(!strncmp("tinyows_db_encoding", yytext, 19))
		map_md_state = MAP_MD_TOWS_DB_ENCODING;
	else if(!strncmp("tinyows_schema_dir", yytext, 18))
		map_md_state = MAP_MD_TOWS_SCHEMA_DIR;
	else if(!strncmp("tinyows_log_level", yytext, 17))
		map_md_state = MAP_MD_TOWS_LOG_LEVEL;
	else if(!strncmp("tinyows_log", yytext, 11))
		map_md_state = MAP_MD_TOWS_LOG;
	else if(!strncmp("tinyows_wfs_default_version", yytext, 77))
		map_md_state = MAP_MD_TOWS_WFS_DEFAULT_VERSION;
	else if(!strncmp("tinyows_degree_precision", yytext, 24))
		map_md_state = MAP_MD_TOWS_DEGREE_PRECISION;
	else if(!strncmp("tinyows_meter_precision", yytext, 23))
		map_md_state = MAP_MD_TOWS_METER_PRECISION;
	else if(!strncmp("tinyows_display_bbox", yytext, 20))
		map_md_state = MAP_MD_TOWS_DISPLAY_BBOX;
	else if(!strncmp("tinyows_estimated_extent", yytext, 24))
		map_md_state = MAP_MD_TOWS_ESTIMATED_EXTENT;
	else if(!strncmp("tinyows_check_schema", yytext, 20))
		map_md_state = MAP_MD_TOWS_CHECK_SCHEMA;
	else if(!strncmp("tinyows_check_valid_geom", yytext, 24))
		map_md_state = MAP_MD_TOWS_CHECK_VALID_GEOM;
	else if(!strncmp("tinyows_expose_pk", yytext, 17))
		map_md_state = MAP_MD_TOWS_EXPOSE_PK;
	else if(!strncmp("tinyows_geobbox", yytext, 15))
		map_md_state = MAP_MD_TOWS_GEOBBOX;
	else map_md_state = MAP_MD_SKIP;
}

static void metadata_value(char *yytext, bool quotes)
{
	int i;
	char *p;
	ows_geobbox *g;
 
	/* remove surrounding quotes */
	if (quotes) {
		 for (p = yytext; *p ; p++); *(--p) = 0; yytext++;
	}

	switch(map_md_state)
	{
		case MAP_MD_SKIP: return;
		case MAP_MD_UPDATESEQUENCE: 		return; /* TODO */
		case MAP_MD_SCHEMAS_LOCATION:		return; /* TODO */
		case MAP_MD_FEATURE_COLLECTION:		return; /* TODO */
		case MAP_MD_ABSTRACT:	
			map_o->metadata->abstract = buffer_init();
        		buffer_add_str(map_o->metadata->abstract, yytext);
			return;
		case MAP_MD_ACCESSCONSTRAINTS:
			map_o->metadata->access_constraints = buffer_init();
       			buffer_add_str(map_o->metadata->access_constraints, yytext);	
			return;
		case MAP_MD_ENCODING:
       			buffer_add_str(map_o->encoding, yytext);	
			return;
		case MAP_MD_FEES:
			map_o->metadata->fees = buffer_init();
       			buffer_add_str(map_o->metadata->fees, yytext);	
			return;
		case MAP_MD_KEYWORDLIST:
			map_o->metadata->keywords = list_explode_str(',', yytext);
			return;
		case MAP_MD_MAXFEATURES:
			map_o->max_features = atoi(yytext);
			return;
		case MAP_MD_NAMESPACE_PREFIX:
			map_ns_prefix = buffer_init();
			buffer_add_str(map_ns_prefix, yytext);
			return;
		case MAP_MD_NAMESPACE_URI:
			map_ns_uri = buffer_init();
			buffer_add_str(map_ns_uri, yytext);
			return;
		case MAP_MD_TITLE:
		    	map_o->metadata->title = buffer_init();
        		buffer_add_str(map_o->metadata->title, yytext);
			return;
		case MAP_MD_SRS:
			map_srid = list_explode_str(',', yytext);
			return;
		case MAP_MD_CONTACT_NAME:
			if (!map_o->contact) map_o->contact=ows_contact_init();
			map_o->contact->name = buffer_from_str(yytext);
			return;
		case MAP_MD_CONTACT_EMAIL:
			if (!map_o->contact) map_o->contact=ows_contact_init();
			map_o->contact->email = buffer_from_str(yytext);
			return;
		case MAP_MD_CONTACT_INDIVIDUAL:
			if (!map_o->contact) map_o->contact=ows_contact_init();
			map_o->contact->indiv_name = buffer_from_str(yytext);
			return;
		case MAP_MD_CONTACT_POSITION:
			if (!map_o->contact) map_o->contact=ows_contact_init();
			map_o->contact->position = buffer_from_str(yytext);
			return;
		case MAP_MD_CONTACT_PHONE:
			if (!map_o->contact) map_o->contact=ows_contact_init();
			map_o->contact->phone = buffer_from_str(yytext);
			return;
		case MAP_MD_CONTACT_FAX:
			if (!map_o->contact) map_o->contact=ows_contact_init();
			map_o->contact->fax = buffer_from_str(yytext);
			return;
		case MAP_MD_CONTACT_ADDRESS:
			if (!map_o->contact) map_o->contact=ows_contact_init();
			map_o->contact->address = buffer_from_str(yytext);
			return;
		case MAP_MD_CONTACT_CITY:
			if (!map_o->contact) map_o->contact=ows_contact_init();
			map_o->contact->city = buffer_from_str(yytext);
			return;
		case MAP_MD_CONTACT_COUNTRY:
			if (!map_o->contact) map_o->contact=ows_contact_init();
			map_o->contact->country = buffer_from_str(yytext);
			return;
		case MAP_MD_TOWS_SCHEMA_DIR:
        		buffer_add_str(map_o->schema_dir, yytext);
			return;
		case MAP_MD_TOWS_ONLINERESOURCE:
		        buffer_add_str(map_o->online_resource, yytext);
			return;
		case MAP_MD_TOWS_DB_ENCODING:
			buffer_add_str(map_o->db_encoding, yytext);
			return;
		case MAP_MD_TOWS_LOG:
			map_o->log_file = buffer_init();
			buffer_add_str(map_o->log_file, yytext);
			return;
		case MAP_MD_TOWS_LOG_LEVEL:
			i = atoi(yytext);
			if (i > 0 && i < 16) map_o->log_level = i;
			return;
                case MAP_MD_TOWS_WFS_DEFAULT_VERSION:
			ows_version_set_str(map_o->wfs_default_version, yytext);
			return;
		case MAP_MD_TOWS_DEGREE_PRECISION:
			i = atoi(yytext);
			if (i > 0 && i < 12) map_o->degree_precision = i;
			return;
		case MAP_MD_TOWS_METER_PRECISION:
			i = atoi(yytext);
			if (i > 0 && i < 12) map_o->meter_precision = i;
			return;
		case MAP_MD_TOWS_DISPLAY_BBOX:
			if (!atoi(yytext)) map_o->display_bbox = false;
			return;
		case MAP_MD_TOWS_ESTIMATED_EXTENT:
			if (atoi(yytext)) map_o->estimated_extent = true;
			return;
		case MAP_MD_TOWS_CHECK_SCHEMA:
			if (!atoi(yytext)) map_o->check_schema = false;
			return;
		case MAP_MD_TOWS_CHECK_VALID_GEOM:
			if (!atoi(yytext)) map_o->check_valid_geom = false;
			return;
		case MAP_MD_TOWS_EXPOSE_PK:
			if (atoi(yytext)) map_o->check_valid_geom = true;
			return;
		case MAP_MD_TOWS_GEOBBOX:
			g = ows_geobbox_init();
        		if (ows_geobbox_set_from_str(map_o, g, yytext)) map_o->max_geobbox = g;
        		else ows_geobbox_free(g);
			return;
	}
}

static void metadata_layer_key(char *yytext, bool quotes)
{
	char *p;

	/* remove surrounding quotes */
	if (quotes) {
		 for (p = yytext; *p ; p++); *(--p) = 0; yytext++;
	}

	     if(!strncmp("gml_exclude_items", yytext, 17))
		map_lmd_state = MAP_LMD_EXCLUDE_ITEMS;
	else if(!strncmp("gml_featureid", yytext, 13) ||
                !strncmp("wfs_featureid", yytext, 13) ||
                !strncmp("ows_featureid", yytext, 13))
		map_lmd_state = MAP_LMD_FEATURE_ID;
	/* TODO groups handle */
	else if(!strncmp("gml_include_items", yytext, 17))
		map_lmd_state = MAP_LMD_INCLUDE_ITEMS;
	/* TODO ALIAS handle */
	/* TODO TYPE handle */
	else if(!strncmp("gml_xml_items", yytext, 13))
		map_lmd_state = MAP_LMD_XML_ITEMS;
	else if(!strncmp("wfs_abstract", yytext, 12))
		map_lmd_state = MAP_LMD_ABSTRACT;
	else if(!strncmp("wfs_extent", yytext, 10))
		map_lmd_state = MAP_LMD_EXTENT;
	else if(!strncmp("wfs_keywordlist", yytext, 15))
		map_lmd_state = MAP_LMD_KEYWORDLIST;
	else if(!strncmp("wfs_namespace_prefix", yytext, 20))
		map_lmd_state = MAP_LMD_NAMESPACE_PREFIX;
	else if(!strncmp("wfs_namespace_uri", yytext, 17))
		map_lmd_state = MAP_LMD_NAMESPACE_URI;
	else if(!strncmp("wfs_metadataurl_format", yytext, 22))
		map_lmd_state = MAP_LMD_METADATAURL_FORMAT;
	else if(!strncmp("wfs_metadataurl_href", yytext, 20))
		map_lmd_state = MAP_LMD_METADATAURL_HREF;
	else if(!strncmp("wfs_metadataurl_type", yytext, 20))
		map_lmd_state = MAP_LMD_METADATAURL_TYPE;
	else if(!strncmp("wfs_srs", yytext, 7))
		map_lmd_state = MAP_LMD_SRS;
	else if(!strncmp("wfs_title", yytext, 9))
		map_lmd_state = MAP_LMD_TITLE;
	else if(!strncmp("tinyows_table", yytext, 13))
		map_lmd_state = MAP_LMD_TOWS_TABLE;
	else if(!strncmp("tinyows_schema", yytext, 14))
		map_lmd_state = MAP_LMD_TOWS_SCHEMA;
	else if(!strncmp("tinyows_retrievable", yytext, 19))
		map_lmd_state = MAP_LMD_TOWS_RETRIEVABLE;
	else if(!strncmp("tinyows_writable", yytext, 16))
		map_lmd_state = MAP_LMD_TOWS_WRITABLE;
	else if(!strncmp("tinyows_geobbox", yytext, 15))
		map_md_state = MAP_LMD_TOWS_GEOBBOX;
	else if(!strncmp("tinyows_gml_ns_list", yytext, 19))
		map_lmd_state = MAP_LMD_TOWS_GML_NS_LIST;
	else map_lmd_state = MAP_LMD_SKIP;
}

static void metadata_layer_value(char *yytext, bool quotes)
{
	ows_geobbox *g;
	char *p;

	/* remove surrounding quotes */
	if (quotes) {
		 for (p = yytext; *p ; p++); *(--p) = 0; yytext++;
	}

	switch(map_lmd_state)
	{
	case MAP_LMD_SKIP: return;
	case MAP_LMD_EXCLUDE_ITEMS:
	case MAP_LMD_FEATURE_ID:
	case MAP_LMD_INCLUDE_ITEMS:
	case MAP_LMD_XML_ITEMS:
	case MAP_LMD_EXTENT:
	case MAP_LMD_METADATAURL_FORMAT:
	case MAP_LMD_METADATAURL_HREF:
	case MAP_LMD_METADATAURL_TYPE:
		 /* TODO */ return;

	case MAP_LMD_NAMESPACE_URI:
		buffer_add_str(map_l->ns_uri, yytext);
		return;
	case MAP_LMD_NAMESPACE_PREFIX:
		buffer_add_str(map_l->ns_prefix, yytext);
		return;
	case MAP_LMD_SRS:
		map_l->srid = list_explode_str(',', yytext);
		return;
	case MAP_LMD_KEYWORDLIST:
		map_l->keywords = list_explode_str(',', yytext);
		return;
	case MAP_LMD_ABSTRACT:
		map_l->abstract = buffer_init();
       		buffer_add_str(map_l->abstract, yytext);
		return;
	case MAP_LMD_TITLE:
		map_l->title = buffer_init();
       		buffer_add_str(map_l->title, yytext);
		return;
	case MAP_LMD_TOWS_SCHEMA:
       		buffer_add_str(map_l->storage->schema, yytext);
		return;
	case MAP_LMD_TOWS_TABLE:
       		buffer_add_str(map_l->storage->table, yytext);
		return;
        case MAP_LMD_TOWS_GML_NS_LIST:
		map_l->gml_ns = list_explode_str(',', yytext);
		return;
	case MAP_LMD_TOWS_WRITABLE:
		map_l->writable=atoi(yytext)?1:0;
		return;
	case MAP_LMD_TOWS_RETRIEVABLE:
		map_l->retrievable=atoi(yytext)?1:0;
		return;
	case MAP_LMD_TOWS_GEOBBOX:
		g = ows_geobbox_init();
       		if (ows_geobbox_set_from_str(map_o, g, yytext)) map_l->geobbox = g;
       		else ows_geobbox_free(g);
		return;
	}
}

static void properties(char *yytext, bool quotes)
{
	char *p;

	/* remove surrounding quotes */
	if (quotes) {
		 for (p = yytext; *p ; p++); *(--p) = 0; yytext++;
	}

	switch(map_prop_state) {
	case MAP_NAME:
		map_o->metadata->name = buffer_init();
       		buffer_add_str(map_o->metadata->name, yytext);
		return;
	}
	
}

static void layer_properties(char * yytext, bool quotes)
{
	char *p;

	/* remove surrounding quotes */
	if (quotes) {
		for (p = yytext; *p ; p++); *(--p) = 0; yytext++;
	}

	switch(map_layer_prop_state) {
	case MAP_LAYER_NAME:
		map_l->name = buffer_init();
       		buffer_add_str(map_l->name, yytext);
		return;
	case MAP_LAYER_CONNECTION:
		/* TODO: Having a Layer connection notion in TinyOWS */
		if (map_o->pg_dsn->use && strcmp(map_o->pg_dsn->buf, yytext))
			ows_error(map_o, OWS_ERROR_CONFIG_FILE,
				"MapFile have more than one single PostGIS db connection.",
				"parse_config_file");
		else if (!map_o->pg_dsn->use) buffer_add_str(map_o->pg_dsn, yytext);
		return;
	}
}


static void end_layer()
{
	if (!map_is_postgis) ows_layer_free(map_l);
	else {
		if (!map_l->storage->table->use)
			buffer_copy(map_l->storage->table, map_l->name);
		if (!map_l->storage->schema->use)
			buffer_add_str(map_l->storage->schema, "public");
		if (!map_is_dump) map_l->retrievable=map_l->writable = false;
		ows_layer_list_add(map_o->layers, map_l);
	}

		
	map_is_dump = map_is_postgis = false;
}






























#line 1465 "src/mapfile/mapfile.c"

#define INITIAL 0
#define MAP 1
#define WEB 2
#define METADATA 3
#define METADATA_VALUE 4
#define PROPERTIES 5
#define LAYER_PROPERTIES 6
#define LAYER_METADATA 7
#define LAYER_METADATA_VALUE 8
#define LAYER_CONNECTIONTYPE 9
#define LAYER_DUMP 10
#define LAYER 11
#define FEATURE 12
#define GRID 13
#define JOIN 14
#define CLASS 15
#define STYLE 16
#define STYLE_PATTERN 17
#define LABEL 18
#define PROJECTION 19
#define QUERYMAP 20
#define SCALEBAR 21
#define LEGEND 22
#define REFERENCE 23
#define OUTPUTFORMAT 24
#define SYMBOL 25
#define PATTERN 26
#define POINTS 27
#define INCLUDE 28

#ifndef YY_NO_UNISTD_H
/* Special case for "unistd.h", since it is non-ANSI. We include it way
 * down here because we want the user's section 1 to have been scanned first.
 * The user has a chance to override it with an option.
 */
#include <unistd.h>
#endif

#ifndef YY_EXTRA_TYPE
#define YY_EXTRA_TYPE void *
#endif

static int yy_init_globals (void );

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

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

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

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

#ifndef YY_NO_INPUT

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

#endif

        static int yy_start_stack_ptr = 0;
        static int yy_start_stack_depth = 0;
        static int *yy_start_stack = NULL;
    
    static void yy_push_state (int new_state );
    
    static void yy_pop_state (void );
    
    static int yy_top_state (void );
    
/* 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_LVALUE->yy_is_interactive ) \
		{ \
		int c = '*'; \
		size_t 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 \
		{ \
		errno=0; \
		while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
			{ \
			if( errno != EINTR) \
				{ \
				YY_FATAL_ERROR( "input in flex scanner failed" ); \
				break; \
				} \
			errno=0; \
			clearerr(yyin); \
			} \
		}\
\

#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

/* end tables serialization structures and prototypes */

/* Default declaration of generated scanner - a define so the user can
 * easily add parameters.
 */
#ifndef YY_DECL
#define YY_DECL_IS_OURS 1

extern int yylex (void);

#define YY_DECL int yylex (void)
#endif /* !YY_DECL */

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

/** The main scanner function which does all the work.
 */
YY_DECL
{
	register yy_state_type yy_current_state;
	register char *yy_cp, *yy_bp;
	register int yy_act;
    
#line 582 "src/mapfile/mapfile.l"


#line 1657 "src/mapfile/mapfile.c"

	if ( !(yy_init) )
		{
		(yy_init) = 1;

#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 ) {
			yyensure_buffer_stack ();
			YY_CURRENT_BUFFER_LVALUE =
				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:
		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 >= 677 )
					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_current_state != 676 );
		yy_cp = (yy_last_accepting_cpos);
		yy_current_state = (yy_last_accepting_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 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 584 "src/mapfile/mapfile.l"
{ char c ; for (c=input() ; c && c != '\n' ; c=input()); }
	YY_BREAK
case 2:
YY_RULE_SETUP
#line 585 "src/mapfile/mapfile.l"
{ yy_push_state(INCLUDE); OWS_MAP_DBG }
	YY_BREAK
case 3:
YY_RULE_SETUP
#line 588 "src/mapfile/mapfile.l"
{ /*LEGEND rule must appears before END... */
				  yy_push_state(LEGEND); OWS_MAP_DBG }
	YY_BREAK
case 4:
YY_RULE_SETUP
#line 591 "src/mapfile/mapfile.l"
{ 
				 OWS_MAP_EATLINE
				 if (yy_top_state() == INITIAL && YY_START != MAP) { 
					ows_error(map_o, OWS_ERROR_CONFIG_FILE,
					"MapFile Parse Error", "parse_config_file");
					yyterminate();}

				  if (YY_START == LAYER) { end_layer(); }
				  yy_pop_state(); OWS_MAP_DBG
				}
	YY_BREAK
case 5:
YY_RULE_SETUP
#line 602 "src/mapfile/mapfile.l"
{ yy_push_state(MAP); OWS_MAP_DBG }
	YY_BREAK
case 6:
YY_RULE_SETUP
#line 603 "src/mapfile/mapfile.l"
{ yy_push_state(WEB); OWS_MAP_DBG }
	YY_BREAK
case 7:
YY_RULE_SETUP
#line 604 "src/mapfile/mapfile.l"
{ yy_push_state(QUERYMAP); OWS_MAP_DBG }
	YY_BREAK
case 8:
YY_RULE_SETUP
#line 605 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE /* must be before SYMBOL */ }
	YY_BREAK
case 9:
YY_RULE_SETUP
#line 606 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 10:
YY_RULE_SETUP
#line 607 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 11:
YY_RULE_SETUP
#line 608 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 12:
YY_RULE_SETUP
#line 609 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 13:
YY_RULE_SETUP
#line 610 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 14:
YY_RULE_SETUP
#line 611 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 15:
YY_RULE_SETUP
#line 612 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 16:
YY_RULE_SETUP
#line 613 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 17:
YY_RULE_SETUP
#line 614 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 18:
YY_RULE_SETUP
#line 615 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 19:
YY_RULE_SETUP
#line 616 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 20:
YY_RULE_SETUP
#line 617 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 21:
YY_RULE_SETUP
#line 618 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 22:
YY_RULE_SETUP
#line 619 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 23:
YY_RULE_SETUP
#line 620 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 24:
YY_RULE_SETUP
#line 621 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 25:
YY_RULE_SETUP
#line 622 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 26:
YY_RULE_SETUP
#line 623 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 27:
YY_RULE_SETUP
#line 624 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 28:
YY_RULE_SETUP
#line 625 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 29:
YY_RULE_SETUP
#line 626 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 30:
YY_RULE_SETUP
#line 627 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 31:
YY_RULE_SETUP
#line 628 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 32:
YY_RULE_SETUP
#line 629 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 33:
YY_RULE_SETUP
#line 630 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 34:
YY_RULE_SETUP
#line 631 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 35:
YY_RULE_SETUP
#line 632 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 36:
YY_RULE_SETUP
#line 633 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 37:
YY_RULE_SETUP
#line 634 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 38:
YY_RULE_SETUP
#line 635 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 39:
YY_RULE_SETUP
#line 636 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 40:
YY_RULE_SETUP
#line 637 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 41:
YY_RULE_SETUP
#line 638 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 42:
YY_RULE_SETUP
#line 639 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 43:
YY_RULE_SETUP
#line 640 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 44:
YY_RULE_SETUP
#line 641 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 45:
YY_RULE_SETUP
#line 642 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 46:
YY_RULE_SETUP
#line 643 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 47:
YY_RULE_SETUP
#line 644 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 48:
YY_RULE_SETUP
#line 645 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 49:
YY_RULE_SETUP
#line 646 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 50:
YY_RULE_SETUP
#line 647 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 51:
YY_RULE_SETUP
#line 648 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 52:
YY_RULE_SETUP
#line 649 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 53:
YY_RULE_SETUP
#line 650 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 54:
YY_RULE_SETUP
#line 651 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 55:
YY_RULE_SETUP
#line 652 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 56:
YY_RULE_SETUP
#line 653 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 57:
YY_RULE_SETUP
#line 654 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 58:
YY_RULE_SETUP
#line 655 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 59:
YY_RULE_SETUP
#line 656 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 60:
YY_RULE_SETUP
#line 657 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 61:
YY_RULE_SETUP
#line 658 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 62:
YY_RULE_SETUP
#line 659 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 63:
YY_RULE_SETUP
#line 660 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 64:
YY_RULE_SETUP
#line 661 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 65:
YY_RULE_SETUP
#line 662 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 66:
YY_RULE_SETUP
#line 663 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 67:
YY_RULE_SETUP
#line 664 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 68:
YY_RULE_SETUP
#line 666 "src/mapfile/mapfile.l"
{ yy_push_state(SYMBOL); OWS_MAP_DBG }
	YY_BREAK
case 69:
YY_RULE_SETUP
#line 667 "src/mapfile/mapfile.l"
{ yy_push_state(SCALEBAR); OWS_MAP_DBG  }
	YY_BREAK
case 70:
YY_RULE_SETUP
#line 668 "src/mapfile/mapfile.l"
{ yy_push_state(REFERENCE); OWS_MAP_DBG }
	YY_BREAK
case 71:
YY_RULE_SETUP
#line 669 "src/mapfile/mapfile.l"
{ yy_push_state(OUTPUTFORMAT); OWS_MAP_DBG }
	YY_BREAK
case 72:
YY_RULE_SETUP
#line 670 "src/mapfile/mapfile.l"
{ yy_push_state(METADATA); OWS_MAP_DBG }
	YY_BREAK
case 73:
YY_RULE_SETUP
#line 671 "src/mapfile/mapfile.l"
{ yy_push_state(GRID); OWS_MAP_DBG }
	YY_BREAK
case 74:
YY_RULE_SETUP
#line 672 "src/mapfile/mapfile.l"
{ yy_push_state(JOIN); OWS_MAP_DBG }
	YY_BREAK
case 75:
YY_RULE_SETUP
#line 673 "src/mapfile/mapfile.l"
{ yy_push_state(LAYER_METADATA); OWS_MAP_DBG }
	YY_BREAK
case 76:
YY_RULE_SETUP
#line 674 "src/mapfile/mapfile.l"
{ yy_push_state(CLASS); OWS_MAP_DBG }
	YY_BREAK
case 77:
YY_RULE_SETUP
#line 675 "src/mapfile/mapfile.l"
{ yy_push_state(STYLE); OWS_MAP_DBG }
	YY_BREAK
case 78:
YY_RULE_SETUP
#line 676 "src/mapfile/mapfile.l"
{ yy_push_state(LABEL); OWS_MAP_DBG }
	YY_BREAK
case 79:
YY_RULE_SETUP
#line 677 "src/mapfile/mapfile.l"
{ yy_push_state(PROJECTION); OWS_MAP_DBG }
	YY_BREAK
case 80:
YY_RULE_SETUP
#line 678 "src/mapfile/mapfile.l"
{ yy_push_state(PATTERN); OWS_MAP_DBG }
	YY_BREAK
case 81:
YY_RULE_SETUP
#line 679 "src/mapfile/mapfile.l"
{ yy_push_state(POINTS); OWS_MAP_DBG }
	YY_BREAK
case 82:
YY_RULE_SETUP
#line 680 "src/mapfile/mapfile.l"
{ yy_push_state(LABEL); OWS_MAP_DBG }
	YY_BREAK
case 83:
YY_RULE_SETUP
#line 681 "src/mapfile/mapfile.l"
{ yy_push_state(LAYER); map_l = ows_layer_init(); OWS_MAP_DBG }
	YY_BREAK
case 84:
YY_RULE_SETUP
#line 682 "src/mapfile/mapfile.l"
{ yy_push_state(FEATURE); OWS_MAP_DBG }
	YY_BREAK
case 85:
YY_RULE_SETUP
#line 683 "src/mapfile/mapfile.l"
{ BEGIN PROPERTIES; map_prop_state = MAP_NAME; }
	YY_BREAK
case 86:
YY_RULE_SETUP
#line 684 "src/mapfile/mapfile.l"
{ BEGIN LAYER_PROPERTIES; map_layer_prop_state = MAP_LAYER_NAME; }
	YY_BREAK
case 87:
YY_RULE_SETUP
#line 685 "src/mapfile/mapfile.l"
{ BEGIN LAYER_PROPERTIES; map_layer_prop_state = MAP_LAYER_CONNECTION; }
	YY_BREAK
case 88:
YY_RULE_SETUP
#line 686 "src/mapfile/mapfile.l"
{ BEGIN LAYER_CONNECTIONTYPE; }
	YY_BREAK
case 89:
YY_RULE_SETUP
#line 687 "src/mapfile/mapfile.l"
{ BEGIN LAYER; map_is_postgis=true; }
	YY_BREAK
case 90:
YY_RULE_SETUP
#line 688 "src/mapfile/mapfile.l"
{ BEGIN LAYER; map_is_postgis=false; }
	YY_BREAK
case 91:
YY_RULE_SETUP
#line 689 "src/mapfile/mapfile.l"
{ BEGIN LAYER_DUMP; }
	YY_BREAK
case 92:
YY_RULE_SETUP
#line 690 "src/mapfile/mapfile.l"
{ BEGIN LAYER; map_is_dump=true; }
	YY_BREAK
case 93:
YY_RULE_SETUP
#line 691 "src/mapfile/mapfile.l"
{ BEGIN LAYER; map_is_dump=false; }
	YY_BREAK
case 94:
/* rule 94 can match eol */
YY_RULE_SETUP
#line 693 "src/mapfile/mapfile.l"
{}
	YY_BREAK
case 95:
/* rule 95 can match eol */
YY_RULE_SETUP
#line 695 "src/mapfile/mapfile.l"
{metadata_key(yytext, true); BEGIN METADATA_VALUE;}
	YY_BREAK
case 96:
/* rule 96 can match eol */
YY_RULE_SETUP
#line 696 "src/mapfile/mapfile.l"
{metadata_value(yytext, true); BEGIN METADATA;}
	YY_BREAK
case 97:
/* rule 97 can match eol */
YY_RULE_SETUP
#line 697 "src/mapfile/mapfile.l"
{metadata_layer_key(yytext, true); BEGIN LAYER_METADATA_VALUE;}
	YY_BREAK
case 98:
/* rule 98 can match eol */
YY_RULE_SETUP
#line 698 "src/mapfile/mapfile.l"
{metadata_layer_value(yytext, true); BEGIN LAYER_METADATA;}
	YY_BREAK
case 99:
/* rule 99 can match eol */
YY_RULE_SETUP
#line 699 "src/mapfile/mapfile.l"
{

	 char *p, *q; 
         buffer *path;

	 yy_pop_state(); OWS_MAP_DBG

	 if(map_include_stack_ptr >= OWS_MAP_MAX_INCLUDE_DEPTH) {
		ows_error(map_o, OWS_ERROR_CONFIG_FILE,
		"MapFile: include nested too deeply", "parse_config_file");
		yyterminate();
         }

	 map_include_stack[map_include_stack_ptr] = YY_CURRENT_BUFFER;
         map_include_stack_ptr++;

	 for (p = q = yytext; *p ; p++); *(--p) = 0; q++; /* remove surrounding quotes */
         path = mapfile_build_path(map_o, q);
         yyin = fopen(path->buf, "r");
         buffer_free(path);

         if (!yyin) {
		ows_error(map_o, OWS_ERROR_CONFIG_FILE,
		"MapFile: include unable to open file", "parse_config_file");
		yyterminate();
	}

         yy_switch_to_buffer(yy_create_buffer(yyin,YY_BUF_SIZE));
}
	YY_BREAK
case 100:
/* rule 100 can match eol */
YY_RULE_SETUP
#line 730 "src/mapfile/mapfile.l"
{properties(yytext, true);  BEGIN MAP;}
	YY_BREAK
case 101:
YY_RULE_SETUP
#line 731 "src/mapfile/mapfile.l"
{properties(yytext, false);  BEGIN MAP;}		
	YY_BREAK
case 102:
/* rule 102 can match eol */
YY_RULE_SETUP
#line 732 "src/mapfile/mapfile.l"
{layer_properties(yytext, true);  BEGIN LAYER;}
	YY_BREAK
case 103:
YY_RULE_SETUP
#line 733 "src/mapfile/mapfile.l"
{layer_properties(yytext, false);  BEGIN LAYER;}		
	YY_BREAK
case 104:
/* rule 104 can match eol */
YY_RULE_SETUP
#line 734 "src/mapfile/mapfile.l"
{}
	YY_BREAK
case 105:
YY_RULE_SETUP
#line 735 "src/mapfile/mapfile.l"
{}
	YY_BREAK
case 106:
/* rule 106 can match eol */
YY_RULE_SETUP
#line 736 "src/mapfile/mapfile.l"
{}
	YY_BREAK
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(MAP):
case YY_STATE_EOF(WEB):
case YY_STATE_EOF(METADATA):
case YY_STATE_EOF(METADATA_VALUE):
case YY_STATE_EOF(PROPERTIES):
case YY_STATE_EOF(LAYER_PROPERTIES):
case YY_STATE_EOF(LAYER_METADATA):
case YY_STATE_EOF(LAYER_METADATA_VALUE):
case YY_STATE_EOF(LAYER_CONNECTIONTYPE):
case YY_STATE_EOF(LAYER_DUMP):
case YY_STATE_EOF(LAYER):
case YY_STATE_EOF(FEATURE):
case YY_STATE_EOF(GRID):
case YY_STATE_EOF(JOIN):
case YY_STATE_EOF(CLASS):
case YY_STATE_EOF(STYLE):
case YY_STATE_EOF(STYLE_PATTERN):
case YY_STATE_EOF(LABEL):
case YY_STATE_EOF(PROJECTION):
case YY_STATE_EOF(QUERYMAP):
case YY_STATE_EOF(SCALEBAR):
case YY_STATE_EOF(LEGEND):
case YY_STATE_EOF(REFERENCE):
case YY_STATE_EOF(OUTPUTFORMAT):
case YY_STATE_EOF(SYMBOL):
case YY_STATE_EOF(PATTERN):
case YY_STATE_EOF(POINTS):
case YY_STATE_EOF(INCLUDE):
#line 738 "src/mapfile/mapfile.l"
{ 
	/* End of main file */
	if (map_include_stack_ptr == 0 && YY_START == 0) yyterminate(); 
	
	else if (map_include_stack_ptr) {
		fclose(YY_CURRENT_BUFFER->yy_input_file);
                yy_delete_buffer(YY_CURRENT_BUFFER );
                yy_switch_to_buffer(map_include_stack[--map_include_stack_ptr]);
	} else {
		ows_error(map_o, OWS_ERROR_CONFIG_FILE, "MapFile parse error",
			"parse_config_file"); 
		yyterminate();
	}
}
	YY_BREAK
case 107:
YY_RULE_SETUP
#line 753 "src/mapfile/mapfile.l"
ECHO;
	YY_BREAK
#line 2364 "src/mapfile/mapfile.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_LVALUE->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_LVALUE->yy_n_chars;
			YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
			YY_CURRENT_BUFFER_LVALUE->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_LVALUE->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_last_accepting_cpos);
				yy_current_state = (yy_last_accepting_state);
				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_LVALUE->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 (void)
{
    	register char *dest = YY_CURRENT_BUFFER_LVALUE->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_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
		YY_FATAL_ERROR(
		"fatal flex scanner internal error--end of buffer missed" );

	if ( YY_CURRENT_BUFFER_LVALUE->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_LVALUE->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_LVALUE->yy_n_chars = (yy_n_chars) = 0;

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

		while ( num_to_read <= 0 )
			{ /* Not enough room in the buffer - grow it. */

			/* 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. */
					yyrealloc((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_LVALUE->yy_buf_size -
						number_to_move - 1;

			}

		if ( num_to_read > YY_READ_BUF_SIZE )
			num_to_read = YY_READ_BUF_SIZE;

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

		YY_CURRENT_BUFFER_LVALUE->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_LVALUE->yy_buffer_status =
				YY_BUFFER_EOF_PENDING;
			}
		}

	else
		ret_val = EOB_ACT_CONTINUE_SCAN;

	(yy_n_chars) += number_to_move;
	YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
	YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;

	(yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->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 (void)
{
	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 )
		{
		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 >= 677 )
				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 );
 */
    static yy_state_type yy_try_NUL_trans  (yy_state_type yy_current_state )
{
	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 >= 677 )
			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 == 676);

	return yy_is_jam ? 0 : yy_current_state;
}

#ifndef YY_NO_INPUT
#ifdef __cplusplus
    static int yyinput (void)
#else
    static int input  (void)
#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_LVALUE->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 );

					/*FALLTHROUGH*/

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

					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;
}
#endif	/* ifndef YY_NO_INPUT */

/** Immediately switch to a different input stream.
 * @param input_file A readable stream.
 * 
 * @note This function does not reset the start condition to @c INITIAL .
 */
    void yyrestart  (FILE * input_file )
{
    
	if ( ! YY_CURRENT_BUFFER ){
        yyensure_buffer_stack ();
		YY_CURRENT_BUFFER_LVALUE =
            yy_create_buffer(yyin,YY_BUF_SIZE );
	}

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

/** Switch to a different input buffer.
 * @param new_buffer The new input buffer.
 * 
 */
    void yy_switch_to_buffer  (YY_BUFFER_STATE  new_buffer )
{
    
	/* TODO. We should be able to replace this entire function body
	 * with
	 *		yypop_buffer_state();
	 *		yypush_buffer_state(new_buffer);
     */
	yyensure_buffer_stack ();
	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_LVALUE->yy_buf_pos = (yy_c_buf_p);
		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
		}

	YY_CURRENT_BUFFER_LVALUE = 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;
}

static void yy_load_buffer_state  (void)
{
    	(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
	(yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
	yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
	(yy_hold_char) = *(yy_c_buf_p);
}

/** Allocate and initialize an input buffer state.
 * @param file A readable stream.
 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
 * 
 * @return the allocated buffer state.
 */
    YY_BUFFER_STATE yy_create_buffer  (FILE * file, int  size )
{
	YY_BUFFER_STATE b;
    
	b = (YY_BUFFER_STATE) yyalloc(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 *) yyalloc(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;
}

/** Destroy the buffer.
 * @param b a buffer created with yy_create_buffer()
 * 
 */
    void yy_delete_buffer (YY_BUFFER_STATE  b )
{
    
	if ( ! b )
		return;

	if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
		YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;

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

	yyfree((void *) b  );
}

/* Initializes or reinitializes a buffer.
 * This function is sometimes called more than once on the same buffer,
 * such as during a yyrestart() or at EOF.
 */
    static void yy_init_buffer  (YY_BUFFER_STATE  b, FILE * file )

{
	int oerrno = errno;
    
	yy_flush_buffer(b );

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

    /* If b is the current buffer, then yy_init_buffer was _probably_
     * called from yyrestart() or through yy_get_next_buffer.
     * In that case, we don't want to reset the lineno or column.
     */
    if (b != YY_CURRENT_BUFFER){
        b->yy_bs_lineno = 1;
        b->yy_bs_column = 0;
    }

        b->yy_is_interactive = 0;
    
	errno = oerrno;
}

/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
 * 
 */
    void yy_flush_buffer (YY_BUFFER_STATE  b )
{
    	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( );
}

/** Pushes the new state onto the stack. The new state becomes
 *  the current state. This function will allocate the stack
 *  if necessary.
 *  @param new_buffer The new state.
 *  
 */
void yypush_buffer_state (YY_BUFFER_STATE new_buffer )
{
    	if (new_buffer == NULL)
		return;

	yyensure_buffer_stack();

	/* This block is copied from yy_switch_to_buffer. */
	if ( YY_CURRENT_BUFFER )
		{
		/* Flush out information for old buffer. */
		*(yy_c_buf_p) = (yy_hold_char);
		YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
		}

	/* Only push if top exists. Otherwise, replace top. */
	if (YY_CURRENT_BUFFER)
		(yy_buffer_stack_top)++;
	YY_CURRENT_BUFFER_LVALUE = new_buffer;

	/* copied from yy_switch_to_buffer. */
	yy_load_buffer_state( );
	(yy_did_buffer_switch_on_eof) = 1;
}

/** Removes and deletes the top of the stack, if present.
 *  The next element becomes the new top.
 *  
 */
void yypop_buffer_state (void)
{
    	if (!YY_CURRENT_BUFFER)
		return;

	yy_delete_buffer(YY_CURRENT_BUFFER );
	YY_CURRENT_BUFFER_LVALUE = NULL;
	if ((yy_buffer_stack_top) > 0)
		--(yy_buffer_stack_top);

	if (YY_CURRENT_BUFFER) {
		yy_load_buffer_state( );
		(yy_did_buffer_switch_on_eof) = 1;
	}
}

/* Allocates the stack if it does not exist.
 *  Guarantees space for at least one push.
 */
static void yyensure_buffer_stack (void)
{
	int num_to_alloc;
    
	if (!(yy_buffer_stack)) {

		/* First allocation is just for 2 elements, since we don't know if this
		 * scanner will even need a stack. We use 2 instead of 1 to avoid an
		 * immediate realloc on the next call.
         */
		num_to_alloc = 1;
		(yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
								(num_to_alloc * sizeof(struct yy_buffer_state*)
								);
		
		memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
				
		(yy_buffer_stack_max) = num_to_alloc;
		(yy_buffer_stack_top) = 0;
		return;
	}

	if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){

		/* Increase the buffer to prepare for a possible push. */
		int grow_size = 8 /* arbitrary grow size */;

		num_to_alloc = (yy_buffer_stack_max) + grow_size;
		(yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
								((yy_buffer_stack),
								num_to_alloc * sizeof(struct yy_buffer_state*)
								);

		/* zero only the new slots.*/
		memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
		(yy_buffer_stack_max) = num_to_alloc;
	}
}

/** Setup the input buffer state to scan directly from a user-specified character buffer.
 * @param base the character buffer
 * @param size the size in bytes of the character buffer
 * 
 * @return the newly allocated buffer state object. 
 */
YY_BUFFER_STATE yy_scan_buffer  (char * base, yy_size_t  size )
{
	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) yyalloc(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;
}

/** Setup the input buffer state to scan a string. The next call to yylex() will
 * scan from a @e copy of @a str.
 * @param str a NUL-terminated string to scan
 * 
 * @return the newly allocated buffer state object.
 * @note If you want to scan bytes that may contain NUL values, then use
 *       yy_scan_bytes() instead.
 */
YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )
{
    
	return yy_scan_bytes(yystr,strlen(yystr) );
}

/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
 * scan from a @e copy of @a bytes.
 * @param bytes the byte buffer to scan
 * @param len the number of bytes in the buffer pointed to by @a bytes.
 * 
 * @return the newly allocated buffer state object.
 */
YY_BUFFER_STATE yy_scan_bytes  (yyconst char * yybytes, int  _yybytes_len )
{
	YY_BUFFER_STATE b;
	char *buf;
	yy_size_t n;
	int i;
    
	/* Get memory for full buffer, including space for trailing EOB's. */
	n = _yybytes_len + 2;
	buf = (char *) yyalloc(n  );
	if ( ! buf )
		YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );

	for ( i = 0; i < _yybytes_len; ++i )
		buf[i] = yybytes[i];

	buf[_yybytes_len] = buf[_yybytes_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;
}

    static void yy_push_state (int  new_state )
{
    	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 *) yyalloc(new_size  );

		else
			(yy_start_stack) = (int *) yyrealloc((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);
}

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

	BEGIN((yy_start_stack)[(yy_start_stack_ptr)]);
}

    static int yy_top_state  (void)
{
    	return (yy_start_stack)[(yy_start_stack_ptr) - 1];
}

#ifndef YY_EXIT_FAILURE
#define YY_EXIT_FAILURE 2
#endif

static void yy_fatal_error (yyconst char* msg )
{
    	(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. */ \
        int yyless_macro_arg = (n); \
        YY_LESS_LINENO(yyless_macro_arg);\
		yytext[yyleng] = (yy_hold_char); \
		(yy_c_buf_p) = yytext + yyless_macro_arg; \
		(yy_hold_char) = *(yy_c_buf_p); \
		*(yy_c_buf_p) = '\0'; \
		yyleng = yyless_macro_arg; \
		} \
	while ( 0 )

/* Accessor  methods (get/set functions) to struct members. */

/** Get the current line number.
 * 
 */
int yyget_lineno  (void)
{
        
    return yylineno;
}

/** Get the input stream.
 * 
 */
FILE *yyget_in  (void)
{
        return yyin;
}

/** Get the output stream.
 * 
 */
FILE *yyget_out  (void)
{
        return yyout;
}

/** Get the length of the current token.
 * 
 */
int yyget_leng  (void)
{
        return yyleng;
}

/** Get the current token.
 * 
 */

char *yyget_text  (void)
{
        return yytext;
}

/** Set the current line number.
 * @param line_number
 * 
 */
void yyset_lineno (int  line_number )
{
    
    yylineno = line_number;
}

/** Set the input stream. This does not discard the current
 * input buffer.
 * @param in_str A readable stream.
 * 
 * @see yy_switch_to_buffer
 */
void yyset_in (FILE *  in_str )
{
        yyin = in_str ;
}

void yyset_out (FILE *  out_str )
{
        yyout = out_str ;
}

int yyget_debug  (void)
{
        return yy_flex_debug;
}

void yyset_debug (int  bdebug )
{
        yy_flex_debug = bdebug ;
}

static int yy_init_globals (void)
{
        /* Initialization is the same as for the non-reentrant scanner.
     * This function is called from yylex_destroy(), so don't allocate here.
     */

    (yy_buffer_stack) = 0;
    (yy_buffer_stack_top) = 0;
    (yy_buffer_stack_max) = 0;
    (yy_c_buf_p) = (char *) 0;
    (yy_init) = 0;
    (yy_start) = 0;

    (yy_start_stack_ptr) = 0;
    (yy_start_stack_depth) = 0;
    (yy_start_stack) =  NULL;

/* Defined in main.c */
#ifdef YY_STDINIT
    yyin = stdin;
    yyout = stdout;
#else
    yyin = (FILE *) 0;
    yyout = (FILE *) 0;
#endif

    /* For future reference: Set errno on error, since we are called by
     * yylex_init()
     */
    return 0;
}

/* yylex_destroy is for both reentrant and non-reentrant scanners. */
int yylex_destroy  (void)
{
    
    /* Pop the buffer stack, destroying each element. */
	while(YY_CURRENT_BUFFER){
		yy_delete_buffer(YY_CURRENT_BUFFER  );
		YY_CURRENT_BUFFER_LVALUE = NULL;
		yypop_buffer_state();
	}

	/* Destroy the stack itself. */
	yyfree((yy_buffer_stack) );
	(yy_buffer_stack) = NULL;

    /* Destroy the start condition stack. */
        yyfree((yy_start_stack)  );
        (yy_start_stack) = NULL;

    /* Reset the globals. This is important in a non-reentrant scanner so the next time
     * yylex() is called, initialization will occur. */
    yy_init_globals( );

    return 0;
}

/*
 * Internal utility routines.
 */

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

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

	return n;
}
#endif

void *yyalloc (yy_size_t  size )
{
	return (void *) malloc( size );
}

void *yyrealloc  (void * ptr, yy_size_t  size )
{
	/* 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 );
}

void yyfree (void * ptr )
{
	free( (char *) ptr );	/* see yyrealloc() for (char *) cast */
}

#define YYTABLES_NAME "yytables"

#line 753 "src/mapfile/mapfile.l"



void ows_parse_config_mapfile(ows * o, const char *filename)
{
	ows_layer_node *ln;

	assert(o);
	assert(filename);

	if (!(yyin = fopen(filename, "r"))) {
		ows_error(o, OWS_ERROR_CONFIG_FILE, "Unable to open MapFile !", 
				"parse_config_file");
		return;
	}

	map_o = o;
	map_o->metadata = ows_metadata_init();
	map_o->layers = ows_layer_list_init();

 	while( yylex() ) ;

	if (!map_o->encoding->use)    buffer_add_str(map_o->encoding, OWS_DEFAULT_XML_ENCODING);
	if (!map_o->db_encoding->use) buffer_add_str(map_o->db_encoding, OWS_DEFAULT_DB_ENCODING);
	
	if (map_srid) {
		for (ln = o->layers->first ; ln ; ln = ln->next)
			list_add_list(ln->layer->srid, map_srid);
		list_free(map_srid);
	}

	if (map_ns_uri) {
		for (ln = o->layers->first ; ln ; ln = ln->next)
			if (!ln->layer->ns_uri->use)
				buffer_copy(ln->layer->ns_uri, map_ns_uri); 
		buffer_free(map_ns_uri);
	}
	
	if (map_ns_prefix) {
		for (ln = o->layers->first ; ln ; ln = ln->next)
			if (!ln->layer->ns_prefix->use)
				buffer_copy(ln->layer->ns_prefix, map_ns_prefix); 
		buffer_free(map_ns_prefix);
	}

	fclose(yyin);
}

