help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: calculator with additional function


From: Laurence Finston
Subject: Re: calculator with additional function
Date: Fri, 10 Jun 2005 22:29:48 +0200
User-agent: IMHO/0.98.3+G (Webmail for Roxen)

-------------------
> At 09:53 +0200 2005/06/10, address@hidden 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]