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 31
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif

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

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

/* end standard C headers. */

/* flex integer type definitions */

#ifndef FLEXINT_H
#define FLEXINT_H

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

#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
#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

#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[309] =
    {   0,
        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
       85,   83,    4,    3,    3,   59,   83,   82,   40,   57,
       83,   83,   35,   36,   55,   53,   34,   54,   43,   56,
       60,   60,   79,   44,   83,   47,   50,   39,   83,   83,
       83,   83,   83,   83,   83,   83,   83,   83,   83,   83,
       83,   83,   83,   83,   37,   38,   83,   33,   83,   83,
       83,   41,   83,   42,   58,   74,   73,   78,   75,   77,
       78,   67,   67,   70,   70,    4,    3,   48,    0,   64,
        0,   46,    0,   63,    0,    0,    2,    1,   60,   62,
       60,    0,    0,   79,   79,   49,   49,   51,   81,    0,

       52,    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,
        0,   45,   73,   75,    0,   76,    0,    0,    0,    0,
        0,    0,   64,   65,    0,    0,   63,   68,    0,    0,
        0,   62,    0,    0,   62,   61,   79,    0,   81,   81,
       79,   31,   11,    0,    0,    0,    0,    0,    0,    0,
        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
        0,    0,    0,    0,   18,    0,    0,   80,    0,    0,
        0,   66,   69,   64,    0,   63,    0,    0,   62,    0,

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

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

       59,   60,   36,   37,   38,   39,   40,   61,   42,   62,
       44,   45,   39,   63,   64,   65,   66,   39,   50,   51,
       52,   39,   67,   68,   69,   70,    1,   71,   71,   71,
       71,   71,   71,   71,   71,   71,   71,   71,   71,   71,
       71,   71,   71,   71,   71,   71,   71,   71,   71,   71,
       71,   71,   71,   71,   71,   71,   71,   71,   71,   71,
       71,   71,   71,   71,   71,   71,   71,   71,   71,   71,
       71,   71,   71,   71,   71,   71,   71,   71,   71,   71,
       71,   71,   71,   71,   71,   71,   71,   71,   71,   71,
       71,   71,   71,   71,   71,   71,   71,   71,   71,   71,

       71,   71,   71,   71,   71,   71,   71,   71,   71,   71,
       71,   71,   71,   71,   71,   71,   71,   71,   71,   71,
       71,   71,   71,   71,   71,   71,   71,   71,   71,   71,
       71,   71,   71,   71,   71,   71,   71,   71,   71,   71,
       71,   71,   71,   71,   71,   71,   71,   71,   71,   71,
       71,   71,   71,   71,   71
    } ;

static yyconst flex_int32_t yy_meta[72] =
    {   0,
        1,    1,    2,    2,    3,    1,    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,   11,   11,   11,   11,   11,
       11,   11,   11,   11,   11,   11,   11,   11,   11,   11,
       11,   11,    1,   12,    1,   13,   14,   10,   10,   10,
       11,   11,   11,   11,   11,   11,    1,    1,    1,    1,
       12
    } ;

static yyconst flex_int16_t yy_base[346] =
    {   0,
        0,    0,   71,    0,  142,    0, 1089, 1084, 1075, 1074,
     1081, 1103,  212, 1103, 1059, 1032,  208, 1103, 1103, 1103,
     1046,  204, 1103, 1103, 1103, 1103, 1103, 1103,  197,  205,
      214,  219, 1039, 1103,  280, 1103, 1007, 1103,  199,  329,
      200,  209, 1006,  211,  206,  207,  330,  201,  331,  332,
      333,  338,  339,  205, 1103, 1103, 1005,  342,  347,  341,
      214, 1103,  955, 1103, 1103, 1103,    0, 1103,  259, 1103,
      996, 1002,  996,  987,  982,  274, 1103, 1103,  350,  367,
        0, 1103,  346,  386,    0,  387, 1103, 1103, 1103,  390,
      395,  404,    0, 1103,  977,  953, 1103, 1103,  243,  947,

     1103,  947,  946,  395,  396,  408,  933,  390,  405,  411,
      414,  407,  222,  409,  424,  421,  417,  427,  428,  439,
      346,  443,  448,  453,  449,  352,  457,    0,  418,  458,
      459, 1103,    0,  378,  932, 1103,  946,  937,  934,  928,
      926,  923,  457, 1103,    0,  875,  464, 1103,    0,  874,
      485,  475,  505,  229,  489,    0,  912,  894,  907,  887,
      896,  882,  881,  494,  475,  482,  485,  507,  508,  509,
      510,  513,  518,  512,  515,  519,  522,  517,  521,  524,
      531,  540,  543,  546,  880,  340,  525,    0,  544,  549,
      547,  895,  889,  828,  558,  824,  559,  478,  574,  565,

      582, 1103, 1103,  866,  822,  566,  568,  570,  574,  575,
      588,  818,  589,  571,  591,  598,  812,  596,  605,  607,
      601,  600,  602,  541,  620,  608,  625,    0,  609,  808,
      807,  771,    0,  796,  794,  757,    0,  785,  788, 1103,
     1103,  787,  604,  626,  631,  630,  634,  786,  632,  637,
      772,  758,  725,  635,  639,  724,  642,  723,  641,  721,
      720,    0,  715,  713,  715,    0,    0,  710,  709,  712,
        0,  649,  654,  656,  653,  710,  651,  658,  708,  665,
      706,  704,    0,  699, 1103,    0,    0,  695, 1103,    0,
      679,  680,  682,  684,  697,  687,  667,    0,    0,  686,

      690,  663,  422,  689,  415,  249,  204, 1103,  751,  765,
      779,  793,  804,  814,  822,  832,  846,  860,  482,  871,
      885,  896,  901,  708,  714,  912,  922,  932,  939,  947,
      954,  957,  971,  981,  986, 1000, 1010, 1020, 1034, 1039,
     1049, 1063, 1068, 1078, 1088
    } ;

