
/* A Bison parser, made by GNU Bison 2.4.1.  */

/* Skeleton implementation for Bison's Yacc-like parsers in C
   
      Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
   Free Software Foundation, Inc.
   
   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.
   
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   
   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

/* As a special exception, you may create a larger work that contains
   part or all of the Bison parser skeleton and distribute that work
   under terms of your choice, so long as that work isn't itself a
   parser generator using the skeleton or a modified version thereof
   as a parser skeleton.  Alternatively, if you modify or redistribute
   the parser skeleton itself, you may (at your option) remove this
   special exception, which will cause the skeleton and the resulting
   Bison output files to be licensed under the GNU General Public
   License without this special exception.
   
   This special exception was added by the Free Software Foundation in
   version 2.2 of Bison.  */

/* C LALR(1) parser skeleton written by Richard Stallman, by
   simplifying the original so-called "semantic" parser.  */

/* All symbols defined below should begin with yy or YY, to avoid
   infringing on user name space.  This should be done even for local
   variables, as they might otherwise be expanded by user macros.
   There are some unavoidable exceptions within include files to
   define necessary library symbols; they are noted "INFRINGES ON
   USER NAME SPACE" below.  */

/* Identify Bison output.  */
#define YYBISON 1

/* Bison version.  */
#define YYBISON_VERSION "2.4.1"

/* Skeleton name.  */
#define YYSKELETON_NAME "yacc.c"

/* Pure parsers.  */
#define YYPURE 1

/* Push parsers.  */
#define YYPUSH 0

/* Pull parsers.  */
#define YYPULL 1

/* Using locations.  */
#define YYLSP_NEEDED 0

/* Substitute the variable and function names.  */
#define yyparse         sparql_parser_parse
#define yylex           sparql_parser_lex
#define yyerror         sparql_parser_error
#define yylval          sparql_parser_lval
#define yychar          sparql_parser_char
#define yydebug         sparql_parser_debug
#define yynerrs         sparql_parser_nerrs


/* Copy the first part of user declarations.  */

/* Line 189 of yacc.c  */
#line 28 "./sparql_parser.y"

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

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

#include <stdio.h>
#include <stdarg.h>

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

#include <sparql_parser.h>

#define YY_DECL int sparql_lexer_lex (YYSTYPE *sparql_parser_lval, yyscan_t yyscanner)
#define YY_NO_UNISTD_H 1
#include <sparql_lexer.h>

#include <sparql_common.h>


#if 0
#undef RASQAL_DEBUG
#define RASQAL_DEBUG 3
#endif


#define DEBUG_FH stderr

/* Make verbose error messages for syntax errors */
#define YYERROR_VERBOSE 1

/* Fail with an debug error message if RASQAL_DEBUG > 1 */
#if RASQAL_DEBUG > 1
#define YYERROR_MSG(msg) do { fputs("** YYERROR ", DEBUG_FH); fputs(msg, DEBUG_FH); fputc('\n', DEBUG_FH); YYERROR; } while(0)
#else
#define YYERROR_MSG(ignore) YYERROR
#endif

/* Slow down the grammar operation and watch it work */
#if RASQAL_DEBUG > 2
#define YYDEBUG 1
#endif

/* the lexer does not seem to track this */
#undef RASQAL_SPARQL_USE_ERROR_COLUMNS

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


/* What the lexer wants */
extern int sparql_lexer_lex (YYSTYPE *sparql_parser_lval, yyscan_t scanner);
#define YYLEX_PARAM ((rasqal_sparql_query_language*)(((rasqal_query*)rq)->context))->scanner

/* Pure parser argument (a void*) */
#define YYPARSE_PARAM rq

/* Make the yyerror below use the rdf_parser */
#undef yyerror
#define yyerror(message) sparql_query_error((rasqal_query*)rq, message)

/* Make lex/yacc interface as small as possible */
#undef yylex
#define yylex sparql_lexer_lex


static int sparql_parse(rasqal_query* rq);
static void sparql_query_error(rasqal_query* rq, const char *message);
static void sparql_query_error_full(rasqal_query *rq, const char *message, ...) RASQAL_PRINTF_FORMAT(2, 3);



/* Line 189 of yacc.c  */
#line 160 "sparql_parser.c"

/* Enabling traces.  */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif

/* Enabling verbose error messages.  */
#ifdef YYERROR_VERBOSE
# undef YYERROR_VERBOSE
# define YYERROR_VERBOSE 1
#else
# define YYERROR_VERBOSE 0
#endif

/* Enabling the token table.  */
#ifndef YYTOKEN_TABLE
# define YYTOKEN_TABLE 0
#endif


/* Tokens.  */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
   /* Put the tokens into the symbol table, so that GDB and other debuggers
      know about them.  */
   enum yytokentype {
     SELECT = 258,
     FROM = 259,
     WHERE = 260,
     OPTIONAL = 261,
     DESCRIBE = 262,
     CONSTRUCT = 263,
     ASK = 264,
     DISTINCT = 265,
     REDUCED = 266,
     LIMIT = 267,
     UNION = 268,
     PREFIX = 269,
     BASE = 270,
     BOUND = 271,
     GRAPH = 272,
     NAMED = 273,
     FILTER = 274,
     OFFSET = 275,
     ORDER = 276,
     BY = 277,
     REGEX = 278,
     ASC = 279,
     DESC = 280,
     LANGMATCHES = 281,
     A = 282,
     STR = 283,
     LANG = 284,
     DATATYPE = 285,
     ISURI = 286,
     ISBLANK = 287,
     ISLITERAL = 288,
     SAMETERM = 289,
     GROUP = 290,
     COUNT = 291,
     SUM = 292,
     AVG = 293,
     MIN = 294,
     MAX = 295,
     DELETE = 296,
     INSERT = 297,
     WITH = 298,
     CLEAR = 299,
     CREATE = 300,
     SILENT = 301,
     DATA = 302,
     DROP = 303,
     LOAD = 304,
     INTO = 305,
     EXPLAIN = 306,
     LET = 307,
     AS = 308,
     COALESCE = 309,
     SC_OR = 310,
     SC_AND = 311,
     EQ = 312,
     NEQ = 313,
     LT = 314,
     GT = 315,
     LE = 316,
     GE = 317,
     ASSIGN = 318,
     STRING_LITERAL = 319,
     DOUBLE_LITERAL = 320,
     DOUBLE_POSITIVE_LITERAL = 321,
     DOUBLE_NEGATIVE_LITERAL = 322,
     INTEGER_LITERAL = 323,
     INTEGER_POSITIVE_LITERAL = 324,
     INTEGER_NEGATIVE_LITERAL = 325,
     DECIMAL_LITERAL = 326,
     DECIMAL_POSITIVE_LITERAL = 327,
     DECIMAL_NEGATIVE_LITERAL = 328,
     BOOLEAN_LITERAL = 329,
     URI_LITERAL = 330,
     URI_LITERAL_BRACE = 331,
     QNAME_LITERAL = 332,
     QNAME_LITERAL_BRACE = 333,
     BLANK_LITERAL = 334,
     IDENTIFIER = 335
   };
#endif
/* Tokens.  */
#define SELECT 258
#define FROM 259
#define WHERE 260
#define OPTIONAL 261
#define DESCRIBE 262
#define CONSTRUCT 263
#define ASK 264
#define DISTINCT 265
#define REDUCED 266
#define LIMIT 267
#define UNION 268
#define PREFIX 269
#define BASE 270
#define BOUND 271
#define GRAPH 272
#define NAMED 273
#define FILTER 274
#define OFFSET 275
#define ORDER 276
#define BY 277
#define REGEX 278
#define ASC 279
#define DESC 280
#define LANGMATCHES 281
#define A 282
#define STR 283
#define LANG 284
#define DATATYPE 285
#define ISURI 286
#define ISBLANK 287
#define ISLITERAL 288
#define SAMETERM 289
#define GROUP 290
#define COUNT 291
#define SUM 292
#define AVG 293
#define MIN 294
#define MAX 295
#define DELETE 296
#define INSERT 297
#define WITH 298
#define CLEAR 299
#define CREATE 300
#define SILENT 301
#define DATA 302
#define DROP 303
#define LOAD 304
#define INTO 305
#define EXPLAIN 306
#define LET 307
#define AS 308
#define COALESCE 309
#define SC_OR 310
#define SC_AND 311
#define EQ 312
#define NEQ 313
#define LT 314
#define GT 315
#define LE 316
#define GE 317
#define ASSIGN 318
#define STRING_LITERAL 319
#define DOUBLE_LITERAL 320
#define DOUBLE_POSITIVE_LITERAL 321
#define DOUBLE_NEGATIVE_LITERAL 322
#define INTEGER_LITERAL 323
#define INTEGER_POSITIVE_LITERAL 324
#define INTEGER_NEGATIVE_LITERAL 325
#define DECIMAL_LITERAL 326
#define DECIMAL_POSITIVE_LITERAL 327
#define DECIMAL_NEGATIVE_LITERAL 328
#define BOOLEAN_LITERAL 329
#define URI_LITERAL 330
#define URI_LITERAL_BRACE 331
#define QNAME_LITERAL 332
#define QNAME_LITERAL_BRACE 333
#define BLANK_LITERAL 334
#define IDENTIFIER 335




#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
{

/* Line 214 of yacc.c  */
#line 114 "./sparql_parser.y"

  raptor_sequence *seq;
  rasqal_variable *variable;
  rasqal_literal *literal;
  rasqal_triple *triple;
  rasqal_expression *expr;
  rasqal_graph_pattern *graph_pattern;
  double floating;
  raptor_uri *uri;
  unsigned char *name;
  rasqal_formula *formula;
  rasqal_update_operation *update;



/* Line 214 of yacc.c  */
#line 372 "sparql_parser.c"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
#endif


/* Copy the second part of user declarations.  */


/* Line 264 of yacc.c  */
#line 384 "sparql_parser.c"

#ifdef short
# undef short
#endif

#ifdef YYTYPE_UINT8
typedef YYTYPE_UINT8 yytype_uint8;
#else
typedef unsigned char yytype_uint8;
#endif

#ifdef YYTYPE_INT8
typedef YYTYPE_INT8 yytype_int8;
#elif (defined __STDC__ || defined __C99__FUNC__ \
     || defined __cplusplus || defined _MSC_VER)
typedef signed char yytype_int8;
#else
typedef short int yytype_int8;
#endif

#ifdef YYTYPE_UINT16
typedef YYTYPE_UINT16 yytype_uint16;
#else
typedef unsigned short int yytype_uint16;
#endif

#ifdef YYTYPE_INT16
typedef YYTYPE_INT16 yytype_int16;
#else
typedef short int yytype_int16;
#endif

#ifndef YYSIZE_T
# ifdef __SIZE_TYPE__
#  define YYSIZE_T __SIZE_TYPE__
# elif defined size_t
#  define YYSIZE_T size_t
# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
     || defined __cplusplus || defined _MSC_VER)
#  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
#  define YYSIZE_T size_t
# else
#  define YYSIZE_T unsigned int
# endif
#endif

#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)

#ifndef YY_
# if YYENABLE_NLS
#  if ENABLE_NLS
#   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
#   define YY_(msgid) dgettext ("bison-runtime", msgid)
#  endif
# endif
# ifndef YY_
#  define YY_(msgid) msgid
# endif
#endif

/* Suppress unused-variable warnings by "using" E.  */
#if ! defined lint || defined __GNUC__
# define YYUSE(e) ((void) (e))
#else
# define YYUSE(e) /* empty */
#endif

/* Identity function, used to suppress warnings about constant conditions.  */
#ifndef lint
# define YYID(n) (n)
#else
#if (defined __STDC__ || defined __C99__FUNC__ \
     || defined __cplusplus || defined _MSC_VER)
static int
YYID (int yyi)
#else
static int
YYID (yyi)
    int yyi;
#endif
{
  return yyi;
}
#endif

#if ! defined yyoverflow || YYERROR_VERBOSE

/* The parser invokes alloca or malloc; define the necessary symbols.  */

# ifdef YYSTACK_USE_ALLOCA
#  if YYSTACK_USE_ALLOCA
#   ifdef __GNUC__
#    define YYSTACK_ALLOC __builtin_alloca
#   elif defined __BUILTIN_VA_ARG_INCR
#    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
#   elif defined _AIX
#    define YYSTACK_ALLOC __alloca
#   elif defined _MSC_VER
#    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
#    define alloca _alloca
#   else
#    define YYSTACK_ALLOC alloca
#    if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
     || defined __cplusplus || defined _MSC_VER)
#     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
#     ifndef _STDLIB_H
#      define _STDLIB_H 1
#     endif
#    endif
#   endif
#  endif
# endif

# ifdef YYSTACK_ALLOC
   /* Pacify GCC's `empty if-body' warning.  */
#  define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
#  ifndef YYSTACK_ALLOC_MAXIMUM
    /* The OS might guarantee only one guard page at the bottom of the stack,
       and a page size can be as small as 4096 bytes.  So we cannot safely
       invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
       to allow for a few compiler-allocated temporary stack slots.  */
#   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
#  endif
# else
#  define YYSTACK_ALLOC YYMALLOC
#  define YYSTACK_FREE YYFREE
#  ifndef YYSTACK_ALLOC_MAXIMUM
#   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
#  endif
#  if (defined __cplusplus && ! defined _STDLIB_H \
       && ! ((defined YYMALLOC || defined malloc) \
	     && (defined YYFREE || defined free)))
#   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
#   ifndef _STDLIB_H
#    define _STDLIB_H 1
#   endif
#  endif
#  ifndef YYMALLOC
#   define YYMALLOC malloc
#   if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
     || defined __cplusplus || defined _MSC_VER)
#   endif
#  endif
#  ifndef YYFREE
#   define YYFREE free
#   if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
     || defined __cplusplus || defined _MSC_VER)
#   endif
#  endif
# endif
#endif /* ! defined yyoverflow || YYERROR_VERBOSE */


#if (! defined yyoverflow \
     && (! defined __cplusplus \
	 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))

/* A type that is properly aligned for any stack member.  */
union yyalloc
{
  yytype_int16 yyss_alloc;
  YYSTYPE yyvs_alloc;
};

/* The size of the maximum gap between one aligned stack and the next.  */
# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)

/* The size of an array large to enough to hold all stacks, each with
   N elements.  */
# define YYSTACK_BYTES(N) \
     ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
      + YYSTACK_GAP_MAXIMUM)

/* Copy COUNT objects from FROM to TO.  The source and destination do
   not overlap.  */
# ifndef YYCOPY
#  if defined __GNUC__ && 1 < __GNUC__
#   define YYCOPY(To, From, Count) \
      __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
#  else
#   define YYCOPY(To, From, Count)		\
      do					\
	{					\
	  YYSIZE_T yyi;				\
	  for (yyi = 0; yyi < (Count); yyi++)	\
	    (To)[yyi] = (From)[yyi];		\
	}					\
      while (YYID (0))
#  endif
# endif

/* Relocate STACK from its old location to the new one.  The
   local variables YYSIZE and YYSTACKSIZE give the old and new number of
   elements in the stack, and YYPTR gives the new location of the
   stack.  Advance YYPTR to a properly aligned location for the next
   stack.  */
# define YYSTACK_RELOCATE(Stack_alloc, Stack)				\
    do									\
      {									\
	YYSIZE_T yynewbytes;						\
	YYCOPY (&yyptr->Stack_alloc, Stack, yysize);			\
	Stack = &yyptr->Stack_alloc;					\
	yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
	yyptr += yynewbytes / sizeof (*yyptr);				\
      }									\
    while (YYID (0))

#endif

/* YYFINAL -- State number of the termination state.  */
#define YYFINAL  6
/* YYLAST -- Last index in YYTABLE.  */
#define YYLAST   1184

/* YYNTOKENS -- Number of terminals.  */
#define YYNTOKENS  97
/* YYNNTS -- Number of nonterminals.  */
#define YYNNTS  107
/* YYNRULES -- Number of rules.  */
#define YYNRULES  242
/* YYNRULES -- Number of states.  */
#define YYNSTATES  441

/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
#define YYUNDEFTOK  2
#define YYMAXUTOK   335

#define YYTRANSLATE(YYX)						\
  ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)

/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
static const yytype_uint8 yytranslate[] =
{
       0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,    96,     2,     2,    63,     2,     2,     2,
      56,    57,    74,    72,    55,    73,    94,    75,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,    95,
       2,     2,     2,    62,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,    58,     2,    59,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,    60,     2,    61,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
       5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
      15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
      25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
      35,    36,    37,    38,    39,    40,    41,    42,    43,    44,
      45,    46,    47,    48,    49,    50,    51,    52,    53,    54,
      64,    65,    66,    67,    68,    69,    70,    71,    76,    77,
      78,    79,    80,    81,    82,    83,    84,    85,    86,    87,
      88,    89,    90,    91,    92,    93
};

#if YYDEBUG
/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
   YYRHS.  */
static const yytype_uint16 yyprhs[] =
{
       0,     0,     3,     7,     9,    10,    12,    14,    16,    18,
      20,    23,    25,    27,    29,    31,    33,    35,    37,    39,
      42,    45,    46,    51,    52,    59,    66,    72,    74,    76,
      79,    83,    85,    87,    91,    93,    97,   101,   103,   105,
     107,   109,   111,   116,   121,   126,   131,   136,   141,   147,
     153,   159,   162,   166,   168,   172,   176,   182,   188,   190,
     196,   202,   204,   206,   209,   211,   215,   221,   227,   239,
     247,   255,   257,   261,   265,   270,   274,   279,   282,   287,
     291,   295,   297,   298,   300,   303,   305,   308,   310,   312,
     313,   317,   321,   322,   325,   328,   330,   332,   333,   337,
     338,   341,   343,   346,   349,   351,   353,   355,   357,   360,
     363,   368,   370,   371,   374,   376,   377,   381,   383,   385,
     387,   388,   392,   394,   396,   398,   400,   402,   405,   409,
     413,   415,   419,   421,   428,   431,   433,   435,   437,   441,
     446,   450,   452,   453,   457,   459,   460,   464,   466,   469,
     472,   476,   479,   480,   482,   483,   486,   489,   490,   492,
     494,   496,   498,   500,   504,   508,   511,   513,   515,   517,
     519,   521,   523,   525,   528,   531,   533,   535,   537,   539,
     541,   543,   546,   548,   552,   554,   558,   560,   564,   568,
     572,   576,   580,   584,   586,   590,   594,   597,   600,   602,
     606,   610,   612,   615,   618,   621,   623,   625,   627,   629,
     631,   633,   637,   642,   647,   654,   659,   664,   671,   676,
     681,   686,   688,   690,   697,   706,   708,   710,   712,   714,
     716,   718,   720,   722,   724,   726,   728,   730,   732,   734,
     736,   738,   740
};

/* YYRHS -- A `-1'-separated list of the rules' RHS.  */
static const yytype_int16 yyrhs[] =
{
      98,     0,    -1,   103,    99,   100,    -1,    51,    -1,    -1,
     106,    -1,   117,    -1,   118,    -1,   120,    -1,   101,    -1,
     101,   102,    -1,   102,    -1,   121,    -1,   126,    -1,   127,
      -1,   128,    -1,   129,    -1,   130,    -1,   131,    -1,   104,
     105,    -1,    15,    88,    -1,    -1,   105,    14,    93,    88,
      -1,    -1,     3,    10,   107,   133,   137,   139,    -1,     3,
      11,   107,   133,   137,   139,    -1,     3,   107,   133,   137,
     139,    -1,   108,    -1,    74,    -1,   108,   109,    -1,   108,
      55,   109,    -1,   109,    -1,   183,    -1,   110,    53,   184,
      -1,   111,    -1,    56,   111,    57,    -1,    56,   186,    57,
      -1,   112,    -1,   113,    -1,   114,    -1,   115,    -1,   116,
      -1,    36,    56,   186,    57,    -1,    36,    56,    74,    57,
      -1,    37,    56,   186,    57,    -1,    38,    56,   186,    57,
      -1,    39,    56,   186,    57,    -1,    40,    56,   186,    57,
      -1,     8,   165,   133,   137,   139,    -1,     7,   119,   133,
     138,   139,    -1,     7,    74,   133,   138,   139,    -1,   119,
     182,    -1,   119,    55,   182,    -1,   182,    -1,     9,   133,
     137,    -1,    41,   132,   138,    -1,    41,    60,   125,    61,
     137,    -1,    41,    47,    60,   122,    61,    -1,   153,    -1,
      17,    88,    60,   153,    61,    -1,    17,   182,    60,   167,
      61,    -1,   167,    -1,   123,    -1,   125,   124,    -1,   124,
      -1,    42,   132,   138,    -1,    42,    60,   125,    61,   137,
      -1,    42,    47,    60,   122,    61,    -1,    43,    88,    41,
      60,   125,    61,    42,    60,   125,    61,   138,    -1,    43,
      88,    41,    60,   125,    61,   138,    -1,    43,    88,    42,
      60,   125,    61,   138,    -1,    44,    -1,    44,    17,    88,
      -1,    45,    17,    88,    -1,    45,    46,    17,    88,    -1,
      48,    17,    88,    -1,    48,    46,    17,    88,    -1,    49,
      88,    -1,    49,    88,    50,    88,    -1,   133,     4,   134,
      -1,   133,     4,   135,    -1,   132,    -1,    -1,   136,    -1,
      18,   136,    -1,   202,    -1,     5,   147,    -1,   147,    -1,
     137,    -1,    -1,   140,   142,   141,    -1,    35,    22,   143,
      -1,    -1,   145,   146,    -1,   146,   145,    -1,   145,    -1,
     146,    -1,    -1,    21,    22,   143,    -1,    -1,   143,   144,
      -1,   144,    -1,    24,   194,    -1,    25,   194,    -1,   162,
      -1,   183,    -1,   194,    -1,   195,    -1,    12,    81,    -1,
      20,    81,    -1,    60,   148,   149,    61,    -1,   153,    -1,
      -1,   149,   150,    -1,   150,    -1,    -1,   151,   152,   148,
      -1,   154,    -1,   160,    -1,    94,    -1,    -1,   168,    94,
     148,    -1,   168,    -1,   155,    -1,   157,    -1,   156,    -1,
     159,    -1,     6,   147,    -1,    17,   182,   147,    -1,   147,
      13,   158,    -1,   147,    -1,   158,    13,   147,    -1,   147,
      -1,    52,    56,   183,    76,   186,    57,    -1,    19,   161,
      -1,   194,    -1,   195,    -1,   162,    -1,   197,   164,    57,
      -1,    54,    56,   164,    57,    -1,   164,    55,   186,    -1,
     186,    -1,    -1,    60,   166,    61,    -1,   167,    -1,    -1,
     168,    94,   166,    -1,   168,    -1,   181,   169,    -1,   176,
     171,    -1,   175,   172,   170,    -1,    95,   171,    -1,    -1,
     169,    -1,    -1,   174,   173,    -1,    55,   172,    -1,    -1,
     180,    -1,   182,    -1,    27,    -1,   178,    -1,   177,    -1,
      58,   169,    59,    -1,    56,   179,    57,    -1,   179,   180,
      -1,   180,    -1,   181,    -1,   176,    -1,   183,    -1,   185,
      -1,   183,    -1,   202,    -1,    62,   184,    -1,    63,   184,
      -1,    93,    -1,   202,    -1,    77,    -1,   198,    -1,    87,
      -1,   203,    -1,    56,    57,    -1,   187,    -1,   187,    64,
     188,    -1,   188,    -1,   188,    65,   189,    -1,   189,    -1,
     190,    66,   190,    -1,   190,    67,   190,    -1,   190,    68,
     190,    -1,   190,    69,   190,    -1,   190,    70,   190,    -1,
     190,    71,   190,    -1,   190,    -1,   191,    72,   190,    -1,
     191,    73,   190,    -1,   191,   200,    -1,   191,   201,    -1,
     191,    -1,   192,    74,   191,    -1,   192,    75,   191,    -1,
     192,    -1,    96,   193,    -1,    72,   193,    -1,    73,   193,
      -1,   193,    -1,   194,    -1,   195,    -1,   162,    -1,   185,
      -1,   183,    -1,    56,   186,    57,    -1,    28,    56,   186,
      57,    -1,    29,    56,   186,    57,    -1,    26,    56,   186,
      55,   186,    57,    -1,    30,    56,   186,    57,    -1,    16,
      56,   183,    57,    -1,    34,    56,   186,    55,   186,    57,
      -1,    31,    56,   186,    57,    -1,    32,    56,   186,    57,
      -1,    33,    56,   186,    57,    -1,   196,    -1,   163,    -1,
      23,    56,   186,    55,   186,    57,    -1,    23,    56,   186,
      55,   186,    55,   186,    57,    -1,    89,    -1,    91,    -1,
     199,    -1,   200,    -1,   201,    -1,    81,    -1,    84,    -1,
      78,    -1,    82,    -1,    85,    -1,    79,    -1,    83,    -1,
      86,    -1,    80,    -1,    88,    -1,    90,    -1,    92,    -1,
      58,    59,    -1
};

/* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
static const yytype_uint16 yyrline[] =
{
       0,   348,   348,   354,   366,   373,   378,   383,   388,   392,
     396,   397,   401,   405,   409,   413,   417,   421,   425,   433,
     441,   446,   453,   483,   490,   497,   504,   516,   520,   531,
     540,   549,   573,   577,   602,   606,   610,   617,   621,   625,
     629,   633,   640,   656,   680,   699,   718,   737,   757,   767,
     773,   783,   792,   801,   822,   831,   845,   874,   896,   912,
     932,   947,   954,   962,   975,   999,  1013,  1040,  1058,  1080,
    1101,  1126,  1150,  1178,  1202,  1230,  1254,  1283,  1307,  1335,
    1336,  1339,  1340,  1344,  1360,  1376,  1384,  1388,  1396,  1401,
    1408,  1413,  1442,  1447,  1448,  1449,  1450,  1452,  1458,  1466,
    1471,  1481,  1506,  1513,  1520,  1528,  1545,  1553,  1565,  1581,
    1599,  1657,  1671,  1683,  1720,  1725,  1737,  1785,  1798,  1826,
    1827,  1832,  1863,  1871,  1875,  1879,  1883,  1891,  1935,  1990,
    2005,  2012,  2022,  2052,  2073,  2081,  2085,  2089,  2097,  2134,
    2163,  2173,  2195,  2202,  2210,  2215,  2231,  2266,  2281,  2325,
    2373,  2476,  2481,  2488,  2493,  2500,  2583,  2588,  2595,  2603,
    2613,  2645,  2649,  2657,  2724,  2856,  2914,  2956,  2960,  2968,
    2980,  2993,  2999,  3007,  3011,  3018,  3029,  3033,  3037,  3041,
    3045,  3049,  3059,  3067,  3074,  3082,  3090,  3099,  3106,  3113,
    3120,  3127,  3134,  3141,  3150,  3157,  3164,  3177,  3190,  3197,
    3204,  3211,  3219,  3226,  3230,  3237,  3251,  3255,  3259,  3268,
    3274,  3288,  3296,  3303,  3310,  3317,  3324,  3339,  3346,  3353,
    3360,  3367,  3371,  3379,  3386,  3400,  3406,  3426,  3430,  3434,
    3441,  3445,  3449,  3457,  3461,  3465,  3473,  3477,  3481,  3493,
    3499,  3519,  3525
};
#endif

#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
   First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
static const char *const yytname[] =
{
  "$end", "error", "$undefined", "SELECT", "FROM", "WHERE", "OPTIONAL",
  "DESCRIBE", "CONSTRUCT", "ASK", "DISTINCT", "REDUCED", "LIMIT", "UNION",
  "PREFIX", "BASE", "BOUND", "GRAPH", "NAMED", "FILTER", "OFFSET", "ORDER",
  "BY", "REGEX", "ASC", "DESC", "LANGMATCHES", "\"a\"", "\"str\"",
  "\"lang\"", "\"datatype\"", "\"isUri\"", "\"isBlank\"", "\"isLiteral\"",
  "\"sameTerm\"", "GROUP", "COUNT", "SUM", "AVG", "MIN", "MAX", "DELETE",
  "INSERT", "WITH", "CLEAR", "CREATE", "SILENT", "DATA", "DROP", "LOAD",
  "INTO", "EXPLAIN", "LET", "AS", "COALESCE", "','", "'('", "')'", "'['",
  "']'", "'{'", "'}'", "'?'", "'$'", "SC_OR", "SC_AND", "EQ", "NEQ", "LT",
  "GT", "LE", "GE", "'+'", "'-'", "'*'", "'/'", "\":=\"",
  "\"string literal\"", "\"double literal\"",
  "\"double positive literal\"", "\"double negative literal\"",
  "\"integer literal\"", "\"integer positive literal\"",
  "\"integer negative literal\"", "\"decimal literal\"",
  "\"decimal positive literal\"", "\"decimal negative literal\"",
  "\"boolean literal\"", "\"URI literal\"", "\"URI literal (\"",
  "\"QName literal\"", "\"QName literal (\"", "\"blank node literal\"",
  "\"identifier\"", "'.'", "';'", "'!'", "$accept", "Query", "ExplainOpt",
  "ReportFormat", "UpdateOperationList", "UpdateOperation", "Prologue",
  "BaseDeclOpt", "PrefixDeclListOpt", "SelectQuery",
  "SelectExpressionList", "SelectExpressionListTail", "SelectTerm",
  "SelectExpression", "AggregateExpression", "CountAggregateExpression",
  "SumAggregateExpression", "AvgAggregateExpression",
  "MinAggregateExpression", "MaxAggregateExpression", "ConstructQuery",
  "DescribeQuery", "VarOrIRIrefList", "AskQuery", "DeleteQuery",
  "GraphTriples", "GraphTemplate", "ModifyTemplate", "ModifyTemplateList",
  "InsertQuery", "UpdateQuery", "ClearQuery", "CreateQuery", "DropQuery",
  "LoadQuery", "DatasetClauseList", "DatasetClauseListOpt",
  "DefaultGraphClause", "NamedGraphClause", "SourceSelector",
  "WhereClause", "WhereClauseOpt", "SolutionModifier", "GroupClauseOpt",
  "LimitOffsetClausesOpt", "OrderClauseOpt", "OrderConditionList",
  "OrderCondition", "LimitClause", "OffsetClause", "GroupGraphPattern",
  "TriplesBlockOpt", "GraphPatternListOpt", "GraphPatternList",
  "GraphPatternListFilter", "DotOptional", "TriplesBlock",
  "GraphPatternNotTriples", "OptionalGraphPattern", "GraphGraphPattern",
  "GroupOrUnionGraphPattern", "GroupOrUnionGraphPatternList",
  "LetGraphPattern", "Filter", "Constraint", "FunctionCall",
  "CoalesceExpression", "ArgList", "ConstructTemplate",
  "ConstructTriplesOpt", "ConstructTriples", "TriplesSameSubject",
  "PropertyListNotEmpty", "PropertyListTailOpt", "PropertyList",
  "ObjectList", "ObjectTail", "Object", "Verb", "TriplesNode",
  "BlankNodePropertyList", "Collection", "GraphNodeListNotEmpty",
  "GraphNode", "VarOrTerm", "VarOrIRIref", "Var", "VarName", "GraphTerm",
  "Expression", "ConditionalOrExpression", "ConditionalAndExpression",
  "RelationalExpression", "AdditiveExpression", "MultiplicativeExpression",
  "UnaryExpression", "PrimaryExpression", "BrackettedExpression",
  "BuiltInCall", "RegexExpression", "IRIrefBrace", "NumericLiteral",
  "NumericLiteralUnsigned", "NumericLiteralPositive",
  "NumericLiteralNegative", "IRIref", "BlankNode", 0
};
#endif

# ifdef YYPRINT
/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
   token YYLEX-NUM.  */
static const yytype_uint16 yytoknum[] =
{
       0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
     265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
     275,   276,   277,   278,   279,   280,   281,   282,   283,   284,
     285,   286,   287,   288,   289,   290,   291,   292,   293,   294,
     295,   296,   297,   298,   299,   300,   301,   302,   303,   304,
     305,   306,   307,   308,   309,    44,    40,    41,    91,    93,
     123,   125,    63,    36,   310,   311,   312,   313,   314,   315,
     316,   317,    43,    45,    42,    47,   318,   319,   320,   321,
     322,   323,   324,   325,   326,   327,   328,   329,   330,   331,
     332,   333,   334,   335,    46,    59,    33
};
# endif

/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
static const yytype_uint8 yyr1[] =
{
       0,    97,    98,    99,    99,   100,   100,   100,   100,   100,
     101,   101,   102,   102,   102,   102,   102,   102,   102,   103,
     104,   104,   105,   105,   106,   106,   106,   107,   107,   108,
     108,   108,   109,   109,   110,   110,   110,   111,   111,   111,
     111,   111,   112,   112,   113,   114,   115,   116,   117,   118,
     118,   119,   119,   119,   120,   121,   121,   121,   122,   122,
     123,   124,   124,   125,   125,   126,   126,   126,   127,   127,
     127,   128,   128,   129,   129,   130,   130,   131,   131,   132,
     132,   133,   133,   134,   135,   136,   137,   137,   138,   138,
     139,   140,   140,   141,   141,   141,   141,   141,   142,   142,
     143,   143,   144,   144,   144,   144,   144,   144,   145,   146,
     147,   148,   148,   149,   149,   149,   150,   151,   151,   152,
     152,   153,   153,   154,   154,   154,   154,   155,   156,   157,
     157,   158,   158,   159,   160,   161,   161,   161,   162,   163,
     164,   164,   164,   165,   166,   166,   167,   167,   168,   168,
     169,   170,   170,   171,   171,   172,   173,   173,   174,   175,
     175,   176,   176,   177,   178,   179,   179,   180,   180,   181,
     181,   182,   182,   183,   183,   184,   185,   185,   185,   185,
     185,   185,   186,   187,   187,   188,   188,   189,   189,   189,
     189,   189,   189,   189,   190,   190,   190,   190,   190,   191,
     191,   191,   192,   192,   192,   192,   193,   193,   193,   193,
     193,   194,   195,   195,   195,   195,   195,   195,   195,   195,
     195,   195,   195,   196,   196,   197,   197,   198,   198,   198,
     199,   199,   199,   200,   200,   200,   201,   201,   201,   202,
     202,   203,   203
};

