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

📄 parser.cup

📁 数据仓库展示程序
💻 CUP
📖 第 1 页 / 共 4 页
字号:
    |   keyword
    ;


identifier ::=
        unquoted_identifier
    |   quoted_identifier
    ;

// a keyword (unlike a reserved word) can be converted back into an
// identifier in some contexts
keyword ::=
        DIMENSION {:
            RESULT = "Dimension";
        :}
    |   PROPERTIES {:
            RESULT = "Properties";
        :}
    ;

compound_id ::=
        identifier:i {:
            RESULT = new Id(i);
        :}
    |   compound_id:hd DOT identifier:tl {:
            RESULT = hd.append(tl, false);
        :}

    ;

//
// <regular_identifier> ::= <alpha_char> [{<alpha_char> | <digit>
//                                       | <underscore>}...]
//
// <delimited_identifier> ::=
//      <start_delimiter>{<double_end_delimiter> | <nondelimit_end_symbol>}
//           [{<double_end_delimiter> | <nondelimit_end_symbol> }...]
//      <end_delimiter>
//
// <start_delimiter> ::= <open_bracket>
//
// <end_delimiter> ::= <close_bracket>
//
// <double_end_delimiter> ::= <end_delimiter> end_delimiter>
//
// <nondelimit_end_symbol> ::= !! <any_character_except_delimit_end_symbol>
//
// <cube_name> ::= [ [ [ <data_source>] <catalog_name>] [<schema_name>].]
//                 <identifier>
cube_name ::= compound_id ;
//
// <data_source> ::= <identifier>
//
// <catalog_name> ::= <identifier>
//
// <schema_name> ::= <identifier>
//
// <dim_hier> ::= [<cube_name>.]<dimension_name>
//             | [[<cube_name>.]< dimension_name>.]<hierarchy_name>
// jhyde: Need more lookahead for this to work... just use id in place of dim_hier.
//   dim_hier ::= id;
//
// <dimension_name> ::= <identifier>
//                    | <member>.DIMENSION
//                    | <level>.DIMENSION
//                    | <hierarchy>.DIMENSION
//
// <hierarchy_name> ::= <identifier>
//                    | < member>.HIERARCHY
//                    | <level>.HIERARCHY
//
// <level> ::= [<dim_hier>.]< identifier>
//            | <dim_hier>.LEVELS(<index>)
//            | <member>.LEVEL
//
// Note: The first production is for the case when named levels are
// supported. The second production is for the case when named levels are not
// supported.
//
//
// <member> ::= [<level>.]<identifier>
//             | <dim_hier>.<identifier>
//             | <member>.<identifier>
//             | <member_value_expression>
//
// Note: The <member>.<identifier> recognizes the fact that members may
// sometimes need to be qualified by their parent names. For example,
// "Portland" is a city in Oregon, and also in Maine. So a reference to
// Portland will be either Oregon.Portland or Maine.Portland.
//
//
// <property> ::= <mandatory_property> | <user_defined_property>
//
// <mandatory_property> ::= CATALOG_NAME
//                        | SCHEMA_NAME
//                        | CUBE_NAME
//                        | DIMENSION_UNIQUE_NAME
//                        | HIERARCHY_UNIQUE_NAME
//                        | LEVEL_UNIQUE_NAME
//                        | LEVEL_NUMBER
//                        | MEMBER_UNIQUE_NAME
//                        | MEMBER_NAME
//                        | MEMBER_TYPE
//                        | MEMBER_GUID
//                        | MEMBER_CAPTION
//                        | MEMBER_ORDINAL
//                        | CHILDREN_CARDINALITY
//                        | PARENT_LEVEL
//                        | PARENT_UNIQUE_NAME
//                        | PARENT_COUNT
//                        | DESCRIPTION
//
// <user_defined_property> ::= <dim_hier>.<identifier>
//                           | <level>.<identifier>
//                           | <member>.<identifier>
//
// Note: The three productions recognize the fact that a property can apply to
// all the members of a dimension, or all the members of a level, or just to a
// member.
//
//
// <tuple> ::= <member>
//          | (<member> [, <member>...])
//          | <tuple_value_expression>
//
// Note: Each member must be from a different dimension or from a different
// hierarchy.
//
//
// <set> ::= <member>:<member>
//
// Note: Each member must be from the same hierarchy and the same level.
//
//
//         | <set_value_expression>
//         | <open_brace>[<set>|<tuple> [, <set>|<tuple>...]]<close_brace>
//
// Note: Duplicates (if any) are always retained when specifying sets in this
// fashion.
//
//
//         | (<set>)
//
// <open_brace> ::= {
//
// <close_brace> ::= }
//
// <open_bracket> ::= [
//
// <close_bracket> ::= ]
//
// <underscore> ::= _
//
// <alpha_char> ::= a | b | c | ...| z | A | B | C | ... | Z
//
// <digit> ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
//
// Leveling Rules for Elements
//
// The ability to qualify a cube name by one or more of <data_source>,
// <catalog_name>, or <schema_name> is optional. Consumers can check the value
// of the property MDPROP_MDX_OBJQUALIFICATION to see whether a provider
// supports cube qualification.
//
//
// The ability to qualify a dimension name by a cube name is
// optional. Consumers can check the value of the property
// MDPROP_MDX_OBJQUALIFICATION to see whether a provider supports dimension
// qualification.
//
//
// The ability to qualify a hierarchy name by a dimension name or by cube name
// and dimension name is optional. Consumers can check the value of the
// property MDPROP_MDX_OBJQUALIFICATION to see whether a provider supports
// hierarchy qualification.
//
//
// The provider need support only one of the two productions for <level>. If it
// supports
//
// <level> ::= [<dim_hier>.] <identifier>
//
// then the ability to qualify by <dim_hier> is optional.
//
// Consumers can check the value of the property MDPROP_NAMED_LEVELS to see if
// the provider supports named levels. If it does, then the consumer can check
// MDPROP_MDX_OBJQUALIFICATION to see whether named levels can be qualified by
// <dim_hier>.
//
// The ability to qualify a member by a level, a member, or <dim_hier> is
// optional. Consumers can check the value of the property
// MDPROP_MDX_OBJQUALIFICATION to see whether a provider supports member
// qualification.
//
// Note: Several leveling rules above make it optional to qualify
// multidimensional schema object names. However, this does not imply that the
// ability to generate unique names for members, levels, dimensions, and
// hierarchies is optional. Providers are required to furnish unique names in
// the schema rowsets for these objects. If providers generate unique names by
// means other than qualification, then the ability to qualify is optional. For
// more information, see 'Provider Implementation Considerations for Unique
// Names' in Chapter 2.
//
//

