Skip to content

Commit f45ab4e

Browse files
committed
[css-syntax] Define <urange> in terms of tokens. The definition is looser than it originally was, which vastly simplifies the specification and recognition of the token, without harming use.
--HG-- extra : rebase_source : edbe8a3d5531121e48c0940a45641b261d702967
1 parent 26552c2 commit f45ab4e

File tree

2 files changed

+244
-48
lines changed

2 files changed

+244
-48
lines changed

css-syntax/Overview.bs

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2973,8 +2973,105 @@ The <<urange>> type</h3>
29732973
(using the <a href="http://www.w3.org/TR/css3-values/#value-defs">Value Definition Syntax in the Values & Units spec</a>) as:
29742974

29752975
<pre class="prod">
2976+
<<urange>> =
2977+
u '+' <<urange-codepoint>> |
2978+
u '+' <<urange-codepoint>>? '?'+ |
2979+
u '+' <<urange-codepoint>> <<negative-urange-codepoint>> |
2980+
u '+' <<urange-range>>
29762981
</pre>
29772982

2983+
where:
2984+
2985+
: <dfn><<urange-codepoint>></dfn>
2986+
:: One of the following:
2987+
* A <<number-token>> whose type flag is set to "integer" and whose representation is composed solely of <a>digits</a> (no leading "+" or "-" characters).
2988+
* An <<ident-token>> whose representation is solely <a>hex digits</a>.
2989+
* A <<dimension-token>> whose type flag is set to "integer" and whose unit is composed solely of <a>hex digits</a>
2990+
2991+
: <dfn><<negative-urange-codepoint>></dfn>
2992+
:: One of the following:
2993+
* A <<number-token>> whose type flag is set to "integer", and whose value is negative.
2994+
(If the implementation does not support <a href="https://en.wikipedia.org/wiki/Signed_zero">negative zero</a>,
2995+
then when the value is zero,
2996+
the implementation must additionally verify that the representation begins with U+002D HYPHEN-MINUS (-).)
2997+
* An <<ident-token>> whose representation is U+002D HYPHEN-MINUS, followed solely <a>hex digits</a>.
2998+
* A <<dimension-token>> whose type flag is set to "integer",
2999+
whose value is negative,
3000+
and whose unit is composed solely of <a>hex digits</a>.
3001+
(Same caveat as for <<number-token>> applies here.)
3002+
3003+
: <dfn><<urange-range>></dfn>
3004+
:: One of the following:
3005+
* An <<ident-token>> whose representation consists solely of
3006+
one or more <a>hex digits</a>,
3007+
followed by U+002D HYPHEN-MINUS (-),
3008+
followed by one or more <a>hex digits</a>.
3009+
* A <<dimension-token>> whose type flag is set to "integer",
3010+
and whose unit consists solely of
3011+
one or more <a>hex digits</a>,
3012+
followed by U+002D HYPHEN-MINUS (-),
3013+
followed by one or more <a>hex digits</a>.
3014+
3015+
In this production,
3016+
no whitespace can occur between any of the tokens.
3017+
3018+
The <<urange>> production represents a range of one or more contiguous unicode code points,
3019+
which are non-negative integers.
3020+
Each clause of the above grammar is interpreted as follows:
3021+
3022+
: <code>u '+' <<urange-codepoint>></code>
3023+
::
3024+
<a title="interpret a token as a hex integer">Interpret the &lt;urange-codepoint> as a hex integer</a>.
3025+
The <<urange>> represents a range consisting only of the resulting value.
3026+
3027+
: <code>u '+' <<urange-codepoint>>? '?'+</code>
3028+
::
3029+
If the <<urange-codepoint>> is specified,
3030+
let <var>B</var> be the result of <a title="interpret a token as a hex integer">interpreting the &lt;urange-codepoint> as a hex integer</a>;
3031+
otherwise, let <var>B</var> be zero.
3032+
Let <var>S</var> be the number of contiguous U+003F QUESTION MARK (?) codepoints.
3033+
3034+
The <<urange>> represents a contiguous range from
3035+
<code style="white-space: nowrap">B✕(16<sup>S</sup>)</code> to
3036+
<code style="white-space: nowrap">B✕(16<sup>S</sup>) + 16<sup>S+1</sup> − 1</code>,
3037+
inclusive.
3038+
3039+
: <code>u '+' <<urange-codepoint>> <<negative-urange-codepoint>></code>
3040+
::
3041+
Let <var>starting value</var> be the result of <a title="interpret a token as a hex integer">interpreting the &lt;urange-codepoint> as a hex integer</a>.
3042+
Let <var>ending value</var> be the negation of the result of <a title="interpret a token as a hex integer">interpreting the &lt;negative-urange-codepoint> as a hex integer</a>.
3043+
3044+
The <<urange>> represents a contiguous range from <var>starting value</var> to <var>ending value</var>, inclusive.
3045+
3046+
: <code>u '+' <<urange-range>></code>
3047+
::
3048+
Split the <<urange-range>>’s representation (or representation + unit)
3049+
into the two halves on either side of the U+002D HYPHEN-MINUS (-) codepoint.
3050+
Interpret each half as a hexadecimal integer.
3051+
3052+
The <<urange>> represents a contiguous range from the first half's value to the second half's value, inclusive.
3053+
3054+
To <dfn>interpret a token as a hex integer</dfn>:
3055+
3056+
* If the token is a <<number-token>> whose type flag is set to "integer",
3057+
interpret its representation as a hexadecimal number
3058+
and return the resulting value.
3059+
3060+
* If the token is an <<ident-token>> consisting solely of <a>hex digits</a>,
3061+
interpret its representation as a hexadecimal number
3062+
and return the resulting value.
3063+
3064+
* If the token is a <<dimension-token>> whose type flag is set to "integer"
3065+
and whose unit consists solely of <a>hex digits</a>,
3066+
concatenate its representation and its unit,
3067+
then interpret that as a hexadecimal number
3068+
and return the resulting value.
3069+
3070+
* Otherwise, the token can't be interpreted as a hex integer.
3071+
It is a specification error to reach this clause.
3072+
3073+
3074+
29783075

29793076
<!--
29803077
██████ ████████ ███ ██ ██ ██ ██ ███ ████████ ██████

0 commit comments

Comments
 (0)