⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 parser.cup

📁 数据仓库展示程序
💻 CUP
📖 第 1 页 / 共 4 页
字号:
        :}
    |   identifier:i LPAREN exp_list_opt:lis RPAREN {:
            RESULT = new FunCall(
                i, Syntax.Function, (Exp[]) lis.toArray(new Exp[0]));
        :}
    |   LPAREN exp_list:lis RPAREN {:
            // Whereas ([Sales],[Time]) and () are tuples, ([Sales]) and (5)
            // are just expressions.
            RESULT = new FunCall(
                "()", Syntax.Parentheses, (Exp[]) lis.toArray(new Exp[0]));
        :}
    |   LBRACE exp_list_opt:lis RBRACE {: // set built from sets/tuples
            RESULT = new FunCall(
                "{}", Syntax.Braces, (Exp[]) lis.toArray(new Exp[0]));
        :}
    |   case_expression
    ;

case_expression ::=
        CASE value_expression_opt:x
        when_list:y
        else_clause_opt:z
        END {:
            ArrayList v = new ArrayList();
            if (x != null) {
                v.add(x);
            }
            for (int i = 0; i < y.size(); i++) {
                Exp[] exps = (Exp[]) y.get(i);
                Util.assertTrue(exps.length == 2);
                v.add(exps[0]);
                v.add(exps[1]);
            }
            if (z != null) {
                v.add(z);
            }
            if (x == null) {
                RESULT = new FunCall(
                    "_CaseTest", Syntax.Case, (Exp[]) v.toArray(new Exp[0]));
            } else {
                RESULT = new FunCall(
                    "_CaseMatch", Syntax.Case, (Exp[]) v.toArray(new Exp[0]));
            }
        :}
    ;

value_expression_opt ::=
        /* empty */
    |   value_expression
    ;

when_list ::=
        /* empty */ {:
            RESULT = new ArrayList();
        :}
    |   when_list:x when_clause:y {:
            RESULT = x; x.add(y);
        :}
    ;

when_clause ::=
        WHEN value_expression:x THEN value_expression:y {:
            RESULT = new Exp[] {x,y};
        :}
    ;

else_clause_opt ::=
        /* empty */
    |   ELSE value_expression:x {:
            RESULT = x;
        :}
    ;

//
// <conditional_expression> ::= <if_expression> | <case_expression>
//
// <if_expression> ::= iif(<search_condition>, <true_part>, <false_part>)
//
// <true_part> ::= <value_expression>
//
// <false_part> ::= <value_expression>
//
// <case_expression> ::= <simple_case> | <searched_case> | <coalesce_empty>
//
// <simple_case> ::= CASE <case_operand>
//                      <simple_when_clause>...
//                     [<else_clause>]
//                   END
//
// <searched_case> ::= CASE
//                        <searched_when_clause>...
//                       [<else_clause>]
//                     END
//
// <simple_when_clause> ::= WHEN <when_operand> THEN <result>
//
// <searched_when_clause> ::= WHEN <search_condition> THEN <result>
//
// <else_clause> ::= ELSE <value_expression>
//
// <case_operand> ::= <value_expression>
//
// <when_operand> ::= <value_expression>
//
// <result> ::= <value_expression>
//
// <coalesce_empty> ::= COALESCEEMPTY (<value_expression>
//                                  {, <value_expression> }...)
//
// <signed_numeric_literal> ::= [<sign>]<unsigned_numeric_literal>
//
// <unsigned_numeric_literal> ::= <exact_numeric_literal>
//                              | <approximate_numeric_literal>
//
// <exact_numeric_literal> ::= <unsigned_integer>[.<unsigned_integer>]
//                           | <unsigned_integer>.
//                           | .<unsigned_integer>
//
// <unsigned_integer> ::= {<digit>}...
//
// <approximate_numeric_literal> ::= <mantissa>E<exponent>
//
// <mantissa> ::= < exact_numeric_literal>
//
// <exponent> ::= [<sign>]<unsigned_integer>
//
// <string_value_expression> ::= <value_expression_primary>
//                             | <string_value_expression>
//                               <concatenation_operator>
//                               <value_expression_primary>
//
// Note: The data type of <value_expression_primary> in the above production
// shall be a character string.
//
//
// <character_string_literal> ::= <quote>[<character_representation>...]
//                               <quote>
//
// <character_representation> ::= <nonquote_character> | <quote_symbol>
//
// <nonquote_character> ::= !!
//                     <any_character_in_the_character_set_other_than_quote>
//
// <quote_symbol> ::= <quote> <quote>
//
// <quote>  ::= '
//
// <concatenation_operator> ::= ||
//
// Leveling Rules for Expressions
//
// The following productions for <value_expression_primary> are optional:
//
// The ability to qualify <tuple>[.VALUE] by <cube_name> in a value expression
// primary is optional. Consumers can check the value of the property
// MDPROP_MDX_OUTERREFERENCE to see whether a provider supports this feature.
//
//
// <property>[.VALUE]. Consumers can check the value of the property
// MDPROP_MDX_QUERYBYPROPERTY to see whether a provider supports this feature.
//
//
// <simple_case>, <searched_case>. Consumers can check the value of the
// property MDPROP_MDX_CASESUPPORT to see whether a provider supports this
// feature.
//

