W3C home > Mailing lists > Public > public-css-archive@w3.org > August 2021

Re: [csswg-drafts] [css-values] Automatic parsing of value definitions (#2921)

From: Tab Atkins Jr. via GitHub <sysbot+gh@w3.org>
Date: Wed, 18 Aug 2021 15:39:39 +0000
To: public-css-archive@w3.org
Message-ID: <issue_comment.created-901219411-1629301177-sysbot+gh@w3.org>
> but for example `<dimension>` and `<rounding-strategy>`,

`<dimension>` is *necessarily* a prose definition; there's too many things that could potentially resolve to a `<dimension>` to be reasonably listed in an explicit grammar.

`<rounding-strategy>` is kinda in prose, but it's also got definition metadata identifying its components - any `<dfn data-dfn-type=value data-dfn-for="<some-nonterminal>">one</dfn>` is an arm of an implicit `<some-nonterminal> = one | two | three` grammar. Adding an explicit grammar-production block would not improve the readability of that section, so hopefully reffy can infer grammar from dfns when necessary instead.

> are [shorthand] properties the only properties that have no initial value?

Yes. (Tho possibly logicals with physical equivalents also have this.)

> does the value not applicable (initial value comes from physical property) for the properties background-position-block and background-position-inline correspond to auto?

Unclear. The logicals probably are the same as shorthands, and don't have an initial value at all; this isn't consistent between css-logical and css-backgrounds currently.

> The component values ​​are often identical to the tokens that result from tokenization, which makes me think that the terminal CSS types could be defined with the corresponding type of tokens: <dimension-token>, <percentage-token>, etc...

No, they can't be - there are often many ways to produce a particular terminal value that are not just the literal tokens. For example, `calc(1%)` is a `<percentage>`, but is definitely not a `<percentage-token>`. The token productions should almost never be used in ordinary specs; they only deserve mention when you're discussing very low-level details of CSS, such as the definition of "dimension".

> I remember that I read a property or type definition before, that defines a "greedy" parsing behavior. I can't remember which one, but perhaps the following issue is not a an issue at all. If so please forgive me.

You may have heard that CSS *tokenization* is greedy, which is true (for example, `1px` is guaranteed to parse as a dimension, not as a number followed by an ident). But parsing is definitely non-greedy.

(Technically "greedy" doesn't apply to tokenization, because it's specified with an algorithm rather than as a grammar. But the algo is designed to implement "longest-match" greedy semantics for a theoretical equivalent grammar, because that's the semantics that CSS2 had when it *did* specify tokenization with a grammar.)

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


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Wednesday, 18 August 2021 15:39:41 UTC

This archive was generated by hypermail 2.4.0 : Tuesday, 19 October 2021 01:31:48 UTC