From 85dfd1e0b006f96344231b60f938b51cde3ef409 Mon Sep 17 00:00:00 2001 From: Michael Dyck Date: Wed, 31 Jul 2019 08:33:51 -0400 Subject: [PATCH] Normative: Make B.1.1 "Numeric Literals" normative. (Part of Annex B reform, see PR #1595.) --- spec.html | 142 +++++++++++++++++++++++++++--------------------------- 1 file changed, 70 insertions(+), 72 deletions(-) diff --git a/spec.html b/spec.html index a7388cd7969..b84bb362bd0 100644 --- a/spec.html +++ b/spec.html @@ -13975,6 +13975,7 @@

Syntax

DecimalBigIntegerLiteral NonDecimalIntegerLiteral[+Sep] NonDecimalIntegerLiteral[+Sep] BigIntLiteralSuffix + LegacyOctalIntegerLiteral DecimalBigIntegerLiteral :: `0` BigIntLiteralSuffix @@ -13998,6 +13999,7 @@

Syntax

`0` NonZeroDigit NonZeroDigit NumericLiteralSeparator? DecimalDigits[+Sep] + NonOctalDecimalIntegerLiteral DecimalDigits[Sep] :: DecimalDigit @@ -14042,9 +14044,25 @@

Syntax

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] @@ -14061,9 +14079,21 @@

Syntax

For example: `3in` is an error and not the two input elements `3` and `in`.

-

A conforming implementation, when processing strict mode code, must not extend, as described in , the syntax of |NumericLiteral| to include , nor extend the syntax of |DecimalIntegerLiteral| to include .

- + +

Static Semantics: Early Errors

+ + NumericLiteral :: LegacyOctalIntegerLiteral + + DecimalIntegerLiteral :: NonOctalDecimalIntegerLiteral + +
    +
  • It is a Syntax Error if the source code matching this production is strict mode code.
  • +
+ In non-strict code, this syntax is allowed, but deprecated. +
+ +

Static Semantics: MV

