From b45e4463512ef9c397c8ad29fac7b7e232232235 Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Fri, 11 Sep 2026 16:54:24 -0400 Subject: [PATCH] Normative: Add initial spec text Closes #3 Ref https://github.com/tc39/ecma262/pull/3857 --- package.json | 2 +- spec.emu | 233 ++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 204 insertions(+), 31 deletions(-) diff --git a/package.json b/package.json index 2a5c3ae..7b7c9ee 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "license": "MIT", "devDependencies": { "@tc39/ecma262-biblio": "^2.1.2895", - "ecmarkup": "^21.3.0", + "ecmarkup": "^25.0.0", "jsdom": "^26.1.0", "parse5-html-rewriting-stream": "^7.1.0", "tmp": "^0.2.3" diff --git a/spec.emu b/spec.emu index 5d05685..f52d570 100644 --- a/spec.emu +++ b/spec.emu @@ -1,39 +1,212 @@ - +
-title: Proposal Title Goes Here
-stage: -1
-contributors: Your Name(s) Here
+title: Bigint from exponential
+status: proposal
+stage: 1
+shortname: <a href="https://github.com/tc39/proposal-bigint-from-exponential">proposal-bigint-from-exponential</a>
+contributors: Richard Gibson
 
+ - -

This is an emu-clause

-

This is an algorithm:

- - 1. Let _proposal_ be *undefined*. - 1. If IsAccepted(_proposal_) is *true*, then - 1. Let _stage_ be *0*ℤ. - 1. Else, - 1. Let _stage_ be *-1*ℤ. - 1. Return ? ToString(_stage_). - -
+ +

Abstract Operations

+ + +

Type Conversion

+ + +

+ ToNumber ( + _arg_: an ECMAScript language value, + ): either a normal completion containing a Number or a throw completion +

+
+
description
+
It converts _arg_ to a value of type Number.
+
+ + +

ToNumber Applied to the String Type

+

The abstract operation StringToNumber specifies how to convert a String value to a Number value, using the following grammar.

+

Syntax

+ + StringNumericLiteral ::: + StrWhiteSpace? + StrWhiteSpace? StrNumericLiteral StrWhiteSpace? + + StrWhiteSpace ::: + StrWhiteSpaceChar StrWhiteSpace? + + StrWhiteSpaceChar ::: + WhiteSpace + LineTerminator + + StrNumericLiteral ::: + StrDecimalLiteral + NonDecimalIntegerLiteral[~Sep] + + StrDecimalLiteral ::: + StrUnsignedDecimalLiteral + `+` StrUnsignedDecimalLiteral + `-` StrUnsignedDecimalLiteral + + StrUnsignedDecimalLiteral ::: + `Infinity` + DecimalDigits[~Sep] `.` DecimalDigits[~Sep]? ExponentPart[~Sep]? + `.` DecimalDigits[~Sep] ExponentPart[~Sep]? + DecimalDigits[~Sep] ExponentPart[~Sep]? + +

All grammar symbols not explicitly defined above have the definitions used in the Lexical Grammar for numeric literals ()

+ +

Some differences should be noted between the syntax of a |StringNumericLiteral| and a |NumericLiteral|:

+
    +
  • + A |StringNumericLiteral| may include leading and/or trailing white space and/or line terminators. +
  • +
  • + A |StringNumericLiteral| that is decimal may have any number of leading `0` digits. +
  • +
  • + A |StringNumericLiteral| that is decimal may include a `+` or `-` to indicate its sign. +
  • +
  • + A |StringNumericLiteral| that is empty or contains only white space is converted to *+0*𝔽. +
  • +
  • + `Infinity` and `-Infinity` are recognized as a |StringNumericLiteral| but not as a |NumericLiteral|. +
  • +
  • + A |StringNumericLiteral| cannot include a |BigIntLiteralSuffix|. +
  • +
  • + A |StringNumericLiteral| cannot include a |NumericLiteralSeparator|. +
  • +
