-
Notifications
You must be signed in to change notification settings - Fork 661
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[css-selectors-4] Include whitespace in non-optional <combinator>
#7027
Comments
I don't understand the problem, what makes you think that whitespaces are required?
Also note:
|
Yeah, I'm not certain what issue you're running into exactly either. Whitespace is implicitly allowed between any two grammar productions, so it's never indicated explicitly. The prose indicates where whitespace is not allowed. Can you clarify what grammar productions, precisely, you're decomposing into when parsing |
|
...huh, I was gonna say that CSS grammars obey longest-match semantics, not ordered-match semantics, but that's not stated anywhere. I still don't think it's quite possible to indicate whitespace in the grammar (the quoted-character notation indicates delim tokens, which whitespace is not), but indicating in the prose that an "omitted" combinator must be whitespace should be fine. |
Is there a difference between obey longest-match semantics and greedy? Is it possible to obey longest-match semantics without being greedy?
I perfectly understand this and it answers my questions about the fix I need to apply on my implementation. Thanks. |
Yes, greedy means the first thing to match a segment claims that segment forever, even if it would cause the overall match to fail. Longest-match is somewhat greedy - the parse that consumes the most tokens for a production is the one that wins, even if it would cause the overall match to fail, but that isn't necessarily the "first" (it depends on how you order the productions). CSS tokenization is explicitly designed to be longest-match; it will always parse Anyway, fixed the issue here by adding an explicit prose requirement that whitespace is required if you omit the combinator. |
Thanks, I'm closing this issue then. Just so I'm sure I understood correctly, and to explain a bit better the issue than in my initial comment (9 days later I had a hard time figuring it out myself, sorry):
But because CSS matching against a grammar is implicitly defined to obey longest-match, instead of the above step 7, the parser should try with the second alternative for I feel like this is fundamental and probably missing from the spec, as well as these comments:
|
That is, to match |
No, my edit fixed this case. Combinator is optional, but if omitted the two |
Selectors 4 does not include the whitespace in the production rule for
<combinator>
:What is wrong with
<combinator> = ' ' | '>' | '+' | '~' | [ '|' '|' ]
? (whitespace between quotes)With
svg|*
as input, my current implementation for parsing this grammar result to two<compound-selector>
. I would like to know if whitespaces are actually required between tokens for applying the correct fix.https://drafts.csswg.org/css-syntax-3/#rule-defs
The text was updated successfully, but these errors were encountered: