#ifdef HAVE_CONFIG_H
#include <rasqal_config.h>
#endif

#ifdef WIN32
#include <win32_rasqal_config.h>
#endif

#line 10 "sparql_lexer.c"

#line 12 "sparql_lexer.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;

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

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

/* An opaque pointer. */
#ifndef YY_TYPEDEF_YY_SCANNER_T
#define YY_TYPEDEF_YY_SCANNER_T
typedef void* yyscan_t;
#endif

/* For convenience, these vars (plus the bison vars far below)
   are macros in the reentrant scanner. */
#define yyin yyg->yyin_r
#define yyout yyg->yyout_r
#define yyextra yyg->yyextra_r
#define yyleng yyg->yyleng_r
#define yytext yyg->yytext_r
#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno)
#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
#define yy_flex_debug yyg->yy_flex_debug_r

/* 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 yyg->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 ((yyg->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 sparql_lexer_restart(yyin ,yyscanner )

#define YY_END_OF_BUFFER_CHAR 0

/* Size of default input buffer. */
#ifndef YY_BUF_SIZE
#ifdef __ia64__
/* On IA-64, the buffer size is 16k, not 8k.
 * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
 * Ditto for the __ia64__ case accordingly.
 */
#define YY_BUF_SIZE 32768
#else
#define YY_BUF_SIZE 16384
#endif /* __ia64__ */
#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

#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 = yyg->yy_hold_char; \
		YY_RESTORE_YY_MORE_OFFSET \
		yyg->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, yyg->yytext_ptr , yyscanner )

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

