Re: (Question) CSS3 parsing procedure, where does parsing Declarations go?

On Thu, Jun 25, 2015 at 8:20 PM, Hai Thanh Nguyen <phaikawl@gmail.com> wrote:
> I have a question about http://dev.w3.org/csswg/css-syntax.
> It's written in the document that inside Simple Block are declarations.
> There's actually instruction on how to parse Declarations. However it
> doesn't seem to be anywhere in the overall procedure:
> Stylesheet -> Qualified Rule -> Simple Block -> Component Values
>
> There's no path from the Stylesheet that leads to a Declaration, they just
> don't belong anywhere in the AST tree that's supposed to be parsed.
> Am I missing something? Why is it that way? Like, where am I supposed to
> call the "ParseDeclarations" function in my parser? Does it have to be
> parsed separately, away from the AST according to the standard? That's super
> weird.

Correct, there's nothing in the Syntax spec that leads *directly*
there.  This is because the CSS syntax is generic, and arbitrary
blocks can contain either declaration or qualified rules (and
at-rules, for both types.  Which parsing algo to use is determined by
context-specific grammar, not the generic CSS syntax.

In particular, top-level qualified rules are style rules, which are
defined as containing declarations.

~TJ

Received on Friday, 26 June 2015 16:10:34 UTC