Logo Search packages:      
Sourcecode: rasqal version File versions  Download package

sparql_lexer.c

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

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

#line 2 "sparql_lexer.c"

#line 4 "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 33
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif

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

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

/* end standard C headers. */

/* flex integer type definitions */

#ifndef FLEXINT_H
#define FLEXINT_H

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

#if __STDC_VERSION__ >= 199901L

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

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

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

#endif /* ! FLEXINT_H */

#ifdef __cplusplus

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

#else /* ! __cplusplus */

#if __STDC__

#define YY_USE_CONST

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

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

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

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

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

int sparql_lexer_lex_init (yyscan_t* scanner);

/* 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
#define YY_BUF_SIZE 16384
#endif

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

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

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

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

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

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

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

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

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

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

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

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

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

      int yy_buffer_status;

#define YY_BUFFER_NEW 0
#define YY_BUFFER_NORMAL 1
      /* When an EOF's been seen but there's still some text to process
       * then we mark the buffer as YY_EOF_PENDING, to indicate that we
       * shouldn't try reading from the input source any more.  We might
       * still have a bunch of tokens to match, though, because of
       * possible backing-up.
       *
       * When we actually see the EOF, we change the status to "new"
       * (via 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 );
static void yy_fatal_error (yyconst char msg[] ,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 84
#define YY_END_OF_BUFFER 85
/* 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[315] =
    {   0,
        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
       85,   83,    4,    3,    3,   58,   83,   83,   41,   83,
       83,   36,   37,   56,   54,   35,   55,   44,   57,   59,
       59,   79,   45,   83,   48,   51,   40,   83,   83,   83,
       83,   83,   83,   83,   83,   83,   83,   83,   83,   83,
       83,   83,   83,   83,   38,   39,   83,   34,   42,   83,
       43,   74,   73,   78,   75,   77,   78,   67,   67,   70,
       70,    4,    3,   49,    0,   64,    0,    0,   82,   82,
       47,    0,   63,    0,    0,    0,   61,    2,    0,   59,
       61,   59,    0,    0,   79,   79,   50,   50,   52,   81,

        0,   53,    0,    0,   79,    0,    0,    0,   29,    0,
        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
        0,    0,   46,   73,   75,    0,    0,   76,    0,    0,
        0,    0,    0,    0,   64,   65,    0,    0,   63,   68,
        0,    0,    0,    0,    1,    1,   61,    0,    0,   62,
       60,   79,    0,    0,   81,   81,   31,   11,    0,    0,
        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
       18,    0,    0,    0,   80,   66,   69,   64,    0,   63,

        0,    0,   62,    0,   62,   81,   16,    0,    0,    0,
       32,    0,    0,    0,    6,    0,    0,    0,    0,   19,
        0,    0,    0,    0,    0,    0,    0,    0,   71,    0,
        0,   80,    0,   64,   64,    0,    0,   63,   63,    0,
        0,   17,    0,    0,    0,    0,   72,    0,   24,    0,
       21,    0,    0,   13,   25,    0,    0,   28,    0,   30,
        0,   14,    7,   64,    0,   64,    0,    0,   63,    0,
       63,    0,    0,    0,    0,    0,    0,   26,    0,    0,
        0,   27,    0,    8,    5,   64,    0,    0,   64,   63,
        0,    0,   63,    0,    0,    0,    0,   22,    0,    0,

        0,    0,   20,    9,   12,    0,    0,   15,   10,   23,
        0,    0,   33,    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,   21,   21,
       21,   21,   21,   21,   21,   21,   21,   22,   23,   24,
       25,   26,   27,   28,   29,   30,   31,   32,   33,   34,
       35,   36,   37,   38,   39,   40,   41,   42,   43,   44,
       38,   45,   46,   47,   48,   38,   49,   50,   51,   38,
       52,   53,   54,   55,   56,    1,   57,   30,   31,   32,

       33,   34,   35,   36,   37,   38,   39,   40,   41,   42,
       43,   44,   38,   45,   46,   47,   48,   38,   49,   50,
       51,   38,   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,
        7,    8,    1,    9,    3,    1,    1,    1,   10,   10,
       10,   10,   10,   10,   10,   10,   10,   10,   10,   10,
       10,   10,   10,   10,   10,   10,   10,   10,   10,   10,
       10,    1,   11,    1,   12,   13,   10,    1,    1,    1,
       11
    } ;

static yyconst flex_int16_t yy_base[347] =
    {   0,
        0,    0,   61,    0,  122,    0,  895,  894,  888,  887,
      892, 1212,  182, 1212,  884,  834,  178,  185, 1212,  844,
      175, 1212, 1212, 1212,  172, 1212,  176,  178,  181,  184,
      200,  834, 1212,  240, 1212,  820, 1212,  190,  284,  192,
      285,  191,  286,  193,  287,  299,  308,  316,  294,  204,
      307,  302,  326,  327, 1212, 1212,  815,  333, 1212,  771,
     1212, 1212,    0, 1212,  201, 1212,  201,  815,  813,  801,
      794,  225, 1212, 1212,  304,  325,    0,  355, 1212,  800,
     1212,  299,  353,    0,  346,  351,  353, 1212,  372, 1212,
      357,  376,  372,  381, 1212,  370,  771, 1212, 1212,  213,

      739, 1212,  373,  381,  751,  400,  382,  399,  401,  402,
      407,  412,  414,  415,  423,  424,  430,  431,  444,  447,
      452,  455,  454,  460,  462,  463,  472,  478,  481,  484,
      486,    0, 1212,    0,  227,  487,  489, 1212,  744,  743,
      723,  698,  691,  688,  291, 1212,    0,  635,  428, 1212,
        0,  618,  505,  402, 1212,  669,  494,  513,  406,  430,
      511,  479,  498,  644,  655,  621,  495,  517,  528,  529,
      530,  531,  536,  537,  544,  547,  552,  555,  557,  560,
      563,  569,  574,  580,  585,  588,  590,  596,  599,  602,
      597,  604,  611,  616,  598,  602,  590,  540,  514,  534,

      617,  536,  543,  607,  622, 1212,  618,  626,  627,  628,
      633,  634,  635,  644,  641,  647,  658,  642,  663,  664,
      666,  671,  673,  674,  676,  679,  682,  689,  690,  696,
      701,  568,  565,  525,    0,  546,  704,  482,    0,  498,
      706,  707,  709,  715,  718,  717,  723,  724,  725,  726,
      731,  734,  742,  739,  740,  754,  752,  755,  757,  760,
      762,  763,  765,  500,  449,  438,  768,  770,  439,  417,
      414,  771,  773,  778,  780,  786,  788,  793,  795,  796,
      803,  805,  810,  811,  813,  417,  389,  372, 1212,  367,
      352,  336, 1212,  818,  820,  825,  826,  833,  834,  839,

      842,  847,  844,  850,  853,  856,  859,  858,  861,  866,
      867,  868,  875, 1212,  914,  927,  940,  953,  966,  976,
      985,  992, 1001, 1014, 1027, 1040, 1050, 1063, 1067,  206,
      191, 1076, 1085, 1091, 1098, 1104, 1106, 1119, 1128, 1132,
     1145, 1154, 1163, 1176, 1185, 1198
    } ;

static yyconst flex_int16_t yy_def[347] =
    {   0,
      314,    1,  314,    3,  314,    5,  315,  315,  316,  316,
      314,  314,  314,  314,  314,  314,  317,  318,  314,  314,
      319,  314,  314,  314,  314,  314,  314,  314,  314,  314,
      314,  320,  314,  314,  314,  314,  314,  321,  321,  321,
      321,  321,  321,  321,  321,  321,  321,  321,  321,  321,
      321,  321,  321,  321,  314,  314,  314,  321,  314,  314,
      314,  314,  322,  314,  314,  314,  323,  324,  324,  325,
      325,  314,  314,  314,  317,  314,  317,  318,  314,  314,
      314,  319,  314,  319,  314,  314,  314,  314,  326,  314,
      314,  314,  314,  314,  314,  327,  328,  314,  314,  328,

      328,  314,  321,  321,  320,  321,  321,  321,  321,  321,
      321,  321,  321,  321,  321,  321,  321,  321,  321,  321,
      321,  321,  321,  321,  321,  321,  321,  321,  321,  321,
      321,  329,  314,  322,  314,  323,  323,  314,  324,  324,
      324,  325,  325,  325,  314,  314,  330,  314,  314,  314,
      331,  314,  314,  326,  314,  314,  314,  314,  314,  314,
      314,  327,  327,  328,  314,  328,  321,  321,  321,  321,
      321,  321,  321,  321,  321,  321,  321,  321,  321,  321,
      321,  321,  321,  321,  321,  321,  321,  321,  321,  321,
      321,  321,  321,  321,  332,  324,  325,  333,  334,  335,

      336,  314,  314,  314,  314,  314,  321,  321,  321,  321,
      321,  321,  321,  321,  321,  321,  321,  321,  321,  321,
      321,  321,  321,  321,  321,  321,  321,  321,  321,  321,
      321,  332,  332,  333,  337,  338,  339,  335,  340,  341,
      342,  321,  321,  321,  321,  321,  321,  321,  321,  321,
      321,  321,  321,  321,  321,  321,  321,  321,  321,  321,
      321,  321,  321,  343,  344,  344,  339,  339,  345,  346,
      346,  342,  342,  321,  321,  321,  321,  321,  321,  321,
      321,  321,  321,  321,  321,  343,  343,  344,  314,  345,
      345,  346,  314,  321,  321,  321,  321,  321,  321,  321,

      321,  321,  321,  321,  321,  321,  321,  321,  321,  321,
      321,  321,  321,    0,  314,  314,  314,  314,  314,  314,
      314,  314,  314,  314,  314,  314,  314,  314,  314,  314,
      314,  314,  314,  314,  314,  314,  314,  314,  314,  314,
      314,  314,  314,  314,  314,  314
    } ;

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

       63,   63,   63,   63,   63,   63,   63,   63,   63,   63,
       63,   63,   62,   63,   62,   62,   63,   63,   62,   62,
       62,   63,   64,   65,   64,   64,   65,   64,   64,   64,
       64,   64,   64,   64,   64,   64,   64,   64,   64,   64,
       64,   64,   64,   66,   64,   64,   64,   64,   64,   64,
       67,   67,   67,   67,   67,   67,   67,   67,   67,   67,
       67,   67,   67,   67,   67,   67,   67,   67,   67,   67,
       67,   67,   67,   64,   67,   64,   64,   64,   67,   64,
       64,   64,   67,   72,   76,   83,   72,   79,   80,   85,
       90,   86,   86,   85,   88,   86,   86,   87,   87,   89,

      200,   91,  135,   92,   92,  135,   90,  104,  104,  104,
      104,  105,  105,  105,  105,  198,   93,   91,  137,   92,
       92,  104,  138,   90,  166,  105,   72,   84,  135,   72,
       77,  135,   93,   94,  110,  106,  126,  117,  165,   90,
       97,   97,   97,   97,   98,   97,   97,   97,   97,   97,
       97,   97,   97,   97,   97,   97,   97,   97,   97,   97,
       97,   97,   97,   98,   99,  100,   97,   97,  101,  101,
      101,  101,  101,  101,  101,  101,  101,  101,  101,  101,
      101,  101,  101,  101,  101,  101,  101,  101,  101,  101,
      101,   97,   97,   97,   97,   97,  101,   97,   97,   97,

       97,  104,  104,  104,  104,  105,  105,  105,  105,  149,
      145,  104,  107,  111,  114,  105,  104,  112,  147,  104,
      105,  113,  115,  105,  104,  104,  108,  119,  105,  105,
      116,  146,  118,  104,  109,  120,  121,  105,  125,  127,
      107,  111,  114,  104,  104,  148,  129,  105,  105,  122,
      104,   84,  147,  128,  105,  119,   77,   79,   80,  123,
      124,  293,  131,  150,  121,   87,   87,  130,   91,  291,
       86,   86,   87,   87,  155,  156,  157,  157,  106,  148,
      151,   95,   90,   93,  291,  153,  159,  163,  159,  158,
      104,  160,  160,   91,  105,   92,   92,  289,  104,  104,

      161,  161,  314,  105,  155,  156,  287,  152,   93,  161,
      161,  161,  161,  161,  161,   90,  104,  104,  104,  104,
      105,  105,  105,  105,  104,  160,  160,  169,  105,  104,
      167,  104,  104,  105,  287,  105,  105,  161,  168,  293,
      104,  104,  293,  171,  105,  105,  170,  104,  104,  160,
      160,  105,  105,  172,  175,  151,  291,  173,  178,  174,
      179,  104,  176,  289,  104,  105,  177,  180,  105,  104,
      181,  104,  104,  105,  289,  105,  105,  104,  180,  104,
      104,  105,  152,  105,  105,  182,  178,  183,  185,  104,
       95,  187,  184,  105,  188,  104,  163,  189,  104,  105,

      186,  104,  105,  104,  137,  105,  137,  105,  138,  314,
      314,  190,  104,  157,  157,  163,  105,  287,  194,  202,
      193,  202,  191,  271,  203,  203,  158,  204,  192,  204,
      161,  161,  205,  205,  104,  235,  152,  236,  105,  161,
      161,  161,  161,  161,  161,  104,  104,  104,  104,  105,
      105,  105,  105,  104,  104,  203,  203,  105,  105,  210,
      207,  104,  203,  203,  104,  105,  211,  161,  105,  104,
      208,  266,  104,  105,  104,  209,  105,  104,  105,  148,
      104,  105,  233,  212,  105,  233,  104,  210,  152,  213,
      105,  104,  215,  214,  148,  105,  217,  104,  216,  219,

      197,  105,  104,  220,  218,  104,  105,  104,  196,  105,
      221,  105,  222,  104,  104,  233,  104,  105,  105,  104,
      105,  104,  225,  105,  224,  105,  205,  205,  104,  226,
      223,  227,  105,  104,  228,  104,  229,  105,  239,  105,
      240,  205,  205,  104,  104,  104,  165,  105,  105,  105,
      104,  104,  104,  230,  105,  105,  105,  242,  104,  104,
      231,  104,  105,  105,  104,  105,  206,  247,  105,  165,
      246,  155,  201,  243,  244,  104,  248,  245,  251,  105,
      104,  104,  249,  104,  105,  105,  250,  105,  104,  199,
      104,  104,  105,  104,  105,  105,  104,  105,  197,  104,

      105,  144,  255,  105,  253,  256,  104,  104,  143,  252,
      105,  105,  254,  104,  250,  259,  257,  105,  104,  261,
      258,  268,  105,  273,  104,  235,  104,  239,  105,  196,
      105,  260,  104,  263,  104,  104,  105,  262,  105,  105,
      104,  104,  104,  104,  105,  105,  105,  105,  104,  141,
      140,  104,  105,  274,  276,  105,  104,  104,  277,  104,
      105,  105,   95,  105,  165,  275,  280,  279,  278,  104,
      281,  104,  104,  105,  104,  105,  105,  104,  105,  104,
      104,  105,  104,  105,  105,  268,  105,  268,  273,  235,
      273,  314,  239,  283,  314,  104,  165,  104,  281,  105,

      282,  105,   79,  104,  144,  104,  284,  105,  285,  105,
      104,  143,  104,  104,  105,  296,  105,  105,  297,  141,
      104,  140,  104,  295,  105,  294,  105,  104,  104,  133,
      104,  105,  105,  298,  105,  104,  132,  104,  301,  105,
      299,  105,  104,  104,  102,   95,  105,  105,  302,  300,
      104,  104,  303,   81,  105,  105,  104,  304,   74,  104,
      105,  104,  306,  105,  104,  105,  301,  104,  105,  307,
      104,  105,  305,  104,  105,  104,  104,  105,  104,  105,
      105,  308,  105,  104,  104,  104,   73,  105,  105,  105,
      306,  314,  104,  309,  311,  310,  105,   71,   71,  312,

       69,   69,  314,  314,  314,  314,  314,  314,  314,  314,
      314,  314,  314,  313,   68,   68,   68,   68,   68,   68,
       68,   68,   68,   68,   68,   68,   68,   70,   70,   70,
       70,   70,   70,   70,   70,   70,   70,   70,   70,   70,
       75,  314,   75,   75,   75,   75,   75,   75,   75,   75,
       75,   75,   75,   78,   78,   78,   78,   78,   78,   78,
       78,   78,   78,   78,   78,   78,   82,  314,   82,   82,
       82,   82,   82,   82,   82,   82,   82,   82,   82,   96,
      314,  314,  314,  314,  314,   96,   96,  314,   96,  103,
      103,  103,  103,  314,  103,  103,  314,  103,  134,  314,

      314,  134,  134,  314,  134,  136,  136,  136,  136,  314,
      136,  136,  314,  136,  139,  139,  139,  139,  139,  139,
      139,  139,  139,  139,  139,  139,  139,  142,  142,  142,
      142,  142,  142,  142,  142,  142,  142,  142,  142,  142,
      154,  154,  154,  154,  154,  154,  154,  154,  154,  154,
      154,  154,  154,  162,  162,  162,  162,  314,  314,  162,
      162,  314,  162,  164,  164,  164,  164,  164,  164,  164,
      164,  164,  164,  164,  164,  164,  195,  195,  314,  195,
      232,  232,  232,  314,  314,  232,  232,  314,  232,  234,
      314,  234,  314,  314,  234,  314,  234,  234,  237,  237,

      237,  237,  238,  314,  238,  314,  314,  238,  314,  238,
      238,  241,  241,  241,  241,  264,  264,  314,  264,  265,
      265,  314,  265,  265,  265,  265,  265,  314,  265,  265,
      265,  265,  267,  267,  267,  267,  314,  267,  267,  314,
      267,  269,  269,  314,  269,  270,  270,  314,  270,  270,
      270,  270,  270,  314,  270,  270,  270,  270,  272,  272,
      272,  272,  314,  272,  272,  314,  272,  286,  286,  286,
      314,  314,  286,  286,  314,  286,  288,  288,  288,  288,
      288,  288,  288,  288,  288,  288,  288,  288,  288,  290,
      290,  290,  314,  314,  290,  290,  314,  290,  292,  292,

      292,  292,  292,  292,  292,  292,  292,  292,  292,  292,
      292,   11,  314,  314,  314,  314,  314,  314,  314,  314,
      314,  314,  314,  314,  314,  314,  314,  314,  314,  314,
      314,  314,  314,  314,  314,  314,  314,  314,  314,  314,
      314,  314,  314,  314,  314,  314,  314,  314,  314,  314,
      314,  314,  314,  314,  314,  314,  314,  314,  314,  314,
      314,  314,  314,  314,  314,  314,  314,  314,  314,  314,
      314,  314,  314
    } ;

static yyconst flex_int16_t yy_chk[1274] =
    {   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,   13,   17,   21,   13,   18,   18,   25,
       30,   25,   25,   27,   29,   27,   27,   28,   28,   29,

      331,   30,   65,   30,   30,   65,   31,   38,   42,   40,
       44,   38,   42,   40,   44,  330,   30,   31,   67,   31,
       31,   50,   67,   30,  100,   50,   72,   21,  135,   72,
       17,  135,   31,   30,   40,   38,   50,   44,  100,   31,
       34,   34,   34,   34,   34,   34,   34,   34,   34,   34,
       34,   34,   34,   34,   34,   34,   34,   34,   34,   34,
       34,   34,   34,   34,   34,   34,   34,   34,   34,   34,
       34,   34,   34,   34,   34,   34,   34,   34,   34,   34,
       34,   34,   34,   34,   34,   34,   34,   34,   34,   34,
       34,   34,   34,   34,   34,   34,   34,   34,   34,   34,

       34,   39,   41,   43,   45,   39,   41,   43,   45,   82,
       75,   49,   39,   41,   43,   49,   46,   41,  145,   52,
       46,   41,   43,   52,   51,   47,   39,   46,   51,   47,
       43,   76,   45,   48,   39,   46,   47,   48,   49,   51,
       39,   41,   43,   53,   54,  145,   52,   53,   54,   48,
       58,   82,   76,   51,   58,   46,   75,   78,   78,   48,
       48,  292,   54,   83,   47,   85,   85,   53,   86,  291,
       86,   86,   87,   87,   89,   89,   91,   91,   58,   76,
       83,   96,   92,   86,  290,   87,   93,   96,   93,   91,
      103,   93,   93,   92,  103,   92,   92,  288,  104,  107,

       94,   94,  104,  107,  154,  154,  287,   83,   92,   94,
       94,   94,   94,   94,   94,   92,  108,  106,  109,  110,
      108,  106,  109,  110,  111,  159,  159,  107,  111,  112,
      106,  113,  114,  112,  286,  113,  114,   94,  106,  271,
      115,  116,  270,  110,  115,  116,  108,  117,  118,  160,
      160,  117,  118,  111,  114,  149,  269,  112,  117,  113,
      118,  119,  115,  266,  120,  119,  116,  118,  120,  121,
      118,  123,  122,  121,  265,  123,  122,  124,  118,  125,
      126,  124,  149,  125,  126,  119,  117,  120,  122,  127,
      162,  124,  121,  127,  125,  128,  162,  126,  129,  128,

      123,  130,  129,  131,  136,  130,  137,  131,  136,  163,
      137,  127,  167,  157,  157,  163,  167,  264,  131,  153,
      130,  153,  128,  240,  153,  153,  157,  158,  129,  158,
      161,  161,  158,  158,  168,  199,  238,  199,  168,  161,
      161,  161,  161,  161,  161,  169,  170,  171,  172,  169,
      170,  171,  172,  173,  174,  202,  202,  173,  174,  172,
      169,  175,  203,  203,  176,  175,  173,  161,  176,  177,
      170,  236,  178,  177,  179,  171,  178,  180,  179,  234,
      181,  180,  233,  174,  181,  232,  182,  172,  200,  175,
      182,  183,  177,  176,  198,  183,  179,  184,  178,  181,

      197,  184,  185,  182,  180,  186,  185,  187,  196,  186,
      183,  187,  184,  188,  191,  195,  189,  188,  191,  190,
      189,  192,  187,  190,  186,  192,  204,  204,  193,  188,
      185,  189,  193,  194,  190,  207,  192,  194,  201,  207,
      201,  205,  205,  208,  209,  210,  166,  208,  209,  210,
      211,  212,  213,  193,  211,  212,  213,  208,  215,  218,
      194,  214,  215,  218,  216,  214,  165,  213,  216,  164,
      212,  156,  152,  209,  210,  217,  214,  211,  218,  217,
      219,  220,  216,  221,  219,  220,  217,  221,  222,  148,
      223,  224,  222,  225,  223,  224,  226,  225,  144,  227,

      226,  143,  222,  227,  220,  223,  228,  229,  142,  219,
      228,  229,  221,  230,  217,  226,  224,  230,  231,  228,
      225,  237,  231,  241,  242,  237,  243,  241,  242,  141,
      243,  227,  244,  231,  246,  245,  244,  230,  246,  245,
      247,  248,  249,  250,  247,  248,  249,  250,  251,  140,
      139,  252,  251,  243,  245,  252,  254,  255,  246,  253,
      254,  255,  105,  253,  101,  244,  252,  250,  248,  257,
      253,  256,  258,  257,  259,  256,  258,  260,  259,  261,
      262,  260,  263,  261,  262,  267,  263,  268,  272,  267,
      273,  268,  272,  257,  273,  274,   97,  275,  253,  274,

      256,  275,   80,  276,   71,  277,  259,  276,  261,  277,
      278,   70,  279,  280,  278,  276,  279,  280,  277,   69,
      281,   68,  282,  275,  281,  274,  282,  283,  284,   60,
      285,  283,  284,  279,  285,  294,   57,  295,  283,  294,
      280,  295,  296,  297,   36,   32,  296,  297,  294,  281,
      298,  299,  295,   20,  298,  299,  300,  296,   16,  301,
      300,  303,  299,  301,  302,  303,  283,  304,  302,  300,
      305,  304,  297,  306,  305,  308,  307,  306,  309,  308,
      307,  301,  309,  310,  311,  312,   15,  310,  311,  312,
      299,   11,  313,  302,  307,  306,  313,   10,    9,  311,

        8,    7,    0,    0,    0,    0,    0,    0,    0,    0,
        0,    0,    0,  312,  315,  315,  315,  315,  315,  315,
      315,  315,  315,  315,  315,  315,  315,  316,  316,  316,
      316,  316,  316,  316,  316,  316,  316,  316,  316,  316,
      317,    0,  317,  317,  317,  317,  317,  317,  317,  317,
      317,  317,  317,  318,  318,  318,  318,  318,  318,  318,
      318,  318,  318,  318,  318,  318,  319,    0,  319,  319,
      319,  319,  319,  319,  319,  319,  319,  319,  319,  320,
        0,    0,    0,    0,    0,  320,  320,    0,  320,  321,
      321,  321,  321,    0,  321,  321,    0,  321,  322,    0,

        0,  322,  322,    0,  322,  323,  323,  323,  323,    0,
      323,  323,    0,  323,  324,  324,  324,  324,  324,  324,
      324,  324,  324,  324,  324,  324,  324,  325,  325,  325,
      325,  325,  325,  325,  325,  325,  325,  325,  325,  325,
      326,  326,  326,  326,  326,  326,  326,  326,  326,  326,
      326,  326,  326,  327,  327,  327,  327,    0,    0,  327,
      327,    0,  327,  328,  328,  328,  328,  328,  328,  328,
      328,  328,  328,  328,  328,  328,  329,  329,    0,  329,
      332,  332,  332,    0,    0,  332,  332,    0,  332,  333,
        0,  333,    0,    0,  333,    0,  333,  333,  334,  334,

      334,  334,  335,    0,  335,    0,    0,  335,    0,  335,
      335,  336,  336,  336,  336,  337,  337,    0,  337,  338,
      338,    0,  338,  338,  338,  338,  338,    0,  338,  338,
      338,  338,  339,  339,  339,  339,    0,  339,  339,    0,
      339,  340,  340,    0,  340,  341,  341,    0,  341,  341,
      341,  341,  341,    0,  341,  341,  341,  341,  342,  342,
      342,  342,    0,  342,  342,    0,  342,  343,  343,  343,
        0,    0,  343,  343,    0,  343,  344,  344,  344,  344,
      344,  344,  344,  344,  344,  344,  344,  344,  344,  345,
      345,  345,    0,    0,  345,  345,    0,  345,  346,  346,

      346,  346,  346,  346,  346,  346,  346,  346,  346,  346,
      346,  314,  314,  314,  314,  314,  314,  314,  314,  314,
      314,  314,  314,  314,  314,  314,  314,  314,  314,  314,
      314,  314,  314,  314,  314,  314,  314,  314,  314,  314,
      314,  314,  314,  314,  314,  314,  314,  314,  314,  314,
      314,  314,  314,  314,  314,  314,  314,  314,  314,  314,
      314,  314,  314,  314,  314,  314,  314,  314,  314,  314,
      314,  314,  314
    } ;

/* 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
 *
 * $Id: sparql_lexer.l 11543 2006-10-25 05:58:44Z dajobe $
 *
 * Copyright (C) 2004-2006, David Beckett http://purl.org/net/dajobe/
 * 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 */