+
+ + +

+ StringToNumber ( + _string_: a String, + ): a Number +

+
+
+ + 1. Let _literal_ be ParseText(_string_, |StringNumericLiteral|). + 1. If _literal_ is a List of errors, return *NaN*. + 1. Return the StringNumericValue of _literal_. + +
- -

- IsAccepted ( - _proposal_: an ECMAScript language value - ): a Boolean -

-
-
description
-
Tells you if the proposal was accepted
-
- - 1. If _proposal_ is not a String, or is not accepted, return *false*. - 1. Return *true*. - + + + +

Runtime Semantics: MV

+
    +
  • + The MV of StringNumericLiteral ::: StrWhiteSpace? is 0. +
  • +
  • + The MV of StringNumericLiteral ::: StrWhiteSpace? StrNumericLiteral StrWhiteSpace? is the MV of |StrNumericLiteral|. +
  • +
  • + The MV of StrDecimalLiteral ::: `-` StrUnsignedDecimalLiteral is the negative of the MV of |StrUnsignedDecimalLiteral|. +
  • +
  • + The MV of StrUnsignedDecimalLiteral ::: `Infinity` is +∞. +
  • +
  • + The MV of StrUnsignedDecimalLiteral ::: DecimalDigits ExponentPart? is the MV of |DecimalDigits| × 10_e_, where _e_ is the MV of |ExponentPart| if |ExponentPart| is present and otherwise is 0. +
  • +
  • + The MV of StrUnsignedDecimalLiteral ::: `.` DecimalDigits ExponentPart? is the MV of |DecimalDigits| × 10_e_ - _n_, where _n_ is the number of code points in |DecimalDigits| and _e_ is the MV of |ExponentPart| if |ExponentPart| is present and otherwise is 0. +
  • +
  • + The MV of StrUnsignedDecimalLiteral ::: DecimalDigits `.` DecimalDigits? ExponentPart? is (the MV of the first |DecimalDigits| plus (_f_ × 10-_n_)) × 10_e_, where _f_ is the MV of the second |DecimalDigits| if the second |DecimalDigits| is present and otherwise is 0, _n_ is the number of code points in the second |DecimalDigits| if the second |DecimalDigits| is present and otherwise is 0, and _e_ is the MV of |ExponentPart| if |ExponentPart| is present and otherwise is 0. +
  • +
+
+
+
+
+ + +

+ StringToBigInt ( + _string_: a String, + ): a BigInt or *undefined* +

+
+
+ + 1. Let _literal_ be ParseText(_string_, |StringIntegerLiteral||StringNumericLiteral|). + 1. If _literal_ is a List of errors, return *undefined*. + 1. Let _mv_ be the MV of _literal_. + 1. Assert: _mv_ is an integer. + 1. If _mv_ is not an integer, return *undefined*. + 1. Return ℤ(_mv_). + + + + + +

StringIntegerLiteral Grammar

+

StringToBigInt uses the following grammar.

+

Syntax

+ + StringIntegerLiteral ::: + StrWhiteSpace? + StrWhiteSpace? StrIntegerLiteral StrWhiteSpace? + + StrIntegerLiteral ::: + SignedInteger[~Sep] + NonDecimalIntegerLiteral[~Sep] + +
+
+ + + + +

Runtime Semantics: MV

+
    +
  • + The MV of StringIntegerLiteral ::: StrWhiteSpace? is 0. +
  • +
  • + The MV of StringIntegerLiteral ::: StrWhiteSpace? StrIntegerLiteral StrWhiteSpace? is the MV of |StrIntegerLiteral|. +
  • +
+
+
+
+
+ + +

Grammar Summary

+ + +

Number Conversions

+ + + + + + +

All grammar symbols not explicitly defined by the |StringNumericLiteral| grammar have the definitions used in the Lexical Grammar for numeric literals.

+ + + + +
+