Issues with CSS21 grammar (CR 20070719)

Dear CSSers,

Here are some issues with the current grammar, as defined by
http://www.w3.org/TR/CSS21/grammar.html dated 20070719,
amended by the errata at
http://www.w3.org/Style/css2-updates/CR-CSS21-20070719-errata.html)

I/ Collision in "import" definition.

stylesheet
   : [ CHARSET_SYM STRING ';' ]?
     [S|CDO|CDC]* [ import [S|CDO|CDC]* ]*
     [ [ ruleset | media | page ] [S|CDO|CDC]* ]*

import
   : IMPORT_SYM S*
     [STRING|URI] S* [ medium [ COMMA S* medium]* ]? ';' S*

The final S* of the import rule collides with the S in [ import [S|CDO|CDC]* ]*
The issue might be solved in two ways:

1/ In the 'stylesheet' rule:
   [ import [S|CDO|CDC]* ]*
   =>
   [ import [[CDO|CDC] [S|CDO|CDC]*]? ]*

2/ In the 'import' rule:
   [STRING|URI] S* [ medium [ COMMA S* medium]* ]? ';' S*
   =>
   [STRING|URI] S* [ medium [ COMMA S* medium]* ]? ';'

II / Collision in stylesheet and ruleset/media/page
Same issue, the final S* of 'ruleset' 'media' and 'page' conflicts with
[S|CDO|CDC]*
To solve this one, the same two ways are possible:

1/ In the 'stylesheet' rule
   [ [ ruleset | media | page ] [S|CDO|CDC]* ]*
   =>
   [ [ ruleset | media | page ] [[CDO|CDC] [S|CDO|CDC]]?* ]*

2/ In the 'media' rule
   MEDIA_SYM S* medium [ COMMA S* medium ]* LBRACE S* ruleset* '}' S*
   =>
   MEDIA_SYM S* medium [ COMMA S* medium ]* LBRACE S* ruleset* S* '}'

   In the 'page' rule
   LBRACE S* declaration [ ';' S* declaration ]* '}' S*
   =>
   LBRACE S* declaration [ ';' S* declaration ]* '}'

   In the 'ruleset' rule
   LBRACE S* declaration [ ';' S* declaration ]* '}' S*
   =>
   LBRACE S* declaration [ ';' S* declaration ]* '}'

III / Error in the 'page' rule

   PAGE_SYM S* pseudo_page? S*
is problematic when pseudo_page is not present.
The following soles that issue.
   PAGE_SYM S* (pseudo_page S*)?

IV / Error in the 'pseudo' rule

Same as in III/

':' [ IDENT | FUNCTION S* IDENT? S* ')' ]
should read
':' [ IDENT | FUNCTION S* (IDENT S*)? ')' ]

V / empty tokens
To avoid empty tokens in the grammar, here are the proposed changes:
1/ in "operator"
'/' S* | COMMA S* | /* empty */
=>
'/' S* | COMMA S*
or even [ '/' | COMMA ] S*
(Note, COMMA includes {w}, which is not the case for '/'. Same comment in
  the definition of 'unary_operator')

in "expr"
term [ operator term ]*
=>
term [ operator? term ]*

2/ in "declaration"
  property ':' S* expr prio?
   | /* empty */
=>
  property ':' S* expr prio?

in "page"
LBRACE S* declaration [ ';' S* declaration ]* '}' S*
=>
LBRACE S* declaration? [ ';' S* declaration? ]* '}' S*

in "ruleset"
LBRACE S* declaration [ ';' S* declaration ]* '}' S*
=>
LBRACE S* declaration? [ ';' S* declaration? ]* '}' S*

(note that in 'page' and 'ruleset' the final S* might be dropped, 
depending on the resolution of the issue II above).

Cheers,

-- 
Baroula que barouleras, au tiéu toujou t'entourneras.

         ~~Yves

Received on Friday, 20 February 2009 14:10:31 UTC