#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 35
#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 defined (__STDC_VERSION__) && __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 */

/* C99 requires __STDC__ to be defined as 1. */
#if defined (__STDC__)

#define YY_USE_CONST

#endif	/* defined (__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

#ifndef YY_TYPEDEF_YY_SIZE_T
#define YY_TYPEDEF_YY_SIZE_T
typedef size_t yy_size_t;
#endif

extern yy_size_t 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)  )

#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.
	 */
	yy_size_t 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 yy_size_t yy_n_chars;		/* number of characters read into yy_ch_buf */
yy_size_t 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,yy_size_t 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,   34,   35,   36,   37,

       38,   39,   40,   41,   42,   43,   44,   45,   46,   47,
       48,   49,   50,   51,   52,   53,   54,   29,   55,   56,
       57,   58,    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[59] =
    {   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,    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,   45,   82,    0,  133,    0,    7,   20,   29,   52,
       72,  152,  181,  192,  203,  208,  214,  229,  267,  316,
      365,  418,  462,    0,  507,  558,   80,  120,  235,  240,
      609,    0,  658,    0,  241,  242,  706,    0,  243,  260,
      287,  288,  295,  333,  757,  806,  339,  340,  855,  898,
      941,  986,  341,  342,  385,  386,  391,  394,  373, 1613,
     1613, 1613,  360, 1613,  337,   13,   16,    9,   22,   11,
       40,   95,  105,   60,   43,   48,  116,  135,  193,  138,
      139,  388,  141,  153,  181,  191,  404,  226, 1613, 1613,
      338,  326,  327,  321,    0,   26,   12,    0,  254,    0,

       78,  292,    0,  278,  309,  306,  293,  290,    0,  288,
      288,    0,  303,  323,  407,  433,  432,  338,  405,  436,
      452,  450,  455,  437,  453,  448,  473,  444,  481,  488,
      483,  488,  485,  491,  493,  509,  509,  502,  503,  506,
      509,  509,  505,  510,  522,  520,  538,  543,  538,  557,
      545,  560,  547,  550,  565,  567,  240,  237,  238, 1613,
      231,  565,  567,  556,  559,  555,  562,  578,   54,  576,
      572,  571,  585,  605,  606,  612,  614,  606,  610,  622,
      609,  609,  616,  631,  633,  630,   58,  623,  639,  220,
     1613,  209,  198, 1613,  194,    0,  165,  188,    0,  444,

      155,  658,    0,  178,  153,    0,  669,  117,  662,  116,
     1613,   71,   68, 1613,   63,    0,  666,  653,    0,  671,
      655,  678,  668,  664,  676,  689,  679,  679,  704,  703,
      705,  716,  703,  711,  721,  166,  707,  715,  717,  221,
      732,  234,  723,  748,  734,  730,  755,  739,  743,  293,
      751,  761,  766,  762,  772,  765,  760,  772,  420,  782,
      782,  773,  787,  776,  780,  795,  797,  812,  803,  808,
       35, 1613,   19, 1613,  809, 1613,  816,  822,  805,  821,
      824,  825,  826,  816,  823,  818,  835,  834,  834,  858,
      847, 1613,  845,  852,  851,  869,  867, 1613,  855,  876,

      863, 1613,    0, 1613,    0,    0,  860,    0,  877,  864,
      870,  887,  876,  878,  882,  895,  912,  896,  915,  906,
      917,  922,  920,  913,  907, 1613,  914,  913,  926,  931,
      928,  942,  940,  939,  951,  949,  962,  955,  948,  966,
      970,  955,  965,  963,  964,  966,  975,  973,  991,  990,
     1002,  992, 1002,  999,  998, 1010,  996, 1010, 1014, 1006,
     1002, 1015, 1011, 1010, 1025, 1013, 1024, 1613, 1018, 1035,
      721, 1026, 1042, 1043, 1036, 1040, 1029, 1040, 1054, 1055,
     1056, 1057, 1059, 1055, 1061,    0, 1050, 1066, 1613, 1613,
     1051, 1070, 1071, 1613, 1064, 1076, 1613, 1070, 1079, 1613,

     1071, 1613, 1086, 1076, 1083, 1087, 1095, 1088, 1092, 1613,
     1100, 1092, 1102, 1103, 1108, 1105, 1100, 1111, 1115, 1103,
     1119, 1613, 1115, 1109, 1613, 1613, 1116, 1120, 1128, 1129,
     1134, 1613, 1613, 1137, 1613, 1123, 1140, 1141, 1150, 1147,
     1135, 1613, 1152, 1137, 1159, 1150, 1159, 1163, 1150, 1155,
     1170, 1613, 1613, 1154, 1155, 1159, 1163, 1178, 1183, 1176,
     1187, 1183, 1169, 1177, 1182, 1613, 1185, 1206, 1203, 1613,
     1189, 1613, 1208, 1613, 1613, 1202, 1215, 1208, 1613, 1198,
     1205, 1205, 1204, 1213, 1613, 1613, 1613, 1218, 1214, 1222,
     1613, 1231, 1613, 1218, 1217, 1613, 1219, 1234, 1613, 1226,

     1227, 1227, 1613, 1242, 1235, 1255, 1245, 1259, 1260, 1247,
     1247, 1613, 1613, 1267, 1251, 1254, 1251, 1255, 1257, 1260,
     1259, 1260, 1278, 1275, 1613, 1613, 1274, 1269, 1270, 1272,
     1291, 1613, 1279, 1280, 1278, 1302, 1294, 1306, 1613, 1298,
     1308, 1298, 1299, 1613, 1305, 1613, 1613, 1301, 1613, 1306,
     1308, 1318, 1313, 1327, 1313, 1312, 1330, 1331, 1320, 1329,
     1330, 1342, 1345,    0, 1336, 1347, 1345, 1613, 1339, 1353,
     1358, 1363, 1356, 1365, 1366, 1367, 1613, 1370, 1613, 1361,
     1368, 1376, 1356, 1377, 1367, 1379, 1382, 1370, 1377, 1613,
     1388, 1613, 1386, 1375, 1386, 1395, 1613, 1403, 1613, 1613,

     1386, 1398, 1397, 1410, 1404, 1404, 1613, 1407, 1613, 1613,
     1410, 1409, 1613, 1613, 1410, 1613, 1613, 1406, 1409, 1613,
     1418, 1418, 1613, 1613, 1613, 1433, 1613, 1415, 1420, 1613,
     1425, 1427, 1439, 1613, 1431, 1613, 1434, 1435, 1445, 1441,
     1455, 1613, 1439, 1458, 1613, 1444, 1613, 1458, 1613, 1453,
     1454, 1459, 1613, 1455, 1456, 1613, 1453, 1459, 1465, 1466,
     1472, 1613, 1482, 1472, 1486, 1613, 1613, 1613, 1474, 1491,
     1484, 1484, 1613, 1613, 1613, 1613, 1531, 1534, 1537, 1540,
     1543, 1546, 1549, 1552, 1555, 1558, 1561, 1564, 1567, 1570,
     1573, 1576, 1579, 1582, 1585, 1588, 1591,   18,    5, 1594,

     1597, 1600, 1603, 1606, 1609
    } ;

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[1672] =
    {   0,
      676,   61,   62,   63,   64,   65,   61,  219,   89,   90,
       91,   66,   92,  201,  201,   67,  164,  199,  166,   68,
      216,   89,   90,   91,  272,   92,   60,  198,  198,  199,
       89,   90,   93,  162,   94,   61,  163,   66,  272,   60,
       66,   67,  164,  165,  166,   68,   61,   62,   63,   64,
       65,   61,   60,   89,   90,   93,   66,   94,   61,  162,
       67,  167,  163,   66,   68,   60,   66,  171,  214,  165,
      172,  214,  173,   61,   62,   96,  211,   97,   98,  205,
      205,  206,   66,   99,   60,  281,   67,  167,  299,   66,
       68,   69,   70,  171,   71,   60,  172,   72,  173,   60,

       73,   60,   74,   75,   76,   77,   78,   79,   80,   99,
      281,   81,  169,  299,  168,  163,  170,   69,   70,  211,
       71,   60,  304,   72,   60,   60,   73,   60,   74,   75,
       76,   77,   78,   79,   80,   60,   81,   60,  169,   60,
      168,  163,  170,  174,   82,   83,  175,   84,   85,  179,
      180,   86,   87,   61,   62,   96,  304,   97,   98,   88,
      302,   60,  183,   99,  184,   60,  198,  198,  199,  174,
       82,   83,  175,   84,   85,  179,  180,   86,   87,  205,
      205,  206,   89,   90,  101,   88,  102,  103,  183,   99,
      184,  302,  104,   89,   90,  101,  325,  102,  103,  194,

      185,  194,  176,  104,   89,   90,  105,  177,  106,   89,
       90,  105,  186,  106,  191,   89,   90,  107,  104,  108,
       61,  325,   60,  191,  178,   66,  185,   60,  176,  104,
       89,   90,  107,  177,  108,   61,  160,  189,  186,   60,
       66,  160,  272,  272,   60,   60,   60,   60,   60,  178,
       60,   66,  329,   60,   60,   60,   60,   60,   60,   60,
       60,   60,   60,  189,   60,  331,   66,   60,   61,   62,
       63,   60,   65,   61,  202,   60,   60,  329,  110,   60,
       60,   60,   60,   60,   60,   60,   60,   60,   60,  111,
      331,   60,   60,  208,  208,  214,  214,  206,  209,   60,

      202,   60,   60,   60,  110,   60,   60,   60,  217,  218,
       60,  211,  211,  147,   60,  111,   60,   61,   62,   63,
       60,   65,   61,  220,  209,  340,  194,  110,   60,   60,
      194,  191,   60,   60,  217,  218,   60,   60,  111,  147,
       60,  191,  160,   60,   60,   60,   60,  221,   60,  220,
      340,  147,   60,  110,  149,  149,   60,   60,  150,  150,
       60,   60,  229,  160,  111,   60,   61,   62,   63,   60,
       65,   61,  676,  221,   60,  676,  113,  147,   60,  676,
      149,  149,   60,   60,  150,  150,   60,   60,  229,   60,
       60,  114,  676,  676,  157,   60,  158,  157,   60,  158,

       60,   60,  113,  676,   60,   60,   60,  181,  162,   60,
       60,  187,  182,   60,  676,  188,  230,  114,   60,   61,
       62,   63,   60,   65,   61,  222,   60,   60,  223,  113,
       60,   60,   60,  181,  162,   60,   60,  187,  182,   60,
      224,  188,  230,  226,  114,  201,  201,  227,  676,  199,
      676,  222,  349,  228,  223,  113,  676,  231,  676,  232,
      225,  233,  234,  235,  236,  237,  224,  676,  239,  226,
      114,  115,  116,  227,  117,  118,  119,  349,  120,  228,
      121,  122,  123,  231,   76,  232,  225,  233,  234,  235,
      236,  237,  240,  162,  239,  241,  676,  115,  116,  244,

      117,  118,  119,  238,  120,  245,  121,  122,  123,  242,
       76,   60,  246,  676,  243,  247,  249,  252,  240,  162,
      248,  241,  124,  253,  250,  244,   60,  254,  238,  255,
      256,  245,  257,  125,  258,  242,  126,  259,  246,  243,
      251,  247,  249,  252,  260,  261,  248,  676,  124,  253,
      250,  676,   60,  254,  262,  255,  256,  263,  257,  125,
      258,  126,   60,  259,  264,  251,  265,  266,  267,  268,
      260,  261,  269,  124,  249,  274,  275,   60,  276,  277,
      262,  278,  279,  263,  125,  280,  676,  126,  270,  282,
      264,  283,  265,  266,  267,  268,  676,  284,  269,  124,

      249,  274,  275,   60,  276,  277,  285,  278,  279,  676,
      125,  280,  126,   60,  270,  282,  286,  283,  287,  288,
      127,  289,  128,  284,   60,  290,  129,  130,   60,  291,
      292,  293,  285,  294,  131,  132,  676,  295,  296,  676,
      297,  676,  286,  298,  287,  288,  127,  289,  128,  300,
       60,  290,  129,  130,   60,  291,  292,  293,  301,  294,
      131,  132,   60,  295,  296,  133,  297,  134,  303,  298,
      208,  208,  305,   60,  206,  300,  306,   60,  307,  135,
      136,  308,  309,  137,  301,  310,  676,  138,  311,  676,
      312,  133,  676,  134,  303,  313,  314,  315,  305,   60,

      316,  676,  306,   60,  307,  135,  136,  308,  309,  137,
      319,  310,  138,  139,  311,  140,  312,  141,  142,  317,
      320,  313,  314,  315,  321,  318,  316,  143,  144,  322,
      323,  145,  324,  326,  676,  146,  319,  327,  328,  139,
      330,  140,  332,  141,  142,  317,  320,  335,  336,  676,
      321,  318,  446,  143,  144,  322,  323,  145,  324,  326,
      146,   60,  337,  327,  328,  338,  330,  333,  332,  339,
      341,  342,   60,  335,  336,  147,   60,  446,  334,  343,
      344,  345,  274,  148,  676,  346,  347,  348,  337,  350,
      351,  338,  352,  333,  353,  339,  341,  342,   60,  676,

      354,  147,   60,  334,  355,  343,  344,  345,  274,  148,
       60,  346,  347,  348,  356,  350,  351,  357,  352,  358,
      353,   60,  359,  360,  147,   60,  354,  361,  362,  363,
      355,  364,  148,  676,  365,  366,  367,  368,  369,  370,
      356,  676,  371,  357,  676,  358,  372,   60,  359,  360,
      147,   60,  373,  361,  362,  363,  374,  364,  148,   60,
      365,  366,  367,  368,  369,  370,  375,  151,  371,  376,
       60,  377,  372,  378,   60,  152,  676,  379,  373,  380,
      381,  382,  374,  383,  676,  384,  385,  676,  386,  387,
      388,  676,  375,  151,  389,  376,   60,  377,  390,  378,

       60,  152,   60,  379,  391,  380,  381,  382,  392,  383,
      151,  384,  385,   60,  386,  387,  388,   60,  152,  676,
      389,  393,  394,  395,  390,  396,  397,  676,  398,  399,
      391,  400,  401,  402,  392,  676,  151,  676,  403,   60,
      404,  405,  406,   60,  152,   60,  407,  393,  394,  395,
      408,  396,  397,  153,  398,  399,  154,  400,  401,  402,
       60,  155,  409,  156,  403,  410,  404,  405,  406,  411,
      412,  413,  407,  414,  415,  676,  408,  416,  417,  153,
      676,  418,  154,  419,  420,  421,   60,  155,  409,  156,
       60,  410,  422,  423,  424,  411,  412,  413,  153,  414,

      415,  154,  425,  416,  417,   60,  155,  418,  156,  419,
      420,  421,  426,  427,  428,  429,  430,  431,  422,  423,
      424,  432,  433,  434,  153,  435,  436,  154,  425,  437,
      438,   60,  155,  439,  156,  440,  441,  442,  426,  427,
      428,  429,  430,  431,  443,  444,  445,  432,  433,  434,
      447,  435,  436,  448,  449,  437,  438,  450,  451,  439,
      452,  440,  441,  442,  453,  454,  455,  456,  457,  458,
      443,  444,  445,  459,  460,  461,  447,  462,  463,  448,
      449,  464,  465,  450,  451,  452,  466,  467,  468,  469,
      453,  454,  455,  456,  457,  458,  470,  471,  472,  459,

      460,  461,  473,  462,  463,  474,  475,  464,  465,  476,
      477,  478,  466,  467,  468,  469,  479,  480,  481,  482,
      483,  484,  470,  471,  472,  485,  486,  487,  473,  488,
      489,  474,  475,  490,  491,  476,  477,  478,  492,  493,
      494,  495,  479,  480,  481,  482,  483,  484,  496,  497,
      498,  485,  486,  487,  499,  488,  489,  500,  501,  490,
      491,  502,  503,  504,  492,  493,  494,  495,  505,  506,
      507,  508,  509,  510,  496,  497,  498,  511,  512,  513,
      499,  514,  516,  500,  501,  517,  515,  502,  503,  504,
      518,  519,  522,  523,  505,  506,  507,  508,  509,  510,

      520,  524,  521,  511,  512,  513,  525,  514,  516,  526,
      529,  517,  515,  527,  530,  531,  518,  519,  522,  523,
      532,  528,  533,  534,  535,  536,  520,  524,  521,  537,
      538,  539,  525,  540,  541,  526,  529,  542,  543,  527,
      530,  531,  544,  545,  546,  547,  532,  528,  533,  534,
      535,  536,  548,  549,  551,  537,  538,  539,  550,  540,
      541,  552,  553,  542,  543,  554,  555,  556,  544,  545,
      546,  547,  557,  558,  559,  560,  561,  562,  548,  549,
      551,  563,  564,  550,  565,  566,  567,  552,  553,  568,
      569,  554,  555,  556,  570,  571,  572,  573,  557,  558,

      559,  560,  561,  562,  574,  575,  576,  563,  564,  577,
      565,  566,  567,  578,  579,  568,  569,  580,  581,  582,
      570,  571,  572,  573,  583,  584,  585,  586,  587,  588,
      574,  575,  576,  589,  577,  590,  591,  592,  593,  578,
      579,  594,  595,  580,  581,  582,  596,  597,  598,  599,
      583,  584,  585,  586,  587,  588,  600,  601,  602,  589,
      603,  590,  591,  592,  593,  604,  605,  594,  595,  606,
      607,  608,  596,  597,  598,  599,  609,  610,  611,  612,
      613,  614,  600,  601,  602,  615,  603,  616,  617,  618,
      619,  604,  605,  620,  621,  606,  607,  608,  622,  623,

      624,  625,  609,  610,  611,  612,  613,  614,  626,  627,
      628,  615,  616,  629,  617,  618,  619,  630,  631,  620,
      621,  632,  633,  634,  622,  623,  624,  625,  635,  636,
      637,  638,  639,  640,  626,  627,  628,  641,  642,  629,
      643,  644,  645,  630,  631,  646,  647,  632,  633,  634,
      648,  649,  650,  651,  635,  636,  637,  638,  639,  640,
      652,  653,  654,  641,  642,  655,  643,  644,  645,  656,
      657,  646,  647,  658,  659,  660,  648,  649,  650,  651,
      661,  662,  663,  676,  664,  665,  652,  653,  654,  666,
      667,  655,  668,  669,  670,  656,  657,  671,  672,  658,

      659,  660,  673,  674,  675,  676,  661,  662,  663,  664,
      676,  665,  676,  676,  676,  666,  667,  676,  668,  669,
      670,  676,  676,  671,  672,  676,  676,  676,  673,  674,
      675,   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,  676,  196,  197,  197,  197,
      200,  200,  200,  203,  676,  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,   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,  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[1672] =
    {   0,
        0,    1,    1,    1,    1,    1,    1,  699,    7,    7,
        7,    1,    7,   97,   97,    1,   68,   97,   70,    1,
      698,    8,    8,    8,  273,    8,    7,   96,   96,   96,
        9,    9,    9,   66,    9,    9,   67,    1,  271,    8,
        9,    1,   68,   69,   70,    1,    2,    2,    2,    2,
        2,    2,    7,   10,   10,   10,    2,   10,   10,   66,
        2,   71,   67,   10,    2,    8,    9,   74,  215,   69,
       75,  213,   76,   11,   11,   11,  212,   11,   11,  101,
      101,  101,    2,   11,   27,  169,    2,   71,  187,   10,
        2,    3,    3,   74,    3,   27,   75,    3,   76,   27,

        3,    3,    3,    3,    3,    3,    3,    3,    3,   11,
      169,    3,   73,  187,   72,   72,   73,    3,    3,  210,
        3,   27,  208,    3,   28,   27,    3,    3,    3,    3,
        3,    3,    3,    3,    3,   28,    3,    5,   73,   28,
       72,   72,   73,   77,    5,    5,   78,    5,    5,   80,
       81,    5,    5,   12,   12,   12,  205,   12,   12,    5,
      201,   28,   83,   12,   84,   28,  197,  197,  197,   77,
        5,    5,   78,    5,    5,   80,   81,    5,    5,  204,
      204,  204,   13,   13,   13,    5,   13,   13,   83,   12,
       84,  198,   13,   14,   14,   14,  236,   14,   14,  195,

       85,  193,   79,   14,   15,   15,   15,   79,   15,   16,
       16,   16,   86,   16,  192,   17,   17,   17,   13,   17,
       17,  236,   15,  190,   79,   17,   85,   16,   79,   14,
       18,   18,   18,   79,   18,   18,  161,   88,   86,   29,
       18,  159,  158,  157,   30,   35,   36,   39,   15,   79,
       29,   17,  240,   16,   29,   30,   35,   36,   39,   30,
       35,   36,   39,   88,   40,  242,   18,   19,   19,   19,
       19,   19,   19,   19,   99,   40,   29,  240,   19,   40,
       29,   30,   35,   36,   39,   30,   35,   36,   39,   19,
      242,   41,   42,  102,  102,  108,  107,  102,  104,   43,

       99,   40,   41,   42,   19,   40,   41,   42,  110,  111,
       43,  106,  105,   43,   43,   19,   20,   20,   20,   20,
       20,   20,   20,  113,  104,  250,   94,   20,   41,   42,
       93,   92,   41,   42,  110,  111,   43,   44,   20,   43,
       43,   91,   65,   47,   48,   53,   54,  114,   44,  113,
      250,   44,   44,   20,   47,   48,   53,   54,   47,   48,
       53,   54,  118,   63,   20,   21,   21,   21,   21,   21,
       21,   21,   59,  114,   44,    0,   21,   44,   44,    0,
       47,   48,   53,   54,   47,   48,   53,   54,  118,   55,
       56,   21,    0,    0,   57,   57,   57,   58,   58,   58,

       55,   56,   21,    0,   55,   56,   57,   82,   82,   58,
       57,   87,   82,   58,    0,   87,  119,   21,   22,   22,
       22,   22,   22,   22,   22,  115,   55,   56,  115,   22,
       55,   56,   57,   82,   82,   58,   57,   87,   82,   58,
      116,   87,  119,  117,   22,  200,  200,  117,    0,  200,
        0,  115,  259,  117,  115,   22,    0,  120,    0,  121,
      116,  122,  123,  124,  125,  126,  116,    0,  128,  117,
       22,   23,   23,  117,   23,   23,   23,  259,   23,  117,
       23,   23,   23,  120,   23,  121,  116,  122,  123,  124,
      125,  126,  129,  127,  128,  130,    0,   23,   23,  132,

       23,   23,   23,  127,   23,  133,   23,   23,   23,  131,
       23,   25,  134,    0,  131,  135,  136,  138,  129,  127,
      135,  130,   25,  139,  137,  132,   25,  140,  127,  141,
      142,  133,  143,   25,  144,  131,   25,  145,  134,  131,
      137,  135,  136,  138,  146,  147,  135,    0,   25,  139,
      137,    0,   25,  140,  148,  141,  142,  149,  143,   25,
      144,   25,   26,  145,  150,  137,  151,  152,  153,  154,
      146,  147,  155,   26,  156,  162,  163,   26,  164,  165,
      148,  166,  167,  149,   26,  168,    0,   26,  156,  170,
      150,  171,  151,  152,  153,  154,    0,  172,  155,   26,

      156,  162,  163,   26,  164,  165,  173,  166,  167,    0,
       26,  168,   26,   31,  156,  170,  174,  171,  175,  176,
       31,  177,   31,  172,   31,  178,   31,   31,   31,  179,
      180,  181,  173,  182,   31,   31,    0,  183,  184,    0,
      185,    0,  174,  186,  175,  176,   31,  177,   31,  188,
       31,  178,   31,   31,   31,  179,  180,  181,  189,  182,
       31,   31,   33,  183,  184,   33,  185,   33,  202,  186,
      207,  207,  209,   33,  207,  188,  217,   33,  218,   33,
       33,  220,  221,   33,  189,  222,    0,   33,  223,    0,
      224,   33,    0,   33,  202,  225,  226,  227,  209,   33,

      228,    0,  217,   33,  218,   33,   33,  220,  221,   33,
      230,  222,   33,   37,  223,   37,  224,   37,   37,  229,
      231,  225,  226,  227,  232,  229,  228,   37,   37,  233,
      234,   37,  235,  237,    0,   37,  230,  238,  239,   37,
      241,   37,  243,   37,   37,  229,  231,  245,  246,    0,
      232,  229,  371,   37,   37,  233,  234,   37,  235,  237,
       37,   45,  247,  238,  239,  248,  241,  244,  243,  249,
      251,  252,   45,  245,  246,   45,   45,  371,  244,  253,
      254,  255,  255,   45,    0,  256,  257,  258,  247,  260,
      261,  248,  262,  244,  263,  249,  251,  252,   45,    0,

      264,   45,   45,  244,  265,  253,  254,  255,  255,   45,
       46,  256,  257,  258,  266,  260,  261,  267,  262,  268,
      263,   46,  269,  270,   46,   46,  264,  275,  277,  278,
      265,  279,   46,    0,  280,  281,  282,  283,  284,  285,
      266,    0,  286,  267,    0,  268,  287,   46,  269,  270,
       46,   46,  288,  275,  277,  278,  289,  279,   46,   49,
      280,  281,  282,  283,  284,  285,  290,   49,  286,  291,
       49,  293,  287,  294,   49,   49,    0,  295,  288,  296,
      297,  299,  289,  300,    0,  301,  307,    0,  309,  310,
      311,    0,  290,   49,  312,  291,   49,  293,  313,  294,

       49,   49,   50,  295,  314,  296,  297,  299,  315,  300,
       50,  301,  307,   50,  309,  310,  311,   50,   50,    0,
      312,  316,  317,  318,  313,  319,  320,    0,  321,  322,
      314,  323,  324,  325,  315,    0,   50,    0,  327,   50,
      328,  329,  330,   50,   50,   51,  331,  316,  317,  318,
      332,  319,  320,   51,  321,  322,   51,  323,  324,  325,
       51,   51,  333,   51,  327,  334,  328,  329,  330,  335,
      336,  337,  331,  338,  339,    0,  332,  340,  341,   51,
        0,  342,   51,  343,  344,  345,   51,   51,  333,   51,
       52,  334,  346,  347,  348,  335,  336,  337,   52,  338,

      339,   52,  349,  340,  341,   52,   52,  342,   52,  343,
      344,  345,  350,  351,  352,  353,  354,  355,  346,  347,
      348,  356,  357,  358,   52,  359,  360,   52,  349,  361,
      362,   52,   52,  363,   52,  364,  365,  366,  350,  351,
      352,  353,  354,  355,  367,  369,  370,  356,  357,  358,
      372,  359,  360,  373,  374,  361,  362,  375,  376,  363,
      377,  364,  365,  366,  378,  379,  380,  381,  382,  383,
      367,  369,  370,  384,  385,  387,  372,  388,  391,  373,
      374,  392,  393,  375,  376,  377,  395,  396,  398,  399,
      378,  379,  380,  381,  382,  383,  401,  403,  404,  384,

      385,  387,  405,  388,  391,  406,  407,  392,  393,  408,
      409,  411,  395,  396,  398,  399,  412,  413,  414,  415,
      416,  417,  401,  403,  404,  418,  419,  420,  405,  421,
      423,  406,  407,  424,  427,  408,  409,  411,  428,  429,
      430,  431,  412,  413,  414,  415,  416,  417,  434,  436,
      437,  418,  419,  420,  438,  421,  423,  439,  440,  424,
      427,  441,  443,  444,  428,  429,  430,  431,  445,  446,
      447,  448,  449,  450,  434,  436,  437,  451,  454,  455,
      438,  456,  457,  439,  440,  458,  456,  441,  443,  444,
      459,  460,  462,  463,  445,  446,  447,  448,  449,  450,

      461,  464,  461,  451,  454,  455,  465,  456,  457,  467,
      469,  458,  456,  468,  471,  473,  459,  460,  462,  463,
      476,  468,  477,  478,  480,  481,  461,  464,  461,  482,
      483,  484,  465,  488,  489,  467,  469,  490,  492,  468,
      471,  473,  494,  495,  497,  498,  476,  468,  477,  478,
      480,  481,  500,  501,  504,  482,  483,  484,  502,  488,
      489,  505,  506,  490,  492,  507,  508,  509,  494,  495,
      497,  498,  510,  511,  514,  515,  516,  517,  500,  501,
      504,  518,  519,  502,  520,  521,  522,  505,  506,  523,
      524,  507,  508,  509,  527,  528,  529,  530,  510,  511,

      514,  515,  516,  517,  531,  533,  534,  518,  519,  535,
      520,  521,  522,  536,  537,  523,  524,  538,  540,  541,
      527,  528,  529,  530,  542,  543,  545,  548,  550,  551,
      531,  533,  534,  552,  535,  553,  554,  555,  556,  536,
      537,  557,  558,  538,  540,  541,  559,  560,  561,  562,
      542,  543,  545,  548,  550,  551,  563,  565,  566,  552,
      567,  553,  554,  555,  556,  569,  570,  557,  558,  571,
      572,  573,  559,  560,  561,  562,  574,  575,  576,  578,
      580,  581,  563,  565,  566,  582,  567,  583,  584,  585,
      586,  569,  570,  587,  588,  571,  572,  573,  589,  591,

      593,  594,  574,  575,  576,  578,  580,  581,  595,  596,
      598,  582,  583,  601,  584,  585,  586,  602,  603,  587,
      588,  604,  605,  606,  589,  591,  593,  594,  608,  611,
      612,  615,  618,  619,  595,  596,  598,  621,  622,  601,
      626,  628,  629,  602,  603,  631,  632,  604,  605,  606,
      633,  635,  637,  638,  608,  611,  612,  615,  618,  619,
      639,  640,  641,  621,  622,  643,  626,  628,  629,  644,
      646,  631,  632,  648,  650,  651,  633,  635,  637,  638,
      652,  654,  655,    0,  657,  658,  639,  640,  641,  659,
      660,  643,  661,  663,  664,  644,  646,  665,  669,  648,

      650,  651,  670,  671,  672,    0,  652,  654,  655,  657,
        0,  658,    0,    0,    0,  659,  660,    0,  661,  663,
      664,    0,    0,  665,  669,    0,    0,    0,  670,  671,
      672,  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,    0,  688,  689,  689,  689,
      690,  690,  690,  691,    0,  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,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  676,  676,  676,
      676,  676,  676,  676,  676,  676,  676,  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_lmd_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);
                if (map_l->name->use) {
                    buffer_add_head(map_l->name, ':');
                    buffer_add_head_str(map_l->name, 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;

                buffer_copy(map_l->name_prefix, map_l->name);
                if (map_l->ns_prefix->use) {
                    buffer_add_head(map_l->name_prefix, ':');
                    buffer_add_head_str(map_l->name_prefix, map_l->ns_prefix->buf);
                }

                buffer_copy(map_l->name_no_uri, map_l->name);
                if (map_l->ns_uri->use) {
                    buffer_add_head(map_l->name, ':');
                    buffer_add_head_str(map_l->name, map_l->ns_uri->buf);
                }

		ows_layer_list_add(map_o->layers, map_l);
	}
		
	map_is_dump = map_is_postgis = false;
}






























#line 1639 "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.
 */
#ifndef _WIN32
#include <unistd.h>
#endif
#endif

#ifndef YY_EXTRA_TYPE
#define YY_EXTRA_TYPE void *
#endif

static int yy_init_globals (void );

/* Accessor methods to globals.
   These are made visible to non-reentrant scanners for convenience. */

int yylex_destroy (void );

int yyget_debug (void );

void yyset_debug (int debug_flag  );

YY_EXTRA_TYPE yyget_extra (void );

void yyset_extra (YY_EXTRA_TYPE user_defined  );

FILE *yyget_in (void );

void yyset_in  (FILE * in_str  );

FILE *yyget_out (void );

void yyset_out  (FILE * out_str  );

yy_size_t yyget_leng (void );

char *yyget_text (void );

int yyget_lineno (void );

void yyset_lineno (int line_number  );

/* 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 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 = '*'; \
		yy_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 598 "src/mapfile/mapfile.l"


#line 1860 "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 600 "src/mapfile/mapfile.l"
{ char c ; for (c=input() ; c && c != '\n' ; c=input()); }
	YY_BREAK
case 2:
YY_RULE_SETUP
#line 601 "src/mapfile/mapfile.l"
{ yy_push_state(INCLUDE); OWS_MAP_DBG }
	YY_BREAK
case 3:
YY_RULE_SETUP
#line 604 "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 607 "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 618 "src/mapfile/mapfile.l"
{ yy_push_state(MAP); OWS_MAP_DBG }
	YY_BREAK
case 6:
YY_RULE_SETUP
#line 619 "src/mapfile/mapfile.l"
{ yy_push_state(WEB); OWS_MAP_DBG }
	YY_BREAK
case 7:
YY_RULE_SETUP
#line 620 "src/mapfile/mapfile.l"
{ yy_push_state(QUERYMAP); OWS_MAP_DBG }
	YY_BREAK
case 8:
YY_RULE_SETUP
#line 621 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE /* must be before SYMBOL */ }
	YY_BREAK
