Re: [csswg-drafts] [css-nesting-1] Can we relax the syntax further? (#7961)

I think the infinite-lookahead parsing rules should be:

* If the first token is an ident, then:
  * If it's a dashed-ident, followed by any amount of whitespace, followed by a colon: it's a custom property.
  * If it's followed by any amount of whitespace and a colon, then look forward until you see either a semicolon (it's a property) or a {}-block (it's a rule).
  * Otherwise, it's a rule.
* Otherwise, it's a rule.

This gives us infinite lookahead, with arbitrary mixing of properties and selectors, with only *three* compromises:

1. Non-custom properties can never contain top-level {}-blocks. (They can put them in strings, or in functions, or in parens, whatever. Just not at the top.)
2. Selectors can never contain top-level semicolons. (Ditto.)
3. Nested selectors can't start with a type selector that's a dashed-ident (that is, start with a --) followed by a pseudo-class. If you have a markup language that allows this (HTML doesn't), you still have to wrap it in an `:is()` or whatever. (But any other combo works - `--foo.bar` is just fine.)

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


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

Received on Wednesday, 18 January 2023 16:31:33 UTC