/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
static const yytype_uint8 yyr2[] =
{
       0,     2,     3,     1,     0,     1,     1,     1,     1,     1,
       2,     1,     1,     1,     1,     1,     1,     1,     1,     2,
       2,     0,     4,     0,     6,     6,     5,     1,     1,     2,
       3,     1,     1,     3,     1,     3,     3,     1,     1,     1,
       1,     1,     4,     4,     4,     4,     4,     4,     5,     5,
       5,     2,     3,     1,     3,     3,     5,     5,     1,     5,
       5,     1,     1,     2,     1,     3,     5,     5,    11,     7,
       7,     1,     3,     3,     4,     3,     4,     2,     4,     3,
       3,     1,     0,     1,     2,     1,     2,     1,     1,     0,
       3,     3,     0,     2,     2,     1,     1,     0,     3,     0,
       2,     1,     2,     2,     1,     1,     1,     1,     2,     2,
       4,     1,     0,     2,     1,     0,     3,     1,     1,     1,
       0,     3,     1,     1,     1,     1,     1,     2,     3,     3,
       1,     3,     1,     6,     2,     1,     1,     1,     3,     4,
       3,     1,     0,     3,     1,     0,     3,     1,     2,     2,
       3,     2,     0,     1,     0,     2,     2,     0,     1,     1,
       1,     1,     1,     3,     3,     2,     1,     1,     1,     1,
       1,     1,     1,     2,     2,     1,     1,     1,     1,     1,
       1,     2,     1,     3,     1,     3,     1,     3,     3,     3,
       3,     3,     3,     1,     3,     3,     2,     2,     1,     3,
       3,     1,     2,     2,     2,     1,     1,     1,     1,     1,
       1,     3,     4,     4,     6,     4,     4,     6,     4,     4,
       4,     1,     1,     6,     8,     1,     1,     1,     1,     1,
       1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
       1,     1,     2
};

/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
   STATE-NUM when YYTABLE doesn't specify something else to do.  Zero
   means the default is an error.  */
static const yytype_uint8 yydefact[] =
{
      21,     0,     0,     4,    23,    20,     1,     3,     0,    19,
       0,     0,     0,    82,    82,    82,     0,    71,     0,     0,
       0,     2,     9,    11,     5,     6,     7,     8,    12,    13,
      14,    15,    16,    17,    18,     0,     0,     0,     0,     0,
       0,     0,     0,     0,     0,     0,    28,    82,    27,    31,
       0,    34,    37,    38,    39,    40,    41,    32,    82,   239,
     240,    82,    53,   171,   172,   145,    82,    81,     0,     0,
       0,    89,     0,     0,     0,    89,     0,     0,     0,     0,
       0,     0,    77,    10,     0,    82,    82,     0,     0,     0,
       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
       0,     0,     0,     0,     0,     0,     0,   177,   232,   235,
     238,   230,   233,   236,   231,   234,   237,   179,   225,   226,
     241,     0,     0,   208,   222,   210,   209,     0,   182,   184,
     186,   193,   198,   201,   205,   206,   207,   221,   142,   178,
     227,   228,   229,   176,   180,   175,   173,   174,     0,     0,
      29,     0,    89,     0,    89,    51,     0,     0,     0,   144,
     147,   154,   162,   161,     0,   169,   170,     0,     0,     0,
     112,    54,    87,     0,     0,    62,    64,     0,    61,    88,
      55,     0,     0,    65,     0,     0,    72,    73,     0,    75,
       0,     0,    22,     0,     0,     0,     0,     0,     0,     0,
       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
       0,   142,   181,     0,   242,   203,   204,   202,    35,    36,
       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
     196,   197,     0,     0,     0,   141,    92,    30,    33,    92,
      52,    92,   168,     0,   166,   167,   160,     0,     0,   159,
     143,   145,   153,   149,   148,    92,     0,    79,    80,    83,
      85,    86,   115,   111,   122,     0,     0,    58,     0,     0,
      63,     0,     0,     0,     0,    74,    76,    78,    92,    92,
      43,    42,    44,    45,    46,    47,     0,     0,     0,     0,
       0,     0,     0,     0,     0,     0,     0,   211,   183,   185,
     187,   188,   189,   190,   191,   192,   194,   195,   199,   200,
       0,   138,     0,    26,    99,    50,    49,   164,   165,   163,
     152,   157,   158,   146,    48,    84,     0,     0,     0,     0,
     130,     0,   114,   120,   117,   123,   125,   124,   126,   118,
     112,     0,    57,     0,    56,    67,    66,     0,     0,    24,
      25,   216,     0,     0,   212,   213,   215,   218,   219,   220,
       0,   139,   140,     0,     0,    97,   154,   150,     0,   155,
     127,     0,     0,   134,   137,   135,   136,     0,     0,   110,
     113,   119,   112,   121,     0,     0,    89,    89,     0,     0,
       0,     0,     0,    91,   101,   104,   105,   106,   107,     0,
       0,     0,    90,    95,    96,   151,   156,   128,     0,   132,
     129,   116,     0,    60,     0,    69,    70,     0,   223,   214,
     217,   102,   103,   100,    98,   108,   109,    93,    94,     0,
       0,    59,     0,     0,     0,   131,     0,   224,   133,    89,
      68
};

/* YYDEFGOTO[NTERM-NUM].  */
static const yytype_int16 yydefgoto[] =
{
      -1,     2,     8,    21,    22,    23,     3,     4,     9,    24,
      47,    48,    49,    50,    51,    52,    53,    54,    55,    56,
      25,    26,    61,    27,    28,   266,   175,   176,   177,    29,
      30,    31,    32,    33,    34,    67,    72,   257,   258,   259,
     179,   180,   313,   314,   402,   365,   393,   394,   403,   404,
     172,   262,   331,   332,   333,   382,   263,   334,   335,   336,
     337,   410,   338,   339,   373,   123,   124,   234,    66,   158,
     178,   160,   252,   367,   253,   320,   369,   321,   248,   161,
     162,   163,   243,   322,   164,   249,   125,   146,   126,   213,
     128,   129,   130,   131,   132,   133,   134,   135,   136,   137,
     138,   139,   140,   141,   142,   143,   144
};

/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
   STATE-NUM.  */
#define YYPACT_NINF -360
static const yytype_int16 yypact[] =
{
      26,   -42,    50,     5,  -360,  -360,  -360,  -360,   770,    45,
    1020,   288,    14,  -360,    -8,    -3,     3,    86,    30,    31,
      32,  -360,   187,  -360,  -360,  -360,  -360,  -360,  -360,  -360,
    -360,  -360,  -360,  -360,  -360,   -15,   272,   272,    56,    69,
      74,    82,    88,   401,    80,    80,  -360,  -360,   406,  -360,
     102,  -360,  -360,  -360,  -360,  -360,  -360,  -360,  -360,  -360,
    -360,   231,  -360,  -360,  -360,  1092,  -360,  -360,    15,   105,
     899,    38,   158,   115,   899,    38,    87,    91,   110,   182,
     117,   184,   164,  -360,   127,  -360,  -360,   478,   632,   632,
     632,   632,   160,   163,   169,   183,   186,   189,   190,   191,
     194,   199,   203,   555,   201,   709,   709,  -360,  -360,  -360,
    -360,  -360,  -360,  -360,  -360,  -360,  -360,  -360,  -360,  -360,
    -360,   709,   204,  -360,  -360,  -360,  -360,   205,   206,   202,
    -360,   455,   308,    62,  -360,  -360,  -360,  -360,   632,  -360,
    -360,  -360,  -360,  -360,  -360,  -360,  -360,  -360,    15,   414,
    -360,    80,    15,   285,    15,  -360,  1022,   181,   227,  -360,
     208,   107,  -360,  -360,   107,  -360,  -360,    15,    17,   235,
    1092,  -360,  -360,   937,   285,  -360,  -360,   195,  -360,  -360,
    -360,   937,   747,  -360,   236,   237,  -360,  -360,   210,  -360,
     212,   216,  -360,    15,    15,   248,   249,   250,   259,   263,
     267,    78,   632,   632,   632,   632,   632,   632,   632,   632,
     632,   632,  -360,   268,  -360,  -360,  -360,  -360,  -360,  -360,
     632,   632,   632,   632,   632,   632,   632,   632,   632,   632,
    -360,  -360,   632,   632,    51,  -360,   294,  -360,  -360,   294,
    -360,   294,  -360,  1059,  -360,  -360,  -360,   281,  1092,  -360,
    -360,  1092,  -360,  -360,  -360,   294,   -58,  -360,  -360,  -360,
    -360,  -360,   116,  -360,   232,   253,   293,  -360,   282,    12,
    -360,   299,    12,   899,   899,  -360,  -360,  -360,   294,   294,
    -360,  -360,  -360,  -360,  -360,  -360,   292,   297,   300,   306,
     307,   311,   312,   314,   320,   310,    61,  -360,   202,  -360,
    -360,  -360,  -360,  -360,  -360,  -360,  -360,  -360,  -360,  -360,
     632,  -360,   357,  -360,   361,  -360,  -360,  -360,  -360,  -360,
     289,   331,  -360,  -360,  -360,  -360,   235,   285,   369,   348,
     392,   284,  -360,   316,  -360,  -360,  -360,  -360,  -360,  -360,
    1092,   346,  -360,  1092,  -360,  -360,  -360,   785,   823,  -360,
    -360,  -360,   632,   632,  -360,  -360,  -360,  -360,  -360,  -360,
     632,  -360,  -360,   978,   390,    72,   107,  -360,  1092,  -360,
    -360,   235,   632,  -360,  -360,  -360,  -360,    78,   235,  -360,
    -360,  -360,  1092,  -360,  1092,   352,    20,    12,    66,   358,
     359,   362,   362,   978,  -360,  -360,  -360,  -360,  -360,   978,
     338,   339,  -360,   408,   409,  -360,  -360,  -360,   360,  -360,
     434,  -360,   387,  -360,   389,  -360,  -360,   632,  -360,  -360,
    -360,  -360,  -360,  -360,   978,  -360,  -360,  -360,  -360,   632,
     235,  -360,   899,   399,   410,  -360,   861,  -360,  -360,    12,
    -360
};

/* YYPGOTO[NTERM-NUM].  */
static const yytype_int16 yypgoto[] =
{
    -360,  -360,  -360,  -360,  -360,   443,  -360,  -360,  -360,  -360,
     113,  -360,   -34,  -360,   423,  -360,  -360,  -360,  -360,  -360,
    -360,  -360,  -360,  -360,  -360,   290,  -360,  -170,   -71,  -360,
    -360,  -360,  -360,  -360,  -360,   179,    24,  -360,  -360,   219,
     -35,   -73,    13,  -360,  -360,  -360,    73,  -359,    92,    95,
    -165,  -309,  -360,   168,  -360,  -360,  -157,  -360,  -360,  -360,
    -360,  -360,  -360,  -360,  -360,  -310,  -360,   317,  -360,   244,
     -59,  -160,  -128,  -360,   134,   135,  -360,  -360,  -360,  -148,
    -360,  -360,  -360,  -141,  -147,     0,   -10,   -40,   -25,   -21,
    -360,   309,   318,   291,   -23,  -360,    21,  -305,  -300,  -360,
    -360,  -360,  -360,   370,   373,    43,  -360
};

/* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
   positive, shift that token.  If negative, reduce the rule which
   number is the opposite.  If zero, do what YYDEFACT says.
   If YYTABLE_NINF, syntax error.  */
#define YYTABLE_NINF -82
static const yytype_int16 yytable[] =
{
      57,    63,   183,   182,   261,   147,   159,   270,   242,   245,
     264,    62,   270,   264,   150,   244,   267,   169,   374,   168,
     169,   264,   127,   375,   267,   169,    57,    57,   376,   247,
      59,   383,    60,   171,   423,   256,   254,    68,    57,    69,
     166,     1,   -81,   169,    73,   166,     5,    78,    80,   166,
       6,    63,    70,   395,    64,   165,     7,    74,   397,    35,
     165,   155,   414,   398,   165,   423,   196,   197,   198,   199,
     200,   148,   170,   411,    65,   170,    79,    81,    84,   239,
     170,   241,   152,   395,   400,   154,   421,   422,   397,   395,
     167,    76,   401,   398,   397,   242,   245,   330,   170,   398,
     242,   245,   318,    77,    64,    59,   310,    60,   311,   193,
     194,   238,    87,   236,   395,   237,   310,   235,   361,   397,
      82,   417,   326,   418,   398,    88,   215,   216,   184,   185,
      89,   166,   255,   327,   246,   328,   232,   233,    90,    57,
      44,    45,   217,    63,    91,   166,   165,    63,   166,    85,
      86,    63,   166,   240,    63,   151,   166,   166,   278,   279,
     165,   370,   168,   165,    63,   173,   330,   165,   329,    44,
      45,   165,   165,   145,   268,   181,   170,   270,   270,   186,
     264,   287,   288,   289,   290,   291,   292,   293,   294,   295,
     235,   286,   159,    71,    75,    59,    64,    60,   187,   188,
      64,   190,   347,   348,    64,   189,   407,    64,   246,   308,
     309,   260,   174,   409,   191,   192,   201,    64,   166,   202,
     242,   245,   264,   166,   264,   203,   166,   412,    14,    15,
      16,    17,    18,   165,   344,    19,    20,   346,   165,   204,
     214,   165,   205,    44,    45,   206,   207,   208,   166,   166,
     209,   156,   315,   157,   316,   210,   269,    44,    45,   211,
     214,   218,   219,   165,   165,   435,   270,   221,   324,    59,
     220,    60,   107,   108,   109,   110,   111,   112,   113,   114,
     115,   116,   117,    59,   385,    60,   153,   120,   250,   362,
     326,   349,   350,    44,    45,   170,   273,   274,   275,   260,
     276,   327,   251,   328,   277,   280,   281,   282,    38,    39,
      40,    41,    42,   415,   416,   166,   283,    63,   166,    59,
     284,    60,   166,   166,   285,   297,   340,   371,    43,   312,
     165,   388,   389,   165,    44,    45,   329,   165,   165,   390,
     319,   341,   343,   166,   170,   379,    46,    44,    45,   351,
      44,    45,   352,   396,   342,   353,    63,   166,   165,   166,
     345,   436,    58,   354,   355,   360,   440,   408,   356,   357,
      64,   358,   165,    59,   165,    60,    59,   359,    60,   363,
     228,   229,   364,   396,   366,    92,   368,   109,   110,   396,
     112,   113,    93,   115,   116,    94,   433,    95,    96,    97,
      98,    99,   100,   101,   377,   378,   384,   166,   434,    64,
     381,   166,   399,   413,   396,   419,   420,    92,   372,   425,
     426,   400,   165,   102,    93,   372,   165,    94,   401,    95,
      96,    97,    98,    99,   100,   101,   429,    38,    39,    40,
      41,    42,    38,    39,    40,    41,    42,   430,   431,   432,
      38,    39,    40,    41,    42,   102,   437,   103,   118,   104,
     119,   149,    43,    44,    45,    83,   122,   438,    44,    45,
      43,   271,   424,   105,   106,   325,    44,    45,   107,   108,
     109,   110,   111,   112,   113,   114,   115,   116,   117,    59,
     118,    60,   119,   120,    92,   323,   428,   121,   427,   380,
     405,    93,   230,   406,    94,   231,    95,    96,    97,    98,
      99,   100,   101,   300,   301,   302,   303,   304,   305,   306,
     307,   222,   223,   224,   225,   226,   227,     0,   296,   298,
       0,     0,   102,     0,   103,     0,   104,     0,     0,   299,
      44,    45,     0,     0,     0,     0,     0,     0,     0,     0,
     105,   106,   195,     0,     0,   107,   108,   109,   110,   111,
     112,   113,   114,   115,   116,   117,    59,   118,    60,   119,
     120,    92,     0,     0,   121,     0,     0,     0,    93,     0,
       0,    94,     0,    95,    96,    97,    98,    99,   100,   101,
       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
       0,     0,     0,     0,     0,     0,     0,     0,     0,   102,
       0,   103,   212,   104,     0,     0,     0,    44,    45,     0,
       0,     0,     0,     0,     0,     0,     0,   105,   106,     0,
       0,     0,   107,   108,   109,   110,   111,   112,   113,   114,
     115,   116,   117,    59,   118,    60,   119,   120,    92,     0,
       0,   121,     0,     0,     0,    93,     0,     0,    94,     0,
      95,    96,    97,    98,    99,   100,   101,     0,     0,     0,
       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
       0,     0,     0,     0,     0,     0,   102,     0,   103,     0,
     104,     0,     0,     0,    44,    45,     0,     0,     0,     0,
       0,     0,     0,     0,   105,   106,     0,     0,     0,   107,
     108,   109,   110,   111,   112,   113,   114,   115,   116,   117,
      59,   118,    60,   119,   120,    92,     0,     0,   121,     0,
       0,     0,    93,     0,     0,    94,     0,    95,    96,    97,
      98,    99,   100,   101,     0,     0,     0,     0,     0,     0,
       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
       0,     0,     0,   102,   174,   103,     0,   104,     0,     0,
       0,    44,    45,    10,     0,     0,     0,    11,    12,    13,
       0,     0,     0,     0,     0,     0,   107,   108,   109,   110,
     111,   112,   113,   114,   115,   116,   117,    59,   118,    60,
     119,   120,   174,   156,     0,   157,     0,     0,   272,    44,
      45,    14,    15,    16,    17,    18,     0,     0,    19,    20,
       0,     0,     0,     0,   107,   108,   109,   110,   111,   112,
     113,   114,   115,   116,   117,    59,     0,    60,     0,   120,
     174,   156,     0,   157,     0,     0,   386,    44,    45,     0,
       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
       0,     0,   107,   108,   109,   110,   111,   112,   113,   114,
     115,   116,   117,    59,     0,    60,     0,   120,   174,   156,
       0,   157,     0,     0,   387,    44,    45,     0,     0,     0,
       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
     107,   108,   109,   110,   111,   112,   113,   114,   115,   116,
     117,    59,     0,    60,     0,   120,   174,   156,     0,   157,
       0,     0,   439,    44,    45,     0,     0,     0,     0,     0,
       0,     0,     0,     0,     0,     0,     0,     0,   107,   108,
     109,   110,   111,   112,   113,   114,   115,   116,   117,    59,
       0,    60,     0,   120,   265,   156,     0,   157,     0,     0,
       0,    44,    45,     0,     0,     0,     0,     0,     0,     0,
       0,     0,     0,     0,     0,     0,   107,   108,   109,   110,
     111,   112,   113,   114,   115,   116,   117,    59,     0,    60,
       0,   120,     0,   156,    92,   157,     0,     0,     0,    44,
      45,    93,   391,   392,    94,     0,    95,    96,    97,    98,
      99,   100,   101,     0,   107,   108,   109,   110,   111,   112,
     113,   114,   115,   116,   117,    59,     0,    60,     0,   120,
      36,    37,   102,     0,   372,     0,     0,     0,     0,     0,
      44,    45,     0,     0,     0,     0,     0,     0,     0,     0,
       0,     0,     0,     0,     0,     0,    38,    39,    40,    41,
      42,     0,     0,     0,     0,     0,     0,   118,     0,   119,
       0,     0,     0,     0,     0,     0,    43,     0,   156,   212,
     157,     0,    44,    45,    44,    45,     0,     0,     0,     0,
       0,     0,     0,     0,    46,     0,     0,     0,     0,   107,
     108,   109,   110,   111,   112,   113,   114,   115,   116,   117,
      59,     0,    60,     0,   120,   156,   317,   157,     0,     0,
       0,    44,    45,     0,     0,     0,     0,     0,     0,     0,
       0,     0,     0,     0,     0,     0,   107,   108,   109,   110,
     111,   112,   113,   114,   115,   116,   117,    59,   156,    60,
     157,   120,     0,     0,    44,    45,     0,     0,     0,     0,
       0,     0,     0,     0,     0,     0,     0,     0,     0,   107,
     108,   109,   110,   111,   112,   113,   114,   115,   116,   117,
      59,     0,    60,     0,   120
};

static const yytype_int16 yycheck[] =
{
      10,    11,    75,    74,   169,    45,    65,   177,   156,   156,
     170,    11,   182,   173,    48,   156,   173,     5,   328,     4,
       5,   181,    43,   328,   181,     5,    36,    37,   328,   157,
      88,   340,    90,    68,   393,    18,   164,    13,    48,    47,
      65,    15,     4,     5,    47,    70,    88,    17,    17,    74,
       0,    61,    60,   363,    11,    65,    51,    60,   363,    14,
      70,    61,    42,   363,    74,   424,    87,    88,    89,    90,
      91,    47,    60,   382,    60,    60,    46,    46,    93,   152,
      60,   154,    58,   393,    12,    61,   391,   392,   393,   399,
      66,    88,    20,   393,   399,   243,   243,   262,    60,   399,
     248,   248,   243,    17,    61,    88,    55,    90,    57,    85,
      86,   151,    56,   148,   424,   149,    55,   138,    57,   424,
      88,    55,     6,    57,   424,    56,   105,   106,    41,    42,
      56,   156,   167,    17,    27,    19,    74,    75,    56,   149,
      62,    63,   121,   153,    56,   170,   156,   157,   173,    36,
      37,   161,   177,   153,   164,    53,   181,   182,   193,   194,
     170,   326,     4,   173,   174,    60,   331,   177,    52,    62,
      63,   181,   182,    93,   174,    60,    60,   347,   348,    88,
     340,   202,   203,   204,   205,   206,   207,   208,   209,   210,
     211,   201,   251,    14,    15,    88,   153,    90,    88,    17,
     157,    17,   273,   274,   161,    88,   371,   164,    27,   232,
     233,   168,    17,   378,    50,    88,    56,   174,   243,    56,
     368,   368,   382,   248,   384,    56,   251,   384,    41,    42,
      43,    44,    45,   243,   269,    48,    49,   272,   248,    56,
      59,   251,    56,    62,    63,    56,    56,    56,   273,   274,
      56,    56,   239,    58,   241,    56,    61,    62,    63,    56,
      59,    57,    57,   273,   274,   430,   436,    65,   255,    88,
      64,    90,    77,    78,    79,    80,    81,    82,    83,    84,
      85,    86,    87,    88,   343,    90,    55,    92,    61,   310,
       6,   278,   279,    62,    63,    60,    60,    60,    88,   256,
      88,    17,    94,    19,    88,    57,    57,    57,    36,    37,
      38,    39,    40,   386,   387,   340,    57,   327,   343,    88,
      57,    90,   347,   348,    57,    57,    94,   327,    56,    35,
     340,   352,   353,   343,    62,    63,    52,   347,   348,   360,
      59,    88,    60,   368,    60,    61,    74,    62,    63,    57,
      62,    63,    55,   363,    61,    55,   366,   382,   368,   384,
      61,   432,    74,    57,    57,    55,   439,   377,    57,    57,
     327,    57,   382,    88,   384,    90,    88,    57,    90,    22,
      72,    73,    21,   393,    95,    16,    55,    79,    80,   399,
      82,    83,    23,    85,    86,    26,   417,    28,    29,    30,
      31,    32,    33,    34,    56,    13,    60,   432,   429,   366,
      94,   436,    22,    61,   424,    57,    57,    16,    56,    81,
      81,    12,   432,    54,    23,    56,   436,    26,    20,    28,
      29,    30,    31,    32,    33,    34,    76,    36,    37,    38,
      39,    40,    36,    37,    38,    39,    40,    13,    61,    60,
      36,    37,    38,    39,    40,    54,    57,    56,    89,    58,
      91,    55,    56,    62,    63,    22,    43,    57,    62,    63,
      56,   181,   399,    72,    73,   256,    62,    63,    77,    78,
      79,    80,    81,    82,    83,    84,    85,    86,    87,    88,
      89,    90,    91,    92,    16,   251,   404,    96,   403,   331,
     366,    23,   132,   368,    26,   132,    28,    29,    30,    31,
      32,    33,    34,   222,   223,   224,   225,   226,   227,   228,
     229,    66,    67,    68,    69,    70,    71,    -1,   211,   220,
      -1,    -1,    54,    -1,    56,    -1,    58,    -1,    -1,   221,
      62,    63,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
      72,    73,    74,    -1,    -1,    77,    78,    79,    80,    81,
      82,    83,    84,    85,    86,    87,    88,    89,    90,    91,
      92,    16,    -1,    -1,    96,    -1,    -1,    -1,    23,    -1,
      -1,    26,    -1,    28,    29,    30,    31,    32,    33,    34,
      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    54,
      -1,    56,    57,    58,    -1,    -1,    -1,    62,    63,    -1,
      -1,    -1,    -1,    -1,    -1,    -1,    -1,    72,    73,    -1,
      -1,    -1,    77,    78,    79,    80,    81,    82,    83,    84,
      85,    86,    87,    88,    89,    90,    91,    92,    16,    -1,
      -1,    96,    -1,    -1,    -1,    23,    -1,    -1,    26,    -1,
      28,    29,    30,    31,    32,    33,    34,    -1,    -1,    -1,
      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
      -1,    -1,    -1,    -1,    -1,    -1,    54,    -1,    56,    -1,
      58,    -1,    -1,    -1,    62,    63,    -1,    -1,    -1,    -1,
      -1,    -1,    -1,    -1,    72,    73,    -1,    -1,    -1,    77,
      78,    79,    80,    81,    82,    83,    84,    85,    86,    87,
      88,    89,    90,    91,    92,    16,    -1,    -1,    96,    -1,
      -1,    -1,    23,    -1,    -1,    26,    -1,    28,    29,    30,
      31,    32,    33,    34,    -1,    -1,    -1,    -1,    -1,    -1,
      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
      -1,    -1,    -1,    54,    17,    56,    -1,    58,    -1,    -1,
      -1,    62,    63,     3,    -1,    -1,    -1,     7,     8,     9,
      -1,    -1,    -1,    -1,    -1,    -1,    77,    78,    79,    80,
      81,    82,    83,    84,    85,    86,    87,    88,    89,    90,
      91,    92,    17,    56,    -1,    58,    -1,    -1,    61,    62,
      63,    41,    42,    43,    44,    45,    -1,    -1,    48,    49,
      -1,    -1,    -1,    -1,    77,    78,    79,    80,    81,    82,
      83,    84,    85,    86,    87,    88,    -1,    90,    -1,    92,
      17,    56,    -1,    58,    -1,    -1,    61,    62,    63,    -1,
      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
      -1,    -1,    77,    78,    79,    80,    81,    82,    83,    84,
      85,    86,    87,    88,    -1,    90,    -1,    92,    17,    56,
      -1,    58,    -1,    -1,    61,    62,    63,    -1,    -1,    -1,
      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
      77,    78,    79,    80,    81,    82,    83,    84,    85,    86,
      87,    88,    -1,    90,    -1,    92,    17,    56,    -1,    58,
      -1,    -1,    61,    62,    63,    -1,    -1,    -1,    -1,    -1,
      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    77,    78,
      79,    80,    81,    82,    83,    84,    85,    86,    87,    88,
      -1,    90,    -1,    92,    17,    56,    -1,    58,    -1,    -1,
      -1,    62,    63,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
      -1,    -1,    -1,    -1,    -1,    -1,    77,    78,    79,    80,
      81,    82,    83,    84,    85,    86,    87,    88,    -1,    90,
      -1,    92,    -1,    56,    16,    58,    -1,    -1,    -1,    62,
      63,    23,    24,    25,    26,    -1,    28,    29,    30,    31,
      32,    33,    34,    -1,    77,    78,    79,    80,    81,    82,
      83,    84,    85,    86,    87,    88,    -1,    90,    -1,    92,
      10,    11,    54,    -1,    56,    -1,    -1,    -1,    -1,    -1,
      62,    63,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
      -1,    -1,    -1,    -1,    -1,    -1,    36,    37,    38,    39,
      40,    -1,    -1,    -1,    -1,    -1,    -1,    89,    -1,    91,
      -1,    -1,    -1,    -1,    -1,    -1,    56,    -1,    56,    57,
      58,    -1,    62,    63,    62,    63,    -1,    -1,    -1,    -1,
      -1,    -1,    -1,    -1,    74,    -1,    -1,    -1,    -1,    77,
      78,    79,    80,    81,    82,    83,    84,    85,    86,    87,
      88,    -1,    90,    -1,    92,    56,    57,    58,    -1,    -1,
      -1,    62,    63,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
      -1,    -1,    -1,    -1,    -1,    -1,    77,    78,    79,    80,
      81,    82,    83,    84,    85,    86,    87,    88,    56,    90,
      58,    92,    -1,    -1,    62,    63,    -1,    -1,    -1,    -1,
      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    77,
      78,    79,    80,    81,    82,    83,    84,    85,    86,    87,
      88,    -1,    90,    -1,    92
};

/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
   symbol of state STATE-NUM.  */
static const yytype_uint8 yystos[] =
{
       0,    15,    98,   103,   104,    88,     0,    51,    99,   105,
       3,     7,     8,     9,    41,    42,    43,    44,    45,    48,
      49,   100,   101,   102,   106,   117,   118,   120,   121,   126,
     127,   128,   129,   130,   131,    14,    10,    11,    36,    37,
      38,    39,    40,    56,    62,    63,    74,   107,   108,   109,
     110,   111,   112,   113,   114,   115,   116,   183,    74,    88,
      90,   119,   182,   183,   202,    60,   165,   132,   133,    47,
      60,   132,   133,    47,    60,   132,    88,    17,    17,    46,
      17,    46,    88,   102,    93,   107,   107,    56,    56,    56,
      56,    56,    16,    23,    26,    28,    29,    30,    31,    32,
      33,    34,    54,    56,    58,    72,    73,    77,    78,    79,
      80,    81,    82,    83,    84,    85,    86,    87,    89,    91,
      92,    96,   111,   162,   163,   183,   185,   186,   187,   188,
     189,   190,   191,   192,   193,   194,   195,   196,   197,   198,
     199,   200,   201,   202,   203,    93,   184,   184,   133,    55,
     109,    53,   133,    55,   133,   182,    56,    58,   166,   167,
     168,   176,   177,   178,   181,   183,   185,   133,     4,     5,
      60,   137,   147,    60,    17,   123,   124,   125,   167,   137,
     138,    60,   125,   138,    41,    42,    88,    88,    17,    88,
      17,    50,    88,   133,   133,    74,   186,   186,   186,   186,
     186,    56,    56,    56,    56,    56,    56,    56,    56,    56,
      56,    56,    57,   186,    59,   193,   193,   193,    57,    57,
      64,    65,    66,    67,    68,    69,    70,    71,    72,    73,
     200,   201,    74,    75,   164,   186,   137,   109,   184,   138,
     182,   138,   176,   179,   180,   181,    27,   169,   175,   182,
      61,    94,   169,   171,   169,   137,    18,   134,   135,   136,
     202,   147,   148,   153,   168,    17,   122,   153,   182,    61,
     124,   122,    61,    60,    60,    88,    88,    88,   137,   137,
      57,    57,    57,    57,    57,    57,   183,   186,   186,   186,
     186,   186,   186,   186,   186,   186,   164,    57,   188,   189,
     190,   190,   190,   190,   190,   190,   190,   190,   191,   191,
      55,    57,    35,   139,   140,   139,   139,    57,   180,    59,
     172,   174,   180,   166,   139,   136,     6,    17,    19,    52,
     147,   149,   150,   151,   154,   155,   156,   157,   159,   160,
      94,    88,    61,    60,   137,    61,   137,   125,   125,   139,
     139,    57,    55,    55,    57,    57,    57,    57,    57,    57,
      55,    57,   186,    22,    21,   142,    95,   170,    55,   173,
     147,   182,    56,   161,   162,   194,   195,    56,    13,    61,
     150,    94,   152,   148,    60,   167,    61,    61,   186,   186,
     186,    24,    25,   143,   144,   162,   183,   194,   195,    22,
      12,    20,   141,   145,   146,   171,   172,   147,   183,   147,
     158,   148,   153,    61,    42,   138,   138,    55,    57,    57,
      57,   194,   194,   144,   143,    81,    81,   146,   145,    76,
      13,    61,    60,   186,   186,   147,   125,    57,    57,    61,
     138
};

#define yyerrok		(yyerrstatus = 0)
#define yyclearin	(yychar = YYEMPTY)
#define YYEMPTY		(-2)
#define YYEOF		0

#define YYACCEPT	goto yyacceptlab
#define YYABORT		goto yyabortlab
#define YYERROR		goto yyerrorlab


/* Like YYERROR except do call yyerror.  This remains here temporarily
   to ease the transition to the new meaning of YYERROR, for GCC.
   Once GCC version 2 has supplanted version 1, this can go.  */

#define YYFAIL		goto yyerrlab

#define YYRECOVERING()  (!!yyerrstatus)

#define YYBACKUP(Token, Value)					\
do								\
  if (yychar == YYEMPTY && yylen == 1)				\
    {								\
      yychar = (Token);						\
      yylval = (Value);						\
      yytoken = YYTRANSLATE (yychar);				\
      YYPOPSTACK (1);						\
      goto yybackup;						\
    }								\
  else								\
    {								\
      yyerror (YY_("syntax error: cannot back up")); \
      YYERROR;							\
    }								\