/* definitions */
#line 76 "./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>

#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)
 *   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_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_flags;


static int rasqal_sparql_name_check(const 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(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);


/*
 * 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.
 */
/* 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 */
/* The initial char conditions are to ensure this doesn't grab < or <= */
#line 1015 "sparql_lexer.c"

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

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

/* 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
#define YY_READ_BUF_SIZE 8192
#endif

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

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

#endif

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

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

/* Report a fatal error. */
#ifndef YY_FATAL_ERROR
#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , 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 245 "./sparql_lexer.l"

  /* rules */

  int c;
  rasqal_query *rq=(rasqal_query*)yyextra;
  rasqal_sparql_query_engine *rqe=(rasqal_sparql_query_engine*)rq->context;


#line 1243 "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 >= 315 )
                              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 != 314 );
            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 253 "./sparql_lexer.l"
{ /* C++ comment */
        rqe->lineno++;
}
      YY_BREAK
case 2:
YY_RULE_SETUP
#line 257 "./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 263 "./sparql_lexer.l"
{ rqe->lineno++; }
      YY_BREAK
case 4:
YY_RULE_SETUP
#line 265 "./sparql_lexer.l"
{ /* eat up other whitespace */
      ;
}
      YY_BREAK
case 5:
YY_RULE_SETUP
#line 269 "./sparql_lexer.l"
{ return SELECT; }
      YY_BREAK
