help-bison
[Top][All Lists]
Advanced

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

Re: simple loop construct, advice needed


From: Andrej Prsa
Subject: Re: simple loop construct, advice needed
Date: Fri, 13 Aug 2004 20:47:36 +0200

Hi!

> This "language" accepts only a very limited set of commands, e.g. DEFINE
> and CALL commands and an IF-ELSE-structure.
> 
> In many cases, some commands are repeated (with absolutely no changes) a
> number of times.
> 
> For performance reasons, I would like to add a very simple loop
> functionality to this existing flex/bison environment.
> 
> For example:
> 
> FOR 10
>   command1
>   command2
>   command3
> ENDFOR

If you want to learn the formalism, I suggest the very same approach this
list had suggested to me awhile ago: intermediate representations, namely
the AST (Abstract Syntax Trees). I'm an astrophysicist and not a computer
scientist and I've managed to implement it, so it's really no big deal.

If you'd like to see a working example, you may take a look at my project;
it's a scripting language for modeling eclipsing binary stars. You may get
it at:

        http://www.fiz.uni-lj.si/phoebe

Download 0.30pre2 version and in the src/ directory you'll find both .lex
and .y files along phoebe_scripter_ast.c for AST implementation. I cannot
stress enough that I am *not* a computer scientist so don't expect the
optimal program; it is working, however. Of course, I'd greatly appreciate
any feedback too.

Some of the implemented commands: value and function definitions, if-else
conditionals, for, do, while loops, code blocks, help etc.

If you've any questions, don't hesitate to contact me.

Good luck,

Andrej




reply via email to

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