while (YYID (0))


#define YYTERROR	1
#define YYERRCODE	256


/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
   If N is 0, then set CURRENT to the empty location which ends
   the previous symbol: RHS[0] (always defined).  */

#define YYRHSLOC(Rhs, K) ((Rhs)[K])
#ifndef YYLLOC_DEFAULT
# define YYLLOC_DEFAULT(Current, Rhs, N)				\
    do									\
      if (YYID (N))                                                    \
	{								\
	  (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;	\
	  (Current).first_column = YYRHSLOC (Rhs, 1).first_column;	\
	  (Current).last_line    = YYRHSLOC (Rhs, N).last_line;		\
	  (Current).last_column  = YYRHSLOC (Rhs, N).last_column;	\
	}								\
      else								\
	{								\
	  (Current).first_line   = (Current).last_line   =		\
	    YYRHSLOC (Rhs, 0).last_line;				\
	  (Current).first_column = (Current).last_column =		\
	    YYRHSLOC (Rhs, 0).last_column;				\
	}								\
    while (YYID (0))
#endif


/* YY_LOCATION_PRINT -- Print the location on the stream.
   This macro was not mandated originally: define only if we know
   we won't break user code: when these are the locations we know.  */

#ifndef YY_LOCATION_PRINT
# if YYLTYPE_IS_TRIVIAL
#  define YY_LOCATION_PRINT(File, Loc)			\
     fprintf (File, "%d.%d-%d.%d",			\
	      (Loc).first_line, (Loc).first_column,	\
	      (Loc).last_line,  (Loc).last_column)
# else
#  define YY_LOCATION_PRINT(File, Loc) ((void) 0)
# endif
#endif


/* YYLEX -- calling `yylex' with the right arguments.  */

#ifdef YYLEX_PARAM
# define YYLEX yylex (&yylval, YYLEX_PARAM)
#else
# define YYLEX yylex (&yylval)
#endif

/* Enable debugging if requested.  */
#if YYDEBUG

# ifndef YYFPRINTF
#  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
#  define YYFPRINTF fprintf
# endif

# define YYDPRINTF(Args)			\
do {						\
  if (yydebug)					\
    YYFPRINTF Args;				\
} while (YYID (0))

# define YY_SYMBOL_PRINT(Title, Type, Value, Location)			  \
do {									  \
  if (yydebug)								  \
    {									  \
      YYFPRINTF (stderr, "%s ", Title);					  \
      yy_symbol_print (stderr,						  \
		  Type, Value); \
      YYFPRINTF (stderr, "\n");						  \
    }									  \
} while (YYID (0))


/*--------------------------------.
| Print this symbol on YYOUTPUT.  |
`--------------------------------*/

/*ARGSUSED*/
#if (defined __STDC__ || defined __C99__FUNC__ \
     || defined __cplusplus || defined _MSC_VER)
static void
yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
#else
static void
yy_symbol_value_print (yyoutput, yytype, yyvaluep)
    FILE *yyoutput;
    int yytype;
    YYSTYPE const * const yyvaluep;
#endif
{
  if (!yyvaluep)
    return;
# ifdef YYPRINT
  if (yytype < YYNTOKENS)
    YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
# else
  YYUSE (yyoutput);
# endif
  switch (yytype)
    {
      default:
	break;
    }
}


/*--------------------------------.
| Print this symbol on YYOUTPUT.  |
`--------------------------------*/

#if (defined __STDC__ || defined __C99__FUNC__ \
     || defined __cplusplus || defined _MSC_VER)
static void
yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
#else
static void
yy_symbol_print (yyoutput, yytype, yyvaluep)
    FILE *yyoutput;
    int yytype;
    YYSTYPE const * const yyvaluep;
#endif
{
  if (yytype < YYNTOKENS)
    YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
  else
    YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);

  yy_symbol_value_print (yyoutput, yytype, yyvaluep);
  YYFPRINTF (yyoutput, ")");
}

/*------------------------------------------------------------------.
| yy_stack_print -- Print the state stack from its BOTTOM up to its |
| TOP (included).                                                   |
`------------------------------------------------------------------*/

#if (defined __STDC__ || defined __C99__FUNC__ \
     || defined __cplusplus || defined _MSC_VER)
static void
yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
#else
static void
yy_stack_print (yybottom, yytop)
    yytype_int16 *yybottom;
    yytype_int16 *yytop;
#endif
{
  YYFPRINTF (stderr, "Stack now");
  for (; yybottom <= yytop; yybottom++)
    {
      int yybot = *yybottom;
      YYFPRINTF (stderr, " %d", yybot);
    }
  YYFPRINTF (stderr, "\n");
}

# define YY_STACK_PRINT(Bottom, Top)				\
do {								\
  if (yydebug)							\
    yy_stack_print ((Bottom), (Top));				\
} while (YYID (0))


/*------------------------------------------------.
| Report that the YYRULE is going to be reduced.  |
`------------------------------------------------*/

#if (defined __STDC__ || defined __C99__FUNC__ \
     || defined __cplusplus || defined _MSC_VER)
static void
yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
#else
static void
yy_reduce_print (yyvsp, yyrule)
    YYSTYPE *yyvsp;
    int yyrule;
#endif
{
  int yynrhs = yyr2[yyrule];
  int yyi;
  unsigned long int yylno = yyrline[yyrule];
  YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
	     yyrule - 1, yylno);
  /* The symbols being reduced.  */
  for (yyi = 0; yyi < yynrhs; yyi++)
    {
      YYFPRINTF (stderr, "   $%d = ", yyi + 1);
      yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
		       &(yyvsp[(yyi + 1) - (yynrhs)])
		       		       );
      YYFPRINTF (stderr, "\n");
    }
}

# define YY_REDUCE_PRINT(Rule)		\
do {					\
  if (yydebug)				\
    yy_reduce_print (yyvsp, Rule); \
} while (YYID (0))

/* Nonzero means print parse trace.  It is left uninitialized so that
   multiple parsers can coexist.  */
int yydebug;
#else /* !YYDEBUG */
# define YYDPRINTF(Args)
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
# define YY_STACK_PRINT(Bottom, Top)
# define YY_REDUCE_PRINT(Rule)
#endif /* !YYDEBUG */


/* YYINITDEPTH -- initial size of the parser's stacks.  */
#ifndef	YYINITDEPTH
# define YYINITDEPTH 200
#endif

/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
   if the built-in stack extension method is used).

   Do not make this value too large; the results are undefined if
   YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
   evaluated with infinite-precision integer arithmetic.  */

#ifndef YYMAXDEPTH
# define YYMAXDEPTH 10000
#endif



#if YYERROR_VERBOSE

# ifndef yystrlen
#  if defined __GLIBC__ && defined _STRING_H
#   define yystrlen strlen
#  else
/* Return the length of YYSTR.  */
#if (defined __STDC__ || defined __C99__FUNC__ \
     || defined __cplusplus || defined _MSC_VER)
static YYSIZE_T
yystrlen (const char *yystr)
#else
static YYSIZE_T
yystrlen (yystr)
    const char *yystr;
#endif
{
  YYSIZE_T yylen;
  for (yylen = 0; yystr[yylen]; yylen++)
    continue;
  return yylen;
}
#  endif
# endif

# ifndef yystpcpy
#  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
#   define yystpcpy stpcpy
#  else
/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
   YYDEST.  */
#if (defined __STDC__ || defined __C99__FUNC__ \
     || defined __cplusplus || defined _MSC_VER)
static char *
yystpcpy (char *yydest, const char *yysrc)
#else
static char *
yystpcpy (yydest, yysrc)
    char *yydest;
    const char *yysrc;
#endif
{
  char *yyd = yydest;
  const char *yys = yysrc;

  while ((*yyd++ = *yys++) != '\0')
    continue;

  return yyd - 1;
}
#  endif
# endif

# ifndef yytnamerr
/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
   quotes and backslashes, so that it's suitable for yyerror.  The
   heuristic is that double-quoting is unnecessary unless the string
   contains an apostrophe, a comma, or backslash (other than
   backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
   null, do not copy; instead, return the length of what the result
   would have been.  */
static YYSIZE_T
yytnamerr (char *yyres, const char *yystr)
{
  if (*yystr == '"')
    {
      YYSIZE_T yyn = 0;
      char const *yyp = yystr;

      for (;;)
	switch (*++yyp)
	  {
	  case '\'':
	  case ',':
	    goto do_not_strip_quotes;

	  case '\\':
	    if (*++yyp != '\\')
	      goto do_not_strip_quotes;
	    /* Fall through.  */
	  default:
	    if (yyres)
	      yyres[yyn] = *yyp;
	    yyn++;
	    break;

	  case '"':
	    if (yyres)
	      yyres[yyn] = '\0';
	    return yyn;
	  }
    do_not_strip_quotes: ;
    }

  if (! yyres)
    return yystrlen (yystr);

  return yystpcpy (yyres, yystr) - yyres;
}
# endif

/* Copy into YYRESULT an error message about the unexpected token
   YYCHAR while in state YYSTATE.  Return the number of bytes copied,
   including the terminating null byte.  If YYRESULT is null, do not
   copy anything; just return the number of bytes that would be
   copied.  As a special case, return 0 if an ordinary "syntax error"
   message will do.  Return YYSIZE_MAXIMUM if overflow occurs during
   size calculation.  */
static YYSIZE_T
yysyntax_error (char *yyresult, int yystate, int yychar)
{
  int yyn = yypact[yystate];

  if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
    return 0;
  else
    {
      int yytype = YYTRANSLATE (yychar);
      YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
      YYSIZE_T yysize = yysize0;
      YYSIZE_T yysize1;
      int yysize_overflow = 0;
      enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
      char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
      int yyx;

# if 0
      /* This is so xgettext sees the translatable formats that are
	 constructed on the fly.  */
      YY_("syntax error, unexpected %s");
      YY_("syntax error, unexpected %s, expecting %s");
      YY_("syntax error, unexpected %s, expecting %s or %s");
      YY_("syntax error, unexpected %s, expecting %s or %s or %s");
      YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
# endif
      char *yyfmt;
      char const *yyf;
      static char const yyunexpected[] = "syntax error, unexpected %s";
      static char const yyexpecting[] = ", expecting %s";
      static char const yyor[] = " or %s";
      char yyformat[sizeof yyunexpected
		    + sizeof yyexpecting - 1
		    + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
		       * (sizeof yyor - 1))];
      char const *yyprefix = yyexpecting;

      /* Start YYX at -YYN if negative to avoid negative indexes in
	 YYCHECK.  */
      int yyxbegin = yyn < 0 ? -yyn : 0;

      /* Stay within bounds of both yycheck and yytname.  */
      int yychecklim = YYLAST - yyn + 1;
      int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
      int yycount = 1;

      yyarg[0] = yytname[yytype];
      yyfmt = yystpcpy (yyformat, yyunexpected);

      for (yyx = yyxbegin; yyx < yyxend; ++yyx)
	if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
	  {
	    if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
	      {
		yycount = 1;
		yysize = yysize0;
		yyformat[sizeof yyunexpected - 1] = '\0';
		break;
	      }
	    yyarg[yycount++] = yytname[yyx];
	    yysize1 = yysize + yytnamerr (0, yytname[yyx]);
	    yysize_overflow |= (yysize1 < yysize);
	    yysize = yysize1;
	    yyfmt = yystpcpy (yyfmt, yyprefix);
	    yyprefix = yyor;
	  }

      yyf = YY_(yyformat);
      yysize1 = yysize + yystrlen (yyf);
      yysize_overflow |= (yysize1 < yysize);
      yysize = yysize1;

      if (yysize_overflow)
	return YYSIZE_MAXIMUM;

      if (yyresult)
	{
	  /* Avoid sprintf, as that infringes on the user's name space.
	     Don't have undefined behavior even if the translation
	     produced a string with the wrong number of "%s"s.  */
	  char *yyp = yyresult;
	  int yyi = 0;
	  while ((*yyp = *yyf) != '\0')
	    {
	      if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
		{
		  yyp += yytnamerr (yyp, yyarg[yyi++]);
		  yyf += 2;
		}
	      else
		{
		  yyp++;
		  yyf++;
		}
	    }
	}
      return yysize;
    }
}
#endif /* YYERROR_VERBOSE */


/*-----------------------------------------------.
| Release the memory associated to this symbol.  |
`-----------------------------------------------*/

/*ARGSUSED*/
#if (defined __STDC__ || defined __C99__FUNC__ \
     || defined __cplusplus || defined _MSC_VER)
static void
yydestruct (void *YYPARSE_PARAM, const char *yymsg, int yytype, YYSTYPE *yyvaluep)
#else
static void
yydestruct (YYPARSE_PARAM, yymsg, yytype, yyvaluep)
    void *YYPARSE_PARAM;
    const char *yymsg;
    int yytype;
    YYSTYPE *yyvaluep;
#endif
{
  YYUSE (yyvaluep);

  if (!yymsg)
    yymsg = "Deleting";
  YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);

  switch (yytype)
    {
      case 77: /* "\"string literal\"" */

/* Line 1000 of yacc.c  */
#line 246 "./sparql_parser.y"
	{
  if((yyvaluep->literal))
    rasqal_free_literal((yyvaluep->literal));
};

/* Line 1000 of yacc.c  */
#line 1889 "sparql_parser.c"
	break;
      case 78: /* "\"double literal\"" */

/* Line 1000 of yacc.c  */
#line 246 "./sparql_parser.y"
	{
  if((yyvaluep->literal))
    rasqal_free_literal((yyvaluep->literal));
};

/* Line 1000 of yacc.c  */
#line 1901 "sparql_parser.c"
	break;
      case 79: /* "\"double positive literal\"" */

/* Line 1000 of yacc.c  */
#line 246 "./sparql_parser.y"
	{
  if((yyvaluep->literal))
    rasqal_free_literal((yyvaluep->literal));
};

/* Line 1000 of yacc.c  */
#line 1913 "sparql_parser.c"
	break;
      case 80: /* "\"double negative literal\"" */

/* Line 1000 of yacc.c  */
#line 246 "./sparql_parser.y"
	{
  if((yyvaluep->literal))
    rasqal_free_literal((yyvaluep->literal));
};

/* Line 1000 of yacc.c  */
#line 1925 "sparql_parser.c"
	break;
      case 81: /* "\"integer literal\"" */

/* Line 1000 of yacc.c  */
#line 246 "./sparql_parser.y"
	{
  if((yyvaluep->literal))
    rasqal_free_literal((yyvaluep->literal));
};

/* Line 1000 of yacc.c  */
#line 1937 "sparql_parser.c"
	break;
      case 82: /* "\"integer positive literal\"" */

/* Line 1000 of yacc.c  */
#line 246 "./sparql_parser.y"
	{
  if((yyvaluep->literal))
    rasqal_free_literal((yyvaluep->literal));
};

/* Line 1000 of yacc.c  */
#line 1949 "sparql_parser.c"
	break;
      case 83: /* "\"integer negative literal\"" */

/* Line 1000 of yacc.c  */
#line 246 "./sparql_parser.y"
	{
  if((yyvaluep->literal))
    rasqal_free_literal((yyvaluep->literal));
};

/* Line 1000 of yacc.c  */
#line 1961 "sparql_parser.c"
	break;
      case 84: /* "\"decimal literal\"" */

/* Line 1000 of yacc.c  */
#line 246 "./sparql_parser.y"
	{
  if((yyvaluep->literal))
    rasqal_free_literal((yyvaluep->literal));
};

/* Line 1000 of yacc.c  */
#line 1973 "sparql_parser.c"
	break;
      case 85: /* "\"decimal positive literal\"" */

/* Line 1000 of yacc.c  */
#line 246 "./sparql_parser.y"
	{
  if((yyvaluep->literal))
    rasqal_free_literal((yyvaluep->literal));
};

/* Line 1000 of yacc.c  */
#line 1985 "sparql_parser.c"
	break;
      case 86: /* "\"decimal negative literal\"" */

/* Line 1000 of yacc.c  */
#line 246 "./sparql_parser.y"
	{
  if((yyvaluep->literal))
    rasqal_free_literal((yyvaluep->literal));
};

/* Line 1000 of yacc.c  */
#line 1997 "sparql_parser.c"
	break;
      case 87: /* "\"boolean literal\"" */

/* Line 1000 of yacc.c  */
#line 246 "./sparql_parser.y"
	{
  if((yyvaluep->literal))
    rasqal_free_literal((yyvaluep->literal));
};

/* Line 1000 of yacc.c  */
#line 2009 "sparql_parser.c"
	break;
      case 88: /* "\"URI literal\"" */

/* Line 1000 of yacc.c  */
#line 257 "./sparql_parser.y"
	{
  if((yyvaluep->uri))
    raptor_free_uri((yyvaluep->uri));
};

/* Line 1000 of yacc.c  */
#line 2021 "sparql_parser.c"
	break;
      case 89: /* "\"URI literal (\"" */

/* Line 1000 of yacc.c  */
#line 257 "./sparql_parser.y"
	{
  if((yyvaluep->uri))
    raptor_free_uri((yyvaluep->uri));
};

/* Line 1000 of yacc.c  */
#line 2033 "sparql_parser.c"
	break;
      case 90: /* "\"QName literal\"" */

/* Line 1000 of yacc.c  */
#line 263 "./sparql_parser.y"
	{
  if((yyvaluep->name))
    RASQAL_FREE(cstring, (yyvaluep->name));
};

/* Line 1000 of yacc.c  */
#line 2045 "sparql_parser.c"
	break;
      case 91: /* "\"QName literal (\"" */

/* Line 1000 of yacc.c  */
#line 263 "./sparql_parser.y"
	{
  if((yyvaluep->name))
    RASQAL_FREE(cstring, (yyvaluep->name));
};

/* Line 1000 of yacc.c  */
#line 2057 "sparql_parser.c"
	break;
      case 92: /* "\"blank node literal\"" */

/* Line 1000 of yacc.c  */
#line 263 "./sparql_parser.y"
	{
  if((yyvaluep->name))
    RASQAL_FREE(cstring, (yyvaluep->name));
};

/* Line 1000 of yacc.c  */
#line 2069 "sparql_parser.c"
	break;
      case 93: /* "\"identifier\"" */

/* Line 1000 of yacc.c  */
#line 263 "./sparql_parser.y"
	{
  if((yyvaluep->name))
    RASQAL_FREE(cstring, (yyvaluep->name));
};

/* Line 1000 of yacc.c  */
#line 2081 "sparql_parser.c"
	break;
      case 106: /* "SelectQuery" */

/* Line 1000 of yacc.c  */
#line 269 "./sparql_parser.y"
	{
  if((yyvaluep->seq))
    raptor_free_sequence((yyvaluep->seq));
};

/* Line 1000 of yacc.c  */
#line 2093 "sparql_parser.c"
	break;
      case 107: /* "SelectExpressionList" */

/* Line 1000 of yacc.c  */
#line 269 "./sparql_parser.y"
	{
  if((yyvaluep->seq))
    raptor_free_sequence((yyvaluep->seq));
};

/* Line 1000 of yacc.c  */
#line 2105 "sparql_parser.c"
	break;
      case 108: /* "SelectExpressionListTail" */

/* Line 1000 of yacc.c  */
#line 269 "./sparql_parser.y"
	{
  if((yyvaluep->seq))
    raptor_free_sequence((yyvaluep->seq));
};

/* Line 1000 of yacc.c  */
#line 2117 "sparql_parser.c"
	break;
      case 109: /* "SelectTerm" */

/* Line 1000 of yacc.c  */
#line 333 "./sparql_parser.y"
	{
  if((yyvaluep->variable))
    rasqal_free_variable((yyvaluep->variable));
};

/* Line 1000 of yacc.c  */
#line 2129 "sparql_parser.c"
	break;
      case 110: /* "SelectExpression" */

/* Line 1000 of yacc.c  */
#line 309 "./sparql_parser.y"
	{
  if((yyvaluep->expr))
    rasqal_free_expression((yyvaluep->expr));
};

/* Line 1000 of yacc.c  */
#line 2141 "sparql_parser.c"
	break;
      case 111: /* "AggregateExpression" */

/* Line 1000 of yacc.c  */
#line 309 "./sparql_parser.y"
	{
  if((yyvaluep->expr))
    rasqal_free_expression((yyvaluep->expr));
};

/* Line 1000 of yacc.c  */
#line 2153 "sparql_parser.c"
	break;
      case 112: /* "CountAggregateExpression" */

/* Line 1000 of yacc.c  */
#line 309 "./sparql_parser.y"
	{
  if((yyvaluep->expr))
    rasqal_free_expression((yyvaluep->expr));
};

/* Line 1000 of yacc.c  */
#line 2165 "sparql_parser.c"
	break;
      case 113: /* "SumAggregateExpression" */

/* Line 1000 of yacc.c  */
#line 309 "./sparql_parser.y"
	{
  if((yyvaluep->expr))
    rasqal_free_expression((yyvaluep->expr));
};

/* Line 1000 of yacc.c  */
#line 2177 "sparql_parser.c"
	break;
      case 114: /* "AvgAggregateExpression" */

/* Line 1000 of yacc.c  */
#line 309 "./sparql_parser.y"
	{
  if((yyvaluep->expr))
    rasqal_free_expression((yyvaluep->expr));
};

/* Line 1000 of yacc.c  */
#line 2189 "sparql_parser.c"
	break;
      case 115: /* "MinAggregateExpression" */

/* Line 1000 of yacc.c  */
#line 309 "./sparql_parser.y"
	{
  if((yyvaluep->expr))
    rasqal_free_expression((yyvaluep->expr));
};

/* Line 1000 of yacc.c  */
#line 2201 "sparql_parser.c"
	break;
      case 116: /* "MaxAggregateExpression" */

/* Line 1000 of yacc.c  */
#line 309 "./sparql_parser.y"
	{
  if((yyvaluep->expr))
    rasqal_free_expression((yyvaluep->expr));
};

/* Line 1000 of yacc.c  */
#line 2213 "sparql_parser.c"
	break;
      case 117: /* "ConstructQuery" */

/* Line 1000 of yacc.c  */
#line 269 "./sparql_parser.y"
	{
  if((yyvaluep->seq))
    raptor_free_sequence((yyvaluep->seq));
};

/* Line 1000 of yacc.c  */
#line 2225 "sparql_parser.c"
	break;
      case 118: /* "DescribeQuery" */

/* Line 1000 of yacc.c  */
#line 269 "./sparql_parser.y"
	{
  if((yyvaluep->seq))
    raptor_free_sequence((yyvaluep->seq));
};

/* Line 1000 of yacc.c  */
#line 2237 "sparql_parser.c"
	break;
      case 119: /* "VarOrIRIrefList" */

/* Line 1000 of yacc.c  */
#line 269 "./sparql_parser.y"
	{
  if((yyvaluep->seq))
    raptor_free_sequence((yyvaluep->seq));
};

/* Line 1000 of yacc.c  */
#line 2249 "sparql_parser.c"
	break;
      case 122: /* "GraphTriples" */

/* Line 1000 of yacc.c  */
#line 280 "./sparql_parser.y"
	{
  if((yyvaluep->update))
    rasqal_free_update_operation((yyvaluep->update));
};

/* Line 1000 of yacc.c  */
#line 2261 "sparql_parser.c"
	break;
      case 123: /* "GraphTemplate" */

/* Line 1000 of yacc.c  */
#line 297 "./sparql_parser.y"
	{
  if((yyvaluep->graph_pattern))
    rasqal_free_graph_pattern((yyvaluep->graph_pattern));
};

/* Line 1000 of yacc.c  */
#line 2273 "sparql_parser.c"
	break;
      case 124: /* "ModifyTemplate" */

/* Line 1000 of yacc.c  */
#line 297 "./sparql_parser.y"
	{
  if((yyvaluep->graph_pattern))
    rasqal_free_graph_pattern((yyvaluep->graph_pattern));
};

/* Line 1000 of yacc.c  */
#line 2285 "sparql_parser.c"
	break;
      case 125: /* "ModifyTemplateList" */

/* Line 1000 of yacc.c  */
#line 269 "./sparql_parser.y"
	{
  if((yyvaluep->seq))
    raptor_free_sequence((yyvaluep->seq));
};

/* Line 1000 of yacc.c  */
#line 2297 "sparql_parser.c"
	break;
      case 136: /* "SourceSelector" */

/* Line 1000 of yacc.c  */
#line 323 "./sparql_parser.y"
	{
  if((yyvaluep->literal))
    rasqal_free_literal((yyvaluep->literal));
};

/* Line 1000 of yacc.c  */
#line 2309 "sparql_parser.c"
	break;
      case 143: /* "OrderConditionList" */

/* Line 1000 of yacc.c  */
#line 269 "./sparql_parser.y"
	{
  if((yyvaluep->seq))
    raptor_free_sequence((yyvaluep->seq));
};

/* Line 1000 of yacc.c  */
#line 2321 "sparql_parser.c"
	break;
      case 144: /* "OrderCondition" */

/* Line 1000 of yacc.c  */
#line 309 "./sparql_parser.y"
	{
  if((yyvaluep->expr))
    rasqal_free_expression((yyvaluep->expr));
};

/* Line 1000 of yacc.c  */
#line 2333 "sparql_parser.c"
	break;
      case 147: /* "GroupGraphPattern" */

/* Line 1000 of yacc.c  */
#line 297 "./sparql_parser.y"
	{
  if((yyvaluep->graph_pattern))
    rasqal_free_graph_pattern((yyvaluep->graph_pattern));
};

/* Line 1000 of yacc.c  */
#line 2345 "sparql_parser.c"
	break;
      case 148: /* "TriplesBlockOpt" */

/* Line 1000 of yacc.c  */
#line 286 "./sparql_parser.y"
	{
  if((yyvaluep->formula))
    rasqal_free_formula((yyvaluep->formula));
};

/* Line 1000 of yacc.c  */
#line 2357 "sparql_parser.c"
	break;
      case 149: /* "GraphPatternListOpt" */

/* Line 1000 of yacc.c  */
#line 297 "./sparql_parser.y"
	{
  if((yyvaluep->graph_pattern))
    rasqal_free_graph_pattern((yyvaluep->graph_pattern));
};

/* Line 1000 of yacc.c  */
#line 2369 "sparql_parser.c"
	break;
      case 150: /* "GraphPatternList" */

/* Line 1000 of yacc.c  */
#line 297 "./sparql_parser.y"
	{
  if((yyvaluep->graph_pattern))
    rasqal_free_graph_pattern((yyvaluep->graph_pattern));
};

/* Line 1000 of yacc.c  */
#line 2381 "sparql_parser.c"
	break;
      case 151: /* "GraphPatternListFilter" */

/* Line 1000 of yacc.c  */
#line 297 "./sparql_parser.y"
	{
  if((yyvaluep->graph_pattern))
    rasqal_free_graph_pattern((yyvaluep->graph_pattern));
};

/* Line 1000 of yacc.c  */
#line 2393 "sparql_parser.c"
	break;
      case 153: /* "TriplesBlock" */

/* Line 1000 of yacc.c  */
#line 286 "./sparql_parser.y"
	{
  if((yyvaluep->formula))
    rasqal_free_formula((yyvaluep->formula));
};

/* Line 1000 of yacc.c  */
#line 2405 "sparql_parser.c"
	break;
      case 154: /* "GraphPatternNotTriples" */

/* Line 1000 of yacc.c  */
#line 297 "./sparql_parser.y"
	{
  if((yyvaluep->graph_pattern))
    rasqal_free_graph_pattern((yyvaluep->graph_pattern));
};

/* Line 1000 of yacc.c  */
#line 2417 "sparql_parser.c"
	break;
      case 155: /* "OptionalGraphPattern" */

/* Line 1000 of yacc.c  */
#line 297 "./sparql_parser.y"
	{
  if((yyvaluep->graph_pattern))
    rasqal_free_graph_pattern((yyvaluep->graph_pattern));
};

/* Line 1000 of yacc.c  */
#line 2429 "sparql_parser.c"
	break;
      case 156: /* "GraphGraphPattern" */

/* Line 1000 of yacc.c  */
#line 297 "./sparql_parser.y"
	{
  if((yyvaluep->graph_pattern))
    rasqal_free_graph_pattern((yyvaluep->graph_pattern));
};

/* Line 1000 of yacc.c  */
#line 2441 "sparql_parser.c"
	break;
      case 157: /* "GroupOrUnionGraphPattern" */

/* Line 1000 of yacc.c  */
#line 297 "./sparql_parser.y"
	{
  if((yyvaluep->graph_pattern))
    rasqal_free_graph_pattern((yyvaluep->graph_pattern));
};

/* Line 1000 of yacc.c  */
#line 2453 "sparql_parser.c"
	break;
      case 158: /* "GroupOrUnionGraphPatternList" */

/* Line 1000 of yacc.c  */
#line 297 "./sparql_parser.y"
	{
  if((yyvaluep->graph_pattern))
    rasqal_free_graph_pattern((yyvaluep->graph_pattern));
};

/* Line 1000 of yacc.c  */
#line 2465 "sparql_parser.c"
	break;
      case 159: /* "LetGraphPattern" */

/* Line 1000 of yacc.c  */
#line 297 "./sparql_parser.y"
	{
  if((yyvaluep->graph_pattern))
    rasqal_free_graph_pattern((yyvaluep->graph_pattern));
};

/* Line 1000 of yacc.c  */
#line 2477 "sparql_parser.c"
	break;
      case 160: /* "Filter" */

/* Line 1000 of yacc.c  */
#line 309 "./sparql_parser.y"
	{
  if((yyvaluep->expr))
    rasqal_free_expression((yyvaluep->expr));
};

/* Line 1000 of yacc.c  */
#line 2489 "sparql_parser.c"
	break;
      case 161: /* "Constraint" */

/* Line 1000 of yacc.c  */
#line 309 "./sparql_parser.y"
	{
  if((yyvaluep->expr))
    rasqal_free_expression((yyvaluep->expr));
};

/* Line 1000 of yacc.c  */
#line 2501 "sparql_parser.c"
	break;
      case 162: /* "FunctionCall" */

/* Line 1000 of yacc.c  */
#line 309 "./sparql_parser.y"
	{
  if((yyvaluep->expr))
    rasqal_free_expression((yyvaluep->expr));
};

/* Line 1000 of yacc.c  */
#line 2513 "sparql_parser.c"
	break;
      case 163: /* "CoalesceExpression" */

/* Line 1000 of yacc.c  */
#line 309 "./sparql_parser.y"
	{
  if((yyvaluep->expr))
    rasqal_free_expression((yyvaluep->expr));
};

/* Line 1000 of yacc.c  */
#line 2525 "sparql_parser.c"
	break;
      case 164: /* "ArgList" */

/* Line 1000 of yacc.c  */
#line 269 "./sparql_parser.y"
	{
  if((yyvaluep->seq))
    raptor_free_sequence((yyvaluep->seq));
};

/* Line 1000 of yacc.c  */
#line 2537 "sparql_parser.c"
	break;
      case 165: /* "ConstructTemplate" */

/* Line 1000 of yacc.c  */
#line 269 "./sparql_parser.y"
	{
  if((yyvaluep->seq))
    raptor_free_sequence((yyvaluep->seq));
};

/* Line 1000 of yacc.c  */
#line 2549 "sparql_parser.c"
	break;
      case 166: /* "ConstructTriplesOpt" */

/* Line 1000 of yacc.c  */
#line 269 "./sparql_parser.y"
	{
  if((yyvaluep->seq))
    raptor_free_sequence((yyvaluep->seq));
};

/* Line 1000 of yacc.c  */
#line 2561 "sparql_parser.c"
	break;
      case 167: /* "ConstructTriples" */

/* Line 1000 of yacc.c  */
#line 269 "./sparql_parser.y"
	{
  if((yyvaluep->seq))
    raptor_free_sequence((yyvaluep->seq));
};

/* Line 1000 of yacc.c  */
#line 2573 "sparql_parser.c"
	break;
      case 168: /* "TriplesSameSubject" */

/* Line 1000 of yacc.c  */
#line 286 "./sparql_parser.y"
	{
  if((yyvaluep->formula))
    rasqal_free_formula((yyvaluep->formula));
};

/* Line 1000 of yacc.c  */
#line 2585 "sparql_parser.c"
	break;
      case 169: /* "PropertyListNotEmpty" */

/* Line 1000 of yacc.c  */
#line 286 "./sparql_parser.y"
	{
  if((yyvaluep->formula))
    rasqal_free_formula((yyvaluep->formula));
};

/* Line 1000 of yacc.c  */
#line 2597 "sparql_parser.c"
	break;
      case 170: /* "PropertyListTailOpt" */

/* Line 1000 of yacc.c  */
#line 286 "./sparql_parser.y"
	{
  if((yyvaluep->formula))
    rasqal_free_formula((yyvaluep->formula));
};

/* Line 1000 of yacc.c  */
#line 2609 "sparql_parser.c"
	break;
      case 171: /* "PropertyList" */

/* Line 1000 of yacc.c  */
#line 286 "./sparql_parser.y"
	{
  if((yyvaluep->formula))
    rasqal_free_formula((yyvaluep->formula));
};

/* Line 1000 of yacc.c  */
#line 2621 "sparql_parser.c"
	break;
      case 172: /* "ObjectList" */

/* Line 1000 of yacc.c  */
#line 286 "./sparql_parser.y"
	{
  if((yyvaluep->formula))
    rasqal_free_formula((yyvaluep->formula));
};

/* Line 1000 of yacc.c  */
#line 2633 "sparql_parser.c"
	break;
      case 173: /* "ObjectTail" */

/* Line 1000 of yacc.c  */
#line 286 "./sparql_parser.y"
	{
  if((yyvaluep->formula))
    rasqal_free_formula((yyvaluep->formula));
};

/* Line 1000 of yacc.c  */
#line 2645 "sparql_parser.c"
	break;
      case 174: /* "Object" */

/* Line 1000 of yacc.c  */
#line 286 "./sparql_parser.y"
	{
  if((yyvaluep->formula))
    rasqal_free_formula((yyvaluep->formula));
};

/* Line 1000 of yacc.c  */
#line 2657 "sparql_parser.c"
	break;
      case 175: /* "Verb" */

/* Line 1000 of yacc.c  */
#line 286 "./sparql_parser.y"
	{
  if((yyvaluep->formula))
    rasqal_free_formula((yyvaluep->formula));
};

/* Line 1000 of yacc.c  */
#line 2669 "sparql_parser.c"
	break;
      case 176: /* "TriplesNode" */

/* Line 1000 of yacc.c  */
#line 286 "./sparql_parser.y"
	{
  if((yyvaluep->formula))
    rasqal_free_formula((yyvaluep->formula));
};

/* Line 1000 of yacc.c  */
#line 2681 "sparql_parser.c"
	break;
      case 177: /* "BlankNodePropertyList" */

/* Line 1000 of yacc.c  */
#line 286 "./sparql_parser.y"
	{
  if((yyvaluep->formula))
    rasqal_free_formula((yyvaluep->formula));
};

/* Line 1000 of yacc.c  */
#line 2693 "sparql_parser.c"
	break;
      case 178: /* "Collection" */

/* Line 1000 of yacc.c  */
#line 286 "./sparql_parser.y"
	{
  if((yyvaluep->formula))
    rasqal_free_formula((yyvaluep->formula));
};

/* Line 1000 of yacc.c  */
#line 2705 "sparql_parser.c"
	break;
      case 179: /* "GraphNodeListNotEmpty" */

/* Line 1000 of yacc.c  */
#line 269 "./sparql_parser.y"
	{
  if((yyvaluep->seq))
    raptor_free_sequence((yyvaluep->seq));
};

/* Line 1000 of yacc.c  */
#line 2717 "sparql_parser.c"
	break;
      case 180: /* "GraphNode" */

/* Line 1000 of yacc.c  */
#line 286 "./sparql_parser.y"
	{
  if((yyvaluep->formula))
    rasqal_free_formula((yyvaluep->formula));
};

/* Line 1000 of yacc.c  */
#line 2729 "sparql_parser.c"
	break;
      case 181: /* "VarOrTerm" */

/* Line 1000 of yacc.c  */
#line 286 "./sparql_parser.y"
	{
  if((yyvaluep->formula))
    rasqal_free_formula((yyvaluep->formula));
};

/* Line 1000 of yacc.c  */
#line 2741 "sparql_parser.c"
	break;
      case 182: /* "VarOrIRIref" */

/* Line 1000 of yacc.c  */
#line 323 "./sparql_parser.y"
	{
  if((yyvaluep->literal))
    rasqal_free_literal((yyvaluep->literal));
};

/* Line 1000 of yacc.c  */
#line 2753 "sparql_parser.c"
	break;
      case 183: /* "Var" */

/* Line 1000 of yacc.c  */
#line 333 "./sparql_parser.y"
	{
  if((yyvaluep->variable))
    rasqal_free_variable((yyvaluep->variable));
};

/* Line 1000 of yacc.c  */
#line 2765 "sparql_parser.c"
	break;
      case 184: /* "VarName" */

/* Line 1000 of yacc.c  */
#line 333 "./sparql_parser.y"
	{
  if((yyvaluep->variable))
    rasqal_free_variable((yyvaluep->variable));
};

/* Line 1000 of yacc.c  */
#line 2777 "sparql_parser.c"
	break;
      case 185: /* "GraphTerm" */

/* Line 1000 of yacc.c  */
#line 323 "./sparql_parser.y"
	{
  if((yyvaluep->literal))
    rasqal_free_literal((yyvaluep->literal));
};

/* Line 1000 of yacc.c  */
#line 2789 "sparql_parser.c"
	break;
      case 186: /* "Expression" */

/* Line 1000 of yacc.c  */
#line 309 "./sparql_parser.y"
	{
  if((yyvaluep->expr))
    rasqal_free_expression((yyvaluep->expr));
};

/* Line 1000 of yacc.c  */
#line 2801 "sparql_parser.c"
	break;
      case 187: /* "ConditionalOrExpression" */

/* Line 1000 of yacc.c  */
#line 309 "./sparql_parser.y"
	{
  if((yyvaluep->expr))
    rasqal_free_expression((yyvaluep->expr));
};

/* Line 1000 of yacc.c  */
#line 2813 "sparql_parser.c"
	break;
      case 188: /* "ConditionalAndExpression" */

/* Line 1000 of yacc.c  */
#line 309 "./sparql_parser.y"
	{
  if((yyvaluep->expr))
    rasqal_free_expression((yyvaluep->expr));
};

/* Line 1000 of yacc.c  */
#line 2825 "sparql_parser.c"
	break;
      case 189: /* "RelationalExpression" */

/* Line 1000 of yacc.c  */
#line 309 "./sparql_parser.y"
	{
  if((yyvaluep->expr))
    rasqal_free_expression((yyvaluep->expr));
};

/* Line 1000 of yacc.c  */
#line 2837 "sparql_parser.c"
	break;
      case 190: /* "AdditiveExpression" */

/* Line 1000 of yacc.c  */
#line 309 "./sparql_parser.y"
	{
  if((yyvaluep->expr))
    rasqal_free_expression((yyvaluep->expr));
};

/* Line 1000 of yacc.c  */
#line 2849 "sparql_parser.c"
	break;
      case 191: /* "MultiplicativeExpression" */

/* Line 1000 of yacc.c  */
#line 309 "./sparql_parser.y"
	{
  if((yyvaluep->expr))
    rasqal_free_expression((yyvaluep->expr));
};

/* Line 1000 of yacc.c  */
#line 2861 "sparql_parser.c"
	break;
      case 192: /* "UnaryExpression" */

/* Line 1000 of yacc.c  */
#line 309 "./sparql_parser.y"
	{
  if((yyvaluep->expr))
    rasqal_free_expression((yyvaluep->expr));
};

/* Line 1000 of yacc.c  */
#line 2873 "sparql_parser.c"
	break;
      case 193: /* "PrimaryExpression" */

/* Line 1000 of yacc.c  */
#line 309 "./sparql_parser.y"
	{
  if((yyvaluep->expr))
    rasqal_free_expression((yyvaluep->expr));
};

/* Line 1000 of yacc.c  */
#line 2885 "sparql_parser.c"
	break;
      case 194: /* "BrackettedExpression" */

/* Line 1000 of yacc.c  */
#line 309 "./sparql_parser.y"
	{
  if((yyvaluep->expr))
    rasqal_free_expression((yyvaluep->expr));
};

/* Line 1000 of yacc.c  */
#line 2897 "sparql_parser.c"
	break;
      case 195: /* "BuiltInCall" */

/* Line 1000 of yacc.c  */
#line 309 "./sparql_parser.y"
	{
  if((yyvaluep->expr))
    rasqal_free_expression((yyvaluep->expr));
};

/* Line 1000 of yacc.c  */
#line 2909 "sparql_parser.c"
	break;
      case 196: /* "RegexExpression" */

/* Line 1000 of yacc.c  */
#line 309 "./sparql_parser.y"
	{
  if((yyvaluep->expr))
    rasqal_free_expression((yyvaluep->expr));
};

/* Line 1000 of yacc.c  */
#line 2921 "sparql_parser.c"
	break;
      case 197: /* "IRIrefBrace" */

/* Line 1000 of yacc.c  */
#line 323 "./sparql_parser.y"
	{
  if((yyvaluep->literal))
    rasqal_free_literal((yyvaluep->literal));
};

/* Line 1000 of yacc.c  */
#line 2933 "sparql_parser.c"
	break;
      case 198: /* "NumericLiteral" */

/* Line 1000 of yacc.c  */
#line 323 "./sparql_parser.y"
	{
  if((yyvaluep->literal))
    rasqal_free_literal((yyvaluep->literal));
};

/* Line 1000 of yacc.c  */
#line 2945 "sparql_parser.c"
	break;
      case 199: /* "NumericLiteralUnsigned" */

/* Line 1000 of yacc.c  */
#line 323 "./sparql_parser.y"
	{
  if((yyvaluep->literal))
    rasqal_free_literal((yyvaluep->literal));
};

/* Line 1000 of yacc.c  */
#line 2957 "sparql_parser.c"
	break;
      case 200: /* "NumericLiteralPositive" */

/* Line 1000 of yacc.c  */
#line 323 "./sparql_parser.y"
	{
  if((yyvaluep->literal))
    rasqal_free_literal((yyvaluep->literal));
};

/* Line 1000 of yacc.c  */
#line 2969 "sparql_parser.c"
	break;
      case 201: /* "NumericLiteralNegative" */

/* Line 1000 of yacc.c  */
#line 323 "./sparql_parser.y"
	{
  if((yyvaluep->literal))
    rasqal_free_literal((yyvaluep->literal));
};

/* Line 1000 of yacc.c  */
#line 2981 "sparql_parser.c"
	break;
      case 202: /* "IRIref" */

/* Line 1000 of yacc.c  */
#line 323 "./sparql_parser.y"
	{
  if((yyvaluep->literal))
    rasqal_free_literal((yyvaluep->literal));
};

/* Line 1000 of yacc.c  */
#line 2993 "sparql_parser.c"
	break;
      case 203: /* "BlankNode" */

/* Line 1000 of yacc.c  */
#line 323 "./sparql_parser.y"
	{
  if((yyvaluep->literal))
    rasqal_free_literal((yyvaluep->literal));
};

/* Line 1000 of yacc.c  */
#line 3005 "sparql_parser.c"
	break;

      default:
	break;
    }
}