case 6:
YY_RULE_SETUP
#line 270 "./sparql_lexer.l"
{ return FROM; }
      YY_BREAK
case 7:
YY_RULE_SETUP
#line 271 "./sparql_lexer.l"
{ return WHERE; }
      YY_BREAK
case 8:
YY_RULE_SETUP
#line 272 "./sparql_lexer.l"
{ BEGIN(PREF);
            return PREFIX; }
      YY_BREAK
case 9:
YY_RULE_SETUP
#line 274 "./sparql_lexer.l"
{ return DESCRIBE; }
      YY_BREAK
case 10:
YY_RULE_SETUP
#line 275 "./sparql_lexer.l"
{ return CONSTRUCT; }
      YY_BREAK
case 11:
YY_RULE_SETUP
#line 276 "./sparql_lexer.l"
{ return ASK; }
      YY_BREAK
case 12:
YY_RULE_SETUP
#line 277 "./sparql_lexer.l"
{ return DISTINCT; }
      YY_BREAK
case 13:
YY_RULE_SETUP
#line 278 "./sparql_lexer.l"
{ return LIMIT; }
      YY_BREAK
case 14:
YY_RULE_SETUP
#line 279 "./sparql_lexer.l"
{ return UNION; }
      YY_BREAK
case 15:
YY_RULE_SETUP
#line 280 "./sparql_lexer.l"
{ return OPTIONAL; }
      YY_BREAK