// ----------------------------------------------------------------------------
//
//
// Expressions
//
// Note: The syntax of <value_expression> is generally the same as SQL-92,
// subclause 6.11, <value_expression>. Differences are:
//
// <tuple>[.VALUE], <property>[.VALUE], and <conditional_expression> are new
// values for <value_expression_primary>.
//
//
// There are new values for <numeric_value_function>, mainly for statistical
// analysis.
//
//
// The BNF for <value_expression_primary>, <character_string_literal>, and
// <string_value_expression> have been shortened by eliminating several
// intermediate nonterminals.
//
// <value_expression> ::= <numeric_value_expression>
//                      | <string_value_expression>
//
// <numeric_value_expression> ::= <term>
//                    | <numeric_value_expression> {<plus> | <minus>} <term>
value_expression ::=
        term5
    |   value_expression:x OR term5:y {:
            RESULT = new FunCall("OR", Syntax.Infix, new Exp[] {x, y});
        :}
    |   value_expression:x XOR term5:y {:
            RESULT = new FunCall("XOR", Syntax.Infix, new Exp[] {x, y});
        :}
    ;

term5 ::=
        term4
    |   term5:x AND term4:y {:
            RESULT = new FunCall("AND", Syntax.Infix, new Exp[] {x, y});
        :}
    ;