/* Prevent warnings from -Wmissing-prototypes.  */
#ifdef YYPARSE_PARAM
#if defined __STDC__ || defined __cplusplus
int yyparse (void *YYPARSE_PARAM);
#else
int yyparse ();
#endif
#else /* ! YYPARSE_PARAM */
#if defined __STDC__ || defined __cplusplus
int yyparse (void);
#else
int yyparse ();
#endif
#endif /* ! YYPARSE_PARAM */





/*-------------------------.
| yyparse or yypush_parse.  |
`-------------------------*/

#ifdef YYPARSE_PARAM
#if (defined __STDC__ || defined __C99__FUNC__ \
     || defined __cplusplus || defined _MSC_VER)
int
yyparse (void *YYPARSE_PARAM)
#else
int
yyparse (YYPARSE_PARAM)
    void *YYPARSE_PARAM;
#endif
#else /* ! YYPARSE_PARAM */
#if (defined __STDC__ || defined __C99__FUNC__ \
     || defined __cplusplus || defined _MSC_VER)
int
yyparse (void)
#else
int
yyparse ()

#endif
#endif
{
/* The lookahead symbol.  */
int yychar;

/* The semantic value of the lookahead symbol.  */
YYSTYPE yylval;

    /* Number of syntax errors so far.  */
    int yynerrs;

    int yystate;
    /* Number of tokens to shift before error messages enabled.  */
    int yyerrstatus;

    /* The stacks and their tools:
       `yyss': related to states.
       `yyvs': related to semantic values.

       Refer to the stacks thru separate pointers, to allow yyoverflow
       to reallocate them elsewhere.  */

    /* The state stack.  */
    yytype_int16 yyssa[YYINITDEPTH];
    yytype_int16 *yyss;
    yytype_int16 *yyssp;

    /* The semantic value stack.  */
    YYSTYPE yyvsa[YYINITDEPTH];
    YYSTYPE *yyvs;
    YYSTYPE *yyvsp;

    YYSIZE_T yystacksize;

  int yyn;
  int yyresult;
  /* Lookahead token as an internal (translated) token number.  */
  int yytoken;
  /* The variables used to return semantic value and location from the
     action routines.  */
  YYSTYPE yyval;

#if YYERROR_VERBOSE
  /* Buffer for error messages, and its allocated size.  */
  char yymsgbuf[128];
  char *yymsg = yymsgbuf;
  YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
#endif

#define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))

  /* The number of symbols on the RHS of the reduced rule.
     Keep to zero when no symbol should be popped.  */
  int yylen = 0;

  yytoken = 0;
  yyss = yyssa;
  yyvs = yyvsa;
  yystacksize = YYINITDEPTH;

  YYDPRINTF ((stderr, "Starting parse\n"));

  yystate = 0;
  yyerrstatus = 0;
  yynerrs = 0;
  yychar = YYEMPTY; /* Cause a token to be read.  */

  /* Initialize stack pointers.
     Waste one element of value and location stack
     so that they stay on the same level as the state stack.
     The wasted elements are never initialized.  */
  yyssp = yyss;
  yyvsp = yyvs;

  goto yysetstate;

/*------------------------------------------------------------.
| yynewstate -- Push a new state, which is found in yystate.  |
`------------------------------------------------------------*/
 yynewstate:
  /* In all cases, when you get here, the value and location stacks
     have just been pushed.  So pushing a state here evens the stacks.  */
  yyssp++;

 yysetstate:
  *yyssp = yystate;

  if (yyss + yystacksize - 1 <= yyssp)
    {
      /* Get the current used size of the three stacks, in elements.  */
      YYSIZE_T yysize = yyssp - yyss + 1;

#ifdef yyoverflow
      {
	/* Give user a chance to reallocate the stack.  Use copies of
	   these so that the &'s don't force the real ones into
	   memory.  */
	YYSTYPE *yyvs1 = yyvs;
	yytype_int16 *yyss1 = yyss;

	/* Each stack pointer address is followed by the size of the
	   data in use in that stack, in bytes.  This used to be a
	   conditional around just the two extra args, but that might
	   be undefined if yyoverflow is a macro.  */
	yyoverflow (YY_("memory exhausted"),
		    &yyss1, yysize * sizeof (*yyssp),
		    &yyvs1, yysize * sizeof (*yyvsp),
		    &yystacksize);

	yyss = yyss1;
	yyvs = yyvs1;
      }
#else /* no yyoverflow */
# ifndef YYSTACK_RELOCATE
      goto yyexhaustedlab;
# else
      /* Extend the stack our own way.  */
      if (YYMAXDEPTH <= yystacksize)
	goto yyexhaustedlab;
      yystacksize *= 2;
      if (YYMAXDEPTH < yystacksize)
	yystacksize = YYMAXDEPTH;

      {
	yytype_int16 *yyss1 = yyss;
	union yyalloc *yyptr =
	  (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
	if (! yyptr)
	  goto yyexhaustedlab;
	YYSTACK_RELOCATE (yyss_alloc, yyss);
	YYSTACK_RELOCATE (yyvs_alloc, yyvs);
#  undef YYSTACK_RELOCATE
	if (yyss1 != yyssa)
	  YYSTACK_FREE (yyss1);
      }
# endif
#endif /* no yyoverflow */

      yyssp = yyss + yysize - 1;
      yyvsp = yyvs + yysize - 1;

      YYDPRINTF ((stderr, "Stack size increased to %lu\n",
		  (unsigned long int) yystacksize));

      if (yyss + yystacksize - 1 <= yyssp)
	YYABORT;
    }

  YYDPRINTF ((stderr, "Entering state %d\n", yystate));

  if (yystate == YYFINAL)
    YYACCEPT;

  goto yybackup;

/*-----------.
| yybackup.  |
`-----------*/
yybackup:

  /* Do appropriate processing given the current state.  Read a
     lookahead token if we need one and don't already have one.  */

  /* First try to decide what to do without reference to lookahead token.  */
  yyn = yypact[yystate];
  if (yyn == YYPACT_NINF)
    goto yydefault;

  /* Not known => get a lookahead token if don't already have one.  */

  /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
  if (yychar == YYEMPTY)
    {
      YYDPRINTF ((stderr, "Reading a token: "));
      yychar = YYLEX;
    }

  if (yychar <= YYEOF)
    {
      yychar = yytoken = YYEOF;
      YYDPRINTF ((stderr, "Now at end of input.\n"));
    }
  else
    {
      yytoken = YYTRANSLATE (yychar);
      YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
    }

  /* If the proper action on seeing token YYTOKEN is to reduce or to
     detect an error, take that action.  */
  yyn += yytoken;
  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
    goto yydefault;
  yyn = yytable[yyn];
  if (yyn <= 0)
    {
      if (yyn == 0 || yyn == YYTABLE_NINF)
	goto yyerrlab;
      yyn = -yyn;
      goto yyreduce;
    }

  /* Count tokens shifted since error; after three, turn off error
     status.  */
  if (yyerrstatus)
    yyerrstatus--;

  /* Shift the lookahead token.  */
  YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);

  /* Discard the shifted token.  */
  yychar = YYEMPTY;

  yystate = yyn;
  *++yyvsp = yylval;

  goto yynewstate;


/*-----------------------------------------------------------.
| yydefault -- do the default action for the current state.  |
`-----------------------------------------------------------*/
yydefault:
  yyn = yydefact[yystate];
  if (yyn == 0)
    goto yyerrlab;
  goto yyreduce;


/*-----------------------------.
| yyreduce -- Do a reduction.  |
`-----------------------------*/
yyreduce:
  /* yyn is the number of a rule to reduce with.  */
  yylen = yyr2[yyn];

  /* If YYLEN is nonzero, implement the default value of the action:
     `$$ = $1'.

     Otherwise, the following line sets YYVAL to garbage.
     This behavior is undocumented and Bison
     users should not rely upon it.  Assigning to YYVAL
     unconditionally makes the parser a bit smaller, and it avoids a
     GCC warning that YYVAL may be used uninitialized.  */
  yyval = yyvsp[1-yylen];


  YY_REDUCE_PRINT (yyn);
  switch (yyn)
    {
        case 2:

/* Line 1455 of yacc.c  */
#line 349 "./sparql_parser.y"
    {
}
    break;

  case 3:

/* Line 1455 of yacc.c  */
#line 355 "./sparql_parser.y"
    {
  rasqal_sparql_query_language* sparql;
  sparql = (rasqal_sparql_query_language*)(((rasqal_query*)rq)->context);

  if(sparql->extended)
    ((rasqal_query*)rq)->explain=1;
  else
    sparql_syntax_error((rasqal_query*)rq, 
                        "EXPLAIN cannot be used with SPARQL 1.0");
}
    break;

  case 4:

/* Line 1455 of yacc.c  */
#line 366 "./sparql_parser.y"
    {
  /* nothing to do */
}
    break;

  case 5:

/* Line 1455 of yacc.c  */
#line 374 "./sparql_parser.y"
    {
  ((rasqal_query*)rq)->selects = (yyvsp[(1) - (1)].seq);
  ((rasqal_query*)rq)->verb = RASQAL_QUERY_VERB_SELECT;
}
    break;

  case 6:

/* Line 1455 of yacc.c  */
#line 379 "./sparql_parser.y"
    {
  ((rasqal_query*)rq)->constructs = (yyvsp[(1) - (1)].seq);
  ((rasqal_query*)rq)->verb = RASQAL_QUERY_VERB_CONSTRUCT;
}
    break;

  case 7:

/* Line 1455 of yacc.c  */
#line 384 "./sparql_parser.y"
    {
  ((rasqal_query*)rq)->describes = (yyvsp[(1) - (1)].seq);
  ((rasqal_query*)rq)->verb = RASQAL_QUERY_VERB_DESCRIBE;
}
    break;

  case 8:

/* Line 1455 of yacc.c  */
#line 389 "./sparql_parser.y"
    {
  ((rasqal_query*)rq)->verb = RASQAL_QUERY_VERB_ASK;
}
    break;

  case 12:

/* Line 1455 of yacc.c  */
#line 402 "./sparql_parser.y"
    {
  ((rasqal_query*)rq)->verb = RASQAL_QUERY_VERB_DELETE;
}
    break;

  case 13:

/* Line 1455 of yacc.c  */
#line 406 "./sparql_parser.y"
    {
  ((rasqal_query*)rq)->verb = RASQAL_QUERY_VERB_INSERT;
}
    break;

  case 14:

/* Line 1455 of yacc.c  */
#line 410 "./sparql_parser.y"
    {
  ((rasqal_query*)rq)->verb = RASQAL_QUERY_VERB_UPDATE;
}
    break;

  case 15:

/* Line 1455 of yacc.c  */
#line 414 "./sparql_parser.y"
    {
  ((rasqal_query*)rq)->verb = RASQAL_QUERY_VERB_UPDATE;
}
    break;

  case 16:

/* Line 1455 of yacc.c  */
#line 418 "./sparql_parser.y"
    {
  ((rasqal_query*)rq)->verb = RASQAL_QUERY_VERB_UPDATE;
}
    break;

  case 17:

/* Line 1455 of yacc.c  */
#line 422 "./sparql_parser.y"
    {
  ((rasqal_query*)rq)->verb = RASQAL_QUERY_VERB_UPDATE;
}
    break;

  case 18:

/* Line 1455 of yacc.c  */
#line 426 "./sparql_parser.y"
    {
  ((rasqal_query*)rq)->verb = RASQAL_QUERY_VERB_UPDATE;
}
    break;

  case 19:

/* Line 1455 of yacc.c  */
#line 434 "./sparql_parser.y"
    {
  /* nothing to do */
}
    break;

  case 20:

/* Line 1455 of yacc.c  */
#line 442 "./sparql_parser.y"
    {
  rasqal_query_set_base_uri((rasqal_query*)rq, (yyvsp[(2) - (2)].uri));
}
    break;

  case 21:

/* Line 1455 of yacc.c  */
#line 446 "./sparql_parser.y"
    {
  /* nothing to do */
}
    break;

  case 22:

/* Line 1455 of yacc.c  */
#line 454 "./sparql_parser.y"
    {
  raptor_sequence *seq = ((rasqal_query*)rq)->prefixes;
  unsigned const char* prefix_string = (yyvsp[(3) - (4)].name);
  size_t l = 0;

  if(prefix_string)
    l=strlen((const char*)prefix_string);
  
  if(raptor_namespaces_find_namespace(((rasqal_query*)rq)->namespaces,
                                      prefix_string, l)) {
    /* A prefix may be defined only once */
    sparql_syntax_warning(((rasqal_query*)rq), 
                          "PREFIX %s can be defined only once.",
                          prefix_string ? (const char*)prefix_string : ":");
    RASQAL_FREE(cstring, prefix_string);
    raptor_free_uri((yyvsp[(4) - (4)].uri));
  } else {
    rasqal_prefix *p;
    p = rasqal_new_prefix(((rasqal_query*)rq)->world, prefix_string, (yyvsp[(4) - (4)].uri));
    if(!p)
      YYERROR_MSG("PrefixDeclOpt: failed to create new prefix");
    if(raptor_sequence_push(seq, p))
      YYERROR_MSG("PrefixDeclOpt: cannot push prefix to seq");
    if(rasqal_query_declare_prefix(((rasqal_query*)rq), p)) {
      YYERROR_MSG("PrefixDeclOpt: cannot declare prefix");
    }
  }
}
    break;

  case 23:

/* Line 1455 of yacc.c  */
#line 483 "./sparql_parser.y"
    {
  /* nothing to do, rq->prefixes already initialised */
}
    break;

  case 24:

/* Line 1455 of yacc.c  */
#line 492 "./sparql_parser.y"
    {
  (yyval.seq) = (yyvsp[(3) - (6)].seq);
  ((rasqal_query*)rq)->distinct = 1;
  ((rasqal_query*)rq)->query_graph_pattern = (yyvsp[(5) - (6)].graph_pattern);
}
    break;

  case 25:

/* Line 1455 of yacc.c  */
#line 499 "./sparql_parser.y"
    {
  (yyval.seq) = (yyvsp[(3) - (6)].seq);
  ((rasqal_query*)rq)->distinct = 2;
  ((rasqal_query*)rq)->query_graph_pattern = (yyvsp[(5) - (6)].graph_pattern);
}
    break;

  case 26:

/* Line 1455 of yacc.c  */
#line 506 "./sparql_parser.y"
    {
  (yyval.seq) = (yyvsp[(2) - (5)].seq);
  ((rasqal_query*)rq)->query_graph_pattern = (yyvsp[(4) - (5)].graph_pattern);
}
    break;

  case 27:

/* Line 1455 of yacc.c  */
#line 517 "./sparql_parser.y"
    {
  (yyval.seq) = (yyvsp[(1) - (1)].seq);
}
    break;

  case 28:

/* Line 1455 of yacc.c  */
#line 521 "./sparql_parser.y"
    {
  (yyval.seq) = NULL;
  ((rasqal_query*)rq)->wildcard = 1;
}
    break;

  case 29:

/* Line 1455 of yacc.c  */
#line 532 "./sparql_parser.y"
    {
  (yyval.seq) = (yyvsp[(1) - (2)].seq);
  if(raptor_sequence_push((yyval.seq), (yyvsp[(2) - (2)].variable))) {
    raptor_free_sequence((yyval.seq));
    (yyval.seq) = NULL;
    YYERROR_MSG("SelectExpressionListTail 1: sequence push failed");
  }
}
    break;

  case 30:

/* Line 1455 of yacc.c  */
#line 541 "./sparql_parser.y"
    {
  (yyval.seq) = (yyvsp[(1) - (3)].seq);
  if(raptor_sequence_push((yyval.seq), (yyvsp[(3) - (3)].variable))) {
    raptor_free_sequence((yyval.seq));
    (yyval.seq) = NULL;
    YYERROR_MSG("SelectExpressionListTail 2: sequence push failed");
  }
}
    break;

  case 31:

/* Line 1455 of yacc.c  */
#line 550 "./sparql_parser.y"
    {
  /* The variables are freed from the raptor_query field variables */
#ifdef RAPTOR_V2_AVAILABLE
  (yyval.seq) = raptor_new_sequence(NULL,
                           (raptor_data_print_handler*)rasqal_variable_print);
#else
  (yyval.seq) = raptor_new_sequence(NULL,
                           (raptor_sequence_print_handler*)rasqal_variable_print);
#endif
  if(!(yyval.seq))
    YYERROR_MSG("SelectExpressionListTail 3: failed to create sequence");
  if(raptor_sequence_push((yyval.seq), (yyvsp[(1) - (1)].variable))) {
    raptor_free_sequence((yyval.seq));
    (yyval.seq) = NULL;
    YYERROR_MSG("SelectExpressionListTail 3: sequence push failed");
  }
}
    break;

  case 32:

/* Line 1455 of yacc.c  */
#line 574 "./sparql_parser.y"
    {
  (yyval.variable) = (yyvsp[(1) - (1)].variable);
}
    break;

  case 33:

/* Line 1455 of yacc.c  */
#line 578 "./sparql_parser.y"
    {
  rasqal_sparql_query_language* sparql;
  sparql = (rasqal_sparql_query_language*)(((rasqal_query*)rq)->context);

  (yyval.variable) = NULL;
  if(!sparql->extended)
    sparql_syntax_error((rasqal_query*)rq,
                        "SELECT expression AS Variable cannot be used with SPARQL 1.0");
  else {
    if(rasqal_expression_mentions_variable((yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].variable))) {
      sparql_query_error_full((rasqal_query*)rq, 
                              "SELECT expression contains the AS variable name '%s'",
                              (yyvsp[(3) - (3)].variable)->name);
    } else {
      (yyval.variable) = (yyvsp[(3) - (3)].variable);
      (yyvsp[(3) - (3)].variable)->expression = (yyvsp[(1) - (3)].expr);
    }

  }
}
    break;

  case 34:

/* Line 1455 of yacc.c  */
#line 603 "./sparql_parser.y"
    {
  (yyval.expr) = (yyvsp[(1) - (1)].expr);
}
    break;

  case 35:

/* Line 1455 of yacc.c  */
#line 607 "./sparql_parser.y"
    {
  (yyval.expr) = (yyvsp[(2) - (3)].expr);
}
    break;

  case 36:

/* Line 1455 of yacc.c  */
#line 611 "./sparql_parser.y"
    {
  (yyval.expr) = (yyvsp[(2) - (3)].expr);
}
    break;

  case 37:

/* Line 1455 of yacc.c  */
#line 618 "./sparql_parser.y"
    {
  (yyval.expr) = (yyvsp[(1) - (1)].expr);
}
    break;

  case 38:

/* Line 1455 of yacc.c  */
#line 622 "./sparql_parser.y"
    {
  (yyval.expr) = (yyvsp[(1) - (1)].expr);
}
    break;

  case 39:

/* Line 1455 of yacc.c  */
#line 626 "./sparql_parser.y"
    {
  (yyval.expr) = (yyvsp[(1) - (1)].expr);
}
    break;

  case 40:

/* Line 1455 of yacc.c  */
#line 630 "./sparql_parser.y"
    {
  (yyval.expr) = (yyvsp[(1) - (1)].expr);
}
    break;

  case 41:

/* Line 1455 of yacc.c  */
#line 634 "./sparql_parser.y"
    {
  (yyval.expr) = (yyvsp[(1) - (1)].expr);
}
    break;

  case 42:

/* Line 1455 of yacc.c  */
#line 641 "./sparql_parser.y"
    {
  rasqal_sparql_query_language* sparql;
  sparql = (rasqal_sparql_query_language*)(((rasqal_query*)rq)->context);

  if(!sparql->extended) {
    sparql_syntax_error((rasqal_query*)rq,
                        "COUNT cannot be used with SPARQL 1.0");
    (yyval.expr) = NULL;
  } else {
    (yyval.expr) = rasqal_new_1op_expression(((rasqal_query*)rq)->world,
                                   RASQAL_EXPR_COUNT, (yyvsp[(3) - (4)].expr));
    if(!(yyval.expr))
      YYERROR_MSG("CountAggregateExpression 1: cannot create expr");
  }
}
    break;

  case 43:

/* Line 1455 of yacc.c  */
#line 657 "./sparql_parser.y"
    {
  rasqal_sparql_query_language* sparql;
  sparql = (rasqal_sparql_query_language*)(((rasqal_query*)rq)->context);

  if(!sparql->extended) {
    sparql_syntax_error((rasqal_query*)rq,
                        "COUNT cannot be used with SPARQL 1.0");
    (yyval.expr) = NULL;
  } else {
    rasqal_expression* vs;
    vs = rasqal_new_0op_expression(((rasqal_query*)rq)->world,
                                   RASQAL_EXPR_VARSTAR);
    if(!vs)
      YYERROR_MSG("CountAggregateExpression 2: cannot create varstar expr");
    (yyval.expr) = rasqal_new_1op_expression(((rasqal_query*)rq)->world, 
                                   RASQAL_EXPR_COUNT, vs);
    if(!(yyval.expr))
      YYERROR_MSG("CountAggregateExpression 2: cannot create expr");
  }
}
    break;

  case 44:

/* Line 1455 of yacc.c  */
#line 681 "./sparql_parser.y"
    {
  rasqal_sparql_query_language* sparql;
  sparql = (rasqal_sparql_query_language*)(((rasqal_query*)rq)->context);

  if(!sparql->extended) {
    sparql_syntax_error((rasqal_query*)rq,
                        "SUM cannot be used with SPARQL 1.0");
    (yyval.expr) = NULL;
  } else {
    (yyval.expr) = rasqal_new_1op_expression(((rasqal_query*)rq)->world,
                                   RASQAL_EXPR_SUM, (yyvsp[(3) - (4)].expr));
    if(!(yyval.expr))
      YYERROR_MSG("SumAggregateExpression 1: cannot create expr");
  }
}
    break;

  case 45:

/* Line 1455 of yacc.c  */
#line 700 "./sparql_parser.y"
    {
  rasqal_sparql_query_language* sparql;
  sparql = (rasqal_sparql_query_language*)(((rasqal_query*)rq)->context);

  if(!sparql->extended) {
    sparql_syntax_error((rasqal_query*)rq,
                        "AVG cannot be used with SPARQL 1.0");
    (yyval.expr) = NULL;
  } else {
    (yyval.expr) = rasqal_new_1op_expression(((rasqal_query*)rq)->world,
                                   RASQAL_EXPR_AVG, (yyvsp[(3) - (4)].expr));
    if(!(yyval.expr))
      YYERROR_MSG("AvgAggregateExpression 1: cannot create expr");
  }
}
    break;

  case 46:

/* Line 1455 of yacc.c  */
#line 719 "./sparql_parser.y"
    {
  rasqal_sparql_query_language* sparql;
  sparql = (rasqal_sparql_query_language*)(((rasqal_query*)rq)->context);

  if(!sparql->extended) {
    sparql_syntax_error((rasqal_query*)rq,
                        "MIN cannot be used with SPARQL 1.0");
    (yyval.expr) = NULL;
  } else {
    (yyval.expr) = rasqal_new_1op_expression(((rasqal_query*)rq)->world,
                                   RASQAL_EXPR_MIN, (yyvsp[(3) - (4)].expr));
    if(!(yyval.expr))
      YYERROR_MSG("MinAggregateExpression 1: cannot create expr");
  }
}
    break;

  case 47:

/* Line 1455 of yacc.c  */
#line 738 "./sparql_parser.y"
    {
  rasqal_sparql_query_language* sparql;
  sparql = (rasqal_sparql_query_language*)(((rasqal_query*)rq)->context);

  if(!sparql->extended) {
    sparql_syntax_error((rasqal_query*)rq,
                        "MAX cannot be used with SPARQL 1.0");
    (yyval.expr) = NULL;
  } else {
    (yyval.expr) = rasqal_new_1op_expression(((rasqal_query*)rq)->world,
                                   RASQAL_EXPR_MAX, (yyvsp[(3) - (4)].expr));
    if(!(yyval.expr))
      YYERROR_MSG("MaxAggregateExpression 1: cannot create expr");
  }
}
    break;

  case 48:

/* Line 1455 of yacc.c  */
#line 759 "./sparql_parser.y"
    {
  (yyval.seq) = (yyvsp[(2) - (5)].seq);
  ((rasqal_query*)rq)->query_graph_pattern = (yyvsp[(4) - (5)].graph_pattern);
}
    break;

  case 49:

/* Line 1455 of yacc.c  */
#line 769 "./sparql_parser.y"
    {
  (yyval.seq) = (yyvsp[(2) - (5)].seq);
  ((rasqal_query*)rq)->query_graph_pattern = (yyvsp[(4) - (5)].graph_pattern);
}
    break;

  case 50:

/* Line 1455 of yacc.c  */
#line 775 "./sparql_parser.y"
    {
  (yyval.seq) = NULL;
  ((rasqal_query*)rq)->query_graph_pattern = (yyvsp[(4) - (5)].graph_pattern);
}
    break;

  case 51:

/* Line 1455 of yacc.c  */
#line 784 "./sparql_parser.y"
    {
  (yyval.seq) = (yyvsp[(1) - (2)].seq);
  if(raptor_sequence_push((yyval.seq), (yyvsp[(2) - (2)].literal))) {
    raptor_free_sequence((yyval.seq));
    (yyval.seq) = NULL;
    YYERROR_MSG("VarOrIRIrefList 1: sequence push failed");
  }
}
    break;

  case 52:

/* Line 1455 of yacc.c  */
#line 793 "./sparql_parser.y"
    {
  (yyval.seq) = (yyvsp[(1) - (3)].seq);
  if(raptor_sequence_push((yyval.seq), (yyvsp[(3) - (3)].literal))) {
    raptor_free_sequence((yyval.seq));
    (yyval.seq) = NULL;
    YYERROR_MSG("VarOrIRIrefList 2: sequence push failed");
  }
}
    break;

  case 53:

/* Line 1455 of yacc.c  */
#line 802 "./sparql_parser.y"
    {
#ifdef RAPTOR_V2_AVAILABLE
  (yyval.seq) = raptor_new_sequence((raptor_data_free_handler*)rasqal_free_literal,
                           (raptor_data_print_handler*)rasqal_literal_print);
#else
  (yyval.seq) = raptor_new_sequence((raptor_sequence_free_handler*)rasqal_free_literal,
                           (raptor_sequence_print_handler*)rasqal_literal_print);
#endif
  if(!(yyval.seq))
    YYERROR_MSG("VarOrIRIrefList 3: cannot create seq");
  if(raptor_sequence_push((yyval.seq), (yyvsp[(1) - (1)].literal))) {
    raptor_free_sequence((yyval.seq));
    (yyval.seq) = NULL;
    YYERROR_MSG("VarOrIRIrefList 3: sequence push failed");
  }
}
    break;

  case 54:

/* Line 1455 of yacc.c  */
#line 824 "./sparql_parser.y"
    {
  ((rasqal_query*)rq)->query_graph_pattern = (yyvsp[(3) - (3)].graph_pattern);
}
    break;

  case 55:

/* Line 1455 of yacc.c  */
#line 832 "./sparql_parser.y"
    {
  rasqal_sparql_query_language* sparql;
  sparql = (rasqal_sparql_query_language*)(((rasqal_query*)rq)->context);

  if(!sparql->extended)
    sparql_syntax_error((rasqal_query*)rq,
                        "DELETE cannot be used with SPARQL 1.0");

  /* LAQRS: experimental syntax */
  sparql_syntax_warning(((rasqal_query*)rq), 
                        "DELETE FROM <uri> ... WHERE ... is deprecated LAQRS syntax.");
  ((rasqal_query*)rq)->query_graph_pattern = (yyvsp[(3) - (3)].graph_pattern);
}
    break;

  case 56:

/* Line 1455 of yacc.c  */
#line 846 "./sparql_parser.y"
    {
  rasqal_sparql_query_language* sparql;
  rasqal_update_operation* update;

  sparql = (rasqal_sparql_query_language*)(((rasqal_query*)rq)->context);

  if(!sparql->extended)
    sparql_syntax_error((rasqal_query*)rq,
                        "DELETE cannot be used with SPARQL 1.0");

  /* SPARQL 1.1 (Draft) update:
   * deleting via template + query - not inline atomic triples 
   */

  update = rasqal_new_update_operation(RASQAL_UPDATE_TYPE_UPDATE,
                                       NULL /* graph_uri */,
                                       NULL /* document_uri */,
                                       NULL /* insert templates */,
                                       (yyvsp[(3) - (5)].seq) /* delete templates */,
                                       (yyvsp[(5) - (5)].graph_pattern) /* where */,
                                       0 /* flags */);
  if(!update) {
    YYERROR_MSG("DeleteQuery: rasqal_new_update_operation failed");
  } else {
    if(rasqal_query_add_update_operation(((rasqal_query*)rq), update))
      YYERROR_MSG("DeleteQuery: rasqal_query_add_update_operation failed");
  }
}
    break;

  case 57:

/* Line 1455 of yacc.c  */
#line 875 "./sparql_parser.y"
    {
  rasqal_sparql_query_language* sparql;
  sparql = (rasqal_sparql_query_language*)(((rasqal_query*)rq)->context);

  if(!sparql->extended)
    sparql_syntax_error((rasqal_query*)rq,
                        "DELETE DATA cannot be used with SPARQL 1.0");

  /* SPARQL 1.1 (Draft) update:
   * deleting inline triples - not inserting from graph URIs 
   */
  (yyvsp[(4) - (5)].update)->type = RASQAL_UPDATE_TYPE_UPDATE;
  (yyvsp[(4) - (5)].update)->delete_templates = (yyvsp[(4) - (5)].update)->insert_templates; (yyvsp[(4) - (5)].update)->insert_templates = NULL;
  (yyvsp[(4) - (5)].update)->flags |= RASQAL_UPDATE_FLAGS_DATA;
  
  rasqal_query_add_update_operation((rasqal_query*)rq, (yyvsp[(4) - (5)].update));
}
    break;

  case 58:

/* Line 1455 of yacc.c  */
#line 897 "./sparql_parser.y"
    {
  (yyval.update) = NULL;
 
  if((yyvsp[(1) - (1)].formula)) {
    (yyval.update) = rasqal_new_update_operation(RASQAL_UPDATE_TYPE_UNKNOWN,
                                     NULL /* graph_uri */,
                                     NULL /* document_uri */,
                                     (yyvsp[(1) - (1)].formula)->triples /* insert templates */, 
                                     NULL /* delete templates */,
                                     NULL /* where */,
                                     0 /* flags */);
    (yyvsp[(1) - (1)].formula)->triples = NULL;
    rasqal_free_formula((yyvsp[(1) - (1)].formula));
  }
}
    break;

  case 59:

/* Line 1455 of yacc.c  */
#line 913 "./sparql_parser.y"
    {
  (yyval.update) = NULL;

  if((yyvsp[(4) - (5)].formula)) {
    (yyval.update) = rasqal_new_update_operation(RASQAL_UPDATE_TYPE_UNKNOWN,
                                     (yyvsp[(2) - (5)].uri) /* graph uri */,
                                     NULL /* document uri */,
                                     (yyvsp[(4) - (5)].formula)->triples /* insert templates */,
                                     NULL /* delete templates */,
                                     NULL /* where */,
                                     0 /* flags */);
    (yyvsp[(4) - (5)].formula)->triples = NULL;
    rasqal_free_formula((yyvsp[(4) - (5)].formula));
  }
}
    break;

  case 60:

/* Line 1455 of yacc.c  */
#line 933 "./sparql_parser.y"
    {
  if((yyvsp[(4) - (5)].seq)) {
    (yyval.graph_pattern) = rasqal_new_basic_graph_pattern_from_triples((rasqal_query*)rq, (yyvsp[(4) - (5)].seq));
    if(!(yyval.graph_pattern))
      YYERROR_MSG("GraphGraphPattern: cannot create graph pattern");
    else
      rasqal_graph_pattern_set_origin((yyval.graph_pattern), (yyvsp[(2) - (5)].literal));
  }
}
    break;

  case 61:

/* Line 1455 of yacc.c  */
#line 948 "./sparql_parser.y"
    {
  if((yyvsp[(1) - (1)].seq))
    (yyval.graph_pattern) = rasqal_new_basic_graph_pattern_from_triples((rasqal_query*)rq, (yyvsp[(1) - (1)].seq));
  else
    (yyval.graph_pattern) = NULL;
}
    break;

  case 62:

/* Line 1455 of yacc.c  */
#line 955 "./sparql_parser.y"
    {
  (yyval.graph_pattern) = (yyvsp[(1) - (1)].graph_pattern);
}
    break;

  case 63:

/* Line 1455 of yacc.c  */
#line 963 "./sparql_parser.y"
    {
  (yyval.seq) = (yyvsp[(1) - (2)].seq);

  if((yyvsp[(2) - (2)].graph_pattern)) {
    if(raptor_sequence_push((yyval.seq), (yyvsp[(2) - (2)].graph_pattern))) {
      raptor_free_sequence((yyval.seq));
      (yyval.seq) = NULL;
      YYERROR_MSG("ModifyTemplateList 1: sequence push failed");
    }
  }

}
    break;

  case 64:

/* Line 1455 of yacc.c  */
#line 976 "./sparql_parser.y"
    {
#ifdef RAPTOR_V2_AVAILABLE
  (yyval.seq) = raptor_new_sequence((raptor_data_free_handler*)rasqal_free_graph_pattern,
                           (raptor_data_print_handler*)rasqal_graph_pattern_print);
#else
  (yyval.seq) = raptor_new_sequence((raptor_sequence_free_handler*)rasqal_free_graph_pattern,
                           (raptor_sequence_print_handler*)rasqal_graph_pattern_print);
#endif
  if(!(yyval.seq))
    YYERROR_MSG("ModifyTemplateList 2: cannot create sequence");
  if((yyval.seq)) {
    if(raptor_sequence_push((yyval.seq), (yyvsp[(1) - (1)].graph_pattern))) {
      raptor_free_sequence((yyval.seq));
      (yyval.seq) = NULL;
      YYERROR_MSG("ModifyTemplateList 2: sequence push failed");
    }
  }
}
    break;

  case 65:

/* Line 1455 of yacc.c  */
#line 1000 "./sparql_parser.y"
    {
  rasqal_sparql_query_language* sparql;
  sparql  = (rasqal_sparql_query_language*)(((rasqal_query*)rq)->context);

  if(!sparql->extended)
    sparql_syntax_error((rasqal_query*)rq,
                        "INSERT cannot be used with SPARQL 1.0");

  /* LAQRS: experimental syntax */
  sparql_syntax_warning(((rasqal_query*)rq), 
                        "INSERT FROM <uri> ... WHERE ... is deprecated LAQRS syntax.");
  ((rasqal_query*)rq)->query_graph_pattern = (yyvsp[(3) - (3)].graph_pattern);
}
    break;

  case 66:

/* Line 1455 of yacc.c  */
#line 1014 "./sparql_parser.y"
    {
  rasqal_sparql_query_language* sparql;
  rasqal_update_operation* update;

  sparql = (rasqal_sparql_query_language*)(((rasqal_query*)rq)->context);

  if(!sparql->extended)
    sparql_syntax_error((rasqal_query*)rq,
                        "INSERT cannot be used with SPARQL 1.0");

  /* inserting via template + query - not inline atomic triples */

  update = rasqal_new_update_operation(RASQAL_UPDATE_TYPE_UPDATE,
                                       NULL /* graph_uri */,
                                       NULL /* document_uri */,
                                       (yyvsp[(3) - (5)].seq) /* insert templates */,
                                       NULL /* delete templates */,
                                       (yyvsp[(5) - (5)].graph_pattern) /* where */,
                                       0 /* flags */);
  if(!update) {
    YYERROR_MSG("InsertQuery: rasqal_new_update_operation failed");
  } else {
    if(rasqal_query_add_update_operation(((rasqal_query*)rq), update))
      YYERROR_MSG("InsertQuery: rasqal_query_add_update_operation failed");
  }
}
    break;

  case 67:

/* Line 1455 of yacc.c  */
#line 1041 "./sparql_parser.y"
    {
  rasqal_sparql_query_language* sparql;
  sparql = (rasqal_sparql_query_language*)(((rasqal_query*)rq)->context);

  if(!sparql->extended)
    sparql_syntax_error((rasqal_query*)rq,
                        "INSERT DATA cannot be used with SPARQL 1.0");

  /* inserting inline atomic triples (no variables) - not via template */
  (yyvsp[(4) - (5)].update)->type = RASQAL_UPDATE_TYPE_UPDATE;
  (yyvsp[(4) - (5)].update)->flags |= RASQAL_UPDATE_FLAGS_DATA;

  rasqal_query_add_update_operation((rasqal_query*)rq, (yyvsp[(4) - (5)].update));
}
    break;

  case 68:

/* Line 1455 of yacc.c  */
#line 1062 "./sparql_parser.y"
    {
  rasqal_update_operation* update;

  /* after this $2, $5, $9 and $12 are owned by update */
  update = rasqal_new_update_operation(RASQAL_UPDATE_TYPE_UPDATE,
                                       (yyvsp[(2) - (11)].uri) /* graph uri */, 
                                       NULL /* document uri */,
                                       (yyvsp[(9) - (11)].seq) /* insert templates */,
                                       (yyvsp[(5) - (11)].seq) /* delete templates */,
                                       (yyvsp[(11) - (11)].graph_pattern) /* where */,
                                       0 /* flags */);
  if(!update) {
    YYERROR_MSG("UpdateQuery 1: rasqal_new_update_operation failed");
  } else {
    if(rasqal_query_add_update_operation(((rasqal_query*)rq), update))
      YYERROR_MSG("UpdateQuery 1: rasqal_query_add_update_operation failed");
  }
}
    break;

  case 69:

/* Line 1455 of yacc.c  */
#line 1083 "./sparql_parser.y"
    {
  rasqal_update_operation* update;

  /* after this $2, $5 and $8 are owned by update */
  update = rasqal_new_update_operation(RASQAL_UPDATE_TYPE_UPDATE,
                                       (yyvsp[(2) - (7)].uri) /* graph uri */, 
                                       NULL /* document uri */,
                                       NULL /* insert templates */,
                                       (yyvsp[(5) - (7)].seq) /* delete templates */,
                                       (yyvsp[(7) - (7)].graph_pattern) /* where */,
                                       0 /* flags */);
  if(!update) {
    YYERROR_MSG("UpdateQuery 2: rasqal_new_update_operation failed");
  } else {
    if(rasqal_query_add_update_operation(((rasqal_query*)rq), update))
      YYERROR_MSG("UpdateQuery 2: rasqal_query_add_update_operation failed");
  }
}
    break;

  case 70:

/* Line 1455 of yacc.c  */
#line 1104 "./sparql_parser.y"
    {
  rasqal_update_operation* update;

  /* after this $2, $5 and $8 are owned by update */
  update = rasqal_new_update_operation(RASQAL_UPDATE_TYPE_UPDATE,
                                       (yyvsp[(2) - (7)].uri) /* graph uri */, 
                                       NULL /* document uri */,
                                       (yyvsp[(5) - (7)].seq) /* insert templates */,
                                       NULL /* delete templates */,
                                       (yyvsp[(7) - (7)].graph_pattern) /* where */,
                                       0 /* flags */);
  if(!update) {
    YYERROR_MSG("UpdateQuery 3: rasqal_new_update_operation failed");
  } else {
    if(rasqal_query_add_update_operation(((rasqal_query*)rq), update))
      YYERROR_MSG("UpdateQuery 3: rasqal_query_add_update_operation failed");
  }
}
    break;

  case 71:

/* Line 1455 of yacc.c  */
#line 1127 "./sparql_parser.y"
    {
  rasqal_sparql_query_language* sparql;
  rasqal_update_operation* update;

  sparql = (rasqal_sparql_query_language*)(((rasqal_query*)rq)->context);

  if(!sparql->extended)
    sparql_syntax_error((rasqal_query*)rq,
                        "CLEAR cannot be used with SPARQL 1.0");

  update = rasqal_new_update_operation(RASQAL_UPDATE_TYPE_CLEAR,
                                       NULL /* graph uri */, 
                                       NULL /* document uri */,
                                       NULL, NULL,
                                       NULL /* where */,
                                       0 /* flags */);
  if(!update) {
    YYERROR_MSG("ClearQuery: rasqal_new_update_operation failed");
  } else {
    if(rasqal_query_add_update_operation(((rasqal_query*)rq), update))
      YYERROR_MSG("ClearQuery: rasqal_query_add_update_operation failed");
  }
}
    break;

  case 72:

/* Line 1455 of yacc.c  */
#line 1151 "./sparql_parser.y"
    {
  rasqal_sparql_query_language* sparql;
  rasqal_update_operation* update;

  sparql = (rasqal_sparql_query_language*)(((rasqal_query*)rq)->context);

  if(!sparql->extended)
    sparql_syntax_error((rasqal_query*)rq,
                        "CLEAR GRAPH <uri> cannot be used with SPARQL 1.0");

  update = rasqal_new_update_operation(RASQAL_UPDATE_TYPE_CLEAR,
                                       (yyvsp[(3) - (3)].uri) /* graph uri */, 
                                       NULL /* document uri */,
                                       NULL, NULL,
                                       NULL /*where */,
                                       0 /* flags */);
  if(!update) {
    YYERROR_MSG("ClearQuery: rasqal_new_update_operation failed");
  } else {
    if(rasqal_query_add_update_operation(((rasqal_query*)rq), update))
      YYERROR_MSG("ClearQuery: rasqal_query_add_update_operation failed");
  }
}
    break;

  case 73:

/* Line 1455 of yacc.c  */
#line 1179 "./sparql_parser.y"
    {
  rasqal_sparql_query_language* sparql;
  rasqal_update_operation* update;

  sparql = (rasqal_sparql_query_language*)(((rasqal_query*)rq)->context);

  if(!sparql->extended)
    sparql_syntax_error((rasqal_query*)rq, 
                        "CREATE GRAPH <uri> cannot be used with SPARQL 1.0");

  update = rasqal_new_update_operation(RASQAL_UPDATE_TYPE_CREATE,
                                       (yyvsp[(3) - (3)].uri) /* graph uri */, 
                                       NULL /* document uri */,
                                       NULL, NULL,
                                       NULL /*where */,
                                       0 /* flags */);
  if(!update) {
    YYERROR_MSG("CreateQuery: rasqal_new_update_operation failed");
  } else {
    if(rasqal_query_add_update_operation(((rasqal_query*)rq), update))
      YYERROR_MSG("CreateQuery: rasqal_query_add_update_operation failed");
  }
}
    break;

  case 74:

/* Line 1455 of yacc.c  */
#line 1203 "./sparql_parser.y"
    {
  rasqal_sparql_query_language* sparql;
  rasqal_update_operation* update;

  sparql = (rasqal_sparql_query_language*)(((rasqal_query*)rq)->context);

  if(!sparql->extended)
    sparql_syntax_error((rasqal_query*)rq, 
                        "CREATE SILENT GRAPH <uri> cannot be used with SPARQL 1.0");

  update = rasqal_new_update_operation(RASQAL_UPDATE_TYPE_CREATE,
                                       (yyvsp[(4) - (4)].uri) /* graph uri */, 
                                       NULL /* document uri */,
                                       NULL, NULL,
                                       NULL /*where */,
                                       RASQAL_UPDATE_FLAGS_SILENT /* flags */);
  if(!update) {
    YYERROR_MSG("CreateQuery: rasqal_new_update_operation failed");
  } else {
    if(rasqal_query_add_update_operation(((rasqal_query*)rq), update))
      YYERROR_MSG("CreateQuery: rasqal_query_add_update_operation failed");
  }
}
    break;

  case 75:

/* Line 1455 of yacc.c  */
#line 1231 "./sparql_parser.y"
    {
  rasqal_sparql_query_language* sparql;
  rasqal_update_operation* update;

  sparql = (rasqal_sparql_query_language*)(((rasqal_query*)rq)->context);

  if(!sparql->extended)
    sparql_syntax_error((rasqal_query*)rq, 
                        "DROP GRAPH <uri> cannot be used with SPARQL 1.0");

  update = rasqal_new_update_operation(RASQAL_UPDATE_TYPE_DROP,
                                       (yyvsp[(3) - (3)].uri) /* graph uri */, 
                                       NULL /* document uri */,
                                       NULL, NULL,
                                       NULL /*where */,
                                       0 /* flags */);
  if(!update) {
    YYERROR_MSG("DropQuery: rasqal_new_update_operation failed");
  } else {
    if(rasqal_query_add_update_operation(((rasqal_query*)rq), update))
      YYERROR_MSG("DropQuery: rasqal_query_add_update_operation failed");
  }
}
    break;

  case 76:

/* Line 1455 of yacc.c  */
#line 1255 "./sparql_parser.y"
    {
  rasqal_sparql_query_language* sparql;
  rasqal_update_operation* update;

  sparql = (rasqal_sparql_query_language*)(((rasqal_query*)rq)->context);

  if(!sparql->extended)
    sparql_syntax_error((rasqal_query*)rq, 
                        "DROP SILENT GRAPH <uri> cannot be used with SPARQL 1.0");


  update = rasqal_new_update_operation(RASQAL_UPDATE_TYPE_DROP,
                                       (yyvsp[(4) - (4)].uri) /* graph uri */, 
                                       NULL /* document uri */,
                                       NULL, NULL,
                                       NULL /*where */,
                                       RASQAL_UPDATE_FLAGS_SILENT /* flags */);
  if(!update) {
    YYERROR_MSG("DropQuery: rasqal_new_update_operation failed");
  } else {
    if(rasqal_query_add_update_operation(((rasqal_query*)rq), update))
      YYERROR_MSG("DropQuery: rasqal_query_add_update_operation failed");
  }
}
    break;

  case 77:

/* Line 1455 of yacc.c  */
#line 1284 "./sparql_parser.y"
    {
  rasqal_sparql_query_language* sparql;
  rasqal_update_operation* update;
  
  sparql = (rasqal_sparql_query_language*)(((rasqal_query*)rq)->context);

  if(!sparql->extended)
    sparql_syntax_error((rasqal_query*)rq, 
                        "LOAD <document uri> cannot be used with SPARQL 1.0");
  
  update = rasqal_new_update_operation(RASQAL_UPDATE_TYPE_LOAD,
                                       NULL /* graph uri */, 
                                       (yyvsp[(2) - (2)].uri) /* document uri */,
                                       NULL, NULL,
                                       NULL /*where */,
                                       0 /* flags */);
  if(!update) {
    YYERROR_MSG("LoadQuery: rasqal_new_update_operation failed");
  } else {
    if(rasqal_query_add_update_operation(((rasqal_query*)rq), update))
      YYERROR_MSG("LoadQuery: rasqal_query_add_update_operation failed");
  }
}
    break;

  case 78:

/* Line 1455 of yacc.c  */
#line 1308 "./sparql_parser.y"
    {
  rasqal_sparql_query_language* sparql;
  rasqal_update_operation* update;

  sparql = (rasqal_sparql_query_language*)(((rasqal_query*)rq)->context);

  if(!sparql->extended)
    sparql_syntax_error((rasqal_query*)rq, 
                        "LOAD <document uri> INTO <graph URI> cannot be used with SPARQL 1.0");

  update = rasqal_new_update_operation(RASQAL_UPDATE_TYPE_LOAD,
                                       (yyvsp[(4) - (4)].uri) /* graph uri */,
                                       (yyvsp[(2) - (4)].uri) /* document uri */,
                                       NULL, NULL,
                                       NULL /*where */,
                                       0 /* flags */);
  if(!update) {
    YYERROR_MSG("LoadQuery: rasqal_new_update_operation failed");
  } else {
    if(rasqal_query_add_update_operation(((rasqal_query*)rq), update))
      YYERROR_MSG("LoadQuery: rasqal_query_add_update_operation failed");
  }
}
    break;

  case 83:

/* Line 1455 of yacc.c  */
#line 1345 "./sparql_parser.y"
    {
  if((yyvsp[(1) - (1)].literal)) {
    raptor_uri* uri = rasqal_literal_as_uri((yyvsp[(1) - (1)].literal));
    if(rasqal_query_add_data_graph((rasqal_query*)rq, uri, NULL,
                                   RASQAL_DATA_GRAPH_BACKGROUND)) {
      rasqal_free_literal((yyvsp[(1) - (1)].literal));
      YYERROR_MSG("DefaultGraphClause: rasqal_query_add_data_graph failed");
    }
    rasqal_free_literal((yyvsp[(1) - (1)].literal));
  }
}
    break;

  case 84:

/* Line 1455 of yacc.c  */
#line 1361 "./sparql_parser.y"
    {
  if((yyvsp[(2) - (2)].literal)) {
    raptor_uri* uri = rasqal_literal_as_uri((yyvsp[(2) - (2)].literal));
    if(rasqal_query_add_data_graph((rasqal_query*)rq, uri, uri,
                                   RASQAL_DATA_GRAPH_NAMED)) {
      rasqal_free_literal((yyvsp[(2) - (2)].literal));
      YYERROR_MSG("NamedGraphClause: rasqal_query_add_data_graph failed");
    }
    rasqal_free_literal((yyvsp[(2) - (2)].literal));
  }
}
    break;

  case 85:

/* Line 1455 of yacc.c  */
#line 1377 "./sparql_parser.y"
    {
  (yyval.literal) = (yyvsp[(1) - (1)].literal);
}
    break;

  case 86:

/* Line 1455 of yacc.c  */
#line 1385 "./sparql_parser.y"
    {
  (yyval.graph_pattern) = (yyvsp[(2) - (2)].graph_pattern);
}
    break;

  case 87:

/* Line 1455 of yacc.c  */
#line 1389 "./sparql_parser.y"
    {
  (yyval.graph_pattern) = (yyvsp[(1) - (1)].graph_pattern);
}
    break;

  case 88:

/* Line 1455 of yacc.c  */
#line 1397 "./sparql_parser.y"
    {
  (yyval.graph_pattern) = (yyvsp[(1) - (1)].graph_pattern);
}
    break;

  case 89:

/* Line 1455 of yacc.c  */
#line 1401 "./sparql_parser.y"
    {
  (yyval.graph_pattern) = NULL;
}
    break;

  case 91:

/* Line 1455 of yacc.c  */
#line 1414 "./sparql_parser.y"
    {
  rasqal_sparql_query_language* sparql;
  sparql = (rasqal_sparql_query_language*)(((rasqal_query*)rq)->context);

  if(!sparql->extended)
    sparql_syntax_error((rasqal_query*)rq,
                        "GROUP BY cannot be used with SPARQL 1.0");
  else if(((rasqal_query*)rq)->verb == RASQAL_QUERY_VERB_ASK) {
    sparql_query_error((rasqal_query*)rq, 
                       "GROUP BY cannot be used with ASK");
  } else {
    raptor_sequence *seq = (yyvsp[(3) - (3)].seq);
    ((rasqal_query*)rq)->group_conditions_sequence = seq;
    if(seq) {
      int i;
      int size = raptor_sequence_size(seq);
      
      for(i = 0; i < size; i++) {
        rasqal_expression* e;
        e = (rasqal_expression*)raptor_sequence_get_at(seq, i);
        if(e->op == RASQAL_EXPR_ORDER_COND_ASC)
          e->op = RASQAL_EXPR_GROUP_COND_ASC;
        else
          e->op = RASQAL_EXPR_GROUP_COND_DESC;
      }
    }
  }
}
    break;

  case 97:

/* Line 1455 of yacc.c  */
#line 1452 "./sparql_parser.y"
    { 
}
    break;

  case 98:

/* Line 1455 of yacc.c  */
#line 1459 "./sparql_parser.y"
    {
  if(((rasqal_query*)rq)->verb == RASQAL_QUERY_VERB_ASK) {
    sparql_query_error((rasqal_query*)rq, "ORDER BY cannot be used with ASK");
  } else {
    ((rasqal_query*)rq)->order_conditions_sequence = (yyvsp[(3) - (3)].seq);
  }
}
    break;

  case 100:

/* Line 1455 of yacc.c  */
#line 1472 "./sparql_parser.y"
    {
  (yyval.seq) = (yyvsp[(1) - (2)].seq);
  if((yyvsp[(2) - (2)].expr))
    if(raptor_sequence_push((yyval.seq), (yyvsp[(2) - (2)].expr))) {
      raptor_free_sequence((yyval.seq));
      (yyval.seq) = NULL;
      YYERROR_MSG("OrderConditionList 1: sequence push failed");
    }
}
    break;

  case 101:

/* Line 1455 of yacc.c  */
#line 1482 "./sparql_parser.y"
    {
#ifdef RAPTOR_V2_AVAILABLE
  (yyval.seq) = raptor_new_sequence((raptor_data_free_handler*)rasqal_free_expression,
                           (raptor_data_print_handler*)rasqal_expression_print);
#else
  (yyval.seq) = raptor_new_sequence((raptor_sequence_free_handler*)rasqal_free_expression,
                           (raptor_sequence_print_handler*)rasqal_expression_print);
#endif
  if(!(yyval.seq)) {
    if((yyvsp[(1) - (1)].expr))
      rasqal_free_expression((yyvsp[(1) - (1)].expr));
    YYERROR_MSG("OrderConditionList 2: cannot create sequence");
  }
  if((yyvsp[(1) - (1)].expr))
    if(raptor_sequence_push((yyval.seq), (yyvsp[(1) - (1)].expr))) {
      raptor_free_sequence((yyval.seq));
      (yyval.seq) = NULL;
      YYERROR_MSG("OrderConditionList 2: sequence push failed");
    }
}
    break;

  case 102:

/* Line 1455 of yacc.c  */
#line 1507 "./sparql_parser.y"
    {
  (yyval.expr) = rasqal_new_1op_expression(((rasqal_query*)rq)->world,
                                 RASQAL_EXPR_ORDER_COND_ASC, (yyvsp[(2) - (2)].expr));
  if(!(yyval.expr))
    YYERROR_MSG("OrderCondition 1: cannot create expr");
}
    break;

  case 103:

/* Line 1455 of yacc.c  */
#line 1514 "./sparql_parser.y"
    {
  (yyval.expr) = rasqal_new_1op_expression(((rasqal_query*)rq)->world,
                                 RASQAL_EXPR_ORDER_COND_DESC, (yyvsp[(2) - (2)].expr));
  if(!(yyval.expr))
    YYERROR_MSG("OrderCondition 2: cannot create expr");
}
    break;

  case 104:

/* Line 1455 of yacc.c  */
#line 1521 "./sparql_parser.y"
    {
  /* The direction of ordering is ascending by default */
  (yyval.expr) = rasqal_new_1op_expression(((rasqal_query*)rq)->world,
                                 RASQAL_EXPR_ORDER_COND_ASC, (yyvsp[(1) - (1)].expr));
  if(!(yyval.expr))
    YYERROR_MSG("OrderCondition 3: cannot create expr");
}
    break;

  case 105:

/* Line 1455 of yacc.c  */
#line 1529 "./sparql_parser.y"
    {
  rasqal_literal* l;
  rasqal_expression *e;
  l = rasqal_new_variable_literal(((rasqal_query*)rq)->world, (yyvsp[(1) - (1)].variable));
  if(!l)
    YYERROR_MSG("OrderCondition 4: cannot create lit");
  e = rasqal_new_literal_expression(((rasqal_query*)rq)->world, l);
  if(!e)
    YYERROR_MSG("OrderCondition 4: cannot create lit expr");

  /* The direction of ordering is ascending by default */
  (yyval.expr) = rasqal_new_1op_expression(((rasqal_query*)rq)->world,
                                 RASQAL_EXPR_ORDER_COND_ASC, e);
  if(!(yyval.expr))
    YYERROR_MSG("OrderCondition 1: cannot create expr");
}
    break;

  case 106:

/* Line 1455 of yacc.c  */
#line 1546 "./sparql_parser.y"
    {
  /* The direction of ordering is ascending by default */
  (yyval.expr) = rasqal_new_1op_expression(((rasqal_query*)rq)->world,
                                 RASQAL_EXPR_ORDER_COND_ASC, (yyvsp[(1) - (1)].expr));
  if(!(yyval.expr))
    YYERROR_MSG("OrderCondition 5: cannot create expr");
}
    break;

  case 107:

/* Line 1455 of yacc.c  */
#line 1554 "./sparql_parser.y"
    {
  /* The direction of ordering is ascending by default */
  (yyval.expr) = rasqal_new_1op_expression(((rasqal_query*)rq)->world,
                                 RASQAL_EXPR_ORDER_COND_ASC, (yyvsp[(1) - (1)].expr));
  if(!(yyval.expr))
    YYERROR_MSG("OrderCondition 6: cannot create expr");
}
    break;

  case 108:

/* Line 1455 of yacc.c  */
#line 1566 "./sparql_parser.y"
    {
  if(((rasqal_query*)rq)->verb == RASQAL_QUERY_VERB_ASK) {
    sparql_query_error((rasqal_query*)rq, "LIMIT cannot be used with ASK");
  } else {
    if((yyvsp[(2) - (2)].literal) != NULL) {
      ((rasqal_query*)rq)->limit = (yyvsp[(2) - (2)].literal)->value.integer;
      rasqal_free_literal((yyvsp[(2) - (2)].literal));
    }
  }
  
}
    break;

  case 109:

/* Line 1455 of yacc.c  */
#line 1582 "./sparql_parser.y"
    {
  if(((rasqal_query*)rq)->verb == RASQAL_QUERY_VERB_ASK) {
    sparql_query_error((rasqal_query*)rq, "LIMIT cannot be used with ASK");
  } else {
    if((yyvsp[(2) - (2)].literal) != NULL) {
      ((rasqal_query*)rq)->offset = (yyvsp[(2) - (2)].literal)->value.integer;
      rasqal_free_literal((yyvsp[(2) - (2)].literal));
    }
  }
}
    break;

  case 110:

/* Line 1455 of yacc.c  */
#line 1600 "./sparql_parser.y"
    {
  rasqal_graph_pattern *formula_gp = NULL;

#if RASQAL_DEBUG > 1  
  fprintf(DEBUG_FH, "GroupGraphPattern\n  TriplesBlockOpt=");
  if((yyvsp[(2) - (4)].formula))
    rasqal_formula_print((yyvsp[(2) - (4)].formula), DEBUG_FH);
  else
    fputs("NULL", DEBUG_FH);
  fprintf(DEBUG_FH, ", GraphpatternListOpt=");
  if((yyvsp[(3) - (4)].graph_pattern))
    rasqal_graph_pattern_print((yyvsp[(3) - (4)].graph_pattern), DEBUG_FH);
  else
    fputs("NULL", DEBUG_FH);
  fputs("\n", DEBUG_FH);
#endif


  if(!(yyvsp[(2) - (4)].formula) && !(yyvsp[(3) - (4)].graph_pattern)) {
    (yyval.graph_pattern) = rasqal_new_2_group_graph_pattern((rasqal_query*)rq, NULL, NULL);
    if(!(yyval.graph_pattern))
      YYERROR_MSG("GroupGraphPattern: cannot create group gp");
  } else {
    if((yyvsp[(2) - (4)].formula)) {
      formula_gp = rasqal_new_basic_graph_pattern_from_formula((rasqal_query*)rq,
                                                               (yyvsp[(2) - (4)].formula));
      if(!formula_gp) {
        if((yyvsp[(3) - (4)].graph_pattern))
          rasqal_free_graph_pattern((yyvsp[(3) - (4)].graph_pattern));
        YYERROR_MSG("GroupGraphPattern: cannot create formula_gp");
      }
    }

    if((yyvsp[(3) - (4)].graph_pattern)) {
      (yyval.graph_pattern) = (yyvsp[(3) - (4)].graph_pattern);
      if(formula_gp && raptor_sequence_shift((yyval.graph_pattern)->graph_patterns, formula_gp)) {
        rasqal_free_graph_pattern((yyval.graph_pattern));
        (yyval.graph_pattern) = NULL;
        YYERROR_MSG("GroupGraphPattern: sequence push failed");
      }
    } else
      (yyval.graph_pattern) = formula_gp;
  }
  
#if RASQAL_DEBUG > 1  
  fprintf(DEBUG_FH, "  after graph pattern=");
  if((yyval.graph_pattern))
    rasqal_graph_pattern_print((yyval.graph_pattern), DEBUG_FH);
  else
    fputs("NULL", DEBUG_FH);
  fprintf(DEBUG_FH, "\n\n");
#endif
}
    break;

  case 111:

/* Line 1455 of yacc.c  */
#line 1658 "./sparql_parser.y"
    {
#if RASQAL_DEBUG > 1  
  fprintf(DEBUG_FH, "TriplesBlockOpt 1\n  TriplesBlock=");
  if((yyvsp[(1) - (1)].formula))
    rasqal_formula_print((yyvsp[(1) - (1)].formula), DEBUG_FH);
  else
    fputs("NULL", DEBUG_FH);
  fputs("\n\n", DEBUG_FH);
#endif

  (yyval.formula) = (yyvsp[(1) - (1)].formula);
}
    break;

  case 112:

/* Line 1455 of yacc.c  */
#line 1671 "./sparql_parser.y"
    {
  (yyval.formula) = NULL;
}
    break;

  case 113:

/* Line 1455 of yacc.c  */
#line 1684 "./sparql_parser.y"
    {
#if RASQAL_DEBUG > 1  
  fprintf(DEBUG_FH, "GraphPatternListOpt\n  GraphPatternListOpt=");
  if((yyvsp[(1) - (2)].graph_pattern))
    rasqal_graph_pattern_print((yyvsp[(1) - (2)].graph_pattern), DEBUG_FH);
  else
    fputs("NULL", DEBUG_FH);
  fprintf(DEBUG_FH, ", GraphPatternList=");
  if((yyvsp[(2) - (2)].graph_pattern))
    rasqal_graph_pattern_print((yyvsp[(2) - (2)].graph_pattern), DEBUG_FH);
  else
    fputs("NULL", DEBUG_FH);
  fputs("\n", DEBUG_FH);
#endif

  (yyval.graph_pattern) =  ((yyvsp[(1) - (2)].graph_pattern) ? (yyvsp[(1) - (2)].graph_pattern) : (yyvsp[(2) - (2)].graph_pattern));
  if((yyvsp[(1) - (2)].graph_pattern) && (yyvsp[(2) - (2)].graph_pattern)) {
    (yyval.graph_pattern) = (yyvsp[(1) - (2)].graph_pattern);
    if(rasqal_graph_patterns_join((yyval.graph_pattern), (yyvsp[(2) - (2)].graph_pattern))) {
      rasqal_free_graph_pattern((yyval.graph_pattern));
      rasqal_free_graph_pattern((yyvsp[(2) - (2)].graph_pattern));
      (yyval.graph_pattern) = NULL;
      YYERROR_MSG("GraphPatternListOpt: sequence join failed");
    }
    rasqal_free_graph_pattern((yyvsp[(2) - (2)].graph_pattern));
  }
  
#if RASQAL_DEBUG > 1  
  fprintf(DEBUG_FH, "  after grouping graph pattern=");
  if((yyval.graph_pattern))
    rasqal_graph_pattern_print((yyval.graph_pattern), DEBUG_FH);
  else
    fputs("NULL", DEBUG_FH);
  fprintf(DEBUG_FH, "\n\n");
#endif
}
    break;

  case 114:

/* Line 1455 of yacc.c  */
#line 1721 "./sparql_parser.y"
    {
  (yyval.graph_pattern) = (yyvsp[(1) - (1)].graph_pattern);
}
    break;

  case 115:

/* Line 1455 of yacc.c  */
#line 1725 "./sparql_parser.y"
    {
  (yyval.graph_pattern) = NULL;
}
    break;

  case 116:

/* Line 1455 of yacc.c  */
#line 1738 "./sparql_parser.y"
    {
  rasqal_graph_pattern *formula_gp = NULL;

#if RASQAL_DEBUG > 1  
  fprintf(DEBUG_FH, "GraphPatternList\n  GraphPatternListFilter=");
  if((yyvsp[(1) - (3)].graph_pattern))
    rasqal_graph_pattern_print((yyvsp[(1) - (3)].graph_pattern), DEBUG_FH);
  else
    fputs("NULL", DEBUG_FH);
  fprintf(DEBUG_FH, ", TriplesBlockOpt=");
  if((yyvsp[(3) - (3)].formula))
    rasqal_formula_print((yyvsp[(3) - (3)].formula), DEBUG_FH);
  else
    fputs("NULL", DEBUG_FH);
  fputs("\n", DEBUG_FH);
#endif

  if((yyvsp[(3) - (3)].formula)) {
    formula_gp = rasqal_new_basic_graph_pattern_from_formula((rasqal_query*)rq, 
                                                             (yyvsp[(3) - (3)].formula));
    if(!formula_gp) {
      if((yyvsp[(1) - (3)].graph_pattern))
        rasqal_free_graph_pattern((yyvsp[(1) - (3)].graph_pattern));
      YYERROR_MSG("GraphPatternList: cannot create formula_gp");
    }
  }
  (yyval.graph_pattern) = rasqal_new_2_group_graph_pattern((rasqal_query*)rq, (yyvsp[(1) - (3)].graph_pattern), formula_gp);
  if(!(yyval.graph_pattern))
    YYERROR_MSG("GraphPatternList: cannot create sequence");

#if RASQAL_DEBUG > 1  
  fprintf(DEBUG_FH, "  after graph pattern=");
  if((yyval.graph_pattern))
    rasqal_graph_pattern_print((yyval.graph_pattern), DEBUG_FH);
  else
    fputs("NULL", DEBUG_FH);
  fprintf(DEBUG_FH, "\n\n");
#endif
}
    break;

  case 117:

/* Line 1455 of yacc.c  */
#line 1786 "./sparql_parser.y"
    {
#if RASQAL_DEBUG > 1  
  fprintf(DEBUG_FH, "GraphPatternListFilter 1\n  GraphPatternNotTriples=");
  if((yyvsp[(1) - (1)].graph_pattern))
    rasqal_graph_pattern_print((yyvsp[(1) - (1)].graph_pattern), DEBUG_FH);
  else
    fputs("NULL", DEBUG_FH);
  fputs("\n\n", DEBUG_FH);
#endif

  (yyval.graph_pattern) = (yyvsp[(1) - (1)].graph_pattern);
}
    break;

  case 118:

/* Line 1455 of yacc.c  */
#line 1799 "./sparql_parser.y"
    {
#if RASQAL_DEBUG > 1  
  fprintf(DEBUG_FH, "GraphPatternListFilter 2\n  Filter=");
  if((yyvsp[(1) - (1)].expr))
    rasqal_expression_print((yyvsp[(1) - (1)].expr), DEBUG_FH);
  else
    fputs("NULL", DEBUG_FH);
  fputs("\n", DEBUG_FH);
#endif

  (yyval.graph_pattern) = rasqal_new_filter_graph_pattern((rasqal_query*)rq, (yyvsp[(1) - (1)].expr));
  if(!(yyval.graph_pattern))
    YYERROR_MSG("GraphPatternListFilter 2: cannot create graph pattern");

#if RASQAL_DEBUG > 1  
  fprintf(DEBUG_FH, "  after graph pattern=");
  if((yyval.graph_pattern))
    rasqal_graph_pattern_print((yyval.graph_pattern), DEBUG_FH);
  else
    fputs("NULL", DEBUG_FH);
  fprintf(DEBUG_FH, "\n\n");
#endif
}
    break;

  case 121:

/* Line 1455 of yacc.c  */
#line 1833 "./sparql_parser.y"
    {
#if RASQAL_DEBUG > 1  
  fprintf(DEBUG_FH, "TriplesBlock\n  TriplesSameSubject=");
  if((yyvsp[(1) - (3)].formula))
    rasqal_formula_print((yyvsp[(1) - (3)].formula), DEBUG_FH);
  else
    fputs("NULL", DEBUG_FH);
  fprintf(DEBUG_FH, ", TriplesBlockOpt=");
  if((yyvsp[(3) - (3)].formula))
    rasqal_formula_print((yyvsp[(3) - (3)].formula), DEBUG_FH);
  else
    fputs("NULL", DEBUG_FH);
  fputs("\n", DEBUG_FH);
#endif


  (yyval.formula) =  ((yyvsp[(1) - (3)].formula) ? (yyvsp[(1) - (3)].formula) : (yyvsp[(3) - (3)].formula));
  if((yyvsp[(1) - (3)].formula) && (yyvsp[(3) - (3)].formula)) {
    /* $1 and $3 are freed as necessary */
    (yyval.formula) = rasqal_formula_join((yyvsp[(1) - (3)].formula), (yyvsp[(3) - (3)].formula));
    if(!(yyvsp[(1) - (3)].formula))
      YYERROR_MSG("TriplesBlock: formula join failed");
  }

#if RASQAL_DEBUG > 1  
  fprintf(DEBUG_FH, "  after joining formula=");
  rasqal_formula_print((yyval.formula), DEBUG_FH);
  fprintf(DEBUG_FH, "\n\n");
#endif
}
    break;

  case 122:

/* Line 1455 of yacc.c  */
#line 1864 "./sparql_parser.y"
    {
  (yyval.formula) = (yyvsp[(1) - (1)].formula);
}
    break;

  case 123:

/* Line 1455 of yacc.c  */
#line 1872 "./sparql_parser.y"
    {
  (yyval.graph_pattern) = (yyvsp[(1) - (1)].graph_pattern);
}
    break;

  case 124:

/* Line 1455 of yacc.c  */
#line 1876 "./sparql_parser.y"
    {
  (yyval.graph_pattern) = (yyvsp[(1) - (1)].graph_pattern);
}
    break;

  case 125:

/* Line 1455 of yacc.c  */
#line 1880 "./sparql_parser.y"
    {
  (yyval.graph_pattern) = (yyvsp[(1) - (1)].graph_pattern);
}
    break;

  case 126:

/* Line 1455 of yacc.c  */
#line 1884 "./sparql_parser.y"
    {
  (yyval.graph_pattern) = (yyvsp[(1) - (1)].graph_pattern);
}
    break;

  case 127:

/* Line 1455 of yacc.c  */
#line 1892 "./sparql_parser.y"
    {
#if RASQAL_DEBUG > 1  
  fprintf(DEBUG_FH, "PatternElementForms 4\n  graphpattern=");
  if((yyvsp[(2) - (2)].graph_pattern))
    rasqal_graph_pattern_print((yyvsp[(2) - (2)].graph_pattern), DEBUG_FH);
  else
    fputs("NULL", DEBUG_FH);
  fputs("\n\n", DEBUG_FH);
#endif

  (yyval.graph_pattern) = NULL;

  if((yyvsp[(2) - (2)].graph_pattern)) {
    raptor_sequence *seq;

#ifdef RAPTOR_V2_AVAILABLE
    seq = raptor_new_sequence((raptor_data_free_handler*)rasqal_free_graph_pattern,
                              (raptor_data_print_handler*)rasqal_graph_pattern_print);
#else
    seq = raptor_new_sequence((raptor_sequence_free_handler*)rasqal_free_graph_pattern,
                              (raptor_sequence_print_handler*)rasqal_graph_pattern_print);
#endif
    if(!seq) {
      rasqal_free_graph_pattern((yyvsp[(2) - (2)].graph_pattern));
      YYERROR_MSG("OptionalGraphPattern 1: cannot create sequence");
    } else {
      if(raptor_sequence_push(seq, (yyvsp[(2) - (2)].graph_pattern))) {
        raptor_free_sequence(seq);
        YYERROR_MSG("OptionalGraphPattern 2: sequence push failed");
      } else {
        (yyval.graph_pattern) = rasqal_new_graph_pattern_from_sequence((rasqal_query*)rq,
                                                    seq,
                                                    RASQAL_GRAPH_PATTERN_OPERATOR_OPTIONAL);
        if(!(yyval.graph_pattern))
          YYERROR_MSG("OptionalGraphPattern: cannot create graph pattern");
      }
    }
  }
}
    break;

  case 128:

/* Line 1455 of yacc.c  */
#line 1936 "./sparql_parser.y"
    {
#if RASQAL_DEBUG > 1  
  fprintf(DEBUG_FH, "GraphGraphPattern 2\n  varoruri=");
  rasqal_literal_print((yyvsp[(2) - (3)].literal), DEBUG_FH);
  fprintf(DEBUG_FH, ", graphpattern=");
  if((yyvsp[(3) - (3)].graph_pattern))
    rasqal_graph_pattern_print((yyvsp[(3) - (3)].graph_pattern), DEBUG_FH);
  else
    fputs("NULL", DEBUG_FH);
  fputs("\n\n", DEBUG_FH);
#endif

  if((yyvsp[(3) - (3)].graph_pattern)) {
    raptor_sequence *seq;

#ifdef RAPTOR_V2_AVAILABLE
    seq = raptor_new_sequence((raptor_data_free_handler*)rasqal_free_graph_pattern,
                              (raptor_data_print_handler*)rasqal_graph_pattern_print);
#else
    seq = raptor_new_sequence((raptor_sequence_free_handler*)rasqal_free_graph_pattern,
                              (raptor_sequence_print_handler*)rasqal_graph_pattern_print);
#endif
    if(!seq) {
      rasqal_free_graph_pattern((yyvsp[(3) - (3)].graph_pattern));
      YYERROR_MSG("GraphGraphPattern 1: cannot create sequence");
    } else {
      if(raptor_sequence_push(seq, (yyvsp[(3) - (3)].graph_pattern))) {
        raptor_free_sequence(seq);
        YYERROR_MSG("GraphGraphPattern 2: sequence push failed");
      } else {
        (yyval.graph_pattern) = rasqal_new_graph_pattern_from_sequence((rasqal_query*)rq,
                                                    seq,
                                                    RASQAL_GRAPH_PATTERN_OPERATOR_GRAPH);
        if(!(yyval.graph_pattern))
          YYERROR_MSG("GraphGraphPattern: cannot create graph pattern");
        else
          rasqal_graph_pattern_set_origin((yyval.graph_pattern), (yyvsp[(2) - (3)].literal));
      }
    }
  }


#if RASQAL_DEBUG > 1  
  fprintf(DEBUG_FH, "GraphGraphPattern\n  graphpattern=");
  rasqal_graph_pattern_print((yyval.graph_pattern), DEBUG_FH);
  fputs("\n\n", DEBUG_FH);
#endif

  rasqal_free_literal((yyvsp[(2) - (3)].literal));
}
    break;

  case 129:

/* Line 1455 of yacc.c  */
#line 1991 "./sparql_parser.y"
    {
  (yyval.graph_pattern) = (yyvsp[(3) - (3)].graph_pattern);
  if(raptor_sequence_shift((yyval.graph_pattern)->graph_patterns, (yyvsp[(1) - (3)].graph_pattern))) {
    rasqal_free_graph_pattern((yyval.graph_pattern));
    (yyval.graph_pattern) = NULL;
    YYERROR_MSG("GroupOrUnionGraphPattern: sequence push failed");
  }

#if RASQAL_DEBUG > 1  
  fprintf(DEBUG_FH, "UnionGraphPattern\n  graphpattern=");
  rasqal_graph_pattern_print((yyval.graph_pattern), DEBUG_FH);
  fputs("\n\n", DEBUG_FH);
#endif
}
    break;

  case 130:

/* Line 1455 of yacc.c  */
#line 2006 "./sparql_parser.y"
    {
  (yyval.graph_pattern) = (yyvsp[(1) - (1)].graph_pattern);
}
    break;

  case 131:

/* Line 1455 of yacc.c  */
#line 2013 "./sparql_parser.y"
    {
  (yyval.graph_pattern) = (yyvsp[(1) - (3)].graph_pattern);
  if((yyvsp[(3) - (3)].graph_pattern))
    if(raptor_sequence_push((yyval.graph_pattern)->graph_patterns, (yyvsp[(3) - (3)].graph_pattern))) {
      rasqal_free_graph_pattern((yyval.graph_pattern));
      (yyval.graph_pattern) = NULL;
      YYERROR_MSG("GroupOrUnionGraphPatternList 1: sequence push failed");
    }
}
    break;

  case 132:

/* Line 1455 of yacc.c  */
#line 2023 "./sparql_parser.y"
    {
  raptor_sequence *seq;
#ifdef RAPTOR_V2_AVAILABLE
  seq = raptor_new_sequence((raptor_data_free_handler*)rasqal_free_graph_pattern,
                            (raptor_data_print_handler*)rasqal_graph_pattern_print);
#else
  seq = raptor_new_sequence((raptor_sequence_free_handler*)rasqal_free_graph_pattern,
                            (raptor_sequence_print_handler*)rasqal_graph_pattern_print);
#endif
  if(!seq) {
    if((yyvsp[(1) - (1)].graph_pattern))
      rasqal_free_graph_pattern((yyvsp[(1) - (1)].graph_pattern));
    YYERROR_MSG("GroupOrUnionGraphPatternList 2: cannot create sequence");
  }
  if((yyvsp[(1) - (1)].graph_pattern))
    if(raptor_sequence_push(seq, (yyvsp[(1) - (1)].graph_pattern))) {
      raptor_free_sequence(seq);
      YYERROR_MSG("GroupOrUnionGraphPatternList 2: sequence push failed");
    }
  (yyval.graph_pattern) = rasqal_new_graph_pattern_from_sequence((rasqal_query*)rq,
                                              seq,
                                              RASQAL_GRAPH_PATTERN_OPERATOR_UNION);
  if(!(yyval.graph_pattern))
    YYERROR_MSG("GroupOrUnionGraphPatternList 1: cannot create gp");
}
    break;

  case 133:

/* Line 1455 of yacc.c  */
#line 2053 "./sparql_parser.y"
    {
  rasqal_sparql_query_language* sparql;
  sparql = (rasqal_sparql_query_language*)(((rasqal_query*)rq)->context);

  if((yyvsp[(3) - (6)].variable) && (yyvsp[(5) - (6)].expr)) {
    if(sparql->extended)
      (yyval.graph_pattern) = rasqal_new_let_graph_pattern((rasqal_query*)rq, (yyvsp[(3) - (6)].variable), (yyvsp[(5) - (6)].expr));
    else {
      sparql_syntax_error((rasqal_query*)rq,
                          "LET cannot be used with SPARQL 1.0");
      rasqal_free_expression((yyvsp[(5) - (6)].expr));
      (yyval.graph_pattern) = NULL;
    }
  } else
    (yyval.graph_pattern) = NULL;
}
    break;

  case 134:

/* Line 1455 of yacc.c  */
#line 2074 "./sparql_parser.y"
    {
  (yyval.expr) = (yyvsp[(2) - (2)].expr);
}
    break;

  case 135:

/* Line 1455 of yacc.c  */
#line 2082 "./sparql_parser.y"
    {
  (yyval.expr) = (yyvsp[(1) - (1)].expr);
}
    break;

  case 136:

/* Line 1455 of yacc.c  */
#line 2086 "./sparql_parser.y"
    {
  (yyval.expr) = (yyvsp[(1) - (1)].expr);
}
    break;

  case 137:

/* Line 1455 of yacc.c  */
#line 2090 "./sparql_parser.y"
    {
  (yyval.expr) = (yyvsp[(1) - (1)].expr);
}
    break;

  case 138:

/* Line 1455 of yacc.c  */
#line 2098 "./sparql_parser.y"
    {
  raptor_uri* uri = rasqal_literal_as_uri((yyvsp[(1) - (3)].literal));
  
  if(!(yyvsp[(2) - (3)].seq)) {
#ifdef RAPTOR_V2_AVAILABLE
    (yyvsp[(2) - (3)].seq) = raptor_new_sequence((raptor_data_free_handler*)rasqal_free_expression,
                             (raptor_data_print_handler*)rasqal_expression_print);
#else
    (yyvsp[(2) - (3)].seq) = raptor_new_sequence((raptor_sequence_free_handler*)rasqal_free_expression,
                             (raptor_sequence_print_handler*)rasqal_expression_print);
#endif
    if(!(yyvsp[(2) - (3)].seq)) {
      rasqal_free_literal((yyvsp[(1) - (3)].literal));
      YYERROR_MSG("FunctionCall: cannot create sequence");
    }
  }

  uri = raptor_uri_copy(uri);

  if(raptor_sequence_size((yyvsp[(2) - (3)].seq)) == 1 &&
     rasqal_xsd_is_datatype_uri(((rasqal_query*)rq)->world, uri)) {
    rasqal_expression* e = (rasqal_expression*)raptor_sequence_pop((yyvsp[(2) - (3)].seq));
    (yyval.expr) = rasqal_new_cast_expression(((rasqal_query*)rq)->world, uri, e);
    raptor_free_sequence((yyvsp[(2) - (3)].seq));
  } else {
    (yyval.expr) = rasqal_new_function_expression(((rasqal_query*)rq)->world, uri, (yyvsp[(2) - (3)].seq));
  }
  rasqal_free_literal((yyvsp[(1) - (3)].literal));

  if(!(yyval.expr))
    YYERROR_MSG("FunctionCall: cannot create expr");
}
    break;

  case 139:

/* Line 1455 of yacc.c  */
#line 2135 "./sparql_parser.y"
    {
  rasqal_sparql_query_language* sparql;
  sparql = (rasqal_sparql_query_language*)(((rasqal_query*)rq)->context);

  if(!sparql->extended)
    sparql_syntax_error((rasqal_query*)rq,
                        "COALESCE cannot be used with SPARQL 1.0");

  if(!(yyvsp[(3) - (4)].seq)) {
#ifdef RAPTOR_V2_AVAILABLE
    (yyvsp[(3) - (4)].seq) = raptor_new_sequence((raptor_data_free_handler*)rasqal_free_expression,
                             (raptor_data_print_handler*)rasqal_expression_print);
#else
    (yyvsp[(3) - (4)].seq) = raptor_new_sequence((raptor_sequence_free_handler*)rasqal_free_expression,
                             (raptor_sequence_print_handler*)rasqal_expression_print);
#endif
    if(!(yyvsp[(3) - (4)].seq))
      YYERROR_MSG("FunctionCall: cannot create sequence");
  }

  (yyval.expr) = rasqal_new_coalesce_expression(((rasqal_query*)rq)->world, (yyvsp[(3) - (4)].seq));
  if(!(yyval.expr))
    YYERROR_MSG("Coalesce: cannot create expr");
}
    break;

  case 140:

/* Line 1455 of yacc.c  */
#line 2164 "./sparql_parser.y"
    {
  (yyval.seq) = (yyvsp[(1) - (3)].seq);
  if((yyvsp[(3) - (3)].expr))
    if(raptor_sequence_push((yyval.seq), (yyvsp[(3) - (3)].expr))) {
      raptor_free_sequence((yyval.seq));
      (yyval.seq) = NULL;
      YYERROR_MSG("ArgList 1: sequence push failed");
    }
}
    break;

  case 141:

/* Line 1455 of yacc.c  */
#line 2174 "./sparql_parser.y"
    {
#ifdef RAPTOR_V2_AVAILABLE
  (yyval.seq) = raptor_new_sequence((raptor_data_free_handler*)rasqal_free_expression,
                           (raptor_data_print_handler*)rasqal_expression_print);
#else
  (yyval.seq) = raptor_new_sequence((raptor_sequence_free_handler*)rasqal_free_expression,
                           (raptor_sequence_print_handler*)rasqal_expression_print);
#endif
  if(!(yyval.seq)) {
    if((yyvsp[(1) - (1)].expr))
      rasqal_free_expression((yyvsp[(1) - (1)].expr));
    YYERROR_MSG("ArgList 2: cannot create sequence");
  }
  if((yyvsp[(1) - (1)].expr))
    if(raptor_sequence_push((yyval.seq), (yyvsp[(1) - (1)].expr))) {
      raptor_free_sequence((yyval.seq));
      (yyval.seq) = NULL;
      YYERROR_MSG("ArgList 2: sequence push failed");
    }
}
    break;

  case 142:

/* Line 1455 of yacc.c  */
#line 2195 "./sparql_parser.y"
    {
  (yyval.seq) = NULL;
}
    break;

  case 143:

/* Line 1455 of yacc.c  */
#line 2203 "./sparql_parser.y"
    {
  (yyval.seq) = (yyvsp[(2) - (3)].seq);
}
    break;

  case 144:

/* Line 1455 of yacc.c  */
#line 2211 "./sparql_parser.y"
    {
  (yyval.seq) = (yyvsp[(1) - (1)].seq);
}
    break;

  case 145:

/* Line 1455 of yacc.c  */
#line 2215 "./sparql_parser.y"
    {
#ifdef RAPTOR_V2_AVAILABLE
  (yyval.seq) = raptor_new_sequence((raptor_data_free_handler*)rasqal_free_triple,
                           (raptor_data_print_handler*)rasqal_triple_print);
#else
  (yyval.seq) = raptor_new_sequence((raptor_sequence_free_handler*)rasqal_free_triple,
                           (raptor_sequence_print_handler*)rasqal_triple_print);
#endif
  if(!(yyval.seq)) {
    YYERROR_MSG("ConstructTriplesOpt: cannot create sequence");
  }
}
    break;

  case 146:

/* Line 1455 of yacc.c  */
#line 2232 "./sparql_parser.y"
    {
  (yyval.seq) = NULL;
 
  if((yyvsp[(1) - (3)].formula)) {
    (yyval.seq) = (yyvsp[(1) - (3)].formula)->triples;
    (yyvsp[(1) - (3)].formula)->triples = NULL;
    rasqal_free_formula((yyvsp[(1) - (3)].formula));
  }
  
  if((yyvsp[(3) - (3)].seq)) {
    if(!(yyval.seq)) {
#ifdef RAPTOR_V2_AVAILABLE
      (yyval.seq) = raptor_new_sequence((raptor_data_free_handler*)rasqal_free_triple,
                               (raptor_data_print_handler*)rasqal_triple_print);
#else
      (yyval.seq) = raptor_new_sequence((raptor_sequence_free_handler*)rasqal_free_triple,
                               (raptor_sequence_print_handler*)rasqal_triple_print);
#endif
      if(!(yyval.seq)) {
        raptor_free_sequence((yyvsp[(3) - (3)].seq));
        YYERROR_MSG("ConstructTriples: cannot create sequence");
      }
    }

    if(raptor_sequence_join((yyval.seq), (yyvsp[(3) - (3)].seq))) {
      raptor_free_sequence((yyvsp[(3) - (3)].seq));
      raptor_free_sequence((yyval.seq));
      (yyval.seq) = NULL;
      YYERROR_MSG("ConstructTriples: sequence join failed");
    }
    raptor_free_sequence((yyvsp[(3) - (3)].seq));
  }

 }
    break;

  case 147:

/* Line 1455 of yacc.c  */
#line 2267 "./sparql_parser.y"
    {
  (yyval.seq) = NULL;
  
  if((yyvsp[(1) - (1)].formula)) {
    (yyval.seq) = (yyvsp[(1) - (1)].formula)->triples;
    (yyvsp[(1) - (1)].formula)->triples = NULL;
    rasqal_free_formula((yyvsp[(1) - (1)].formula));
  }
  
}
    break;

  case 148:

/* Line 1455 of yacc.c  */
#line 2282 "./sparql_parser.y"
    {
  int i;

#if RASQAL_DEBUG > 1  
  fprintf(DEBUG_FH, "TriplesSameSubject 1\n  subject=");
  rasqal_formula_print((yyvsp[(1) - (2)].formula), DEBUG_FH);
  if((yyvsp[(2) - (2)].formula)) {
    fprintf(DEBUG_FH, "\n  propertyList=");
    rasqal_formula_print((yyvsp[(2) - (2)].formula), DEBUG_FH);
    fprintf(DEBUG_FH, "\n");
  } else     
    fprintf(DEBUG_FH, "\n  and empty propertyList\n");
#endif

  if((yyvsp[(2) - (2)].formula)) {
    raptor_sequence *seq = (yyvsp[(2) - (2)].formula)->triples;
    rasqal_literal *subject = (yyvsp[(1) - (2)].formula)->value;
    int size = raptor_sequence_size(seq);
    
    /* non-empty property list, handle it  */
    for(i = 0; i < size; i++) {
      rasqal_triple* t2 = (rasqal_triple*)raptor_sequence_get_at(seq, i);
      if(t2->subject)
        continue;
      t2->subject = rasqal_new_literal_from_literal(subject);
    }
#if RASQAL_DEBUG > 1  
    fprintf(DEBUG_FH, "  after substitution propertyList=");
    rasqal_formula_print((yyvsp[(2) - (2)].formula), DEBUG_FH);
    fprintf(DEBUG_FH, "\n");
#endif
  }

  (yyval.formula) = rasqal_formula_join((yyvsp[(1) - (2)].formula), (yyvsp[(2) - (2)].formula));
  if(!(yyval.formula))
    YYERROR_MSG("TriplesSameSubject 1: formula join failed");

#if RASQAL_DEBUG > 1  
  fprintf(DEBUG_FH, "  after joining formula=");
  rasqal_formula_print((yyval.formula), DEBUG_FH);
  fprintf(DEBUG_FH, "\n\n");
#endif
}
    break;

  case 149:

/* Line 1455 of yacc.c  */
#line 2326 "./sparql_parser.y"
    {
  int i;

#if RASQAL_DEBUG > 1  
  fprintf(DEBUG_FH, "TriplesSameSubject 2\n  TriplesNode=");
  rasqal_formula_print((yyvsp[(1) - (2)].formula), DEBUG_FH);
  if((yyvsp[(2) - (2)].formula)) {
    fprintf(DEBUG_FH, "\n  propertyList=");
    rasqal_formula_print((yyvsp[(2) - (2)].formula), DEBUG_FH);
    fprintf(DEBUG_FH, "\n");
  } else     
    fprintf(DEBUG_FH, "\n  and empty propertyList\n");
#endif

  if((yyvsp[(2) - (2)].formula)) {
    raptor_sequence *seq = (yyvsp[(2) - (2)].formula)->triples;
    rasqal_literal *subject = (yyvsp[(1) - (2)].formula)->value;
    int size = raptor_sequence_size(seq);
    
    /* non-empty property list, handle it  */
    for(i = 0; i < size; i++) {
      rasqal_triple* t2 = (rasqal_triple*)raptor_sequence_get_at(seq, i);
      if(t2->subject)
        continue;
      t2->subject = rasqal_new_literal_from_literal(subject);
    }
#if RASQAL_DEBUG > 1  
    fprintf(DEBUG_FH, "  after substitution propertyList=");
    rasqal_formula_print((yyvsp[(2) - (2)].formula), DEBUG_FH);
    fprintf(DEBUG_FH, "\n");
#endif
  }

  (yyval.formula) = rasqal_formula_join((yyvsp[(1) - (2)].formula), (yyvsp[(2) - (2)].formula));
  if(!(yyval.formula))
    YYERROR_MSG("TriplesSameSubject 2: formula join failed");

#if RASQAL_DEBUG > 1  
  fprintf(DEBUG_FH, "  after joining formula=");
  rasqal_formula_print((yyval.formula), DEBUG_FH);
  fprintf(DEBUG_FH, "\n\n");
#endif
}
    break;

  case 150:

/* Line 1455 of yacc.c  */
#line 2374 "./sparql_parser.y"
    {
  int i;
  
#if RASQAL_DEBUG > 1  
  fprintf(DEBUG_FH, "PropertyList 1\n  Verb=");
  rasqal_formula_print((yyvsp[(1) - (3)].formula), DEBUG_FH);
  fprintf(DEBUG_FH, "\n  ObjectList=");
  rasqal_formula_print((yyvsp[(2) - (3)].formula), DEBUG_FH);
  fprintf(DEBUG_FH, "\n  PropertyListTail=");
  if((yyvsp[(3) - (3)].formula) != NULL)
    rasqal_formula_print((yyvsp[(3) - (3)].formula), DEBUG_FH);
  else
    fputs("NULL", DEBUG_FH);
  fprintf(DEBUG_FH, "\n");
#endif
  
  if((yyvsp[(2) - (3)].formula) == NULL) {
#if RASQAL_DEBUG > 1  
    fprintf(DEBUG_FH, " empty ObjectList not processed\n");
#endif
  } else if((yyvsp[(1) - (3)].formula) && (yyvsp[(2) - (3)].formula)) {
    raptor_sequence *seq = (yyvsp[(2) - (3)].formula)->triples;
    rasqal_literal *predicate = (yyvsp[(1) - (3)].formula)->value;
    rasqal_formula *formula;
    rasqal_triple *t2;
    int size;
    
    formula = rasqal_new_formula(((rasqal_query*)rq)->world);
    if(!formula) {
      rasqal_free_formula((yyvsp[(1) - (3)].formula));
      rasqal_free_formula((yyvsp[(2) - (3)].formula));
      if((yyvsp[(3) - (3)].formula))
        rasqal_free_formula((yyvsp[(3) - (3)].formula));
      YYERROR_MSG("PropertyList 1: cannot create formula");
    }
#ifdef RAPTOR_V2_AVAILABLE
    formula->triples = raptor_new_sequence((raptor_data_free_handler*)rasqal_free_triple,
                                           (raptor_data_print_handler*)rasqal_triple_print);
#else
    formula->triples = raptor_new_sequence((raptor_sequence_free_handler*)rasqal_free_triple,
                                           (raptor_sequence_print_handler*)rasqal_triple_print);
#endif
    if(!formula->triples) {
      rasqal_free_formula(formula);
      rasqal_free_formula((yyvsp[(1) - (3)].formula));
      rasqal_free_formula((yyvsp[(2) - (3)].formula));
      if((yyvsp[(3) - (3)].formula))
        rasqal_free_formula((yyvsp[(3) - (3)].formula));
      YYERROR_MSG("PropertyList 1: cannot create sequence");
    }

    /* non-empty property list, handle it  */
    size = raptor_sequence_size(seq);
    for(i = 0; i < size; i++) {
      t2 = (rasqal_triple*)raptor_sequence_get_at(seq, i);
      if(!t2->predicate)
        t2->predicate = (rasqal_literal*)rasqal_new_literal_from_literal(predicate);
    }
  
#if RASQAL_DEBUG > 1  
    fprintf(DEBUG_FH, "  after substitution ObjectList=");
    raptor_sequence_print(seq, DEBUG_FH);
    fprintf(DEBUG_FH, "\n");
#endif

    while(raptor_sequence_size(seq)) {
      t2 = (rasqal_triple*)raptor_sequence_unshift(seq);
      if(raptor_sequence_push(formula->triples, t2)) {
        rasqal_free_formula(formula);
        rasqal_free_formula((yyvsp[(1) - (3)].formula));
        rasqal_free_formula((yyvsp[(2) - (3)].formula));
        if((yyvsp[(3) - (3)].formula))
          rasqal_free_formula((yyvsp[(3) - (3)].formula));
        YYERROR_MSG("PropertyList 1: sequence push failed");
      }
    }

    (yyvsp[(3) - (3)].formula) = rasqal_formula_join(formula, (yyvsp[(3) - (3)].formula));
    if(!(yyvsp[(3) - (3)].formula)) {
      rasqal_free_formula((yyvsp[(1) - (3)].formula));
      rasqal_free_formula((yyvsp[(2) - (3)].formula));
      YYERROR_MSG("PropertyList 1: formula join failed");
    }

#if RASQAL_DEBUG > 1  
    fprintf(DEBUG_FH, "  after appending ObjectList=");
    rasqal_formula_print((yyvsp[(3) - (3)].formula), DEBUG_FH);
    fprintf(DEBUG_FH, "\n\n");
#endif

    rasqal_free_formula((yyvsp[(2) - (3)].formula));
  }

  if((yyvsp[(1) - (3)].formula))
    rasqal_free_formula((yyvsp[(1) - (3)].formula));

  (yyval.formula) = (yyvsp[(3) - (3)].formula);
}
    break;

  case 151:

/* Line 1455 of yacc.c  */
#line 2477 "./sparql_parser.y"
    {
  (yyval.formula) = (yyvsp[(2) - (2)].formula);
}
    break;

  case 152:

/* Line 1455 of yacc.c  */
#line 2481 "./sparql_parser.y"
    {
  (yyval.formula) = NULL;
}
    break;

  case 153:

/* Line 1455 of yacc.c  */
#line 2489 "./sparql_parser.y"
    {
  (yyval.formula) = (yyvsp[(1) - (1)].formula);
}
    break;

  case 154:

/* Line 1455 of yacc.c  */
#line 2493 "./sparql_parser.y"
    {
  (yyval.formula) = NULL;
}
    break;

  case 155:

/* Line 1455 of yacc.c  */
#line 2501 "./sparql_parser.y"
    {
  rasqal_formula *formula;
  rasqal_triple *triple;

#if RASQAL_DEBUG > 1  
  fprintf(DEBUG_FH, "ObjectList 1\n");
  fprintf(DEBUG_FH, "  Object=\n");
  rasqal_formula_print((yyvsp[(1) - (2)].formula), DEBUG_FH);
  fprintf(DEBUG_FH, "\n");
  if((yyvsp[(2) - (2)].formula)) {
    fprintf(DEBUG_FH, "  ObjectTail=");
    rasqal_formula_print((yyvsp[(2) - (2)].formula), DEBUG_FH);
    fprintf(DEBUG_FH, "\n");
  } else
    fprintf(DEBUG_FH, "  and empty ObjectTail\n");
#endif

  formula = rasqal_new_formula(((rasqal_query*)rq)->world);
  if(!formula) {
    rasqal_free_formula((yyvsp[(1) - (2)].formula));
    if((yyvsp[(2) - (2)].formula))
      rasqal_free_formula((yyvsp[(2) - (2)].formula));
    YYERROR_MSG("ObjectList: cannot create formula");
  }
  
#ifdef RAPTOR_V2_AVAILABLE
  formula->triples = raptor_new_sequence((raptor_data_free_handler*)rasqal_free_triple,
                                         (raptor_data_print_handler*)rasqal_triple_print);
#else
  formula->triples = raptor_new_sequence((raptor_sequence_free_handler*)rasqal_free_triple,
                                         (raptor_sequence_print_handler*)rasqal_triple_print);
#endif
  if(!formula->triples) {
    rasqal_free_formula(formula);
    rasqal_free_formula((yyvsp[(1) - (2)].formula));
    if((yyvsp[(2) - (2)].formula))
      rasqal_free_formula((yyvsp[(2) - (2)].formula));
    YYERROR_MSG("ObjectList: cannot create sequence");
  }

  triple = rasqal_new_triple(NULL, NULL, (yyvsp[(1) - (2)].formula)->value);
  (yyvsp[(1) - (2)].formula)->value = NULL; /* value now owned by triple */
  if(!triple) {
    rasqal_free_formula(formula);
    rasqal_free_formula((yyvsp[(1) - (2)].formula));
    if((yyvsp[(2) - (2)].formula))
      rasqal_free_formula((yyvsp[(2) - (2)].formula));
    YYERROR_MSG("ObjectList: cannot create triple");
  }

  if(raptor_sequence_push(formula->triples, triple)) {
    rasqal_free_formula(formula);
    rasqal_free_formula((yyvsp[(1) - (2)].formula));
    if((yyvsp[(2) - (2)].formula))
      rasqal_free_formula((yyvsp[(2) - (2)].formula));
    YYERROR_MSG("ObjectList: sequence push failed");
  }

  (yyval.formula) = rasqal_formula_join(formula, (yyvsp[(1) - (2)].formula));
  if(!(yyval.formula)) {
    if((yyvsp[(2) - (2)].formula))
      rasqal_free_formula((yyvsp[(2) - (2)].formula));
    YYERROR_MSG("ObjectList: formula join $1 failed");
  }

  (yyval.formula) = rasqal_formula_join((yyval.formula), (yyvsp[(2) - (2)].formula));
  if(!(yyval.formula))
    YYERROR_MSG("ObjectList: formula join $2 failed");

#if RASQAL_DEBUG > 1  
  fprintf(DEBUG_FH, "  objectList is now ");
  if((yyval.formula))
    raptor_sequence_print((yyval.formula)->triples, DEBUG_FH);
  else
    fputs("NULL", DEBUG_FH);
  fprintf(DEBUG_FH, "\n\n");
#endif
}
    break;

  case 156:

/* Line 1455 of yacc.c  */
#line 2584 "./sparql_parser.y"
    {
  (yyval.formula) = (yyvsp[(2) - (2)].formula);
}
    break;

  case 157:

/* Line 1455 of yacc.c  */
#line 2588 "./sparql_parser.y"
    {
  (yyval.formula) = NULL;
}
    break;

  case 158:

/* Line 1455 of yacc.c  */
#line 2596 "./sparql_parser.y"
    {
  (yyval.formula) = (yyvsp[(1) - (1)].formula);
}
    break;

  case 159:

/* Line 1455 of yacc.c  */
#line 2604 "./sparql_parser.y"
    {
  (yyval.formula) = rasqal_new_formula(((rasqal_query*)rq)->world);
  if(!(yyval.formula)) {
    if((yyvsp[(1) - (1)].literal))
      rasqal_free_literal((yyvsp[(1) - (1)].literal));
    YYERROR_MSG("Verb 1: cannot create formula");
  }
  (yyval.formula)->value = (yyvsp[(1) - (1)].literal);
}
    break;

  case 160:

/* Line 1455 of yacc.c  */
#line 2614 "./sparql_parser.y"
    {
  raptor_uri *uri;

#if RASQAL_DEBUG > 1  
  fprintf(DEBUG_FH, "verb Verb=rdf:type (a)\n");
#endif

#ifdef RAPTOR_V2_AVAILABLE
  uri = raptor_new_uri_for_rdf_concept(((rasqal_query*)rq)->world->raptor_world_ptr,
                                       (const unsigned char*)"type");
#else
  uri = raptor_new_uri_for_rdf_concept("type");
#endif
  if(!uri)
    YYERROR_MSG("Verb 2: uri for rdf concept type failed");
  (yyval.formula) = rasqal_new_formula(((rasqal_query*)rq)->world);
  if(!(yyval.formula)) {
    raptor_free_uri(uri);
    YYERROR_MSG("Verb 2: cannot create formula");
  }
  (yyval.formula)->value = rasqal_new_uri_literal(((rasqal_query*)rq)->world, uri);
  if(!(yyval.formula)->value) {
    rasqal_free_formula((yyval.formula));
    (yyval.formula) = NULL;
    YYERROR_MSG("Verb 2: cannot create uri literal");
  }
}
    break;

  case 161:

/* Line 1455 of yacc.c  */
#line 2646 "./sparql_parser.y"
    {
  (yyval.formula) = (yyvsp[(1) - (1)].formula);
}
    break;

  case 162:

/* Line 1455 of yacc.c  */
#line 2650 "./sparql_parser.y"
    {
  (yyval.formula) = (yyvsp[(1) - (1)].formula);
}
    break;

  case 163:

/* Line 1455 of yacc.c  */
#line 2658 "./sparql_parser.y"
    {
  int i;
  const unsigned char *id;

  if((yyvsp[(2) - (3)].formula) == NULL) {
    (yyval.formula) = rasqal_new_formula(((rasqal_query*)rq)->world);
    if(!(yyval.formula))
      YYERROR_MSG("BlankNodePropertyList: cannot create formula");
  } else {
    (yyval.formula) = (yyvsp[(2) - (3)].formula);
    if((yyval.formula)->value) {
      rasqal_free_literal((yyval.formula)->value);
      (yyval.formula)->value = NULL;
    }
  }
  
  id = rasqal_query_generate_bnodeid((rasqal_query*)rq, NULL);
  if(!id) {
    rasqal_free_formula((yyval.formula));
    (yyval.formula) = NULL;
    YYERROR_MSG("BlankNodeProperyList: cannot create bnodeid");
  }

  (yyval.formula)->value = rasqal_new_simple_literal(((rasqal_query*)rq)->world,
                                        RASQAL_LITERAL_BLANK, id);
  if(!(yyval.formula)->value) {
    rasqal_free_formula((yyval.formula));
    (yyval.formula) = NULL;
    YYERROR_MSG("BlankNodePropertyList: cannot create literal");
  }

  if((yyvsp[(2) - (3)].formula) == NULL) {
#if RASQAL_DEBUG > 1  
    fprintf(DEBUG_FH, "TriplesNode\n  PropertyList=");
    rasqal_formula_print((yyval.formula), DEBUG_FH);
    fprintf(DEBUG_FH, "\n");
#endif
  } else {
    raptor_sequence *seq = (yyvsp[(2) - (3)].formula)->triples;

    /* non-empty property list, handle it  */
#if RASQAL_DEBUG > 1  
    fprintf(DEBUG_FH, "TriplesNode\n  PropertyList=");
    raptor_sequence_print(seq, DEBUG_FH);
    fprintf(DEBUG_FH, "\n");
#endif

    for(i = 0; i<raptor_sequence_size(seq); i++) {
      rasqal_triple* t2 = (rasqal_triple*)raptor_sequence_get_at(seq, i);
      if(t2->subject)
        continue;
      
      t2->subject = (rasqal_literal*)rasqal_new_literal_from_literal((yyval.formula)->value);
    }

#if RASQAL_DEBUG > 1
    fprintf(DEBUG_FH, "  after substitution formula=");
    rasqal_formula_print((yyval.formula), DEBUG_FH);
    fprintf(DEBUG_FH, "\n\n");
#endif
  }
}
    break;

  case 164:

/* Line 1455 of yacc.c  */
#line 2725 "./sparql_parser.y"
    {
  int i;
  rasqal_query* rdf_query = (rasqal_query*)rq;
  rasqal_literal* first_identifier = NULL;
  rasqal_literal* rest_identifier = NULL;
  rasqal_literal* object = NULL;
  rasqal_literal* blank = NULL;

#if RASQAL_DEBUG > 1
  char const *errmsg;
  #define YYERR_MSG_GOTO(label,msg) do { errmsg = msg; goto label; } while(0)
#else
  #define YYERR_MSG_GOTO(label,ignore) goto label
#endif

#if RASQAL_DEBUG > 1  
  fprintf(DEBUG_FH, "Collection\n  GraphNodeListNotEmpty=");
  raptor_sequence_print((yyvsp[(2) - (3)].seq), DEBUG_FH);
  fprintf(DEBUG_FH, "\n");
#endif

  (yyval.formula) = rasqal_new_formula(((rasqal_query*)rq)->world);
  if(!(yyval.formula))
    YYERR_MSG_GOTO(err_Collection, "Collection: cannot create formula");

#ifdef RAPTOR_V2_AVAILABLE
  (yyval.formula)->triples = raptor_new_sequence((raptor_data_free_handler*)rasqal_free_triple,
                                    (raptor_data_print_handler*)rasqal_triple_print);
#else
  (yyval.formula)->triples = raptor_new_sequence((raptor_sequence_free_handler*)rasqal_free_triple,
                                    (raptor_sequence_print_handler*)rasqal_triple_print);
#endif
  if(!(yyval.formula)->triples)
    YYERR_MSG_GOTO(err_Collection, "Collection: cannot create sequence");

  first_identifier = rasqal_new_uri_literal(rdf_query->world,
                                            raptor_uri_copy(rdf_query->world->rdf_first_uri));
  if(!first_identifier)
    YYERR_MSG_GOTO(err_Collection, "Collection: cannot first_identifier");
  
  rest_identifier = rasqal_new_uri_literal(rdf_query->world,
                                           raptor_uri_copy(rdf_query->world->rdf_rest_uri));
  if(!rest_identifier)
    YYERR_MSG_GOTO(err_Collection, "Collection: cannot create rest_identifier");
  
  object = rasqal_new_uri_literal(rdf_query->world,
                                  raptor_uri_copy(rdf_query->world->rdf_nil_uri));
  if(!object)
    YYERR_MSG_GOTO(err_Collection, "Collection: cannot create nil object");

  for(i = raptor_sequence_size((yyvsp[(2) - (3)].seq))-1; i >= 0; i--) {
    rasqal_formula* f = (rasqal_formula*)raptor_sequence_get_at((yyvsp[(2) - (3)].seq), i);
    rasqal_triple *t2;
    const unsigned char *blank_id = NULL;

    blank_id = rasqal_query_generate_bnodeid(rdf_query, NULL);
    if(!blank_id)
      YYERR_MSG_GOTO(err_Collection, "Collection: cannot create bnodeid");

    blank = rasqal_new_simple_literal(((rasqal_query*)rq)->world, RASQAL_LITERAL_BLANK, blank_id);
    if(!blank)
      YYERR_MSG_GOTO(err_Collection, "Collection: cannot create bnode");

    /* Move existing formula triples */
    if(f->triples)
      if(raptor_sequence_join((yyval.formula)->triples, f->triples))
        YYERR_MSG_GOTO(err_Collection, "Collection: sequence join failed");

    /* add new triples we needed */
    t2 = rasqal_new_triple(rasqal_new_literal_from_literal(blank),
                           rasqal_new_literal_from_literal(first_identifier),
                           rasqal_new_literal_from_literal(f->value));
    if(!t2)
      YYERR_MSG_GOTO(err_Collection, "Collection: cannot create triple");

    if(raptor_sequence_push((yyval.formula)->triples, t2))
      YYERR_MSG_GOTO(err_Collection, "Collection: cannot create triple");

    t2 = rasqal_new_triple(rasqal_new_literal_from_literal(blank),
                           rasqal_new_literal_from_literal(rest_identifier),
                           rasqal_new_literal_from_literal(object));
    if(!t2)
      YYERR_MSG_GOTO(err_Collection, "Collection: cannot create triple 2");

    if(raptor_sequence_push((yyval.formula)->triples, t2))
      YYERR_MSG_GOTO(err_Collection, "Collection: sequence push 2 failed");

    rasqal_free_literal(object);
    object=blank;
    blank = NULL;
  }

  /* free sequence of formulas just processed */
  raptor_free_sequence((yyvsp[(2) - (3)].seq));
  
  (yyval.formula)->value=object;
  
#if RASQAL_DEBUG > 1
  fprintf(DEBUG_FH, "  after substitution collection=");
  rasqal_formula_print((yyval.formula), DEBUG_FH);
  fprintf(DEBUG_FH, "\n\n");
#endif

  rasqal_free_literal(first_identifier);
  rasqal_free_literal(rest_identifier);

  break; /* success */

  err_Collection:
  
  if(blank)
    rasqal_free_literal(blank);
  if(object)
    rasqal_free_literal(object);
  if(rest_identifier)
    rasqal_free_literal(rest_identifier);
  if(first_identifier)
    rasqal_free_literal(first_identifier);
  if((yyvsp[(2) - (3)].seq))
    raptor_free_sequence((yyvsp[(2) - (3)].seq));
  if((yyval.formula)) {
    rasqal_free_formula((yyval.formula));
    (yyval.formula) = NULL;
  }
  YYERROR_MSG(errmsg);
}
    break;

  case 165:

/* Line 1455 of yacc.c  */
#line 2857 "./sparql_parser.y"
    {
#if RASQAL_DEBUG > 1  
  char const *errmsg;

  fprintf(DEBUG_FH, "GraphNodeListNotEmpty 1\n");
  if((yyvsp[(2) - (2)].formula)) {
    fprintf(DEBUG_FH, "  GraphNode=");
    rasqal_formula_print((yyvsp[(2) - (2)].formula), DEBUG_FH);
    fprintf(DEBUG_FH, "\n");
  } else  
    fprintf(DEBUG_FH, "  and empty GraphNode\n");
  if((yyvsp[(1) - (2)].seq)) {
    fprintf(DEBUG_FH, "  GraphNodeListNotEmpty=");
    raptor_sequence_print((yyvsp[(1) - (2)].seq), DEBUG_FH);
    fprintf(DEBUG_FH, "\n");
  } else
    fprintf(DEBUG_FH, "  and empty GraphNodeListNotEmpty\n");
#endif

  (yyval.seq) = (yyvsp[(1) - (2)].seq);
  if(!(yyval.seq)) {
#ifdef RAPTOR_V2_AVAILABLE
    (yyval.seq) = raptor_new_sequence((raptor_data_free_handler*)rasqal_free_formula,
                             (raptor_data_print_handler*)rasqal_formula_print);
#else
    (yyval.seq) = raptor_new_sequence((raptor_sequence_free_handler*)rasqal_free_formula,
                             (raptor_sequence_print_handler*)rasqal_formula_print);
#endif
    if(!(yyval.seq))
      YYERR_MSG_GOTO(err_GraphNodeListNotEmpty,
                     "GraphNodeListNotEmpty: cannot create formula");
  }
  
  if((yyvsp[(2) - (2)].formula)) {
    if(raptor_sequence_push((yyval.seq), (yyvsp[(2) - (2)].formula))) {
      YYERR_MSG_GOTO(err_GraphNodeListNotEmpty,
                     "GraphNodeListNotEmpty 1: sequence push failed");
    }
    (yyvsp[(2) - (2)].formula) = NULL;
#if RASQAL_DEBUG > 1  
    fprintf(DEBUG_FH, "  itemList is now ");
    raptor_sequence_print((yyval.seq), DEBUG_FH);
    fprintf(DEBUG_FH, "\n\n");
#endif
  }

  break; /* success */

  err_GraphNodeListNotEmpty:
  if((yyvsp[(2) - (2)].formula))
    rasqal_free_formula((yyvsp[(2) - (2)].formula));
  if((yyval.seq)) {
    raptor_free_sequence((yyval.seq));
    (yyval.seq) = NULL;
  }
  YYERROR_MSG(errmsg);
}
    break;

  case 166:

/* Line 1455 of yacc.c  */
#line 2915 "./sparql_parser.y"
    {
#if RASQAL_DEBUG > 1  
  fprintf(DEBUG_FH, "GraphNodeListNotEmpty 2\n");
  if((yyvsp[(1) - (1)].formula)) {
    fprintf(DEBUG_FH, "  GraphNode=");
    rasqal_formula_print((yyvsp[(1) - (1)].formula), DEBUG_FH);
    fprintf(DEBUG_FH, "\n");
  } else  
    fprintf(DEBUG_FH, "  and empty GraphNode\n");
#endif

  if(!(yyvsp[(1) - (1)].formula))
    (yyval.seq) = NULL;
  else {
#ifdef RAPTOR_V2_AVAILABLE
    (yyval.seq) = raptor_new_sequence((raptor_data_free_handler*)rasqal_free_formula,
                             (raptor_data_print_handler*)rasqal_formula_print);
#else
    (yyval.seq) = raptor_new_sequence((raptor_sequence_free_handler*)rasqal_free_formula,
                             (raptor_sequence_print_handler*)rasqal_formula_print);
#endif
    if(!(yyval.seq)) {
      rasqal_free_formula((yyvsp[(1) - (1)].formula));
      YYERROR_MSG("GraphNodeListNotEmpty 2: cannot create sequence");
    }
    if(raptor_sequence_push((yyval.seq), (yyvsp[(1) - (1)].formula))) {
      raptor_free_sequence((yyval.seq));
      (yyval.seq) = NULL;
      YYERROR_MSG("GraphNodeListNotEmpty 2: sequence push failed");
    }
  }
#if RASQAL_DEBUG > 1  
  fprintf(DEBUG_FH, "  GraphNodeListNotEmpty is now ");
  raptor_sequence_print((yyval.seq), DEBUG_FH);
  fprintf(DEBUG_FH, "\n\n");
#endif
}
    break;

  case 167:

/* Line 1455 of yacc.c  */
#line 2957 "./sparql_parser.y"
    {
  (yyval.formula) = (yyvsp[(1) - (1)].formula);
}
    break;

  case 168:

/* Line 1455 of yacc.c  */
#line 2961 "./sparql_parser.y"
    {
  (yyval.formula) = (yyvsp[(1) - (1)].formula);
}
    break;

  case 169:

/* Line 1455 of yacc.c  */
#line 2969 "./sparql_parser.y"
    {
  (yyval.formula) = rasqal_new_formula(((rasqal_query*)rq)->world);
  if(!(yyval.formula))
    YYERROR_MSG("VarOrTerm 1: cannot create formula");
  (yyval.formula)->value = rasqal_new_variable_literal(((rasqal_query*)rq)->world, (yyvsp[(1) - (1)].variable));
  if(!(yyval.formula)->value) {
    rasqal_free_formula((yyval.formula));
    (yyval.formula) = NULL;
    YYERROR_MSG("VarOrTerm 1: cannot create literal");
  }
}
    break;

  case 170:

/* Line 1455 of yacc.c  */
#line 2981 "./sparql_parser.y"
    {
  (yyval.formula) = rasqal_new_formula(((rasqal_query*)rq)->world);
  if(!(yyval.formula)) {
    if((yyvsp[(1) - (1)].literal))
      rasqal_free_literal((yyvsp[(1) - (1)].literal));
    YYERROR_MSG("VarOrTerm 2: cannot create formula");
  }
  (yyval.formula)->value = (yyvsp[(1) - (1)].literal);
}
    break;

  case 171:

/* Line 1455 of yacc.c  */
#line 2994 "./sparql_parser.y"
    {
  (yyval.literal) = rasqal_new_variable_literal(((rasqal_query*)rq)->world, (yyvsp[(1) - (1)].variable));
  if(!(yyval.literal))
    YYERROR_MSG("VarOrIRIref: cannot create literal");
}
    break;

  case 172:

/* Line 1455 of yacc.c  */
#line 3000 "./sparql_parser.y"
    {
  (yyval.literal) = (yyvsp[(1) - (1)].literal);
}
    break;

  case 173:

/* Line 1455 of yacc.c  */
#line 3008 "./sparql_parser.y"
    {
  (yyval.variable) = (yyvsp[(2) - (2)].variable);
}
    break;

  case 174:

/* Line 1455 of yacc.c  */
#line 3012 "./sparql_parser.y"
    {
  (yyval.variable) = (yyvsp[(2) - (2)].variable);
}
    break;

  case 175:

/* Line 1455 of yacc.c  */
#line 3019 "./sparql_parser.y"
    {
  (yyval.variable) = rasqal_new_variable((rasqal_query*)rq, (yyvsp[(1) - (1)].name), NULL);
  if(!(yyval.variable))
    YYERROR_MSG("VarName: cannot create var");
}
    break;

  case 176:

/* Line 1455 of yacc.c  */
#line 3030 "./sparql_parser.y"
    {
  (yyval.literal) = (yyvsp[(1) - (1)].literal);
}
    break;

  case 177:

/* Line 1455 of yacc.c  */
#line 3034 "./sparql_parser.y"
    {
  (yyval.literal) = (yyvsp[(1) - (1)].literal);
}
    break;

  case 178:

/* Line 1455 of yacc.c  */
#line 3038 "./sparql_parser.y"
    {
  (yyval.literal) = (yyvsp[(1) - (1)].literal);
}
    break;

  case 179:

/* Line 1455 of yacc.c  */
#line 3042 "./sparql_parser.y"
    {
  (yyval.literal) = (yyvsp[(1) - (1)].literal);
}
    break;

  case 180:

/* Line 1455 of yacc.c  */
#line 3046 "./sparql_parser.y"
    {
  (yyval.literal) = (yyvsp[(1) - (1)].literal);
}
    break;

  case 181:

/* Line 1455 of yacc.c  */
#line 3050 "./sparql_parser.y"
    {
  (yyval.literal) = rasqal_new_uri_literal(((rasqal_query*)rq)->world, 
                              raptor_uri_copy(((rasqal_query*)rq)->world->rdf_nil_uri));
  if(!(yyval.literal))
    YYERROR_MSG("GraphTerm: cannot create literal");
}
    break;

  case 182:

/* Line 1455 of yacc.c  */
#line 3060 "./sparql_parser.y"
    {
  (yyval.expr) = (yyvsp[(1) - (1)].expr);
}
    break;

  case 183:

/* Line 1455 of yacc.c  */
#line 3068 "./sparql_parser.y"
    {
  (yyval.expr) = rasqal_new_2op_expression(((rasqal_query*)rq)->world,
                                 RASQAL_EXPR_OR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr));
  if(!(yyval.expr))
    YYERROR_MSG("ConditionalOrExpression: cannot create expr");
}
    break;

  case 184:

