Skip to content

Commit c5f0070

Browse files
committed
Add a more abstract 'consume a primitive' function and collapse all the places where I differentiated between blocks, functions, and tokens to just use this new function.
--HG-- extra : rebase_source : a5404c95777809ac212fc23391c1f2fabe354301
1 parent 0d31827 commit c5f0070

2 files changed

Lines changed: 108 additions & 297 deletions

File tree

css3-syntax/Overview.html

Lines changed: 62 additions & 168 deletions
Original file line numberDiff line numberDiff line change
@@ -305,14 +305,17 @@ <h2 class="no-num no-toc" id=contents> Table of contents</h2>
305305
<li><a href="#next-block-or-statement-error-mode"><span
306306
class=secno>3.6.12. </span> Next-block-or-statement error mode</a>
307307

308-
<li><a href="#consume-a-simple-block"><span class=secno>3.6.13.
308+
<li><a href="#consume-a-primitive-"><span class=secno>3.6.13. </span>
309+
Consume a primitive </a>
310+
311+
<li><a href="#consume-a-simple-block"><span class=secno>3.6.14.
309312
</span> Consume a simple block</a>
310313

311-
<li><a href="#consume-a-function"><span class=secno>3.6.14. </span>
314+
<li><a href="#consume-a-function"><span class=secno>3.6.15. </span>
312315
Consume a function</a>
313316

314317
<li><a href="#switch-to-the-current-rules-content-mode"><span
315-
class=secno>3.6.15. </span> Switch to the current rule's content
318+
class=secno>3.6.16. </span> Switch to the current rule's content
316319
mode</a>
317320
</ul>
318321

