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

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 UTC