/** * 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 Grammar - native syntax for the query engine // #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 // 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(SPARQLParser10) /** * 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.lang.sparql_10 ; 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.* ; public class SPARQLParser10 extends SPARQLParser10Base { boolean allowAggregatesInExpressions = false ; } PARSER_END(SPARQLParser10) void QueryUnit(): { } { Query() } void Query() : { } { Prologue() ( SelectQuery() | ConstructQuery() | DescribeQuery() | AskQuery() ) } 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 ; Node n ; } {