mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
C++, fix parsing of floating point literals
Fixes sphinx-doc/sphinx#5636
This commit is contained in:
parent
c899b27b4a
commit
b3de33deef
1
CHANGES
1
CHANGES
@ -22,6 +22,7 @@ Bugs fixed
|
|||||||
* #5627: qthelp: index.html missing in QtHelp
|
* #5627: qthelp: index.html missing in QtHelp
|
||||||
* #5659: linkcheck: crashes for a hyperlink containing multibyte character
|
* #5659: linkcheck: crashes for a hyperlink containing multibyte character
|
||||||
* #5754: DOC: Fix some mistakes in :doc:`/latex`
|
* #5754: DOC: Fix some mistakes in :doc:`/latex`
|
||||||
|
* #5636: C++, fix parsing of floating point literals.
|
||||||
|
|
||||||
Testing
|
Testing
|
||||||
--------
|
--------
|
||||||
|
@ -294,7 +294,18 @@ _octal_literal_re = re.compile(r'0[0-7]*')
|
|||||||
_hex_literal_re = re.compile(r'0[xX][0-7a-fA-F][0-7a-fA-F]*')
|
_hex_literal_re = re.compile(r'0[xX][0-7a-fA-F][0-7a-fA-F]*')
|
||||||
_binary_literal_re = re.compile(r'0[bB][01][01]*')
|
_binary_literal_re = re.compile(r'0[bB][01][01]*')
|
||||||
_integer_suffix_re = re.compile(r'')
|
_integer_suffix_re = re.compile(r'')
|
||||||
_float_literal_re = re.compile(r'[+-]?[0-9]*\.[0-9]+')
|
_float_literal_re = re.compile(r'''(?x)
|
||||||
|
[+-]?(
|
||||||
|
# decimal
|
||||||
|
([0-9]+[eE][+-]?[0-9]+)
|
||||||
|
| ([0-9]*\.[0-9]+([eE][+-]?[0-9]+)?)
|
||||||
|
| ([0-9]+\.([eE][+-]?[0-9]+)?)
|
||||||
|
# hex
|
||||||
|
| (0[xX][0-9a-fA-F]+[pP][+-]?[0-9a-fA-F]+)
|
||||||
|
| (0[xX][0-9a-fA-F]*\.[0-9a-fA-F]+([pP][+-]?[0-9a-fA-F]+)?)
|
||||||
|
| (0[xX][0-9a-fA-F]+\.([pP][+-]?[0-9a-fA-F]+)?)
|
||||||
|
)
|
||||||
|
''')
|
||||||
_char_literal_re = re.compile(r'''(?x)
|
_char_literal_re = re.compile(r'''(?x)
|
||||||
((?:u8)|u|U|L)?
|
((?:u8)|u|U|L)?
|
||||||
'(
|
'(
|
||||||
|
@ -124,8 +124,20 @@ def test_expressions():
|
|||||||
expr = i + l + u
|
expr = i + l + u
|
||||||
exprCheck(expr, 'L' + expr + 'E')
|
exprCheck(expr, 'L' + expr + 'E')
|
||||||
for suffix in ['', 'f', 'F', 'l', 'L']:
|
for suffix in ['', 'f', 'F', 'l', 'L']:
|
||||||
expr = '5.0' + suffix
|
for e in [
|
||||||
exprCheck(expr, 'L' + expr + 'E')
|
'5e42', '5e+42', '5e-42',
|
||||||
|
'5.', '5.e42', '5.e+42', '5.e-42',
|
||||||
|
'.5', '.5e42', '.5e+42', '.5e-42',
|
||||||
|
'5.0', '5.0e42','5.0e+42', '5.0e-42']:
|
||||||
|
expr = e + suffix
|
||||||
|
exprCheck(expr, 'L' + expr + 'E')
|
||||||
|
for e in [
|
||||||
|
'ApF', 'Ap+F', 'Ap-F',
|
||||||
|
'A.', 'A.pF', 'A.p+F', 'A.p-F',
|
||||||
|
'.A', '.ApF', '.Ap+F', '.Ap-F',
|
||||||
|
'A.B', 'A.BpF','A.Bp+F', 'A.Bp-F']:
|
||||||
|
expr = "0x" + e + suffix
|
||||||
|
exprCheck(expr, 'L' + expr + 'E')
|
||||||
exprCheck('"abc\\"cba"', 'LA8_KcE') # string
|
exprCheck('"abc\\"cba"', 'LA8_KcE') # string
|
||||||
exprCheck('this', 'fpT')
|
exprCheck('this', 'fpT')
|
||||||
# character literals
|
# character literals
|
||||||
|
Loading…
Reference in New Issue
Block a user