On Fri, 23 Jan 2004, Peter Aherne wrote:
> I stuck on yet another scripting problem. After much expermentation and
> googling I'm still nowhere. Here is the problem, I want a script to turn
> this :
>> <snipped>
Not easily. For what it's worth, you are trying to do "Loop Unrolling"
which would normally be handled by the compiler optimizer so you could
try and search for programs which do automatic loop unrolling.
If you can't find one and you don't want to use flex and yacc to do this
(which is the right way), you can try a simple state machine in perl. i.e.
start in STATE_OUTSIDE_LOOP, search for stuff that looks like a for loop,
parse it and enter STATE_INSIDE loop. If you find a {, increment a brace
count, a } and decrement it. Once you have the full loop read, use regular
expression to replace i with each number in the interation. It's doable
within a few hours but will be very very very delicate. It depends on if
this is a once off job or not.
--
Mel Gorman
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!