case 16:
YY_RULE_SETUP
#line 281 "./sparql_lexer.l"
{ return BASE; }
      YY_BREAK
case 17:
YY_RULE_SETUP
#line 282 "./sparql_lexer.l"
{ return BOUND; }
      YY_BREAK
case 18:
YY_RULE_SETUP
#line 283 "./sparql_lexer.l"
{ return STR; }
      YY_BREAK
case 19:
YY_RULE_SETUP
#line 284 "./sparql_lexer.l"
{ return LANG; }
      YY_BREAK
case 20:
YY_RULE_SETUP
#line 285 "./sparql_lexer.l"
{ return DATATYPE; }
      YY_BREAK
case 21:
YY_RULE_SETUP
#line 286 "./sparql_lexer.l"
{ return ISURI; }
      YY_BREAK
case 22:
YY_RULE_SETUP
#line 287 "./sparql_lexer.l"
{ return ISBLANK; }
      YY_BREAK
case 23:
YY_RULE_SETUP
#line 288 "./sparql_lexer.l"
{ return ISLITERAL; }
      YY_BREAK
case 24:
YY_RULE_SETUP
#line 289 "./sparql_lexer.l"
{ return GRAPH; }
      YY_BREAK
case 25:
YY_RULE_SETUP
#line 290 "./sparql_lexer.l"
{ return NAMED; }
      YY_BREAK
