[OT-ish] GOTO in Euphoria;-)
- Posted by Pete Lomax <petelomax at blueyonder.co.uk> Feb 12, 2004
- 451 views
Just a bit of fun. Counts the number of times the word goto appears in a source file. (prints 57 if you don't supply a file, the number of gotos in itself) If anyone's interested I'll post this laid out properly, showing some really funky scope rules. Anyway, enjoy: -- goto.exw: usage exw goto.exw <file> constant togo="goto" type goto(integer goto) return goto= goto end type type goto_s(sequence goto) return equal( goto, goto) end type goto goto_t, goto_u procedure goto_a( goto goto) goto_t+= goto if goto then goto_u= goto end if end procedure procedure goto_b( goto goto) goto_u= goto_u* goto+1 goto_a( goto_u= goto*5) end procedure function goto_c( goto goto) goto_b( goto=togo[ goto_u]) return goto!=-1 end function procedure goto_d( goto goto) goto_u= goto!=1 goto_t= goto=0 while goto_c(getc( goto)) do end while close( goto) printf(1,"%d goto \'s\n", goto_t) end procedure procedure goto_x( goto_s goto) goto_d(open( goto[length( goto)],"r")) end procedure goto_x(command_line())