Doc #80716 [Com]: bad regular expression for float format
| From: | php at yopmail dot com | Date: | Tue, 23 Feb 2021 16:36:32 +0000 |
| Subject: | Doc #80716 [Com]: bad regular expression for float format | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-18589@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=80716&edit=1
ID: 80716
Comment by: php at yopmail dot com
Reported by: jonathan dot poelen+php at gmail dot com
Summary: bad regular expression for float format
Status: Open
Type: Documentation Problem
Package: Documentation problem
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
If that can help: from https://github.com/php/php-src/blob/php-7.4.0/Zend/zend_language_scanner.l
(still same in https://github.com/php/php-src/blob/php-8.0.2/Zend/zend_language_scanner.l
):
LNUM [0-9]+(_[0-9]+)*
DNUM ({LNUM}?"."{LNUM})|({LNUM}"."{LNUM}?)
EXPONENT_DNUM (({LNUM}|{DNUM})[eE][+-]?{LNUM})
and:
<ST_IN_SCRIPTING>{DNUM}|{EXPONENT_DNUM} {
/* snip */
RETURN_TOKEN_WITH_VAL(T_DNUMBER);
}
Previous Comments:
------------------------------------------------------------------------
[2021-02-06 06:15:29] jonathan dot poelen+php at gmail dot com
Description:
------------
---
From manual page: https://php.net/language.types.float
---
The bnf is:
LNUM [0-9]+(_[0-9]+)*
DNUM ([0-9]*(_[0-9]+)*[\.]{LNUM}) | ({LNUM}[\.][0-9]*(_[0-9]+)*)
EXPONENT_DNUM (({LNUM} | {DNUM}) [eE][+-]? {LNUM})
Unfortunately, these accept _123.45 or 123._45 as float. DNUM should be
DNUM ({LNUM}?[\.]{LNUM}) | ({LNUM}[\.])
I think there is a missing float rule that combines DNUM and EXPONENT_DNUM.
float {EXPONENT_DNUM} | {DNUM}
Finally, it seems strange to me to have [\.] instead of \. or [.] and the format used is not the
same as on the integer page: https://www.php.net/manual/en/language.types.integer.php
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80716&edit=1