// ARQ/SPARQL Grammar - native syntax for the query engine #if 0 // (Run through cpp -P -C first) #endif #if !defined(ARQ) && !defined(SPARQL) #error Please define one of ARQ and SPARQL #endif #if defined(ARQ) && defined(SPARQL) #error Please define only one of ARQ and SPARQL #endif #ifdef SPARQL #define PACKAGE lang.sparql #define CLASS SPARQLParser #define PARSERBASE SPARQLParserBase #endif #ifdef ARQ #define PACKAGE lang.arq #define CLASS ARQParser #define PARSERBASE ARQParserBase #endif // Author: Andy Seaborne andy.seaborne@hp.com // (c) Copyright 2004, 2005, 2006, 2007 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 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.syntax.* ; import com.hp.hpl.jena.sparql.expr.* ; public class CLASS extends PARSERBASE { } PARSER_END(CLASS) void CompilationUnit(): { } { Query() } void Query() : { } { Prologue() ( SelectQuery() | ConstructQuery() | DescribeQuery() | AskQuery() ) } void Prologue() : {} { ( BaseDecl() ) ? ( PrefixDecl() )* } void BaseDecl() : { String iri ; } { iri = IRI_REF() { getQuery().setBaseURI(iri) ; } } void PrefixDecl() : { Token t ; String iri ; } { t = iri = IRI_REF() { String s = fixupPrefix(t.image, t.beginLine, t.beginColumn) ; getQuery().setPrefix(s, iri) ; } } // ---- Query type clauses void SelectQuery() : { Node v ; } {