Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-128185: Align the grammar of the Decimal string constructor with float's #128315

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
25 changes: 13 additions & 12 deletions Doc/library/decimal.rst
Original file line number Diff line number Diff line change
Expand Up @@ -350,18 +350,19 @@ Decimal objects
*value* can be an integer, string, tuple, :class:`float`, or another :class:`Decimal`
object. If no *value* is given, returns ``Decimal('0')``. If *value* is a
string, it should conform to the decimal numeric string syntax after leading
and trailing whitespace characters, as well as underscores throughout, are removed::

sign ::= '+' | '-'
digit ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
indicator ::= 'e' | 'E'
digits ::= digit [digit]...
decimal-part ::= digits '.' [digits] | ['.'] digits
exponent-part ::= indicator [sign] digits
infinity ::= 'Infinity' | 'Inf'
nan ::= 'NaN' [digits] | 'sNaN' [digits]
numeric-value ::= decimal-part [exponent-part] | infinity
numeric-string ::= [sign] numeric-value | [sign] nan
and trailing whitespace characters, as well as underscores throughout, are removed:

.. productionlist:: decimal
sign: "+" | "-"
digit: "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
HarryLHW marked this conversation as resolved.
Show resolved Hide resolved
indicator: "e" | "E"
digits: (`digit` | "_")* `digit` (`digit` | "_")*
decimal_part: `digits` "." [`digits`] | ["."] `digits`
exponent_part: `indicator` [`sign`] `digits`
infinity: "Infinity" | "Inf"
nan: "NaN" [`digits`] | "sNaN" [`digits`]
numeric_value: `decimal_part` [`exponent_part`] | `infinity`
numeric_string: [`sign`] `numeric_value` | [`sign`] `nan`

Other Unicode decimal digits are also permitted where ``digit``
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you can reference grammar term instead. Though, this may add a conflict with #128323, so - you can include that change here as well.

appears above. These include decimal digits from various other
Expand Down
Loading