#ifndef YY_STRUCT_YY_BUFFER_STATE
#define YY_STRUCT_YY_BUFFER_STATE
struct yy_buffer_state
	{
	FILE *yy_input_file;

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

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

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

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

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

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

    int yy_bs_lineno; /**< The line count. */
    int yy_bs_column; /**< The column count. */
    
	/* Whether to try to fill the input buffer when we reach the
	 * end of it.
	 */
	int yy_fill_buffer;

	int yy_buffer_status;

#define YY_BUFFER_NEW 0
#define YY_BUFFER_NORMAL 1
	/* When an EOF's been seen but there's still some text to process
	 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
	 * shouldn't try reading from the input source any more.  We might
	 * still have a bunch of tokens to match, though, because of
	 * possible backing-up.
	 *
	 * When we actually see the EOF, we change the status to "new"
	 * (via sparql_lexer_restart()), 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 */

/* 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 ( yyg->yy_buffer_stack \
                          ? yyg->yy_buffer_stack[yyg->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 yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]

void sparql_lexer_restart (FILE *input_file ,yyscan_t yyscanner );
void sparql_lexer__switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
YY_BUFFER_STATE sparql_lexer__create_buffer (FILE *file,int size ,yyscan_t yyscanner );
void sparql_lexer__delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
void sparql_lexer__flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
void sparql_lexer_push_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
void sparql_lexer_pop_buffer_state (yyscan_t yyscanner );

static void sparql_lexer_ensure_buffer_stack (yyscan_t yyscanner );
static void sparql_lexer__load_buffer_state (yyscan_t yyscanner );
static void sparql_lexer__init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner );

#define YY_FLUSH_BUFFER sparql_lexer__flush_buffer(YY_CURRENT_BUFFER ,yyscanner)

YY_BUFFER_STATE sparql_lexer__scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
YY_BUFFER_STATE sparql_lexer__scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
YY_BUFFER_STATE sparql_lexer__scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );

void *sparql_lexer_alloc (yy_size_t ,yyscan_t yyscanner );
void *sparql_lexer_realloc (void *,yy_size_t ,yyscan_t yyscanner );
void sparql_lexer_free (void * ,yyscan_t yyscanner );

#define yy_new_buffer sparql_lexer__create_buffer

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

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

#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)

/* Begin user sect3 */

typedef unsigned char YY_CHAR;

typedef int yy_state_type;

#define yytext_ptr yytext_r

static yy_state_type yy_get_previous_state (yyscan_t yyscanner );
static yy_state_type yy_try_NUL_trans (yy_state_type current_state  ,yyscan_t yyscanner);
static int yy_get_next_buffer (yyscan_t yyscanner );

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

#define YY_NUM_RULES 110
#define YY_END_OF_BUFFER 111
/* 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[456] =
    {   0,
        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
        0,    0,  111,  109,    4,    3,    3,   78,  109,  109,
       63,  109,  109,   58,   59,   76,   83,   57,   84,   66,
       77,   80,  104,   67,  109,   70,   73,   62,  109,  109,
      109,  109,  109,  109,  109,  109,  109,  109,  109,  109,
      109,  109,  109,  109,  109,  109,  109,   60,   61,  109,
       56,   64,  109,   65,   96,   95,   99,   97,   98,  103,
      100,  102,  103,   89,   89,   92,   92,    4,    3,   71,
        0,   86,    0,    0,  108,  108,   69,    0,   85,    0,
        0,   80,   81,    2,    0,   81,    0,  104,  104,   79,

       72,   72,   74,  107,    0,   72,   75,    0,    0,  104,
       42,    0,    0,    0,   30,    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,   68,   95,   97,   98,  100,    0,    0,  101,    0,
        0,    0,    0,    0,    0,   86,   87,    0,    0,   85,
       90,    0,    0,    0,    0,    1,    1,   81,    0,    0,
       82,  104,    0,    0,  107,    0,   32,   11,   39,    0,
        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,

        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
        0,    0,    0,   46,    0,    0,   41,   40,    0,    0,
        0,    0,    0,    0,    0,    0,    0,    0,   19,   38,
        0,    0,    0,    0,  105,   88,   91,   86,    0,   85,
        0,    0,   82,    0,   82,    0,   17,    0,    0,    0,
        0,    0,    0,   52,    0,   33,    0,   53,    0,    0,
        0,    6,    0,    0,    0,   55,    0,    0,    0,   20,
        0,   54,    0,    0,    0,    0,    0,    0,    0,    0,
        0,    0,   93,    0,    0,   48,  105,    0,    0,    0,
       86,   86,    0,    0,   85,   85,    0,    0,    0,    0,

      106,   18,   49,    0,    0,   37,    0,    0,    0,    0,
        0,    0,   94,    0,   25,   36,    0,    0,   22,    0,
        0,   14,   26,    0,    0,   29,    0,    0,   31,    0,
        0,    0,   15,    7,    0,    0,   86,    0,   86,    0,
        0,   85,    0,   85,    0,    0,    0,    0,   50,    0,
       43,    0,    0,    0,   27,   44,    0,    0,    0,   28,
        0,    8,    0,    0,    5,   51,   88,    0,    0,   91,
        0,    0,   86,    0,    0,   85,    0,    0,    0,    0,
        0,    0,    0,   35,   23,    0,    0,    0,   13,    0,
       88,    0,    0,   88,    0,    0,   91,    0,    0,   91,

        0,    0,   47,    0,   21,    9,   12,    0,    0,   16,
       45,   88,    0,    0,    0,    0,   91,    0,    0,    0,
        0,   10,   24,    0,   88,   91,    0,    0,    0,   34,
        0,    0,   88,    0,    0,   91,    0,    0,   88,    0,
        0,   88,    0,    0,   91,    0,    0,   91,    0,    0,
       88,    0,   91,    0,    0
    } ;

static yyconst flex_int32_t yy_ec[256] =
    {   0,
        1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
        2,    1,    4,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    5,    6,    7,    8,    9,    1,   10,   11,   12,
       13,   14,   15,   16,   17,   18,   19,   20,   20,   20,
       20,   20,   20,   20,   20,   20,   20,   21,   22,   23,
       24,   25,   26,   27,   28,   29,   30,   31,   32,   33,
       34,   35,   36,   37,   38,   39,   40,   41,   42,   43,
       37,   44,   45,   46,   47,   48,   49,   50,   51,   37,
       52,   53,   54,   55,   56,    1,   57,   29,   30,   31,

       32,   33,   34,   35,   36,   37,   38,   39,   40,   41,
       42,   43,   37,   44,   45,   46,   47,   48,   49,   50,
       51,   37,   58,   59,   60,    1,    1,   61,   61,   61,
       61,   61,   61,   61,   61,   61,   61,   61,   61,   61,
       61,   61,   61,   61,   61,   61,   61,   61,   61,   61,
       61,   61,   61,   61,   61,   61,   61,   61,   61,   61,
       61,   61,   61,   61,   61,   61,   61,   61,   61,   61,
       61,   61,   61,   61,   61,   61,   61,   61,   61,   61,
       61,   61,   61,   61,   61,   61,   61,   61,   61,   61,
       61,   61,   61,   61,   61,   61,   61,   61,   61,   61,

       61,   61,   61,   61,   61,   61,   61,   61,   61,   61,
       61,   61,   61,   61,   61,   61,   61,   61,   61,   61,
       61,   61,   61,   61,   61,   61,   61,   61,   61,   61,
       61,   61,   61,   61,   61,   61,   61,   61,   61,   61,
       61,   61,   61,   61,   61,   61,   61,   61,   61,   61,
       61,   61,   61,   61,   61
    } ;

static yyconst flex_int32_t yy_meta[62] =
    {   0,
        1,    1,    2,    2,    3,    1,    1,    1,    1,    1,
        1,    4,    1,    1,    1,    1,    5,    6,    1,    7,
        8,    1,    9,   10,    1,    1,    1,   11,   11,   11,
       11,   11,   11,   11,   11,   11,   11,   11,   11,   11,
       11,   11,   11,   11,   11,   11,   11,   11,   11,   11,
       11,    1,   12,    1,   13,    7,   11,    1,    1,    1,
       12
    } ;

static yyconst flex_int16_t yy_base[495] =
    {   0,
        0,    0,   61,    0,  122,    0,  183,    0, 1667, 1655,
     1650, 1635, 1507, 2558,  243, 2558, 1503, 1481,  239,  246,
     2558, 1494,  236, 2558, 2558, 2558,  233, 2558,  234, 1483,
      241,  238,  245, 2558,  292, 2558, 1478, 2558,  243,  336,
      241,  337,  338,  335,  354,  245,  356,  363,  368,  362,
      385,  364,  247,  394,  392,  368,  396, 2558, 2558, 1480,
      416, 2558, 1365, 2558, 2558,    0, 2558,  269,    0, 2558,
      270, 2558,  255, 1416, 1411, 1378, 1301,  276, 2558, 2558,
      363,  408,    0,  283, 2558, 1308, 2558,  349,  400,    0,
     1286,  424,  401, 2558,  358,  425,  432, 2558,  272, 2558,

     1228, 2558, 2558, 1230, 1163,  418, 2558,  432,  441,  434,
      447,  448,  449,  453,  454,  455,  460,  465,  472,  471,
      477,  478,  484,  485,  490,  491,  507,  505,  516,  518,
      520,  522,  526,  535,  539,  547,  540,  549,  551,  556,
      558,  557,  563,  572,  573,  578,  580,  585,  587,  586,
        0, 2558,    0,  607,    0,  608,  602,  604, 2558, 1177,
     1164, 1160, 1128, 1126, 1124,  464, 2558,    0, 1056,  477,
     2558,    0, 1054,  609,  420, 2558, 1089,  428,  613, 1055,
     1050,  503,  530, 1024, 2558,  614,  617,  619,  648,  655,
      656,  660,  661,  662,  668,  673,  674,  672,  678,  692,

      685,  693,  694,  698,  700,  702,  704,  715,  706,  716,
      708,  725,  732,  736,  738,  742,  744,  746,  750,  751,
      757,  758,  759,  763,  765,  767,  773,  777,  782,  783,
      790,  794,  795,  796, 1012,  629,  560,  970,  345,  959,
      593,  988,  984,  958,  943,  839,  800,  802,  883,  806,
      884,  885,  889,  890,  891,  895,  896,  807,  897,  901,
      902,  808,  903,  908,  922,  814,  924,  923,  928,  929,
      937,  816,  939,  935,  943,  944,  950,  954,  955,  961,
      959,  969,  973,  974,  979,  975,  930,  910,  734,  630,
      775,    0,  794,  980,  752,    0,  781,  981,    0,  777,

      775,  985,  991,  995,  999, 1000, 1001, 1005, 1006, 1010,
     1011, 1018, 1016, 1023, 1024, 1029, 1030, 1037, 1039, 1041,
     1043, 1045, 1047, 1051, 1061, 1056, 1062, 1063, 1067, 1069,
     1068, 1073, 1075, 1085, 1113, 1164,  752,  733, 2558, 1086,
     1087,  724,  680, 2558, 1092, 1097, 1103, 1198, 1104, 1147,
     1105, 1109, 1110, 1202, 1111, 1151, 1206, 1208, 1210, 1155,
     1161, 1159, 1160, 1214, 1165, 1212, 1252, 1241, 1313, 1364,
     1244, 1425,  680,  654,  643,  613,  528,  505, 1218, 1233,
     1239, 1358, 1216, 1220, 1252, 1359, 1469, 1470, 1256, 1471,
     1511,  506, 1028,  507,    0,  463, 1572,  575,  724,  469,

        0,  458, 1257, 1258, 1289, 1360, 1364, 1616, 1475, 1365,
     1370,    0,    0, 1091, 1092, 1215,    0,    0, 1236, 1483,
     1624, 1401, 1477, 1618, 1631, 1629, 1623, 1635, 1632, 1479,
     1690, 1751, 1812, 1640, 1873, 1934, 1647, 1995, 2056, 1641,
     1644,  447,    0,  363, 2117, 1642, 1648,  365,    0,  261,
        0,    0,    0,    0, 2558, 2178, 2191, 2204, 2217, 2230,
     2240, 2248, 2254, 2260, 2268, 2280, 2293, 2306, 2316, 2328,
     2335,  266,  256, 2343, 2351, 2357, 2365, 2371, 2377, 2389,
     2398, 2404, 2416, 2425, 2433, 2445, 2454, 2466, 2479, 2492,
     2505, 2518, 2531, 2544

    } ;

static yyconst flex_int16_t yy_def[495] =
    {   0,
      455,    1,  455,    3,  455,    5,  455,    7,  456,  456,
      457,  457,  455,  455,  455,  455,  455,  455,  458,  459,
      455,  455,  460,  455,  455,  455,  455,  455,  455,  455,
      455,  455,  461,  455,  455,  455,  455,  455,  462,  462,
      462,  462,  462,   42,  462,  462,  462,   42,   42,  462,
      462,  462,  462,   42,  462,  462,  462,  455,  455,  455,
      462,  455,  455,  455,  455,  463,  455,  455,  464,  455,
      455,  455,  465,  466,  466,  467,  467,  455,  455,  455,
      458,  455,  458,  459,  455,  455,  455,  460,  455,  460,
      455,  455,  455,  455,  468,  455,  455,  455,  469,  455,

      470,  455,  455,  455,  470,  470,  455,  462,  462,  461,
      462,  462,  462,  462,  462,  462,  462,  462,  462,  462,
      462,  462,  462,  462,  462,  462,  462,  462,  462,  462,
      462,  462,  462,  462,  462,  462,  462,  462,  462,  462,
      462,  462,  462,  462,  462,  462,  462,  462,  462,  462,
      471,  455,  463,  455,  464,  455,  465,  465,  455,  466,
      466,  466,  467,  467,  467,  455,  455,  472,  455,  455,
      455,  473,  455,  455,  468,  455,  455,  455,  455,  455,
      455,  469,  469,  470,  455,  470,  462,  462,  462,  462,
      462,  462,  462,  462,  462,  462,  462,  462,  462,  462,

      462,  462,  462,  462,  462,  462,  462,  462,  462,  462,
      462,  462,  462,  462,  462,  462,  462,  462,  462,  462,
      462,  462,  462,  462,  462,  462,  462,  462,  462,  462,
      462,  462,  462,  462,  474,  466,  467,  475,  476,  477,
      478,  455,  455,  455,  455,  455,  462,  462,  462,  462,
      462,  462,  462,  462,  462,  462,  462,  462,  462,  462,
      462,  462,  462,  462,  462,  462,  462,  462,  462,  462,
      462,  462,  462,  462,  462,  462,  462,  462,  462,  462,
      462,  462,  462,  462,  462,  462,  474,  474,  466,  467,
      475,  479,  480,  481,  477,  482,  483,  484,  246,  246,

      455,  462,  462,  462,  462,  462,  462,  462,  462,  462,
      462,  462,  462,  462,  462,  462,  462,  462,  462,  462,
      462,  462,  462,  462,  462,  462,  462,  462,  462,  462,
      462,  462,  462,  462,  466,  467,  485,  486,  455,  481,
      481,  487,  488,  455,  484,  484,  462,  462,  462,  462,
      462,  462,  462,  462,  462,  462,  462,  462,  462,  462,
      462,  462,  462,  462,  462,  462,  466,  489,  455,  467,
      490,  455,  485,  485,  486,  487,  487,  488,  462,  462,
      462,  462,  462,  462,  462,  462,  462,  462,  462,  462,
      455,  491,  491,  466,  369,  369,  455,  492,  492,  467,

      372,  372,  462,  462,  462,  462,  462,  462,  462,  462,
      462,  391,  391,  491,  491,  491,  397,  397,  492,  492,
      492,  462,  462,  462,  491,  492,  462,  491,  492,  462,
      455,  455,  455,  493,  455,  455,  494,  455,  455,  491,
      491,  466,  435,  435,  455,  492,  492,  467,  438,  438,
      439,  439,  445,  445,    0,  455,  455,  455,  455,  455,
      455,  455,  455,  455,  455,  455,  455,  455,  455,  455,
      455,  455,  455,  455,  455,  455,  455,  455,  455,  455,
      455,  455,  455,  455,  455,  455,  455,  455,  455,  455,
      455,  455,  455,  455

    } ;

static yyconst flex_int16_t yy_nxt[2620] =
    {   0,
       14,   15,   16,   17,   15,   18,   19,   20,   21,   22,
       23,   24,   25,   26,   27,   28,   29,   30,   31,   32,
       33,   34,   35,   36,   37,   38,   14,   39,   40,   41,
       42,   43,   44,   45,   46,   47,   46,   46,   48,   49,
       50,   51,   52,   53,   54,   55,   56,   46,   57,   46,
       46,   58,   46,   59,   14,   60,   61,   62,   63,   64,
       46,   65,   65,   65,   65,   65,   65,   65,   65,   65,
       65,   65,   65,   65,   65,   65,   65,   65,   65,   65,
       66,   65,   65,   65,   65,   65,   65,   65,   66,   66,
       66,   66,   66,   66,   66,   66,   66,   66,   66,   66,

       66,   66,   66,   66,   66,   66,   66,   66,   66,   66,
       66,   66,   65,   66,   65,   65,   66,   66,   65,   65,
       65,   66,   67,   68,   67,   67,   68,   67,   67,   67,
       67,   67,   67,   67,   67,   67,   67,   67,   67,   67,
       67,   69,   67,   67,   67,   67,   67,   67,   67,   69,
       69,   69,   69,   69,   69,   69,   69,   69,   69,   69,
       69,   69,   69,   69,   69,   69,   69,   69,   69,   69,
       69,   69,   69,   67,   69,   67,   67,   69,   69,   67,
       67,   67,   69,   70,   71,   70,   70,   71,   70,   70,
       70,   70,   70,   70,   70,   70,   70,   70,   70,   70,

       70,   70,   70,   72,   70,   70,   70,   70,   70,   70,
       73,   73,   73,   73,   73,   73,   73,   73,   73,   73,
       73,   73,   73,   73,   73,   73,   73,   73,   73,   73,
       73,   73,   73,   73,   70,   73,   70,   70,   70,   73,
       70,   70,   70,   73,   78,   82,   89,   78,   85,   86,
       91,   91,   92,   92,   94,   96,   98,   92,  109,   95,
      109,  110,  109,  110,  109,  110,  240,  110,  100,   97,
      154,  156,  158,  154,  156,  159,  238,   78,  141,  116,
       78,  419,  117,   98,  118,   85,   86,  111,   90,  183,
      112,   83,  101,  101,  101,  101,  102,  101,  101,  101,

      101,  101,  101,  101,  101,  101,  101,  101,  101,  101,
      101,  101,  101,  101,  102,  103,  104,  101,  101,  105,
      105,  105,  105,  105,  105,  105,  105,  105,  105,  105,
      105,  105,  105,  105,  105,  105,  105,  105,  105,  105,
      105,  105,  105,  101,  101,  101,  101,  106,  105,  101,
      101,  101,  101,  109,  109,  109,  110,  110,  110,  170,
      176,  177,  124,  113,  119,  292,  108,  293,  120,  166,
      125,  109,  121,  109,  110,  164,  110,  114,  126,  109,
      122,  109,  110,  414,  110,  109,  115,  123,  110,  136,
      130,  124,  113,  119,  131,  134,  128,  127,  132,  108,

      129,   90,  109,  135,  133,  110,  108,  140,  148,  109,
      171,  108,  110,  109,  167,   83,  110,  137,  136,  130,
       93,  142,  176,  177,  134,  143,  172,  138,  139,  144,
      149,  150,  174,  109,  168,  147,  110,  108,  186,  145,
      146,   96,  104,   92,  178,   98,  180,  178,  180,  109,
      142,  181,  110,  161,  173,   97,  179,  455,  109,  179,
      111,  455,  169,  112,  109,  109,  109,  110,  110,  110,
      109,  109,  109,  110,  110,  110,  187,  109,  163,  164,
      110,  189,  109,  160,  188,  110,  192,  193,  109,  109,
      168,  110,  110,  190,  109,  109,  196,  110,  110,  191,

      194,  109,  109,  172,  110,  110,  195,  109,  109,  198,
      110,  110,  415,  161,   98,  199,  193,  197,  169,  201,
      183,  200,  109,  203,  109,  110,  202,  110,  204,  344,
      394,  173,  205,  109,  206,  109,  110,  109,  110,  109,
      110,  455,  110,  109,  210,  377,  110,  183,  207,  208,
      209,  211,  109,  216,  212,  110,  109,  109,  213,  110,
      110,  215,  211,  206,  109,  214,  109,  110,  109,  110,
      237,  110,  220,  109,  109,  109,  110,  110,  110,  218,
      109,  222,  216,  110,  217,  420,  219,  223,  224,  109,
      109,  225,  110,  110,  221,  109,  226,  109,  110,  400,

      110,  227,  109,  109,  109,  110,  110,  110,  154,  156,
      228,  154,  156,  296,  290,  297,  229,  230,  233,  158,
      232,  158,  159,  242,  455,  242,  231,  244,  243,  244,
      377,  234,  245,  246,  109,  236,  109,  110,  104,  110,
      164,  246,  246,  246,  246,  246,  246,  246,  246,  246,
      246,  246,  246,  246,  246,  246,  246,  246,  246,  246,
      246,  246,  246,  246,  246,  109,  246,  339,  110,  246,
      246,  374,  109,  109,  246,  110,  110,  109,  109,  109,
      110,  110,  110,  289,  336,  109,  247,  249,  110,  109,
      109,  109,  110,  110,  110,  109,  248,  374,  110,  250,

      253,  254,  109,  255,  344,  110,  251,  256,  252,  109,
      109,  109,  110,  110,  110,  109,  249,  109,  110,  109,
      110,  109,  110,  109,  110,  109,  110,  258,  110,  253,
      254,  259,  109,  109,  421,  110,  110,  257,  260,  262,
      161,  377,  109,  261,  263,  110,  265,  266,  400,  109,
      264,  268,  110,  109,  267,  109,  110,  339,  110,  109,
      269,  109,  110,  109,  110,  270,  110,  109,  109,  374,
      110,  110,  272,  271,  109,  109,  109,  110,  110,  110,
      109,  273,  109,  110,  109,  110,  185,  110,  335,  276,
      109,  277,  275,  110,  109,  274,  279,  110,  280,  109,

      109,  104,  110,  110,  281,  344,  173,  109,  282,  278,
      110,  109,  109,  109,  110,  110,  110,  109,  339,  109,
      110,  283,  110,  109,  109,  109,  110,  110,  110,  169,
      286,  109,  302,  109,  110,  284,  110,  304,  285,  184,
      184,  184,  184,  184,  184,  184,  184,  184,  184,  184,
      184,  184,  184,  184,  184,  299,  300,  184,  299,  184,
      184,  184,  184,  301,  184,  184,  299,  299,  299,  299,
      299,  299,  299,  299,  299,  299,  299,  299,  299,  299,
      299,  299,  299,  299,  299,  299,  299,  299,  299,  299,
      184,  299,  184,  184,  299,  299,  184,  184,  184,  299,

      109,  109,  109,  110,  110,  110,  109,  109,  109,  110,
      110,  110,  109,  109,  109,  110,  110,  110,  109,  109,
      109,  110,  110,  110,  312,  109,  303,  288,  110,  305,
      306,  311,  313,  314,  307,  308,  309,  315,  310,  109,
      109,  109,  110,  110,  110,  109,  109,  288,  110,  110,
      316,  318,  109,  312,  109,  110,  109,  110,  319,  110,
      109,  109,  245,  110,  110,  317,  324,  109,  321,  323,
      110,  109,  109,  320,  110,  110,  109,  245,  109,  110,
      318,  110,  322,  328,  325,  327,  109,  326,  331,  110,
      109,  109,  109,  110,  110,  110,  109,  341,  346,  110,

      292,  296,  109,  243,  329,  110,  330,  243,  109,  332,
      334,  110,  109,  173,  333,  110,  109,  109,  109,  110,
      110,  110,  109,  109,  169,  110,  110,  109,  109,  288,
      110,  110,  349,  109,  416,  109,  110,  351,  110,  347,
      109,  109,  348,  110,  110,  352,  109,  109,  104,  110,
      110,  353,  394,  354,  109,  350,  109,  110,  109,  110,
      109,  110,  109,  110,  109,  110,  355,  110,  109,  181,
      359,  110,  358,  109,  181,  356,  110,  357,  109,  109,
      109,  110,  110,  110,  109,  109,  109,  110,  110,  110,
      109,  176,  109,  110,  363,  110,  360,  415,  416,  359,

      364,  361,  109,  341,  341,  110,  292,  455,  241,  346,
      239,  362,  296,  365,  346,  394,  394,  455,  366,  161,
      109,  109,  109,  110,  110,  110,  109,  109,  109,  110,
      110,  110,  379,  367,  237,  368,  165,  382,  164,  383,
      369,  369,  369,  369,  369,  369,  369,  369,  369,  369,
      369,  369,  369,  369,  369,  369,  369,  369,  369,  369,
      369,  369,  369,  369,  109,  369,  236,  110,  109,  369,
      162,  110,  109,  369,  164,  110,  109,  109,  109,  110,
      110,  110,  109,  161,  370,  110,  371,  104,  388,  381,
      389,  372,  372,  372,  372,  372,  372,  372,  372,  372,

      372,  372,  372,  372,  372,  372,  372,  372,  372,  372,
      372,  372,  372,  372,  372,  109,  372,  388,  110,  109,
      372,  425,  110,  109,  372,  109,  110,  109,  110,  109,
      110,  109,  110,  109,  110,  109,  110,  109,  110,  394,
      110,  185,  384,  385,  380,  160,  420,  393,  163,  403,
      109,  386,  104,  110,  399,  387,  109,  390,  161,  110,
      400,  407,  404,  160,  160,  394,  163,  163,  400,  109,
      405,  391,  110,  109,  109,  109,  110,  110,  110,  391,
      391,  391,  391,  391,  391,  391,  391,  391,  391,  391,
      391,  391,  391,  391,  391,  391,  391,  391,  391,  391,

      391,  391,  391,  422,  391,   93,  109,  391,  391,  110,
       85,  165,  391,  160,  160,  160,  160,  160,  160,  161,
      160,  160,  160,  160,  160,  160,  160,  160,  160,  395,
      396,  160,  395,  367,  160,  160,  160,  160,  160,  160,
      395,  395,  395,  395,  395,  395,  395,  395,  395,  395,
      395,  395,  395,  395,  395,  395,  395,  395,  395,  395,
      395,  395,  395,  395,  160,  395,  160,  160,  395,  395,
      160,  160,  160,  395,  164,  109,  109,  109,  110,  110,
      110,  109,  109,  397,  110,  110,  408,  109,  164,  406,
      110,  397,  397,  397,  397,  397,  397,  397,  397,  397,

      397,  397,  397,  397,  397,  397,  397,  397,  397,  397,
      397,  397,  397,  397,  397,  408,  397,  162,  109,  397,
      397,  110,  161,  152,  397,  163,  163,  163,  163,  163,
      163,  163,  163,  163,  163,  164,  163,  163,  163,  163,
      163,  401,  402,  163,  401,  370,  163,  163,  163,  163,
      163,  163,  401,  401,  401,  401,  401,  401,  401,  401,
      401,  401,  401,  401,  401,  401,  401,  401,  401,  401,
      401,  401,  401,  401,  401,  401,  163,  401,  163,  163,
      401,  401,  163,  163,  163,  401,  109,  109,  109,  110,
      110,  110,  109,  421,  109,  110,  109,  110,  409,  110,

      151,  107,   93,   87,   80,   79,  455,  400,  410,  424,
      411,  160,  160,  160,  160,  160,  160,  161,  160,  160,
      160,  160,  160,  160,  160,  160,  160,  412,  413,  160,
      412,  160,  160,  160,  160,  160,  160,  160,  412,  412,
      412,  412,  412,  412,  412,  412,  412,  412,  412,  412,
      412,  412,  412,  412,  412,  412,  412,  412,  412,  412,
      412,  412,  160,  412,  160,  160,  412,  412,  160,  160,
      160,  412,  163,  163,  163,  163,  163,  163,  163,  163,
      163,  163,  164,  163,  163,  163,  163,  163,  417,  418,
      163,  417,  163,  163,  163,  163,  163,  163,  163,  417,

      417,  417,  417,  417,  417,  417,  417,  417,  417,  417,
      417,  417,  417,  417,  417,  417,  417,  417,  417,  417,
      417,  417,  417,  163,  417,  163,  163,  417,  417,  163,
      163,  163,  417,  109,  426,  109,  110,  425,  110,  426,
      109,  415,  420,  110,  414,   77,  441,  415,  400,  427,
      416,  419,  420,  400,  423,  394,  400,  447,  421,  394,
       77,   75,  414,  414,  442,  394,  400,  430,  394,  419,
      419,  448,  400,   75,  455,  455,  455,  455,  455,  455,
      455,  455,  455,  429,  455,  428,  432,  455,  455,  431,
      414,  414,  414,  414,  414,  414,  415,  414,  414,  414,

      414,  414,  414,  414,  414,  414,  414,  414,  414,  414,
      433,  414,  434,  414,  394,  414,  414,  435,  435,  435,
      435,  435,  435,  435,  435,  435,  435,  435,  435,  435,
      435,  435,  435,  435,  435,  435,  435,  435,  435,  435,
      435,  414,  435,  414,  414,  414,  435,  414,  414,  414,
      435,  419,  419,  419,  419,  419,  419,  419,  419,  419,
      419,  420,  419,  419,  419,  419,  419,  419,  419,  419,
      419,  436,  419,  437,  419,  400,  419,  419,  438,  438,
      438,  438,  438,  438,  438,  438,  438,  438,  438,  438,
      438,  438,  438,  438,  438,  438,  438,  438,  438,  438,

      438,  438,  419,  438,  419,  419,  419,  438,  419,  419,
      419,  438,  414,  414,  414,  414,  414,  414,  415,  414,
      414,  414,  414,  414,  414,  414,  414,  414,  414,  414,
      414,  439,  414,  414,  414,  414,  394,  414,  414,  439,
      439,  439,  439,  439,  439,  439,  439,  439,  439,  439,
      439,  439,  439,  439,  439,  439,  439,  439,  439,  439,
      439,  439,  439,  414,  439,  414,  414,  439,  439,  414,
      414,  414,  439,  414,  414,  414,  414,  414,  414,  415,
      414,  414,  414,  414,  414,  414,  414,  414,  414,  443,
      444,  414,  443,  433,  414,  414,  414,  394,  414,  414,

      443,  443,  443,  443,  443,  443,  443,  443,  443,  443,
      443,  443,  443,  443,  443,  443,  443,  443,  443,  443,
      443,  443,  443,  443,  414,  443,  414,  414,  443,  443,
      414,  414,  414,  443,  419,  419,  419,  419,  419,  419,
      419,  419,  419,  419,  420,  419,  419,  419,  419,  419,
      419,  419,  419,  445,  419,  419,  419,  419,  400,  419,
      419,  445,  445,  445,  445,  445,  445,  445,  445,  445,
      445,  445,  445,  445,  445,  445,  445,  445,  445,  445,
      445,  445,  445,  445,  445,  419,  445,  419,  419,  445,
      445,  419,  419,  419,  445,  419,  419,  419,  419,  419,

      419,  419,  419,  419,  419,  420,  419,  419,  419,  419,
      419,  449,  450,  419,  449,  436,  419,  419,  419,  400,
      419,  419,  449,  449,  449,  449,  449,  449,  449,  449,
      449,  449,  449,  449,  449,  449,  449,  449,  449,  449,
      449,  449,  449,  449,  449,  449,  419,  449,  419,  419,
      449,  449,  419,  419,  419,  449,  414,  414,  414,  414,
      414,  414,  415,  414,  414,  414,  414,  414,  414,  414,
      414,  414,  451,  452,  414,  451,  414,  414,  414,  414,
      394,  414,  414,  451,  451,  451,  451,  451,  451,  451,
      451,  451,  451,  451,  451,  451,  451,  451,  451,  451,

      451,  451,  451,  451,  451,  451,  451,  414,  451,  414,
      414,  451,  451,  414,  414,  414,  451,  419,  419,  419,
      419,  419,  419,  419,  419,  419,  419,  420,  419,  419,
      419,  419,  419,  453,  454,  419,  453,  419,  419,  419,
      419,  400,  419,  419,  453,  453,  453,  453,  453,  453,
      453,  453,  453,  453,  453,  453,  453,  453,  453,  453,
      453,  453,  453,  453,  453,  453,  453,  453,  419,  453,
      419,  419,  453,  453,  419,  419,  419,  453,   74,   74,
       74,   74,   74,   74,   74,   74,   74,   74,   74,   74,
       74,   76,   76,   76,   76,   76,   76,   76,   76,   76,

       76,   76,   76,   76,   81,  455,   81,   81,   81,   81,
       81,   81,   81,   81,   81,   81,   81,   84,   84,   84,
       84,   84,   84,   84,   84,   84,   84,   84,   84,   84,
       88,  455,   88,   88,   88,   88,   88,   88,   88,   88,
       88,   88,   88,   99,  455,  455,   99,  455,  455,   99,
       99,   99,  108,  108,  108,  108,  455,  455,  108,  108,
      153,  455,  455,  455,  153,  153,  155,  455,  455,  455,
      155,  155,  157,  157,  157,  157,  455,  455,  157,  157,
      160,  160,  160,  160,  160,  160,  160,  160,  160,  160,
      160,  160,  160,  163,  163,  163,  163,  163,  163,  163,

      163,  163,  163,  163,  163,  163,  175,  175,  175,  175,
      175,  175,  175,  175,  175,  175,  175,  175,  175,  182,
      182,  182,  182,  455,  455,  455,  182,  182,  184,  184,
      184,  184,  184,  184,  184,  184,  184,  184,  184,  184,
      184,  235,  455,  455,  455,  235,  235,  287,  287,  287,
      455,  455,  455,  287,  287,  291,  455,  291,  455,  455,
      455,  291,  455,  291,  294,  294,  455,  294,  294,  295,
      455,  295,  455,  455,  455,  295,  455,  295,  298,  298,
      455,  298,  298,  337,  455,  455,  455,  337,  337,  338,
      338,  455,  338,  338,  338,  338,  338,  455,  455,  338,

      338,  338,  340,  340,  340,  340,  455,  455,  340,  340,
      342,  455,  455,  455,  342,  342,  343,  343,  455,  343,
      343,  343,  343,  343,  455,  455,  343,  343,  343,  345,
      345,  345,  345,  455,  455,  345,  345,  373,  373,  373,
      455,  455,  455,  373,  373,  375,  375,  375,  375,  375,
      375,  375,  375,  375,  375,  375,  375,  375,  376,  376,
      376,  455,  455,  455,  376,  376,  378,  378,  378,  378,
      378,  378,  378,  378,  378,  378,  378,  378,  378,  392,
      392,  392,  392,  392,  392,  392,  392,  392,  392,  392,
      392,  392,  398,  398,  398,  398,  398,  398,  398,  398,

      398,  398,  398,  398,  398,  414,  414,  414,  414,  414,
      414,  414,  414,  414,  414,  414,  414,  414,  419,  419,
      419,  419,  419,  419,  419,  419,  419,  419,  419,  419,
      419,  440,  440,  440,  440,  440,  440,  440,  440,  440,
      440,  440,  440,  440,  446,  446,  446,  446,  446,  446,
      446,  446,  446,  446,  446,  446,  446,   13,  455,  455,
      455,  455,  455,  455,  455,  455,  455,  455,  455,  455,
      455,  455,  455,  455,  455,  455,  455,  455,  455,  455,
      455,  455,  455,  455,  455,  455,  455,  455,  455,  455,
      455,  455,  455,  455,  455,  455,  455,  455,  455,  455,

      455,  455,  455,  455,  455,  455,  455,  455,  455,  455,
      455,  455,  455,  455,  455,  455,  455,  455,  455
    } ;

static yyconst flex_int16_t yy_chk[2620] =
    {   0,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    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,    3,    3,    3,    3,    3,    3,    3,    3,
        3,    3,    5,    5,    5,    5,    5,    5,    5,    5,
        5,    5,    5,    5,    5,    5,    5,    5,    5,    5,
        5,    5,    5,    5,    5,    5,    5,    5,    5,    5,
        5,    5,    5,    5,    5,    5,    5,    5,    5,    5,
        5,    5,    5,    5,    5,    5,    5,    5,    5,    5,
        5,    5,    5,    5,    5,    5,    5,    5,    5,    5,
        5,    5,    5,    7,    7,    7,    7,    7,    7,    7,
        7,    7,    7,    7,    7,    7,    7,    7,    7,    7,

        7,    7,    7,    7,    7,    7,    7,    7,    7,    7,
        7,    7,    7,    7,    7,    7,    7,    7,    7,    7,
        7,    7,    7,    7,    7,    7,    7,    7,    7,    7,
        7,    7,    7,    7,    7,    7,    7,    7,    7,    7,
        7,    7,    7,    7,   15,   19,   23,   15,   20,   20,
       27,   29,   27,   29,   31,   32,   33,   32,   41,   31,
       39,   41,   46,   39,   53,   46,  473,   53,   33,   32,
       68,   71,   73,   68,   71,   73,  472,   78,   53,   41,
       78,  450,   41,   99,   41,   84,   84,   39,   23,   99,
       39,   19,   35,   35,   35,   35,   35,   35,   35,   35,

       35,   35,   35,   35,   35,   35,   35,   35,   35,   35,
       35,   35,   35,   35,   35,   35,   35,   35,   35,   35,
       35,   35,   35,   35,   35,   35,   35,   35,   35,   35,
       35,   35,   35,   35,   35,   35,   35,   35,   35,   35,
       35,   35,   35,   35,   35,   35,   35,   35,   35,   35,
       35,   35,   35,   40,   42,   43,   40,   42,   43,   88,
       95,   95,   44,   40,   42,  239,   44,  239,   42,   81,
       44,   45,   42,   47,   45,  448,   47,   40,   44,   50,
       42,   52,   50,  444,   52,   56,   40,   43,   56,   50,
       48,   44,   40,   42,   48,   49,   47,   45,   48,   49,

       47,   88,   51,   49,   48,   51,   48,   52,   56,   55,
       89,   49,   55,   57,   82,   81,   57,   51,   50,   48,
       93,   54,  175,  175,   49,   54,   89,   51,   51,   54,
       57,   57,   93,   61,   82,   55,   61,   54,  106,   54,
       54,   92,  106,   92,   96,  110,   97,  178,   97,  108,
       54,   97,  108,  442,   89,   92,   96,  110,  109,  178,
       61,  109,   82,   61,  111,  112,  113,  111,  112,  113,
      114,  115,  116,  114,  115,  116,  111,  117,  402,  400,
      117,  112,  118,  396,  111,  118,  116,  117,  120,  119,
      166,  120,  119,  113,  121,  122,  118,  121,  122,  114,

      117,  123,  124,  170,  123,  124,  117,  125,  126,  120,
      125,  126,  392,  394,  182,  120,  117,  119,  166,  122,
      182,  121,  128,  124,  127,  128,  123,  127,  125,  378,
      392,  170,  126,  129,  127,  130,  129,  131,  130,  132,
      131,  183,  132,  133,  129,  377,  133,  183,  127,  128,
      128,  129,  134,  133,  129,  134,  135,  137,  130,  135,
      137,  132,  129,  127,  136,  131,  138,  136,  139,  138,
      237,  139,  137,  140,  142,  141,  140,  142,  141,  135,
      143,  139,  133,  143,  134,  398,  136,  140,  141,  144,
      145,  141,  144,  145,  138,  146,  142,  147,  146,  398,

      147,  143,  148,  150,  149,  148,  150,  149,  154,  156,
      144,  154,  156,  241,  237,  241,  145,  146,  149,  157,
      148,  158,  157,  174,  158,  174,  147,  179,  174,  179,
      376,  150,  179,  186,  187,  236,  188,  187,  186,  188,
      290,  186,  186,  186,  186,  186,  186,  186,  186,  186,
      186,  186,  186,  186,  186,  186,  186,  186,  186,  186,
      186,  186,  186,  186,  186,  189,  186,  375,  189,  186,
      186,  374,  190,  191,  186,  190,  191,  192,  193,  194,
      192,  193,  194,  236,  290,  195,  190,  192,  195,  198,
      196,  197,  198,  196,  197,  199,  191,  373,  199,  193,

      196,  197,  201,  198,  343,  201,  194,  199,  195,  200,
      202,  203,  200,  202,  203,  204,  192,  205,  204,  206,
      205,  207,  206,  209,  207,  211,  209,  201,  211,  196,
      197,  202,  208,  210,  399,  208,  210,  200,  203,  205,
      289,  342,  212,  204,  206,  212,  208,  209,  399,  213,
      207,  211,  213,  214,  210,  215,  214,  338,  215,  216,
      212,  217,  216,  218,  217,  213,  218,  219,  220,  337,
      219,  220,  216,  215,  221,  222,  223,  221,  222,  223,
      224,  219,  225,  224,  226,  225,  301,  226,  289,  222,
      227,  223,  221,  227,  228,  220,  225,  228,  226,  229,

      230,  300,  229,  230,  227,  297,  295,  231,  228,  224,
      231,  232,  233,  234,  232,  233,  234,  247,  293,  248,
      247,  231,  248,  250,  258,  262,  250,  258,  262,  291,
      234,  266,  248,  272,  266,  232,  272,  250,  233,  246,
      246,  246,  246,  246,  246,  246,  246,  246,  246,  246,
      246,  246,  246,  246,  246,  246,  246,  246,  246,  246,
      246,  246,  246,  246,  246,  246,  246,  246,  246,  246,
      246,  246,  246,  246,  246,  246,  246,  246,  246,  246,
      246,  246,  246,  246,  246,  246,  246,  246,  246,  246,
      246,  246,  246,  246,  246,  246,  246,  246,  246,  246,

      249,  251,  252,  249,  251,  252,  253,  254,  255,  253,
      254,  255,  256,  257,  259,  256,  257,  259,  260,  261,
      263,  260,  261,  263,  259,  264,  249,  288,  264,  251,
      252,  257,  260,  261,  253,  254,  255,  263,  256,  265,
      268,  267,  265,  268,  267,  269,  270,  287,  269,  270,
      264,  267,  274,  259,  271,  274,  273,  271,  268,  273,
      275,  276,  245,  275,  276,  265,  274,  277,  270,  273,
      277,  278,  279,  269,  278,  279,  281,  244,  280,  281,
      267,  280,  271,  278,  275,  277,  282,  276,  281,  282,
      283,  284,  286,  283,  284,  286,  285,  294,  298,  285,

      294,  298,  302,  243,  279,  302,  280,  242,  303,  282,
      285,  303,  304,  240,  284,  304,  305,  306,  307,  305,
      306,  307,  308,  309,  238,  308,  309,  310,  311,  235,
      310,  311,  307,  313,  393,  312,  313,  309,  312,  304,
      314,  315,  305,  314,  315,  310,  316,  317,  184,  316,
      317,  311,  393,  312,  318,  308,  319,  318,  320,  319,
      321,  320,  322,  321,  323,  322,  314,  323,  324,  181,
      321,  324,  320,  326,  180,  317,  326,  318,  325,  327,
      328,  325,  327,  328,  329,  331,  330,  329,  331,  330,
      332,  177,  333,  332,  328,  333,  324,  414,  415,  321,

      330,  325,  334,  340,  341,  334,  340,  341,  173,  345,
      169,  327,  345,  331,  346,  414,  415,  346,  332,  335,
      347,  349,  351,  347,  349,  351,  352,  353,  355,  352,
      353,  355,  347,  335,  165,  335,  164,  352,  163,  353,
      335,  335,  335,  335,  335,  335,  335,  335,  335,  335,
      335,  335,  335,  335,  335,  335,  335,  335,  335,  335,
      335,  335,  335,  335,  350,  335,  162,  350,  356,  335,
      161,  356,  360,  335,  336,  360,  362,  363,  361,  362,
      363,  361,  365,  160,  336,  365,  336,  105,  361,  350,
      363,  336,  336,  336,  336,  336,  336,  336,  336,  336,

      336,  336,  336,  336,  336,  336,  336,  336,  336,  336,
      336,  336,  336,  336,  336,  348,  336,  361,  348,  354,
      336,  416,  354,  357,  336,  358,  357,  359,  358,  366,
      359,  364,  366,  383,  364,  379,  383,  384,  379,  416,
      384,  104,  354,  357,  348,  368,  419,  368,  371,  379,
      380,  358,  101,  380,  371,  359,  381,  364,  367,  381,
      419,  383,  380,  368,  368,  368,  371,  371,  371,  385,
      381,  367,  385,  389,  403,  404,  389,  403,  404,  367,
      367,  367,  367,  367,  367,  367,  367,  367,  367,  367,
      367,  367,  367,  367,  367,  367,  367,  367,  367,  367,

      367,  367,  367,  404,  367,   91,  405,  367,  367,  405,
       86,   77,  367,  369,  369,  369,  369,  369,  369,  369,
      369,  369,  369,  369,  369,  369,  369,  369,  369,  369,
      369,  369,  369,  369,  369,  369,  369,  369,  369,  369,
      369,  369,  369,  369,  369,  369,  369,  369,  369,  369,
      369,  369,  369,  369,  369,  369,  369,  369,  369,  369,
      369,  369,  369,  369,  369,  369,  369,  369,  369,  369,
      369,  369,  369,  369,  370,  382,  386,  406,  382,  386,
      406,  407,  410,  370,  407,  410,  386,  411,   76,  382,
      411,  370,  370,  370,  370,  370,  370,  370,  370,  370,

      370,  370,  370,  370,  370,  370,  370,  370,  370,  370,
      370,  370,  370,  370,  370,  386,  370,   75,  422,  370,
      370,  422,   74,   63,  370,  372,  372,  372,  372,  372,
      372,  372,  372,  372,  372,  372,  372,  372,  372,  372,
      372,  372,  372,  372,  372,  372,  372,  372,  372,  372,
      372,  372,  372,  372,  372,  372,  372,  372,  372,  372,
      372,  372,  372,  372,  372,  372,  372,  372,  372,  372,
      372,  372,  372,  372,  372,  372,  372,  372,  372,  372,
      372,  372,  372,  372,  372,  372,  387,  388,  390,  387,
      388,  390,  409,  420,  423,  409,  430,  423,  387,  430,

       60,   37,   30,   22,   18,   17,   13,  420,  388,  409,
      390,  391,  391,  391,  391,  391,  391,  391,  391,  391,
      391,  391,  391,  391,  391,  391,  391,  391,  391,  391,
      391,  391,  391,  391,  391,  391,  391,  391,  391,  391,
      391,  391,  391,  391,  391,  391,  391,  391,  391,  391,
      391,  391,  391,  391,  391,  391,  391,  391,  391,  391,
      391,  391,  391,  391,  391,  391,  391,  391,  391,  391,
      391,  391,  397,  397,  397,  397,  397,  397,  397,  397,
      397,  397,  397,  397,  397,  397,  397,  397,  397,  397,
      397,  397,  397,  397,  397,  397,  397,  397,  397,  397,

      397,  397,  397,  397,  397,  397,  397,  397,  397,  397,
      397,  397,  397,  397,  397,  397,  397,  397,  397,  397,
      397,  397,  397,  397,  397,  397,  397,  397,  397,  397,
      397,  397,  397,  408,  421,  424,  408,  425,  424,  426,
      427,  428,  429,  427,  434,   12,  434,  440,  421,  424,
      441,  437,  446,  426,  408,  425,  429,  437,  447,  428,
       11,   10,  434,  434,  434,  440,  446,  427,  441,  437,
      437,  437,  447,    9,    0,    0,    0,    0,    0,    0,
        0,    0,    0,  426,    0,  425,  429,    0,    0,  428,
      431,  431,  431,  431,  431,  431,  431,  431,  431,  431,

      431,  431,  431,  431,  431,  431,  431,  431,  431,  431,
      431,  431,  431,  431,  431,  431,  431,  431,  431,  431,
      431,  431,  431,  431,  431,  431,  431,  431,  431,  431,
      431,  431,  431,  431,  431,  431,  431,  431,  431,  431,
      431,  431,  431,  431,  431,  431,  431,  431,  431,  431,
      431,  432,  432,  432,  432,  432,  432,  432,  432,  432,
      432,  432,  432,  432,  432,  432,  432,  432,  432,  432,
      432,  432,  432,  432,  432,  432,  432,  432,  432,  432,
      432,  432,  432,  432,  432,  432,  432,  432,  432,  432,
      432,  432,  432,  432,  432,  432,  432,  432,  432,  432,

      432,  432,  432,  432,  432,  432,  432,  432,  432,  432,
      432,  432,  433,  433,  433,  433,  433,  433,  433,  433,
      433,  433,  433,  433,  433,  433,  433,  433,  433,  433,
      433,  433,  433,  433,  433,  433,  433,  433,  433,  433,
      433,  433,  433,  433,  433,  433,  433,  433,  433,  433,
      433,  433,  433,  433,  433,  433,  433,  433,  433,  433,
      433,  433,  433,  433,  433,  433,  433,  433,  433,  433,
      433,  433,  433,  435,  435,  435,  435,  435,  435,  435,
      435,  435,  435,  435,  435,  435,  435,  435,  435,  435,
      435,  435,  435,  435,  435,  435,  435,  435,  435,  435,

      435,  435,  435,  435,  435,  435,  435,  435,  435,  435,
      435,  435,  435,  435,  435,  435,  435,  435,  435,  435,
      435,  435,  435,  435,  435,  435,  435,  435,  435,  435,
      435,  435,  435,  435,  436,  436,  436,  436,  436,  436,
      436,  436,  436,  436,  436,  436,  436,  436,  436,  436,
      436,  436,  436,  436,  436,  436,  436,  436,  436,  436,
      436,  436,  436,  436,  436,  436,  436,  436,  436,  436,
      436,  436,  436,  436,  436,  436,  436,  436,  436,  436,
      436,  436,  436,  436,  436,  436,  436,  436,  436,  436,
      436,  436,  436,  436,  436,  438,  438,  438,  438,  438,

      438,  438,  438,  438,  438,  438,  438,  438,  438,  438,
      438,  438,  438,  438,  438,  438,  438,  438,  438,  438,
      438,  438,  438,  438,  438,  438,  438,  438,  438,  438,
      438,  438,  438,  438,  438,  438,  438,  438,  438,  438,
      438,  438,  438,  438,  438,  438,  438,  438,  438,  438,
      438,  438,  438,  438,  438,  438,  439,  439,  439,  439,
      439,  439,  439,  439,  439,  439,  439,  439,  439,  439,
      439,  439,  439,  439,  439,  439,  439,  439,  439,  439,
      439,  439,  439,  439,  439,  439,  439,  439,  439,  439,
      439,  439,  439,  439,  439,  439,  439,  439,  439,  439,

      439,  439,  439,  439,  439,  439,  439,  439,  439,  439,
      439,  439,  439,  439,  439,  439,  439,  445,  445,  445,
      445,  445,  445,  445,  445,  445,  445,  445,  445,  445,
      445,  445,  445,  445,  445,  445,  445,  445,  445,  445,
      445,  445,  445,  445,  445,  445,  445,  445,  445,  445,
      445,  445,  445,  445,  445,  445,  445,  445,  445,  445,
      445,  445,  445,  445,  445,  445,  445,  445,  445,  445,
      445,  445,  445,  445,  445,  445,  445,  445,  456,  456,
      456,  456,  456,  456,  456,  456,  456,  456,  456,  456,
      456,  457,  457,  457,  457,  457,  457,  457,  457,  457,

      457,  457,  457,  457,  458,    0,  458,  458,  458,  458,
      458,  458,  458,  458,  458,  458,  458,  459,  459,  459,
      459,  459,  459,  459,  459,  459,  459,  459,  459,  459,
      460,    0,  460,  460,  460,  460,  460,  460,  460,  460,
      460,  460,  460,  461,    0,    0,  461,    0,    0,  461,
      461,  461,  462,  462,  462,  462,    0,    0,  462,  462,
      463,    0,    0,    0,  463,  463,  464,    0,    0,    0,
      464,  464,  465,  465,  465,  465,    0,    0,  465,  465,
      466,  466,  466,  466,  466,  466,  466,  466,  466,  466,
      466,  466,  466,  467,  467,  467,  467,  467,  467,  467,

      467,  467,  467,  467,  467,  467,  468,  468,  468,  468,
      468,  468,  468,  468,  468,  468,  468,  468,  468,  469,
      469,  469,  469,    0,    0,    0,  469,  469,  470,  470,
      470,  470,  470,  470,  470,  470,  470,  470,  470,  470,
      470,  471,    0,    0,    0,  471,  471,  474,  474,  474,
        0,    0,    0,  474,  474,  475,    0,  475,    0,    0,
        0,  475,    0,  475,  476,  476,    0,  476,  476,  477,
        0,  477,    0,    0,    0,  477,    0,  477,  478,  478,
        0,  478,  478,  479,    0,    0,    0,  479,  479,  480,
      480,    0,  480,  480,  480,  480,  480,    0,    0,  480,

      480,  480,  481,  481,  481,  481,    0,    0,  481,  481,
      482,    0,    0,    0,  482,  482,  483,  483,    0,  483,
      483,  483,  483,  483,    0,    0,  483,  483,  483,  484,
      484,  484,  484,    0,    0,  484,  484,  485,  485,  485,
        0,    0,    0,  485,  485,  486,  486,  486,  486,  486,
      486,  486,  486,  486,  486,  486,  486,  486,  487,  487,
      487,    0,    0,    0,  487,  487,  488,  488,  488,  488,
      488,  488,  488,  488,  488,  488,  488,  488,  488,  489,
      489,  489,  489,  489,  489,  489,  489,  489,  489,  489,
      489,  489,  490,  490,  490,  490,  490,  490,  490,  490,

      490,  490,  490,  490,  490,  491,  491,  491,  491,  491,
      491,  491,  491,  491,  491,  491,  491,  491,  492,  492,
      492,  492,  492,  492,  492,  492,  492,  492,  492,  492,
      492,  493,  493,  493,  493,  493,  493,  493,  493,  493,
      493,  493,  493,  493,  494,  494,  494,  494,  494,  494,
      494,  494,  494,  494,  494,  494,  494,  455,  455,  455,
      455,  455,  455,  455,  455,  455,  455,  455,  455,  455,
      455,  455,  455,  455,  455,  455,  455,  455,  455,  455,
      455,  455,  455,  455,  455,  455,  455,  455,  455,  455,
      455,  455,  455,  455,  455,  455,  455,  455,  455,  455,

      455,  455,  455,  455,  455,  455,  455,  455,  455,  455,
      455,  455,  455,  455,  455,  455,  455,  455,  455
    } ;

/* 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
#line 1 "./sparql_lexer.l"
/* -*- Mode: c; c-basic-offset: 2 -*-
 *
 * sparql_lexer.l - Rasqal SPARQL lexer - making tokens for sparql grammar generator
 *
 * Copyright (C) 2004-2010, David Beckett http://www.dajobe.org/
 * Copyright (C) 2004-2005, University of Bristol, UK http://www.bristol.ac.uk/
 * 
 * This package is Free Software and part of Redland http://librdf.org/
 * 
 * It is licensed under the following three licenses as alternatives:
 *   1. GNU Lesser General Public License (LGPL) V2.1 or any newer version
 *   2. GNU General Public License (GPL) V2 or any newer version
 *   3. Apache License, V2.0 or any newer version
 * 
 * You may not use this file except in compliance with at least one of
 * the above three licenses.
 * 
 * See LICENSE.html or LICENSE.txt at the top of this package for the
 * complete terms and further detail along with the license texts for
 * the licenses in COPYING.LIB, COPYING and LICENSE-2.0.txt respectively.
 * 
 * To generate the C files from this source, rather than use the
 * shipped sparql_lexer.c/.h needs a patched version of flex 2.5.31 such
 * as the one available in Debian GNU/Linux.   Details below
 * near the %option descriptions.
 *
 * SPARQL defined in http://www.w3.org/TR/rdf-sparql-query/
 *   http://www.w3.org/TR/2005/WD-rdf-sparql-query-20050419/
 *
 * Editor's draft of above http://www.w3.org/2001/sw/DataAccess/rq23/
 */
/* recognise 8-bits */
/* all symbols prefixed by this */
/* This is not needed, flex is invoked -osparql_lexer.c */
/* Emit a C header file for prototypes
 * Only available in flex 2.5.13 or newer.
 * It was renamed to header-file in flex 2.5.19
 */
/* Do not emit #include <unistd.h>
 * Only available in flex 2.5.7 or newer.
 * Broken in flex 2.5.31 without patches.
 */
#define YY_NO_UNISTD_H 1
/* Never interactive */
/*  No isatty() check */
/* Batch scanner */
/* Never use yyunput */
/* Supply our own alloc/realloc/free functions */
/* Re-entrant scanner */

/* definitions */
#line 78 "./sparql_lexer.l"

/* NOTE: These headers are NOT included here. They are inserted by fix-flex
 * since otherwise it appears far too late in the generated C
 */

/*
#ifdef HAVE_CONFIG_H
#include <rasqal_config.h>
#endif

#ifdef WIN32
#include <win32_rasqal_config.h>
#endif
*/

#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <ctype.h>
#ifdef HAVE_SETJMP_H
#include <setjmp.h>
#endif

#include <rasqal.h>
#include <rasqal_internal.h>

#include <sparql_parser.h>

#include <sparql_common.h>



static int sparql_skip_c_comment(rasqal_query *rq);

/*
 * Extra checks beyond valid Namespaces in XML 1.1 name
 *
 * SPARQL_NAME_CHECK_VARNAME (token VARNAME)
 *   No '.' allowed.
 *   No '-' allowed.
 *
 * SPARQL_NAME_CHECK_PREFIX (token NCNAME_PREFIX)
 *   No '_' allowed as the first character.
 *   No '.' allowed as the last character.
 *
 * SPARQL_NAME_CHECK_NCNAME (token NCNAME)
 *  [0-9] allowed as the first character
 *   No '.' allowed as the first character.
 *   No '.' allowed as the last character.
 *
*/
typedef enum {
  SPARQL_NAME_CHECK_NO_UL_FIRST  = 1,
  SPARQL_NAME_CHECK_NO_DOT_LAST  = 2,
  SPARQL_NAME_CHECK_NO_DOT_MINUS = 4,
  SPARQL_NAME_CHECK_ALLOW_09_FIRST = 8,

  SPARQL_NAME_CHECK_VARNAME = SPARQL_NAME_CHECK_NO_DOT_MINUS,
  SPARQL_NAME_CHECK_PREFIX  = SPARQL_NAME_CHECK_NO_UL_FIRST | SPARQL_NAME_CHECK_NO_DOT_LAST,
  SPARQL_NAME_CHECK_NCNAME  = SPARQL_NAME_CHECK_NO_DOT_LAST | SPARQL_NAME_CHECK_ALLOW_09_FIRST
} sparql_name_check_flags;


static int rasqal_sparql_name_check(unsigned char *string, size_t length, sparql_name_check_flags check_flags);
static unsigned char *sparql_copy_name(rasqal_query *rq, const unsigned char *text, size_t len, sparql_name_check_flags check_flags);
static raptor_uri* sparql_copy_qname(rasqal_query *rq, const unsigned char *text, size_t len);
static int sparql_copy_string_token(rasqal_query *rq, YYSTYPE* lval, const unsigned char *text, size_t len, int delim);

#ifdef RASQAL_DEBUG
const char * sparql_token_print(rasqal_world* world, int token, YYSTYPE *lval);
#endif

int sparql_lexer_lex (YYSTYPE *sparql_parser_lval, yyscan_t yyscanner);
#define YY_DECL int sparql_lexer_lex (YYSTYPE *sparql_parser_lval, yyscan_t yyscanner)

#ifdef __cplusplus
#define INPUT_FN yyinput
#else
#define INPUT_FN input
#endif

/* Remove the re-fill function since it should never be called */
#define YY_INPUT(buf,result,max_size) { return YY_NULL; }


/* Missing sparql_lexer.c/h prototypes */
int sparql_lexer_get_column(yyscan_t yyscanner);
void sparql_lexer_set_column(int  column_no , yyscan_t yyscanner);

static void sparql_lexer_cleanup(yyscan_t yyscanner);

#ifdef HAVE_SETJMP
static jmp_buf sparql_lexer_fatal_error_longjmp_env;

/* fatal error handler declaration */
#define YY_FATAL_ERROR(msg) do {		\
    sparql_lexer_fatal_error(msg, yyscanner);   \
    longjmp(sparql_lexer_fatal_error_longjmp_env, 1);        \
} while(0)
#else
#define YY_FATAL_ERROR(msg) do {		\
    sparql_lexer_fatal_error(msg, yyscanner);   \
    abort();                                    \
} while(0)
#endif
 
