Re: [csswg-drafts] [selectors-4] Augment the grammar to unambigously encode handling of white-space? (#10940)

Yes, it is still the case that whitespace is allowed between any two tokens (or allowed to *not* be there) (except for the rare cases where some text defines specific requirements about it). It's not defined in Selectors because [it's defined in Values & Units, which defines the grammar CSS uses](https://drafts.csswg.org/css-values/#component-whitespace).

In general (unless specific text overrides), it's not that whitespace is allowed/disallowed, it's that whitespace is *ignored*; all that matters is that the tokens are parsed properly. Whitespace is a convenient way to ensure that two things *are* tokenized separately, but not the only way: `foo bar` produces two idents, but so does `foo/**/bar`, with no whitespace. Sometimes you can use neither - `foo()bar` produces a function followed by an ident, same as `foo() bar`.

Regarding parser generators, we don't optimize for that. If it's clearer to read and write to put a condition in the surrounding text rather than in the grammar, we're happy to do that instead. But a parser generator would have to be optimized for CSS anyway (due to its specific tokenization rules, and its whitespace rules), and you'd have to manually handle the few cases where whitespace is required or disallowed.

-- 
GitHub Notification of comment by tabatkins
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/10940#issuecomment-2371827087 using your GitHub account


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

Received on Tuesday, 24 September 2024 16:52:29 UTC