/* Line 1455 of yacc.c  */
#line 3075 "./sparql_parser.y"
    {
  (yyval.expr) = (yyvsp[(1) - (1)].expr);
}
    break;

  case 185:

/* Line 1455 of yacc.c  */
#line 3083 "./sparql_parser.y"
    {
  (yyval.expr) = rasqal_new_2op_expression(((rasqal_query*)rq)->world,
                                 RASQAL_EXPR_AND, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr));
  if(!(yyval.expr))
    YYERROR_MSG("ConditionalAndExpression: cannot create expr");
;
}
    break;

  case 186:

/* Line 1455 of yacc.c  */
#line 3091 "./sparql_parser.y"
    {
  (yyval.expr) = (yyvsp[(1) - (1)].expr);
}
    break;

  case 187:

/* Line 1455 of yacc.c  */
#line 3100 "./sparql_parser.y"
    {
  (yyval.expr) = rasqal_new_2op_expression(((rasqal_query*)rq)->world,
                                 RASQAL_EXPR_EQ, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr));
  if(!(yyval.expr))
    YYERROR_MSG("RelationalExpression 1: cannot create expr");
}
    break;

  case 188:

/* Line 1455 of yacc.c  */
#line 3107 "./sparql_parser.y"
    {
  (yyval.expr) = rasqal_new_2op_expression(((rasqal_query*)rq)->world,
                                 RASQAL_EXPR_NEQ, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr));
  if(!(yyval.expr))
    YYERROR_MSG("RelationalExpression 2: cannot create expr");
}
    break;

  case 189:

