Skip to content

Commit

Permalink
Normative: Make B.1.1 "Numeric Literals" normative.
Browse files Browse the repository at this point in the history
(Part of Annex B reform, see PR tc39#1595.)
  • Loading branch information
jmdyck committed Jun 10, 2021
1 parent 28fb25e commit 85dfd1e
Showing 1 changed file with 70 additions and 72 deletions.
142 changes: 70 additions & 72 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -13975,6 +13975,7 @@ <h2>Syntax</h2>
DecimalBigIntegerLiteral
NonDecimalIntegerLiteral[+Sep]
NonDecimalIntegerLiteral[+Sep] BigIntLiteralSuffix
LegacyOctalIntegerLiteral

DecimalBigIntegerLiteral ::
`0` BigIntLiteralSuffix
Expand All @@ -13998,6 +13999,7 @@ <h2>Syntax</h2>
`0`
NonZeroDigit
NonZeroDigit NumericLiteralSeparator? DecimalDigits[+Sep]
NonOctalDecimalIntegerLiteral

DecimalDigits[Sep] ::
DecimalDigit
Expand Down Expand Up @@ -14042,9 +14044,25 @@ <h2>Syntax</h2>
OctalDigits[?Sep] OctalDigit
[+Sep] OctalDigits[+Sep] NumericLiteralSeparator OctalDigit

LegacyOctalIntegerLiteral ::
`0` OctalDigit
LegacyOctalIntegerLiteral OctalDigit

NonOctalDecimalIntegerLiteral ::
`0` NonOctalDigit
LegacyOctalLikeDecimalIntegerLiteral NonOctalDigit
NonOctalDecimalIntegerLiteral DecimalDigit

LegacyOctalLikeDecimalIntegerLiteral ::
`0` OctalDigit
LegacyOctalLikeDecimalIntegerLiteral OctalDigit

OctalDigit :: one of
`0` `1` `2` `3` `4` `5` `6` `7`

NonOctalDigit :: one of
`8` `9`

HexIntegerLiteral[Sep] ::
`0x` HexDigits[?Sep]
`0X` HexDigits[?Sep]
Expand All @@ -14061,9 +14079,21 @@ <h2>Syntax</h2>
<emu-note>
<p>For example: `3in` is an error and not the two input elements `3` and `in`.</p>
</emu-note>
<p>A conforming implementation, when processing strict mode code, must not extend, as described in <emu-xref href="#sec-additional-syntax-numeric-literals"></emu-xref>, the syntax of |NumericLiteral| to include <emu-xref href="#prod-annexB-LegacyOctalIntegerLiteral"></emu-xref>, nor extend the syntax of |DecimalIntegerLiteral| to include <emu-xref href="#prod-annexB-NonOctalDecimalIntegerLiteral"></emu-xref>.</p>

<emu-clause id="sec-static-semantics-mv">
<emu-clause id="sec-numeric-literals-early-errors">
<h1>Static Semantics: Early Errors</h1>
<emu-grammar>
NumericLiteral :: LegacyOctalIntegerLiteral

DecimalIntegerLiteral :: NonOctalDecimalIntegerLiteral
</emu-grammar>
<ul>
<li>It is a Syntax Error if the source code matching this production is strict mode code.</li>
</ul>
<emu-note>In non-strict code, this syntax is allowed, but deprecated.</emu-note>
</emu-clause>

<emu-clause id="sec-static-semantics-mv" oldids="sec-additional-syntax-numeric-literals-status-semantics">
<h1>Static Semantics: MV</h1>
<p>A numeric literal stands for a value of the Number type or the BigInt type.</p>
<ul>
Expand Down Expand Up @@ -14158,10 +14188,10 @@ <h1>Static Semantics: MV</h1>
The MV of <emu-grammar>DecimalDigit :: `7`</emu-grammar> or of <emu-grammar>NonZeroDigit :: `7`</emu-grammar> or of <emu-grammar>HexDigit :: `7`</emu-grammar> or of <emu-grammar>OctalDigit :: `7`</emu-grammar> is 7.
</li>
<li>
The MV of <emu-grammar>DecimalDigit :: `8`</emu-grammar> or of <emu-grammar>NonZeroDigit :: `8`</emu-grammar> or of <emu-grammar>HexDigit :: `8`</emu-grammar> is 8.
The MV of <emu-grammar>DecimalDigit :: `8`</emu-grammar> or of <emu-grammar>NonZeroDigit :: `8`</emu-grammar> or of <emu-grammar>NonOctalDigit :: `8`</emu-grammar> or of <emu-grammar>HexDigit :: `8`</emu-grammar> is 8.
</li>
<li>
The MV of <emu-grammar>DecimalDigit :: `9`</emu-grammar> or of <emu-grammar>NonZeroDigit :: `9`</emu-grammar> or of <emu-grammar>HexDigit :: `9`</emu-grammar> is 9.
The MV of <emu-grammar>DecimalDigit :: `9`</emu-grammar> or of <emu-grammar>NonZeroDigit :: `9`</emu-grammar> or of <emu-grammar>NonOctalDigit :: `9`</emu-grammar> or of <emu-grammar>HexDigit :: `9`</emu-grammar> is 9.
</li>
<li>
The MV of <emu-grammar>HexDigit :: `a`</emu-grammar> or of <emu-grammar>HexDigit :: `A`</emu-grammar> is 10.
Expand Down Expand Up @@ -14211,6 +14241,27 @@ <h1>Static Semantics: MV</h1>
<li>
The MV of <emu-grammar>OctalDigits :: OctalDigits NumericLiteralSeparator OctalDigit</emu-grammar> is (the MV of |OctalDigits| &times; 8) plus the MV of |OctalDigit|.
</li>
<li>
The MV of <emu-grammar>LegacyOctalIntegerLiteral :: `0` OctalDigit</emu-grammar> is the MV of |OctalDigit|.
</li>
<li>
The MV of <emu-grammar>LegacyOctalIntegerLiteral :: LegacyOctalIntegerLiteral OctalDigit</emu-grammar> is (the MV of |LegacyOctalIntegerLiteral| times 8) plus the MV of |OctalDigit|.
</li>
<li>
The MV of <emu-grammar>NonOctalDecimalIntegerLiteral :: `0` NonOctalDigit</emu-grammar> is the MV of |NonOctalDigit|.
</li>
<li>
The MV of <emu-grammar>NonOctalDecimalIntegerLiteral :: LegacyOctalLikeDecimalIntegerLiteral NonOctalDigit</emu-grammar> is (the MV of |LegacyOctalLikeDecimalIntegerLiteral| times 10) plus the MV of |NonOctalDigit|.
</li>
<li>
The MV of <emu-grammar>NonOctalDecimalIntegerLiteral :: NonOctalDecimalIntegerLiteral DecimalDigit</emu-grammar> is (the MV of |NonOctalDecimalIntegerLiteral| times 10) plus the MV of |DecimalDigit|.
</li>
<li>
The MV of <emu-grammar>LegacyOctalLikeDecimalIntegerLiteral :: `0` OctalDigit</emu-grammar> is the MV of |OctalDigit|.
</li>
<li>
The MV of <emu-grammar>LegacyOctalLikeDecimalIntegerLiteral :: LegacyOctalLikeDecimalIntegerLiteral OctalDigit</emu-grammar> is (the MV of |LegacyOctalLikeDecimalIntegerLiteral| times 10) plus the MV of |OctalDigit|.
</li>
<li>
The MV of <emu-grammar>HexIntegerLiteral :: `0x` HexDigits</emu-grammar> is the MV of |HexDigits|.
</li>
Expand Down Expand Up @@ -14239,6 +14290,10 @@ <h1>Static Semantics: NumericValue</h1>
<emu-alg>
1. Return the Number value that results from rounding the MV of |NonDecimalIntegerLiteral| as described below.
</emu-alg>
<emu-grammar>NumericLiteral :: LegacyOctalIntegerLiteral</emu-grammar>
<emu-alg>
1. Return the Number value that results from rounding the MV of |LegacyOctalIntegerLiteral| as described below.
</emu-alg>
<p>Once the exact MV for a numeric literal has been determined, it is then rounded to a value of the Number type. If the MV is 0, then the rounded value is *+0*<sub>𝔽</sub>; otherwise, the rounded value must be the Number value for the MV (as specified in <emu-xref href="#sec-ecmascript-language-types-number-type"></emu-xref>), unless the literal is a |DecimalLiteral| and the literal has more than 20 significant digits, in which case the Number value may be either the Number value for the MV of a literal produced by replacing each significant digit after the 20th with a `0` digit or the Number value for the MV of a literal produced by replacing each significant digit after the 20th with a `0` digit and then incrementing the literal at the 20th significant digit position. A digit is <em>significant</em> if it is not part of an |ExponentPart| and</p>
<ul>
<li>
Expand Down Expand Up @@ -24460,7 +24515,7 @@ <h1>Forbidden Extensions</h1>
The Syntactic Grammar must not be extended in any manner that allows the token `:` to immediately follow source text that matches the |BindingIdentifier| nonterminal symbol.
</li>
<li>
When processing strict mode code, the syntax of |NumericLiteral| must not be extended to include <emu-xref href="#prod-annexB-LegacyOctalIntegerLiteral"></emu-xref> and the syntax of |DecimalIntegerLiteral| must not be extended to include <emu-xref href="#prod-annexB-NonOctalDecimalIntegerLiteral"></emu-xref> as described in <emu-xref href="#sec-additional-syntax-numeric-literals"></emu-xref>.
When processing strict mode code, the syntax of |NumericLiteral| must not be extended to include |LegacyOctalIntegerLiteral| and the syntax of |DecimalIntegerLiteral| must not be extended to include |NonOctalDecimalIntegerLiteral| as described in <emu-xref href="#sec-literals-numeric-literals"></emu-xref>.
</li>
<li>
|TemplateCharacter| must not be extended to include <emu-xref href="#prod-annexB-LegacyOctalEscapeSequence"></emu-xref> or <emu-xref href="#prod-annexB-NonOctalDecimalEscapeSequence"></emu-xref> as defined in <emu-xref href="#sec-additional-syntax-string-literals"></emu-xref>.
Expand Down Expand Up @@ -41350,7 +41405,11 @@ <h1>Lexical Grammar</h1>
<emu-prodref name="BinaryDigit"></emu-prodref>
<emu-prodref name="OctalIntegerLiteral"></emu-prodref>
<emu-prodref name="OctalDigits"></emu-prodref>
<emu-prodref name="LegacyOctalIntegerLiteral"></emu-prodref>
<emu-prodref name="NonOctalDecimalIntegerLiteral"></emu-prodref>
<emu-prodref name="LegacyOctalLikeDecimalIntegerLiteral"></emu-prodref>
<emu-prodref name="OctalDigit"></emu-prodref>
<emu-prodref name="NonOctalDigit"></emu-prodref>
<emu-prodref name="HexIntegerLiteral"></emu-prodref>
<emu-prodref name="HexDigits"></emu-prodref>
<emu-prodref name="HexDigit"></emu-prodref>
Expand Down Expand Up @@ -41713,74 +41772,13 @@ <h1>Additional Syntax</h1>

<emu-annex id="sec-additional-syntax-numeric-literals">
<h1>Numeric Literals</h1>
<p>The syntax and semantics of <emu-xref href="#sec-literals-numeric-literals"></emu-xref> is extended as follows except that this extension is not allowed for strict mode code:</p>
<h2>Syntax</h2>
<emu-grammar type="definition">
NumericLiteral ::
DecimalLiteral
DecimalBigIntegerLiteral
NonDecimalIntegerLiteral[+Sep]
NonDecimalIntegerLiteral[+Sep] BigIntLiteralSuffix
LegacyOctalIntegerLiteral

LegacyOctalIntegerLiteral ::
`0` OctalDigit
LegacyOctalIntegerLiteral OctalDigit

DecimalIntegerLiteral ::
`0`
NonZeroDigit
NonZeroDigit NumericLiteralSeparator? DecimalDigits[+Sep]
NonOctalDecimalIntegerLiteral

NonOctalDecimalIntegerLiteral ::
`0` NonOctalDigit
LegacyOctalLikeDecimalIntegerLiteral NonOctalDigit
NonOctalDecimalIntegerLiteral DecimalDigit

LegacyOctalLikeDecimalIntegerLiteral ::
`0` OctalDigit
LegacyOctalLikeDecimalIntegerLiteral OctalDigit
<p>The following syntax from <emu-xref href="#sec-literals-numeric-literals"></emu-xref>, and its associated semantics, used to be normative optional:</p>
<emu-grammar>
NumericLiteral :: LegacyOctalIntegerLiteral

NonOctalDigit :: one of
`8` `9`
DecimalIntegerLiteral :: NonOctalDecimalIntegerLiteral
</emu-grammar>

<emu-annex id="sec-additional-syntax-numeric-literals-status-semantics">
<h1>Static Semantics</h1>
<ul>
<li>
The MV of <emu-grammar>LegacyOctalIntegerLiteral :: `0` OctalDigit</emu-grammar> is the MV of |OctalDigit|.
</li>
<li>
The MV of <emu-grammar>LegacyOctalIntegerLiteral :: LegacyOctalIntegerLiteral OctalDigit</emu-grammar> is (the MV of |LegacyOctalIntegerLiteral| times 8) plus the MV of |OctalDigit|.
</li>
<li>
The MV of <emu-grammar>DecimalIntegerLiteral :: NonOctalDecimalIntegerLiteral</emu-grammar> is the MV of |NonOctalDecimalIntegerLiteral|.
</li>
<li>
The MV of <emu-grammar>NonOctalDecimalIntegerLiteral :: `0` NonOctalDigit</emu-grammar> is the MV of |NonOctalDigit|.
</li>
<li>
The MV of <emu-grammar>NonOctalDecimalIntegerLiteral :: LegacyOctalLikeDecimalIntegerLiteral NonOctalDigit</emu-grammar> is (the MV of |LegacyOctalLikeDecimalIntegerLiteral| times 10) plus the MV of |NonOctalDigit|.
</li>
<li>
The MV of <emu-grammar>NonOctalDecimalIntegerLiteral :: NonOctalDecimalIntegerLiteral DecimalDigit</emu-grammar> is (the MV of |NonOctalDecimalIntegerLiteral| times 10) plus the MV of |DecimalDigit|.
</li>
<li>
The MV of <emu-grammar>LegacyOctalLikeDecimalIntegerLiteral :: `0` OctalDigit</emu-grammar> is the MV of |OctalDigit|.
</li>
<li>
The MV of <emu-grammar>LegacyOctalLikeDecimalIntegerLiteral :: LegacyOctalLikeDecimalIntegerLiteral OctalDigit</emu-grammar> is (the MV of |LegacyOctalLikeDecimalIntegerLiteral| times 10) plus the MV of |OctalDigit|.
</li>
<li>
The MV of <emu-grammar>NonOctalDigit :: `8`</emu-grammar> is 8.
</li>
<li>
The MV of <emu-grammar>NonOctalDigit :: `9`</emu-grammar> is 9.
</li>
</ul>
</emu-annex>
<p>and the productions for |LegacyOctalIntegerLiteral|, |NonOctalDecimalIntegerLiteral|, |LegacyOctalLikeDecimalIntegerLiteral|, and |NonOctalDigit|.</p>
</emu-annex>

<emu-annex id="sec-additional-syntax-string-literals">
Expand Down Expand Up @@ -43055,7 +43053,7 @@ <h1>The Strict Mode of ECMAScript</h1>
`implements`, `interface`, `let`, `package`, `private`, `protected`, `public`, `static`, and `yield` are reserved words within strict mode code. (<emu-xref href="#sec-keywords-and-reserved-words"></emu-xref>).
</li>
<li>
A conforming implementation, when processing strict mode code, must not extend, as described in <emu-xref href="#sec-additional-syntax-numeric-literals"></emu-xref>, the syntax of |NumericLiteral| to include <emu-xref href="#prod-annexB-LegacyOctalIntegerLiteral"></emu-xref>, nor extend the syntax of |DecimalIntegerLiteral| to include <emu-xref href="#prod-annexB-NonOctalDecimalIntegerLiteral"></emu-xref>.
A conforming implementation, when processing strict mode code, must disallow instances of the productions <emu-grammar>NumericLiteral :: LegacyOctalIntegerLiteral</emu-grammar> and <emu-grammar>DecimalIntegerLiteral :: NonOctalDecimalIntegerLiteral</emu-grammar>.
</li>
<li>
A conforming implementation, when processing strict mode code, may not extend the syntax of |EscapeSequence| to include <emu-xref href="#prod-annexB-LegacyOctalEscapeSequence"></emu-xref> or <emu-xref href="#prod-annexB-NonOctalDecimalEscapeSequence"></emu-xref> as described in <emu-xref href="#sec-additional-syntax-string-literals"></emu-xref>.
Expand Down

0 comments on commit 85dfd1e

Please sign in to comment.