static void sparql_lexer_fatal_error(yyconst char *msg, yyscan_t yyscanner);

/* Fatal error handler that returns EOF instead of abort()/longjmp()
 * so that parser can clean up properly */
#define YY_FATAL_ERROR_EOF(msg) do { \
    sparql_lexer_fatal_error(msg, yyscanner); \
    yyterminate(); \
} while(0)
/*
 * rq23 is http://www.w3.org/2001/sw/DataAccess/rq23/
 * CVS ID 1.420 2005/07/12 15:38:40
 */
/* [85] NCCHAR1p ::= [A-Z] | [a-z] | [#x00C0-#x00D6] | [#x00D8-#x00F6] |
 *   [#x00F8-#x02FF] | [#x0370-#x037D] | [#x037F-#x1FFF] |
 *   [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] |
 *   [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] |
 *   [#x10000-#xEFFFF]
 *
 * This is an XML 1.1 NameStartChar
 *   http://www.w3.org/TR/2004/REC-xml11-20040204/#NT-NameStartChar
 * except
 *   No '_' allowed.
 */
/* [86] NCCHAR1 ::= NCCHAR1p | '_'
 * This is an XML 1.1 NameStartChar
 *   http://www.w3.org/TR/2004/REC-xml11-20040204/#NT-NameStartChar
 */