case 26:
YY_RULE_SETUP
#line 291 "./sparql_lexer.l"
{ return FILTER; }
      YY_BREAK
case 27:
YY_RULE_SETUP
#line 292 "./sparql_lexer.l"
{ return OFFSET; }
      YY_BREAK
case 28:
YY_RULE_SETUP
#line 293 "./sparql_lexer.l"
{ return ORDER; }
      YY_BREAK
case 29:
YY_RULE_SETUP
#line 294 "./sparql_lexer.l"
{ return BY; }
      YY_BREAK
case 30:
YY_RULE_SETUP
#line 295 "./sparql_lexer.l"
{ return REGEX; }
      YY_BREAK
case 31:
YY_RULE_SETUP
#line 296 "./sparql_lexer.l"
{ return ASC; }
      YY_BREAK
case 32:
YY_RULE_SETUP
#line 297 "./sparql_lexer.l"
{ return DESC; } 
      YY_BREAK
case 33:
YY_RULE_SETUP
#line 298 "./sparql_lexer.l"
{ return LANGMATCHES; } 
      YY_BREAK
case 34:
YY_RULE_SETUP
#line 300 "./sparql_lexer.l"
{ return A; }
      YY_BREAK
case 35:
YY_RULE_SETUP
#line 302 "./sparql_lexer.l"
{ return ','; } 
      YY_BREAK
