compile-time regexp lib released

Robert Fraser fraserofthenight at gmail.com
Tue Aug 7 15:13:48 PDT 2007


Marton Papp Wrote:

> Hi!
> 
> I do not mind. Except I do not understand your choice of __1, __2..
> why not _1,_2,_3?
> Or dollar1,dollar2,dollar3?
> and would you fork it or would you like it to be added to scregexp?
> 
> Regards
> 
> Marton Papp

I was just going to extend it for my project when I eventually get around to it, probably not for another few months (I want to see Descent get as strong an IDE as JDT before I start splitting my attention). If you think it might be useful for scregexp, I don't think it'd be too hard to add.

Thinking a bit more about it, an array might be better for that. _[0] would be the first capture, _[1] the second, etc. But that still doesn't allow something awesome like:

if(str =~ m/(\d+)_(\w+)/)
{
    print "$1 = $2";
}

... or how I'd like to see it in D:

if(str.matches(`(\d+)_(\w+)`)
{
    writefln("%d = %d", _[0], _[1]);
}

... where matches() compiles the regex at compile time like scregex.

Oh well, maybe AST macros will open up that possibility, though I'm not sure exactly how that's work.



More information about the Digitalmars-d mailing list