/* [87]  VARNAME ::= ( NCCHAR1 | _ ) 
 *   ( NCCHAR1 | [0-9] | #x00B7 | [#x0300-#x036F] | [#x203F-#x2040] )*
 *
 * This is an Namespaces in XML 1.1 Name except:
 *   No '.' allowed.
 *   No '-' allowed.
 */
/* [88]  NCCHAR ::= 
 *   NCCHAR1 | '-' | [0-9] | #x00B7 | [#x0300-#x036F] | [#x203F-#x2040]
 *
 * This is XML 1.1 NameChar
 *   http://www.w3.org/TR/2004/REC-xml11-20040204/#NT-NameChar
 * except:
 *   No '.' allowed.
 */
/* [89]  NCNAME_PREFIX ::= NCCHAR1p ((NCCHAR|".")* NCCHAR)?
 *
 * This is an Namespaces in XML 1.1 Name except:
 *   No '_' allowed as the first character.
 *   No '.' allowed as the last character.
 */
/* [90]  NCNAME ::= NCCHAR1 ((NCCHAR|".")* NCCHAR)?
 *
 * This is an Namespaces in XML 1.1 Name except:
 *   No '.' allowed as the last character.
 */
/* SPARQL allows [0-9] after a : in the 
 * W3C Candidate Recommendation 14 June 2007 
 * as an at risk feature that may be removed.
 */
/* rq23 [67] QNAME_NS ::= NCNAME_PREFIX? ':'
 * Inlined into in rule <PREF>{NCNAME_PREFIX}":" below 
 */
/* rq23 [68] QNAME ::= NCNAME_PREFIX? ':' NCNAME? */
/* rq23 [69] BNODE_LABEL (renamed to BNAME) ::= '_:' NCNAME */
/* a blank node name written inside a URI - this is an illegal
 * URI form and for convienence 
 */
/* The initial char conditions are to ensure this doesn't grab < or <= 
 * as operators.  starting with <_: is caught by BNAME2 above.
 **/
#line 1408 "sparql_lexer.c"

#define INITIAL 0
#define ID 1
#define SPID 2
#define PREF 3
#define LITERAL 4
#define LITERAL2 5

#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 YY_NO_UNISTD_H
#include <unistd.h>
#endif
#endif

#ifndef YY_EXTRA_TYPE
#define YY_EXTRA_TYPE void *
#endif

/* Holds the entire state of the reentrant scanner. */
struct yyguts_t
    {

    /* User-defined. Not touched by flex. */
    YY_EXTRA_TYPE yyextra_r;

    /* The rest are the same as the globals declared in the non-reentrant scanner. */
    FILE *yyin_r, *yyout_r;
    size_t yy_buffer_stack_top; /**< index of top of stack. */
    size_t yy_buffer_stack_max; /**< capacity of stack. */
    YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */
    char yy_hold_char;
    int yy_n_chars;
    int yyleng_r;
    char *yy_c_buf_p;
    int yy_init;
    int yy_start;
    int yy_did_buffer_switch_on_eof;
    int yy_start_stack_ptr;
    int yy_start_stack_depth;
    int *yy_start_stack;
    yy_state_type yy_last_accepting_state;
    char* yy_last_accepting_cpos;

    int yylineno_r;
    int yy_flex_debug_r;

    char *yytext_r;
    int yy_more_flag;
    int yy_more_len;

    }; /* end struct yyguts_t */

static int yy_init_globals (yyscan_t yyscanner );

int sparql_lexer_lex_init (yyscan_t* scanner);

int sparql_lexer_lex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);

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

int sparql_lexer_lex_destroy (yyscan_t yyscanner );

int sparql_lexer_get_debug (yyscan_t yyscanner );

void sparql_lexer_set_debug (int debug_flag ,yyscan_t yyscanner );

YY_EXTRA_TYPE sparql_lexer_get_extra (yyscan_t yyscanner );

void sparql_lexer_set_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );

FILE *sparql_lexer_get_in (yyscan_t yyscanner );

void sparql_lexer_set_in  (FILE * in_str ,yyscan_t yyscanner );

FILE *sparql_lexer_get_out (yyscan_t yyscanner );

void sparql_lexer_set_out  (FILE * out_str ,yyscan_t yyscanner );

int sparql_lexer_get_leng (yyscan_t yyscanner );

char *sparql_lexer_get_text (yyscan_t yyscanner );

int sparql_lexer_get_lineno (yyscan_t yyscanner );

void sparql_lexer_set_lineno (int line_number ,yyscan_t yyscanner );

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

#ifndef YY_SKIP_YYWRAP
#ifdef __cplusplus
extern "C" int sparql_lexer_wrap (yyscan_t yyscanner );
#else
extern int sparql_lexer_wrap (yyscan_t yyscanner );
#endif
#endif

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

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

#ifndef YY_NO_INPUT

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

#endif

/* Amount of stuff to slurp up with each read. */
#ifndef YY_READ_BUF_SIZE
#ifdef __ia64__
/* On IA-64, the buffer size is 16k, not 8k */
#define YY_READ_BUF_SIZE 16384
#else
#define YY_READ_BUF_SIZE 8192
#endif /* __ia64__ */
#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 do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
#endif

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

#endif

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

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

/* Report a fatal error. */
#ifndef YY_FATAL_ERROR
#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner)
#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 sparql_lexer_lex (yyscan_t yyscanner);

#define YY_DECL int sparql_lexer_lex (yyscan_t yyscanner)
#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;
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;

#line 290 "./sparql_lexer.l"

  /* rules */



  int c;
  rasqal_query *rq;
  rasqal_sparql_query_language *rqe;

  rq = (rasqal_query*)yyextra;
  rqe = (rasqal_sparql_query_language*)rq->context;

#ifdef HAVE_SETJMP
  if(setjmp(sparql_lexer_fatal_error_longjmp_env))
    return 1;
#endif
  


#line 1659 "sparql_lexer.c"

	if ( !yyg->yy_init )
		{
		yyg->yy_init = 1;

#ifdef YY_USER_INIT
		YY_USER_INIT;
#endif

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

		if ( ! yyin )
			yyin = stdin;

		if ( ! yyout )
			yyout = stdout;

		if ( ! YY_CURRENT_BUFFER ) {
			sparql_lexer_ensure_buffer_stack (yyscanner);
			YY_CURRENT_BUFFER_LVALUE =
				sparql_lexer__create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
		}

		sparql_lexer__load_buffer_state(yyscanner );
		}

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

		/* Support of yytext. */
		*yy_cp = yyg->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 = yyg->yy_start;
yy_match:
		do
			{
			register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
			if ( yy_accept[yy_current_state] )
				{
				yyg->yy_last_accepting_state = yy_current_state;
				yyg->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 >= 456 )
					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 != 455 );
		yy_cp = yyg->yy_last_accepting_cpos;
		yy_current_state = yyg->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 = yyg->yy_hold_char;
			yy_cp = yyg->yy_last_accepting_cpos;
			yy_current_state = yyg->yy_last_accepting_state;
			goto yy_find_action;

