Repository navigation
Closed
Labels
docsDocumentation in the Doc dir
Description
Documentation
The floating point syntax spec is incorrect, and can be found in /Doc/library/functions.rst:
The syntax rendered currently is the following:
sign ::= "+" | "-"
infinity ::= "Infinity" | "inf"
nan ::= "nan"
digitpart ::= `!digit` (["_"] `!digit`)*
number ::= [digitpart] "." digitpart | digitpart ["."]
exponent ::= ("e" | "E") ["+" | "-"] digitpart
floatnumber ::= number [exponent]
floatvalue ::= [sign] (floatnumber | infinity | nan)digitpart should not include an exclamation point or backtick quotes. The backticks appear to be the underlying syntax failing to render, but the exclamation points have a meaning, which is an issue. This is the underlying syntax:
sign: "+" | "-"
infinity: "Infinity" | "inf"
nan: "nan"
digitpart: `!digit` (["_"] `!digit`)*
number: [`digitpart`] "." `digitpart` | `digitpart` ["."]
exponent: ("e" | "E") ["+" | "-"] `digitpart`
floatnumber: number [`exponent`]EBNF includes a "Special Sequences" syntax, that would be appropriate for this situation, but I'm uncertain if it is possible to use in the underlying YAML format. It should be rendered like this:
sign ::= "+" | "-"
infinity ::= "Infinity" | "inf"
nan ::= "nan"
digit ::= ? Any character in the unicode digit class ?
digitpart ::= digit (["_"] digit)*
number ::= [digitpart] "." digitpart | digitpart ["."]
exponent ::= ("e" | "E") ["+" | "-"] digitpart
floatnumber ::= number [exponent]
floatvalue ::= [sign] (floatnumber | infinity | nan)Linked PRs
- gh-114070: correct the specification of
digitin the float() docs #114080 - [3.12] gh-114070: correct the specification of
digitin the float() docs (GH-114080) #114094 - [3.11] gh-114070: correct the specification of
digitin the float() docs (GH-114080) #114095 - gh-114070: fix token reference warnings in expressions.rst #114169
- [3.12] gh-114070: fix token reference warnings in expressions.rst (GH-114169) #114192
- [3.11] gh-114070: fix token reference warnings in expressions.rst (GH-114169) #114193
Metadata
Metadata
Assignees
Labels
docsDocumentation in the Doc dir
Activity
skirpichev commentedon Jan 15, 2024
In other places - angle brackets are used to surround RHS's of digit-like definitions. For example:
hugovk commentedon Jan 15, 2024
This one has a clickable
digitlink, which takes us to:In YAML:
Would it be appropriate to add something like that here?
skirpichev commentedon Jan 15, 2024
@hugovk, no - that will be incorrect in this case. This is valid, for example, in case of floating-point literals.
But the
float()constructor (int()too) supports more (not sure for good or evil): "Here digit is a Unicode decimal digit (character in the Unicode general category Nd)." (c)For example:
hugovk commentedon Jan 15, 2024
OK, then shall we use angle brackets here?
skirpichev commentedon Jan 15, 2024
I think so. The documentation says it's using "a modified Backus–Naur form (BNF) grammar notation", where: "A phrase between angular brackets (<...>) gives an informal description of the symbol defined; e.g., this could be used to describe the notion of ‘control character’ if needed."
hauntsaninja commentedon Jan 15, 2024
I think the markup got regressed in https://github.com/python/cpython/pull/112669/files#diff-6a7a07ac473fdd76734669b1b70626ad2176011129902f6add017810f54d0439L667
I improved the grammar here in #100437 , let me know if there's anything I can help with. Moving the description of
digitinto angle brackets within the grammar rule sounds reasonable to me.pythongh-114070: correct the specification of ``digit`` in the float(…
skirpichev commentedon Jan 15, 2024
@hauntsaninja, see #114080
gh-114070: correct the specification of ``digit`` in the float() docs (…
pythongh-114070: correct the specification of ``digit`` in the float(…
pythongh-114070: correct the specification of ``digit`` in the float(…
[3.12] gh-114070: correct the specification of ``digit`` in the float…
[3.11] gh-114070: correct the specification of ``digit`` in the float…
hauntsaninja commentedon Jan 15, 2024
Thanks knotapun, skirpichev and hugovk!!
hugovk commentedon Jan 16, 2024
Yes, thanks!
If people are interested, there's some other
productionlistitems that are causing token reference warnings that need fixing one way or another:make -C Doc html SPHINXERRORHANDLING=-n SOURCES="reference/compound_stmts.rst reference/expressions.rst"pythongh-114070: fix token reference warnings in expressions.rst
gh-114070: fix token reference warnings in expressions.rst (#114169)
pythongh-114070: fix token reference warnings in expressions.rst (pyt…
pythongh-114070: fix token reference warnings in expressions.rst (pyt…
[3.12] gh-114070: fix token reference warnings in expressions.rst (GH…
[3.11] gh-114070: fix token reference warnings in expressions.rst (GH…
pythongh-114070: correct the specification of ``digit`` in the float(…
pythongh-114070: fix token reference warnings in expressions.rst (pyt…
pythongh-114070: correct the specification of ``digit`` in the float(…
pythongh-114070: fix token reference warnings in expressions.rst (pyt…
pythongh-114070: correct the specification of ``digit`` in the float(…
pythongh-114070: fix token reference warnings in expressions.rst (pyt…