W3C home > Mailing lists > Public > www-style@w3.org > January 2013

Re: [css3-syntax] Parser "entry points"

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Sun, 27 Jan 2013 22:38:10 -0800
Message-ID: <CAAWBYDAXczrD8yc1tUv-DPwrnt1iFQU0fJaWzS11AiT1OyswXg@mail.gmail.com>
To: Simon Sapin <simon.sapin@kozea.fr>
Cc: www-style list <www-style@w3.org>
On Sun, Jan 27, 2013 at 8:36 AM, Simon Sapin <simon.sapin@kozea.fr> wrote:
> I count four different cases where the Syntax module would be needed:
>
> 1. Parsing a whole stylesheet
> 2. Parsing a style attribute
> 3. Parsing a single declaration (part of a @support condition)
> 4. Parsing any stand-alone "unit" that does not have error recovery:
> selectors (for selector APIs), media queries (media attribute), conditions
> or property values (for CSS.supports()), etc.
>
> Did I miss any?

Just one, as far as I can tell - we also need to parse a single full
rule of any kind (style or at-rule), for the CSSStyleSheet#insertRule
method.

> Stylesheets start in top-level mode and are otherwise already taken care of
> by the draft.
>
> A style attribute is like a declaration block where a top-level } token does
> not terminate the block but is treated like a ] token (that is: make the
> current declaration invalid and make the parser skip until the next ; token
> or EOF.) Start in declaration-block mode, and these sections need to be
> adjusted:
>
> * 3.5.7. Declaration-block mode
> * 3.5.9. Declaration-value mode
> * 3.5.11. Declaration-end mode

Hrm, okay.  My plan was to just start the parser at a particular
state, and end it when the rule got popped or the current declaration
was appended or unset, but I guess I do have to explicitly change the
parser for a few states.

I wonder if impls would be okay with changing behavior to end the rule
after } and ignore anything that comes after?  That would simplify the
parser slightly. ^_^

> Similarly, for a single declaration, a ; token does not end the declaration.

What do you mean by "does not end the declaration"?  It looks like
top-level ; tokens aren't allowed in @supports conditions, and I don't
see how they'd be allowed anywhere else that wants to take a single
decl in the future.  I'd prefer to just say that it's a syntax error
if the decl is appended or unset before the token stream is fully
consumed.

> !important is taken care of by saying that such a "can not be made
> important".

Yes.

> Finally, anything that does not have error recovery is the same with respect
> to the Syntax module. It needs a new mode that repeatedly "consumes a
> primitive" until EOF, and maybe fails at the first non-preserved token.
> Parsing these primitives further is up to other modules.

Can you explain what you mean by this in more detail?

~TJ
Received on Monday, 28 January 2013 06:38:58 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:21:04 GMT