@@ -2194,9 +2197,8 @@ <h4 id=top-level-mode-><span class=secno>3.6.2. </span> <dfn
21942197
<dt>{ token
21952198

21962199
<dd> This is a <i>parse error</i>. <a
2197-
href="#consume-a-simple-block0"><i>Consume a simple block</i></a> with
2198-
the <a href="#current-input-token"><i>current input token</i></a>. Ignore
2199-
the return value. Remain in this state.
2200+
href="#consume-a-primitive"><i>Consume a primitive</i></a> and ignore the
2201+
return value. Remain in this state.
22002202

22012203
<dt>anything else
22022204

@@ -2234,27 +2236,11 @@ <h4 id=at-rule-mode><span class=secno>3.6.3. </span> <dfn
22342236
Reconsume the <a href="#current-input-token"><i>current input
22352237
token</i></a>.
22362238

2237-
<dt>[ token
2238-
2239-
<dt>( token
2240-
2241-
<dd> <a href="#consume-a-simple-block0"><i>Consume a simple block</i></a>
2242-
with the <a href="#current-input-token"><i>current input token</i></a>.
2243-
Append the returned block to the prelude of the <a
2244-
href="#current-rule"><i>current rule</i></a> and remain in this mode.
2245-
2246-
<dt>function token
2247-
2248-
<dd> <a href="#consume-a-function0"><i>Consume a function</i></a> with the
2249-
<a href="#current-input-token"><i>current input token</i></a>. Append the
2250-
returned function to the prelude of the <a
2251-
href="#current-rule"><i>current rule</i></a> and remain in this mode.
2252-
22532239
<dt>anything else
22542240

2255-
<dd> Append the <a href="#current-input-token"><i>current input
2256-
token</i></a> to the prelude of the <a href="#current-rule"><i>current
2257-
rule</i></a> and remain in this mode.
2241+
<dd> <a href="#consume-a-primitive"><i>Consume a primitive</i></a> and
2242+
append the returned value to the prelude of the <a
2243+
href="#current-rule"><i>current rule</i></a>. Remain in this mode.
22582244
</dl>
22592245

22602246
<h4 id=rule-mode><span class=secno>3.6.4. </span> <dfn id=rule-mode0>Rule
@@ -2304,25 +2290,10 @@ <h4 id=selector-mode><span class=secno>3.6.5. </span> <dfn
23042290
<dd> Switch to the <a href="#declaration-mode0"><i>declaration
23052291
mode</i></a>.
23062292

2307-
<dt>[ token
2308-
2309-
<dt>( token
2310-
2311-
<dd> <a href="#consume-a-simple-block0"><i>Consume a simple block</i></a>
2312-
with the <a href="#current-input-token"><i>current input token</i></a>.
2313-
Append the returned block to the selector of the <a
2314-
href="#current-rule"><i>current rule</i></a> and remain in this mode.
2315-
2316-
<dt>function token
2317-
2318-
<dd> <a href="#consume-a-function0"><i>Consume a function</i></a> with the
2319-
<a href="#current-input-token"><i>current input token</i></a>. Append the
2320-
returned function to the selector of the <a
2321-
href="#current-rule"><i>current rule</i></a> and remain in this mode.
2322-
23232293
<dt>anything else
23242294

2325-
<dd> Append the token to the selector of the <a
2295+
<dd> <a href="#consume-a-primitive"><i>Consume a primitive</i></a> and
2296+
append the returned value to the selector of the <a
23262297
href="#current-rule"><i>current rule</i></a>. Remain in this mode.
23272298
</dl>
23282299

@@ -2403,26 +2374,6 @@ <h4 id=declaration-value-mode><span class=secno>3.6.8. </span> <dfn
24032374
<p> Consume the <a href="#next-input-token"><i>next input token</i></a>.
24042375

24052376
<dl>
2406-
<dt>{ token
2407-
2408-
<dt>[ token
2409-
2410-
<dt>( token
2411-
2412-
<dd> <a href="#consume-a-simple-block0"><i>Consume a simple block</i></a>
2413-
with the <a href="#current-input-token"><i>current input token</i></a>.
2414-
Append the returned block to the value of the <a
2415-
href="#current-declaration"><i>current declaration</i></a> and remain in
2416-
this mode.
2417-
2418-
<dt>function token
2419-
2420-
<dd> <a href="#consume-a-function0"><i>Consume a function</i></a> with the
2421-
<a href="#current-input-token"><i>current input token</i></a>. Append the
2422-
returned function to the value of the <a
2423-
href="#current-declaration"><i>current declaration</i></a>. and remain in
2424-
this mode.
2425-
24262377
<dt>delim token with a value of "!"
24272378

24282379
<dd> If the <a href="#next-input-token"><i>next input token</i></a> is an
@@ -2455,8 +2406,8 @@ <h4 id=declaration-value-mode><span class=secno>3.6.8. </span> <dfn
24552406

24562407
<dt>anything else
24572408

2458-
<dd> Append the <a href="#current-input-token"><i>current input
2459-
token</i></a> to the value of the <a
2409+
<dd> <a href="#consume-a-primitive"><i>Consume a primitive</i></a> and
2410+
append the returned value to the value of the <a
24602411
href="#current-declaration"><i>current declaration</i></a>. Remain in
24612412
this mode.
24622413
</dl>
@@ -2511,29 +2462,15 @@ <h4 id=next-block-error-mode><span class=secno>3.6.10. </span> <dfn
25112462
<dl>
25122463
<dt>{ token
25132464

2514-
<dd> <a href="#consume-a-simple-block0"><i>Consume a simple block</i></a>
2515-
with the <a href="#current-input-token"><i>current input token</i></a>.
2516-
Ignore the return value. <a
2465+
<dd> <a href="#consume-a-primitive"><i>Consume a primitive</i></a>. Ignore
2466+
the return value. <a
25172467
href="#switch-to-the-current-rules-content-mode0"><i>Switch to the
25182468
current rule's content mode</i></a>.
25192469

2520-
<dt>[ token
2521-
2522-
<dt>( token
2523-
2524-
<dd> <a href="#consume-a-simple-block0"><i>Consume a simple block</i></a>
2525-
with the <a href="#current-input-token"><i>current input token</i></a>.
2526-
Ignore the return value. Remain in this mode.
2527-
2528-
<dt>function token
2529-
2530-
<dd> <a href="#consume-a-function0"><i>Consume a function</i></a> with the
2531-
<a href="#current-input-token"><i>current input token</i></a>. Ignore the
2532-
return value. Remain in this mode.
2533-
25342470
<dt>anything else
25352471

2536-
<dd> Do nothing. Remain in this mode.
2472+
<dd> <a href="#consume-a-primitive"><i>Consume a primitive</i></a>. Ignore
2473+
the return value. Remain in this mode.
25372474
</dl>
25382475

25392476
<h4 id=next-declaration-error-mode><span class=secno>3.6.11. </span> <dfn
@@ -2553,25 +2490,10 @@ <h4 id=next-declaration-error-mode><span class=secno>3.6.11. </span> <dfn
25532490
mode</i></a>. Reprocess the <a href="#current-input-token"><i>current
25542491
input token</i></a>.
25552492

2556-
<dt>{ token
2557-
2558-
<dt>[ token
2559-
2560-
<dt>( token
2561-
2562-
<dd> <a href="#consume-a-simple-block0"><i>Consume a simple block</i></a>
2563-
with the <a href="#current-input-token"><i>current input token</i></a>.
2564-
Ignore the return value. Remain in this mode.
2565-
2566-
<dt>function token
2567-
2568-
<dd> <a href="#consume-a-function0"><i>Consume a function</i></a> with the
2569-
<a href="#current-input-token"><i>current input token</i></a>. Ignore the
2570-
return value. Remain in this mode.
2571-
25722493
<dt>anything else
25732494

2574-
<dd> Do nothing. Remain in this mode.
2495+
<dd> <a href="#consume-a-primitive"><i>Consume a primitive</i></a>. Ignore
2496+
the return value. Remain in this mode.
25752497
</dl>
25762498

25772499
<h4 id=next-block-or-statement-error-mode><span class=secno>3.6.12. </span>
@@ -2589,45 +2511,48 @@ <h4 id=next-block-or-statement-error-mode><span class=secno>3.6.12. </span>
25892511

25902512
<dt>{ token
25912513

2592-
<dd> <a href="#consume-a-simple-block0"><i>Consume a simple block</i></a>
2593-
with the <a href="#current-input-token"><i>current input token</i></a>.
2594-
Ignore the return value. <a
2514+
<dd> <a href="#consume-a-primitive"><i>Consume a primitive</i></a>. Ignore
2515+
the return value. <a
25952516
href="#switch-to-the-current-rules-content-mode0"><i>Switch to the
25962517
current rule's content mode</i></a>.
25972518

2598-
<dt>[ token
2519+
<dt>anything else
25992520

2600-
<dt>( token
2521+
<dd> <a href="#consume-a-primitive"><i>Consume a primitive</i></a>. Ignore
2522+
the return value. Remain in this mode.
2523+
</dl>
26012524

2602-
<dd> <a href="#consume-a-simple-block0"><i>Consume a simple block</i></a>
2603-
with the <a href="#current-input-token"><i>current input token</i></a>.
2604-
Ignore the return value. Remain in this mode.
2525+
<h4 id=consume-a-primitive-><span class=secno>3.6.13. </span> <dfn
2526+
id=consume-a-primitive>Consume a primitive</dfn></h4>
26052527

2606-
<dt>function token
2528+
<p> This section describes how to <a href="#consume-a-primitive"><i>consume
2529+
a primitive</i></a>.
26072530

2608-
<dd> <a href="#consume-a-function0"><i>Consume a function</i></a> with the
2609-
<a href="#current-input-token"><i>current input token</i></a>. Ignore the
2610-
return value. Remain in this mode.
2531+
<p> If the <a href="#current-input-token"><i>current input token</i></a> is
2532+
a {, [, or ( token, <a href="#consume-a-simple-block0"><i>consume a simple
2533+
block</i></a> and return it.
26112534

2612-
<dt>anything else
2535+
<p> Otherwise, if the <a href="#current-input-token"><i>current input
2536+
token</i></a> is a function token, <a
2537+
href="#consume-a-function0"><i>consume a function</i></a> and return it.
26132538

2614-
<dd> Do nothing. Remain in this mode.
2615-
</dl>
2539+
<p> Otherwise, return the <a href="#current-input-token"><i>current input
2540+
token</i></a>.
26162541

2617-
<h4 id=consume-a-simple-block><span class=secno>3.6.13. </span> <dfn
2542+
<h4 id=consume-a-simple-block><span class=secno>3.6.14. </span> <dfn
26182543
id=consume-a-simple-block0>Consume a simple block</dfn></h4>
26192544

26202545
<p> This section describes how to <a
2621-
href="#consume-a-simple-block0"><i>consume a simple block</i></a>. It must
2622-
be called with an {, [, or ( token.
2546+
href="#consume-a-simple-block0"><i>consume a simple block</i></a>.
26232547

26242548
<p> The <dfn id=ending-token>ending token</dfn> is the mirror variant of
2625-
the token this algorithm was called with. (E.g. if it was called with [,
2626-
the <a href="#ending-token"><i>ending token</i></a> is ].)
2549+
the <a href="#current-input-token"><i>current input token</i></a>. (E.g.
2550+
if it was called with [, the <a href="#ending-token"><i>ending
2551+
token</i></a> is ].)
26272552

2628-
<p> Create a simple block with its associated token set to the token this
2629-
algorithm was called with. This is the <dfn id=current-block>current
2630-
block</dfn>.
2553+
<p> Create a simple block with its associated token set to the <a
2554+
href="#current-input-token"><i>current input token</i></a>. This is the
2555+
<dfn id=current-block>current block</dfn>.
26312556

26322557
<p> Repeatedly consume the <a href="#next-input-token"><i>next input
26332558
token</i></a> and process it as follows:
@@ -2639,32 +2564,14 @@ <h4 id=consume-a-simple-block><span class=secno>3.6.13. </span> <dfn
26392564

26402565
<dd> Return the block.
26412566

2642-
<dt>{ token
2643-
2644-
<dt>[ token
2645-
2646-
<dt>( token
2647-
2648-
<dd> <a href="#consume-a-simple-block0"><i>Consume a simple block</i></a>
2649-
with the <a href="#current-input-token"><i>current input token</i></a>.
2650-
Append the returned block to the value of the <a
2651-
href="#current-block"><i>current block</i></a>.
2652-
2653-
<dt>function token
2654-
2655-
<dd> <a href="#consume-a-function0"><i>Consume a function</i></a> with the
2656-
<a href="#current-input-token"><i>current input token</i></a>. Append the
2657-
returned function to the value of the <a href="#current-block"><i>current
2658-
block</i></a>.
2659-
26602567
<dt>anything else
26612568

2662-
<dd> Append the <a href="#current-input-token"><i>current input
2663-
token</i></a> to the value of the <a href="#current-block"><i>current
2664-
block</i></a>.
2569+
<dd> <a href="#consume-a-primitive"><i>Consume a primitive</i></a> and
2570+
append the returned value to the value of the <a
2571+
href="#current-block"><i>current block</i></a>.
26652572
</dl>
26662573

2667-
<h4 id=consume-a-function><span class=secno>3.6.14. </span> <dfn
2574+
<h4 id=consume-a-function><span class=secno>3.6.15. </span> <dfn
26682575
id=consume-a-function0>Consume a function</dfn></h4>
26692576

26702577
<p> This section describes how to <a href="#consume-a-function0"><i>consume
@@ -2690,29 +2597,13 @@ <h4 id=consume-a-function><span class=secno>3.6.14. </span> <dfn
26902597
<dd> Append the <i>current argument</i> to the function's argument list.
26912598
Create a new <i>current argument</i> which is initially empty.
26922599

2693-
<dt>{ token
2694-
2695-
<dt>[ token
2696-
2697-
<dt>( token
2698-
2699-
<dd> <a href="#consume-a-simple-block0"><i>Consume a simple block</i></a>
2700-
with the <a href="#current-input-token"><i>current input token</i></a>.
2701-
Append the returned block to the value of the <i>current argument</i>.
2702-
2703-
<dt>function token
2704-
2705-
<dd> <a href="#consume-a-function0"><i>Consume a function</i></a> with the
2706-
<a href="#current-input-token"><i>current input token</i></a>. Append the
2707-
returned function to the value of the <i>current argument</i>.
2708-
27092600
<dt>anything else
27102601

2711-
<dd> Append the <a href="#current-input-token"><i>current input
2712-
token</i></a> to the value of the <i>current argument</i>.
2602+
<dd> <a href="#consume-a-primitive"><i>Consume a primitive</i></a> and
2603+
append the returned value to the value of the <i>current argument</i>.
27132604
</dl>
27142605

2715-
<h4 id=switch-to-the-current-rules-content-mode><span class=secno>3.6.15.
2606+
<h4 id=switch-to-the-current-rules-content-mode><span class=secno>3.6.16.
27162607
</span> <dfn id=switch-to-the-current-rules-content-mode0>Switch to the
27172608
current rule's content mode</dfn></h4>
27182609

@@ -3029,16 +2920,19 @@ <h2 class=no-num id=index> Index</h2>
30292920
title="Comment state"><strong>3.4.8.</strong></a>
30302921

30312922
<li>Consume a function, <a href="#consume-a-function0"
3032-
title="Consume a function"><strong>3.6.14.</strong></a>
2923+
title="Consume a function"><strong>3.6.15.</strong></a>
30332924

30342925
<li>Consume an escaped character, <a href="#consume-an-escaped-character0"
30352926
title="Consume an escaped character"><strong>3.4.26.</strong></a>
30362927

2928+
<li>Consume a primitive, <a href="#consume-a-primitive"
2929+
title="Consume a primitive"><strong>3.6.13.</strong></a>
2930+
30372931
<li>Consume a simple block, <a href="#consume-a-simple-block0"
3038-
title="Consume a simple block"><strong>3.6.13.</strong></a>
2932+
title="Consume a simple block"><strong>3.6.14.</strong></a>
30392933

30402934
<li>current block, <a href="#current-block"
3041-
title="current block"><strong>3.6.13.</strong></a>
2935+
title="current block"><strong>3.6.14.</strong></a>
30422936

30432937
<li>current declaration, <a href="#current-declaration"
30442938
title="current declaration"><strong>3.6.1.</strong></a>
@@ -3076,7 +2970,7 @@ <h2 class=no-num id=index> Index</h2>
30762970
title="Double-quote-string state"><strong>3.4.4.</strong></a>
30772971

30782972
<li>ending token, <a href="#ending-token"
3079-
title="ending token"><strong>3.6.13.</strong></a>
2973+
title="ending token"><strong>3.6.14.</strong></a>
30802974

30812975
<li>end of the range, <a href="#end-of-the-range"
30822976
title="end of the range"><strong>3.4.27.</strong></a>
@@ -3184,7 +3078,7 @@ <h2 class=no-num id=index> Index</h2>
31843078

31853079
<li>Switch to the current rule's content mode, <a
31863080
href="#switch-to-the-current-rules-content-mode0"
3187-
title="Switch to the current rule's content mode"><strong>3.6.15.</strong></a>
3081+
title="Switch to the current rule's content mode"><strong>3.6.16.</strong></a>
31883082

31893083

31903084
<li>Top-level mode, <a href="#top-level-mode"

0 commit comments

Comments
 (0)