Package com.clarkparsia.sparqlowl.parser.antlr

Examples of com.clarkparsia.sparqlowl.parser.antlr.SparqlOwlParser


    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;
  }
View Full Code Here


    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;
  }
View Full Code Here

  public static void main(String[] args) throws IOException, RecognitionException {
    SparqlOwlLexer lexer = new SparqlOwlLexer( new ANTLRReaderStream( new InputStreamReader(
        System.in ) ) );
    CommonTokenStream tokenStream = new CommonTokenStream( lexer );
    SparqlOwlParser parser = new SparqlOwlParser( tokenStream );
    SparqlOwlParser.query_return result = parser.query();
    Tree t = (Tree) result.getTree();
    System.out.println( t.toStringTree() );
  }
View Full Code Here

  public static void main(String[] args) throws IOException, RecognitionException {
    SparqlOwlLexer lexer = new SparqlOwlLexer( new ANTLRReaderStream( new InputStreamReader(
        System.in ) ) );
    CommonTokenStream tokenStream = new CommonTokenStream( lexer );
    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 );
    }
    CommonTree t = (CommonTree) result.getTree();

    CommonTreeNodeStream nodes = new CommonTreeNodeStream( t );
    nodes.setTokenStream( tokenStream );
View Full Code Here

TOP

Related Classes of com.clarkparsia.sparqlowl.parser.antlr.SparqlOwlParser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.