case 1:
/* rule 1 can match eol */
YY_RULE_SETUP
#line 309 "./sparql_lexer.l"
{ /* C++ comment */
        rqe->lineno++;
}
	YY_BREAK
case 2:
YY_RULE_SETUP
#line 313 "./sparql_lexer.l"
{ int lines = sparql_skip_c_comment(rq);
          if(lines < 0)
            yyterminate();
          rqe->lineno += lines;
        }
	YY_BREAK
case 3:
/* rule 3 can match eol */
YY_RULE_SETUP
#line 319 "./sparql_lexer.l"
{ rqe->lineno++; }
	YY_BREAK
case 4:
YY_RULE_SETUP
#line 321 "./sparql_lexer.l"
{ /* eat up other whitespace */
	;
}
	YY_BREAK
case 5:
YY_RULE_SETUP
#line 325 "./sparql_lexer.l"
{ return SELECT; }
	YY_BREAK
case 6:
YY_RULE_SETUP
#line 326 "./sparql_lexer.l"
{ return FROM; }
	YY_BREAK
case 7:
YY_RULE_SETUP
#line 327 "./sparql_lexer.l"
{ return WHERE; }
	YY_BREAK
case 8:
YY_RULE_SETUP
#line 328 "./sparql_lexer.l"
{ BEGIN(PREF);
		return PREFIX; }
	YY_BREAK
case 9:
YY_RULE_SETUP
#line 330 "./sparql_lexer.l"
{ return DESCRIBE; }
	YY_BREAK
case 10:
YY_RULE_SETUP
#line 331 "./sparql_lexer.l"
{ return CONSTRUCT; }
	YY_BREAK
case 11:
YY_RULE_SETUP
#line 332 "./sparql_lexer.l"
{ return ASK; }
	YY_BREAK
case 12:
YY_RULE_SETUP
#line 333 "./sparql_lexer.l"
{ return DISTINCT; }
	YY_BREAK
case 13:
YY_RULE_SETUP
#line 334 "./sparql_lexer.l"
{ return REDUCED; }
	YY_BREAK
case 14:
YY_RULE_SETUP
#line 335 "./sparql_lexer.l"
{ return LIMIT; }
	YY_BREAK
case 15:
YY_RULE_SETUP
#line 336 "./sparql_lexer.l"
{ return UNION; }
	YY_BREAK
case 16:
YY_RULE_SETUP
#line 337 "./sparql_lexer.l"
{ return OPTIONAL; }
	YY_BREAK
case 17:
YY_RULE_SETUP
#line 338 "./sparql_lexer.l"
{ return BASE; }
	YY_BREAK
case 18:
YY_RULE_SETUP
#line 339 "./sparql_lexer.l"
{ return BOUND; }
	YY_BREAK
case 19:
YY_RULE_SETUP
#line 340 "./sparql_lexer.l"
{ return STR; }
	YY_BREAK
case 20:
YY_RULE_SETUP
#line 341 "./sparql_lexer.l"
{ return LANG; }
	YY_BREAK
case 21:
YY_RULE_SETUP
#line 342 "./sparql_lexer.l"
{ return DATATYPE; }
	YY_BREAK
case 22:
YY_RULE_SETUP
#line 343 "./sparql_lexer.l"
{ return ISURI; } /* isURI and isIRI */
	YY_BREAK
case 23:
YY_RULE_SETUP
#line 344 "./sparql_lexer.l"
{ return ISBLANK; }
	YY_BREAK
case 24:
YY_RULE_SETUP
#line 345 "./sparql_lexer.l"
{ return ISLITERAL; }
	YY_BREAK
case 25:
YY_RULE_SETUP
#line 346 "./sparql_lexer.l"
{ return GRAPH; }
	YY_BREAK
case 26:
YY_RULE_SETUP
#line 347 "./sparql_lexer.l"
{ return NAMED; }
	YY_BREAK
case 27:
YY_RULE_SETUP
#line 348 "./sparql_lexer.l"
{ return FILTER; }
	YY_BREAK
case 28:
YY_RULE_SETUP
#line 349 "./sparql_lexer.l"
{ return OFFSET; }
	YY_BREAK
case 29:
YY_RULE_SETUP
#line 350 "./sparql_lexer.l"
{ return ORDER; }
	YY_BREAK
case 30:
YY_RULE_SETUP
#line 351 "./sparql_lexer.l"
{ return BY; }
	YY_BREAK
case 31:
YY_RULE_SETUP
#line 352 "./sparql_lexer.l"
{ return REGEX; }
	YY_BREAK
case 32:
YY_RULE_SETUP
#line 353 "./sparql_lexer.l"
{ return ASC; }
	YY_BREAK
case 33:
YY_RULE_SETUP
#line 354 "./sparql_lexer.l"
{ return DESC; } 
	YY_BREAK
case 34:
YY_RULE_SETUP
#line 355 "./sparql_lexer.l"
{ return LANGMATCHES; } 
	YY_BREAK
case 35:
YY_RULE_SETUP
#line 356 "./sparql_lexer.l"
{ return EXPLAIN; }
	YY_BREAK
case 36:
YY_RULE_SETUP
#line 357 "./sparql_lexer.l"
{ return GROUP; }
	YY_BREAK
case 37:
YY_RULE_SETUP
#line 358 "./sparql_lexer.l"
{ return COUNT; }
	YY_BREAK
case 38:
YY_RULE_SETUP
#line 359 "./sparql_lexer.l"
{ return SUM; }
	YY_BREAK
case 39:
YY_RULE_SETUP
#line 360 "./sparql_lexer.l"
{ return AVG; }
	YY_BREAK
case 40:
YY_RULE_SETUP
#line 361 "./sparql_lexer.l"
{ return MIN; }
	YY_BREAK
case 41:
YY_RULE_SETUP
#line 362 "./sparql_lexer.l"
{ return MAX; }
	YY_BREAK
case 42:
YY_RULE_SETUP
#line 363 "./sparql_lexer.l"
{ BEGIN(SPID); return AS; }
	YY_BREAK
case 43:
YY_RULE_SETUP
#line 364 "./sparql_lexer.l"
{ return DELETE; }
	YY_BREAK
case 44:
YY_RULE_SETUP
#line 365 "./sparql_lexer.l"
{ return INSERT; }
	YY_BREAK
case 45:
YY_RULE_SETUP
#line 366 "./sparql_lexer.l"
{ return SAMETERM; }
	YY_BREAK
case 46:
YY_RULE_SETUP
#line 367 "./sparql_lexer.l"
{ return LET; }
	YY_BREAK
case 47:
YY_RULE_SETUP
#line 368 "./sparql_lexer.l"
{ return COALESCE; }
	YY_BREAK
case 48:
YY_RULE_SETUP
#line 369 "./sparql_lexer.l"
{ return WITH; }
	YY_BREAK
case 49:
YY_RULE_SETUP
#line 370 "./sparql_lexer.l"
{ return CLEAR; }
	YY_BREAK
case 50:
YY_RULE_SETUP
#line 371 "./sparql_lexer.l"
{ return CREATE; }
	YY_BREAK
case 51:
YY_RULE_SETUP
#line 372 "./sparql_lexer.l"
{ return SILENT; }
	YY_BREAK
case 52:
YY_RULE_SETUP
#line 373 "./sparql_lexer.l"
{ return DATA; }
	YY_BREAK
case 53:
YY_RULE_SETUP
#line 374 "./sparql_lexer.l"
{ return DROP; }
	YY_BREAK
case 54:
YY_RULE_SETUP
#line 375 "./sparql_lexer.l"
{ return LOAD; }
	YY_BREAK
case 55:
YY_RULE_SETUP
#line 376 "./sparql_lexer.l"
{ return INTO; }
	YY_BREAK
case 56:
YY_RULE_SETUP
#line 378 "./sparql_lexer.l"
{ return A; }
	YY_BREAK
case 57:
YY_RULE_SETUP
#line 380 "./sparql_lexer.l"
{ return ','; } 
	YY_BREAK
case 58:
YY_RULE_SETUP
#line 381 "./sparql_lexer.l"
{ return '('; } 
	YY_BREAK
case 59:
YY_RULE_SETUP
#line 382 "./sparql_lexer.l"
{ return ')'; } 
	YY_BREAK
case 60:
YY_RULE_SETUP
#line 383 "./sparql_lexer.l"
{ return '['; }
	YY_BREAK
case 61:
YY_RULE_SETUP
#line 384 "./sparql_lexer.l"
{ return ']'; }
	YY_BREAK
case 62:
YY_RULE_SETUP
#line 385 "./sparql_lexer.l"
{ BEGIN(ID); return '?'; }
	YY_BREAK
case 63:
YY_RULE_SETUP
#line 386 "./sparql_lexer.l"
{ BEGIN(ID); return '$'; }
	YY_BREAK
case 64:
YY_RULE_SETUP
#line 387 "./sparql_lexer.l"
{ return '{'; } 
	YY_BREAK
case 65:
YY_RULE_SETUP
#line 388 "./sparql_lexer.l"
{ return '}'; } 
	YY_BREAK
case 66:
YY_RULE_SETUP
#line 389 "./sparql_lexer.l"
{ return '.'; } 
	YY_BREAK
case 67:
YY_RULE_SETUP
#line 390 "./sparql_lexer.l"
{ return ';'; } 
	YY_BREAK
case 68:
YY_RULE_SETUP
#line 392 "./sparql_lexer.l"
{ return SC_OR; }
	YY_BREAK
case 69:
YY_RULE_SETUP
#line 393 "./sparql_lexer.l"
{ return SC_AND; }
	YY_BREAK
case 70:
YY_RULE_SETUP
#line 395 "./sparql_lexer.l"
{ return EQ; }
	YY_BREAK
case 71:
YY_RULE_SETUP
#line 396 "./sparql_lexer.l"
{ return NEQ; }
	YY_BREAK
case 72:
/* rule 72 can match eol */
*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */
yyg->yy_c_buf_p = yy_cp = yy_bp + 1;
YY_DO_BEFORE_ACTION; /* set up yytext again */
YY_RULE_SETUP
#line 397 "./sparql_lexer.l"
{ return LT; }
	YY_BREAK
case 73:
YY_RULE_SETUP
#line 398 "./sparql_lexer.l"
{ return GT; }
	YY_BREAK
case 74:
YY_RULE_SETUP
#line 399 "./sparql_lexer.l"
{ return LE; }
	YY_BREAK
case 75:
YY_RULE_SETUP
#line 400 "./sparql_lexer.l"
{ return GE; }
	YY_BREAK
case 76:
YY_RULE_SETUP
#line 402 "./sparql_lexer.l"
{ return '*'; }
	YY_BREAK
case 77:
YY_RULE_SETUP
#line 403 "./sparql_lexer.l"
{ return '/'; }
	YY_BREAK
case 78:
YY_RULE_SETUP
#line 404 "./sparql_lexer.l"
{ return '!'; }
	YY_BREAK
case 79:
YY_RULE_SETUP
#line 406 "./sparql_lexer.l"
{ return ASSIGN; }
	YY_BREAK
case 80:
YY_RULE_SETUP
#line 408 "./sparql_lexer.l"
{ c = *yytext;
                  sparql_parser_lval->literal = rasqal_new_typed_literal(rq->world, RASQAL_LITERAL_INTEGER, (const unsigned char*)yytext);
                  if(!sparql_parser_lval->literal)
                    YY_FATAL_ERROR_EOF("rasqal_new_typed_literal failed");
 		  return (c=='+' ? INTEGER_POSITIVE_LITERAL : (c == '-' ? INTEGER_NEGATIVE_LITERAL : INTEGER_LITERAL));
}
	YY_BREAK
case 81:
YY_RULE_SETUP
#line 415 "./sparql_lexer.l"
{ 
                        c = *yytext;
                        
                        if(!rasqal_xsd_datatype_check(RASQAL_LITERAL_DECIMAL, (const unsigned char*)yytext, 0)) {
                          sparql_syntax_error(rq, "SPARQL syntax error - Illegal decimal constant %s", yytext);
                          yyterminate();
                        }
                        sparql_parser_lval->literal = rasqal_new_decimal_literal(rq->world, (const unsigned char*)yytext);
                        if(!sparql_parser_lval->literal)
                          YY_FATAL_ERROR_EOF("rasqal_new_decimal_literal failed");
                        return (c=='+' ? DECIMAL_POSITIVE_LITERAL : (c == '-' ? DECIMAL_NEGATIVE_LITERAL : DECIMAL_LITERAL));
}
	YY_BREAK
case 82:
YY_RULE_SETUP
#line 428 "./sparql_lexer.l"
{
                        c = *yytext;
                        if(!rasqal_xsd_datatype_check(RASQAL_LITERAL_DOUBLE, (const unsigned char*)yytext, 0)) {
                          sparql_syntax_error(rq, "SPARQL syntax error - Illegal double constant %s", yytext);
                          yyterminate();
                        }
                        sparql_parser_lval->literal = rasqal_new_typed_literal(rq->world, RASQAL_LITERAL_DOUBLE, (const unsigned char*)yytext);
                        if(!sparql_parser_lval->literal)
                          YY_FATAL_ERROR_EOF("rasqal_new_typed_literal failed");
                        return (c=='+' ? DOUBLE_POSITIVE_LITERAL : (c == '-' ? DOUBLE_NEGATIVE_LITERAL : DOUBLE_LITERAL));
}
	YY_BREAK
case 83:
YY_RULE_SETUP
#line 440 "./sparql_lexer.l"
{ return '+'; }
	YY_BREAK
case 84:
YY_RULE_SETUP
#line 441 "./sparql_lexer.l"
{ return '-'; }
	YY_BREAK
case 85:
/* rule 85 can match eol */
YY_RULE_SETUP
#line 443 "./sparql_lexer.l"
{ /*' */
                        if(sparql_copy_string_token(rq, sparql_parser_lval,
                           (const unsigned char*)yytext+1, yyleng-1, '\''))
                          YY_FATAL_ERROR_EOF("sparql_copy_string_token failed");
                        return STRING_LITERAL; }
	YY_BREAK
case 86:
/* rule 86 can match eol */
YY_RULE_SETUP
#line 449 "./sparql_lexer.l"
{ /* " */
                        if(sparql_copy_string_token(rq, sparql_parser_lval,
                           (const unsigned char*)yytext+1, yyleng-1, '"'))
                          YY_FATAL_ERROR_EOF("sparql_copy_string_token failed");
                        return STRING_LITERAL; }
	YY_BREAK
case 87:
YY_RULE_SETUP
#line 455 "./sparql_lexer.l"
{ BEGIN(LITERAL); }
	YY_BREAK
case 88:
/* rule 88 can match eol */
YY_RULE_SETUP
#line 457 "./sparql_lexer.l"
{ if(sparql_copy_string_token(rq, sparql_parser_lval, 
                            (unsigned char*)yytext, yyleng, '"')) /* ' */
                            YY_FATAL_ERROR_EOF("sparql_copy_string_token failed");
                          BEGIN(INITIAL);
                          return STRING_LITERAL; }
	YY_BREAK
case 89:
/* rule 89 can match eol */
YY_RULE_SETUP
#line 463 "./sparql_lexer.l"
{ BEGIN(INITIAL);
		  if(!*yytext)
                    return EOF;

                  sparql_syntax_error(rq, "syntax error at %c - \"\"\"string was not terminated", *yytext);
                  yyterminate();  }
	YY_BREAK
case 90:
YY_RULE_SETUP
#line 471 "./sparql_lexer.l"
{ BEGIN(LITERAL2); }
	YY_BREAK
case 91:
/* rule 91 can match eol */
YY_RULE_SETUP
#line 473 "./sparql_lexer.l"
{ if(sparql_copy_string_token(rq, sparql_parser_lval, 
                            (unsigned char*)yytext, yyleng, '\''))
                            YY_FATAL_ERROR_EOF("sparql_copy_string_token failed");
                          BEGIN(INITIAL);
                          return STRING_LITERAL; }
	YY_BREAK
case 92:
/* rule 92 can match eol */
YY_RULE_SETUP
#line 479 "./sparql_lexer.l"
{ BEGIN(INITIAL);
		  if(!*yytext)
                    return EOF;

                  sparql_syntax_error(rq, "syntax error at %c - '''string was not terminated", *yytext);
                  yyterminate();  }
	YY_BREAK
case 93:
YY_RULE_SETUP
#line 487 "./sparql_lexer.l"
{ sparql_parser_lval->literal = rasqal_new_boolean_literal(rq->world, 1);
                    if(!sparql_parser_lval->literal)
                      YY_FATAL_ERROR_EOF("rasqal_new_boolean_literal failed");
                  return BOOLEAN_LITERAL; }
	YY_BREAK
case 94:
YY_RULE_SETUP
#line 492 "./sparql_lexer.l"
{ sparql_parser_lval->literal = rasqal_new_boolean_literal(rq->world, 0);
                        if(!sparql_parser_lval->literal)
                          YY_FATAL_ERROR_EOF("rasqal_new_boolean_literal failed");
                  return BOOLEAN_LITERAL; }
	YY_BREAK
case 95:
YY_RULE_SETUP
#line 497 "./sparql_lexer.l"
{ sparql_parser_lval->name = sparql_copy_name(rq, (const unsigned char*)yytext, yyleng, SPARQL_NAME_CHECK_VARNAME);
		  if(!sparql_parser_lval->name)
                    YY_FATAL_ERROR_EOF("sparql_copy_name failed");
                          BEGIN(INITIAL);
                          return IDENTIFIER; }
	YY_BREAK
case 96:
/* rule 96 can match eol */
YY_RULE_SETUP
#line 502 "./sparql_lexer.l"
{	BEGIN(INITIAL);
		sparql_syntax_error(rq, "SPARQL syntax error - missing variable name after ?");
                yyterminate();
}
	YY_BREAK
case 97:
YY_RULE_SETUP
#line 507 "./sparql_lexer.l"
{ /* eat up leading whitespace */
	;
}
	YY_BREAK
case 98:
YY_RULE_SETUP
#line 510 "./sparql_lexer.l"
{ sparql_parser_lval->name = sparql_copy_name(rq, (const unsigned char*)yytext, yyleng, SPARQL_NAME_CHECK_VARNAME);
		  if(!sparql_parser_lval->name)
                    YY_FATAL_ERROR_EOF("sparql_copy_name failed");
                          BEGIN(INITIAL);
                          return IDENTIFIER; }
	YY_BREAK
case 99:
/* rule 99 can match eol */
YY_RULE_SETUP
#line 516 "./sparql_lexer.l"
{	BEGIN(INITIAL);
		sparql_syntax_error(rq, "SPARQL syntax error - missing variable name after ?");
                yyterminate();
}
	YY_BREAK
case 100:
YY_RULE_SETUP
#line 521 "./sparql_lexer.l"
{ /* eat up leading whitespace */ }
	YY_BREAK
case 101:
YY_RULE_SETUP
#line 522 "./sparql_lexer.l"
{ BEGIN(INITIAL);
		  	  sparql_parser_lval->name = sparql_copy_name(rq, (const unsigned char*)yytext, yyleng-1, SPARQL_NAME_CHECK_PREFIX);
			  if(!sparql_parser_lval->name)
			    YY_FATAL_ERROR_EOF("sparql_copy_name failed");
                          return IDENTIFIER; }
	YY_BREAK
case 102:
YY_RULE_SETUP
#line 527 "./sparql_lexer.l"
{ BEGIN(INITIAL);
		  sparql_parser_lval->name = NULL;
                  return IDENTIFIER; }
	YY_BREAK
case 103:
/* rule 103 can match eol */
YY_RULE_SETUP
#line 531 "./sparql_lexer.l"
{ BEGIN(INITIAL);
		  if(!*yytext)
                    return EOF;

                  sparql_syntax_error(rq, "SPARQL syntax error at '%c'", *yytext);
                  yyterminate();
}
	YY_BREAK
case 104:
YY_RULE_SETUP
#line 539 "./sparql_lexer.l"
{
		int have_brace = (yytext[yyleng-1]=='(');
		if(have_brace)
			yyleng--;
		sparql_parser_lval->uri = sparql_copy_qname(rq, (const unsigned char*)yytext, yyleng);
		if(!sparql_parser_lval->uri)
		  YY_FATAL_ERROR_EOF("sparql_copy_qname failed");
 		return have_brace ? URI_LITERAL_BRACE : URI_LITERAL;
}
	YY_BREAK
case 105:
YY_RULE_SETUP
#line 549 "./sparql_lexer.l"
{	sparql_parser_lval->name = sparql_copy_name(rq, (unsigned char*)yytext+2, yyleng-2, SPARQL_NAME_CHECK_NCNAME);
		return BLANK_LITERAL;
}
	YY_BREAK
case 106:
YY_RULE_SETUP
#line 553 "./sparql_lexer.l"
{	sparql_parser_lval->name = sparql_copy_name(rq, (unsigned char*)yytext+3, yyleng-4, SPARQL_NAME_CHECK_NCNAME);
		return BLANK_LITERAL;
}
	YY_BREAK
case 107:
/* rule 107 can match eol */
YY_RULE_SETUP
#line 557 "./sparql_lexer.l"
{ 
		int have_brace = (yytext[yyleng-1]=='(');
		if(have_brace)
			yyleng--;
		if(yyleng == 2) 
                  sparql_parser_lval->uri = raptor_uri_copy(rq->base_uri);
                else {
                  unsigned char* uri_string;

                  yytext[yyleng-1] = '\0';
                  uri_string = rasqal_escaped_name_to_utf8_string((unsigned char*)yytext+1,
                                                                  yyleng-1,
                                                                  NULL,
                                                                  sparql_syntax_error, rq);
                  if(!uri_string)
                    YY_FATAL_ERROR_EOF("rasqal_escaped_name_to_utf8_string failed");

#ifdef RAPTOR_V2_AVAILABLE
                  sparql_parser_lval->uri = raptor_new_uri_relative_to_base(rq->world->raptor_world_ptr, rq->base_uri, uri_string);
#else
                  sparql_parser_lval->uri = raptor_new_uri_relative_to_base(rq->base_uri, uri_string);
#endif
                  RASQAL_FREE(cstring, uri_string);
                  if(!sparql_parser_lval->uri)
                    YY_FATAL_ERROR_EOF("raptor_new_uri_relative_to_base failed");
                 }
                 return have_brace ? URI_LITERAL_BRACE : URI_LITERAL; }
	YY_BREAK
case 108:
/* rule 108 can match eol */
YY_RULE_SETUP
#line 585 "./sparql_lexer.l"
{ /* # comment */
        	rqe->lineno++;
                }
	YY_BREAK
case 109:
YY_RULE_SETUP
#line 589 "./sparql_lexer.l"
{ if(!*yytext)
                    return EOF;

                  sparql_syntax_error(rq, "SPARQL syntax error at '%c'", *yytext);
                  yyterminate();
		}
	YY_BREAK
case 110:
YY_RULE_SETUP
#line 596 "./sparql_lexer.l"
YY_FATAL_ERROR( "flex scanner jammed" );
	YY_BREAK
#line 2445 "sparql_lexer.c"
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(ID):
case YY_STATE_EOF(SPID):
case YY_STATE_EOF(PREF):
case YY_STATE_EOF(LITERAL):
case YY_STATE_EOF(LITERAL2):
	yyterminate();

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

		/* Undo the effects of YY_DO_BEFORE_ACTION. */
		*yy_cp = yyg->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
			 * sparql_lexer_lex().  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.
			 */
			yyg->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 ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
			{ /* This was really a NUL. */
			yy_state_type yy_next_state;

			yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text;

			yy_current_state = yy_get_previous_state( yyscanner );

			/* 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 , yyscanner);

			yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;

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

			else
				{
				yy_cp = yyg->yy_last_accepting_cpos;
				yy_current_state = yyg->yy_last_accepting_state;
				goto yy_find_action;
				}
			}

		else switch ( yy_get_next_buffer( yyscanner ) )
			{
			case EOB_ACT_END_OF_FILE:
				{
				yyg->yy_did_buffer_switch_on_eof = 0;

				if ( sparql_lexer_wrap(yyscanner ) )
					{
					/* 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.
					 */
					yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ;

					yy_act = YY_STATE_EOF(YY_START);
					goto do_action;
					}

				else
					{
					if ( ! yyg->yy_did_buffer_switch_on_eof )
						YY_NEW_FILE;
					}
				break;
				}

			case EOB_ACT_CONTINUE_SCAN:
				yyg->yy_c_buf_p =
					yyg->yytext_ptr + yy_amount_of_matched_text;

				yy_current_state = yy_get_previous_state( yyscanner );

				yy_cp = yyg->yy_c_buf_p;
				yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
				goto yy_match;

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

				yy_current_state = yy_get_previous_state( yyscanner );

				yy_cp = yyg->yy_c_buf_p;
				yy_bp = yyg->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 sparql_lexer_lex */

/* 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 (yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
	register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
	register char *source = yyg->yytext_ptr;
	register int number_to_move, i;
	int ret_val;

	if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->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 ( yyg->yy_c_buf_p - yyg->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) (yyg->yy_c_buf_p - yyg->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 = yyg->yy_n_chars = 0;

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

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

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

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

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

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

				b->yy_ch_buf = (char *)
					/* Include room in for 2 EOB chars. */
					sparql_lexer_realloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner );
				}
			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" );

			yyg->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]),
			yyg->yy_n_chars, (size_t) num_to_read );

		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
		}

	if ( yyg->yy_n_chars == 0 )
		{
		if ( number_to_move == YY_MORE_ADJ )
			{
			ret_val = EOB_ACT_END_OF_FILE;
			sparql_lexer_restart(yyin  ,yyscanner);
			}

		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) (yyg->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 = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
		YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) sparql_lexer_realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner );
		if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
			YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
	}

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

	yyg->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 (yyscan_t yyscanner)
{
	register yy_state_type yy_current_state;
	register char *yy_cp;
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;

	yy_current_state = yyg->yy_start;

	for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->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] )
			{
			yyg->yy_last_accepting_state = yy_current_state;
			yyg->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 >= 456 )
				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 , yyscan_t yyscanner)
{
	register int yy_is_jam;
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */
	register char *yy_cp = yyg->yy_c_buf_p;

	register YY_CHAR yy_c = 1;
	if ( yy_accept[yy_current_state] )
		{
		yyg->yy_last_accepting_state = yy_current_state;
		yyg->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 >= 456 )
			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 == 455);

	return yy_is_jam ? 0 : yy_current_state;
}

#ifndef YY_NO_INPUT
#ifdef __cplusplus
    static int yyinput (yyscan_t yyscanner)
#else
    static int input  (yyscan_t yyscanner)
#endif

{
	int c;
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;

	*yyg->yy_c_buf_p = yyg->yy_hold_char;

	if ( *yyg->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 ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
			/* This was really a NUL. */
			*yyg->yy_c_buf_p = '\0';

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

			switch ( yy_get_next_buffer( yyscanner ) )
				{
				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. */
					sparql_lexer_restart(yyin ,yyscanner);

					/*FALLTHROUGH*/

				case EOB_ACT_END_OF_FILE:
					{
					if ( sparql_lexer_wrap(yyscanner ) )
						return EOF;

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

				case EOB_ACT_CONTINUE_SCAN:
					yyg->yy_c_buf_p = yyg->yytext_ptr + offset;
					break;
				}
			}
		}

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

	return c;
}
#endif	/* ifndef YY_NO_INPUT */

/** Immediately switch to a different input stream.
 * @param input_file A readable stream.
 * @param yyscanner The scanner object.
 * @note This function does not reset the start condition to @c INITIAL .
 */
    void sparql_lexer_restart  (FILE * input_file , yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;

	if ( ! YY_CURRENT_BUFFER ){
        sparql_lexer_ensure_buffer_stack (yyscanner);
		YY_CURRENT_BUFFER_LVALUE =
            sparql_lexer__create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
	}

	sparql_lexer__init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner);
	sparql_lexer__load_buffer_state(yyscanner );
}

/** Switch to a different input buffer.
 * @param new_buffer The new input buffer.
 * @param yyscanner The scanner object.
 */
    void sparql_lexer__switch_to_buffer  (YY_BUFFER_STATE  new_buffer , yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;

	/* TODO. We should be able to replace this entire function body
	 * with
	 *		sparql_lexer_pop_buffer_state();
	 *		sparql_lexer_push_buffer_state(new_buffer);
     */
	sparql_lexer_ensure_buffer_stack (yyscanner);
	if ( YY_CURRENT_BUFFER == new_buffer )
		return;

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

	YY_CURRENT_BUFFER_LVALUE = new_buffer;
	sparql_lexer__load_buffer_state(yyscanner );

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

static void sparql_lexer__load_buffer_state  (yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
	yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
	yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
	yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
	yyg->yy_hold_char = *yyg->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.
 * @param yyscanner The scanner object.
 * @return the allocated buffer state.
 */
    YY_BUFFER_STATE sparql_lexer__create_buffer  (FILE * file, int  size , yyscan_t yyscanner)
{
	YY_BUFFER_STATE b;
    
	b = (YY_BUFFER_STATE) sparql_lexer_alloc(sizeof( struct yy_buffer_state ) ,yyscanner );
	if ( ! b )
		YY_FATAL_ERROR( "out of dynamic memory in sparql_lexer__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 *) sparql_lexer_alloc(b->yy_buf_size + 2 ,yyscanner );
	if ( ! b->yy_ch_buf )
		YY_FATAL_ERROR( "out of dynamic memory in sparql_lexer__create_buffer()" );

	b->yy_is_our_buffer = 1;

	sparql_lexer__init_buffer(b,file ,yyscanner);

	return b;
}

/** Destroy the buffer.
 * @param b a buffer created with sparql_lexer__create_buffer()
 * @param yyscanner The scanner object.
 */
    void sparql_lexer__delete_buffer (YY_BUFFER_STATE  b , yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;

	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 )
		sparql_lexer_free((void *) b->yy_ch_buf ,yyscanner );

	sparql_lexer_free((void *) b ,yyscanner );
}

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

{
	int oerrno = errno;
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;

	sparql_lexer__flush_buffer(b ,yyscanner);

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

    /* If b is the current buffer, then sparql_lexer__init_buffer was _probably_
     * called from sparql_lexer_restart() 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.
 * @param yyscanner The scanner object.
 */
    void sparql_lexer__flush_buffer (YY_BUFFER_STATE  b , yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
	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 )
		sparql_lexer__load_buffer_state(yyscanner );
}

/** 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.
 *  @param yyscanner The scanner object.
 */
void sparql_lexer_push_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
	if (new_buffer == NULL)
		return;

	sparql_lexer_ensure_buffer_stack(yyscanner);

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

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

	/* copied from sparql_lexer__switch_to_buffer. */
	sparql_lexer__load_buffer_state(yyscanner );
	yyg->yy_did_buffer_switch_on_eof = 1;
}

/** Removes and deletes the top of the stack, if present.
 *  The next element becomes the new top.
 *  @param yyscanner The scanner object.
 */
void sparql_lexer_pop_buffer_state (yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
	if (!YY_CURRENT_BUFFER)
		return;

	sparql_lexer__delete_buffer(YY_CURRENT_BUFFER ,yyscanner);
	YY_CURRENT_BUFFER_LVALUE = NULL;
	if (yyg->yy_buffer_stack_top > 0)
		--yyg->yy_buffer_stack_top;

	if (YY_CURRENT_BUFFER) {
		sparql_lexer__load_buffer_state(yyscanner );
		yyg->yy_did_buffer_switch_on_eof = 1;
	}
}

/* Allocates the stack if it does not exist.
 *  Guarantees space for at least one push.
 */
static void sparql_lexer_ensure_buffer_stack (yyscan_t yyscanner)
{
	int num_to_alloc;
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;

	if (!yyg->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;
		yyg->yy_buffer_stack = (struct yy_buffer_state**)sparql_lexer_alloc
								(num_to_alloc * sizeof(struct yy_buffer_state*)
								, yyscanner);
		if ( ! yyg->yy_buffer_stack )
			YY_FATAL_ERROR( "out of dynamic memory in sparql_lexer_ensure_buffer_stack()" );
								  
		memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
				
		yyg->yy_buffer_stack_max = num_to_alloc;
		yyg->yy_buffer_stack_top = 0;
		return;
	}

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

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

		num_to_alloc = yyg->yy_buffer_stack_max + grow_size;
		yyg->yy_buffer_stack = (struct yy_buffer_state**)sparql_lexer_realloc
								(yyg->yy_buffer_stack,
								num_to_alloc * sizeof(struct yy_buffer_state*)
								, yyscanner);
		if ( ! yyg->yy_buffer_stack )
			YY_FATAL_ERROR( "out of dynamic memory in sparql_lexer_ensure_buffer_stack()" );

		/* zero only the new slots.*/
		memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
		yyg->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
 * @param yyscanner The scanner object.
 * @return the newly allocated buffer state object. 
 */
YY_BUFFER_STATE sparql_lexer__scan_buffer  (char * base, yy_size_t  size , yyscan_t yyscanner)
{
	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) sparql_lexer_alloc(sizeof( struct yy_buffer_state ) ,yyscanner );
	if ( ! b )
		YY_FATAL_ERROR( "out of dynamic memory in sparql_lexer__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;

	sparql_lexer__switch_to_buffer(b ,yyscanner );

	return b;
}

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

/** Setup the input buffer state to scan the given bytes. The next call to sparql_lexer_lex() will
 * scan from a @e copy of @a bytes.
 * @param yybytes the byte buffer to scan
 * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
 * @param yyscanner The scanner object.
 * @return the newly allocated buffer state object.
 */
YY_BUFFER_STATE sparql_lexer__scan_bytes  (yyconst char * yybytes, int  _yybytes_len , yyscan_t yyscanner)
{
	YY_BUFFER_STATE b;
	char *buf;
	yy_size_t n;
	int i;
    
	/* Get memory for full buffer, including space for trailing EOB's. */
	n = _yybytes_len + 2;
	buf = (char *) sparql_lexer_alloc(n ,yyscanner );
	if ( ! buf )
		YY_FATAL_ERROR( "out of dynamic memory in sparql_lexer__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 = sparql_lexer__scan_buffer(buf,n ,yyscanner);
	if ( ! b )
		YY_FATAL_ERROR( "bad buffer in sparql_lexer__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;
}

#ifndef YY_EXIT_FAILURE
#define YY_EXIT_FAILURE 2
#endif


/* 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] = yyg->yy_hold_char; \
		yyg->yy_c_buf_p = yytext + yyless_macro_arg; \
		yyg->yy_hold_char = *yyg->yy_c_buf_p; \
		*yyg->yy_c_buf_p = '\0'; \
		yyleng = yyless_macro_arg; \
		} \
	while ( 0 )

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

/** Get the user-defined data for this scanner.
 * @param yyscanner The scanner object.
 */
YY_EXTRA_TYPE sparql_lexer_get_extra  (yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    return yyextra;
}

/** Get the current line number.
 * @param yyscanner The scanner object.
 */
int sparql_lexer_get_lineno  (yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    
        if (! YY_CURRENT_BUFFER)
            return 0;
    
    return yylineno;
}

/** Get the current column number.
 * @param yyscanner The scanner object.
 */
int sparql_lexer_get_column  (yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    
        if (! YY_CURRENT_BUFFER)
            return 0;
    
    return yycolumn;
}

/** Get the input stream.
 * @param yyscanner The scanner object.
 */
FILE *sparql_lexer_get_in  (yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    return yyin;
}

/** Get the output stream.
 * @param yyscanner The scanner object.
 */
FILE *sparql_lexer_get_out  (yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    return yyout;
}

/** Get the length of the current token.
 * @param yyscanner The scanner object.
 */
int sparql_lexer_get_leng  (yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    return yyleng;
}

/** Get the current token.
 * @param yyscanner The scanner object.
 */

char *sparql_lexer_get_text  (yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    return yytext;
}

/** Set the user-defined data. This data is never touched by the scanner.
 * @param user_defined The data to be associated with this scanner.
 * @param yyscanner The scanner object.
 */
void sparql_lexer_set_extra (YY_EXTRA_TYPE  user_defined , yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    yyextra = user_defined ;
}

/** Set the current line number.
 * @param line_number
 * @param yyscanner The scanner object.
 */
void sparql_lexer_set_lineno (int  line_number , yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;

        /* lineno is only valid if an input buffer exists. */
        if (! YY_CURRENT_BUFFER )
           YY_FATAL_ERROR("sparql_lexer_set_lineno called with no buffer"); 
    
    yylineno = line_number;
}

/** Set the current column.
 * @param line_number
 * @param yyscanner The scanner object.
 */
void sparql_lexer_set_column (int  column_no , yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;

        /* column is only valid if an input buffer exists. */
        if (! YY_CURRENT_BUFFER )
           YY_FATAL_ERROR("sparql_lexer_set_column called with no buffer"); 
    
    yycolumn = column_no;
}

/** Set the input stream. This does not discard the current
 * input buffer.
 * @param in_str A readable stream.
 * @param yyscanner The scanner object.
 * @see sparql_lexer__switch_to_buffer
 */
void sparql_lexer_set_in (FILE *  in_str , yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    yyin = in_str ;
}

void sparql_lexer_set_out (FILE *  out_str , yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    yyout = out_str ;
}

int sparql_lexer_get_debug  (yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    return yy_flex_debug;
}

void sparql_lexer_set_debug (int  bdebug , yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    yy_flex_debug = bdebug ;
}

/* Accessor methods for yylval and yylloc */

/* User-visible API */

/* sparql_lexer_lex_init is special because it creates the scanner itself, so it is
 * the ONLY reentrant function that doesn't take the scanner as the last argument.
 * That's why we explicitly handle the declaration, instead of using our macros.
 */

int sparql_lexer_lex_init(yyscan_t* ptr_yy_globals)

{
    if (ptr_yy_globals == NULL){
        errno = EINVAL;
        return 1;
    }

    *ptr_yy_globals = (yyscan_t) sparql_lexer_alloc ( sizeof( struct yyguts_t ), NULL );

    if (*ptr_yy_globals == NULL){
        errno = ENOMEM;
        return 1;
    }

    /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */
    memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));

    return yy_init_globals ( *ptr_yy_globals );
}

/* sparql_lexer_lex_init_extra has the same functionality as sparql_lexer_lex_init, but follows the
 * convention of taking the scanner as the last argument. Note however, that
 * this is a *pointer* to a scanner, as it will be allocated by this call (and
 * is the reason, too, why this function also must handle its own declaration).
 * The user defined value in the first argument will be available to sparql_lexer_alloc in
 * the yyextra field.
 */

int sparql_lexer_lex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals )

{
    struct yyguts_t dummy_yyguts;

    sparql_lexer_set_extra (yy_user_defined, &dummy_yyguts);

    if (ptr_yy_globals == NULL){
        errno = EINVAL;
        return 1;
    }
	
    *ptr_yy_globals = (yyscan_t) sparql_lexer_alloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
	
    if (*ptr_yy_globals == NULL){
        errno = ENOMEM;
        return 1;
    }
    
    /* By setting to 0xAA, we expose bugs in
    yy_init_globals. Leave at 0x00 for releases. */
    memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
    
    sparql_lexer_set_extra (yy_user_defined, *ptr_yy_globals);
    
    return yy_init_globals ( *ptr_yy_globals );
}

static int yy_init_globals (yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    /* Initialization is the same as for the non-reentrant scanner.
     * This function is called from sparql_lexer_lex_destroy(), so don't allocate here.
     */

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

    yyg->yy_start_stack_ptr = 0;
    yyg->yy_start_stack_depth = 0;
    yyg->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
     * sparql_lexer_lex_init()
     */
    return 0;
}

/* sparql_lexer_lex_destroy is for both reentrant and non-reentrant scanners. */
int sparql_lexer_lex_destroy  (yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;

    /* Pop the buffer stack, destroying each element. */
	while(YY_CURRENT_BUFFER){
		sparql_lexer__delete_buffer(YY_CURRENT_BUFFER ,yyscanner );
		YY_CURRENT_BUFFER_LVALUE = NULL;
		sparql_lexer_pop_buffer_state(yyscanner);
	}

	/* Destroy the stack itself. */
	sparql_lexer_free(yyg->yy_buffer_stack ,yyscanner);
	yyg->yy_buffer_stack = NULL;

    /* Destroy the start condition stack. */
        sparql_lexer_free(yyg->yy_start_stack ,yyscanner );
        yyg->yy_start_stack = NULL;

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

    /* Destroy the main struct (reentrant only). */
    /* clean up leaks if any before freeing yyscanner */
    sparql_lexer_cleanup(yyscanner);
    sparql_lexer_free ( yyscanner , yyscanner );
    yyscanner = NULL;
    return 0;
}

/*
 * Internal utility routines.
 */

#ifndef yytext_ptr
static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner)
{
	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 , yyscan_t yyscanner)
{
	register int n;
	for ( n = 0; s[n]; ++n )
		;

	return n;
}
#endif