static yyconst flex_int16_t yy_def[346] =
    {   0,
      308,    1,  308,    3,  308,    5,  309,  309,  310,  310,
      308,  308,  308,  308,  308,  308,  311,  308,  308,  308,
      308,  312,  308,  308,  308,  308,  308,  308,  308,  308,
      308,  308,  313,  308,  308,  308,  308,  308,  314,  314,
      314,  314,  314,  314,  314,  314,  314,  314,  314,  314,
      314,  314,  314,  314,  308,  308,  308,  314,  314,  314,
      314,  308,  308,  308,  308,  308,  315,  308,  308,  308,
      316,  317,  317,  318,  318,  308,  308,  308,  311,  308,
      311,  308,  312,  308,  312,  308,  308,  308,  308,  308,
      308,  308,  319,  308,  320,  321,  308,  308,  321,  321,

      308,  314,  322,  314,  314,  314,  314,  314,  314,  314,
      314,  314,  314,  314,  314,  314,  314,  314,  314,  314,
      314,  314,  314,  314,  314,  314,  314,  323,  314,  314,
      314,  308,  315,  308,  316,  308,  317,  317,  317,  318,
      318,  318,  308,  308,  324,  308,  308,  308,  325,  308,
      308,  308,  308,  308,  308,  319,  320,  321,  308,  321,
      326,  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,  327,  314,  314,
      314,  317,  318,  328,  329,  330,  331,  308,  308,  308,

      308,  308,  308,  326,  314,  314,  314,  314,  314,  314,
      314,  314,  314,  314,  314,  314,  314,  314,  314,  314,
      314,  314,  314,  314,  314,  314,  314,  327,  314,  314,
      314,  328,  332,  333,  334,  330,  335,  336,  337,  308,
      308,  314,  314,  314,  314,  314,  314,  314,  314,  314,
      314,  314,  314,  314,  314,  314,  314,  314,  314,  314,
      314,  338,  339,  339,  334,  340,  341,  342,  342,  337,
      343,  314,  314,  314,  314,  314,  314,  314,  314,  314,
      314,  314,  338,  339,  308,  344,  341,  342,  308,  345,
      314,  314,  314,  314,  314,  314,  314,  344,  345,  314,

      314,  314,  314,  314,  314,  314,  314,    0,  308,  308,
      308,  308,  308,  308,  308,  308,  308,  308,  308,  308,
      308,  308,  308,  308,  308,  308,  308,  308,  308,  308,
      308,  308,  308,  308,  308,  308,  308,  308,  308,  308,
      308,  308,  308,  308,  308
    } ;

