query.setSyntax( TerpSyntax.getInstance() );
final SparqlOwlLexer lexer = new SparqlOwlLexer( new ANTLRStringStream( queryString ) );
final CommonTokenStream tokenStream = new CommonTokenStream( lexer );
final SparqlOwlParser parser = new SparqlOwlParser( tokenStream );
SparqlOwlParser.query_return result;
try {
result = parser.query();
} catch( RecognitionException e ) {
throw new QueryParseException( format( "%s %s", parser.getErrorHeader( e ), parser
.getErrorMessage( e, parser.getTokenNames() ) ), e.line, e.charPositionInLine );
}
final CommonTree t = (CommonTree) result.getTree();
final CommonTreeNodeStream nodes = new CommonTreeNodeStream( t );
nodes.setTokenStream( tokenStream );
final SparqlOwlTreeARQ treeWalker = new SparqlOwlTreeARQ( nodes );
try {
treeWalker.query( query );
} catch( RecognitionException e ) {
throw new QueryParseException( format( "%s %s", treeWalker.getErrorHeader( e ),
treeWalker.getErrorMessage( e, parser.getTokenNames() ) ), e.line,
e.charPositionInLine );
}
return query;
}