selector grammer

Hi,
while examining why the rule 
{ font-size:12pt } 
is not valid I made the following observations (I found this rule at webreview.com where
they rate it as an error if a browser does not support it (see http://www.webreview.com/style/css2/charts/selectors.shtml)).
The w3c grammer states
simple_selector:
: element_name? [ HASH | class | attrib | pseudo ]* S*
;
by which it should be valid and equivalent to: 
* { font-size:12pt }
We find an additional semantic constraint in the spec at "5.3 universal selector" where is says
"If the universal selector is not the only component of a simple selector, the "*" may be omitted"
Since this is a grammatical issue they could have written:
simple_selector:
: element_name [ HASH | class | attrib | pseudo ]* S*
| [ HASH | class | attrib | pseudo ]+ S*
;
By the original grammer even the following should be valid
#myid#anotherid { font-size:12pt }
Under "5.9 ID selectors" I can't find enything prohibiting this construction apart from the fact
that the rule will never be matched. 
I just had a look at the validators grammer which is :
simple_selector:
: element_name [ HASH | class | attrib | pseudo ]*
| HASH [ class | attrib | pseudo ]*
| class [ HASH | class | attrib | pseudo ]*
| attrib [ HASH | class | attrib | pseudo ]*
| pseudo [ HASH | class | attrib | pseudo ]*
;
By this grammer 
#myid#anotherid { font-size:12pt } 
is invalid while
:first-child#myid#anotherid { font-size:12pt }
or
H1#myid#anotherid { font-size:12pt }
are grammatically valid.
For the second cases apparently an additional semantic check is performed yielding an error message saying that #myid and #anotherid are not "compatible".
How about this alternative?
simple_selector:
: element_name nonhash_selector_list() HASH opt_nonhash_selector_list()
| element_name opt_nonhash_selector_list()
| element_name HASH opt_nonhash_selector_list()
| nonhash_selector_list() HASH opt_nonhash_selector_list()
| nonhash_selector_list()
| HASH opt_nonhash_selector_list()
nonhash_selector_list:
(class()|attrib()|pseudo())+
opt_nonhash_selector_list:
(class()|attrib()|pseudo())*
This version compiles without complaints with bison. It 1) prevents the empty universal selector
and 2) ensures that only one HASH is contained in the selector.

______________________________________________________________________________
Schneller als andere! Die Blitz-SMS von WEB.DE FreeMail!
http://freemail.web.de/features/?mc=021167

Received on Monday, 20 January 2003 18:22:33 UTC