W3C home > Mailing lists > Public > www-style@w3.org > April 2008

Re: [CSS 2.1] General at-blocks and error recovery

From: Bert Bos <bert@w3.org>
Date: Wed, 9 Apr 2008 19:18:08 +0200
To: "www-style@w3.org" <www-style@w3.org>
Message-Id: <200804091918.09364.bert@w3.org>

On Sunday 27 January 2008 05:20, Justin Rogers wrote:
> An at-block is defined as an @ symbol followed by a valid identifier.
> When you see an at-rule you don't know, you eat until you see a
> semi-colon or your process the next block whichever comes first. That
> is definitely clear. It would then mean for a parser/tokenizer
> implementation something like the following:
>
> @import == (known symbol TOK_ATIMPORT)
> @foo == (unknown but valid TOK_ATWELLFORMED)
> @ == (hum, something is wrong, no valid character TOK_UNKNOWN
> perhaps)

It's called a DELIM.

> @1 == (another bad one, this is kind of like @{name}, could 
> be TOK_UNKNOWN followed by some series of additional tokens which are
> semantically invalid during the error recovery).

DELIM + NUMBER.

>
> The rules for recovering in a style sheet when you have an unknown
> token are to eat the next block. This means if you had the following
> CSS:
>
> @1;
> DIV { color: green; }

The "@" and "1" look like like the start of a selector (and hence of a 
rule set), but the ";" is not legal in a selector.

So we are in a case that will never be valid, in no future version of 
CSS, and the parsing rules don't completely deal with such non-CSS 
inputs. But it seems reasonable to expect that by the time the parser 
reaches the ";" it has already decided that it is looking at a rule set 
and thus we may apply section 4.1.7.

And that section says that the selector should be considered to consist 
of everything up to the next "{" (implying that the illegal ";" is also 
part of the selector for this purpose). But because it is an illegal 
selector, the UA must ignore both the selector and the next block.



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, 9 April 2008 17:19:16 GMT

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