case 9:
YY_RULE_SETUP
#line 622 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 10:
YY_RULE_SETUP
#line 623 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 11:
YY_RULE_SETUP
#line 624 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 12:
YY_RULE_SETUP
#line 625 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 13:
YY_RULE_SETUP
#line 626 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 14:
YY_RULE_SETUP
#line 627 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 15:
YY_RULE_SETUP
#line 628 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 16:
YY_RULE_SETUP
#line 629 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 17:
YY_RULE_SETUP
#line 630 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 18:
YY_RULE_SETUP
#line 631 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 19:
YY_RULE_SETUP
#line 632 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 20:
YY_RULE_SETUP
#line 633 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 21:
YY_RULE_SETUP
#line 634 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 22:
YY_RULE_SETUP
#line 635 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 23:
YY_RULE_SETUP
#line 636 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 24:
YY_RULE_SETUP
#line 637 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 25:
YY_RULE_SETUP
#line 638 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 26:
YY_RULE_SETUP
#line 639 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 27:
YY_RULE_SETUP
#line 640 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 28:
YY_RULE_SETUP
#line 641 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 29:
YY_RULE_SETUP
#line 642 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 30:
YY_RULE_SETUP
#line 643 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 31:
YY_RULE_SETUP
#line 644 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 32:
YY_RULE_SETUP
#line 645 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 33:
YY_RULE_SETUP
#line 646 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 34:
YY_RULE_SETUP
#line 647 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 35:
YY_RULE_SETUP
#line 648 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 36:
YY_RULE_SETUP
#line 649 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 37:
YY_RULE_SETUP
#line 650 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 38:
YY_RULE_SETUP
#line 651 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 39:
YY_RULE_SETUP
#line 652 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 40:
YY_RULE_SETUP
#line 653 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 41:
YY_RULE_SETUP
#line 654 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 42:
YY_RULE_SETUP
#line 655 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 43:
YY_RULE_SETUP
#line 656 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 44:
YY_RULE_SETUP
#line 657 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 45:
YY_RULE_SETUP
#line 658 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 46:
YY_RULE_SETUP
#line 659 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 47:
YY_RULE_SETUP
#line 660 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 48:
YY_RULE_SETUP
#line 661 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 49:
YY_RULE_SETUP
#line 662 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 50:
YY_RULE_SETUP
#line 663 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 51:
YY_RULE_SETUP
#line 664 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 52:
YY_RULE_SETUP
#line 665 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 53:
YY_RULE_SETUP
#line 666 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 54:
YY_RULE_SETUP
#line 667 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 55:
YY_RULE_SETUP
#line 668 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 56:
YY_RULE_SETUP
#line 669 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 57:
YY_RULE_SETUP
#line 670 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 58:
YY_RULE_SETUP
#line 671 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 59:
YY_RULE_SETUP
#line 672 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 60:
YY_RULE_SETUP
#line 673 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 61:
YY_RULE_SETUP
#line 674 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 62:
YY_RULE_SETUP
#line 675 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 63:
YY_RULE_SETUP
#line 676 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 64:
YY_RULE_SETUP
#line 677 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 65:
YY_RULE_SETUP
#line 678 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 66:
YY_RULE_SETUP
#line 679 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 67:
YY_RULE_SETUP
#line 680 "src/mapfile/mapfile.l"
{ OWS_MAP_EATLINE }
	YY_BREAK