static yyconst flex_int16_t yy_nxt[1175] =
    {   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,   38,   12,   39,
       40,   41,   42,   43,   44,   45,   43,   46,   43,   43,
       47,   43,   48,   49,   50,   51,   52,   43,   53,   54,
       43,   43,   55,   43,   56,   12,   57,   58,   43,   59,
       47,   60,   51,   52,   61,   53,   62,   63,   64,   65,
       43,   66,   66,   66,   66,   66,   66,   66,   66,   66,
       66,   66,   66,   66,   66,   66,   66,   66,   66,   66,
       66,   67,   67,   66,   66,   66,   66,   66,   66,   66,

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

       71,   71,   71,   71,   71,   71,   71,   71,   68,   68,
       68,   68,   71,   76,   80,   84,   76,   86,   86,   87,
       89,  103,  103,  103,   88,   89,  103,  103,  103,  103,
      118,  103,   90,  103,   91,   91,  103,   90,  109,   91,
       91,  127,  110,  108,  103,  104,  111,   92,  112,  155,
      155,  114,   92,  115,   89,  160,  113,   85,  118,   89,
      134,   81,  104,  134,   93,  171,  109,  110,  114,  159,
      115,  103,   92,  113,   89,   76,  131,   92,   76,   89,
       96,   96,   96,   96,   97,   96,   96,   96,   96,   96,
       96,   96,   96,   96,   96,   96,   96,   96,   96,   96,

       96,   96,   96,   96,   97,   98,   99,   96,   96,  100,
      100,  100,  100,  100,  100,  100,  100,  100,  100,  100,
      100,  100,  100,  100,  100,  100,  100,  100,  100,  100,
      100,  100,   96,   96,   96,   96,   96,  100,  100,  100,
      100,  100,  100,  100,  100,  100,   96,   96,   96,   96,
       96,  103,  103,  103,  103,  103,  143,  147,  105,  116,
      103,  103,  103,  103,  103,  119,  123,  117,  103,  103,
      118,  124,  106,  144,  103,  120,  121,  122,  181,  134,
      107,  126,  134,  226,  112,  125,  105,  116,  104,  186,
      119,  123,  113,  121,  122,  145,  124,  148,  118,   85,

      126,   89,  125,   81,  129,  104,  130,   86,   86,  113,
      152,  152,  103,   90,  149,   91,   91,  103,  103,  154,
      151,  154,  146,  153,  155,  155,  162,  103,   92,  103,
      103,  103,  166,  103,  163,   89,  103,  103,  172,  103,
      103,  150,  164,  103,  103,  151,  103,  170,  153,  103,
      103,  166,  167,   92,  173,   89,  165,  168,  177,  164,
      169,  103,  179,  176,  174,  103,  172,  170,  178,  167,
      103,  103,  175,  165,  168,  103,  182,  169,  189,  103,
      103,  103,  176,  183,  174,  145,  180,  179,  156,  175,
      187,  156,  149,  184,  185,  152,  152,  103,  199,  199,

      198,  182,  198,  180,  103,  199,  199,  103,  153,  155,
      155,  185,  146,  184,  208,  187,  103,  206,  190,  150,
      200,  202,  200,  202,  191,  201,  201,  205,  207,  103,
      103,  103,  103,  153,  103,  103,  206,  103,  209,  103,
      103,  103,  208,  103,  103,  207,  103,  103,  202,  215,
      219,  212,  205,  103,  217,  210,  211,  213,  214,  218,
      216,  221,  103,  103,  222,  103,  103,  220,  103,  103,
      227,  103,  210,  211,  223,  219,  224,  216,  214,  225,
      233,  237,  234,  238,  220,  201,  201,  227,  103,  222,
      103,  258,  103,  103,  199,  199,  103,  103,  242,  223,

      249,  224,  201,  201,  225,  231,  240,  229,  240,  230,
      103,  103,  246,  103,  241,  243,  241,  244,  103,  245,
      103,  247,  103,  103,  103,  248,  103,  103,  249,  103,
      103,  103,  243,  240,  244,  251,  245,  253,  250,  257,
      254,  241,  103,  252,  255,  256,  247,  103,  103,  272,
      260,  259,  103,  103,  103,  250,  103,  103,  261,  103,
      252,  103,  256,  103,  103,  254,  272,  231,  274,  260,
      278,  103,  275,  103,  277,  103,  103,  273,  103,  276,
      103,  280,  279,  261,  294,  103,  293,  103,  282,  103,
      295,  275,  281,  277,  297,  278,  276,  291,  292,  279,

      280,  103,  103,  296,  103,  282,  103,  305,  103,  103,
      300,  103,  103,  301,  291,  302,  304,  194,  194,  103,
      296,  289,  297,  196,  196,  285,  103,  305,  103,  307,
      103,  303,  103,  306,  271,  289,  289,  266,  301,  285,
      302,  285,  103,  103,  304,  103,  103,  103,  303,  307,
      306,   72,   72,   72,   72,   72,   72,   72,   72,   72,
       72,   72,   72,   72,   72,   74,   74,   74,   74,   74,
       74,   74,   74,   74,   74,   74,   74,   74,   74,   79,
      103,   79,   79,   79,   79,   79,   79,   79,   79,   79,
       79,   79,   79,   83,  103,   83,   83,   83,   83,   83,

       83,   83,   83,   83,   83,   83,   83,   95,  103,  103,
      271,  269,  150,   95,   95,   95,  266,   95,  102,  102,
      102,  102,  264,  102,  102,  102,  146,  102,  133,  103,
      103,  133,  133,  133,  103,  133,  135,  135,  135,  135,
      103,  135,  135,  135,  103,  135,  137,  137,  137,  137,
      137,  137,  137,  137,  137,  137,  137,  137,  137,  137,
      140,  140,  140,  140,  140,  140,  140,  140,  140,  140,
      140,  140,  140,  140,  157,  157,  157,  157,   94,  150,
      157,  157,  157,  146,  157,  158,  158,  158,  158,  158,
      158,  158,  158,  158,  158,  158,  158,  158,  158,  161,

      193,  192,  103,  103,  103,  161,  161,  161,   94,  161,
      188,  188,  188,  159,  188,  204,  204,  204,  204,  203,
      159,  204,  204,  204,   94,  204,  228,  228,  228,  197,
      195,  228,  228,  228,  193,  228,  232,  142,  232,  141,
      192,  232,  232,  139,  232,  232,  235,  235,  235,  235,
      235,  236,  138,  236,  136,  103,  236,  236,   94,  236,
      236,  239,  239,  239,  239,  239,  262,  262,  262,  103,
      262,  263,  263,  159,  263,  263,  263,  263,  263,  159,
      263,  263,  263,  263,  263,  265,  265,  265,  265,   94,
      265,  265,  265,  142,  265,  267,  267,  267,  141,  267,

      268,  268,  139,  268,  268,  268,  268,  268,  138,  268,
      268,  268,  268,  268,  270,  270,  270,  270,  136,  270,
      270,  270,  132,  270,  283,  283,  283,  128,  103,  283,
      283,  283,  101,  283,  284,  284,  284,  284,  284,  284,
      284,  284,  284,  284,  284,  284,  284,  284,  286,  286,
      286,   94,  286,  287,  287,  287,   82,   78,  287,  287,
      287,   77,  287,  288,  288,  288,  288,  288,  288,  288,
      288,  288,  288,  288,  288,  288,  288,  290,  290,  290,
      308,  290,  298,  298,  298,   75,   75,  298,  298,  298,
       73,  298,  299,  299,  299,   73,  308,  299,  299,  299,

      308,  299,   11,  308,  308,  308,  308,  308,  308,  308,
      308,  308,  308,  308,  308,  308,  308,  308,  308,  308,
      308,  308,  308,  308,  308,  308,  308,  308,  308,  308,
      308,  308,  308,  308,  308,  308,  308,  308,  308,  308,
      308,  308,  308,  308,  308,  308,  308,  308,  308,  308,
      308,  308,  308,  308,  308,  308,  308,  308,  308,  308,
      308,  308,  308,  308,  308,  308,  308,  308,  308,  308,
      308,  308,  308,  308
    } ;

