Skip to content

Grammar – Consistency & Cleanup 3 #1318

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 1, 2025

Conversation

Nigel-Ecma
Copy link
Contributor

[Continues on from #1291 Grammar – Consistency & Cleanup 2]

This PR makes to small minor changes to the grammar, first it removes the unnecessary type_arguments, changing:

    type_argument_list
        : '<' type_arguments '>'
        ;
    
    type_arguments
        : type_argument (',' type_argument)*
        ;

to the more direct:

    type_argument_list
        : '<' type_argument (',' type_argument)* '>'
        ;

Second it moves the optional trailing comma on attribute into the list, changing:

    global_attribute_section
        : '[' global_attribute_target_specifier attribute_list ']'
        | '[' global_attribute_target_specifier attribute_list ',' ']'
        ;
    
    attribute_section
        : '[' attribute_target_specifier? attribute_list ']'
        | '[' attribute_target_specifier? attribute_list ',' ']'
        ;
    
    attribute_list
        : attribute (',' attribute)*

to the simpler:

    global_attribute_section
        : '[' global_attribute_target_specifier attribute_list ']'
        ;
    
    attribute_section
        : '[' attribute_target_specifier? attribute_list ']'
        ;
    
    attribute_list
        : attribute (',' attribute)* ','?

This has the advantage that the trailing comma is now part of the list and not a level
above, and simplifies the first two by removing the overlapping alternatives.

No text changes are required to support these grammar improvements.

This PR also updates the grammar checker framework to v2.3.2, which includes an improved
implementation of C#’s semantic rules for declaration_expression. For the details see its repo.

Review Notes:

You only need to consider the changes to the *.md files in standard; the other files are machine-generated updates to parsing test samples describing the new expected parse for some samples. If you wish to see visualisations of the changes you may download the changed *.svg files in the PR and the current versions of them in draft-v8 and view them side-by-side (multiple monitors helps!)

- Inline type_arguments into type_argument_list
- Tidy global_attribute_section, attribute_section & attribute_list
- Merge in updated samples & tarball
  - Includes updated declaration_expression predicate
@Nigel-Ecma Nigel-Ecma self-assigned this Apr 30, 2025
Copy link
Member

@BillWagner BillWagner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again @Nigel-Ecma

I like the progress. This looks great.

Copy link
Contributor

@jskeet jskeet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, looks good to me.

@BillWagner
Copy link
Member

Merging this so @Nigel-Ecma can continue with grammar updates.

@BillWagner BillWagner merged commit da5900d into dotnet:draft-v8 May 1, 2025
7 checks passed
@Nigel-Ecma Nigel-Ecma deleted the deep_to_wide_3 branch May 16, 2025 02:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants