I want to write a sort of translator which can translate the code of for loop to coresponding while.
for example if i have :
for(int i = 0 ; i < 10 ;i++)
Console.WriteLine("Hello");
it should translate like :
int i = 0;
while( i < 10)
{
Console.WriteLine("Hello");
i++;
}
Loading
MichaelPosted Oct 10, 2005, 8:21 PM
you could use an regular expression
change
for\({.+}\;{.+}\;{.+}\)\n*\{{(\n.*)*}\}
into
\1;\nwhile(\2)\{\4\3;\n\}