Your code processes a line at a time.
In your example, you have two lines to evaluate.
You're going to need more logic than a simple keyword search to do this.
Essentially you'll need to write a parser that can understand the meaning of statements in context.
I'll throw you a another monkey wrench...
void * p = NULL;
switch(n)
{
case 0:
p = new CStuff1;
break;
case 1:
p = new CStuff2;
break;
case 2:
throw("Invalid Value");
break;
case 3:
p = new CStuff3;
break;
default:
p = NULL;
break;
}