static yyconst flex_int16_t yy_chk[1175] =
    {   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,    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,    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,    5,    5,    5,    5,    5,    5,    5,
        5,    5,    5,   13,   17,   22,   13,   29,   29,   30,
       31,   39,   41,   48,   30,   32,  307,   54,   45,   46,
       48,   42,   31,   44,   31,   31,   61,   32,   42,   32,
       32,   54,   42,   41,  113,   39,   42,   31,   44,  154,
      154,   45,   32,   46,   31,   99,   44,   22,   48,   32,
       69,   17,   39,   69,   31,  113,   42,   42,   45,   99,
       46,  306,   31,   44,   31,   76,   61,   32,   76,   32,
       35,   35,   35,   35,   35,   35,   35,   35,   35,   35,
       35,   35,   35,   35,   35,   35,   35,   35,   35,   35,

       35,   35,   35,   35,   35,   35,   35,   35,   35,   35,
       35,   35,   35,   35,   35,   35,   35,   35,   35,   35,
       35,   35,   35,   35,   35,   35,   35,   35,   35,   35,
       35,   35,   35,   35,   35,   35,   35,   35,   35,   35,
       35,   35,   35,   35,   35,   35,   35,   35,   35,   35,
       35,   40,   47,   49,   50,   51,   79,   83,   40,   47,
       52,   53,  186,   60,   58,   49,   51,   47,  121,   59,
       60,   52,   40,   80,  126,   49,   49,   50,  121,  134,
       40,   53,  134,  186,   59,   52,   40,   47,   58,  126,
       49,   51,   59,   49,   50,   80,   52,   84,   60,   83,

       53,   91,   52,   79,   59,   58,   60,   86,   86,   59,
       90,   90,  108,   91,   84,   91,   91,  104,  105,   92,
       86,   92,   80,   90,   92,   92,  104,  109,   91,  112,
      106,  114,  108,  110,  104,   91,  111,  305,  114,  117,
      129,   84,  105,  116,  303,   86,  115,  112,   90,  118,
      119,  108,  109,   91,  115,   91,  106,  110,  117,  105,
      111,  120,  119,  116,  115,  122,  114,  112,  118,  109,
      123,  125,  115,  106,  110,  124,  122,  111,  129,  127,
      130,  131,  116,  123,  115,  143,  120,  119,  319,  115,
      127,  319,  147,  124,  125,  152,  152,  165,  198,  198,

      151,  122,  151,  120,  166,  151,  151,  167,  152,  155,
      155,  125,  143,  124,  167,  127,  164,  165,  130,  147,
      153,  155,  153,  155,  131,  153,  153,  164,  166,  168,
      169,  170,  171,  152,  174,  172,  165,  175,  168,  178,
      173,  176,  167,  179,  177,  166,  180,  187,  155,  174,
      178,  171,  164,  181,  176,  169,  170,  172,  173,  177,
      175,  180,  182,  224,  181,  183,  189,  179,  184,  191,
      187,  190,  169,  170,  182,  178,  183,  175,  173,  184,
      195,  197,  195,  197,  179,  200,  200,  187,  206,  181,
      207,  224,  208,  214,  199,  199,  209,  210,  206,  182,

      214,  183,  201,  201,  184,  191,  199,  189,  199,  190,
      211,  213,  210,  215,  201,  207,  201,  208,  218,  209,
      216,  211,  222,  221,  223,  213,  243,  219,  214,  220,
      226,  229,  207,  199,  208,  216,  209,  219,  215,  223,
      220,  201,  225,  218,  221,  222,  211,  227,  244,  243,
      226,  225,  246,  245,  249,  215,  247,  254,  227,  250,
      218,  255,  222,  259,  257,  220,  243,  229,  245,  226,
      250,  272,  246,  277,  249,  275,  273,  244,  274,  247,
      278,  255,  254,  227,  275,  302,  274,  280,  259,  297,
      277,  246,  257,  249,  280,  250,  247,  272,  273,  254,

      255,  291,  292,  278,  293,  259,  294,  297,  300,  296,
      291,  304,  301,  292,  272,  293,  296,  324,  324,  295,
      278,  288,  280,  325,  325,  284,  282,  297,  281,  304,
      279,  294,  276,  300,  270,  269,  268,  265,  292,  264,
      293,  263,  261,  260,  296,  258,  256,  253,  294,  304,
      300,  309,  309,  309,  309,  309,  309,  309,  309,  309,
      309,  309,  309,  309,  309,  310,  310,  310,  310,  310,
      310,  310,  310,  310,  310,  310,  310,  310,  310,  311,
      252,  311,  311,  311,  311,  311,  311,  311,  311,  311,
      311,  311,  311,  312,  251,  312,  312,  312,  312,  312,

      312,  312,  312,  312,  312,  312,  312,  313,  248,  242,
      239,  238,  236,  313,  313,  313,  235,  313,  314,  314,
      314,  314,  234,  314,  314,  314,  232,  314,  315,  231,
      230,  315,  315,  315,  217,  315,  316,  316,  316,  316,
      212,  316,  316,  316,  205,  316,  317,  317,  317,  317,
      317,  317,  317,  317,  317,  317,  317,  317,  317,  317,
      318,  318,  318,  318,  318,  318,  318,  318,  318,  318,
      318,  318,  318,  318,  320,  320,  320,  320,  204,  196,
      320,  320,  320,  194,  320,  321,  321,  321,  321,  321,
      321,  321,  321,  321,  321,  321,  321,  321,  321,  322,

      193,  192,  185,  163,  162,  322,  322,  322,  161,  322,
      323,  323,  323,  160,  323,  326,  326,  326,  326,  159,
      158,  326,  326,  326,  157,  326,  327,  327,  327,  150,
      146,  327,  327,  327,  142,  327,  328,  141,  328,  140,
      139,  328,  328,  138,  328,  328,  329,  329,  329,  329,
      329,  330,  137,  330,  135,  107,  330,  330,  103,  330,
      330,  331,  331,  331,  331,  331,  332,  332,  332,  102,
      332,  333,  333,  100,  333,  333,  333,  333,  333,   96,
      333,  333,  333,  333,  333,  334,  334,  334,  334,   95,
      334,  334,  334,   75,  334,  335,  335,  335,   74,  335,

      336,  336,   73,  336,  336,  336,  336,  336,   72,  336,
      336,  336,  336,  336,  337,  337,  337,  337,   71,  337,
      337,  337,   63,  337,  338,  338,  338,   57,   43,  338,
      338,  338,   37,  338,  339,  339,  339,  339,  339,  339,
      339,  339,  339,  339,  339,  339,  339,  339,  340,  340,
      340,   33,  340,  341,  341,  341,   21,   16,  341,  341,
      341,   15,  341,  342,  342,  342,  342,  342,  342,  342,
      342,  342,  342,  342,  342,  342,  342,  343,  343,  343,
       11,  343,  344,  344,  344,   10,    9,  344,  344,  344,
        8,  344,  345,  345,  345,    7,    0,  345,  345,  345,

        0,  345,  308,  308,  308,  308,  308,  308,  308,  308,
      308,  308,  308,  308,  308,  308,  308,  308,  308,  308,
      308,  308,  308,  308,  308,  308,  308,  308,  308,  308,
      308,  308,  308,  308,  308,  308,  308,  308,  308,  308,
      308,  308,  308,  308,  308,  308,  308,  308,  308,  308,
      308,  308,  308,  308,  308,  308,  308,  308,  308,  308,
      308,  308,  308,  308,  308,  308,  308,  308,  308,  308,
      308,  308,  308,  308
    } ;

