calculator with additional function

2005-06-10 Thread tomjab
Hi,
 
There was problem with sent my message so I send it again.
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?


___
Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison


Re: flex input and malloc

2005-06-10 Thread Sylvain Schmitz

jojo wrote:

I want to make a scanner for my microcontroller who is getting

> messages (not longer than 160 chars; example:
> "var1=34.34;var2="test";var3=5"). Those messages are stored in
> a buffer (char buff[160]). The mc should scan and react to this
> messages in doing something and post a message back. My problem
> is that flex is allocating space on heap - well, that works on
> the controller but I didn“t want to do because of less space and
> all problems that can occur with that (memory leaks etc).
> Is there a way to use static memory (array)? Perhaps there are
> other versions of lex who supports this?

I think `yy_scan_buffer` is the answer; see 
[http://www.gnu.org/software/flex/manual/html_chapter/flex_12.html#SEC12].


--
Hope that helps,

  Sylvain


___
Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison


Re: calculator with additional function

2005-06-10 Thread Hans Aberg

At 09:53 +0200 2005/06/10, [EMAIL PROTECTED] wrote:

Hi,

There was problem with sent my message so I send it again.
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?


You have to build a "closure", that can be executed later, building 
it directly in the actions, in terms of code that can executed after 
the syntactic termination of the loop. This code can be binary, or an 
output in some other language that can be compiled and executed 
later. Most do it directly, by hand, perhaps invoking M4, Guile, or 
something, as an aid if the output is any other language. Just a few 
days ago, there has come to my attention the tool 
, probably useful for more advanced things.

--
  Hans Aberg


___
Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison


Re: calculator with additional function

2005-06-10 Thread Laurence Finston
---
> 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