- From: Guillaume via GitHub <sysbot+gh@w3.org>
- Date: Wed, 25 Sep 2024 12:16:43 +0000
- To: public-css-archive@w3.org
I think spec authors write production rules to be human-friendly, and they welcome rewrites, as long as they preserve that aspect.
For example, this could have been written with:
```
<attribute-selector> = '[' <attr-name> <attr-value-comparison>? ']'
<attr-name> = <wq-name>
<attr-value-comparison>? = <attr-matcher> <attr-value> <attr-modifier>?
<attr-value> = <string-token> | <ident-token>
```
From my experience, some production rules are even worse for the performance of a CSS parser consuming them:
```
<legacy-rgb-syntax> = rgb( <percentage>#{3} , <alpha-value>? ) |
rgb( <number>#{3} , <alpha-value>? )
```
If it were written with `rgb( [... | ...], <alpha-value>? )`, a parser could abort parsing the declaration value if it finds a function whose name is `rgb` but the result from parsing its value is a failure: the declaration value is guaranteed to be invalid. In property values like `background`, in which `<color>` has many sibling productions, this is very unfortunate.
--
GitHub Notification of comment by cdoublev
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/10944#issuecomment-2373922290 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 12:16:44 UTC