Skip to content

Commit 3cad55a

Browse files
committed
Align the grammar of the Decimal string constructor with float's
1 parent aeb9b65 commit 3cad55a

1 file changed

Lines changed: 13 additions & 12 deletions

File tree

Doc/library/decimal.rst

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -350,18 +350,19 @@ Decimal objects
350350
*value* can be an integer, string, tuple, :class:`float`, or another :class:`Decimal`
351351
object. If no *value* is given, returns ``Decimal('0')``. If *value* is a
352352
string, it should conform to the decimal numeric string syntax after leading
353-
and trailing whitespace characters, as well as underscores throughout, are removed::
354-
355-
sign ::= '+' | '-'
356-
digit ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
357-
indicator ::= 'e' | 'E'
358-
digits ::= digit [digit]...
359-
decimal-part ::= digits '.' [digits] | ['.'] digits
360-
exponent-part ::= indicator [sign] digits
361-
infinity ::= 'Infinity' | 'Inf'
362-
nan ::= 'NaN' [digits] | 'sNaN' [digits]
363-
numeric-value ::= decimal-part [exponent-part] | infinity
364-
numeric-string ::= [sign] numeric-value | [sign] nan
353+
and trailing whitespace characters are removed:
354+
355+
.. productionlist:: decimal
356+
sign: '+' | '-'
357+
digit: '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
358+
indicator: 'e' | 'E'
359+
digits: (`digit` | "_")* `digit` (`digit` | "_")*
360+
decimal-part: `digits` '.' [`digits`] | ['.'] `digits`
361+
exponent-part: indicator [sign] digits
362+
infinity: 'Infinity' | 'Inf'
363+
nan: 'NaN' [`digits`] | 'sNaN' [`digits`]
364+
numeric-value: `decimal-part` [`exponent-part`] | `infinity``
365+
numeric-string: [`sign`] `numeric-value` | [`sign`] `nan`
365366

366367
Other Unicode decimal digits are also permitted where ``digit``
367368
appears above. These include decimal digits from various other

0 commit comments

Comments
 (0)