You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: css-syntax-3/Overview.bs
+20-62Lines changed: 20 additions & 62 deletions
Original file line number
Diff line number
Diff line change
@@ -230,12 +230,30 @@ Error Handling</h3>
230
230
and seek forward until it finds a semicolon (or the end of the block).
231
231
It then starts fresh, trying to parse a declaration again.
232
232
233
-
<li>
233
+
<li id=autoclosing>
234
234
If the stylesheet ends while any rule, declaration, function, string, etc. are still open,
235
235
everything is automatically closed.
236
236
This doesn't make them invalid,
237
237
though they may be incomplete
238
238
and thus thrown away when they are verified against their grammar.
239
+
240
+
<div class='example'>
241
+
For example, the syntax of the ''translateX()'' function is:
242
+
243
+
<pre>translateX( <<translation-value>> )</pre>
244
+
245
+
However, the stylesheet may end with the function unclosed, like:
246
+
247
+
<pre>.foo { transform: translate(50px</pre>
248
+
249
+
The CSS parser parses this as a style rule containing one declaration,
250
+
whose value is a function named "translate".
251
+
This matches the above grammar,
252
+
even though the ending token didn't appear in the token stream,
253
+
because by the time the parser is finished,
254
+
the presence of the ending token is no longer possible to determine;
255
+
all you have is the fact that there's a block and a function.
256
+
</div>
239
257
</ul>
240
258
241
259
After each construct (declaration, style rule, at-rule) is parsed,
@@ -3444,67 +3462,7 @@ The <code><an+b></code> type</h3>
3444
3462
<h2 id='rule-defs'>
3445
3463
Defining Grammars for Rules and Other Values</h2>
3446
3464
3447
-
[[css-values-4#value-defs]] defines how to specify a grammar for properties.
3448
-
This section extends those definitions
3449
-
to also allow specifying a grammar for rules.
3450
-
3451
-
Non-terminals representing the entire grammar of an [=at-rule=]
3452
-
are written as an @ character followed by the at-rule's name,
3453
-
between <css><</css> and <css>></css>,
3454
-
e.g. <<@media>> to represent the ''@media'' rule.
3455
-
3456
-
The [[css-values-4#numeric-ranges|bracketed range notation]] can be used on
3457
-
any of the numeric token non-terminals.
3458
-
3459
-
Several types of tokens are written literally, without quotes:
3460
-
3461
-
<ul>
3462
-
<li><<ident-token>>s (such as <code>auto</code>, <code>disc</code>, etc), which are simply written as their value.
3463
-
<li><<at-keyword-token>>s, which are written as an @ character followed by the token's value, like <code>@media</code>.
3464
-
<li><<function-token>>s, which are written as the function name followed by a ( character, like <code>translate(</code>.
3465
-
<li>The <<colon-token>> (written as <code>:</code>), <<comma-token>> (written as <code>,</code>), <<semicolon-token>> (written as <code>;</code>), <a href="#tokendef-open-paren"><(-token></a>, <a href="#tokendef-close-paren"><)-token></a>, <a href="#tokendef-open-curly"><{-token></a>, and <a href="#tokendef-close-curly"><}-token></a>s.
3466
-
</ul>
3467
-
3468
-
Tokens match if their value is a match for the value defined in the grammar.
3469
-
Unless otherwise specified, all matches are <a>ASCII case-insensitive</a>.
3470
-
3471
-
Note: Although it is possible, with <a>escaping</a>,
3472
-
to construct an <<ident-token>> whose value ends with <code>(</code> or starts with <code>@</code>,
3473
-
such a tokens is not a <<function-token>> or an <<at-keyword-token>>
3474
-
and does not match corresponding grammar definitions.
3475
-
3476
-
<<delim-token>>s are written with their value enclosed in single quotes.
3477
-
For example, a <<delim-token>> containing the "+" <a>code point</a> is written as <code>'+'</code>.
3478
-
Similarly, the <a href="#tokendef-open-square"><[-token></a> and <a href="#tokendef-close-square"><]-token></a>s must be written in single quotes,
3479
-
as they're used by the syntax of the grammar itself to group clauses.
3480
-
<<whitespace-token>> is never indicated in the grammar;
3481
-
<<whitespace-token>>s are allowed before, after, and between any two tokens,
3482
-
unless explicitly specified otherwise in prose definitions.
3483
-
(For example, if the prelude of a rule is a selector,
3484
-
whitespace is significant.)
3485
-
3486
-
When defining a function or a block,
3487
-
the ending token must be specified in the grammar,
3488
-
but if it's not present in the eventual token stream,
3489
-
it still matches.
3490
-
3491
-
<div class='example'>
3492
-
For example, the syntax of the ''translateX()'' function is:
3493
-
3494
-
<pre>translateX( <<translation-value>> )</pre>
3495
-
3496
-
However, the stylesheet may end with the function unclosed, like:
3497
-
3498
-
<pre>.foo { transform: translate(50px</pre>
3499
-
3500
-
The CSS parser parses this as a style rule containing one declaration,
3501
-
whose value is a function named "translate".
3502
-
This matches the above grammar,
3503
-
even though the ending token didn't appear in the token stream,
3504
-
because by the time the parser is finished,
3505
-
the presence of the ending token is no longer possible to determine;
3506
-
all you have is the fact that there's a block and a function.
3507
-
</div>
3465
+
[[css-values-4#value-defs]] defines how to specify a grammar for properties and other CSS syntactic constructions.
3508
3466
3509
3467
<h3 id='block-contents'>
3510
3468
Defining Block Contents: the <<block-contents>>, <<declaration-list>>, <<qualified-rule-list>>, <<declaration-rule-list>>, and <<rule-list>> productions</h3>
0 commit comments