#define YYTABLES_NAME "yytables"

#line 596 "./sparql_lexer.l"


  /* user code */

int
sparql_lexer_wrap (yyscan_t yyscanner)
{
  return 1;
}


static int
rasqal_sparql_name_check(unsigned char *string, size_t length,
                         sparql_name_check_flags check_flags)
{
  int rc = 0;
  int c = -1;
#if RASQAL_DEBUG > 2
  RASQAL_DEBUG1("Checking name '");
  if(length)
     fwrite(string, length, sizeof(unsigned char), stderr);
  fprintf(stderr, "' (length %d), flags %d\n", (int)length, (int)check_flags);
#endif

  if(!length)
    return 1;

  if(check_flags && SPARQL_NAME_CHECK_ALLOW_09_FIRST &&
     (*string >= '0' && *string <= '9')) {
    c = *string;
    *string = 'X';
  }

  if(!raptor_xml_name_check(string, length, 11)) /* 11 = XML 1.1 */
    goto done;
  
  if((check_flags & SPARQL_NAME_CHECK_NO_UL_FIRST) && *string == '_')
    goto done;

  if((check_flags & SPARQL_NAME_CHECK_NO_DOT_LAST) && string[length-1] == '.')
    goto done;

  if(check_flags & SPARQL_NAME_CHECK_NO_DOT_MINUS) {
    int i;
    for(i = 0; i < (int)length; i++)
      if(string[i] == '.' || string[i] == '-')
        goto done;
  }
  rc = 1;

  done:
  if(c >= 0)
    *string = c;
  return rc;
}


static unsigned char *
sparql_copy_name(rasqal_query *rq, const unsigned char *text, size_t len,
                 sparql_name_check_flags check_flags)
{
  size_t dest_len = 0;
  unsigned char *s;

  s = rasqal_escaped_name_to_utf8_string((unsigned char*)text, len,
                                         &dest_len,
                                         sparql_syntax_error, rq);
  if(!s)
    return s;

  if(!rasqal_sparql_name_check(s, dest_len, check_flags))
    sparql_syntax_error(rq, "Invalid SPARQL name \"%s\"", s);

  return s;
}


static raptor_uri*
sparql_copy_qname(rasqal_query *rq, const unsigned char *text, size_t len)
{
  unsigned char *p;
  size_t dest_len = 0;
  unsigned char *s;
  raptor_uri* uri = NULL;
  
  s = rasqal_escaped_name_to_utf8_string((unsigned char*)text, len,
                                         &dest_len,
                                         sparql_syntax_error, rq);
  if(!s)
    return NULL;

  p = (unsigned char*)strchr((const char*)s, ':');
  if(!rasqal_sparql_name_check(s, p-s, SPARQL_NAME_CHECK_PREFIX))
    sparql_syntax_error(rq, "Invalid SPARQL prefix name \"%s\"", s);
  if(!rasqal_sparql_name_check(p+1, dest_len-((p+1)-s), SPARQL_NAME_CHECK_NCNAME))
    sparql_syntax_error(rq, "Invalid SPARQL local name \"%s\"", p+1);

#ifdef STANDALONE
  /* lexer test cannot declare namespaces - so just ignore expansion */
# ifdef RAPTOR_V2_AVAILABLE
  uri = raptor_new_uri_relative_to_base(rq->world->raptor_world_ptr, rq->base_uri, s);
# else
  uri = raptor_new_uri_relative_to_base(rq->base_uri, s);
# endif
#else
  if(!rq->namespaces) {
    sparql_syntax_error(rq, "SPARQL syntax error - no namespaces declared");
    return NULL;
  }
  
# ifdef RAPTOR_V2_AVAILABLE
  uri = raptor_qname_string_to_uri(rq->namespaces,
                                   s, dest_len);
# else
  uri = raptor_qname_string_to_uri(rq->namespaces,
                                   s, dest_len,
                                   (raptor_simple_message_handler)rasqal_query_simple_error, rq);
# endif
#endif
  RASQAL_FREE(cstring, s);
  
  return uri;
}


static int
sparql_copy_string_token(rasqal_query* rq, YYSTYPE* lval,
                         const unsigned char *text, size_t len, int delim)
{
  unsigned int i;
  const unsigned char *s;
  unsigned char *d;
  unsigned char *string;
  char *language = NULL;
  unsigned char *dt = NULL;
  raptor_uri *dt_uri = NULL;
  unsigned char *dt_qname = NULL;

  string = (unsigned char *)RASQAL_MALLOC(cstring, len+1);
  if(!string)
    return 1;

  for(s = text, d = string, i = 0; i<len; s++, i++) {
    unsigned char c = *s;

    if(c == '\\' ) {
      s++; i++;
      c = *s;
      if(c == 'n')
        *d++ =  '\n';
      else if(c == 'r')
        *d++ =  '\r';
      else if(c == 'f')
        *d++ =  '\f';
      else if(c == 'b')
        *d++ =  '\b';
      else if(c == 't')
        *d++ =  '\t';
      else if(c == '\\' || c == '\'' || c == '"')
        *d++ = c;
      else if(c == 'u' || c == 'U') {
        int ulen = (c == 'u') ? 4 : 8;
        unsigned long unichar = 0;
        int n;
        
        s++; i++;
        if(i + ulen > len) {
          printf("\\%c over end of line", c);
          RASQAL_FREE(cstring, string);
          return 1;
        }
        
        n = sscanf((const char*)s, ((ulen == 4) ? "%04lx" : "%08lx"), &unichar);
        if(n != 1) {
          sparql_syntax_error(rq, "SPARQL syntax error - Illegal Uncode escape '%c%s...'", c, s);
          RASQAL_FREE(cstring, string);
          return 1;
        }

        s += ulen - 1;
        i += ulen - 1;
        
        if(unichar > 0x10ffff) {
          sparql_syntax_error(rq, "SPARQL syntax error - Illegal Unicode character with code point #x%lX.", unichar);
          RASQAL_FREE(cstring, string);
          return 1;
        }
          
        d += raptor_unicode_char_to_utf8(unichar, d);
      } else {
        /* Ignore \x where x isn't the one of: \n \r \t \\ (delim) \u \U */
        sparql_syntax_warning(rq, "Unknown SPARQL string escape \\%c in \"%s\"", c, text);
        *d++ = c;
      }
    } else if(c== delim) {
      *d++ = '\0';

      /* skip delims (', ", ''' or """) */
      while(c == delim) {
        c = *s++; i++;
      }
      
      if(c=='@') {
        language = (char*)d;
        while(i <= len) {
          c = *s++; i++;
          if(!isalpha(c) && !isdigit(c) && c != '-')
            break;
          *d++ = c;
        }
        *d++ = '\0';
      }
      if(c=='^') {
        /* skip second char of ^^ */
        s++; i++;

        dt = d;
        while(i++ <= len)
          *d++ = *s++;
        /* *d='\0' below */
      } else if(language)
        *d = '\0';
      
      break;
   } else
    *d++ = c;
  } /* end of for */

  *d = '\0';

  if(language) {
    char *new_language;
    size_t new_language_len = strlen((const char*)language);
    
    new_language = (char*)RASQAL_MALLOC(cstring, new_language_len + 1);
    if(!new_language) {
      RASQAL_FREE(cstring, string);
      return 1;
    }
    strncpy(new_language, language, new_language_len + 1);
    language = new_language;
  }
  
  if(dt) {
    /* dt can be a URI or qname */
    if(*dt == '<') {
      dt[strlen((const char*)dt)-1] = '\0';
#ifdef RAPTOR_V2_AVAILABLE
      dt_uri = raptor_new_uri(rq->world->raptor_world_ptr, dt+1);
#else
      dt_uri = raptor_new_uri(dt+1);
#endif
      if(!dt_uri) {
        if(language)
          RASQAL_FREE(cstring, language);
        RASQAL_FREE(cstring, string);
        return 1;
      }
    } else {
      unsigned char *dt_p;
      size_t dest_len = 0;
      unsigned char *dt_s;
      
      dt_s = rasqal_escaped_name_to_utf8_string(dt,
                                                strlen((const char*)dt),
                                                &dest_len,
                                                sparql_syntax_error, rq);
      if(!dt_s) {
        if(language)
          RASQAL_FREE(cstring, language);
        RASQAL_FREE(cstring, string);
        return 1;
      }

      dt_p = (unsigned char*)strchr((const char*)dt_s, ':');
      if(!rasqal_sparql_name_check(dt_s, dt_p-dt_s, SPARQL_NAME_CHECK_PREFIX))
        sparql_syntax_error(rq, "Invalid SPARQL prefix name \"%s\"", dt_s);
      if(!rasqal_sparql_name_check(dt_p+1, dest_len-((dt_p+1)-dt_s), 
                                   SPARQL_NAME_CHECK_NCNAME))
        sparql_syntax_error(rq, "Invalid SPARQL local name \"%s\"", dt_p+1);

#ifdef STANDALONE
      /* lexer test cannot declare namespaces - so just ignore expansion */
      dt_qname = dt_s;
#else
      if(!rq->namespaces) {
        sparql_syntax_error(rq, "SPARQL syntax error - no namespaces declared");
        RASQAL_FREE(cstring, dt_s);
        if(language)
          RASQAL_FREE(cstring, language);
        RASQAL_FREE(cstring, string);
        return 1;
      }

# ifdef RAPTOR_V2_AVAILABLE
      dt_uri = raptor_qname_string_to_uri(rq->namespaces,
                                          dt_s, dest_len);
# else
      dt_uri = raptor_qname_string_to_uri(rq->namespaces,
                                          dt_s, dest_len,
                                          (raptor_simple_message_handler)rasqal_query_simple_error, rq);
# endif
      RASQAL_FREE(cstring, dt_s);

      if(!dt_uri) {
        if(language)
          RASQAL_FREE(cstring, language);
        RASQAL_FREE(cstring, string);
        return 1;
      }
#endif
    }
  }

#if RASQAL_DEBUG >3
  fprintf(stderr, "string='%s', language='%s'\n", 
          string, (language ? language : ""));
  fprintf(stderr, "datatype uri='%s'\n",
          (dt_uri ? (const char*)raptor_uri_as_string(dt_uri) : ""));
#endif

  lval->literal = rasqal_new_string_literal(rq->world, string, language, dt_uri, dt_qname);
  if(!lval->literal)
    return 1;

  return 0;
}


static int
sparql_skip_c_comment(rasqal_query *rq)
{
  rasqal_sparql_query_language *rqe;
  yyscan_t yyscanner;
  int lines = 0;
  int c;
  int lastc = -1;
  
  rqe = (rasqal_sparql_query_language*)rq->context;
  yyscanner = rqe->scanner;

  while(1) {
    while ((c = INPUT_FN(yyscanner)) != '*' && c != EOF) {
      if(c == '\r' || (c == '\n' && lastc != '\r'))
        lines++;
      lastc =  c;
    }
    if( c == '*') {
      while ((c = INPUT_FN(yyscanner)) == '*') {
        if(c == '\r' || (c == '\n' && lastc != '\r'))
          lines++;
        lastc =  c;
      }

      if(c == '/')
        break;
    }
    if(c == EOF) {
      sparql_syntax_error(rq, "SPARQL syntax error - EOF in comment");
      lines = -1;
      break;
    }
    lastc =  c;
  }
  return lines;
}


/*
 * sparql_lexer_fatal_error:
 * @msg:
 * @yyscanner:
 *
 * INTERNAL - replacement for the generated error handler.
 * Uses rasqal_query_fatal_error() when possible.
 */
static void sparql_lexer_fatal_error(yyconst char *msg, yyscan_t yyscanner)
{
  rasqal_query *rq = NULL;

  if(yyscanner)
    rq = (rasqal_query *)sparql_lexer_get_extra(yyscanner);

  if(rq) {
    /* avoid "format not a string literal and no format arguments" warning with %s */
    rq->failed = 1;
    rasqal_log_error_simple(rq->world, RAPTOR_LOG_LEVEL_FATAL,
                            &rq->locator, "%s", msg); 
  } else {
    fputs(msg, stderr);
    fputc('\n', stderr);
  }
}


/* Define LEXER_ALLOC_TRACKING to enable allocated memory tracking
 * - fixes lexer memory leak when ensure_buffer_stack fails
 */