case 68:
YY_RULE_SETUP
#line 682 "src/mapfile/mapfile.l"
{ yy_push_state(SYMBOL); OWS_MAP_DBG }
	YY_BREAK
case 69:
YY_RULE_SETUP
#line 683 "src/mapfile/mapfile.l"
{ yy_push_state(SCALEBAR); OWS_MAP_DBG  }
	YY_BREAK
case 70:
YY_RULE_SETUP
#line 684 "src/mapfile/mapfile.l"
{ yy_push_state(REFERENCE); OWS_MAP_DBG }
	YY_BREAK
case 71:
YY_RULE_SETUP
#line 685 "src/mapfile/mapfile.l"
{ yy_push_state(OUTPUTFORMAT); OWS_MAP_DBG }
	YY_BREAK
case 72:
YY_RULE_SETUP
#line 686 "src/mapfile/mapfile.l"
{ yy_push_state(METADATA); OWS_MAP_DBG }
	YY_BREAK
case 73:
YY_RULE_SETUP
#line 687 "src/mapfile/mapfile.l"
{ yy_push_state(GRID); OWS_MAP_DBG }
	YY_BREAK
case 74:
YY_RULE_SETUP
#line 688 "src/mapfile/mapfile.l"
{ yy_push_state(JOIN); OWS_MAP_DBG }
	YY_BREAK
