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

Syntax

BinaryIntegerLiteral OctalIntegerLiteral HexIntegerLiteral + LegacyOctalIntegerLiteral DecimalLiteral :: DecimalIntegerLiteral `.` DecimalDigits? ExponentPart? @@ -10085,6 +10086,7 @@

Syntax

DecimalIntegerLiteral :: `0` NonZeroDigit DecimalDigits? + NonOctalDecimalIntegerLiteral DecimalDigits :: DecimalDigit @@ -10118,6 +10120,19 @@

Syntax

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 @@ -10129,6 +10144,9 @@

Syntax

OctalDigit :: one of `0` `1` `2` `3` `4` `5` `6` `7` + NonOctalDigit :: one of + `8` `9` + HexIntegerLiteral :: `0x` HexDigits `0X` HexDigits @@ -10144,9 +10162,20 @@

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

Static Semantics: MV

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.

    @@ -10162,6 +10191,9 @@

    Static Semantics: MV

  • The MV of NumericLiteral :: HexIntegerLiteral is the MV of |HexIntegerLiteral|.
  • +
  • + The MV of NumericLiteral :: LegacyOctalIntegerLiteral is the MV of |LegacyOctalIntegerLiteral|. +
  • The MV of DecimalLiteral :: DecimalIntegerLiteral `.` is the MV of |DecimalIntegerLiteral|.
  • @@ -10195,6 +10227,9 @@

    Static Semantics: MV

  • The MV of DecimalIntegerLiteral :: NonZeroDigit DecimalDigits is (the MV of |NonZeroDigit| × 10_n_) plus the MV of |DecimalDigits|, where _n_ is the mathematical integer number of code points in |DecimalDigits|.
  • +
  • + The MV of DecimalIntegerLiteral :: NonOctalDecimalIntegerLiteral is the MV of |NonOctalDecimalIntegerLiteral|. +
  • The MV of DecimalDigits :: DecimalDigit is the MV of |DecimalDigit|.
  • @@ -10238,10 +10273,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. @@ -10273,6 +10308,27 @@

    Static Semantics: MV

  • The MV of BinaryDigits :: BinaryDigits BinaryDigit is (the MV of |BinaryDigits| × 2) plus the MV of |BinaryDigit|.
  • +
  • + 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 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 OctalIntegerLiteral :: `0o` OctalDigits is the MV of |OctalDigits|.
  • @@ -23432,9 +23488,6 @@

    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 . -
  • |TemplateCharacter| must not be extended to include as defined in .
  • @@ -39782,9 +39835,13 @@

    Lexical Grammar

    + + + + @@ -40119,73 +40176,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 - 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 +

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

    @@ -41429,7 +41426,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 |LegacyOctalIntegerLiteral|, nor extend the syntax of |DecimalIntegerLiteral| to include |NonOctalDecimalIntegerLiteral|. + 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 |LegacyOctalEscapeSequence| as described in .