term4 ::=
        term3
    |   NOT term4:p {:
            RESULT = new FunCall("NOT", Syntax.Prefix, new Exp[] {p});
        :}
    ;

term3 ::=
        term2
    |   term3:p IS NULL {:
            RESULT = new FunCall("IS NULL", Syntax.Property, new Exp[] {p});
        :}
    |   term3:x comp_op:op term2:y {: // e.g. 1 < 5
            RESULT = new FunCall(op, Syntax.Infix, new Exp[] {x, y});
        :}
    ;

term2 ::=
        term
    |   term2:x PLUS term:y {:
            RESULT = new FunCall("+", Syntax.Infix, new Exp[] {x, y});
        :}
    |   term2:x MINUS term:y {:
            RESULT = new FunCall("-", Syntax.Infix, new Exp[] {x, y});
        :}
    |   term2:x CONCAT term:y {:
            RESULT = new FunCall("||", Syntax.Infix, new Exp[] {x, y});
        :}
    ;

//
// <term> ::= <factor> | <term> {<asterisk> | <solidus>} <factor>
term ::=
        factor
    |   term:x ASTERISK factor:y {:
            RESULT = new FunCall("*", Syntax.Infix, new Exp[] {x, y});
        :}
    |   term:x SOLIDUS factor:y {:
            RESULT = new FunCall("/", Syntax.Infix, new Exp[] {x, y});
        :}
    ;
//
// <factor> ::= [<sign>] <numeric_primary>
//
factor ::=
        value_expression_primary
    |   PLUS value_expression_primary:p {:
            RESULT = p;
        :}
    |   MINUS value_expression_primary:p {:
            RESULT = new FunCall("-", Syntax.Prefix, new Exp[] {p});
        :}
    ;
// <sign> ::= + | -
//
// <plus> ::= +
//
// <minus> ::= -
//
// <asterisk>::= *
//
// <solidus> ::= /
//
// <numeric_primary> ::= <value_expression_primary>
//                     | <numeric_value_function>
//
// Note: The data type of <value_expression_primary> in the above production
// shall be numeric.
//
//
// <value_expression_primary> ::= <unsigned_numeric_literal>
//                             | (<value_expression>)
//                             |  <character_string_literal>
//                             | [<cube_name>.]<tuple>[.VALUE]
//                             |  <property>[.VALUE]
//                             |  <conditional_expression>
value_expression_primary ::=
        STRING:s {:
            RESULT = Literal.createString(s);
        :}
    |   NUMBER:d {:
            RESULT = Literal.create(d);
        :}
    |   identifier:i {:
            RESULT = new Id(i);
        :}
    |   value_expression_primary:i DOT unquoted_identifier:j {:
            if (i instanceof Id && !parser.isFunCall(j)) {
                RESULT = ((Id) i).append(j, false);
            } else {
                RESULT = new FunCall(j, Syntax.Property, new Exp[] {i});
            }
        :}
    |   value_expression_primary:i DOT quoted_identifier:j {:
            if (i instanceof Id) {
                RESULT = ((Id) i).append(j, false);
            } else {
                RESULT = new FunCall(
                    j, Syntax.QuotedProperty, new Exp[] {i});
            }
        :}
    |   value_expression_primary:i DOT amp_quoted_identifier:j {:
            if (i instanceof Id) {
                RESULT = ((Id) i).append(j, true);
            } else {
                RESULT = new FunCall(
                    j, Syntax.AmpersandQuotedProperty, new Exp[] {i});
            }
        :}
    |   value_expression_primary:i DOT identifier:j LPAREN exp_list_opt:lis RPAREN {:
            lis.add(0, i);
            RESULT = new FunCall(j, Syntax.Method, (Exp[]) lis.toArray(new Exp[0]));

⌨️ 快捷键说明

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