// ----------------------------------------------------------------------------
// Search Condition
//
// <search_condition> ::= <boolean_term>
//                      | <search_condition> {OR | XOR} <boolean_term>
//
// <boolean_term> ::= <boolean_factor> | <boolean_term> AND <boolean_factor>
//
// <boolean_factor> ::= [NOT] <boolean_primary>
//
// <boolean_primary> ::= <value_expression> <comp_op> <value_expression>
//                     | ISEMPTY(<value_expression>)
//                     | (<search_condition>)
// <comp_op> ::= <equals_operator>
//             | <not_equals_operator>
//             | <less_than_operator>
//             | <greater_than_operator>
//             | <less_than_or_equals_operator>
//             | <greater_than_or_equals_operator>
comp_op ::=
        EQ {: RESULT = "="; :}
    |   NE {: RESULT = "<>"; :}
    |   LT {: RESULT = "<"; :}
    |   GT {: RESULT = ">"; :}
    |   LE {: RESULT = "<="; :}
    |   GE {: RESULT = ">="; :}
    |   IS {: RESULT = "IS"; :}
    ;
//
// <equals_operator> ::= =
//
// <not_equals_operator> ::= <>
//
// <greater_than_operator> ::= >
//
// <less_than_operator> ::= <
//
// <greater_than_or_equals_operator> ::= >=
//
// <less_than_or_equals_operator> ::= <=
//
// Leveling Rules for Search Condition
//
// If <value_expression> in a <boolean_primary> value is a string value
// expression, then support for <comp_op> values other than <equals_operator>
// and <not_equals_operator> is optional. Consumers can check the value of the
// property MDPROP_MDX_STRING_COMPOP to see whether a provider supports this
// feature.

