- From: Romain Menke via GitHub <sysbot+gh@w3.org>
- Date: Sun, 04 Dec 2022 21:33:03 +0000
- To: public-design-tokens-log@w3.org
> In the case of 3, it seems pretty straightforward to split the string on the first non-numeric character, resulting in the value and unit. What about : ``` 123e3px ``` Is that : - value : 123 - unit : e3px or - value : 123000 - unit : px ---- > The parser will need to use a regular expression to handle these cases, but it seems computationally cheap. To me, it's a good tradeoff for the better ergonomics of writing/editing. A parser is not a regular expression. This is also not about computation overhead. This is about simplicity. The stated goal is to be an interchange format between entire eco systems of tools. Tools which today do not work well together. Inventing new micro syntaxes requires much more work to implement this. ---- Having implemented multiple tokenizers and parsers I can tell you that the hand wavy list of rules above are completely insufficient for the purpose of extracting values from strings. A good reference to get a feel for the complexity involved is the CSS syntax specification. Specifically the sections on tokenization and consuming numeric and string tokens : https://www.w3.org/TR/css-syntax-3/#tokenizer-algorithms ------ All this complexity can be avoided by splitting units and numeric values in two fields in the JSON structure. -- GitHub Notification of comment by romainmenke Please view or discuss this issue at https://github.com/design-tokens/community-group/issues/121#issuecomment-1336522678 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Sunday, 4 December 2022 21:33:05 UTC