case 36:
YY_RULE_SETUP
#line 303 "./sparql_lexer.l"
{ return '('; } 
      YY_BREAK
case 37:
YY_RULE_SETUP
#line 304 "./sparql_lexer.l"
{ return ')'; } 
      YY_BREAK
case 38:
YY_RULE_SETUP
#line 305 "./sparql_lexer.l"
{ return '['; }
      YY_BREAK
case 39:
YY_RULE_SETUP
#line 306 "./sparql_lexer.l"
{ return ']'; }
      YY_BREAK
case 40:
YY_RULE_SETUP
#line 307 "./sparql_lexer.l"
{ BEGIN(ID); return '?'; }
      YY_BREAK
case 41:
YY_RULE_SETUP
#line 308 "./sparql_lexer.l"
{ BEGIN(ID); return '$'; }
      YY_BREAK
case 42:
YY_RULE_SETUP
#line 309 "./sparql_lexer.l"
{ return '{'; } 
      YY_BREAK
case 43:
YY_RULE_SETUP
#line 310 "./sparql_lexer.l"
{ return '}'; } 
      YY_BREAK
case 44:
YY_RULE_SETUP
#line 311 "./sparql_lexer.l"
{ return '.'; } 
      YY_BREAK
case 45:
YY_RULE_SETUP
#line 312 "./sparql_lexer.l"
{ return ';'; } 
      YY_BREAK
case 46:
YY_RULE_SETUP
#line 314 "./sparql_lexer.l"
{ return SC_OR; }
      YY_BREAK
case 47:
YY_RULE_SETUP
#line 315 "./sparql_lexer.l"
{ return SC_AND; }
      YY_BREAK
case 48:
YY_RULE_SETUP
#line 317 "./sparql_lexer.l"
{ return EQ; }
      YY_BREAK
case 49:
YY_RULE_SETUP
#line 318 "./sparql_lexer.l"
{ return NEQ; }
      YY_BREAK
