// ARQ/SPARQL Grammar - native syntax for the query engine #if 0 // (Run through cpp -P -C first) #endif // #if !defined(ARQ) && !defined(SPARQL_10) && !defined(SPARQL_11) // #error Please define one of ARQ, SPARQL_10 or SPARQL11 // #endif // // #if defined(SPARQL_10) // #define SPARQL // #endif #if !defined(ARQ) && !defined(SPARQL) #error Please define one of ARQ, SPARQL or SPARQL11 #endif #if defined(ARQ) && defined(SPARQL) #error Please define only one of ARQ and SPARQL #endif #ifdef SPARQL_10 #define PACKAGE lang.sparql_10 #define CLASS SPARQLParser10 #define PARSERBASE SPARQLParser10Base #endif #ifdef SPARQL_11 #define PACKAGE lang.sparql_11 #define CLASS SPARQLParser11 #define PARSERBASE SPARQLParser11Base #define UPDATE #endif #ifdef ARQ #define SPARQL_11 #define PACKAGE lang.arq #define CLASS ARQParser #define PARSERBASE ARQParserBase #define UPDATE #endif // Author: Andy Seaborne andy.seaborne@hp.com // (c) Copyright 2004, 2005, 2006, 2007, 2008, 2009 Hewlett-Packard Development Company, LP // All rights reserved. // See end of file for details. // // Constraint expression is derived from Java : // example java1.2-a.jj grammer in JavaCC distribution // Much modifed over time. options { JAVA_UNICODE_ESCAPE = true ; UNICODE_INPUT = false ; STATIC = false ; // DEBUG_PARSER = true ; // DEBUG_TOKEN_MANAGER = true ; } PARSER_BEGIN(CLASS) /* * (c) Copyright 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP * All rights reserved. */ package com.hp.hpl.jena.sparql.PACKAGE ; import com.hp.hpl.jena.graph.* ; import com.hp.hpl.jena.query.* ; import com.hp.hpl.jena.sparql.core.Var ; import com.hp.hpl.jena.sparql.syntax.* ; import com.hp.hpl.jena.sparql.expr.* ; import com.hp.hpl.jena.sparql.path.* ; #ifdef SPARQL_11 import com.hp.hpl.jena.sparql.expr.aggregate.* ; #endif #ifdef UPDATE import com.hp.hpl.jena.sparql.modify.op.* ; #endif public class CLASS extends PARSERBASE { private static long UNSET = P_Mod.UNSET ; private static long INF = P_Mod.INF ; boolean allowAggregatesInExpressions = false ; } PARSER_END(CLASS) #ifdef SPARQL_11 // Common top for single entry point. void Top(): {} { Prologue() ( Query() | Update() ) } #endif #ifdef SPARQL_10 void QueryUnit(): { } { Query() } void Query() : { } { Prologue() ( SelectQuery() | ConstructQuery() | DescribeQuery() | AskQuery() ) } #endif #ifdef SPARQL_11 // Refactored fro SPARQL 1.1 void QueryUnit(): { } { Prologue() Query() } void Query() : { } { ( SelectQuery() | ConstructQuery() | DescribeQuery() | AskQuery() ) } #endif void Prologue() : {} { ( BaseDecl() ) ? ( PrefixDecl() )* } void BaseDecl() : { String iri ; } { iri = IRI_REF() { getPrologue().setBaseURI(iri) ; } } void PrefixDecl() : { Token t ; String iri ; } { t = iri = IRI_REF() { String s = fixupPrefix(t.image, t.beginLine, t.beginColumn) ; getPrologue().setPrefix(s, iri) ; } } // ---- Query type clauses void SelectQuery() : { } { Project() ( DatasetClause() )* WhereClause() SolutionModifier() } void SubSelect() :{ } { Project() WhereClause() SolutionModifier() } void Project() : { Var v ; Expr expr ; } {