// ARQ/SPARQL Grammar - native syntax for the query engine // Experimental grammar //#define NEW_GRAMMAR // // Author: Andy Seaborne andy.seaborne@hp.com // (c) Copyright 2004, 2005 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 { // Use \ u escapes in streams AND use a reader for the query // => get both raw and escaped unicode JAVA_UNICODE_ESCAPE = true; UNICODE_INPUT = false ; STATIC = false ; // DEBUG_PARSER = true ; // DEBUG_TOKEN_MANAGER = true ; } PARSER_BEGIN(ARQParser) /* * (c) Copyright 2004, 2005 Hewlett-Packard Development Company, LP * All rights reserved. */ package com.hp.hpl.jena.query.parser.arq ; import java.util.* ; import com.hp.hpl.jena.graph.* ; import com.hp.hpl.jena.query.* ; import com.hp.hpl.jena.query.core.* ; import com.hp.hpl.jena.query.expr.* ; public class ARQParser extends ARQParserBase { } PARSER_END(ARQParser) void CompilationUnit(): { } { Query() } void Query() : { } { Prolog() ( SelectQuery() | ConstructQuery() | DescribeQuery() | AskQuery() ) } void Prolog() : {} { ( BaseDecl() ) ? ( PrefixDecl() )* } void BaseDecl() : { Node n ; } { n = QuotedIRIref() { getQuery().setBaseURI(n.getURI()) ; } } void PrefixDecl() : { Token t ; Node n ; } { t = n = QuotedIRIref() { String s = fixupPrefix(t.image, t.beginLine, t.beginColumn) ; getQuery().setPrefix(s, n.getURI()) ; } } // ---- Query type clauses void SelectQuery() : { Node v ; Token t = null ;} {