/* 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,v 1.63 2005/06/02 18:18:49 cmdjb Exp $
 *
 * Copyright (C) 2004-2005, David Beckett http://purl.org/net/dajobe/
 * Institute for Learning and Research Technology http://www.ilrt.bristol.ac.uk/
 * 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/
 *
 */
/* 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 75 "./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 void sparql_skip_cpp_comment(rasqal_sparql_query_engine *rqe);
static int sparql_skip_c_comment(rasqal_query *rq);

static unsigned char *sparql_copy_name(rasqal_query *rq, const unsigned char *text, size_t len);
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);

/* See
 * http://www.w3.org/TR/xml11/#NT-NameStartChar and 
 * http://www.w3.org/TR/xml11/#NT-NameChar 
 */
/* rq23 [86] NCCHAR1 */
/* rq23 [87] NCCHAR = NCCHAR1 + '_' + '-' + .' + [0-9]*/
/* rq23 [88] NCCHAR_PREFIX */
/* Taken from rq23 [89] NCNAME first clause = NCCHAR1 + '_' */
/* rq23 [89] NCNAME */
/* Taken from rq23 [90] VARNAME = NCCHAR1 set + '_' + [0-9] */
/* rq23 [90] VARNAME  */
/* rq23 [74] QNAME */
/* rq23 [75] BNODE_LABEL renamed */
/* The initial char conditions are to ensure this doesn't grab < or <= */
#line 915 "sparql_lexer.c"

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

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

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

/* 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 163 "./sparql_lexer.l"

  /* rules */

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


#line 1139 "sparql_lexer.c"

      if ( yyg->yy_init )
            {
            yyg->yy_init = 0;

#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 >= 309 )
                              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 != 308 );
            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:
YY_RULE_SETUP
#line 171 "./sparql_lexer.l"
{ /* C++ comment */
      sparql_skip_cpp_comment(rqe);
}
      YY_BREAK
case 2:
YY_RULE_SETUP
#line 175 "./sparql_lexer.l"
{ if(sparql_skip_c_comment(rq) < 0)
            yyterminate();
        }
      YY_BREAK
case 3:
/* rule 3 can match eol */
YY_RULE_SETUP
#line 179 "./sparql_lexer.l"
{ rqe->lineno++; }
      YY_BREAK
case 4:
YY_RULE_SETUP
#line 181 "./sparql_lexer.l"
{ /* eat up other whitespace */
      ;
}
      YY_BREAK
