Skip to content

Commit 8db220f

Browse files
committed
[css3-syntax] Allowed the 'consume a primitive' subalgo to return nothing when it finds a non-preserved token.
--HG-- extra : rebase_source : f6b10d5de666649e33f92a8b84a154cae4ba1785
1 parent 61b0bd0 commit 8db220f

2 files changed

Lines changed: 177 additions & 84 deletions

File tree

css3-syntax/Overview.html

Lines changed: 75 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111

1212
<meta content="CSS Syntax Module Level 3 (CSS3 Syntax)" name=dcterms.title>
1313
<meta content=text name=dcterms.type>
14-
<meta content=2013-01-30 name=dcterms.issued>
14+
<meta content=2013-01-31 name=dcterms.issued>
1515
<meta content="http://dev.w3.org/csswg/css3-syntax/" name=dcterms.creator>
1616
<meta content=W3C name=dcterms.publisher>
17-
<meta content="http://www.w3.org/TR/2013/ED-css3-syntax-20130130/"
17+
<meta content="http://www.w3.org/TR/2013/ED-css3-syntax-20130131/"
1818
name=dcterms.identifier>
1919
<link href="#contents" rel=contents>
2020
<link href="#index" rel=index>
@@ -48,7 +48,7 @@
4848

4949
<h1>CSS Syntax Module Level 3</h1>
5050

51-
<h2 class="no-num no-toc" id=longstatus-date>Editor's Draft 30 January
51+
<h2 class="no-num no-toc" id=longstatus-date>Editor's Draft 31 January
5252
2013</h2>
5353

5454
<dl>
@@ -2745,18 +2745,11 @@ <h2 id=parsing><span class=secno>5. </span> Parsing</h2>
27452745
<dt><dfn id=preserved-tokens>preserved tokens</dfn>
27462746

