"Regan Heath" <[email protected]> wrote in message 
news:[email protected]...
> On Wed, 23 Mar 2011 21:16:02 -0000, Jonathan M Davis <[email protected]> 
> wrote:
>> There are tasks for which you need to be able to lex and parse D code. 
>> To 100% correctly remove unit tests would be one such task.
>
> Is that last bit true?  You definitely need to be able to lex it, but 
> instead of actually parsing it you just count { and } and remove 
> 'unittest' plus { plus } plus everything in between right?
>

No, to do it 100% reliably, you do need lexing/parsing, and also the 
semantics stage. Example:

string makeATest(string str)
{
    return "unit"~"test { "~str~" }";
}
mixin(makeATest(q{
    // Do tests
}));



Reply via email to