Regex in ctfe?

Era Scarecrow via Digitalmars-d digitalmars-d at puremagic.com
Wed Jan 27 11:54:21 PST 2016


On Wednesday, 27 January 2016 at 19:05:01 UTC, H. S. Teoh wrote:
> An alternative would be to use `if (_ctfe)` branches in the 
> code to switch to a different matching engine when in CTFE, and 
> leaving the runtime code untouched.

  Hmmm... As I recall there's 2 major engines that run Regex (DFA 
& NFA). If you don't need the more complex engine (which has 
forward/back referencing, named capturing, etc) then maybe the 
simpler engine would work.

  But it would seem easier/simpler if the compiler just hooks in 
the Regex that's compiled into it instead and passes the data 
back and forth. It does mean you can't test Regex changes during 
the CTFE stage (assuming your actively changing/building it) but 
it wouldn't have the performance hit either.


More information about the Digitalmars-d mailing list