case 5:
YY_RULE_SETUP
#line 185 "./sparql_lexer.l"
{ return SELECT; }
      YY_BREAK
case 6:
YY_RULE_SETUP
#line 186 "./sparql_lexer.l"
{ return FROM; }
      YY_BREAK
case 7:
YY_RULE_SETUP
#line 187 "./sparql_lexer.l"
{ return WHERE; }
      YY_BREAK
case 8:
YY_RULE_SETUP
#line 188 "./sparql_lexer.l"
{ BEGIN(PREF);
            return PREFIX; }
      YY_BREAK
case 9:
YY_RULE_SETUP
#line 190 "./sparql_lexer.l"
{ return DESCRIBE; }
      YY_BREAK
case 10:
YY_RULE_SETUP
#line 191 "./sparql_lexer.l"
{ return CONSTRUCT; }
      YY_BREAK
case 11:
YY_RULE_SETUP
#line 192 "./sparql_lexer.l"
{ return ASK; }
      YY_BREAK
case 12:
YY_RULE_SETUP
#line 193 "./sparql_lexer.l"
{ return DISTINCT; }
      YY_BREAK
case 13:
YY_RULE_SETUP
#line 194 "./sparql_lexer.l"
{ return LIMIT; }
      YY_BREAK
case 14:
YY_RULE_SETUP
#line 195 "./sparql_lexer.l"
{ return UNION; }
      YY_BREAK
case 15:
YY_RULE_SETUP
#line 196 "./sparql_lexer.l"
{ return OPTIONAL; }
      YY_BREAK
case 16:
YY_RULE_SETUP
#line 197 "./sparql_lexer.l"
{ return BASE; }
      YY_BREAK
case 17:
YY_RULE_SETUP
#line 198 "./sparql_lexer.l"
{ return BOUND; }
      YY_BREAK
case 18:
YY_RULE_SETUP
#line 199 "./sparql_lexer.l"
{ return STR; }
      YY_BREAK
case 19:
YY_RULE_SETUP
#line 200 "./sparql_lexer.l"
{ return LANG; }
      YY_BREAK
case 20:
YY_RULE_SETUP
#line 201 "./sparql_lexer.l"
{ return DATATYPE; }
      YY_BREAK
case 21:
YY_RULE_SETUP
#line 202 "./sparql_lexer.l"
{ return ISURI; }
      YY_BREAK
case 22:
YY_RULE_SETUP
#line 203 "./sparql_lexer.l"
{ return ISBLANK; }
      YY_BREAK
case 23:
YY_RULE_SETUP
#line 204 "./sparql_lexer.l"
{ return ISLITERAL; }
      YY_BREAK
case 24:
YY_RULE_SETUP
#line 205 "./sparql_lexer.l"
{ return GRAPH; }
      YY_BREAK
case 25:
YY_RULE_SETUP
#line 206 "./sparql_lexer.l"
{ return NAMED; }
      YY_BREAK
case 26:
YY_RULE_SETUP
#line 207 "./sparql_lexer.l"
{ return FILTER; }
      YY_BREAK
case 27:
YY_RULE_SETUP
#line 208 "./sparql_lexer.l"
{ return OFFSET; }
      YY_BREAK
case 28:
YY_RULE_SETUP
#line 209 "./sparql_lexer.l"
{ return ORDER; }
      YY_BREAK
case 29:
YY_RULE_SETUP
#line 210 "./sparql_lexer.l"
{ return BY; }
      YY_BREAK
case 30:
YY_RULE_SETUP
#line 211 "./sparql_lexer.l"
{ return REGEX; }
      YY_BREAK
case 31:
YY_RULE_SETUP
#line 212 "./sparql_lexer.l"
{ return ASC; }
      YY_BREAK
case 32:
YY_RULE_SETUP
#line 213 "./sparql_lexer.l"
{ return DESC; } 
      YY_BREAK
case 33:
YY_RULE_SETUP
#line 215 "./sparql_lexer.l"
{ return A; }
      YY_BREAK
case 34:
YY_RULE_SETUP
#line 217 "./sparql_lexer.l"
{ return ','; } 
      YY_BREAK
case 35:
YY_RULE_SETUP
#line 218 "./sparql_lexer.l"
{ return '('; } 
      YY_BREAK
case 36:
YY_RULE_SETUP
#line 219 "./sparql_lexer.l"
{ return ')'; } 
      YY_BREAK
case 37:
YY_RULE_SETUP
#line 220 "./sparql_lexer.l"
{ return '['; }
      YY_BREAK
case 38:
YY_RULE_SETUP
#line 221 "./sparql_lexer.l"
{ return ']'; }
      YY_BREAK
case 39:
YY_RULE_SETUP
#line 222 "./sparql_lexer.l"
{ BEGIN(ID); return '?'; }
      YY_BREAK
case 40:
YY_RULE_SETUP
#line 223 "./sparql_lexer.l"
{ BEGIN(ID); return '$'; }
      YY_BREAK
case 41:
YY_RULE_SETUP
#line 224 "./sparql_lexer.l"
{ return '{'; } 
      YY_BREAK
case 42:
YY_RULE_SETUP
#line 225 "./sparql_lexer.l"
{ return '}'; } 
      YY_BREAK
case 43:
YY_RULE_SETUP
#line 226 "./sparql_lexer.l"
{ return '.'; } 
      YY_BREAK
