Boost logo

Boost :

From: Zach Laine (whatwasthataddress_at_[hidden])
Date: 2024-03-04 23:19:06


Sorry, no there isn't. The implementation of the number parser will
eventually just be std::from_chars. So even if I added support to the
Spirit X3 number parsers -- which I use when std::from_chars is
unavailable, the support would eventually go away. Also, there are a
lot of code paths in the Spirit X3 number parsers, and I wouldn't want
to try just jamming such logic in there.

The thing I would do is make a rule that produces my number type (say,
double). Then I would have a character-based parser that the rule
uses, that recognized numbers, and accumulated the characters --
without the separators -- into something like a
boost::container::small_vector<char, 128>, and then on success, I'd
take have a semantic action call parse() on the small_vector, and
assign the result to _val(ctx) for the rule. This sounds like a lot,
but it's actually not that much code. I've done this before in other
projects that had odd properties in their number representations.

Zach

On Mon, Mar 4, 2024 at 3:00 AM Olaf Peter via Boost
<boost_at_[hidden]> wrote:
>
> Hi all,
>
> In the past I had some attempts with Spirit.x3.
> C++, VHDL and other languages support literal digit separators. On
> Stackoverflow.com there are some workarounds (in the context of VHDL's
> digit separator '_' ) for X3, which works but are unattractive and to
> unwieldy/unflexible. Is there a native/direct support for it at
> Boost.Parser?
>
> Thanks,
> Olaf
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk