Re: [csswg-drafts] [Meta] Modular/distributed grammar definitions (#6744)

I did not check if this issue has been discussed at your last meeting, but I think modular/distributed grammar (value) definitions already exist with the `New values` field in some property definition tables in some delta specs, eg. the `contain` property:

- the "main" value definition in [CSS Contain 2](https://drafts.csswg.org/css-contain-2/#contain-property) is `none | strict | content | [ size || layout || style || paint ]`
- the `New values` field in [CSS Contain 3](https://drafts.csswg.org/css-contain-3/#contain-property) is `layout || style || paint || [ size | inline-size ]`

Obviously, I took this example on purpose because it seems ambiguous (at least to me). `New values` should replace what is inside `[ size || layout || style || paint ]`, isn't it? To be fair, it may be an isolated case of a wrong (but unspecified, to my knowledge) usage of this `New values` field: all other `New values` may just work fine when joined using `|` to the corresponding "main" grammar definition. 

But what if this "main" grammar definition is `a || b` and a delta spec wants to define `c` as its `New values`? It would be a hint that a "modular" grammar definition may also require `||=`, noting that there would be nothing wrong with `a || b | c` as the result from extending `a` as the "main" grammar definition, with `b | c` as its `New values`. But how do you extend a "main" grammar definition containing whitespace (or `&&`) separated tokens/productions?

The following may be another isolated issue. [CSS Sizing 4](https://drafts.csswg.org/css-sizing-4/#sizing-values) extends `inline-size` and `width` (among other properties) with `stretch | fit-content | contain` as their `New values`, and [CSS Logical 1](https://drafts.csswg.org/css-logical-1/#dimension-properties) defines `inline-size` with `<'width'>`. When processing the grammar definitions extracted by `@webref/css` from the specifications, I concatenate `New values` to the corresponding "main" value definition using `|` as the "glue" (which may be a wrong assumption, as noted above). Therefore it can result to parsing an input for `inline-size` twice against `stretch | fit-content | contain`. The value definition of `inline-size` (and some other logical properties) should not be extended with `stretch | fit-content | contain`, imo.

Finally, I think a delta spec may need to "rewrite" a grammar definition instead of extending it (while still preserving back-compatibility) for other different reasons, making the usage of a modular grammar definition inconsistent.

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


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

Received on Friday, 4 March 2022 13:42:43 UTC