- From: andruud via GitHub <sysbot+gh@w3.org>
- Date: Thu, 30 Mar 2023 08:14:05 +0000
- To: public-css-archive@w3.org
I’ve been experimenting with parser restarts in Blink lately. Since the last round of discussions, the situation looks a bit more promising: - We initially believed that saving the tokenizer state (to later restore to that state) would be too expensive, but this turned out to be acceptable on closer investigation. - @sesse has made substantial performance improvements to the tokenizer, making a future web with more re-tokenization less scary. - We’ve removed the CachedTokenizer, which simplified the picture. Preliminary performance measurements taken using the prototype (available in Chrome Canary 114.0.5682.0, using –enable-blink-features=CSSNestingIdent) look good. What I’ve implemented isn’t _quite_ “infinite lookahead” as previously described in this issue though, but a restart, and I was hoping to get CSSWG feedback on this approach: - First, try to parse as a declaration. If that succeeded (i.e. resulted in a declaration), then it _was_ a declaration, otherwise: - Rewind and try again as a nested rule. If that succeeded (i.e. resulted in a style rule), then it _was_ a style rule, otherwise: - It doesn’t parse as anything, and we don’t explain what it “is”. (Error recovery works like today, by eating everything until the next semicolon). Combined with the previously suggested restrictions of (1) “selectors can’t contain top-level semicolons”, and (2) “declarations can’t contain top-level curly braces, except for custom properties” (or some weaker but sufficient variant of that), I’m hoping this restart method will do what we want for css-nesting, but also allow for reasonable syntax development in the future. What do you think? -- GitHub Notification of comment by andruud Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/7961#issuecomment-1489883575 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Thursday, 30 March 2023 08:14:07 UTC