XQueryParser parser = new XQueryParser(lexer, false);
XQueryParser parser = new XQueryParser(lexer);
	public CompiledExpression compile(String query) throws XMLDBException {		//LOG.debug("compiling " + query);		DBBroker broker = null;		try {			broker = brokerPool.get(user);			XQueryContext context = new XQueryContext(broker);			context.setBaseURI(properties.getProperty("base-uri", collection.getPath()));			if(moduleLoadPath != null)				context.setModuleLoadPath(moduleLoadPath);			Map.Entry entry;			// declare namespace/prefix mappings			for (Iterator i = namespaceDecls.entrySet().iterator(); i.hasNext();) {				entry = (Map.Entry) i.next();				LOG.debug("prefix " + entry.getKey() + " = " + entry.getValue());				context.declareNamespace(					(String) entry.getKey(),					(String) entry.getValue());			}			// declare static variables			for (Iterator i = variableDecls.entrySet().iterator(); i.hasNext();) {				entry = (Map.Entry) i.next();				context.declareVariable((String) entry.getKey(), entry.getValue());			}			context.setBackwardsCompatibility(xpathCompatible);			XQueryLexer lexer = new XQueryLexer(new StringReader(query));			XQueryParser parser = new XQueryParser(lexer, false);			XQueryTreeParser treeParser = new XQueryTreeParser(context);			parser.xpath();			if (parser.foundErrors()) {				LOG.debug(parser.getErrorMessage());				throw new XMLDBException(					ErrorCodes.UNKNOWN_ERROR,					parser.getErrorMessage());			}			AST ast = parser.getAST();			LOG.debug("generated AST: " + ast.toStringList());			PathExpr expr = new PathExpr(context);			treeParser.xpath(ast, expr);			if (treeParser.foundErrors()) {				throw new XMLDBException(					ErrorCodes.UNKNOWN_ERROR,					treeParser.getErrorMessage(),					treeParser.getLastException());			}			LOG.debug("compiled: " + expr.pprint());			return expr;		} catch (EXistException e) {			throw new XMLDBException(ErrorCodes.VENDOR_ERROR, e.getMessage(), e);		} catch (RecognitionException e) {			throw new XMLDBException(ErrorCodes.VENDOR_ERROR, e.getMessage(), e);		} catch (TokenStreamException e) {			throw new XMLDBException(ErrorCodes.VENDOR_ERROR, e.getMessage(), e);		} catch (XPathException e) {			throw new XMLDBException(ErrorCodes.VENDOR_ERROR, e.getMessage(), e);		} catch (IllegalArgumentException e) {			throw new XMLDBException(ErrorCodes.VENDOR_ERROR, e.getMessage(), e);		} finally {			brokerPool.release(broker);		}	}