/* Line 1455 of yacc.c  */
#line 3114 "./sparql_parser.y"
    {
  (yyval.expr) = rasqal_new_2op_expression(((rasqal_query*)rq)->world,
                                 RASQAL_EXPR_LT, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr));
  if(!(yyval.expr))
    YYERROR_MSG("RelationalExpression 3: cannot create expr");
}
    break;

  case 190:

/* Line 1455 of yacc.c  */
#line 3121 "./sparql_parser.y"
    {
  (yyval.expr) = rasqal_new_2op_expression(((rasqal_query*)rq)->world,
                                 RASQAL_EXPR_GT, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr));
  if(!(yyval.expr))
    YYERROR_MSG("RelationalExpression 4: cannot create expr");
}
    break;

  case 191:

/* Line 1455 of yacc.c  */
#line 3128 "./sparql_parser.y"
    {
  (yyval.expr) = rasqal_new_2op_expression(((rasqal_query*)rq)->world,
                                 RASQAL_EXPR_LE, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr));
  if(!(yyval.expr))
    YYERROR_MSG("RelationalExpression 5: cannot create expr");
}
    break;

  case 192:

/* Line 1455 of yacc.c  */
#line 3135 "./sparql_parser.y"
    {
  (yyval.expr) = rasqal_new_2op_expression(((rasqal_query*)rq)->world,
                                 RASQAL_EXPR_GE, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr));
  if(!(yyval.expr))
    YYERROR_MSG("RelationalExpression 6: cannot create expr");
}
    break;

  case 193:

