Skip to content

Commit 875e992

Browse files
committed
[css-values-5] Added ability to upgrade commas to semicolons. w3c#9539
1 parent cae9002 commit 875e992

File tree

1 file changed

+100
-0
lines changed

1 file changed

+100
-0
lines changed

css-values-5/Overview.bs

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,106 @@ Textual Data Types</h2>
4848

4949
See [[css-values-4#textual-values]].
5050

51+
52+
<!-- Big Text: syntax
53+
54+
███▌ █ ▐▌ █ █▌ █████▌ ███▌ █ █
55+
█▌ █▌ ▐▌ █ █▌ █▌ █▌ ▐█ ▐█ █ █
56+
█▌ █ ▐▌ ██▌ █▌ █▌ █▌ █▌ █ █
57+
███▌ ▐▌█ █▌▐█ █▌ █▌ █▌ █▌ █
58+
█▌ █▌ █▌ ██▌ █▌ █████▌ █ █
59+
█▌ █▌ █▌ █▌ █▌ █▌ █▌ █▌ █ █
60+
███▌ █▌ █▌ ▐▌ █▌ █▌ █▌ █ █
61+
-->
62+
63+
<h2 id=value-defs>
64+
Value Definition Syntax</h2>
65+
66+
See [[css-values-4#value-defs]].
67+
68+
<h3 id=component-functions>
69+
Functional Notation Definitions</h3>
70+
71+
See [[css-values-4#component-functions]].
72+
73+
<h4 id=component-function-commas>
74+
Commas and Semicolons in Functions</h4>
75+
76+
[=Functional notation=] often uses commas
77+
to separate parts of its internal grammar.
78+
However, some functions
79+
(such as ''mix()'')
80+
allow values that, themselves,
81+
can contain commas.
82+
83+
To accommodate these sorts of grammars unambiguously,
84+
commas in functional grammars are <em>implicitly upgradeable</em> to semicolons in Level 5;
85+
that is,
86+
commas in a [=functional notation=]'s grammar
87+
can instead be represented as <<semicolon-token>>s.
88+
This is all-or-nothing:
89+
either every comma in the [=functional notation=] must be written as a semicolon,
90+
or none of them must be.
91+
When the [=functional notation=]’s arguments are parsed,
92+
initially commas in the grammar match only <<comma-token>>s;
93+
if a <<semicolon-token>> is encountered,
94+
then the [=functional notation=] is re-interpreted
95+
with all commas in the grammar replaced by <<semicolon-token>>s.
96+
97+
Commas contained in productions defined as <dfn>comma-containing productions</dfn>
98+
(such as <<any-value>> or <<whole-value>>)
99+
are not implicitly upgradeable.
100+
Even when a [=functional notation=] is being re-interpreted with semicolons,
101+
these productions end when a <<semicolon-token>> is encountered.
102+
103+
<div class="example">
104+
The following examples are both equivalent declarations:
105+
106+
<pre>
107+
list-style: toggle(disc, circle, square);
108+
list-style: toggle(disc; circle; square);
109+
</pre>
110+
111+
however, this is different (and invalid):
112+
113+
<pre>
114+
list-style: toggle(disc, circle; square);
115+
</pre>
116+
117+
because it represents toggling between two values
118+
(<css>disc, circle</css> and <css>square</css>)
119+
and <css>disc, circle</css> is not a valid 'list-style' value.
120+
121+
This ability is important,
122+
because sometimes [=functional notation=] arguments need to include commas.
123+
For example, in 'font-family':
124+
125+
<pre>
126+
font-family: random-item(Times, serif; Arial, sans-serif; Courier, monospace);
127+
</pre>
128+
129+
This randomly chooses one of three font-family lists:
130+
either ''Times, serif'', or ''Arial, sans-serif'', or ''Courier, monospace''.
131+
But if only single fonts were needed for each choice,
132+
commas <em>could</em> have been used to separate them:
133+
134+
<pre>
135+
font-family: random-item(serif, sans-serif, monospace);
136+
</pre>
137+
138+
</div>
139+
140+
[=Functional notations=] are serialized with commas (rather than semicolons) whenever possible.
141+
142+
The following generic productions are [=comma-containing productions=]:
143+
144+
* <<any-value>>
145+
* <<whole-value>>
146+
* <<declaration-value>>
147+
148+
Issue: The functions defined in this spec with semicolons in their grammar
149+
need fixing to just use commas, now.
150+
51151
<!-- Big Text: url
52152

53153
█▌ █▌ ████▌ █▌

0 commit comments

Comments
 (0)