X3: byte_range parser

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

X3: byte_range parser

Mike Gresens
Hi,

is it possible to provide a byte_range parser like the char_range parser?

Like x3::char_('a', 'z')
A x3::byte_(75, 175) ...

Thanks,
Mike...
Reply | Threaded
Open this post in threaded view
|

Re: X3: byte_range parser

Mike Gresens
Current workaround:

const auto byte_rule = [](const std::int_fast8_t from, const std::int_fast8_t to)
{
        const auto check = [from, to](auto& ctx)
        {
                const std::int_fast8_t value = x3::_attr(ctx);
                x3::_val(ctx) = value;
                x3::_pass(ctx) = from <= value && value <= to;
        };

        return x3::byte_ [check];
};