/* Line 1455 of yacc.c  */
#line 3142 "./sparql_parser.y"
    {
  (yyval.expr) = (yyvsp[(1) - (1)].expr);
}
    break;

  case 194:

/* Line 1455 of yacc.c  */
#line 3151 "./sparql_parser.y"
    {
  (yyval.expr) = rasqal_new_2op_expression(((rasqal_query*)rq)->world,
                                 RASQAL_EXPR_PLUS, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr));
  if(!(yyval.expr))
    YYERROR_MSG("AdditiveExpression 1: cannot create expr");
}
    break;

  case 195:

/* Line 1455 of yacc.c  */
#line 3158 "./sparql_parser.y"
    {
  (yyval.expr) = rasqal_new_2op_expression(((rasqal_query*)rq)->world,
                                 RASQAL_EXPR_MINUS, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr));
  if(!(yyval.expr))
    YYERROR_MSG("AdditiveExpression 2: cannot create expr");
}
    break;

  case 196:

/* Line 1455 of yacc.c  */
#line 3165 "./sparql_parser.y"
    {
  rasqal_expression *e;
  e = rasqal_new_literal_expression(((rasqal_query*)rq)->world, (yyvsp[(2) - (2)].literal));
  if(!e) {
    rasqal_free_expression((yyvsp[(1) - (2)].expr));
    YYERROR_MSG("AdditiveExpression 3: cannot create expr");
  }
  (yyval.expr) = rasqal_new_2op_expression(((rasqal_query*)rq)->world,
                                 RASQAL_EXPR_PLUS, (yyvsp[(1) - (2)].expr), e);
  if(!(yyval.expr))
    YYERROR_MSG("AdditiveExpression 4: cannot create expr");
}
    break;

  case 197:

