Compile time regular expression in C++
21–30 of 30 posts
Re: Compile time regular expression in C++
#22Re: Compile time regular expression in C++
#23At the risk of sounding like an idiot, what is the benefit of being able to match at compile time?
Re: Compile time regular expression in C++
#24At the risk of sounding like an idiot, what is the benefit of being able to match at compile time?
Edit: here is her talk, at 39 minutes she shares the benchmarks. https://m.youtube.com/watch?v=QM3W36COnE4
Re: Compile time regular expression in C++
#25Hopefully the standard regex will be constexpr soon.
Re: Compile time regular expression in C++
#26Boost Xpressive has had static/"compile time" regex in C++ since the mid 2000s https://www.boost.org/doc/libs/1_83_0/doc/html/xpressive.htm... A performance comparison would be interesting.
The first compile time regular expressions I saw that just used normal regular expressions was D's CTRE which produced an even faster "engine" than Boost Xpressive. This was thanks to D's compile time function evaluation reaching a point something like this was possible.
I just started using this CTRE for a regular expression whose performance had become problematic and I'm very impressed with it so far. It's pretty easy to surpass std::regex but not sacrificing usability was surprising. Build times haven't been affected too much either (for my use case).
Re: Compile time regular expression in C++
#27Earlier quoted context omitted.
I've never used cl-ppcre myself, but its docs[1] claim that it provides compile-time regexes: > CL-PPCRE uses compiler macros to pre-compile scanners at load time if possible. This happens if the compiler can determine that the regular expression (no matter if it's a string or an S-expression) is constant at compile time and is intended to save the time for creating scanners at execution time (probably creating the s…
I think this is more like caching the regex than creating it at compile time? Load time I think is basically runtime. I think lisp can be loaded and then rehydrated later, but I'm not sure how common that is.
> This happens if the compiler can determine that the regular expression (no matter if it's a string or an S-expression) is constant at compile time
If this were just a run of the mill caching mechanism, then whether the pattern was a constant at compile time wouldn't matter.
Re: Compile time regular expression in C++
#28I'd love for someone to add this to rebar[1] so that we can get a good sense of how well it does against other general purpose regex engines. It will be a little tricky to add (since the build step will require emitting a C++ program and compiling it), but it should be possible. [1]: https://github.com/BurntSushi/rebar
The C++ standard library "general regex engine" is crap (at speed), so there's no competition on that front at least...
There are other engines written in C++ (in part or in whole) in rebar. And it is useful to compare it with engines not written in C++ too.
Re: Compile time regular expression in C++
#29Re: Compile time regular expression in C++
#30This has been available in Lisp since at least 2004. https://github.com/edicl/cl-ppcre/
https://learn.microsoft.com/en-us/dotnet/standard/base-types...