A numeric literal stands for a value of the Number type or the BigInt type.

    @@ -14158,10 +14188,10 @@

    Static Semantics: MV

    The MV of DecimalDigit :: `7` or of NonZeroDigit :: `7` or of HexDigit :: `7` or of OctalDigit :: `7` is 7.
  • - The MV of DecimalDigit :: `8` or of NonZeroDigit :: `8` or of HexDigit :: `8` is 8. + The MV of DecimalDigit :: `8` or of NonZeroDigit :: `8` or of NonOctalDigit :: `8` or of HexDigit :: `8` is 8.
  • - The MV of DecimalDigit :: `9` or of NonZeroDigit :: `9` or of HexDigit :: `9` is 9. + The MV of DecimalDigit :: `9` or of NonZeroDigit :: `9` or of NonOctalDigit :: `9` or of HexDigit :: `9` is 9.
  • The MV of HexDigit :: `a` or of HexDigit :: `A` is 10. @@ -14211,6 +14241,27 @@

    Static Semantics: MV

  • The MV of OctalDigits :: OctalDigits NumericLiteralSeparator OctalDigit is (the MV of |OctalDigits| × 8) plus the MV of |OctalDigit|.
  • +
  • + The MV of LegacyOctalIntegerLiteral :: `0` OctalDigit is the MV of |OctalDigit|. +
  • +
  • + The MV of LegacyOctalIntegerLiteral :: LegacyOctalIntegerLiteral OctalDigit is (the MV of |LegacyOctalIntegerLiteral| times 8) plus the MV of |OctalDigit|. +
  • +
  • + The MV of NonOctalDecimalIntegerLiteral :: `0` NonOctalDigit is the MV of |NonOctalDigit|. +
  • +
  • + The MV of NonOctalDecimalIntegerLiteral :: LegacyOctalLikeDecimalIntegerLiteral NonOctalDigit is (the MV of |LegacyOctalLikeDecimalIntegerLiteral| times 10) plus the MV of |NonOctalDigit|. +
  • +
  • + The MV of NonOctalDecimalIntegerLiteral :: NonOctalDecimalIntegerLiteral DecimalDigit is (the MV of |NonOctalDecimalIntegerLiteral| times 10) plus the MV of |DecimalDigit|. +
  • +
  • + The MV of LegacyOctalLikeDecimalIntegerLiteral :: `0` OctalDigit is the MV of |OctalDigit|. +
  • +
  • + The MV of LegacyOctalLikeDecimalIntegerLiteral :: LegacyOctalLikeDecimalIntegerLiteral OctalDigit is (the MV of |LegacyOctalLikeDecimalIntegerLiteral| times 10) plus the MV of |OctalDigit|. +
  • The MV of HexIntegerLiteral :: `0x` HexDigits is the MV of |HexDigits|.
  • @@ -14239,6 +14290,10 @@

    Static Semantics: NumericValue

    1. Return the Number value that results from rounding the MV of |NonDecimalIntegerLiteral| as described below. + NumericLiteral :: LegacyOctalIntegerLiteral + + 1. Return the Number value that results from rounding the MV of |LegacyOctalIntegerLiteral| as described below. +

    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*𝔽; otherwise, the rounded value must be the Number value for the MV (as specified in ), 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 significant if it is not part of an |ExponentPart| and

    • @@ -24460,7 +24515,7 @@

      Forbidden Extensions

      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.
    • - When processing strict mode code, the syntax of |NumericLiteral| must not be extended to include and the syntax of |DecimalIntegerLiteral| must not be extended to include as described in . + 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 .
    • |TemplateCharacter| must not be extended to include or as defined in . @@ -41350,7 +41405,11 @@

      Lexical Grammar

      + + + + @@ -41713,74 +41772,13 @@

      Additional Syntax

      Numeric Literals

      -

      The syntax and semantics of is extended as follows except that this extension is not allowed for strict mode code:

      -

      Syntax

      - - 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 +

      The following syntax from , and its associated semantics, used to be normative optional:

      + + NumericLiteral :: LegacyOctalIntegerLiteral - NonOctalDigit :: one of - `8` `9` + DecimalIntegerLiteral :: NonOctalDecimalIntegerLiteral - - -

      Static Semantics

      -
        -
      • - The MV of LegacyOctalIntegerLiteral :: `0` OctalDigit is the MV of |OctalDigit|. -
      • -
      • - The MV of LegacyOctalIntegerLiteral :: LegacyOctalIntegerLiteral OctalDigit is (the MV of |LegacyOctalIntegerLiteral| times 8) plus the MV of |OctalDigit|. -
      • -
      • - The MV of DecimalIntegerLiteral :: NonOctalDecimalIntegerLiteral is the MV of |NonOctalDecimalIntegerLiteral|. -
      • -
      • - The MV of NonOctalDecimalIntegerLiteral :: `0` NonOctalDigit is the MV of |NonOctalDigit|. -
      • -
      • - The MV of NonOctalDecimalIntegerLiteral :: LegacyOctalLikeDecimalIntegerLiteral NonOctalDigit is (the MV of |LegacyOctalLikeDecimalIntegerLiteral| times 10) plus the MV of |NonOctalDigit|. -
      • -
      • - The MV of NonOctalDecimalIntegerLiteral :: NonOctalDecimalIntegerLiteral DecimalDigit is (the MV of |NonOctalDecimalIntegerLiteral| times 10) plus the MV of |DecimalDigit|. -
      • -
      • - The MV of LegacyOctalLikeDecimalIntegerLiteral :: `0` OctalDigit is the MV of |OctalDigit|. -
      • -
      • - The MV of LegacyOctalLikeDecimalIntegerLiteral :: LegacyOctalLikeDecimalIntegerLiteral OctalDigit is (the MV of |LegacyOctalLikeDecimalIntegerLiteral| times 10) plus the MV of |OctalDigit|. -
      • -
      • - The MV of NonOctalDigit :: `8` is 8. -
      • -
      • - The MV of NonOctalDigit :: `9` is 9. -
      • -
      -
      +

      and the productions for |LegacyOctalIntegerLiteral|, |NonOctalDecimalIntegerLiteral|, |LegacyOctalLikeDecimalIntegerLiteral|, and |NonOctalDigit|.

      @@ -43055,7 +43053,7 @@

      The Strict Mode of ECMAScript

      `implements`, `interface`, `let`, `package`, `private`, `protected`, `public`, `static`, and `yield` are reserved words within strict mode code. ().
    • - A conforming implementation, when processing strict mode code, must not extend, as described in , the syntax of |NumericLiteral| to include , nor extend the syntax of |DecimalIntegerLiteral| to include . + A conforming implementation, when processing strict mode code, must disallow instances of the productions NumericLiteral :: LegacyOctalIntegerLiteral and DecimalIntegerLiteral :: NonOctalDecimalIntegerLiteral.
    • A conforming implementation, when processing strict mode code, may not extend the syntax of |EscapeSequence| to include or as described in .