case 44:
YY_RULE_SETUP
#line 227 "./sparql_lexer.l"
{ return ';'; } 
      YY_BREAK
case 45:
YY_RULE_SETUP
#line 229 "./sparql_lexer.l"
{ return SC_OR; }
      YY_BREAK
case 46:
YY_RULE_SETUP
#line 230 "./sparql_lexer.l"
{ return SC_AND; }
      YY_BREAK
case 47:
YY_RULE_SETUP
#line 232 "./sparql_lexer.l"
{ return EQ; }
      YY_BREAK
case 48:
YY_RULE_SETUP
#line 233 "./sparql_lexer.l"
{ return NEQ; }
      YY_BREAK
case 49:
/* rule 49 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 234 "./sparql_lexer.l"
{ return LT; }
      YY_BREAK
case 50:
YY_RULE_SETUP
#line 235 "./sparql_lexer.l"
{ return GT; }
      YY_BREAK
case 51:
YY_RULE_SETUP
#line 236 "./sparql_lexer.l"
{ return LE; }
      YY_BREAK
case 52:
YY_RULE_SETUP
#line 237 "./sparql_lexer.l"
{ return GE; }
      YY_BREAK
case 53:
YY_RULE_SETUP
#line 239 "./sparql_lexer.l"
{ return '+'; }
      YY_BREAK
case 54:
YY_RULE_SETUP
#line 240 "./sparql_lexer.l"
{ return '-'; }
      YY_BREAK
case 55:
YY_RULE_SETUP
#line 241 "./sparql_lexer.l"
{ return '*'; }
      YY_BREAK
case 56:
YY_RULE_SETUP
#line 242 "./sparql_lexer.l"
{ return '/'; }
      YY_BREAK
case 57:
YY_RULE_SETUP
#line 243 "./sparql_lexer.l"
{ return '%'; }
      YY_BREAK
case 58:
YY_RULE_SETUP
#line 244 "./sparql_lexer.l"
{ return '~'; }
      YY_BREAK
case 59:
YY_RULE_SETUP
#line 245 "./sparql_lexer.l"
{ return '!'; }
      YY_BREAK
case 60:
YY_RULE_SETUP
#line 247 "./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 61:
YY_RULE_SETUP
#line 254 "./sparql_lexer.l"
{ int i;
                      if(yytext[yyleng+1] == 'x') 
                        sscanf(yytext+2, "%x", &i);
                      else
                        sscanf(yytext+2, "%X", &i);
                      sparql_parser_lval->literal=rasqal_new_integer_literal(RASQAL_LITERAL_INTEGER, i);
                      return INTEGER_LITERAL; 
}
      YY_BREAK
case 62:
YY_RULE_SETUP
#line 263 "./sparql_lexer.l"
{ 
                        double d;
                        sscanf((const char*)yytext, "%lf", &d);
                        sparql_parser_lval->literal=rasqal_new_floating_literal(d);
                        return FLOATING_POINT_LITERAL;
}
      YY_BREAK
case 63:
/* rule 63 can match eol */
YY_RULE_SETUP
#line 270 "./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 275 "./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 280 "./sparql_lexer.l"
{ BEGIN(LITERAL); }
      YY_BREAK
case 66:
/* rule 66 can match eol */
YY_RULE_SETUP
#line 282 "./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 287 "./sparql_lexer.l"
{ BEGIN(INITIAL);
              if (*yytext == EOF)
                    return EOF;

                  sparql_syntax_error(rq, "syntax error at %c - \"\"\"string was not terminated", *yytext);
                  yyterminate();  }
      YY_BREAK
case 68:
YY_RULE_SETUP
#line 295 "./sparql_lexer.l"
{ BEGIN(LITERAL2); }
      YY_BREAK
case 69:
/* rule 69 can match eol */
YY_RULE_SETUP
#line 297 "./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 302 "./sparql_lexer.l"
{ BEGIN(INITIAL);
              if (*yytext == EOF)
                    return EOF;

                  sparql_syntax_error(rq, "syntax error at %c - '''string was not terminated", *yytext);
                  yyterminate();  }
      YY_BREAK
case 71:
YY_RULE_SETUP
#line 310 "./sparql_lexer.l"
{ sparql_parser_lval->literal=rasqal_new_boolean_literal(*yytext== 't');
                  return BOOLEAN_LITERAL; }
      YY_BREAK
case 72:
YY_RULE_SETUP
#line 313 "./sparql_lexer.l"
{ sparql_parser_lval->literal=NULL;
          return NULL_LITERAL; }
      YY_BREAK
case 73:
YY_RULE_SETUP
#line 316 "./sparql_lexer.l"
{ sparql_parser_lval->name=sparql_copy_name(rq, (const unsigned char*)yytext, yyleng);
              if(!sparql_parser_lval->name)
                    yyterminate();
                          BEGIN(INITIAL);
                          return IDENTIFIER; }
      YY_BREAK
case 74:
/* rule 74 can match eol */
YY_RULE_SETUP
#line 321 "./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 327 "./sparql_lexer.l"
{ /* eat up leading whitespace */ }
      YY_BREAK
case 76:
YY_RULE_SETUP
#line 328 "./sparql_lexer.l"
{ BEGIN(INITIAL);
                    sparql_parser_lval->name=sparql_copy_name(rq, (const unsigned char*)yytext, yyleng-1);
                    if(!sparql_parser_lval->name)
                      yyterminate();
                          return IDENTIFIER; }
      YY_BREAK