27472747
<dd> The tokens that can appear in the tree are: ident, hash, string, url,
2748-
delim, number, percentage, dimension, unicode-range, whitespace, cdo,
2749-
cdc, colon, semicolon, at-keyword, ], ), and }.
2748+
delim, number, percentage, dimension, unicode-range, whitespace, colon,
2749+
semicolon, at-keyword,
27502750
<p class=note> This means that the following tokens emitted by the
27512751
tokenizer stage will <strong>not</strong> appear in the stylesheet
2752-
object: function, bad-string, bad-url, [, (, {.
2753-
2754-
<p class=issue> Currently bad-url and bad-string tokens can also appear
2755-
in the tree. Is it worth it to complexify the parser with error-handling
2756-
for this kind of thing (every call to "<a
2757-
href="#consume-a-primitive0"><i>consume a primitive</i></a>" might
2758-
fail)? Or should I just leave them alone, assume that grammar-checking
2759-
will kill them, and leave their serialization undefined?
2752+
object: function, bad-string, bad-url, cdo, cdc, [, ], (, ), {. and }.
27602753

27612754
<dt><dfn id=function>function</dfn>
27622755

@@ -2896,6 +2889,8 @@ <h4 id=top-level-mode><span class=secno>5.3.1. </span> <dfn
28962889

28972890
<dd> Do nothing. Remain in this mode.
28982891

2892+
<dt>bad-string token
2893+
28992894
<dt>at-keyword token
29002895

29012896
<dd> Create an at-rule with its name set to the value of the <a
@@ -2995,9 +2990,18 @@ <h4 id=at-rule-prelude-mode><span class=secno>5.3.2. </span> <dfn
29952990

29962991
<dt>anything else
29972992

2998-
<dd> <a href="#consume-a-primitive0"><i>Consume a primitive</i></a> and
2999-
append the returned value to the prelude of the <a
2993+
<dd> <a href="#consume-a-primitive0"><i>Consume a primitive</i></a>. If
2994+
anything was returned, append the returned value to the prelude of the <a
30002995
href="#current-rule"><i>current rule</i></a>. Remain in this mode.
2996+
<p> Otherwise, this is a <i>parse error</i>. <a
2997+
href="#discard-the-current-rule0"><i>Discard the current rule</i></a>.
2998+
If the <a href="#current-rule"><i>current rule</i></a> is <a
2999+
href="#declaration-filled"><i>declaration-filled</i></a> or <a
3000+
href="#rule-filled"><i>rule-filled</i></a>, switch to the <a
3001+
href="#next-block-error-mode0"><i>next-block error mode</i></a>;
3002+
otherwise, switch to the <a
3003+
href="#next-block-or-statement-error-mode0"><i>next-block-or-statement
3004+
error mode</i></a>.
30013005
</dl>
30023006

30033007
<h4 id=rule-block-mode><span class=secno>5.3.3. </span> <dfn
@@ -3076,9 +3080,13 @@ <h4 id=selector-mode><span class=secno>5.3.4. </span> <dfn
30763080

30773081
<dt>anything else
30783082

3079-
<dd> <a href="#consume-a-primitive0"><i>Consume a primitive</i></a> and
3080-
append the returned value to the selector of the <a
3081-
href="#current-rule"><i>current rule</i></a>. Remain in this mode.
3083+
<dd> <a href="#consume-a-primitive0"><i>Consume a primitive</i></a>. If
3084+
anything was returned, append the returned value to the selector of the
3085+
<a href="#current-rule"><i>current rule</i></a>. Remain in this mode.
3086+
<p> Otherwise, this is a <i>parse error</i>. <a
3087+
href="#discard-the-current-rule0"><i>Discard the current rule</i></a>.
3088+
Switch to the <a href="#next-block-error-mode0"><i>next-block error
3089+
mode</i></a>.
30823090
</dl>
30833091

30843092
<h4 id=declaration-block-mode><span class=secno>5.3.5. </span> <dfn
@@ -3221,9 +3229,13 @@ <h4 id=declaration-value-mode><span class=secno>5.3.7. </span> <dfn
32213229
match for one of the property names on the <a
32223230
href="#hashless-color-quirk-list"><i>hashless color quirk list</i></a>,
32233231
<a href="#consume-a-primitive-with-the-hashless-co0"><i>consume a
3224-
primitive with the hashless color quirk</i></a> and append the returned
3225-
value to the value of the <a href="#current-declaration"><i>current
3226-
declaration</i></a>. Remain in this mode.
3232+
primitive with the hashless color quirk</i></a>. If anything was
3233+
returned, append the returned value to the value of the <a
3234+
href="#current-declaration"><i>current declaration</i></a> and remain in
3235+
this mode; otherwise, unset the <a href="#current-declaration"><i>current
3236+
declaration</i></a> and switch to the <a
3237+
href="#next-declaration-error-mode0"><i>next-declaration error
3238+
mode</i></a>.
32273239
<p> Otherwise, if the <a href="#quirks-mode"><i>quirks mode</i></a> flag
32283240
is set, and the <a href="#current-declaration"><i>current
32293241
declaration's</i></a> name is an <a
@@ -3232,14 +3244,21 @@ <h4 id=declaration-value-mode><span class=secno>5.3.7. </span> <dfn
32323244
href="#unitless-length-quirk-list"><i>unitless length quirk
32333245
list</i></a>, <a
32343246
href="#consume-a-primitive-with-the-unitless-le0"><i>consume a primitive
3235-
with the unitless length quirk</i></a> and append the returned value to
3236-
the value of the <a href="#current-declaration"><i>current
3237-
declaration</i></a>. Remain in this mode.
3247+
with the unitless length quirk</i></a>. If anything was returned, append
3248+
the returned value to the value of the <a
3249+
href="#current-declaration"><i>current declaration</i></a> and remain in
3250+
this mode; otherwise, unset the <a
3251+
href="#current-declaration"><i>current declaration</i></a> and switch to
3252+
the <a href="#next-declaration-error-mode0"><i>next-declaration error
3253+
mode</i></a>.
32383254

32393255
<p> Otherwise, <a href="#consume-a-primitive0"><i>consume a
3240-
primitive</i></a> and append the returned value to the value of the <a
3241-
href="#current-declaration"><i>current declaration</i></a>. Remain in
3242-
this mode.
3256+
primitive</i></a>. If anything was returned, append the returned value
3257+
to the value of the <a href="#current-declaration"><i>current
3258+
declaration</i></a> and remain in this mode; otherwise, unset the <a
3259+
href="#current-declaration"><i>current declaration</i></a> and switch to
3260+
the <a href="#next-declaration-error-mode0"><i>next-declaration error
3261+
mode</i></a>.
32433262
</dl>
32443263

32453264
<h4 id=declaration-important-mode><span class=secno>5.3.8. </span> <dfn
@@ -3425,6 +3444,10 @@ <h3 id=consume-a-primitive><span class=secno>5.4. </span> <dfn
34253444
token</i></a> is an EOF token, <a href="#finish-parsing0"><i>finish
34263445
parsing</i></a>.
34273446

3447+
<p> Otherwise, if the <a href="#current-input-token"><i>current input
3448+
token</i></a> is a cdo token, cdc token, } token, ] token, ) token,
3449+
bad-string token, or bad-url token, return nothing.
3450+
34283451
<p> Otherwise, return the <a href="#current-input-token"><i>current input
34293452
token</i></a>.
34303453

