[css3-selectors] Selector grammar: ambiguity in combinator

Hi,

currently we are working on a CSS3-parser that may drive the SAC interface. 
After reading the different CSS3-modules and long internal discussions there 
remain some open questions on our side. Maybe this mailing list may help us 
resolve our questions.

The selector grammar for CSS3 [1] defines combinators (combining 
simple_selector_sequence units) as follows:

combinator
  /* combinators can be surrounded by white space */
  : S* [ '+' | '>' | '~' | /* empty */ ] S*
  ;

I assume that the "empty"-branch of the above rule should represent the 
"descendant combinator". If so, the above rule may lead to ambiguities in 
interpreting a selector.

Why?
Imagine a descendant combinator that
a) is "empty" and
b) has no surrounding space.
Its representation in a CSS selector would be really _nothing_.

Now the selector "E.warning" may be interpreted in two ways:
1. the obvious interpretation: an E element whose class is "warning"
     using the productions:
     selector ->
     simple_selector_sequence ->
     type_selector class
2. the "other" interpretation: an any element whose class is "warning" that is 
descendant of an E element ("normally" written as "E .warning")
     using the productions:
     selector ->
     simple_selector_sequence combinator simple_selector_sequence ->
     type_selector combinator class
     NOTE: the above interpretation uses the following information given in 
[2]: "If the universal selector is not the only component of a sequence of 
simple selectors, the * may be omitted."


In contrast to [1], [3] states the following: A descendant combinator is a 
white space
that separates two sequences of simple selectors. Thus, [3] avoids the 
ambiguity in interpreting a selector with an empty combinator - a combinator 
may not be empty.


Any comments on the different approaches between [1] an [3]?


Stefan

[1] <http://www.w3.org/TR/2001/CR-css3-selectors-20011113/#grammar>
[2] <http://www.w3.org/TR/2001/CR-css3-selectors-20011113/#universal-selector>
[3] 
<http://www.w3.org/TR/2001/CR-css3-selectors-20011113/#descendant-combinators>

Stefan

Received on Monday, 30 August 2004 08:28:57 UTC