📄 parser.cup
字号:
// <numeric_value_function> ::=
// AGGREGATE(<set> [, <numeric_value_expression>])
// | AVG(<set>[, <numeric_value_expression>])
// | CORRELATION(<set> [, <numeric_value_expression>]
// [, <numeric_value_expression>])
// | COVARIANCE(<set>[, <numeric_value_expression>
// [, <numeric_value_expression>])
// | COUNT(<set>[, INCLUDEEMPTY])
// | LINREGINTERCEPT(<set>[, <numeric_value_expression>
//
//
// Leveling Rules for Numeric Value Function
//
// The following numeric functions are optional: MEDIAN, VAR, STDEV, RANK,
// AGGREGATE, COVARIANCE, CORRELATION, LINREGSLOPE, LINREGVARIANCE, LINREGR2,
// LINREGPOINT. Consumers can check the value of the property
// MDPROP_MDX_NUMERIC_FUNCTIONS to see whether a provider supports this
// feature.
//
// ----------------------------------------------------------------------------
// MDX Statement
//
// <MDX_statement> ::= <select_statement>
// | <create_formula_statement>
// | <drop_formula_statement>
//
// <select_statement> ::= [WITH <formula_specification>]
// SELECT [<axis_specification>
// [, <axis_specification>...]]
// FROM [<cube_specification>]
// WHERE [<slicer_specification>]
// [<cell_props>]
// jhyde: The above is wrong... you can omit 'WHERE'.
statement ::=
select_statement
| _VALUE_EXPRESSION value_expression:e {: RESULT = (QueryPart) e; :}
;
select_statement ::=
with_formula_specification_opt:f
SELECT axis_specification_list_opt:a
FROM cube_specification:c
where_clause_opt:w
cell_props_opt:cp {:
Parser parser = (Parser) CUP$Parser$parser;
// We want 'Sales', not '[Sales]', and can't handle 'Schema.Sales'
// yet.
String cubeName = c.getElement(0);
RESULT = parser.makeQuery(
(Formula[]) f.toArray(new Formula[0]),
(QueryAxis[]) a.toArray(new QueryAxis[0]),
cubeName,
w,
(QueryPart[]) cp.toArray(new QueryPart[0]));
:};
with_formula_specification_opt ::=
/* empty */ {:
RESULT = new ArrayList();
:}
| WITH formula_specification:f {:
RESULT = f;
:}
;
axis_specification_list_opt ::=
/* empty */ {:
RESULT = new ArrayList();
:}
| axis_specification_list
;
axis_specification_list ::=
axis_specification:i {:
RESULT = new ArrayList();
RESULT.add(i);
:}
| axis_specification:e COMMA axis_specification_list:list {:
list.add(0, e);
RESULT = list;
:}
;
where_clause_opt ::=
/* empty */
| WHERE slicer_specification:s {: RESULT = s; :};
cell_props_opt ::=
/* empty */ {:
RESULT = new ArrayList();
:}
| cell_props;
//
// <formula_specification> ::= <single_formula_specification>
// [<single_formula_specification>...]
//
formula_specification ::=
single_formula_specification:e {:
RESULT = new ArrayList();
RESULT.add(e);
:}
| single_formula_specification:hd formula_specification:tl {:
tl.add(0,hd); RESULT = tl;
:}
;
// <single_formula_specification> ::= <member_specification>
// | <set_specification>
//
single_formula_specification ::=
member_specification
| set_specification
;
//
// <member_specification> ::= MEMBER <member_name> AS <value_expression>
// [, <solve_order_specification>]
// [, <member_property_definition>...]
member_specification ::=
MEMBER member_name:m AS QUOTE value_expression:e QUOTE
comma_member_property_def_list_opt:l {:
RESULT = new Formula(
m.toStringArray(),
e,
(MemberProperty[]) l.toArray(new MemberProperty[0]));
:}
| MEMBER member_name:m AS value_expression:e
comma_member_property_def_list_opt:l {:
RESULT = new Formula(
m.toStringArray(),
e,
(MemberProperty[]) l.toArray(new MemberProperty[0]));
:}
;
comma_member_property_def_list_opt ::=
/* empty */ {:
RESULT = new ArrayList();
:}
| COMMA member_property_def_list:l {:
RESULT = l;
:}
;
member_property_def_list ::=
member_property_definition:m {:
RESULT = new ArrayList();
RESULT.add(m);
:}
| member_property_definition:hd COMMA member_property_def_list:tl {:
RESULT = tl;
RESULT.add(0,hd);
:}
;
//
// <member_name> ::= <member>.<identifier>
// | <cube_name>.<member>.<identifier>
//
member_name ::= compound_id;
//
// Note:
//
// The identifier defines a new member. The qualification member has enough
// information to specify the dimension, and the level in the dimension that
// this new member should be on.
//
//
// If <member_name> is part of a member specification that appears in a create
// formula statement or is part of a drop formula statement, then it must be
// qualified by a cube name, as in the second production above.
//
// <solve_order_specification> ::= SOLVE_ORDER = <unsigned_integer>
//
// <member_property_definition> ::= <identifier> = <value_expression>
member_property_definition ::=
identifier:id EQ value_expression:e {:
RESULT = new MemberProperty(id, e);
:}
;
//
// Note: Since the property definition appears in the context of a member
// definition, there is enough information to associate the identifier (which
// is the property name) in the above production with a member.
//
//
// <set_specification> ::= SET <set_name> AS <set>
set_specification ::=
SET set_name:s AS QUOTE expression:e QUOTE {:
RESULT = new Formula(s.toStringArray(), e);
:}
| SET set_name:s AS expression:e {:
RESULT = new Formula(s.toStringArray(), e);
:}
;
//
// <set_name> ::= <identifier> | <cube_name>.<identifier>
set_name ::= compound_id ;
//
// Note: If <set_name> is part of a set specification that appears in a create
// formula statement or is part of a drop formula statement, then it must be
// qualified by a cube name, as in the second production above.
//
//
// <axis_specification> ::= [NON EMPTY] <set> [<dim_props>] ON <axis_name>
axis_specification ::=
non_empty_opt:b expression:s dim_props_opt ON axis_name:a {:
AxisOrdinal axis = AxisOrdinal.get(a.toUpperCase());
RESULT = new QueryAxis(b.booleanValue(), s, axis,
QueryAxis.SubtotalVisibility.Undefined);
:}
| non_empty_opt:b expression:s dim_props_opt ON axis_number:n {:
double d = n.doubleValue();
int index = (int)d;
// AxisOrdinal values go from -2 to 4. The negative values represent
// special cases, so are ignored.
if (index < 0 || index != d || index > AxisOrdinal.MaxOrdinal) {
throw MondrianResource.instance().InvalidAxis.ex(
new Integer(AxisOrdinal.MaxOrdinal), new Double(d));
}
AxisOrdinal axis = AxisOrdinal.get(index);
RESULT = new QueryAxis(b.booleanValue(), s, axis,
QueryAxis.SubtotalVisibility.Undefined);
:}
;
non_empty_opt ::=
/* empty */ {: RESULT = new Boolean(false); :}
| NON EMPTY {: RESULT = new Boolean(true); :}
;
dim_props_opt ::=
/* empty */
| dim_props
;
//
// <axis_name> ::= COLUMNS
// | ROWS
// | PAGES
// | CHAPTERS
// | SECTIONS
// | AXIS(<index>)
axis_name ::= identifier;
axis_number ::=
NUMBER
| AXIS LPAREN NUMBER:n RPAREN {: RESULT = n; :}
;
//
// <dim_props> ::= [DIMENSION] PROPERTIES <property> [, <property>...]
dim_props ::=
dimension_opt PROPERTIES property_list
;
dimension_opt ::=
/* empty */
| DIMENSION
;
property_list ::=
property
| property COMMA property_list
;
property ::=
compound_id
;
//
// <cube_specification> ::= [<cube_name>] [, <cube_name>]
// jhyde: In this implementation, you must supply EXACTLY one cube.
cube_specification ::=
cube_name;
//
// <slicer_specification> ::= {<set> | <tuple>}
slicer_specification ::=
expression;
//
// <cell_props> ::= [CELL] PROPERTIES <cell_property> [, <cell_property>...]
cell_props ::=
cell_opt PROPERTIES cell_property_list
;
cell_opt ::=
/* empty */
| CELL
;
cell_property_list ::=
cell_property
| cell_property COMMA cell_property_list
;
//
// <cell_property> ::= <mandatory_cell_property>
// | <optional_cell_property>
// | <provider_specific_cell_property>
cell_property ::=
mandatory_cell_property
| optional_cell_property
| provider_specific_cell_property
;
//
// <mandatory_cell_property> ::= CELL_ORDINAL | VALUE | FORMATTED_VALUE
//
// <optional_cell_property> ::= FORMAT_STRING
// | FORE_COLOR
// | BACK_COLOR
// | FONT_NAME
// | FONT_SIZE
// | FONT_FLAGS
//
// <provider_specific_cell_property> ::= <identifier>
provider_specific_cell_property ::= identifier;
//
// <create_formula_statement> ::= CREATE [<scope>]<formula_specification>
//
// <drop_formula_statement> ::= <drop_member_statement>
// | <drop_set_statement>
//
// <drop_member_statement> ::= DROP MEMBER <member_name>
// [, <member_name>...]
//
// <drop_set_statement> ::= DROP SET <set_name> [, <set_name>...]
//
// <scope> := GLOBAL | SESSION
//
// Leveling Rules for MDX Statement
//
// Support for <formula_specification> is optional. Consumers can check the
// value of the property MDPROP_MDX_FORMULAS to see whether a provider supports
// this feature.
//
//
// Support for <set> in <slicer_specification> is optional. Consumers can check
// the value of the property MDPROP_MDX_SLICER to see whether a provider
// supports this feature.
//
//
// Support for more than one cube name in <cube_specification> is
// optional. Support for having no cube name in the FROM clause (that is, the
// cube is implicitly defined by the axis and slicer dimensions) is also
// optional. Consumers can check the value of the property MDPROP_MDX_JOINCUBES
// to see whether a provider supports this feature.
//
//
// The axis names CHAPTERS and SECTIONS are optional. Consumers can check the
// value of the property MDPROP_AXES to see whether a provider supports this
// feature.
//
//
// Support for <index> > 2 in the AXIS(<index>) function is optional. Consumers
// can check the value of the property MDPROP_AXES to see whether a provider
// supports this feature.
//
//
// Support for <create_formula_statement> is optional. Consumers can check the
// value of the property MDPROP_MDX_FORMULAS to see whether a provider supports
// this feature.
//
//
// Support for <scope> of GLOBAL is optional. Consumers can check the value of
// the property MDPROP_MDX_FORMULAS to see whether a provider supports this
// feature.
//
// End Parser.cup
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -