- From: Zack Weinberg <zweinberg@mozilla.com>
- Date: Mon, 22 Feb 2010 23:20:52 -0800
- To: Peter Linss <peter.linss@hp.com>
- Cc: fantasai <fantasai.lists@inkedblade.net>, Chris Lilley <chris@w3.org>, "www-style@w3.org" <www-style@w3.org>, Bert Bos <bert@w3.org>
Peter Linss <peter.linss@hp.com> wrote: > >> declaration-list > >> : C* S* C* declaration? C* [ ';' C* S* C* declaration? C*]* C* > >> ; > >> > >> where C is the comment production. Is that correct? (Specifically, > >> are leading and trailing comments allowed, as well as ones between > >> tokens?) > > > > I'll leave this question to Bert, who's our resident grammar expert. > > Per CSS 2.1 ( http://www.w3.org/TR/CSS21/syndata.html#comments ) > comments can appear "anywhere between tokens". We don't put the > comment tokens anywhere in grammar specifications to keep things > simple (they do appear in the tokenizer spec however where they're > allowed inside other tokens). Having comments as the first and last > tokens should also be allowed, although on re-reading the spec, that > isn't really covered by "between tokens"... I don't think that > distinction was made intentionally. > > So yes, your grammar is correct. It maybe doesn't go far enough, because you can have an arbitrary sequence of comments and whitespace, not just comments on either side of one block of whitespace. To formalize it properly, you'd need something like CS: ( C* S* )* declaration-list: CS declaration? CS [ ';' CS declaration? CS ]* ... I think. zw
Received on Tuesday, 23 February 2010 07:21:29 UTC