Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

Firstly, we can do SLRR and simplification with primary_no_array_creation_expression:

Code Block
primary_no_array_creation_expression
    :   (literal
        |    simple_name
        |    parenthesized_expression
        |    member_access
        |    invocation_expression
        |    this_access
        |    base_access
        |    post_increment_expression
        |    post_decrement_expression
        |    object_creation_expression
        |    delegate_creation_expression
        |    anonymous_object_creation_expression
        |    typeof_expression
        |    checked_expression
        |    unchecked_expression
        |    default_value_expression
        |    anonymous_method_expression
        |    sizeof_expression
        |    primary_expression OP_PTR IDENTIFIER
        ) (OPEN_BRACKET (expression_list | expression) CLOSE_BRACKET)*
    ;

...

This point seems to be problematic. primary_expression is actually SLR. But due to the parentheses ANTLR considers them MLR. In-factoring is the only and somewhat ugly solution to allow SLRR:

...

The only simplification which preserves the equivalence without checking for validity would be the out-factoring of "(OPEN_BRACKET (expression_list | expression) CLOSE_BRACKET)*", but as I use a second pass for my compiler a further simplification can be done.

The first move is to pretend the line "array_creation_expression (OPEN_BRACKET (expression_list | expression) CLOSE_BRACKET)*" and out-factor the inner trailing. Thus the outer trailing can be turn into:

...

Child pages (Children Display)
pageANTLR3:2. Example