options { STATIC = false ; DEBUG_PARSER = false ; DEBUG_TOKEN_MANAGER = false ; JAVA_UNICODE_ESCAPE = false ; UNICODE_INPUT = true; } PARSER_BEGIN(SPARQLParser) /******************************************************************************* * Copyright (c) 2004, 2007-2009 IBM Corporation and Cambridge Semantics Incorporated. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * File: $Source: /cvsroot/slrp/glitter/com.ibm.adtech.glitter/grammar/sparql.jj,v $ * Created by: Lee Feigenbaum (feigenbl@us.ibm.com) * Created on: 10/23/06 * Revision: $Id: sparql.jj 164 2007-07-31 14:11:09Z mroy $ * * Contributors: IBM Corporation - initial API and implementation * Cambridge Semantics Incorporated - Fork to Anzo *******************************************************************************/ package org.openanzo.glitter.syntax.concrete; import org.openanzo.exceptions.ExceptionConstants; import org.openanzo.glitter.exception.GlitterRuntimeException; import org.openanzo.glitter.expression.aggregate.Min; import org.openanzo.glitter.expression.aggregate.Max; import org.openanzo.glitter.expression.aggregate.Count; import org.openanzo.glitter.expression.aggregate.Sum; import org.openanzo.glitter.expression.aggregate.Average; import org.openanzo.glitter.expression.aggregate.Sample; import org.openanzo.glitter.expression.aggregate.GroupConcat; import org.openanzo.glitter.expression.Function; import org.openanzo.glitter.expression.builtin.*; import org.openanzo.glitter.util.Constants; import org.openanzo.glitter.util.CURIE; import org.openanzo.rdf.URI; import org.openanzo.rdf.MemVariable; import org.openanzo.rdf.Variable; import org.openanzo.rdf.Literal; import org.openanzo.rdf.TypedLiteral; import org.openanzo.rdf.TriplePatternComponent; import org.openanzo.glitter.syntax.abstrakt.*; import org.openanzo.rdf.BlankNodeManager; import org.openanzo.rdf.MemBlankNode; import org.openanzo.rdf.datatype.*; import org.openanzo.rdf.vocabulary.RDF; import org.openanzo.glitter.query.*; import java.util.List; import java.util.ArrayList; import java.util.Set; import java.util.HashSet; import java.util.HashMap; // JavaCC generates code with compiler warnings that we can't get rid of so we suppress them. @SuppressWarnings({"all"}) public class SPARQLParser extends SPARQLParserBase { } PARSER_END(SPARQLParser) void Query() : { GraphPattern pattern = null; } { Prolog() ( pattern = SelectQuery(true) | pattern = ConstructQuery() | pattern = DescribeQuery() | pattern = AskQuery() ) { getQueryController().setQueryPattern(pattern); } } void Prolog() : {} { // Nothing specific to do here. (BaseDecl())? (PrefixDecl())* } void BaseDecl() : { Token t; } { t = { getQueryController().setBaseUri(getQueryController().resolveUri(token2uri(t))); } } void PrefixDecl() : { Token t; URI uri; CURIE curie; } { t = { curie = new CURIE(t.image); } t = { uri = getQueryController().resolveUri(token2uri(t)); } { getQueryController().mapPrefix(curie.getPrefix(), uri); } } GraphPattern SelectQuery(boolean allowDataset) : { Variable v; Expression e; ArrayList groupByVars = new ArrayList(); GraphPattern pattern; ArrayList expressions = new ArrayList(); ArrayList vars = new ArrayList(); boolean distinct = false; boolean reduced = false; boolean selectStar = false; Projection p; } { // Not sure if this should really be part of an // AST, or whether it would be better as bits of state // instead (for now, it's state)