Re: [css3-syntax] Consumation of comment tokens during tree construction

On Wed, Jan 23, 2013 at 4:03 AM, Peter Moulder <peter.moulder@monash.edu> wrote:
> On Wed, Jan 23, 2013 at 09:45:40AM +0100, Simon Sapin wrote:
>> As much as I dislike having to do this, shouldn’t some comment
>> tokens be preserved where the tree has "lists of primitives" so it
>> can be serialized back correctly? Namely:
>>
>> * at-rule prelude
>> * selector
>> * declaration value
>>
>> Example of pathological input:
>> border: 1px/**/solid
>
> One possible answer is that it's the job of the serializer to insert a
> comment token if asked to serialize the sequence DIMENSION IDENT, whether
> or not we strip out comment tokens.

I'm thinking of going this way.  The list of preserved tokens is small
and should rarely grow, so it's easy to plot out the handful of
problematic cases that need a comment inserted between them if there's
no whitespace.  I think it's just:

hash or at-rule followed by number, ident, dimension, or a function.
number, ident, and dimension in any combination.
number, ident, or dimension followed by a function.
ident followed by (.

Alternately, I could add an explicit clean-up step to the rules when
they're finished which inserts empty comments between those tokens, so
that serialization can continue to be dumb.


> Another possible answer might be that this spec doesn't have to care
> about serialization; is there or might there in future be a CSS spec that
> covers serialization of a CSS core grammar token stream defined in terms
> of css3-syntax, perhaps something related to CSSOM?  If the spec only
> needs to give the right parse rather than the right re-serialization,
> then this spec can omit the comment tokens.

*Something* needs to cover serialization in sufficient detail, whether
it's this or CSSOM.

~TJ

Received on Wednesday, 23 January 2013 17:08:11 UTC