case 75:
YY_RULE_SETUP
#line 689 "src/mapfile/mapfile.l"
{ yy_push_state(LAYER_METADATA); OWS_MAP_DBG }
	YY_BREAK
case 76:
YY_RULE_SETUP
#line 690 "src/mapfile/mapfile.l"
{ yy_push_state(CLASS); OWS_MAP_DBG }
	YY_BREAK
case 77:
YY_RULE_SETUP
#line 691 "src/mapfile/mapfile.l"
{ yy_push_state(STYLE); OWS_MAP_DBG }
	YY_BREAK
case 78:
YY_RULE_SETUP
#line 692 "src/mapfile/mapfile.l"
{ yy_push_state(LABEL); OWS_MAP_DBG }
	YY_BREAK
case 79:
YY_RULE_SETUP
#line 693 "src/mapfile/mapfile.l"
{ yy_push_state(PROJECTION); OWS_MAP_DBG }
	YY_BREAK
case 80:
YY_RULE_SETUP
#line 694 "src/mapfile/mapfile.l"
{ yy_push_state(PATTERN); OWS_MAP_DBG }
	YY_BREAK
case 81:
YY_RULE_SETUP
#line 695 "src/mapfile/mapfile.l"
{ yy_push_state(POINTS); OWS_MAP_DBG }
	YY_BREAK
