// SPARQL Abstract Grammar #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 #define PACKAGE lang.prefix #define CLASS PrefixParser #define PARSERBASE PrefixParserBase // Author: Andy Seaborne andy.seaborne@hp.com // (c) 2006 Hewlett-Packard Development Company, LP // All rights reserved. // See end of file for details. options { JAVA_UNICODE_ESCAPE = true; UNICODE_INPUT = false ; STATIC = false ; // DEBUG_PARSER = true ; // DEBUG_TOKEN_MANAGER = true ; } PARSER_BEGIN(CLASS) /* * (c) Copyright 2006 Hewlett-Packard Development Company, LP * All rights reserved. */ package com.hp.hpl.jena.sparql.PACKAGE ; import java.util.* ; 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() : { } { Prolog() ( SelectQuery() | ConstructQuery() | DescribeQuery() | AskQuery() ) SolutionModifier() ( LOOKAHEAD(2) DatasetClause() )* (WhereClause())? } void Prolog() : {} { ( LOOKAHEAD(2) BaseDecl() ) ? ( LOOKAHEAD(2) PrefixDecl() )* } void BaseDecl() : { Node n ; } { n = Q_IRI_REF() { getQuery().setBaseURI(n.getURI()) ; } } void PrefixDecl() : { Token t ; Node n ; } { t = n = Q_IRI_REF() { String s = fixupPrefix(t.image, t.beginLine, t.beginColumn) ; getQuery().setPrefix(s, n.getURI()) ; } } // ---- Query type clauses void SelectQuery() : { Node v ; Token t = null ;} {