Skip to content

[selectors] Why would this particular grammar production not be "optimized"? #10944

@amn

Description

@amn

Looking at the <attribute-selector> production in the Selectors 4 (draft) grammar:

<attribute-selector> = '[' <wq-name> ']' |
    '[' <wq-name> <attr-matcher> [ <string-token> | <ident-token> ] <attr-modifier>? ']'

I wonder, out of mere curiosity, why not express the production with the following alternative:

<attribute-selector> = '[' <wq-name> [ <attr-matcher> [ <string-token> | <ident-token> ] <attr-modifier>? ]? ']'

Is there some significance to specifically defining the production with the former rule, or was it happenstance? I understand that swapping a grammar rule even with [what appears to be] an equivalent rule, has implications of its own, but like I said I'm just curious if this incidence (and possible others like it) is by-design? It's possible it is written the way it is written for better expressing to the reader the fact they're two different attribute selector syntaxes? It didn't have that effect on me, I must say, on the contrary.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions