Re: Bug in real_parser
Seth <[email protected]>
| Newsgroups | gmane.comp.parsers.spirit.general |
|---|---|
| Message-ID | <[email protected]> |
On 18-09-16 23:07, peterkochlarsen wrote:
> On Coliru I get the same result.
I'm really unsure why you choose not to link that coliru, or say what
platform/compiler it fails on.
> Lastly, I expected both my examples to parse (leaving "E" or "W" for the
> next part of my grammar), but I did not expect "045.000" to become 45000.
If you want to specify a parser that /does not/ expect an exponent part,
then you **must** specify so. Use a custom real_parser policy.
template <typename T> struct simple_real_policies :
boost::spirit::qi::real_policies<T>
{
static bool parse_exp(...) { return false; } // No exponent
};
See it Live On Coliru <http://coliru.stacked-crooked.com/a/d1d48ee326ed485b>
New output:
'4' -> 4
'04' -> 4
'045.' -> 45
'.0' -> 0
'7E0' -> -1 (ERR)
'7.E0' -> -1 (ERR)
'-4' -> -4
'-04' -> -4
'-045.' -> -45
'-.0' -> -0
'-7E0' -> -1 (ERR)
'-7.E0' -> -1 (ERR)
'+4' -> 4
'+04' -> 4
'+045.' -> 45
'+.0' -> 0
'+7E0' -> -1 (ERR)
'+7.E0' -> -1 (ERR)
'-4' -> -4
'-04' -> -4
'-045.' -> -45
'-.0' -> -0
'-7E0' -> -1 (ERR)
'-7.E0' -> -1 (ERR)
'.4e7' -> -1 (ERR)
'.4e-7' -> -1 (ERR)
'045.000W' -> -1 (ERR)
'045.000E' -> -1 (ERR)
------------------------------------------------------------------------------
_______________________________________________
Spirit-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/spirit-general