[CSS 2.1] issue 24: parsing invalid syntax and matching brackets

The WG accepted the proposal[1] to change "declaration" to "statement" 
in http://www.w3.org/TR/CSS21/syndata.html#parsing-errors

   # Malformed declarations. User agents must handle unexpected tokens
   # encountered while parsing a declaration by reading until the end
   # of the declaration, while observing the rules for matching pairs
   # of (), [], {}, "", and '', and correctly handling escapes.

But after reading the resulting text (below), I think it is not right.

   # Malformed statements. User agents must handle unexpected tokens
   # encountered while parsing a statement by reading until the end
   # of the statement, while observing the rules for matching pairs
   # of (), [], {}, "", and '', and correctly handling escapes.

As the examples in 4.2 right after this paragraph show, user agents do 
*not* have to read until the end of the statement. E.g.:

    p { color:red; color:; color:green }

has a malformed declaration in the middle and should be interpreted as

    p { color:red; color:green }

There is no reason to read any further than the second ";".


I think the original issue was how to deal with parentheses in a 
malformed selector, such as

    FOO @BAR({}) {color: red}

The above is guaranteed not to be valid in any future level of CSS, so I 
don't really mind what the error recovery behavior is, but it cannot be 
the one quoted above.

[1] http://lists.w3.org/Archives/Public/www-style/2008May/0252.html



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 Wednesday, 26 November 2008 13:37:35 UTC