Skip to content

Commit

Permalink
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 Jul 31, 2019
1 parent a68d129 commit fbab5da
Showing 1 changed file with 70 additions and 73 deletions.
143 changes: 70 additions & 73 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -10076,6 +10076,7 @@ <h2>Syntax</h2>
BinaryIntegerLiteral
OctalIntegerLiteral
HexIntegerLiteral
LegacyOctalIntegerLiteral

DecimalLiteral ::
DecimalIntegerLiteral `.` DecimalDigits? ExponentPart?
Expand All @@ -10085,6 +10086,7 @@ <h2>Syntax</h2>
DecimalIntegerLiteral ::
`0`
NonZeroDigit DecimalDigits?
NonOctalDecimalIntegerLiteral

DecimalDigits ::
DecimalDigit
Expand Down Expand Up @@ -10118,6 +10120,19 @@ <h2>Syntax</h2>
BinaryDigit :: one of
`0` `1`

NonOctalDecimalIntegerLiteral ::
`0` NonOctalDigit
LegacyOctalLikeDecimalIntegerLiteral NonOctalDigit
NonOctalDecimalIntegerLiteral DecimalDigit

LegacyOctalLikeDecimalIntegerLiteral ::
`0` OctalDigit
LegacyOctalLikeDecimalIntegerLiteral OctalDigit

LegacyOctalIntegerLiteral ::
`0` OctalDigit
LegacyOctalIntegerLiteral OctalDigit

OctalIntegerLiteral ::
`0o` OctalDigits
`0O` OctalDigits
Expand All @@ -10129,6 +10144,9 @@ <h2>Syntax</h2>
OctalDigit :: one of
`0` `1` `2` `3` `4` `5` `6` `7`

NonOctalDigit :: one of
`8` `9`

HexIntegerLiteral ::
`0x` HexDigits
`0X` HexDigits
Expand All @@ -10144,9 +10162,20 @@ <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-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. This value is determined in two steps: first, a mathematical value (MV) is derived from the literal; second, this mathematical value is rounded as described below.</p>
<ul>
Expand All @@ -10162,6 +10191,9 @@ <h1>Static Semantics: MV</h1>
<li>
The MV of <emu-grammar>NumericLiteral :: HexIntegerLiteral</emu-grammar> is the MV of |HexIntegerLiteral|.
</li>
<li>
The MV of <emu-grammar>NumericLiteral :: LegacyOctalIntegerLiteral</emu-grammar> is the MV of |LegacyOctalIntegerLiteral|.
</li>
<li>
The MV of <emu-grammar>DecimalLiteral :: DecimalIntegerLiteral `.`</emu-grammar> is the MV of |DecimalIntegerLiteral|.
</li>
Expand Down Expand Up @@ -10195,6 +10227,9 @@ <h1>Static Semantics: MV</h1>
<li>
The MV of <emu-grammar>DecimalIntegerLiteral :: NonZeroDigit DecimalDigits</emu-grammar> is (the MV of |NonZeroDigit| &times; 10<sub>ℝ</sub><sup>_n_</sup>) plus the MV of |DecimalDigits|, where _n_ is the mathematical integer number of code points in |DecimalDigits|.
</li>
<li>
The MV of <emu-grammar>DecimalIntegerLiteral :: NonOctalDecimalIntegerLiteral</emu-grammar> is the MV of |NonOctalDecimalIntegerLiteral|.
</li>
<li>
The MV of <emu-grammar>DecimalDigits :: DecimalDigit</emu-grammar> is the MV of |DecimalDigit|.
</li>
Expand Down Expand Up @@ -10238,10 +10273,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<sub>ℝ</sub>.
</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<sub>ℝ</sub>.
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<sub>ℝ</sub>.
</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<sub>ℝ</sub>.
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<sub>ℝ</sub>.
</li>
<li>
The MV of <emu-grammar>HexDigit :: `a`</emu-grammar> or of <emu-grammar>HexDigit :: `A`</emu-grammar> is 10<sub>ℝ</sub>.
Expand Down Expand Up @@ -10273,6 +10308,27 @@ <h1>Static Semantics: MV</h1>
<li>
The MV of <emu-grammar>BinaryDigits :: BinaryDigits BinaryDigit</emu-grammar> is (the MV of |BinaryDigits| &times; 2<sub>ℝ</sub>) plus the MV of |BinaryDigit|.
</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<sub>ℝ</sub>) plus the MV of |NonOctalDigit|.
</li>
<li>
The MV of <emu-grammar>NonOctalDecimalIntegerLiteral :: NonOctalDecimalIntegerLiteral DecimalDigit</emu-grammar> is (the MV of |NonOctalDecimalIntegerLiteral| times 10<sub>ℝ</sub>) 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<sub>ℝ</sub>) 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<sub>ℝ</sub>) plus the MV of |OctalDigit|.
</li>
<li>
The MV of <emu-grammar>OctalIntegerLiteral :: `0o` OctalDigits</emu-grammar> is the MV of |OctalDigits|.
</li>
Expand Down Expand Up @@ -23432,9 +23488,6 @@ <h1>Forbidden Extensions</h1>
<li>
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>.
</li>
<li>
|TemplateCharacter| must not be extended to include <emu-xref href="#prod-annexB-LegacyOctalEscapeSequence"></emu-xref> as defined in <emu-xref href="#sec-additional-syntax-string-literals"></emu-xref>.
</li>
Expand Down Expand Up @@ -39782,9 +39835,13 @@ <h1>Lexical Grammar</h1>
<emu-prodref name=BinaryIntegerLiteral></emu-prodref>
<emu-prodref name=BinaryDigits></emu-prodref>
<emu-prodref name=BinaryDigit></emu-prodref>
<emu-prodref name=NonOctalDecimalIntegerLiteral></emu-prodref>
<emu-prodref name=LegacyOctalLikeDecimalIntegerLiteral></emu-prodref>
<emu-prodref name=LegacyOctalIntegerLiteral></emu-prodref>
<emu-prodref name=OctalIntegerLiteral></emu-prodref>
<emu-prodref name=OctalDigits></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 @@ -40119,73 +40176,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
BinaryIntegerLiteral
OctalIntegerLiteral
HexIntegerLiteral
LegacyOctalIntegerLiteral

LegacyOctalIntegerLiteral ::
`0` OctalDigit
LegacyOctalIntegerLiteral OctalDigit

DecimalIntegerLiteral ::
`0`
NonZeroDigit DecimalDigits?
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 @@ -41429,7 +41426,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-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 |LegacyOctalIntegerLiteral|, nor extend the syntax of |DecimalIntegerLiteral| to include |NonOctalDecimalIntegerLiteral|.
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 |LegacyOctalEscapeSequence| as described in <emu-xref href="#sec-additional-syntax-string-literals"></emu-xref>.
Expand Down

0 comments on commit fbab5da

Please sign in to comment.