case 50:
/* rule 50 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 319 "./sparql_lexer.l"
{ return LT; }
      YY_BREAK
case 51:
YY_RULE_SETUP
#line 320 "./sparql_lexer.l"
{ return GT; }
      YY_BREAK
case 52:
YY_RULE_SETUP
#line 321 "./sparql_lexer.l"
{ return LE; }
      YY_BREAK
case 53:
YY_RULE_SETUP
#line 322 "./sparql_lexer.l"
{ return GE; }
      YY_BREAK
case 54:
YY_RULE_SETUP
#line 324 "./sparql_lexer.l"
{ return '+'; }
      YY_BREAK
case 55:
YY_RULE_SETUP
#line 325 "./sparql_lexer.l"
{ return '-'; }
      YY_BREAK
case 56:
YY_RULE_SETUP
#line 326 "./sparql_lexer.l"
{ return '*'; }
      YY_BREAK
case 57:
YY_RULE_SETUP
#line 327 "./sparql_lexer.l"
{ return '/'; }
      YY_BREAK
case 58:
YY_RULE_SETUP
#line 328 "./sparql_lexer.l"
{ return '!'; }
      YY_BREAK
case 59:
YY_RULE_SETUP
#line 330 "./sparql_lexer.l"
{ c=yytext[yyleng-1];
                  if (c== 'l' || c == 'L')
                    yytext[yyleng-1]='\0';
                  sparql_parser_lval->literal=rasqal_new_integer_literal(RASQAL_LITERAL_INTEGER, atoi(yytext));
              return INTEGER_LITERAL; 
}
      YY_BREAK
case 60:
YY_RULE_SETUP
#line 337 "./sparql_lexer.l"
{ int i;
                      int n;
                      if(yytext[yyleng+1] == 'x') 
                        n=sscanf(yytext+2, "%x", &i);
                      else
                        n=sscanf(yytext+2, "%X", &i);
                      if(n != 1) {
                        sparql_syntax_error(rq, "SPARQL syntax error - Illegal hex constant %c%c%c",
                                          yytext[0], yytext[1], yytext[2]);
                        yyterminate();
                      }
                      sparql_parser_lval->literal=rasqal_new_integer_literal(RASQAL_LITERAL_INTEGER, i);
                      return INTEGER_LITERAL; 
}
      YY_BREAK
case 61:
YY_RULE_SETUP
#line 352 "./sparql_lexer.l"
{ 
                        double d;
                        int n;
                        
                        n=sscanf((const char*)yytext, "%lf", &d);
                        if(n != 1) {
                          sparql_syntax_error(rq, "SPARQL syntax error - Illegal decimal constant %s", yytext);
                          yyterminate();
                        }
                        sparql_parser_lval->literal=rasqal_new_decimal_literal((const unsigned char*)yytext);
                        return DECIMAL_LITERAL;
}
      YY_BREAK
case 62:
YY_RULE_SETUP
#line 365 "./sparql_lexer.l"
{
                        double d;
                        int n;
                        
                        n=sscanf((const char*)yytext, "%lf", &d);
                        if(n != 1) {
                          sparql_syntax_error(rq, "SPARQL syntax error - Illegal floating point constant %s", yytext);
                          yyterminate();
                        }
                        sparql_parser_lval->literal=rasqal_new_double_literal(d);
                        return FLOATING_POINT_LITERAL;
}
      YY_BREAK
case 63:
/* rule 63 can match eol */
YY_RULE_SETUP
#line 378 "./sparql_lexer.l"
{ /*' */
                        sparql_copy_string_token(rq, sparql_parser_lval,
                          (const unsigned char*)yytext+1, yyleng-1, '\'');
                        return STRING_LITERAL; }
      YY_BREAK
case 64:
/* rule 64 can match eol */
YY_RULE_SETUP
#line 383 "./sparql_lexer.l"
{ /* " */
                        sparql_copy_string_token(rq, sparql_parser_lval,
                          (const unsigned char*)yytext+1, yyleng-1, '"');
                        return STRING_LITERAL; }
      YY_BREAK
case 65:
YY_RULE_SETUP
#line 388 "./sparql_lexer.l"
{ BEGIN(LITERAL); }
      YY_BREAK
case 66:
/* rule 66 can match eol */
YY_RULE_SETUP
#line 390 "./sparql_lexer.l"
{ sparql_copy_string_token(rq, sparql_parser_lval, 
                            (unsigned char*)yytext, yyleng-3, '"'); /* ' */
                          BEGIN(INITIAL);
                          return STRING_LITERAL; }
      YY_BREAK
case 67:
/* rule 67 can match eol */
YY_RULE_SETUP
#line 395 "./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 68:
YY_RULE_SETUP
#line 403 "./sparql_lexer.l"
{ BEGIN(LITERAL2); }
      YY_BREAK
case 69:
/* rule 69 can match eol */
YY_RULE_SETUP
#line 405 "./sparql_lexer.l"
{ sparql_copy_string_token(rq, sparql_parser_lval, 
                            (unsigned char*)yytext, yyleng-3, '\'');
                          BEGIN(INITIAL);
                          return STRING_LITERAL; }
      YY_BREAK
case 70:
/* rule 70 can match eol */
YY_RULE_SETUP
#line 410 "./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 71:
YY_RULE_SETUP
#line 418 "./sparql_lexer.l"
{ sparql_parser_lval->literal=rasqal_new_boolean_literal(1);
                  return BOOLEAN_LITERAL; }
      YY_BREAK
case 72:
YY_RULE_SETUP
#line 421 "./sparql_lexer.l"
{ sparql_parser_lval->literal=rasqal_new_boolean_literal(0);
                  return BOOLEAN_LITERAL; }
      YY_BREAK
case 73:
YY_RULE_SETUP
#line 424 "./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)
                    yyterminate();
                          BEGIN(INITIAL);
                          return IDENTIFIER; }
      YY_BREAK
case 74:
/* rule 74 can match eol */
YY_RULE_SETUP
#line 429 "./sparql_lexer.l"
{     BEGIN(INITIAL);
            sparql_syntax_error(rq, "SPARQL syntax error - missing variable name after ?");
                yyterminate();
}
      YY_BREAK
case 75:
YY_RULE_SETUP
#line 435 "./sparql_lexer.l"
{ /* eat up leading whitespace */ }
      YY_BREAK
case 76:
YY_RULE_SETUP
#line 436 "./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)
                      yyterminate();
                          return IDENTIFIER; }
      YY_BREAK
case 77:
YY_RULE_SETUP
#line 441 "./sparql_lexer.l"
{ BEGIN(INITIAL);
              sparql_parser_lval->name=NULL;
                  return IDENTIFIER; }
      YY_BREAK
case 78:
/* rule 78 can match eol */
YY_RULE_SETUP
#line 445 "./sparql_lexer.l"
{ BEGIN(INITIAL);
              if (!*yytext)
                    return EOF;

                  sparql_syntax_error(rq, "SPARQL syntax error at '%c'", *yytext);
                  yyterminate();
}
      YY_BREAK
case 79:
YY_RULE_SETUP
#line 453 "./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)
              yyterminate();
            return have_brace ? URI_LITERAL_BRACE : URI_LITERAL;
}
      YY_BREAK