case 82:
YY_RULE_SETUP
#line 696 "src/mapfile/mapfile.l"
{ yy_push_state(LABEL); OWS_MAP_DBG }
	YY_BREAK
case 83:
YY_RULE_SETUP
#line 697 "src/mapfile/mapfile.l"
{ yy_push_state(LAYER); map_l = ows_layer_init(); OWS_MAP_DBG }
	YY_BREAK
case 84:
YY_RULE_SETUP
#line 698 "src/mapfile/mapfile.l"
{ yy_push_state(FEATURE); OWS_MAP_DBG }
	YY_BREAK
case 85:
YY_RULE_SETUP
#line 699 "src/mapfile/mapfile.l"
{ BEGIN PROPERTIES; map_prop_state = MAP_NAME; }
	YY_BREAK
case 86:
YY_RULE_SETUP
#line 700 "src/mapfile/mapfile.l"
{ BEGIN LAYER_PROPERTIES; map_layer_prop_state = MAP_LAYER_NAME; }
	YY_BREAK
case 87:
YY_RULE_SETUP
#line 701 "src/mapfile/mapfile.l"
{ BEGIN LAYER_PROPERTIES; map_layer_prop_state = MAP_LAYER_CONNECTION; }
	YY_BREAK
case 88:
YY_RULE_SETUP
#line 702 "src/mapfile/mapfile.l"
{ BEGIN LAYER_CONNECTIONTYPE; }
	YY_BREAK
