Numeric Literals
Syntax
@@ -16251,6 +16251,7 @@ Syntax
DecimalBigIntegerLiteral
NonDecimalIntegerLiteral[+Sep]
NonDecimalIntegerLiteral[+Sep] BigIntLiteralSuffix
+ LegacyOctalIntegerLiteral
DecimalBigIntegerLiteral ::
`0` BigIntLiteralSuffix
@@ -16274,6 +16275,7 @@ Syntax
`0`
NonZeroDigit
NonZeroDigit NumericLiteralSeparator? DecimalDigits[+Sep]
+ NonOctalDecimalIntegerLiteral
DecimalDigits[Sep] ::
DecimalDigit
@@ -16318,9 +16320,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]
@@ -16337,9 +16355,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 Legacy.
+
+
+
Static Semantics: MV
A numeric literal stands for a value of the Number type or the BigInt type.
@@ -16410,7 +16440,7 @@ Static Semantics: MV
The MV of SignedInteger :: `-` DecimalDigits is the negative of the MV of |DecimalDigits|.
-
- The MV of DecimalDigit :: `0` or of HexDigit :: `0` or of OctalDigit :: `0` or of BinaryDigit :: `0` is 0.
+ The MV of DecimalDigit :: `0` or of HexDigit :: `0` or of OctalDigit :: `0` or of LegacyOctalEscapeSequence :: `0` or of BinaryDigit :: `0` is 0.
-
The MV of DecimalDigit :: `1` or of NonZeroDigit :: `1` or of HexDigit :: `1` or of OctalDigit :: `1` or of BinaryDigit :: `1` is 1.
@@ -16434,10 +16464,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.
@@ -16487,6 +16517,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|.
@@ -16515,6 +16566,10 @@ Static Semantics: NumericValue
1. Return 𝔽(MV of |NonDecimalIntegerLiteral|).
+ NumericLiteral :: LegacyOctalIntegerLiteral
+
+ 1. Return 𝔽(MV of |LegacyOctalIntegerLiteral|).
+
NumericLiteral :: NonDecimalIntegerLiteral BigIntLiteralSuffix
1. Return the BigInt value that represents the MV of |NonDecimalIntegerLiteral|.
@@ -16540,7 +16595,7 @@ Static Semantics: NumericValue
-
+
String Literals
A string literal is 0 or more Unicode code points enclosed in single or double quotes. Unicode code points may also be represented by an escape sequence. All code points may appear literally in a string literal except for the closing quote code points, U+005C (REVERSE SOLIDUS), U+000D (CARRIAGE RETURN), and U+000A (LINE FEED). Any code points may appear in the form of an escape sequence. String literals evaluate to ECMAScript String values. When generating these String values Unicode code points are UTF-16 encoded as defined in . Code points belonging to the Basic Multilingual Plane are encoded as a single code unit element of the string. All other code points are encoded as two code unit elements of the string.
@@ -16577,11 +16632,11 @@ Syntax
EscapeSequence ::
CharacterEscapeSequence
`0` [lookahead ∉ DecimalDigit]
+ LegacyOctalEscapeSequence
+ NonOctalDecimalEscapeSequence
HexEscapeSequence
UnicodeEscapeSequence
-
- A conforming implementation, when processing strict mode code, must not extend the syntax of |EscapeSequence| to include or as described in .
-
+
CharacterEscapeSequence ::
SingleEscapeCharacter
NonEscapeCharacter
@@ -16598,6 +16653,25 @@ Syntax
`x`
`u`
+ LegacyOctalEscapeSequence ::
+ `0` [lookahead ∈ {`8`, `9`}]
+ NonZeroOctalDigit [lookahead ∉ OctalDigit]
+ ZeroToThree OctalDigit [lookahead ∉ OctalDigit]
+ FourToSeven OctalDigit
+ ZeroToThree OctalDigit OctalDigit
+
+ NonZeroOctalDigit ::
+ OctalDigit but not `0`
+
+ ZeroToThree :: one of
+ `0` `1` `2` `3`
+
+ FourToSeven :: one of
+ `4` `5` `6` `7`
+
+ NonOctalDecimalEscapeSequence :: one of
+ `8` `9`
+
HexEscapeSequence ::
`x` HexDigit HexDigit
@@ -16613,7 +16687,26 @@ Syntax
<LF> and <CR> cannot appear in a string literal, except as part of a |LineContinuation| to produce the empty code points sequence. The proper way to include either in the String value of a string literal is to use an escape sequence such as `\\n` or `\\u000A`.
-
+
+ Static Semantics: Early Errors
+
+ EscapeSequence :: LegacyOctalEscapeSequence
+
+ EscapeSequence :: NonOctalDecimalEscapeSequence
+
+
+ - It is a Syntax Error if the source code matching this production is strict mode code.
+
+ In non-strict code, this syntax is Legacy.
+
+ It is possible for string literals to precede a Use Strict Directive that places the enclosing code in strict mode, and implementations must take care to enforce the above rules for such literals. For example, the following source text contains a Syntax Error:
+
+ function invalid() { "\7"; "use strict"; }
+
+
+
+
+
Static Semantics: SV
A string literal stands for a value of the String type. SV produces String values for string literals through recursive application on the various parts of the string literal. As part of this process, some Unicode code points within the string literal are interpreted as having a mathematical value, as described below or in .
@@ -16810,6 +16903,15 @@ Static Semantics: SV
-
The SV of NonEscapeCharacter :: SourceCharacter but not one of EscapeCharacter or LineTerminator is the result of performing UTF16EncodeCodePoint on the code point value of |SourceCharacter|.
+ -
+ The SV of EscapeSequence :: LegacyOctalEscapeSequence is the String value consisting of the code unit whose value is the MV of |LegacyOctalEscapeSequence|.
+
+ -
+ The SV of NonOctalDecimalEscapeSequence :: `8` is the String value consisting of the code unit 0x0038 (DIGIT EIGHT).
+
+ -
+ The SV of NonOctalDecimalEscapeSequence :: `9` is the String value consisting of the code unit 0x0039 (DIGIT NINE).
+
-
The SV of HexEscapeSequence :: `x` HexDigit HexDigit is the String value consisting of the code unit whose value is the MV of |HexEscapeSequence|.
@@ -16819,12 +16921,48 @@ Static Semantics: SV
-
The SV of UnicodeEscapeSequence :: `u{` CodePoint `}` is the result of performing UTF16EncodeCodePoint on the MV of |CodePoint|.
+ -
+ The SV of TemplateEscapeSequence :: `0` is the String value consisting of the code unit 0x0000 (NULL).
+
Static Semantics: MV
+ -
+ The MV of LegacyOctalEscapeSequence :: ZeroToThree OctalDigit is (8 times the MV of |ZeroToThree|) plus the MV of |OctalDigit|.
+
+ -
+ The MV of LegacyOctalEscapeSequence :: FourToSeven OctalDigit is (8 times the MV of |FourToSeven|) plus the MV of |OctalDigit|.
+
+ -
+ The MV of LegacyOctalEscapeSequence :: ZeroToThree OctalDigit OctalDigit is (64 (that is, 82) times the MV of |ZeroToThree|) plus (8 times the MV of the first |OctalDigit|) plus the MV of the second |OctalDigit|.
+
+ -
+ The MV of ZeroToThree :: `0` is 0.
+
+ -
+ The MV of ZeroToThree :: `1` is 1.
+
+ -
+ The MV of ZeroToThree :: `2` is 2.
+
+ -
+ The MV of ZeroToThree :: `3` is 3.
+
+ -
+ The MV of FourToSeven :: `4` is 4.
+
+ -
+ The MV of FourToSeven :: `5` is 5.
+
+ -
+ The MV of FourToSeven :: `6` is 6.
+
+ -
+ The MV of FourToSeven :: `7` is 7.
+
-
The MV of HexEscapeSequence :: `x` HexDigit HexDigit is (16 times the MV of the first |HexDigit|) plus the MV of the second |HexDigit|.
@@ -16945,12 +17083,18 @@ Syntax
TemplateCharacter ::
`$` [lookahead != `{`]
- `\` EscapeSequence
+ `\` TemplateEscapeSequence
`\` NotEscapeSequence
LineContinuation
LineTerminatorSequence
SourceCharacter but not one of ``` or `\` or `$` or LineTerminator
+ TemplateEscapeSequence ::
+ CharacterEscapeSequence
+ `0` [lookahead ∉ DecimalDigit]
+ HexEscapeSequence
+ UnicodeEscapeSequence
+
NotEscapeSequence ::
`0` DecimalDigit
DecimalDigit but not `0`
@@ -16970,7 +17114,6 @@ Syntax
CodePoint ::
HexDigits[~Sep] [> but only if MV of |HexDigits| ≤ 0x10FFFF]
- A conforming implementation must not use the extended definition of |EscapeSequence| described in when parsing a |TemplateCharacter|.
|TemplateSubstitutionTail| is used by the |InputElementTemplateTail| alternative lexical goal.
@@ -17001,7 +17144,7 @@ Static Semantics: TV
The TV of TemplateCharacter :: `$` is the String value consisting of the code unit 0x0024 (DOLLAR SIGN).
- The TV of TemplateCharacter :: `\` EscapeSequence is the SV of |EscapeSequence|.
+ The TV of TemplateCharacter :: `\` TemplateEscapeSequence is the SV of |TemplateEscapeSequence|.
The TV of TemplateCharacter :: `\` NotEscapeSequence is *undefined*.
@@ -17041,13 +17184,13 @@ Static Semantics: TRV
The TRV of TemplateCharacter :: `$` is the String value consisting of the code unit 0x0024 (DOLLAR SIGN).
- The TRV of TemplateCharacter :: `\` EscapeSequence is the string-concatenation of the code unit 0x005C (REVERSE SOLIDUS) and the TRV of |EscapeSequence|.
+ The TRV of TemplateCharacter :: `\` TemplateEscapeSequence is the string-concatenation of the code unit 0x005C (REVERSE SOLIDUS) and the TRV of |TemplateEscapeSequence|.
The TRV of TemplateCharacter :: `\` NotEscapeSequence is the string-concatenation of the code unit 0x005C (REVERSE SOLIDUS) and the TRV of |NotEscapeSequence|.
- The TRV of EscapeSequence :: `0` is the String value consisting of the code unit 0x0030 (DIGIT ZERO).
+ The TRV of TemplateEscapeSequence :: `0` is the String value consisting of the code unit 0x0030 (DIGIT ZERO).
The TRV of NotEscapeSequence :: `0` DecimalDigit is the string-concatenation of the code unit 0x0030 (DIGIT ZERO) and the TRV of |DecimalDigit|.
@@ -17126,7 +17269,7 @@ Static Semantics: TRV
- TV excludes the code units of |LineContinuation| while TRV includes them. <CR><LF> and <CR> |LineTerminatorSequence|s are normalized to <LF> for both TV and TRV. An explicit |EscapeSequence| is needed to include a <CR> or <CR><LF> sequence.
+ TV excludes the code units of |LineContinuation| while TRV includes them. <CR><LF> and <CR> |LineTerminatorSequence|s are normalized to <LF> for both TV and TRV. An explicit |TemplateEscapeSequence| is needed to include a <CR> or <CR><LF> sequence.