Skip to content

Commit

Permalink
MONDRIAN: Oops, forgot one file.
Browse files Browse the repository at this point in the history
[git-p4: depot-paths = "//open/mondrian-release/3.2/": change = 13995]
  • Loading branch information
julianhyde committed Dec 17, 2010
1 parent 8e1ee6d commit 874ba94
Showing 1 changed file with 52 additions and 39 deletions.
91 changes: 52 additions & 39 deletions src/main/mondrian/olap/Parser.cup
Expand Up @@ -15,41 +15,48 @@
*/

import java_cup.runtime.*;

import java.util.*;
import java.math.BigDecimal;

import mondrian.resource.MondrianResource;
import mondrian.mdx.*;
import mondrian.parser.MdxParserValidator;

// Preliminaries to set up and use the scanner.
// action code {: ... :};
parser code {:
// Generated from $Id$
private Scanner scanner;
private String queryString;
private Connection mdxConnection;
Connection mdxConnection;
private FunTable funTable;
private boolean strictValidation;
boolean strictValidation;
MdxParserValidator.QueryPartFactory factory;

/**
* Recursively parses an expression.
*/
Exp recursivelyParseExp(String s)
{
return new Parser().parseExpression(
mdxConnection, s, false, funTable);
factory, mdxConnection, s, false, funTable);
}

/**
* Parses a string to create a {@link Query}.
* Called only by {@link ConnectionBase#parseQuery}.
*/
QueryPart parseInternal(
public QueryPart parseInternal(
MdxParserValidator.QueryPartFactory factory,
Connection mdxConnection,
String queryString,
boolean debug,
FunTable funTable,
boolean strictValidation)
{
Symbol parse_tree;
this.factory = factory;
this.scanner = new StringScanner(queryString, debug);
this.mdxConnection = mdxConnection;
this.queryString = queryString;
Expand Down Expand Up @@ -78,12 +85,14 @@ parser code {:
* Parses a string to create an {@link Exp}.
* Called only by {@link ConnectionBase#parseExpression}.
*/
Exp parseExpression(
public Exp parseExpression(
MdxParserValidator.QueryPartFactory factory,
Connection mdxConnection,
String queryString,
boolean debug,
FunTable funTable)
{
this.factory = factory;
Symbol parse_tree = null;
this.scanner = new PrefixScanner(
debug,
Expand Down Expand Up @@ -143,36 +152,38 @@ parser code {:
}
}

/**
* Creates a {@link Query} object.
* Override this function to make your kind of query.
*/
protected Query makeQuery(
Formula[] formulae, QueryAxis[] axes,
String cube, Exp slicer, QueryPart[] cellProps)
public static class FactoryImpl
implements MdxParserValidator.QueryPartFactory
{
final QueryAxis slicerAxis =
slicer == null
? null
: new QueryAxis(
false, slicer, AxisOrdinal.StandardAxisOrdinal.SLICER,
QueryAxis.SubtotalVisibility.Undefined, new Id[0]);
return new Query(
mdxConnection, formulae, axes, cube, slicerAxis, cellProps,
strictValidation);
}
public Query makeQuery(
Connection connection,
Formula[] formulae,
QueryAxis[] axes,
String cube,
Exp slicer,
QueryPart[] cellProps,
boolean strictValidation)
{
final QueryAxis slicerAxis =
slicer == null
? null
: new QueryAxis(
false, slicer, AxisOrdinal.StandardAxisOrdinal.SLICER,
QueryAxis.SubtotalVisibility.Undefined, new Id[0]);
return new Query(
connection, formulae, axes, cube, slicerAxis, cellProps,
strictValidation);
}

/**
* Creates a {@link DrillThrough} object.
*/
protected DrillThrough makeDrillThrough(
Query query,
int maxRowCount,
int firstRowOrdinal,
List<Exp> returnList)
{
return new DrillThrough(
query, maxRowCount, firstRowOrdinal, returnList);
public DrillThrough makeDrillThrough(
Query query,
int maxRowCount,
int firstRowOrdinal,
List<Exp> returnList)
{
return new DrillThrough(
query, maxRowCount, firstRowOrdinal, returnList);
}
}

// Override lr_parser methods for NLS. With this error handling scheme,
Expand Down Expand Up @@ -362,7 +373,7 @@ terminal
SOLIDUS; // /

// c. Typed terminals
terminal Double NUMBER;
terminal BigDecimal NUMBER;
terminal String ID;
terminal String QUOTED_ID;
terminal String AMP_QUOTED_ID;
Expand Down Expand Up @@ -451,7 +462,7 @@ non terminal List
non terminal Exp[]
when_clause;

non terminal Double
non terminal BigDecimal
axis_number;

non terminal Number
Expand Down Expand Up @@ -1364,12 +1375,14 @@ select_statement ::=
// We want 'Sales', not '[Sales]', and can't handle 'Schema.Sales'
// yet.
String cubeName = c.getElement(0).name;
RESULT = parser.makeQuery(
RESULT = parser.factory.makeQuery(
parser.mdxConnection,
Parser.toFormulaArray(f),
Parser.toQueryAxisArray(a),
cubeName,
w,
Parser.toQueryPartArray(cp));
Parser.toQueryPartArray(cp),
parser.strictValidation);
:};

with_formula_specification_opt ::=
Expand Down Expand Up @@ -1529,7 +1542,7 @@ axis_specification ::=
:}
| non_empty_opt:b expression:s dim_props_opt:dp ON axis_number:n {:
double d = n.doubleValue();
int index = (int)d;
int index = n.intValue();

// AxisOrdinal values go from -2 to 4 for standard axis, but higher
// ordinals are allowed. The negative values represent
Expand Down Expand Up @@ -1662,7 +1675,7 @@ cell_property ::= compound_id;
drillthrough_statement ::=
DRILLTHROUGH maxrows_opt:m firstrowset_opt:f select_statement:s
return_opt:r {:
RESULT = parser.makeDrillThrough(
RESULT = parser.factory.makeDrillThrough(
s,
m == null ? 0 : m.intValue(),
f == null ? 0 : f.intValue(),
Expand Down

0 comments on commit 874ba94

Please sign in to comment.