1.5 Rule Inlining pointer_type

Starting with the first intermediate result of non_array_type, we turn non_array_type into

non_array_type
    :   (type_name
        |    simple_type
        |    enum_type
        |    class_type
        |    interface_type
        |    delegate_type
        |    type_parameter
        |    pointer_type
        ) (rank_specifier | INTERR)*
    ;

After inlining and simplifying we arrive at

pointer_type
    :    type_name (rank_specifier | INTERR)* STAR
    |    simple_type (rank_specifier | INTERR)* STAR
    |    enum_type (rank_specifier | INTERR)* STAR
    |    class_type (rank_specifier | INTERR)* STAR
    |    interface_type (rank_specifier | INTERR)* STAR
    |    delegate_type (rank_specifier | INTERR)* STAR
    |    type_parameter (rank_specifier | INTERR)* STAR
    |    pointer_type (rank_specifier | INTERR)* STAR
    |    VOID STAR
    ;

This can be turned into

pointer_type
    :   (type_name
        |    simple_type
        |    enum_type
        |    class_type
        |    interface_type
        |    delegate_type
        |    type_parameter
        |    VOID
        ) (rank_specifier | INTERR | STAR)* STAR
    ;

Note that I moved the STAR to the end to allow additional transformations, but in this form there can be rank_specifier and INTERR between VOID and the first STAR. This is alleviated by

pointer_type
@init {
    bool allowAll = true;
}
    :   (type_name
        |    simple_type
        |    enum_type
        |    class_type
        |    interface_type
        |    delegate_type
        |    type_parameter
        |    VOID {allowAll = false;}
        ) ({allowAll}?=> rank_specifier \|{allowAll}?=> INTERR | STAR {allowAll = true;})* STAR
    ;

Sections

My siblings (including me):