@@ -3554,6 +3577,8 @@ <h3 id=consume-a-simple-block><span class=secno>5.7. </span> <dfn
35543577
href="#current-input-token"><i>current input token</i></a>. This is the
35553578
<dfn id=current-block>current block</dfn>.
35563579

3580+
<p> Initialize a <var>valid</var> flag to true.
3581+
35573582
<p> Repeatedly consume the <a href="#next-input-token"><i>next input
35583583
token</i></a> and process it as follows:
35593584

@@ -3562,13 +3587,15 @@ <h3 id=consume-a-simple-block><span class=secno>5.7. </span> <dfn
35623587

35633588
<dt><a href="#ending-token"><i>ending token</i></a>
35643589

3565-
<dd> Return the block.
3590+
<dd> If the <var>valid</var> flag is true, return the block.
3591+
<p> Otherwise, return nothing.
35663592

35673593
<dt>anything else
35683594

3569-
<dd> <a href="#consume-a-primitive0"><i>Consume a primitive</i></a> and
3570-
append the returned value to the value of the <a
3571-
href="#current-block"><i>current block</i></a>.
3595+
<dd> <a href="#consume-a-primitive0"><i>Consume a primitive</i></a>. If
3596+
anything was returned, append the returned value to the value of the <a
3597+
href="#current-block"><i>current block</i></a>; otherwise, set the
3598+
<var>valid</var> flag to false.
35723599
</dl>
35733600

35743601
<h3 id=consume-a-function><span class=secno>5.8. </span> <dfn
@@ -3582,6 +3609,8 @@ <h3 id=consume-a-function><span class=secno>5.8. </span> <dfn
35823609
argument, called the <dfn id=current-argument>current argument</dfn>,
35833610
which is initially empty.
35843611

3612+
<p> Initialize a <var>valid</var> flag to true.
3613+
35853614
<p> Repeatedly consume the <a href="#next-input-token"><i>next input
35863615
token</i></a> and process it as follows:
35873616

@@ -3590,8 +3619,10 @@ <h3 id=consume-a-function><span class=secno>5.8. </span> <dfn
35903619

35913620
<dt>) token
35923621

3593-
<dd> Append the <a href="#current-argument"><i>current argument</i></a> to
3594-
the function's argument list. Return the function.
3622+
<dd> If the <var>valid</var> flag is true, append the <a
3623+
href="#current-argument"><i>current argument</i></a> to the function's
3624+
argument list. Return the function.
3625+
<p> Otherwise, return nothing.
35953626

35963627
<dt>delim token with the value ","
35973628

@@ -3606,18 +3637,21 @@ <h3 id=consume-a-function><span class=secno>5.8. </span> <dfn
36063637
the function's name is as <a href="#ascii-case-insensitive"><i>ASCII
36073638
case-insensitive</i></a> match with "rect", <a
36083639
href="#consume-a-primitive-with-the-unitless-le0"><i>consume a primitive
3609-
with the unitless length quirk</i></a> and append the returned value to
3610-
the value of the <a href="#current-argument"><i>current argument</i></a>.
3611-
3640+
with the unitless length quirk</i></a>. If anything was returned, append
3641+
the returned value to the value of the <a
3642+
href="#current-argument"><i>current argument</i></a>; otherwise, set the
3643+
<var>valid</var> flag to false.
36123644
<p> Otherwise, <a href="#consume-a-primitive0"><i>consume a
3613-
primitive</i></a> and append the returned value to the value of the <a
3614-
href="#current-argument"><i>current argument</i></a>.
3645+
primitive</i></a>. If anything was returned, append the returned value
3646+
to the value of the <a href="#current-argument"><i>current
3647+
argument</i></a>; otherwise, set the <var>valid</var> flag to false.
36153648

36163649
<dt>anything else
36173650

3618-
<dd> <a href="#consume-a-primitive0"><i>Consume a primitive</i></a> and
3619-
append the returned value to the value of the <a
3620-
href="#current-argument"><i>current argument</i></a>.
3651+
<dd> <a href="#consume-a-primitive0"><i>Consume a primitive</i></a>. If
3652+
anything was returned, append the returned value to the value of the <a
3653+
href="#current-argument"><i>current argument</i></a>; otherwise, set the
3654+
<var>valid</var> flag to false.
36213655
</dl>
36223656

36233657
<h3 id=switch-to-the-current-rules-content-mode><span class=secno>5.9.

0 commit comments

Comments
 (0)