001 /*
002 // $Id: MdxParser.java 229 2009-05-08 19:11:29Z jhyde $
003 // This software is subject to the terms of the Eclipse Public License v1.0
004 // Agreement, available at the following URL:
005 // http://www.eclipse.org/legal/epl-v10.html.
006 // Copyright (C) 2006-2008 Julian Hyde
007 // All Rights Reserved.
008 // You must accept the terms of that agreement to use this software.
009 */
010 package org.olap4j.mdx.parser;
011
012 import org.olap4j.mdx.SelectNode;
013 import org.olap4j.mdx.ParseTreeNode;
014
015 /**
016 * Parser for the MDX query language.
017 *
018 * <p>A parser is reusable but not reentrant: you can call {@link #parseSelect}
019 * and {@link #parseExpression} several times, but not at the same time
020 * from different threads.
021 *
022 * @see MdxParserFactory
023 *
024 * @author jhyde
025 * @version $Id: MdxParser.java 229 2009-05-08 19:11:29Z jhyde $
026 * @since Aug 22, 2006
027 */
028 public interface MdxParser {
029 /**
030 * Parses an MDX Select statement and returns the {@link SelectNode} at the
031 * root of the parse tree.
032 *
033 * <p>In order to be parsed successfully, the expression must be
034 * syntactically correct but does not need to be valid. (Syntactic
035 * correctness and validity are described further in the description of
036 * {@link #parseExpression(String)}.)
037 *
038 * @param mdx MDX query string
039 * @return Parse tree
040 */
041 SelectNode parseSelect(String mdx);
042
043 /**
044 * Parses an MDX expression and returns a parse tree.
045 *
046 * <p>An expression is a combination of operators and operands, which can
047 * occur in many places inside an MDX query, such as the definition of a
048 * calculated member or an axis.
049 *
050 * <p>In order to be parsed successfully, the expression must be
051 * syntactically correct but does not need to be valid.
052 * For example,
053 *
054 * <blockquote><code>(1 + (2 + 3)</code></blockquote>
055 *
056 * is syntactically incorrect,
057 * because there are more open parentheses "(" than close parentheses ")",
058 * and the parser will give an error. Conversely,
059 *
060 * <blockquote><code>(1 + [Measures].[Bad Measure])</code></blockquote>
061 *
062 * is syntactically correct, and the parser
063 * will successfully create a parse tree, even if
064 * <code>[Measures].[Bad Measure]</code> does not exist.
065 *
066 * @param mdx MDX expression
067 * @return Parse tree
068 */
069 ParseTreeNode parseExpression(String mdx);
070 }
071
072 // End MdxParser.java