------------------- > At 09:53 +0200 2005/06/10, [EMAIL PROTECTED] wrote: > >I need to write calculator with additional function. It have to > >serve loop FOR where I declare how many times it will run and what > >will it do inside. > >My problem is how to bould data structure (it have to be tree) for > >this calculator. > >Have You any idea?
Why does it have to be a tree? If you want to see an example of one way to implement loops, you could look at my code. It's available at http://savannah.gnu.org/cgi-bin/viewcvs/3dldf/3dldf/Group/CWEB/ploops.w The basic idea is that the text of the loop is put into a string, which is then pushed onto a stack of input sources. After each iteration, the conditional governing the loop is tested, and depending on the result, the string is read again, or it's popped from the stack. Using this technique, nested loops are a snap to implement, but not the ultimate in efficiency. Incidentally, I've used a similar technique for macros. Laurence Finston http://www.gnu.org/software/3dldf/LDF.html _______________________________________________ Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison