- From: Bert Bos <bert@w3.org>
- Date: Fri, 14 Mar 2008 17:54:26 +0100
- To: W3C style mailing list <www-style@w3.org>
The expanded grammar in 11.1[1] can be improved a (tiny) bit, I think. My colleague Yves Lafon found the following problem and solution: The rule for "stylesheet" includes [S|CDO|CDC]* after "import" but "import" itself already includes an S* at the end. That means that the spaces after an @import rule are ambiguous: are they the S* of "import" or are they the [S|CDO|CDC]* of "stylesheet"? stylesheet : [ CHARSET_SYM S* STRING S* ';' ]? [S|CDO|CDC]* [ import [S|CDO|CDC]* ]* [ namespace [S|CDO|CDC]* ]* [ [ ruleset | media | page | font_face ] [S|CDO|CDC]* ]* ; import : IMPORT_SYM S* [STRING|URI] S* [ medium [ ',' S* medium]* ]? ';' S* ; The same applies to spaces at the end of "namespace", "ruleset", "page", "font_face" and "media". It doesn't matter what a parser does with the ambiguity, because the presence of those spaces has no influence on the meaning of the rules, but it's nevertheless an ambiguity that can be avoided, if only to reduce the amount of headscratching by implementers. My proposal is to replace [S|CDO|CDC]* by [[CDO|CDC] S*]* in three places: stylesheet : [ CHARSET_SYM S* STRING S* ';' ]? [S|CDO|CDC]* [ import [[CDO|CDC] S*]* ]* [ namespace [[CDO|CDC] S*]* ]* [ [ ruleset | media | page | font_face ] [[CDO|CDC] S*]* ]* ; Yacc-like parsers effectively already do it like this, because of the way they resolve conflicts automatically. Did I overlook anything? [1] http://www.w3.org/TR/2003/WD-css3-syntax-20030813/#grammar0 Bert -- Bert Bos ( W 3 C ) http://www.w3.org/ http://www.w3.org/people/bos W3C/ERCIM bert@w3.org 2004 Rt des Lucioles / BP 93 +33 (0)4 92 38 76 92 06902 Sophia Antipolis Cedex, France
Received on Friday, 14 March 2008 16:55:01 UTC