Open bruno-j-nicoletti opened 4 months ago
lexy needs to encode the strings in the type system (it internally creates a type_string<char, 'a', 'b', 'c'>
type), once it's in a std::string_view
LEXY_KEYWORD
can't get them out of there easily.
If you use C++20, I could support dsl::keyword<std::string_view("abc")>(identifier)
though. Would that help?
Ah, perfect. I'm on C++23.
Thank you so much for getting back to me on everything. Very much appreciate the work you've put into the library and responding to me.
I spoke too soon. That refuses to compile because you can't pass a string_view
instance as an NTTP. I tried passing in a constexpr string class along the lines of the one below, and it gets further, but it still breaks compilation.
This is definitely a rabbit hole I've dragged you down. Appologies.
https://oleksandrkvl.github.io/2021/04/02/cpp-20-overview.html#nttp
I was thinking of something like this, the problem is that I can't get the size where I have ???
: https://godbolt.org/z/7zjbfWj96
size
is a member function so that can't work. I've spent a bit of time playing with approaches and I can almost but not quite get it to work via a helper function. string_view::size()
is constexpr, but I cant figure out how to get the helper function to accept an string_view argument and remain constexpr
https://godbolt.org/z/4GbY7W4ae
Uncomment line 55 to see the issue.
This is very minor issue with the API.
For constants I use
constexpr
over#define
wherever possible. I want to have the set of keywords used by my grammar defined viaconstexpr std::string_view
and use them elsewhere in my code. Unfortunately theLEXY_KEYWORD
macro relies on values passed to it to be literals, so I need to #define them.Not a pressing issue, but a nice API change if it is simple enough to do.