case 89:
YY_RULE_SETUP
#line 703 "src/mapfile/mapfile.l"
{ BEGIN LAYER; map_is_postgis=true; }
	YY_BREAK
case 90:
YY_RULE_SETUP
#line 704 "src/mapfile/mapfile.l"
{ BEGIN LAYER; map_is_postgis=false; }
	YY_BREAK
case 91:
YY_RULE_SETUP
#line 705 "src/mapfile/mapfile.l"
{ BEGIN LAYER_DUMP; }
	YY_BREAK
case 92:
YY_RULE_SETUP
#line 706 "src/mapfile/mapfile.l"
{ BEGIN LAYER; map_is_dump=true; }
	YY_BREAK
case 93:
YY_RULE_SETUP
#line 707 "src/mapfile/mapfile.l"
{ BEGIN LAYER; map_is_dump=false; }
	YY_BREAK
case 94:
/* rule 94 can match eol */
YY_RULE_SETUP
#line 709 "src/mapfile/mapfile.l"
{}
	YY_BREAK
case 95:
/* rule 95 can match eol */
YY_RULE_SETUP
#line 711 "src/mapfile/mapfile.l"
{metadata_key(yytext, true); BEGIN METADATA_VALUE;}
	YY_BREAK
case 96:
/* rule 96 can match eol */
YY_RULE_SETUP
#line 712 "src/mapfile/mapfile.l"
{metadata_value(yytext, true); BEGIN METADATA;}
	YY_BREAK
