Skip to content

Commit e6c2963

Browse files
committed
[css-values-5][css-mixins-1] Exclude : from first if() production. Rename 'comma-containing production' to 'free-form production', slightly rework definition to be clearer. #12487
1 parent bc3a07f commit e6c2963

File tree

2 files changed

+39
-24
lines changed

2 files changed

+39
-24
lines changed

css-mixins-1/Overview.bs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -488,8 +488,8 @@ is the real element at the root of the [=calling context=] stack.
488488
</wpt>
489489

490490
<div class='example'>
491-
A [=comma-containing productions|comma-containing value=]
492-
may be passed as a single argument
491+
A [=free-form production|comma-containing value=]
492+
can be passed as a single argument
493493
by wrapping the value in curly braces, <code>{}</code>:
494494

495495
<pre class='lang-css'>
@@ -2617,7 +2617,7 @@ given a <<declaration-value>> |argument|:
26172617

26182618
<div class=note>
26192619
See [[css-values-5#component-function-commas]] for more information
2620-
on [=comma-containing productions=].
2620+
on [=free-form productions=].
26212621
</div>
26222622
</div>
26232623

css-values-5/Overview.bs

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -122,33 +122,42 @@ Functional Notation Definitions</h3>
122122
Commas in Function Arguments</h4>
123123

124124
[=Functional notation=] often uses commas
125-
to separate parts of its internal grammar.
125+
to separate parts of its internal grammar,
126+
and occasionally other syntax
127+
(such as <code>:</code> or <code>;</code> in ''if()'').
126128
However, some functions
127129
(such as ''mix()'')
128130
allow values that, themselves,
129-
can contain commas.
131+
could contain these argument-separating tokens.
130132
These values
131133
(currently <<whole-value>>, <<declaration-value>>, and <<any-value>>)
132-
are <dfn export>comma-containing productions</dfn>.
134+
are <dfn export>free-form productions</dfn>.
133135

134136
To accommodate these sorts of grammars unambiguously,
135-
the [=comma-containing productions=] can be optionally wrapped in curly braces {}.
136-
These braces are syntactic, not part of the actual value.
137-
Specifically:
138-
139-
* A [=comma-containing production=] can either start with a "{" token, or not.
140-
* If it does not start with a "{" token,
141-
then it cannot contain commas or {} blocks,
142-
in addition to whatever specific restrictions it defines for itself.
137+
the [=free-form productions=] can be optionally wrapped in curly braces {}.
138+
These braces are syntactic, not part of the actual value,
139+
and only serve to explicitly indicate the bounds of the production.
140+
A [=free-form production=] can either
141+
(after optional whitespace)
142+
start with a <<{-token>>, or not:
143+
144+
: If it does not start with a "{" token
145+
::
146+
The production does not match any top-level commas or {} blocks.
143147
(The production stops parsing at that point,
144148
so the comma or {} block is matched by the next grammar term instead;
145149
probably the function's own argument-separating comma.)
146-
* If it does start with a "{" token,
147-
then the production matches just the {} block that the "{" token opens.
150+
Individual usages of the production can define additional tokens
151+
that are similarly restricted from matching at the top-level.
152+
: If it does start with a "{" token
153+
::
154+
The production matches just the {} block that the "{" token opens.
148155
It represents the <em>contents</em> of that block,
149-
and applies whatever specific restrictions it defines for itself
150-
to those contents,
151-
ignoring the {} block wrapper.
156+
ignoring the {} block wrapper itself.
157+
158+
Note: General restrictions defined for a particular [=free-form production=],
159+
like <<declaration-value>> not matching <<semicolon-token>>s,
160+
apply regardless of whether it's {}-wrapped or not.
152161

153162
<div class="example">
154163
For example, the grammar of the ''random-item()'' function is:
@@ -194,7 +203,7 @@ Commas in Function Arguments</h4>
194203
either ''Times, serif'', or ''sans-serif'', or ''monospace''.
195204

196205
However, this {}-wrapping is <em>only</em> allowed for some function arguments--
197-
those defined as [=comma-containing productions=].
206+
those defined as [=free-form productions=].
198207
It's not valid for any other productions;
199208
if you use {} around other function arguments,
200209
it'll just fail to match the function's grammar
@@ -217,24 +226,24 @@ Commas in Function Arguments</h4>
217226

218227
[=Functional notations=] are serialized without {} wrappers whenever possible.
219228

220-
The following generic productions are [=comma-containing productions=]:
229+
The following generic productions are [=free-form productions=]:
221230

222231
* <<any-value>>
223232
* <<whole-value>>
224233
* <<declaration-value>>
225234

226235
For legacy compat reasons,
227236
the <<declaration-value>> defined for the fallback value of ''var()''
228-
is a <dfn export>non-strict comma-containing production</dfn>.
237+
is a <dfn export>non-strict free-form production</dfn>.
229238
It ignores the rules restricting what it can contain
230239
when it does not start with a "{" token:
231240
it is allowed to contain commas and {} blocks.
232-
It still follows the standard [=comma-containing production=] rules
241+
It still follows the standard [=free-form production=] rules
233242
when it <em>does</em> start with a "{" token, however:
234243
the fallback is just the contents of the {} block,
235244
and doesn't include the {} wrapper itself.
236245

237-
Other contexts <em>may</em> define that they use [=non-strict comma-containing productions=],
246+
Other contexts <em>may</em> define that they use [=non-strict free-form productions=],
238247
but it <em>should</em> be avoided unless necessary.
239248

240249
<h3 id=boolean>
@@ -1605,6 +1614,12 @@ Conditional Value Selection: the ''if()'' notation</h3>
16051614
<dfn><<if-args-branch>></dfn> = <<declaration-value>> : <<declaration-value>>?
16061615
</pre>
16071616

1617+
In the above <<if-args-branch>> production,
1618+
the first <<declaration-value>>
1619+
excludes top-level <<colon-token>>s
1620+
as part of its [=free-form production=] restrictions
1621+
(alongside commas and curly braces).
1622+
16081623
<div algorithm>
16091624
To <dfn export>[=replace an arbitrary substitution function|replace an if() function=]</dfn>,
16101625
given a list of |arguments|:

0 commit comments

Comments
 (0)