Skip to content

Commit ed19498

Browse files
committed
[css-syntax-3] Fix handling of nested constructs. #8738
1 parent bea2984 commit ed19498

File tree

1 file changed

+80
-40
lines changed

1 file changed

+80
-40
lines changed

css-syntax-3/Overview.bs

+80-40
Original file line numberDiff line numberDiff line change
@@ -2365,7 +2365,7 @@ Parse a list of declarations</h4>
23652365
and set |input| to the result.
23662366

23672367
<li>
2368-
<a>Consume a list of declarations</a> from |input|,
2368+
<a>Consume a block's contents</a> from |input|,
23692369
and return the result.
23702370
</ol>
23712371
</div>
@@ -2515,8 +2515,9 @@ Consume a list of rules</h4>
25152515

25162516
<dt><<at-keyword-token>>
25172517
<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|.
25202521

25212522
<dt>anything else
25222523
<dd>
@@ -2530,52 +2531,61 @@ Consume a list of rules</h4>
25302531
Consume an at-rule</h4>
25312532

25322533
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):
25342536

25352537
Assert: The [=next token=] is an <<at-keyword-token>>.
25362538

25372539
[=token stream/Consume a token=] from |input|,
25382540
and let |rule| be a new [=at-rule=]
25392541
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.
25412544

25422545
[=token stream/Process=] |input|:
25432546

25442547
<dl>
25452548
<dt><<semicolon-token>>
2549+
<dt><<EOF-token>>
25462550
<dd>
25472551
[=Discard a token=] from |input|.
25482552
If |rule| is valid in the current context,
25492553
return it;
25502554
otherwise return nothing.
25512555

2552-
<dt><<EOF-token>>
2556+
<dt><a href="#tokendef-close-curly">&lt;}-token></a>
25532557
<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.
25582565

25592566
<dt><a href="#tokendef-open-curly">&lt;{-token></a>
25602567
<dd>
25612568
[=Consume a block=] from |input|,
25622569
and assign the results to |rule|'s
25632570
lists of [=declarations=] and child [=rules=].
25642571

2565-
Return |at-rule|.
2572+
If |rule| is valid in the current context,
2573+
return it.
2574+
Otherwise, return nothing.
25662575

25672576
<dt>anything else
25682577
<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.
25712580
</dl>
25722581

25732582

25742583
<h4 id="consume-qualified-rule">
25752584
Consume a qualified rule</h4>
25762585

25772586
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):
25792589

25802590
Let |rule| be a new [=qualified rule=]
25812591
with its prelude, declarations, and child rules
@@ -2588,9 +2598,17 @@ Consume a qualified rule</h4>
25882598
<dt><<semicolon-token>>
25892599
<dd>
25902600
This is a <a>parse error</a>.
2591-
[=Discard a token=] from |input|.
25922601
Return nothing.
25932602

2603+
<dt><a href="#tokendef-close-curly">&lt;}-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+
25942612
<dt><a href="#tokendef-open-curly">&lt;{-token></a>
25952613
<dd>
25962614
[=Consume a block=] from |input|,
@@ -2603,8 +2621,8 @@ Consume a qualified rule</h4>
26032621

26042622
<dt>anything else
26052623
<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.
26082626
</dl>
26092627

26102628

@@ -2621,23 +2639,18 @@ Consume a block</h4>
26212639
and |rules| be an empty [=list=] of [=rules=].
26222640

26232641
[=Discard a token=] from |input|.
2624-
[=Consume a list of declarations=] from |input|
2625-
with <a href="#tokendef-close-curly">&lt;}-token></a> as the stop token,
2642+
[=Consume a block's contents=] from |input|
26262643
and assign the results to |decls| and |rules|.
26272644
[=Discard a token=] from |input|.
26282645

26292646
Return |decls| and |rules|.
26302647

26312648

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>
26342651

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|:
26412654

26422655
Let |decls| be an empty [=list=] of [=declarations=],
26432656
and |rules| be an empty [=list=] of [=rules=].
@@ -2651,27 +2664,30 @@ Consume a list of declarations</h4>
26512664
[=Discard a token=] from |input|.
26522665

26532666
<dt><<EOF-token>>
2654-
<dt>|stop token| (if provided)
2667+
<dt><a href="#tokendef-close-curly">&lt;}-token></a>
26552668
<dd>
26562669
Return |decls| and |rules|.
26572670

26582671
<dt><<at-keyword-token>>
26592672
<dd>
2660-
<a>Consume an at-rule</a> from |input|.
2673+
[=Consume an at-rule=] from |input|,
2674+
with |nested| set to true.
26612675
If a [=rule=] was returned,
26622676
append it to |rules|.
26632677

26642678
<dt>anything else</dd>
26652679
<dd>
26662680
[=Mark=] |input|.
26672681

2668-
[=Consume a declaration=] from |input|.
2682+
[=Consume a declaration=] from |input|,
2683+
with |nested| set to true.
26692684
If a [=declaration=] was returned,
26702685
append it to |decls|,
26712686
and [=discard a mark=] from |input|.
26722687

26732688
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.
26752691
If a [=rule=] was returned,
26762692
append it to |rules|.
26772693
</dl>
@@ -2681,7 +2697,8 @@ Consume a list of declarations</h4>
26812697
Consume a declaration</h4>
26822698

26832699
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):
26852702

26862703
Let |decl| be a new [=declaration=],
26872704
with an initially empty name
@@ -2690,12 +2707,13 @@ Consume a declaration</h4>
26902707
<ol>
26912708
<li>
26922709
If the [=next token=] is an <<ident-token>>,
2693-
[=token stream/Consume a token=] from |input|
2710+
[=token stream/consume a token=] from |input|
26942711
and set |decl|&apos;s name
26952712
to the token's value.
26962713

26972714
Otherwise,
2698-
[=consume the remnants of a bad declaration=] from |input|
2715+
[=consume the remnants of a bad declaration=] from |input|,
2716+
with |nested|,
26992717
and return nothing.
27002718

27012719
<li>
@@ -2706,15 +2724,17 @@ Consume a declaration</h4>
27062724
[=discard a token=] from |input|.
27072725

27082726
Otherwise,
2709-
[=consume the remnants of a bad declaration=] from |input|
2727+
[=consume the remnants of a bad declaration=] from |input|,
2728+
with |nested|,
27102729
and return nothing.
27112730

27122731
<li>
27132732
[=Discard whitespace=] from |input|.
27142733

27152734
<li>
27162735
[=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,
27182738
and set |decl|'s value to the result.
27192739

27202740
<li>
@@ -2737,13 +2757,22 @@ Consume a declaration</h4>
27372757
<div algorithm>
27382758
To <dfn>consume the remnants of a bad declaration</dfn>
27392759
from a [=token stream=] |input|,
2740-
[=token stream/process=] |input|:
2760+
given a bool |nested|:
2761+
2762+
[=token stream/Process=] |input|:
27412763

27422764
: <<eof-token>>
27432765
: <<semicolon-token>>
27442766
:: [=Discard a token=] from |input|,
27452767
and return nothing.
27462768

2769+
: <a href="#tokendef-close-curly">&lt;}-token></a>
2770+
::
2771+
If |nested| is true,
2772+
return nothing.
2773+
Otherwise,
2774+
[=discard a token=].
2775+
27472776
: anything else
27482777
:: [=Consume a component value=] from |input|,
27492778
and do nothing.
@@ -2755,7 +2784,8 @@ Consume a list of component values</h4>
27552784

27562785
To <dfn>consume a list of component values</dfn>
27572786
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):
27592789

27602790
Let |values| be an empty [=list=] of [=component values=].
27612791

@@ -2765,8 +2795,18 @@ Consume a list of component values</h4>
27652795
: |stop token| (if passed)
27662796
:: Return |values|.
27672797

2798+
: <a href="#tokendef-close-curly">&lt;}-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+
27682808
: anything else
2769-
:: [=Consume a component value=],
2809+
:: [=Consume a component value=] from |input|,
27702810
and append the result to |values|.
27712811

27722812

@@ -2777,7 +2817,7 @@ Consume a component value</h4>
27772817
To <dfn>consume a component value</dfn>
27782818
from a [=token stream=] |input|:
27792819

2780-
[=token stream/Process=] |input:
2820+
[=token stream/Process=] |input|:
27812821

27822822
: <a href="#tokendef-open-curly">&lt;{-token></a>
27832823
: <a href="#tokendef-open-square">&lt;[-token></a>

0 commit comments

Comments
 (0)