case 77:
YY_RULE_SETUP
#line 333 "./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 337 "./sparql_lexer.l"
{ BEGIN(INITIAL);
              if (*yytext == EOF)
                    return EOF;

                  sparql_syntax_error(rq, "SPARQL syntax error at '%c'", *yytext);
                  yyterminate();
}
      YY_BREAK
case 79:
YY_RULE_SETUP
#line 345 "./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 355 "./sparql_lexer.l"
{     sparql_parser_lval->name=sparql_copy_name(rq, (unsigned char*)yytext+2, yyleng-2);
            return BLANK_LITERAL;
}
      YY_BREAK
case 81:
/* rule 81 can match eol */
YY_RULE_SETUP
#line 359 "./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 {
                  yytext[yyleng-1]='\0';
                  sparql_parser_lval->uri=raptor_new_uri_relative_to_base(rq->base_uri, (const unsigned char*)yytext+1);
                 }
                 return have_brace ? URI_LITERAL_BRACE : URI_LITERAL; }
      YY_BREAK
case 82:
YY_RULE_SETUP
#line 371 "./sparql_lexer.l"
{ while((c=INPUT_FN(yyscanner)) != '\n' && c)
                    ;
                }
      YY_BREAK
case 83:
YY_RULE_SETUP
#line 375 "./sparql_lexer.l"
{ if (*yytext == EOF)
                    return EOF;

                  sparql_syntax_error(rq, "SPARQL syntax error at '%c'", *yytext);
                  yyterminate();
            }
      YY_BREAK
case 84:
YY_RULE_SETUP
#line 382 "./sparql_lexer.l"
YY_FATAL_ERROR( "flex scanner jammed" );
      YY_BREAK
#line 1746 "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
            {
                  size_t num_to_read =
                  YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;

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

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

                  int yy_c_buf_p_offset =
                        (int) (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, 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 >= 309 )
                        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;
      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 >= 309 )
                  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 == 308);

      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 str 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 * str , yyscan_t yyscanner)
{
    
      return sparql_lexer__scan_bytes(str,strlen(str) ,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 * bytes, int  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 = 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 < len; ++i )
            buf[i] = bytes[i];

      buf[len] = buf[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 */

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 once per scanner lifetime. */

    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 = 1;
    yyg->yy_start = 0;
    yyg->yy_start_stack_ptr = 0;
    yyg->yy_start_stack_depth = 0;
    yyg->yy_start_stack = (int *) 0;

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

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

    memset(*ptr_yy_globals,0,sizeof(struct yyguts_t));

    return yy_init_globals ( *ptr_yy_globals );
}

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

    /* Destroy the main struct (reentrant only). */
    sparql_lexer_free ( yyscanner , yyscanner );
    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;
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
      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;
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
      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"

#undef YY_NEW_FILE
#undef YY_FLUSH_BUFFER
#undef yy_set_bol
#undef yy_new_buffer
#undef yy_set_interactive
#undef yytext_ptr
#undef YY_DO_BEFORE_ACTION

#ifdef YY_DECL_IS_OURS
#undef YY_DECL_IS_OURS
#undef YY_DECL
#endif
#line 382 "./sparql_lexer.l"


  /* user code */

int
sparql_lexer_wrap (yyscan_t yyscanner) {
  return 1;
}


static unsigned char *
sparql_copy_name(rasqal_query *rq, const unsigned char *text, size_t len) {
  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(!raptor_xml_name_check(s, dest_len, 11))
    sparql_syntax_warning(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(!raptor_xml_name_check(s, p-s, 11))
    sparql_syntax_warning(rq, "Invalid SPARQL name \"%s\"", s);
  if(!raptor_xml_name_check(p+1, dest_len-((p+1)-s), 11))
    sparql_syntax_warning(rq, "Invalid SPARQL 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,
                                 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;
        
        s++; i++;
        if(i+ulen > len) {
          printf("\\%c over end of line", c);
          RASQAL_FREE(cstring, string);
          return 1;
        }
        
        sscanf((const char*)s, ((ulen == 4) ? "%04lx" : "%08lx"), &unichar);
        s+= ulen-1;
        i+= ulen-1;
        
        if(unichar < 0 || 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(!raptor_xml_name_check(dt_s, dt_p-dt_s, 11))
        sparql_syntax_warning(rq, "Invalid SPARQL name \"%s\"", dt_s);
      if(!raptor_xml_name_check(dt_p+1, dest_len-((dt_p+1)-dt_s), 11))
        sparql_syntax_warning(rq, "Invalid SPARQL 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,
                                        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;
  
  while(1) {
    while ((c=INPUT_FN(yyscanner)) != '*' && c!= EOF) {
      if(c == '\r' || c == '\n')
        lines++;
    }
    if( c == '*') {
      while ((c=INPUT_FN(yyscanner)) == '*') {
        if(c == '\r' || c == '\n')
          lines++;
      }

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


static void
sparql_skip_cpp_comment(rasqal_sparql_query_engine *rqe) {
  yyscan_t yyscanner=rqe->scanner;
  int c;
  
  while ((c=INPUT_FN(yyscanner)) != EOF)
    if(c == '\r' || c == '\n')
      break;
  return;
}


#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 ',':
      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 '!':
      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 NULL_LITERAL:
      return "NULL_LITERAL";

    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;

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