Boost logo

Boost :

From: Zach Laine (whatwasthataddress_at_[hidden])
Date: 2024-02-27 23:44:35


On Tue, Feb 27, 2024 at 4:24 PM Christian Mazakas via Boost
<boost_at_[hidden]> wrote:
>
> > * My use case involves parsing identifiers that can only contain ASCII
> > lowercase, uppercase, digits and the underscore.
>
> Spirit used to have helpers like this but Parser doesn't seem to have them.
> I noticed this too but it's actually pretty easy to fill this in yourself.
>
> Here's a working example: https://godbolt.org/z/6P6dTbGYY
>
> auto const digit = p::char_('0', '9');
> auto const lower = p::char_('a', 'z');
> auto const upper = p::char_('A', 'Z');
> auto const ident = digit | lower | upper | '_';

Parser does have these (digit, lower, upper), but those match more
than what is desired here. What is desired here is alnum |
char_('_'), I think. That is, only the ASCII a-z, A-Z, 0-9, and _.
You can spell that out yourself as above, as you've done. You could
also just use digit | lower | upper | char_('_'). It will be vaguely
as fast I expect (but certainly measure if it's a perf-critical
situation).

> > * I started my evaluation using clang-18 (Linux) but builds fail
> > (seems to happen under all clang versions I tried).
>
> Hmm, I can't actually can't replicate this, btw.
>
> I'm using the latest tip of develop here:
> https://github.com/cmazakas/parser-review/blob/main/overlays/boost-parser/portfile.cmake#L6
>
> Compiles fine for me using clang-17 on Ubuntu 23.10
>
> You should include details about the nature of your build failures.

Yes, please do! I'd like to know about and fix this, but I have
limited access to Clang.

Zach


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