#ifdef LEXER_ALLOC_TRACKING
typedef struct {
  /* Number of void* slots allocated */
  int lexer_allocs_size;
  /* Allocted void* slots follow in memory after this header */
} lexer_alloc_tracker_header;

/* Initial alloc tracker slot array size - 2 seems to be enough for almost all cases */
static const int initial_lexer_allocs_size = 2;
#endif

/*
 * sparql_lexer_cleanup:
 * @yyscanner:
 *
 * INTERNAL - Clean up unfreed lexer allocs if LEXER_ALLOC_TRACKING is enabled.
 */
static void sparql_lexer_cleanup(yyscan_t yyscanner)
{
#ifdef LEXER_ALLOC_TRACKING
  rasqal_query *rq;
  lexer_alloc_tracker_header *tracker;
  void **lexer_allocs;
  int i;

  if(!yyscanner)
    return;

  rq = (rasqal_query *)sparql_lexer_get_extra(yyscanner);
  if(!rq)
    return;

  tracker = (lexer_alloc_tracker_header *)rq->lexer_user_data;
  if(!tracker)
    return;
  lexer_allocs = (void**)&tracker[1];

  for(i = 0; i<tracker->lexer_allocs_size; ++i) {
    if(lexer_allocs[i])
      free(lexer_allocs[i]);
    lexer_allocs[i] = NULL;
  }
  free(rq->lexer_user_data);
  rq->lexer_user_data = NULL;
#endif
}


/*
 * sparql_lexer_alloc:
 * @size
 * @yyscanner
 *
 * INTERNAL - alloc replacement.
 * Tracks allocated cells if LEXER_ALLOC_TRACKING is enabled.
 */
void *sparql_lexer_alloc(yy_size_t size, yyscan_t yyscanner)
{
#ifdef LEXER_ALLOC_TRACKING
  rasqal_query *rq;
  lexer_alloc_tracker_header *tracker;
  void **lexer_allocs;
  int i;
  void *ptr;

  /* yyscanner not initialized -> probably initializing yyscanner itself
   * -> just malloc without tracking
   */
  if(!yyscanner)
    return malloc(size);

  rq = (rasqal_query *)sparql_lexer_get_extra(yyscanner);
  if(!rq)
    YY_FATAL_ERROR("lexer_alloc: yyscanner extra not initialized");

  /* try to allocate tracker if it does not exist */
  tracker = (lexer_alloc_tracker_header *)rq->lexer_user_data;
  if(!tracker) {
    /* allocate tracker header + array of void* slots */
    tracker = (lexer_alloc_tracker_header*)calloc(1, sizeof(lexer_alloc_tracker_header) + initial_lexer_allocs_size * sizeof(void*));
    if(!tracker)
      YY_FATAL_ERROR("lexer_alloc: cannot allocate tracker");
    tracker->lexer_allocs_size = initial_lexer_allocs_size;
    rq->lexer_user_data = (void *)tracker;
  }
  lexer_allocs = (void**)&tracker[1];

  /* allocate memory */
  ptr = malloc(size);
  
  /* find a free slot for ptr */
  for(i = 0; i<tracker->lexer_allocs_size; ++i) {
    if(!lexer_allocs[i]) {
      lexer_allocs[i] = ptr;
      break;
    }
  }

  /* no free slots -> grow tracker slot array */
  if(i >= tracker->lexer_allocs_size) {
    int j;
    void **dest;
    tracker = (lexer_alloc_tracker_header*)calloc(1, sizeof(lexer_alloc_tracker_header) + i * 2 * sizeof(void*));
    if(!tracker) {
      if(ptr)
        free(ptr);
      YY_FATAL_ERROR("lexer_alloc: cannot grow tracker");
    }
    tracker->lexer_allocs_size = i*2;
    
    /* copy data from old tracker */
    dest = (void**)&tracker[1];
    for(j = 0; j<i; ++j) {
      dest[j] = lexer_allocs[j];
    }
    
    /* set new item to first free slot */
    dest[j] = ptr;

    /* free old tracker and replace with new one */
    free(rq->lexer_user_data);
    rq->lexer_user_data = tracker;
  }

  return ptr;
#else
  return malloc(size);
#endif
}


/*
 * sparql_lexer_realloc:
 *
 * INTERNAL - realloc replacement
 * Tracks allocated cells if LEXER_ALLOC_TRACKING is enabled.
 */
void *sparql_lexer_realloc(void *ptr, yy_size_t size, yyscan_t yyscanner)
{
#ifdef LEXER_ALLOC_TRACKING
  rasqal_query *rq;
  lexer_alloc_tracker_header *tracker;
  void **lexer_allocs;
  int i;
  void *newptr;

  if(!yyscanner)
    YY_FATAL_ERROR("lexer_realloc: yyscanner not initialized");

  rq = (rasqal_query *)sparql_lexer_get_extra(yyscanner);
  if(!rq)
    YY_FATAL_ERROR("lexer_realloc: yyscanner extra not initialized");

  tracker = (lexer_alloc_tracker_header *)rq->lexer_user_data;
  if(!tracker)
    YY_FATAL_ERROR("lexer_realloc: no alloc tracker");
  lexer_allocs = (void**)&tracker[1];

  /* find the old slot for ptr */
  for(i = 0; i < tracker->lexer_allocs_size; ++i) {
    if(lexer_allocs[i] == ptr)
      break;
  }

  /* no old slot -> error */  
  if(i >= tracker->lexer_allocs_size)
    YY_FATAL_ERROR("lexer_realloc: cell not in tracker");

  /* realloc */
  newptr = realloc((char*)ptr, size);

  /* replace entry in tracker */
  lexer_allocs[i] = newptr;

  return newptr;
#else
  return realloc((char*)ptr, size);
#endif
}


/*
 * sparql_lexer_free:
 *
 * INTERNAL - free replacement.
 * Checks for NULL pointer to be freed unlike the default lexer free function.
 * Tracks allocated cells if LEXER_ALLOC_TRACKING is enabled.
 */
void sparql_lexer_free(void *ptr, yyscan_t yyscanner)
{
#ifdef LEXER_ALLOC_TRACKING
  rasqal_query *rq;
  lexer_alloc_tracker_header *tracker;
  void **lexer_allocs;
  int i;

  /* do not free NULL */
  if(!ptr)
    return;

  /* free ptr even if we would encounter an error */
  free(ptr);

  /* yyscanner is allocated with sparql_lexer_alloc() but it's never stored in the tracker
   * - we need yyscanner to access the tracker */
  if(!yyscanner || ptr==yyscanner)
    return;

  rq = (rasqal_query *)sparql_lexer_get_extra(yyscanner);
  if(!rq)
    return;

  tracker = (lexer_alloc_tracker_header *)rq->lexer_user_data;
  if(!tracker)
    return;
  lexer_allocs = (void**)&tracker[1];

  /* find the slot for ptr */
  for(i = 0; i<tracker->lexer_allocs_size; ++i) {
    if(lexer_allocs[i]==ptr)
      break;
  }

  /* no slot -> error */  
  if(i >= tracker->lexer_allocs_size)
    YY_FATAL_ERROR("lexer_free: cell not in tracker");

  /* remove entry from tracker */
  lexer_allocs[i] = NULL;
#else
  if(ptr)
    free(ptr);
#endif
}


#ifdef RASQAL_DEBUG

const char *
sparql_token_print(rasqal_world* world, int token, YYSTYPE *lval)
{
  static char buffer[2048];

  if(!token)
    return "<<EOF>>";
  
  switch(token) {
    case SELECT:
      return "SELECT";

    case FROM:
      return "FROM";

    case WHERE:
      return "WHERE";

    case PREFIX:
      return "PREFIX";

    case DESCRIBE:
      return "DESCRIBE";

    case CONSTRUCT:
      return "CONSTRUCT";

    case ASK:
      return "ASK";

    case DISTINCT:
      return "DISTINCT";

    case LIMIT:
      return "LIMIT";

    case UNION:
      return "UNION";

    case OPTIONAL:
      return "OPTIONAL";

    case BASE:
      return "BASE";

    case BOUND:
      return "BOUND";

    case STR:
      return "STR";
      
    case LANG:
      return "LANG";
      
    case DATATYPE:
      return "DATATYPE";
      
    case ISURI:
      return "ISURI";
      
    case ISBLANK:
      return "ISBLANK";
      
    case ISLITERAL:
      return "ISLITERAL";
      
    case GRAPH:
      return "GRAPH";
      
    case NAMED:
      return "NAMED";
      
    case FILTER:
      return "FILTER";

    case OFFSET:
      return "OFFSET";
      
    case A:
      return "a";
      
    case ORDER:
      return "ORDER";
      
    case BY:
      return "BY";
      
    case REGEX:
      return "REGEX";
      
    case ASC:
      return "ASC[";
      
    case DESC:
      return "DESC[";
      
    case LANGMATCHES:
      return "LANGMATCHES";
      
    case ',':
      return ",";

    case '(':
      return "(";

    case ')':
      return ")";

    case '[':
      return "[";

    case ']':
      return "]";

    case '{':
      return "{";

    case '}':
      return "}";

    case '.':
      return ".";

    case ';':
      return ";";

    case '?':
      return "?";

    case '$':
      return "$";

    case SC_AND:
      return "SC_AND";

    case SC_OR:
      return "SC_OR";

    case GE:
      return "GE";

    case LE:
      return "LE";

    case GT:
      return "GT";

    case LT:
      return "LT";

    case NEQ:
      return "NEQ";

    case EQ:
      return "EQ";

    case '/':
      return "/";

    case '*':
      return "*";

    case '-':
      return "-";

    case '+':
      return "+";

    case '!':
      return "!";

    case EXPLAIN:
      return "EXPLAIN";

    case GROUP:
      return "GROUP";

    case COUNT:
      return "COUNT";

    case SUM:
      return "SUM";

    case AVG:
      return "AVG";

    case MIN:
      return "MIN";

    case MAX:
      return "MAX";

    case DELETE:
      return "DELETE";

    case INSERT:
      return "INSERT";

    case WITH:
      return "WITH";

    case CLEAR:
      return "CLEAR";

    case CREATE:
      return "CREATE";

    case SILENT:
      return "SILENT";

    case DATA:
      return "DATA";
      
    case DROP:
      return "DROP";
      
    case LOAD:
      return "LOAD";
      
    case INTO:
      return "INTO";
      
    case LET:
      return "LET";

    case AS:
      return "AS";

    case ASSIGN:
      return ":=";

    case COALESCE:
      return "COALESCE";

    case INTEGER_LITERAL:
    case INTEGER_POSITIVE_LITERAL:
    case INTEGER_NEGATIVE_LITERAL:
      sprintf(buffer, "INTEGER_LITERAL(%d)", lval->literal->value.integer);
      return buffer;

    case DOUBLE_LITERAL:
    case DOUBLE_POSITIVE_LITERAL:
    case DOUBLE_NEGATIVE_LITERAL:
      sprintf(buffer, "DOUBLE_LITERAL(%g)", lval->floating);
      return buffer;

    case STRING_LITERAL:
      if(lval->literal->language) {
        if(lval->literal->datatype)
          sprintf(buffer, "STRING_LITERAL(\"%s\"@%s^^%s)",
                  lval->literal->string, lval->literal->language,
                  raptor_uri_as_string(lval->literal->datatype)
                  );
        else
          sprintf(buffer, "STRING_LITERAL(\"%s\"@%s)",
                  lval->literal->string, lval->literal->language);
      } else {
        if(lval->literal->datatype)
          sprintf(buffer, "STRING_LITERAL(\"%s\"^^%s)", 
                  lval->literal->string,
                  raptor_uri_as_string(lval->literal->datatype)
                  );
        else
          sprintf(buffer, "STRING_LITERAL(\"%s\")", lval->literal->string);
      }
      return buffer;

    case BOOLEAN_LITERAL:
      return (lval->literal->value.integer ? "BOOLEAN_LITERAL(true)" : "BOOLEAN_LITERAL(false)");

    case URI_LITERAL:
      sprintf(buffer, "URI_LITERAL(%s)",
              raptor_uri_as_string(lval->uri)
              );
      return buffer;

    case QNAME_LITERAL:
      sprintf(buffer, "QNAME_LITERAL(%s)", lval->name);
      return buffer;

    case URI_LITERAL_BRACE:
      sprintf(buffer, "URI_LITERAL_BRACE(%s)",
              raptor_uri_as_string(lval->uri)
              );
      return buffer;

    case QNAME_LITERAL_BRACE:
      sprintf(buffer, "QNAME_LITERAL_BRACE(%s)", lval->name);
      return buffer;

    case IDENTIFIER:
      sprintf(buffer, "IDENTIFIER(%s)", lval->name);
      return buffer;

    case BLANK_LITERAL:
      sprintf(buffer, "BLANK_LITERAL(%s)", lval->name);
      return buffer;

    case DECIMAL_LITERAL:
    case DECIMAL_POSITIVE_LITERAL:
    case DECIMAL_NEGATIVE_LITERAL:
      sprintf(buffer, "DECIMAL_LITERAL(%s)", lval->literal->string);
      return buffer;

   default:
     RASQAL_DEBUG2("UNKNOWN token %d - add a new case\n", token);
     abort();
  }
}
#endif



#ifdef STANDALONE
static void
sparql_token_free(rasqal_world* world, int token, YYSTYPE *lval)
{
  if(!token)
    return;
  
  switch(token) {
    case STRING_LITERAL:
    case INTEGER_LITERAL:
    case INTEGER_POSITIVE_LITERAL:
    case INTEGER_NEGATIVE_LITERAL:
    case DOUBLE_LITERAL:
    case DOUBLE_POSITIVE_LITERAL:
    case DOUBLE_NEGATIVE_LITERAL:
    case DECIMAL_POSITIVE_LITERAL:
    case DECIMAL_NEGATIVE_LITERAL:
    case DECIMAL_LITERAL:
    case BOOLEAN_LITERAL:
      rasqal_free_literal(lval->literal);
      break;
    case URI_LITERAL:
    case URI_LITERAL_BRACE:
      raptor_free_uri(lval->uri);
      break;
    case IDENTIFIER:
    case BLANK_LITERAL:
    case PREFIX:
      RASQAL_FREE(cstring, lval->name);
      break;
    case QNAME_LITERAL:
      if(lval->name)
        RASQAL_FREE(cstring, lval->name);
      break;
    default:
      break;
  }
}


#define FILE_READ_BUF_SIZE 2048

int
main(int argc, char *argv[]) 
{
  const char *program = rasqal_basename(argv[0]);
  char *query_string = NULL;
  rasqal_query rq;
  rasqal_sparql_query_language sparql;
  yyscan_t scanner;
  int token = EOF;
  YYSTYPE lval;
  const unsigned char *uri_string;
  const char *filename = NULL;
  char *buf = NULL;
  size_t len;
  void *buffer;
  rasqal_world *world;
  FILE *fh;
  
  world = rasqal_new_world();
  if(!world || rasqal_world_open(world))
    exit(1);
  
  filename = getenv("SPARQL_QUERY_FILE");
  if(!filename) {
    if(argc != 2) {
      fprintf(stderr, "%s: Too many arguments.\n", program);
      fprintf(stderr, "SPARQL lexer test for Rasqal %s\n", 
              rasqal_version_string);
      fprintf(stderr, "USAGE: %s SPARQL-QUERY-FILE\n", program);
      exit(1);
    }
    
    filename = argv[1];
  }
  
  query_string = (char*)RASQAL_CALLOC(cstring, FILE_READ_BUF_SIZE, 1);
  fh = fopen(filename, "r");
  if(fh) {
    fread(query_string, FILE_READ_BUF_SIZE, 1, fh);
    fclose(fh);
  } else {
    fprintf(stderr, "%s: Cannot open file %s - %s\n", program, filename,
            strerror(errno));
    exit(1);
  }

  memset(&rq, 0, sizeof(rq));
  rq.world = world;
  memset(&sparql, 0, sizeof(sparql));

  sparql_lexer_lex_init(&sparql.scanner);
  scanner = sparql.scanner;

  len =  strlen((const char*)query_string);
  buf =  (char *)RASQAL_MALLOC(cstring, len+3);
  strncpy(buf, query_string, len);
  buf[len] =  ' ';
  buf[len+1] =  buf[len+2] = '\0'; /* YY_END_OF_BUFFER_CHAR; */
  buffer =  sparql_lexer__scan_buffer(buf, len+3, scanner);

  sparql_lexer_set_extra(&rq, scanner);

  /* Initialise enough of the rasqal_query and locator to get error messages */
  rq.context = &sparql;
  sparql.lineno = 1;
  rq.locator.file = filename;
  rq.locator.column = -1;

  uri_string = raptor_uri_filename_to_uri_string(filename);
#ifdef RAPTOR_V2_AVAILABLE
  rq.base_uri = raptor_new_uri(world->raptor_world_ptr, uri_string);
#else
  rq.base_uri = raptor_new_uri(uri_string);
#endif
  raptor_free_memory((void*)uri_string);

  while(1) {
    memset(&lval, 0, sizeof(lval));
    if(sparql_lexer_get_text(scanner) != NULL)
      printf("yyinput '%s'\n", sparql_lexer_get_text(scanner));
    token = sparql_lexer_lex(&lval,scanner);
#ifdef RASQAL_DEBUG
    printf("token %s\n", sparql_token_print(world, token, &lval));
#else
    printf("token %d\n", token);
#endif
    sparql_token_free(world, token, &lval);
    if(!token || token == EOF)
      break;
  }

  if(buf)
    RASQAL_FREE(cstring, buf);
  
  sparql_lexer_lex_destroy(scanner);

  raptor_free_uri(rq.base_uri);

  RASQAL_FREE(cstring, query_string);

  rasqal_free_world(world);

  if(rq.failed)
    return 1;
 
  return 0;
}
#endif