case 97:
/* rule 97 can match eol */
YY_RULE_SETUP
#line 713 "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 714 "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 715 "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 746 "src/mapfile/mapfile.l"
{properties(yytext, true);  BEGIN MAP;}
	YY_BREAK
case 101:
YY_RULE_SETUP
#line 747 "src/mapfile/mapfile.l"
{properties(yytext, false);  BEGIN MAP;}		
	YY_BREAK
case 102:
/* rule 102 can match eol */
YY_RULE_SETUP
#line 748 "src/mapfile/mapfile.l"
{layer_properties(yytext, true);  BEGIN LAYER;}
	YY_BREAK
case 103:
YY_RULE_SETUP
#line 749 "src/mapfile/mapfile.l"
{layer_properties(yytext, false);  BEGIN LAYER;}		
	YY_BREAK
case 104:
/* rule 104 can match eol */
YY_RULE_SETUP
#line 750 "src/mapfile/mapfile.l"
{}
	YY_BREAK
case 105:
YY_RULE_SETUP
#line 751 "src/mapfile/mapfile.l"
{}
	YY_BREAK
case 106:
/* rule 106 can match eol */
YY_RULE_SETUP
#line 752 "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 754 "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 769 "src/mapfile/mapfile.l"
ECHO;
	YY_BREAK
#line 2567 "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
		{
			yy_size_t 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 )
				{
				yy_size_t 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;

	if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
		/* Extend the array by 50%, plus the number we really need. */
		yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
		YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size  );
		if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
			YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
	}

	(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 */
			yy_size_t 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)
{
	yy_size_t 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*)
								);
		if ( ! (yy_buffer_stack) )
			YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
								  
		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*)
								);
		if ( ! (yy_buffer_stack) )
			YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );

		/* 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 yystr 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, yy_size_t  _yybytes_len )
{
	YY_BUFFER_STATE b;
	char *buf;
	yy_size_t n, 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.
 * 
 */
yy_size_t 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 769 "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);
}

