/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // ARQ/SPARQL 1.1 Grammar - native syntax for the query engine #if 0 // (Run through cpp -P -C first) #endif #if !defined(ARQ) && !defined(SPARQL_11) #error Please define one of ARQ and SPARQL_11 #endif #if defined(ARQ) && defined(SPARQL_11) #error Please define only one of ARQ and SPARQL_11 #endif // UPDATE : SPARQL 1.1. Update // ARQ_UPDATE : extensions to SPARQL 1.1 Update to cover SPARQL/Update (W3C Submission) #ifdef SPARQL_11 #define PACKAGE lang.sparql_11 #define CLASS SPARQLParser11 #define PARSERBASE SPARQLParser11Base #define UPDATE #endif #ifdef ARQ #define PACKAGE lang.arq #define CLASS ARQParser #define PARSERBASE ARQParserBase #define UPDATE #define ARQ_UPDATE #endif options { // \ u processed in the input stream // SPARQL 1.0 JAVA_UNICODE_ESCAPE = true ; UNICODE_INPUT = false ; // // \ u processed after parsing. // // strings, prefix names, IRIs // JAVA_UNICODE_ESCAPE = false ; // UNICODE_INPUT = true ; STATIC = false ; // DEBUG_PARSER = true ; // DEBUG_TOKEN_MANAGER = true ; } PARSER_BEGIN(CLASS) /** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ 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.* ; import com.hp.hpl.jena.sparql.expr.aggregate.* ; #ifdef UPDATE import com.hp.hpl.jena.update.* ; import com.hp.hpl.jena.sparql.modify.request.* ; #endif public class CLASS extends PARSERBASE { boolean allowAggregatesInExpressions = false ; } PARSER_END(CLASS) // // Common top for single entry point. // void Top(): {} // { // ( Query() | Update() ) // // } // Query only entry point void QueryUnit(): { } { { startQuery() ; } Query() { finishQuery() ; } } void Query() : { } { Prologue() ( SelectQuery() | ConstructQuery() | DescribeQuery() | AskQuery() // #ifdef ARQ // | JsonTemplateQuery() // #endif ) BindingsClause() } #ifdef UPDATE void UpdateUnit() : {} { { startUpdateRequest() ; } Update() { finishUpdateRequest() ; } } #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() : { } { SelectClause() ( DatasetClause() )* WhereClause() SolutionModifier() } void SubSelect() :{ } { SelectClause() WhereClause() SolutionModifier() } void SelectClause() : { Var v ; Expr expr ; Node n ; } {