Loop.sed



#  Fixup for, while and until statements.

#     for i in wordlist          foreach i ( wordlist )
#     do                   -->
#        :                          :
#     done                       end

#     while list                 while ({ list })
#     do                   -->
#        :                          :
#     done                       end

#     until list                 while (! { list })
#     do                   -->
#        :                          :
#     done                       end

/^[   ]*for.*;[   ]*"\{,1\}do"\{,1\}$/s/[    ]*;[  ]*"\{,1\}do"\{,1\}$//
/^[   ]*while.*;[    ]*"\{,1\}do"\{,1\}$/s/[    ]*;[  ]*"\{,1\}do"\{,1\}$//
/^[   ]*until.*;[    ]*"\{,1\}do"\{,1\}$/s/[    ]*;[  ]*"\{,1\}do"\{,1\}$//
/^[   ]*for/s/for[   ]*\([^   ][^   ]*\)[    ]*in[    ]*\([^   ].*\)$/foreach \1 (\2)/
/^[   ]*while/s/while[  ]*\([^(  ].*\)$/while ({ \1 })/
/^[   ]*until/s/until[  ]*\([^(  ].*\)$/while (! { \1 })/
/^[   ]*do$/d
/^[   ]*done/s/done/end/



Hamilton C shell | Free Updates | Free Demo Software | Win32 Training
Y2K | Customer Testimonials | On-line Hamilton C shell User Guide
Home | Email | Support | Company Profile | Distributors | Links



Copyright © 1997-2001 by Hamilton Laboratories. All rights reserved.
You are visitor number . This page was last modified August 14, 2001.