case 80:
YY_RULE_SETUP
#line 463 "./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 81:
/* rule 81 can match eol */
YY_RULE_SETUP
#line 467 "./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,
                                                                (raptor_simple_message_handler)sparql_syntax_error, rq);
                  if(!uri_string)
                    yyterminate();

                  sparql_parser_lval->uri=raptor_new_uri_relative_to_base(rq->base_uri, uri_string);
                  RASQAL_FREE(cstring, uri_string);
                 }
                 return have_brace ? URI_LITERAL_BRACE : URI_LITERAL; }
      YY_BREAK
case 82:
/* rule 82 can match eol */
YY_RULE_SETUP
#line 489 "./sparql_lexer.l"
{ /* # comment */
            rqe->lineno++;
                }
      YY_BREAK
case 83:
YY_RULE_SETUP
#line 493 "./sparql_lexer.l"
{ if (!*yytext)
                    return EOF;

                  sparql_syntax_error(rq, "SPARQL syntax error at '%c'", *yytext);
                  yyterminate();
            }
      YY_BREAK
case 84:
YY_RULE_SETUP
#line 500 "./sparql_lexer.l"
YY_FATAL_ERROR( "flex scanner jammed" );
      YY_BREAK
#line 1887 "sparql_lexer.c"
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(ID):
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;

      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 >= 315 )
                        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 >= 315 )
                  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 == 314);

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

            /* 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 bytes the byte buffer to scan
 * @param 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

static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner)
{
      (void) fprintf( stderr, "%s\n", msg );
      exit( YY_EXIT_FAILURE );
}

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

#undef yyless
#define yyless(n) \
      do \
            { \
            /* Undo effects of setting up yytext. */ \
        int yyless_macro_arg = (n); \
        YY_LESS_LINENO(yyless_macro_arg);\
            yytext[yyleng] = 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" , yyscanner); 
    
    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" , yyscanner); 
    
    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 );
}

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

void *sparql_lexer_alloc (yy_size_t  size , yyscan_t yyscanner)
{
      return (void *) malloc( size );
}

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

void sparql_lexer_free (void * ptr , yyscan_t yyscanner)
{
      if(ptr) free( (char *) ptr ); /* see sparql_lexer_realloc() for (char *) cast */
}

#define YYTABLES_NAME "yytables"

#line 500 "./sparql_lexer.l"


  /* user code */

int
sparql_lexer_wrap (yyscan_t yyscanner) {
  return 1;
}


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

  if(!length)
    return 1;

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

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

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


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,
                                       (raptor_simple_message_handler)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,
                                       (raptor_simple_message_handler)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 */
  uri=raptor_new_uri_relative_to_base(rq->base_uri, s);
#else
  if(!rq->namespaces) {
    sparql_syntax_error(rq, "SPARQL syntax error - no namespaces declared");
    return NULL;
  }
  
  uri=raptor_qname_string_to_uri(rq->namespaces,
                                 s, dest_len,
                                 (raptor_simple_message_handler)rasqal_query_simple_error, rq);
#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=(unsigned char *)RASQAL_MALLOC(cstring, len+1);
  char *language=NULL;
  unsigned char *dt=NULL;
  raptor_uri *dt_uri=NULL;
  unsigned char *dt_qname=NULL;

  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 == 't')
        *d++= '\t';
      else if(c == '\\' || c == delim)
        *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 delim */
      s++; i++;

      c=*s++; i++;
      if(c=='@') {
        language=(char*)d;
        while(i<=len) {
          c=*s++; i++;
          if(!isalpha(c) && !isdigit(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=(char *)RASQAL_MALLOC(cstring, strlen((const char*)language)+1);
    strcpy(new_language, language);
    language=new_language;
  }
  
  if(dt) {
    /* dt can be a URI or qname */
    if(*dt == '<') {
      dt[strlen((const char*)dt)-1]='\0';
      dt_uri=raptor_new_uri(dt+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,
                                              (raptor_simple_message_handler)sparql_syntax_error, rq);
      if(!dt_s)
        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;
      }
  
      dt_uri=raptor_qname_string_to_uri(rq->namespaces,
                                        dt_s, dest_len,
                                        (raptor_simple_message_handler)rasqal_query_simple_error, rq);
      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(string, language, dt_uri, dt_qname);

  return 0;
}


static int
sparql_skip_c_comment(rasqal_query *rq) {
  rasqal_sparql_query_engine *rqe=(rasqal_sparql_query_engine*)rq->context;
  yyscan_t yyscanner=rqe->scanner;
  int lines=0;
  int c;
  int lastc= -1;
  
  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;
}


#ifdef RASQAL_DEBUG

const char *
sparql_token_print(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 INTEGER_LITERAL:
      sprintf(buffer, "INTEGER_LITERAL(%d)", lval->literal->value.integer);
      return buffer;

    case FLOATING_POINT_LITERAL:
      sprintf(buffer, "FLOATING_POINT_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:
      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(int token, YYSTYPE *lval)
{
  if(!token)
    return;
  
  switch(token) {
    case STRING_LITERAL:
      rasqal_free_literal(lval->literal);
      break;
    case URI_LITERAL:
      raptor_free_uri(lval->uri);
      break;
    case IDENTIFIER:
    case BLANK_LITERAL:
      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_engine 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_init();
  
  if(argc > 1) {
    FILE *fh;
    query_string=(char*)RASQAL_CALLOC(cstring, FILE_READ_BUF_SIZE, 1);
    filename=argv[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);
    }
  } else {
    filename="<stdin>";
    query_string=(char*)RASQAL_CALLOC(cstring, FILE_READ_BUF_SIZE, 1);
    fread(query_string, FILE_READ_BUF_SIZE, 1, stdin);
  }

  memset(&rq, 0, sizeof(rasqal_query));
  memset(&sparql, 0, sizeof(rasqal_sparql_query_engine));

  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);
  rq.base_uri=raptor_new_uri(uri_string);
  raptor_free_memory((void*)uri_string);

  while(1) {
    memset(&lval, 0, sizeof(YYSTYPE));
    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(token, &lval));
#else
    printf("token %d\n", token);
#endif
    sparql_token_free(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_finish();

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


Generated by  Doxygen 1.6.0   Back to index