foonathan / lexy

C++ parsing DSL
https://lexy.foonathan.net
Boost Software License 1.0
1.01k stars 67 forks source link

Ability to provide own encoding #188

Closed Xottab-DUTY closed 7 months ago

Xottab-DUTY commented 8 months ago

Currently lexy has static assertions that only allow predefined encodings. I want to create my custom word_encoding so I can read 2 bytes instead of just byte one by one.

Xottab-DUTY commented 8 months ago

Well, now I'm unsure if this exact feature is needed, maybe there's a better solution for my use case?

Pseudo-code:

struct production
{
    static constexpr auto rule = []
    {
        return lexy::bytes<2>.range(65534, 65535);
    }
}

I want to read 2 bytes and validate that they are in the allowed range. Yes, it's possible to validate each byte, but this is unwanted :)