/* Line 1455 of yacc.c  */
#line 3178 "./sparql_parser.y"
    {
  rasqal_expression *e;
  e = rasqal_new_literal_expression(((rasqal_query*)rq)->world, (yyvsp[(2) - (2)].literal));
  if(!e) {
    rasqal_free_expression((yyvsp[(1) - (2)].expr));
    YYERROR_MSG("AdditiveExpression 5: cannot create expr");
  }
  (yyval.expr) = rasqal_new_2op_expression(((rasqal_query*)rq)->world,
                                 RASQAL_EXPR_PLUS, (yyvsp[(1) - (2)].expr), e);
  if(!(yyval.expr))
    YYERROR_MSG("AdditiveExpression 6: cannot create expr");
}
    break;

  case 198:

/* Line 1455 of yacc.c  */
#line 3191 "./sparql_parser.y"
    {
  (yyval.expr) = (yyvsp[(1) - (1)].expr);
}
    break;

  case 199:

/* Line 1455 of yacc.c  */
#line 3198 "./sparql_parser.y"
    {
  (yyval.expr) = rasqal_new_2op_expression(((rasqal_query*)rq)->world,
                                 RASQAL_EXPR_STAR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr));
  if(!(yyval.expr))
    YYERROR_MSG("MultiplicativeExpression 1: cannot create expr");
}
    break;

  case 200:

/* Line 1455 of yacc.c  */
#line 3205 "./sparql_parser.y"
    {
  (yyval.expr) = rasqal_new_2op_expression(((rasqal_query*)rq)->world,
                                 RASQAL_EXPR_SLASH, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr));
  if(!(yyval.expr))
    YYERROR_MSG("MultiplicativeExpression 2: cannot create expr");
}
    break;

  case 201:

/* Line 1455 of yacc.c  */
#line 3212 "./sparql_parser.y"
    {
  (yyval.expr) = (yyvsp[(1) - (1)].expr);
}
    break;

  case 202:

/* Line 1455 of yacc.c  */
#line 3220 "./sparql_parser.y"
    {
  (yyval.expr) = rasqal_new_1op_expression(((rasqal_query*)rq)->world,
                                 RASQAL_EXPR_BANG, (yyvsp[(2) - (2)].expr));
  if(!(yyval.expr))
    YYERROR_MSG("UnaryExpression 1: cannot create expr");
}
    break;

  case 203:

/* Line 1455 of yacc.c  */
#line 3227 "./sparql_parser.y"
    {
  (yyval.expr) = (yyvsp[(2) - (2)].expr);
}
    break;

  case 204:

/* Line 1455 of yacc.c  */
#line 3231 "./sparql_parser.y"
    {
  (yyval.expr) = rasqal_new_1op_expression(((rasqal_query*)rq)->world,
                                 RASQAL_EXPR_UMINUS, (yyvsp[(2) - (2)].expr));
  if(!(yyval.expr))
    YYERROR_MSG("UnaryExpression 3: cannot create expr");
}
    break;

  case 205:

/* Line 1455 of yacc.c  */
#line 3238 "./sparql_parser.y"
    {
  (yyval.expr) = (yyvsp[(1) - (1)].expr);
}
    break;

  case 206:

/* Line 1455 of yacc.c  */
#line 3252 "./sparql_parser.y"
    {
  (yyval.expr) = (yyvsp[(1) - (1)].expr);
}
    break;

  case 207:

/* Line 1455 of yacc.c  */
#line 3256 "./sparql_parser.y"
    {
  (yyval.expr) = (yyvsp[(1) - (1)].expr);
}
    break;

  case 208:

/* Line 1455 of yacc.c  */
#line 3260 "./sparql_parser.y"
    {
  /* Grammar has IRIrefOrFunction here which is "IRIref ArgList?"
   * and essentially shorthand for FunctionCall | IRIref.  The Rasqal
   * SPARQL lexer distinguishes these for us with IRIrefBrace.
   * IRIref is covered below by GraphTerm.
   */
  (yyval.expr) = (yyvsp[(1) - (1)].expr);
}
    break;

  case 209:

/* Line 1455 of yacc.c  */
#line 3269 "./sparql_parser.y"
    {
  (yyval.expr) = rasqal_new_literal_expression(((rasqal_query*)rq)->world, (yyvsp[(1) - (1)].literal));
  if(!(yyval.expr))
    YYERROR_MSG("PrimaryExpression 4: cannot create expr");
}
    break;

  case 210:

/* Line 1455 of yacc.c  */
#line 3275 "./sparql_parser.y"
    {
  rasqal_literal *l;
  l = rasqal_new_variable_literal(((rasqal_query*)rq)->world, (yyvsp[(1) - (1)].variable));
  if(!l)
    YYERROR_MSG("PrimaryExpression 5: cannot create literal");
  (yyval.expr) = rasqal_new_literal_expression(((rasqal_query*)rq)->world, l);
  if(!(yyval.expr))
    YYERROR_MSG("PrimaryExpression 5: cannot create expr");
}
    break;

  case 211:

/* Line 1455 of yacc.c  */
#line 3289 "./sparql_parser.y"
    {
  (yyval.expr) = (yyvsp[(2) - (3)].expr);
}
    break;

  case 212:

/* Line 1455 of yacc.c  */
#line 3297 "./sparql_parser.y"
    {
  (yyval.expr) = rasqal_new_1op_expression(((rasqal_query*)rq)->world,
                                 RASQAL_EXPR_STR, (yyvsp[(3) - (4)].expr));
  if(!(yyval.expr))
    YYERROR_MSG("BuiltInCall 1: cannot create expr");
}
    break;

  case 213:

/* Line 1455 of yacc.c  */
#line 3304 "./sparql_parser.y"
    {
  (yyval.expr) = rasqal_new_1op_expression(((rasqal_query*)rq)->world,
                                 RASQAL_EXPR_LANG, (yyvsp[(3) - (4)].expr));
  if(!(yyval.expr))
    YYERROR_MSG("BuiltInCall 2: cannot create expr");
}
    break;

  case 214:

/* Line 1455 of yacc.c  */
#line 3311 "./sparql_parser.y"
    {
  (yyval.expr) = rasqal_new_2op_expression(((rasqal_query*)rq)->world,
                                 RASQAL_EXPR_LANGMATCHES, (yyvsp[(3) - (6)].expr), (yyvsp[(5) - (6)].expr));
  if(!(yyval.expr))
    YYERROR_MSG("BuiltInCall 3: cannot create expr");
}
    break;

  case 215:

/* Line 1455 of yacc.c  */
#line 3318 "./sparql_parser.y"
    {
  (yyval.expr) = rasqal_new_1op_expression(((rasqal_query*)rq)->world,
                                 RASQAL_EXPR_DATATYPE, (yyvsp[(3) - (4)].expr));
  if(!(yyval.expr))
    YYERROR_MSG("BuiltInCall 4: cannot create expr");
}
    break;

  case 216:

/* Line 1455 of yacc.c  */
#line 3325 "./sparql_parser.y"
    {
  rasqal_literal *l;
  rasqal_expression *e;
  l = rasqal_new_variable_literal(((rasqal_query*)rq)->world, (yyvsp[(3) - (4)].variable));
  if(!l)
    YYERROR_MSG("BuiltInCall 5: cannot create literal");
  e = rasqal_new_literal_expression(((rasqal_query*)rq)->world, l);
  if(!e)
    YYERROR_MSG("BuiltInCall 6: cannot create literal expr");
  (yyval.expr) = rasqal_new_1op_expression(((rasqal_query*)rq)->world,
                                 RASQAL_EXPR_BOUND, e);
  if(!(yyval.expr))
    YYERROR_MSG("BuiltInCall 7: cannot create expr");
}
    break;

  case 217:

/* Line 1455 of yacc.c  */
#line 3340 "./sparql_parser.y"
    {
  (yyval.expr) = rasqal_new_2op_expression(((rasqal_query*)rq)->world,
                                 RASQAL_EXPR_SAMETERM, (yyvsp[(3) - (6)].expr), (yyvsp[(5) - (6)].expr));
  if(!(yyval.expr))
    YYERROR_MSG("BuiltInCall 8: cannot create expr");
}
    break;

  case 218:

/* Line 1455 of yacc.c  */
#line 3347 "./sparql_parser.y"
    {
  (yyval.expr) = rasqal_new_1op_expression(((rasqal_query*)rq)->world,
                                 RASQAL_EXPR_ISURI, (yyvsp[(3) - (4)].expr));
  if(!(yyval.expr))
    YYERROR_MSG("BuiltInCall 9: cannot create expr");
}
    break;

  case 219:

/* Line 1455 of yacc.c  */
#line 3354 "./sparql_parser.y"
    {
  (yyval.expr) = rasqal_new_1op_expression(((rasqal_query*)rq)->world,
                                 RASQAL_EXPR_ISBLANK, (yyvsp[(3) - (4)].expr));
  if(!(yyval.expr))
    YYERROR_MSG("BuiltInCall 10: cannot create expr");
}
    break;

  case 220:

/* Line 1455 of yacc.c  */
#line 3361 "./sparql_parser.y"
    {
  (yyval.expr) = rasqal_new_1op_expression(((rasqal_query*)rq)->world,
                                 RASQAL_EXPR_ISLITERAL, (yyvsp[(3) - (4)].expr));
  if(!(yyval.expr))
    YYERROR_MSG("BuiltInCall 11: cannot create expr");
}
    break;

  case 221:

/* Line 1455 of yacc.c  */
#line 3368 "./sparql_parser.y"
    {
  (yyval.expr) = (yyvsp[(1) - (1)].expr);
}
    break;

  case 222:

/* Line 1455 of yacc.c  */
#line 3372 "./sparql_parser.y"
    {
  (yyval.expr) = (yyvsp[(1) - (1)].expr);
}
    break;

  case 223:

/* Line 1455 of yacc.c  */
#line 3380 "./sparql_parser.y"
    {
  (yyval.expr) = rasqal_new_3op_expression(((rasqal_query*)rq)->world,
                                 RASQAL_EXPR_REGEX, (yyvsp[(3) - (6)].expr), (yyvsp[(5) - (6)].expr), NULL);
  if(!(yyval.expr))
    YYERROR_MSG("RegexExpression 1: cannot create expr");
}
    break;

  case 224:

/* Line 1455 of yacc.c  */
#line 3387 "./sparql_parser.y"
    {
  (yyval.expr) = rasqal_new_3op_expression(((rasqal_query*)rq)->world,
                                 RASQAL_EXPR_REGEX, (yyvsp[(3) - (8)].expr), (yyvsp[(5) - (8)].expr), (yyvsp[(7) - (8)].expr));
  if(!(yyval.expr))
    YYERROR_MSG("RegexExpression 2: cannot create expr");
}
    break;

  case 225:

/* Line 1455 of yacc.c  */
#line 3401 "./sparql_parser.y"
    {
  (yyval.literal) = rasqal_new_uri_literal(((rasqal_query*)rq)->world, (yyvsp[(1) - (1)].uri));
  if(!(yyval.literal))
    YYERROR_MSG("IRIrefBrace 1: cannot create literal");
}
    break;

  case 226:

/* Line 1455 of yacc.c  */
#line 3407 "./sparql_parser.y"
    {
  (yyval.literal) = rasqal_new_simple_literal(((rasqal_query*)rq)->world,
                                 RASQAL_LITERAL_QNAME, (yyvsp[(1) - (1)].name));
  if(!(yyval.literal))
    YYERROR_MSG("IRIrefBrace 2: cannot create literal");
  if(rasqal_literal_expand_qname((rasqal_query*)rq, (yyval.literal))) {
    sparql_query_error_full((rasqal_query*)rq,
                            "QName %s cannot be expanded", (yyvsp[(1) - (1)].name));
    rasqal_free_literal((yyval.literal));
    (yyval.literal) = NULL;
    YYERROR_MSG("IRIrefBrace 2: cannot expand qname");
  }
}
    break;

  case 227:

/* Line 1455 of yacc.c  */
#line 3427 "./sparql_parser.y"
    {
  (yyval.literal) = (yyvsp[(1) - (1)].literal);
}
    break;

  case 228:

/* Line 1455 of yacc.c  */
#line 3431 "./sparql_parser.y"
    {
  (yyval.literal) = (yyvsp[(1) - (1)].literal);
}
    break;

  case 229:

/* Line 1455 of yacc.c  */
#line 3435 "./sparql_parser.y"
    {
  (yyval.literal) = (yyvsp[(1) - (1)].literal);
}
    break;

  case 230:

/* Line 1455 of yacc.c  */
#line 3442 "./sparql_parser.y"
    {
  (yyval.literal) = (yyvsp[(1) - (1)].literal);
}
    break;

  case 231:

/* Line 1455 of yacc.c  */
#line 3446 "./sparql_parser.y"
    {
  (yyval.literal) = (yyvsp[(1) - (1)].literal);
}
    break;

  case 232:

/* Line 1455 of yacc.c  */
#line 3450 "./sparql_parser.y"
    {
  (yyval.literal) = (yyvsp[(1) - (1)].literal);
}
    break;

  case 233:

/* Line 1455 of yacc.c  */
#line 3458 "./sparql_parser.y"
    {
  (yyval.literal) = (yyvsp[(1) - (1)].literal);
}
    break;

  case 234:

/* Line 1455 of yacc.c  */
#line 3462 "./sparql_parser.y"
    {
  (yyval.literal) = (yyvsp[(1) - (1)].literal);
}
    break;

  case 235:

/* Line 1455 of yacc.c  */
#line 3466 "./sparql_parser.y"
    {
  (yyval.literal) = (yyvsp[(1) - (1)].literal);
}
    break;

  case 236:

/* Line 1455 of yacc.c  */
#line 3474 "./sparql_parser.y"
    {
  (yyval.literal) = (yyvsp[(1) - (1)].literal);
}
    break;

  case 237:

/* Line 1455 of yacc.c  */
#line 3478 "./sparql_parser.y"
    {
  (yyval.literal) = (yyvsp[(1) - (1)].literal);
}
    break;

  case 238:

/* Line 1455 of yacc.c  */
#line 3482 "./sparql_parser.y"
    {
  (yyval.literal) = (yyvsp[(1) - (1)].literal);
}
    break;

  case 239:

/* Line 1455 of yacc.c  */
#line 3494 "./sparql_parser.y"
    {
  (yyval.literal) = rasqal_new_uri_literal(((rasqal_query*)rq)->world, (yyvsp[(1) - (1)].uri));
  if(!(yyval.literal))
    YYERROR_MSG("IRIref 1: cannot create literal");
}
    break;

  case 240:

/* Line 1455 of yacc.c  */
#line 3500 "./sparql_parser.y"
    {
  (yyval.literal) = rasqal_new_simple_literal(((rasqal_query*)rq)->world,
                                 RASQAL_LITERAL_QNAME, (yyvsp[(1) - (1)].name));
  if(!(yyval.literal))
    YYERROR_MSG("IRIref 2: cannot create literal");
  if(rasqal_literal_expand_qname((rasqal_query*)rq, (yyval.literal))) {
    sparql_query_error_full((rasqal_query*)rq,
                            "QName %s cannot be expanded", (yyvsp[(1) - (1)].name));
    rasqal_free_literal((yyval.literal));
    (yyval.literal) = NULL;
    YYERROR_MSG("IRIrefBrace 2: cannot expand qname");
  }
}
    break;

  case 241:

/* Line 1455 of yacc.c  */
#line 3520 "./sparql_parser.y"
    {
  (yyval.literal) = rasqal_new_simple_literal(((rasqal_query*)rq)->world,
                                 RASQAL_LITERAL_BLANK, (yyvsp[(1) - (1)].name));
  if(!(yyval.literal))
    YYERROR_MSG("BlankNode 1: cannot create literal");
}
    break;

  case 242:

/* Line 1455 of yacc.c  */
#line 3526 "./sparql_parser.y"
    {
  const unsigned char *id;
  id = rasqal_query_generate_bnodeid((rasqal_query*)rq, NULL);
  if(!id)
    YYERROR_MSG("BlankNode 2: cannot create bnodeid");
  (yyval.literal) = rasqal_new_simple_literal(((rasqal_query*)rq)->world,
                                 RASQAL_LITERAL_BLANK, id);
  if(!(yyval.literal))
    YYERROR_MSG("BlankNode 2: cannot create literal");
}
    break;



/* Line 1455 of yacc.c  */
#line 7146 "sparql_parser.c"
      default: break;
    }
  YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);

  YYPOPSTACK (yylen);
  yylen = 0;
  YY_STACK_PRINT (yyss, yyssp);

  *++yyvsp = yyval;

  /* Now `shift' the result of the reduction.  Determine what state
     that goes to, based on the state we popped back to and the rule
     number reduced by.  */

  yyn = yyr1[yyn];

  yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
  if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
    yystate = yytable[yystate];
  else
    yystate = yydefgoto[yyn - YYNTOKENS];

  goto yynewstate;


/*------------------------------------.
| yyerrlab -- here on detecting error |
`------------------------------------*/
yyerrlab:
  /* If not already recovering from an error, report this error.  */
  if (!yyerrstatus)
    {
      ++yynerrs;
#if ! YYERROR_VERBOSE
      yyerror (YY_("syntax error"));
#else
      {
	YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
	if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
	  {
	    YYSIZE_T yyalloc = 2 * yysize;
	    if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
	      yyalloc = YYSTACK_ALLOC_MAXIMUM;
	    if (yymsg != yymsgbuf)
	      YYSTACK_FREE (yymsg);
	    yymsg = (char *) YYSTACK_ALLOC (yyalloc);
	    if (yymsg)
	      yymsg_alloc = yyalloc;
	    else
	      {
		yymsg = yymsgbuf;
		yymsg_alloc = sizeof yymsgbuf;
	      }
	  }

	if (0 < yysize && yysize <= yymsg_alloc)
	  {
	    (void) yysyntax_error (yymsg, yystate, yychar);
	    yyerror (yymsg);
	  }
	else
	  {
	    yyerror (YY_("syntax error"));
	    if (yysize != 0)
	      goto yyexhaustedlab;
	  }
      }
#endif
    }



  if (yyerrstatus == 3)
    {
      /* If just tried and failed to reuse lookahead token after an
	 error, discard it.  */

      if (yychar <= YYEOF)
	{
	  /* Return failure if at end of input.  */
	  if (yychar == YYEOF)
	    YYABORT;
	}
      else
	{
	  yydestruct (YYPARSE_PARAM, "Error: discarding",
		      yytoken, &yylval);
	  yychar = YYEMPTY;
	}
    }

  /* Else will try to reuse lookahead token after shifting the error
     token.  */
  goto yyerrlab1;


/*---------------------------------------------------.
| yyerrorlab -- error raised explicitly by YYERROR.  |
`---------------------------------------------------*/
yyerrorlab:

  /* Pacify compilers like GCC when the user code never invokes
     YYERROR and the label yyerrorlab therefore never appears in user
     code.  */
  if (/*CONSTCOND*/ 0)
     goto yyerrorlab;

  /* Do not reclaim the symbols of the rule which action triggered
     this YYERROR.  */
  YYPOPSTACK (yylen);
  yylen = 0;
  YY_STACK_PRINT (yyss, yyssp);
  yystate = *yyssp;
  goto yyerrlab1;


/*-------------------------------------------------------------.
| yyerrlab1 -- common code for both syntax error and YYERROR.  |
`-------------------------------------------------------------*/
yyerrlab1:
  yyerrstatus = 3;	/* Each real token shifted decrements this.  */

  for (;;)
    {
      yyn = yypact[yystate];
      if (yyn != YYPACT_NINF)
	{
	  yyn += YYTERROR;
	  if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
	    {
	      yyn = yytable[yyn];
	      if (0 < yyn)
		break;
	    }
	}

      /* Pop the current state because it cannot handle the error token.  */
      if (yyssp == yyss)
	YYABORT;


      yydestruct (YYPARSE_PARAM, "Error: popping",
		  yystos[yystate], yyvsp);
      YYPOPSTACK (1);
      yystate = *yyssp;
      YY_STACK_PRINT (yyss, yyssp);
    }

  *++yyvsp = yylval;


  /* Shift the error token.  */
  YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);

  yystate = yyn;
  goto yynewstate;


/*-------------------------------------.
| yyacceptlab -- YYACCEPT comes here.  |
`-------------------------------------*/
yyacceptlab:
  yyresult = 0;
  goto yyreturn;

/*-----------------------------------.
| yyabortlab -- YYABORT comes here.  |
`-----------------------------------*/
yyabortlab:
  yyresult = 1;
  goto yyreturn;

#if !defined(yyoverflow) || YYERROR_VERBOSE
/*-------------------------------------------------.
| yyexhaustedlab -- memory exhaustion comes here.  |
`-------------------------------------------------*/
yyexhaustedlab:
  yyerror (YY_("memory exhausted"));
  yyresult = 2;
  /* Fall through.  */
#endif

yyreturn:
  if (yychar != YYEMPTY)
     yydestruct (YYPARSE_PARAM, "Cleanup: discarding lookahead",
		 yytoken, &yylval);
  /* Do not reclaim the symbols of the rule which action triggered
     this YYABORT or YYACCEPT.  */
  YYPOPSTACK (yylen);
  YY_STACK_PRINT (yyss, yyssp);
  while (yyssp != yyss)
    {
      yydestruct (YYPARSE_PARAM, "Cleanup: popping",
		  yystos[*yyssp], yyvsp);
      YYPOPSTACK (1);
    }
#ifndef yyoverflow
  if (yyss != yyssa)
    YYSTACK_FREE (yyss);
#endif
#if YYERROR_VERBOSE
  if (yymsg != yymsgbuf)
    YYSTACK_FREE (yymsg);
#endif
  /* Make sure YYID is used.  */
  return YYID (yyresult);
}



/* Line 1675 of yacc.c  */
#line 3545 "./sparql_parser.y"



/* Support functions */


/* This is declared in sparql_lexer.h but never used, so we always get
 * a warning unless this dummy code is here.  Used once below in an error case.
 */
static int yy_init_globals (yyscan_t yyscanner ) { return 0; }


/**
 * rasqal_sparql_query_language_init - Initialise the SPARQL query language parser
 *
 * Return value: non 0 on failure
 **/
static int
rasqal_sparql_query_language_init(rasqal_query* rdf_query, const char *name)
{
  rasqal_sparql_query_language* rqe;

  rqe = (rasqal_sparql_query_language*)rdf_query->context;

  rdf_query->compare_flags = RASQAL_COMPARE_XQUERY;

  rqe->extended = (strcmp(name, "laqrs") == 0);
  return 0;
}


/**
 * rasqal_sparql_query_language_terminate - Free the SPARQL query language parser
 *
 * Return value: non 0 on failure
 **/
static void
rasqal_sparql_query_language_terminate(rasqal_query* rdf_query)
{
  rasqal_sparql_query_language* sparql;
  sparql = (rasqal_sparql_query_language*)rdf_query->context;

  if(sparql && sparql->scanner_set) {
    sparql_lexer_lex_destroy(sparql->scanner);
    sparql->scanner_set = 0;
  }

}


static int
rasqal_sparql_query_language_prepare(rasqal_query* rdf_query)
{
  /* rasqal_sparql_query_language* sparql = (rasqal_sparql_query_language*)rdf_query->context; */
  int rc;
  
  if(!rdf_query->query_string)
    return 1;
  
  rc=sparql_parse(rdf_query);
  if(rc)
    return rc;

  /* FIXME - should check remaining query parts  */
  if(rasqal_sequence_has_qname(rdf_query->triples) ||
     rasqal_sequence_has_qname(rdf_query->constructs) ||
     rasqal_query_constraints_has_qname(rdf_query)) {
    sparql_query_error(rdf_query, "SPARQL query has unexpanded QNames");
    return 1;
  }

  /* SPARQL: Turn [] into anonymous variables */
  if(rasqal_query_build_anonymous_variables(rdf_query))
    return 1;
  
  /* SPARQL: Expand 'SELECT *' */
  if(rasqal_query_expand_wildcards(rdf_query))
    return 1;
  
  return 0;
}


static int
sparql_parse(rasqal_query* rq)
{
  rasqal_sparql_query_language* rqe;
  raptor_locator *locator=&rq->locator;
  void *buffer;

  rqe = (rasqal_sparql_query_language*)rq->context;

  if(!rq->query_string)
    return yy_init_globals(NULL); /* 0 but a way to use yy_init_globals */

  locator->line = 1;
  locator->column = -1; /* No column info */
  locator->byte = -1; /* No bytes info */

#if RASQAL_DEBUG > 2
  sparql_parser_debug = 1;
#endif

  rqe->lineno = 1;

  if(sparql_lexer_lex_init(&rqe->scanner))
    return 1;
  rqe->scanner_set = 1;

  sparql_lexer_set_extra(((rasqal_query*)rq), rqe->scanner);

  buffer = sparql_lexer__scan_buffer((char*)rq->query_string,
                                     rq->query_string_length, rqe->scanner);

  rqe->error_count = 0;

  sparql_parser_parse(rq);

  sparql_lexer_lex_destroy(rqe->scanner);
  rqe->scanner_set = 0;

  /* Parsing failed */
  if(rq->failed)
    return 1;
  
  return 0;
}


static void
sparql_query_error(rasqal_query *rq, const char *msg)
{
  rasqal_sparql_query_language* rqe;

  rqe = (rasqal_sparql_query_language*)rq->context;

  if(rqe->error_count++)
    return;

  rq->locator.line = rqe->lineno;
#ifdef RASQAL_SPARQL_USE_ERROR_COLUMNS
  /*  rq->locator.column = sparql_lexer_get_column(yyscanner);*/
#endif

  rq->failed = 1;
  rasqal_log_error_simple(((rasqal_query*)rq)->world, RAPTOR_LOG_LEVEL_ERROR,
                          &rq->locator, "%s", msg);
}


static void
sparql_query_error_full(rasqal_query *rq, const char *message, ...)
{
  va_list arguments;
  rasqal_sparql_query_language* rqe;

  rqe = (rasqal_sparql_query_language*)rq->context;

  if(rqe->error_count++)
    return;

  rq->locator.line = rqe->lineno;
#ifdef RASQAL_SPARQL_USE_ERROR_COLUMNS
  /*  rq->locator.column = sparql_lexer_get_column(yyscanner);*/
#endif

  va_start(arguments, message);

  rq->failed = 1;
  rasqal_log_error_varargs(((rasqal_query*)rq)->world, RAPTOR_LOG_LEVEL_ERROR,
                           &rq->locator, message, arguments);

  va_end(arguments);
}


int
sparql_syntax_error(rasqal_query *rq, const char *message, ...)
{
  rasqal_sparql_query_language *rqe;
  va_list arguments;

  rqe = (rasqal_sparql_query_language*)rq->context;

  if(rqe->error_count++)
    return 0;

  rq->locator.line=rqe->lineno;
#ifdef RASQAL_SPARQL_USE_ERROR_COLUMNS
  /*  rp->locator.column=sparql_lexer_get_column(yyscanner);*/
#endif

  va_start(arguments, message);
  rq->failed = 1;
  rasqal_log_error_varargs(((rasqal_query*)rq)->world, RAPTOR_LOG_LEVEL_ERROR,
                           &rq->locator, message, arguments);
  va_end(arguments);

  return 0;
}


int
sparql_syntax_warning(rasqal_query *rq, const char *message, ...)
{
  rasqal_sparql_query_language *rqe;
  va_list arguments;

  rqe = (rasqal_sparql_query_language*)rq->context;

  rq->locator.line = rqe->lineno;
#ifdef RASQAL_SPARQL_USE_ERROR_COLUMNS
  /*  rq->locator.column=sparql_lexer_get_column(yyscanner);*/
#endif

  va_start(arguments, message);
  rasqal_log_error_varargs(((rasqal_query*)rq)->world,
#ifdef RAPTOR_V2_AVAILABLE
                           RAPTOR_LOG_LEVEL_WARN,
#else
                           RAPTOR_LOG_LEVEL_WARNING,
#endif
                           &rq->locator, message,
                           arguments);
  va_end(arguments);

  return (0);
}


static int
rasqal_sparql_query_language_iostream_write_escaped_counted_string(rasqal_query* query,
                                                                 raptor_iostream* iostr,
                                                                 const unsigned char* string,
                                                                 size_t len)
{
  const char delim = '"';
  
  raptor_iostream_write_byte(iostr, delim);
  if(raptor_iostream_write_string_ntriples(iostr, string, len, delim))
    return 1;
  
  raptor_iostream_write_byte(iostr, delim);

  return 0;
}


static void
rasqal_sparql_query_language_register_factory(rasqal_query_language_factory *factory)
{
  factory->context_length = sizeof(rasqal_sparql_query_language);

  factory->init      = rasqal_sparql_query_language_init;
  factory->terminate = rasqal_sparql_query_language_terminate;
  factory->prepare   = rasqal_sparql_query_language_prepare;
  factory->iostream_write_escaped_counted_string = rasqal_sparql_query_language_iostream_write_escaped_counted_string;
}


int
rasqal_init_query_language_sparql(rasqal_world* world) {
  return rasqal_query_language_register_factory(world,
                                                "sparql", 
                                                "SPARQL W3C DAWG RDF Query Language",
                                                NULL,
                                                (const unsigned char*)"http://www.w3.org/TR/rdf-sparql-query/",
                                                &rasqal_sparql_query_language_register_factory);
}

int
rasqal_init_query_language_laqrs(rasqal_world* world) {
  return rasqal_query_language_register_factory(world,
                                                "laqrs", 
                                                "LAQRS adds to Querying RDF in SPARQL",
                                                NULL,
                                                NULL,
                                                &rasqal_sparql_query_language_register_factory);
}


#ifdef STANDALONE
#include <stdio.h>
#include <locale.h>
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifndef HAVE_GETOPT
#include <rasqal_getopt.h>
#endif

#ifdef NEED_OPTIND_DECLARATION
extern int optind;
extern char *optarg;
#endif

#define GETOPT_STRING "di:"

#define SPARQL_FILE_BUF_SIZE 2048

int
main(int argc, char *argv[]) 
{
  const char *program = rasqal_basename(argv[0]);
  char query_string[SPARQL_FILE_BUF_SIZE];
  rasqal_query *query;
  FILE *fh;
  int rc;
  const char *filename = NULL;
  raptor_uri* base_uri = NULL;
  unsigned char *uri_string;
  const char* query_languages[2] = {"sparql", "laqrs"};
  const char* query_language;
  int usage = 0;
  rasqal_world *world;
  
  query_language=query_languages[0];
  
  filename = getenv("SPARQL_QUERY_FILE");
    
  while(!usage) {
    int c = getopt (argc, argv, GETOPT_STRING);

    if (c == -1)
      break;

    switch (c) {
      case 0:
      case '?': /* getopt() - unknown option */
        usage = 1;
        break;
        
      case 'd':
#if RASQAL_DEBUG > 2
        sparql_parser_debug = 1;
#endif
        break;
  
      case 'i':
        if(optarg) {
          if(!strcmp(optarg, "laqrs")) {
            query_language = query_languages[1];
          } else if(!strcmp(optarg, "sparql")) {
            query_language = query_languages[0];
          } else {
            fprintf(stderr, "-i laqrs or -i sparql only\n");
            usage = 1;
          }
        }
        break;
    }
  }

  if(!filename) {
    if((argc-optind) != 1) {
      fprintf(stderr, "%s: Too many arguments.\n", program);
      usage = 1;
    } else
      filename = argv[optind];
  }
  
  if(usage) {
    fprintf(stderr, "SPARQL/LAQRS parser test for Rasqal %s\n", 
            rasqal_version_string);
    fprintf(stderr, "USAGE: %s [OPTIONS] SPARQL-QUERY-FILE\n", program);
    fprintf(stderr, "OPTIONS:\n");
#if RASQAL_DEBUG > 2
    fprintf(stderr, " -d           Bison parser debugging\n");
#endif
    fprintf(stderr, " -i LANGUAGE  Set query language\n");
    exit(1);
  }


 fh = fopen(filename, "r");
 if(!fh) {
   fprintf(stderr, "%s: Cannot open file %s - %s\n", program, filename,
           strerror(errno));
   exit(1);
 }
 
  memset(query_string, 0, SPARQL_FILE_BUF_SIZE);
  rc=fread(query_string, SPARQL_FILE_BUF_SIZE, 1, fh);
  if(rc < SPARQL_FILE_BUF_SIZE) {
    if(ferror(fh)) {
      fprintf(stderr, "%s: file '%s' read failed - %s\n",
              program, filename, strerror(errno));
      fclose(fh);
      return(1);
    }
  }
  
  fclose(fh);

  world = rasqal_new_world();
  if(!world || rasqal_world_open(world))
    exit(1);

  query = rasqal_new_query(world, query_language, NULL);

  uri_string = raptor_uri_filename_to_uri_string(filename);
#ifdef RAPTOR_V2_AVAILABLE
  base_uri = raptor_new_uri(world->raptor_world_ptr, uri_string);
#else
  base_uri = raptor_new_uri(uri_string);
#endif

  rc = rasqal_query_prepare(query, 
                            (const unsigned char*)query_string, base_uri);

  rasqal_query_print(query, stdout);

  rasqal_free_query(query);

  raptor_free_uri(base_uri);

  raptor_free_memory(uri_string);

  rasqal_free_world(world);

  return rc;
}
#endif