// ----------------------------------------------------------------------------
// Set Value Expression
//
// <index> ::= <numeric_value_expression>
//
// Note: <index> denotes an integer argument. If an arbitrary
// <numeric_value_expression> appears here, then it is truncated to the nearest
// integer.
//
//
// <percentage> ::= <numeric_value_expression>
//
// <set_value_expression> ::= <dim_hier>.MEMBERS
//                          | <level>.MEMBERS
//                          | <member>.CHILDREN
//                          | BOTTOMCOUNT(<set>, <index>
//                               [, <numeric_value_expression>])
//                          | BOTTOMPERCENT(<set>, <percentage>,
//                               <numeric_value_expression>)
//                          | BOTTOMSUM(<set>, <numeric_value_expression>,
//                               <numeric_value_expression>)
//                          | CROSSJOIN(<set>, <set>)
//                          | DESCENDANTS(<member>, <level> [,<desc_flags>])
//
// Note: In the absence of explicit <desc_flags> specification, SELF is the
// default.
//
//                          | DISTINCT(<set>)
//                          | DRILLDOWNLEVEL(<set> [, <level>]])
//                          | DRILLDOWNLEVELBOTTOM(<set>, <index>
//                              [,[<level>] [, <numeric_value_expression>]])
//                          | DRILLDOWNLEVELTOP(<set>, <index>[, [<level>]
//                              [, <numeric_value_expression>]])
//                          | DRILLDOWNMEMBER(<set>, <set>[, RECURSIVE])
//                          | DRILLDOWNMEMBERBOTTOM(<set>, <set>, <index>
//                             [, <numeric_value_expression>][, RECURSIVE]])
//                          | DRILLDOWNMEMBERTOP(<set>, <set>, <index>
//                            [, [<numeric_value_expression>][, RECURSIVE]])
//                          | DRILLUPLEVEL(<set>[, <level>]])
//                          | DRILLUPMEMBER(<set>, <set>)
//                          | EXCEPT(<set>, <set> [, ALL])
//                          | EXTRACT(<set>, <dim_hier>[, <dim_hier>...])
//                          | FILTER(<set>, <search_condition>)
//                          | GENERATE(<set>, <set> [, ALL])
//                          | HIERARCHIZE(<set>)
//                          | INTERSECT(<set>, <set> [, ALL])
//                          | LASTPERIODS(<index> [, <member>])
//                          | MTD([<member>])
//                          | ORDER(<set>, <value_expression>
//                              [, ASC | DESC | BASC | BDESC])
//
// Note:   In the absence of explicit specification, ASC is the default.
//
//
//                          | PERIODSTODATE([<level>[, <member>]])
//                          | QTD([<member>])
//                          | TOGGLEDRILLSTATE(<set1>, <set2>[, RECURSIVE])
//
// Note: With the exception of CROSSJOIN, all set functions that take more than
// one <set> argument require that the two set arguments have tuples of the
// same dimensionality.
//
//
//                          | TOPCOUNT(<set>, <index>
//                              [, <numeric_value_expression>])
//                          | TOPPERCENT(<set>, <percentage>,
//                              <numeric_value_expression>)
//                          | TOPSUM(<set>, <numeric_value_expression>,
//                              <numeric_value_expression>)
//                          | UNION(<set>, <set> [, ALL])
//                          | WTD([<member>])
//                          | YTD(<member>)
//
// <desc_flags> ::= SELF
//                | AFTER
//                | BEFORE
//                | BEFORE_AND_AFTER
//                | SELF_AND_AFTER
//                | SELF_AND_BEFORE
//                | SELF_BEFORE_AFTER
//

// ----------------------------------------------------------------------------
// Member Value Expression
//
// <member_value_expression> ::= <member>.{PARENT | FIRSTCHILD | LASTCHILD
//                                         | PREVMEMBER | NEXTMEMBER}
//                             | <member>.LEAD(<index>)
//                             | <member>.LAG(<index>)
//
// Note:   LAG(<index>) is the same as LEAD(-<index>)
//
//
//                             | <member>.{FIRSTSIBLING | LASTSIBLING}
//                             | <dimension>.[CURRENTMEMBER]
//                             | <dimension>.DEFAULTMEMBER
//                             | <hierarchy>.DEFAULTMEMBER
//                             | ANCESTOR(<member>, <level>)
//                             | CLOSINGPERIOD([<level>[, <member>])
//                             | COUSIN(<member>, <member>)
//                             | OPENINGPERIOD([<level>[, <member>])
//                             | PARALLELPERIOD([<level>[, <index>
//                                              [, <member>]]])
expression ::=
        expression:x COLON value_expression:y {: // range yields set
            RESULT = new FunCall(":", Syntax.Infix, new Exp[] {x, y});
        :}
    |   value_expression
    ;
exp_list_opt ::=
        /* empty */ {:
            RESULT = new ArrayList();
        :}
    |   exp_list
    ;
exp_list ::=
        expression:e {:
            RESULT = new ArrayList();
            RESULT.add(e);
        :}
    |   expression:e COMMA exp_list:list {:
            list.add(0, e); RESULT = list;
        :}
    ;
//
// Leveling Rules for Member Value Expression
//
// The following member functions are optional: COUSIN, PARALLELPERIOD,
// OPENINGPERIOD, CLOSINGPERIOD. Consumers can check the value of the property
// MDPROP_MDX_MEMBER_FUNCTIONS to see whether a provider supports this feature.
//

//
//  * Tuple Value Expression
//
// <tuple_value_expression> ::= <set>.CURRENTMEMBER
//                            | <set>[.ITEM](<string_value_expression>
//                               [, <string_value_expression>...] | <index>)
//

//
//  * Numeric Value Function
//

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -