[csswg-drafts] [selectors] (draft) Why is the particular grammar production not "optimized"? (#10944)

amn has just created a new issue for https://github.com/w3c/csswg-drafts:

== [selectors] (draft) Why is the particular grammar production not "optimized"? ==
Looking at [the `<attribute-selector>` production in the Selectors 4 (draft) grammar](http://drafts.csswg.org/selectors/#typedef-attribute-selector):

```
<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>? ]? ']'
```

Reading the former, I must admit the repetition has the suprising-the-reader effect on me. 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?

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/10944 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 25 September 2024 10:34:02 UTC