[css3-syntax] Parser "entry points"

Hi,

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?


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

This leaves the door open for having at-rules in style attributes. (Even 
if we never do it.)


Similarly, for a single declaration, a ; token does not end the 
declaration. !important is taken care of by saying that such a "can not 
be made important".


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.


Cheers,
-- 
Simon Sapin

Received on Sunday, 27 January 2013 16:36:44 UTC