Dashboard > ANTLR 3 > ... > 2. Example > 2.1 Rule Inlining primary_no_array_creation_expression
  ANTLR 3 Log In | Sign Up   View a printable version of the current page.  
  2.1 Rule Inlining primary_no_array_creation_expression
Added by Johannes Luber, last edited by Johannes Luber on May 02, 2008  (view change)
Labels: 
(None)

Inlining primary_expression leads to in-factoring at every other rule. The inlining of the other rules is straight-forward and gives us

primary_no_array_creation_expression
    :    literal
    |    simple_name
    |    parenthesized_expression
    |    array_creation_expression DOT IDENTIFIER type_argument_list?
    |    primary_no_array_creation_expression DOT IDENTIFIER type_argument_list?
    |    predefined_type DOT IDENTIFIER type_argument_list?
    |    qualified_alias_member DOT IDENTIFIER type_argument_list?
    |    array_creation_expression OPEN_PARENS argument_list? CLOSE_PARENS
    |    primary_no_array_creation_expression OPEN_PARENS argument_list? CLOSE_PARENS
    |    primary_no_array_creation_expression OPEN_BRACKET expression_list CLOSE_BRACKET
    |    this_access
    |    base_access
    |    array_creation_expression OP_INC
    |    primary_no_array_creation_expression OP_INC
    |    array_creation_expression OP_DEC
    |    primary_no_array_creation_expression OP_DEC
    |    object_creation_expression
    |    delegate_creation_expression
    |    anonymous_object_creation_expression
    |    typeof_expression
    |    checked_expression
    |    unchecked_expression
    |    default_value_expression
    |    anonymous_method_expression
    |    sizeof_expression
    |    array_creation_expression OP_PTR IDENTIFIER
    |    primary_no_array_creation_expression OP_PTR IDENTIFIER
    |    primary_no_array_creation_expression OPEN_BRACKET expression CLOSE_BRACKET
    ;

After SLRR we get

primary_no_array_creation_expression
    :   (literal
        |    simple_name
        |    predefined_type DOT IDENTIFIER type_argument_list?
        |    qualified_alias_member DOT IDENTIFIER type_argument_list?
        |    this_access
        |    base_access
        |    array_creation_expression OPEN_PARENS argument_list? CLOSE_PARENS
        |    array_creation_expression DOT IDENTIFIER type_argument_list?
        |    array_creation_expression OP_INC
        |    array_creation_expression OP_DEC
        |    array_creation_expression OP_PTR IDENTIFIER
        |    object_creation_expression
        |    delegate_creation_expression
        |    anonymous_object_creation_expression
        |    parenthesized_expression
        |    typeof_expression
        |    sizeof_expression
        |    default_value_expression
        |    anonymous_method_expression
        |    checked_expression
        |    unchecked_expression
        )   (DOT IDENTIFIER type_argument_list?
            |    OPEN_PARENS argument_list? CLOSE_PARENS
            |    OP_INC
            |    OP_DEC
            |    OP_PTR IDENTIFIER
            |    OPEN_BRACKET (expression_list | expression) CLOSE_BRACKET
            )*
    ;

Since this doesn't show any prospect of an ability to simplify, so we go on with the next rule.

Sections

My siblings (including me):

Site powered by a free Open Source Project / Non-profit License (more) of Confluence - the Enterprise wiki.
Learn more or evaluate Confluence for your organisation.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.1 Build:#806 May 06, 2007) - Bug/feature request - Contact Administrators