Package org.exist.xquery.parser

Examples of org.exist.xquery.parser.XQueryTreeParser


           
            // TODO(pkaminsk2): why replicate XQuery.compile here?
           
            final XQueryLexer lexer = new XQueryLexer(context, new StringReader(xpath));
            final XQueryParser parser = new XQueryParser(lexer);
            final XQueryTreeParser treeParser = new XQueryTreeParser(context);
            parser.xpath();
            if (parser.foundErrors()) {
                LOG.debug(parser.getErrorMessage());
                throw new RemoteException(parser.getErrorMessage());
            }
           
            final AST ast = parser.getAST();
           
            final PathExpr expr = new PathExpr(context);
            treeParser.xpath(ast, expr);
            if (treeParser.foundErrors()) {
                LOG.debug(treeParser.getErrorMessage());
                throw new EXistException(treeParser.getErrorMessage());
            }
            LOG.info("query: " + ExpressionDumper.dump(expr));
            final long start = System.currentTimeMillis();
            expr.analyze(new AnalyzeContextInfo());
            final Sequence seq= expr.eval(null, null);
View Full Code Here


    }
   
      long start = System.currentTimeMillis();
        XQueryLexer lexer = new XQueryLexer(context, reader);
    XQueryParser parser = new XQueryParser(lexer);
    XQueryTreeParser treeParser = new XQueryTreeParser(context);
    try {
            if (xpointer)
                parser.xpointer();
            else
                parser.xpath();
            if (parser.foundErrors()) {
              LOG.debug(parser.getErrorMessage());
              throw new StaticXQueryException(
                parser.getErrorMessage());
            }

            AST ast = parser.getAST();
            if (ast == null)
                throw new XPathException("Unknown XQuery parser error: the parser returned an empty syntax tree.");

            PathExpr expr = new PathExpr(context);
            if (xpointer)
                treeParser.xpointer(ast, expr);
            else
                treeParser.xpath(ast, expr);
            if (treeParser.foundErrors()) {
                throw new StaticXQueryException(
                treeParser.getErrorMessage(),
                treeParser.getLastException());
            }

            expr.analyze(new AnalyzeContextInfo(context));

//            if (context.optimizationsEnabled()) {
View Full Code Here

        context.declareVariable(entry.getKey().toString(), entry.getValue());
      }
      // TODO(pkaminsk2): why replicate XQuery.compile here?
      final XQueryLexer lexer = new XQueryLexer(context, new StringReader(select));
      final XQueryParser parser = new XQueryParser(lexer);
      final XQueryTreeParser treeParser = new XQueryTreeParser(context);
      parser.xpath();
      if (parser.foundErrors()) {
        throw new SAXException(parser.getErrorMessage());
      }

      final AST ast = parser.getAST();
     
      if (LOG.isDebugEnabled())
        {LOG.debug("generated AST: " + ast.toStringTree());}

      final PathExpr expr = new PathExpr(context);
      treeParser.xpath(ast, expr);
      if (treeParser.foundErrors()) {
        throw new SAXException(treeParser.getErrorMessage());
      }
      expr.analyze(new AnalyzeContextInfo());
      final Sequence seq = expr.eval(null, null);
      return seq;
    } catch (final RecognitionException e) {
View Full Code Here

        try {
            broker = pool.get(user);
            final XQueryContext context = new XQueryContext(pool, accessCtx);
            final XQueryLexer lexer = new XQueryLexer(context, new StringReader(sortExpr));
            final XQueryParser parser = new XQueryParser(lexer);
            final XQueryTreeParser treeParser = new XQueryTreeParser(context);
            parser.xpath();
            if (parser.foundErrors()) {
                //TODO : error ?
                LOG.debug(parser.getErrorMessage());
            }
            final AST ast = parser.getAST();
            LOG.debug("generated AST: " + ast.toStringTree());
            expr = new PathExpr(context);
            treeParser.xpath(ast, expr);
            if (treeParser.foundErrors()) {
                LOG.debug(treeParser.getErrorMessage());
            }
            expr.analyze(new AnalyzeContextInfo());
            for (final SequenceIterator i = other.iterate(); i.hasNext();) {
                final NodeProxy p = (NodeProxy) i.nextItem();
                final IteratorItem item = new IteratorItem(broker, p, expr, docs, context);
View Full Code Here

       */
     
      final long start = System.currentTimeMillis();
        final XQueryLexer lexer = new XQueryLexer(context, reader);
        final XQueryParser parser = new XQueryParser(lexer);
        final XQueryTreeParser treeParser = new XQueryTreeParser(context);
        try {
            if(xpointer) {
                parser.xpointer();
            } else {
                parser.xpath();
            }
           
            if(parser.foundErrors()) {
              LOG.debug(parser.getErrorMessage());
              throw new StaticXQueryException(parser.getErrorMessage());
            }

            final AST ast = parser.getAST();
            if(ast == null) {
                throw new XPathException("Unknown XQuery parser error: the parser returned an empty syntax tree.");
            }
           
//            LOG.debug("Generated AST: " + ast.toStringTree());
            final PathExpr expr = new PathExpr(context);
            if(xpointer) {
                treeParser.xpointer(ast, expr);
            } else {
                treeParser.xpath(ast, expr);
            }
           
            if(treeParser.foundErrors()) {
                //AST treeAst = treeParser.getAST();
                throw new StaticXQueryException(ast.getLine(), ast.getColumn(), treeParser.getErrorMessage(), treeParser.getLastException());
            }
           
            context.getRootContext().resolveForwardReferences();
            context.analyzeAndOptimizeIfModulesChanged(expr);

View Full Code Here

      pContext.setModuleLoadPath(args[1].getStringValue());
    }
    final XQueryLexer lexer = new XQueryLexer(pContext, new StringReader(expr));
    final XQueryParser parser = new XQueryParser(lexer);
    // shares the context of the outer expression
    final XQueryTreeParser astParser = new XQueryTreeParser(pContext);
    try {
        parser.xpath();
      if(parser.foundErrors()) {
        logger.debug(parser.getErrorMessage());
        throw new XPathException(this, "error found while executing expression: " +
          parser.getErrorMessage());
      }
      final AST ast = parser.getAST();
     
      final PathExpr path = new PathExpr(pContext);
      astParser.xpath(ast, path);
      if(astParser.foundErrors()) {
        throw astParser.getLastException();
      }
      path.analyze(new AnalyzeContextInfo());
    } catch (final RecognitionException e) {     
      error = e.toString();
    } catch (final TokenStreamException e) {
View Full Code Here

      try {
              // parse the query into the internal syntax tree
        XQueryContext context = new XQueryContext(broker.getBrokerPool(), AccessContext.TEST);
        XQueryLexer lexer = new XQueryLexer(context, new StringReader(query));
        XQueryParser xparser = new XQueryParser(lexer);
        XQueryTreeParser treeParser = new XQueryTreeParser(context);
        xparser.xpath();
        if (xparser.foundErrors()) {
          System.err.println(xparser.getErrorMessage());
          return;
        }
 
        AST ast = xparser.getAST();
        System.out.println("generated AST: " + ast.toStringTree());
 
        PathExpr expr = new PathExpr(context);
        treeParser.xpath(ast, expr);
        if (treeParser.foundErrors()) {
          System.err.println(treeParser.getErrorMessage());
          return;
        }
        expr.analyze(new AnalyzeContextInfo());
        // execute the query
        Sequence result = expr.eval(null, null);
View Full Code Here

TOP

Related Classes of org.exist.xquery.parser.XQueryTreeParser

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.