class Query {

    public static Tree compileTree(final String query) throws AttributeExpressionLanguageParsingException {
        try {
            final CommonTokenStream lexerTokenStream = createTokenStream(query);
            final AttributeExpressionParser parser = new AttributeExpressionParser(lexerTokenStream);
            final Tree ast = (Tree) parser.query().getTree();
            final Tree tree = ast.getChild(0);

            // ensure that we are able to build the evaluators, so that we validate syntax
            final Evaluator<?> evaluator = buildEvaluator(tree);
            verifyMappingEvaluatorReduced(evaluator);
            return tree;
        } catch (final AttributeExpressionLanguageParsingException e) {
            throw e;
        } catch (final Exception e) {
            throw new AttributeExpressionLanguageParsingException(e);
        }
    }

    private  Query(final String query, final Tree tree, final Evaluator<?> evaluator);

}