W3C home > Mailing lists > Public > www-style@w3.org > January 2003

Fwd: selector grammer

From: Bjoern Hoehrmann <derhoermi@gmx.net>
Date: Tue, 21 Jan 2003 02:16:58 +0100
To: www-style@w3.org
Cc: alexgeller@web.de
Message-ID: <3e4b9ec0.90701171@smtp.bjoern.hoehrmann.de>

[...]
Date: Tue, 14 Jan 2003 12:32:12 -0500 (EST)
Old-Date: Tue, 14 Jan 2003 18:31:40 +0100
Message-Id: <200301141731.h0EHVeO25360@mailgate5.cinetic.de>
From: Alex Geller <alexgeller@web.de>
To: www-validator-css@w3.org
Subject: selector grammer
X-Archived-At: 
 http://www.w3.org/mid/200301141731.h0EHVeO25360@mailgate5.cinetic.de

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.
[...]
Received on Monday, 20 January 2003 20:16:41 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:54:19 GMT