@@ -2365,7 +2365,7 @@ Parse a list of declarations</h4>
2365
2365
and set |input| to the result.
2366
2366
2367
2367
<li>
2368
- <a>Consume a list of declarations </a> from |input|,
2368
+ <a>Consume a block's contents </a> from |input|,
2369
2369
and return the result.
2370
2370
</ol>
2371
2371
</div>
@@ -2515,8 +2515,9 @@ Consume a list of rules</h4>
2515
2515
2516
2516
<dt> <<at-keyword-token>>
2517
2517
<dd>
2518
- <a>Consume an at-rule</a> from |input|,
2519
- and append the returned value to |rules|.
2518
+ <a>Consume an at-rule</a> from |input|.
2519
+ If anything is returned,
2520
+ append it to |rules|.
2520
2521
2521
2522
<dt> anything else
2522
2523
<dd>
@@ -2530,52 +2531,61 @@ Consume a list of rules</h4>
2530
2531
Consume an at-rule</h4>
2531
2532
2532
2533
To <dfn>consume an at-rule</dfn>
2533
- from a [=token stream=] |input|:
2534
+ from a [=token stream=] |input|,
2535
+ given an optional bool |nested| (default false):
2534
2536
2535
2537
Assert: The [=next token=] is an <<at-keyword-token>> .
2536
2538
2537
2539
[=token stream/Consume a token=] from |input|,
2538
2540
and let |rule| be a new [=at-rule=]
2539
2541
with its name set to the returned token's value,
2540
- and its prelude initially set to an empty [=list=] .
2542
+ its prelude initially set to an empty [=list=] ,
2543
+ and no declarations or child rules.
2541
2544
2542
2545
[=token stream/Process=] |input|:
2543
2546
2544
2547
<dl>
2545
2548
<dt> <<semicolon-token>>
2549
+ <dt> <<EOF-token>>
2546
2550
<dd>
2547
2551
[=Discard a token=] from |input|.
2548
2552
If |rule| is valid in the current context,
2549
2553
return it;
2550
2554
otherwise return nothing.
2551
2555
2552
- <dt> <<EOF- token>>
2556
+ <dt> <a href="#tokendef-close-curly"><}- token></a >
2553
2557
<dd>
2554
- This is a <a>parse error</a> .
2555
- If |rule| is valid in the current context,
2556
- return it;
2557
- otherwise return nothing.
2558
+ If |nested| is true:
2559
+ * If |rule| is valid in the current context,
2560
+ return it.
2561
+ * Otherwise, return nothing.
2562
+
2563
+ Otherwise, [=token stream/consume a token=]
2564
+ and append the result to |rule|'s prelude.
2558
2565
2559
2566
<dt> <a href="#tokendef-open-curly"><{-token></a>
2560
2567
<dd>
2561
2568
[=Consume a block=] from |input|,
2562
2569
and assign the results to |rule|'s
2563
2570
lists of [=declarations=] and child [=rules=] .
2564
2571
2565
- Return |at-rule|.
2572
+ If |rule| is valid in the current context,
2573
+ return it.
2574
+ Otherwise, return nothing.
2566
2575
2567
2576
<dt> anything else
2568
2577
<dd>
2569
- <a>Consume a component value</a> from |input|.
2570
- Append the returned value to |rule|'s prelude.
2578
+ <a>Consume a component value</a> from |input|
2579
+ and append the returned value to |rule|'s prelude.
2571
2580
</dl>
2572
2581
2573
2582
2574
2583
<h4 id="consume-qualified-rule">
2575
2584
Consume a qualified rule</h4>
2576
2585
2577
2586
To <dfn>consume a qualified rule</dfn> ,
2578
- from a [=token stream=] |input|:
2587
+ from a [=token stream=] |input|,
2588
+ given an optional bool |nested| (default false):
2579
2589
2580
2590
Let |rule| be a new [=qualified rule=]
2581
2591
with its prelude, declarations, and child rules
@@ -2588,9 +2598,17 @@ Consume a qualified rule</h4>
2588
2598
<dt> <<semicolon-token>>
2589
2599
<dd>
2590
2600
This is a <a>parse error</a> .
2591
- [=Discard a token=] from |input|.
2592
2601
Return nothing.
2593
2602
2603
+ <dt> <a href="#tokendef-close-curly"><}-token></a>
2604
+ <dd>
2605
+ This is a <a>parse error</a> .
2606
+ If |nested| is true,
2607
+ return nothing.
2608
+ Otherwise,
2609
+ [=token stream/consume a token=]
2610
+ and append the result to |rule|'s prelude.
2611
+
2594
2612
<dt> <a href="#tokendef-open-curly"><{-token></a>
2595
2613
<dd>
2596
2614
[=Consume a block=] from |input|,
@@ -2603,8 +2621,8 @@ Consume a qualified rule</h4>
2603
2621
2604
2622
<dt> anything else
2605
2623
<dd>
2606
- <a>Consume a component value</a> from |input|.
2607
- Append the returned value to |rule|'s prelude.
2624
+ <a>Consume a component value</a> from |input|
2625
+ and append the result to |rule|'s prelude.
2608
2626
</dl>
2609
2627
2610
2628
@@ -2621,23 +2639,18 @@ Consume a block</h4>
2621
2639
and |rules| be an empty [=list=] of [=rules=] .
2622
2640
2623
2641
[=Discard a token=] from |input|.
2624
- [=Consume a list of declarations=] from |input|
2625
- with <a href="#tokendef-close-curly"><}-token></a> as the stop token,
2642
+ [=Consume a block's contents=] from |input|
2626
2643
and assign the results to |decls| and |rules|.
2627
2644
[=Discard a token=] from |input|.
2628
2645
2629
2646
Return |decls| and |rules|.
2630
2647
2631
2648
2632
- <h4 id="consume-list-of-declarations">
2633
- Consume a list of declarations </h4>
2649
+ <h4 id="consume-block-contents" oldids="consume- list-of-declarations">
2650
+ Consume a block's contents </h4>
2634
2651
2635
- Note: This algorithm actually parses both declarations and rules,
2636
- and returns the two in separate lists.
2637
-
2638
- To <dfn>consume a list of declarations</dfn>
2639
- from a [=token stream=] |input|,
2640
- with an optional |stop token|:
2652
+ To <dfn>consume a block's contents</dfn>
2653
+ from a [=token stream=] |input|:
2641
2654
2642
2655
Let |decls| be an empty [=list=] of [=declarations=] ,
2643
2656
and |rules| be an empty [=list=] of [=rules=] .
@@ -2651,27 +2664,30 @@ Consume a list of declarations</h4>
2651
2664
[=Discard a token=] from |input|.
2652
2665
2653
2666
<dt> <<EOF-token>>
2654
- <dt> |stop token| (if provided)
2667
+ <dt> <a href="#tokendef-close-curly"><}- token></a>
2655
2668
<dd>
2656
2669
Return |decls| and |rules|.
2657
2670
2658
2671
<dt> <<at-keyword-token>>
2659
2672
<dd>
2660
- <a>Consume an at-rule</a> from |input|.
2673
+ [=Consume an at-rule=] from |input|,
2674
+ with |nested| set to true.
2661
2675
If a [=rule=] was returned,
2662
2676
append it to |rules|.
2663
2677
2664
2678
<dt> anything else</dd>
2665
2679
<dd>
2666
2680
[=Mark=] |input|.
2667
2681
2668
- [=Consume a declaration=] from |input|.
2682
+ [=Consume a declaration=] from |input|,
2683
+ with |nested| set to true.
2669
2684
If a [=declaration=] was returned,
2670
2685
append it to |decls|,
2671
2686
and [=discard a mark=] from |input|.
2672
2687
2673
2688
Otherwise, [=restore a mark=] from |input|,
2674
- then [=consume a qualified rule=] .
2689
+ then [=consume a qualified rule=] from |input|,
2690
+ with |nested| set to true.
2675
2691
If a [=rule=] was returned,
2676
2692
append it to |rules|.
2677
2693
</dl>
@@ -2681,7 +2697,8 @@ Consume a list of declarations</h4>
2681
2697
Consume a declaration</h4>
2682
2698
2683
2699
To <dfn>consume a declaration</dfn>
2684
- from a [=token stream=] |input|:
2700
+ from a [=token stream=] |input|,
2701
+ given an optional bool |nested| (default false):
2685
2702
2686
2703
Let |decl| be a new [=declaration=] ,
2687
2704
with an initially empty name
@@ -2690,12 +2707,13 @@ Consume a declaration</h4>
2690
2707
<ol>
2691
2708
<li>
2692
2709
If the [=next token=] is an <<ident-token>> ,
2693
- [=token stream/Consume a token=] from |input|
2710
+ [=token stream/consume a token=] from |input|
2694
2711
and set |decl|'s name
2695
2712
to the token's value.
2696
2713
2697
2714
Otherwise,
2698
- [=consume the remnants of a bad declaration=] from |input|
2715
+ [=consume the remnants of a bad declaration=] from |input|,
2716
+ with |nested|,
2699
2717
and return nothing.
2700
2718
2701
2719
<li>
@@ -2706,15 +2724,17 @@ Consume a declaration</h4>
2706
2724
[=discard a token=] from |input|.
2707
2725
2708
2726
Otherwise,
2709
- [=consume the remnants of a bad declaration=] from |input|
2727
+ [=consume the remnants of a bad declaration=] from |input|,
2728
+ with |nested|,
2710
2729
and return nothing.
2711
2730
2712
2731
<li>
2713
2732
[=Discard whitespace=] from |input|.
2714
2733
2715
2734
<li>
2716
2735
[=Consume a list of component values=] from |input|,
2717
- with <<semicolon-token>> as the stop token,
2736
+ with |nested|,
2737
+ and with <<semicolon-token>> as the stop token,
2718
2738
and set |decl|'s value to the result.
2719
2739
2720
2740
<li>
@@ -2737,13 +2757,22 @@ Consume a declaration</h4>
2737
2757
<div algorithm>
2738
2758
To <dfn>consume the remnants of a bad declaration</dfn>
2739
2759
from a [=token stream=] |input|,
2740
- [=token stream/process=] |input|:
2760
+ given a bool |nested|:
2761
+
2762
+ [=token stream/Process=] |input|:
2741
2763
2742
2764
: <<eof-token>>
2743
2765
: <<semicolon-token>>
2744
2766
:: [=Discard a token=] from |input|,
2745
2767
and return nothing.
2746
2768
2769
+ : <a href="#tokendef-close-curly"><}-token></a>
2770
+ ::
2771
+ If |nested| is true,
2772
+ return nothing.
2773
+ Otherwise,
2774
+ [=discard a token=] .
2775
+
2747
2776
: anything else
2748
2777
:: [=Consume a component value=] from |input|,
2749
2778
and do nothing.
@@ -2755,7 +2784,8 @@ Consume a list of component values</h4>
2755
2784
2756
2785
To <dfn>consume a list of component values</dfn>
2757
2786
from a [=token stream=] |input|,
2758
- optionally given a [=token=] |stop token|:
2787
+ given an optional [=token=] |stop token|
2788
+ and an optional boolean |nested| (default false):
2759
2789
2760
2790
Let |values| be an empty [=list=] of [=component values=] .
2761
2791
@@ -2765,8 +2795,18 @@ Consume a list of component values</h4>
2765
2795
: |stop token| (if passed)
2766
2796
:: Return |values|.
2767
2797
2798
+ : <a href="#tokendef-close-curly"><}-token></a>
2799
+ ::
2800
+ If |nested| is true,
2801
+ return |values|.
2802
+
2803
+ Otherwise,
2804
+ this is a <a>parse error</a> .
2805
+ [=token stream/Consume a token=] from |input|
2806
+ and append the result to |values|.
2807
+
2768
2808
: anything else
2769
- :: [=Consume a component value=] ,
2809
+ :: [=Consume a component value=] from |input| ,
2770
2810
and append the result to |values|.
2771
2811
2772
2812
@@ -2777,7 +2817,7 @@ Consume a component value</h4>
2777
2817
To <dfn>consume a component value</dfn>
2778
2818
from a [=token stream=] |input|:
2779
2819
2780
- [=token stream/Process=] |input:
2820
+ [=token stream/Process=] |input| :
2781
2821
2782
2822
: <a href="#tokendef-open-curly"><{-token></a>
2783
2823
: <a href="#tokendef-open-square"><[-token></a>
0 commit comments