Re: Euphoria Interpter ?

new topic     » goto parent     » topic index » view thread      » older message » newer message

cklester wrote:
> 
> Matt Lewis wrote:
> > Bernie Ryan wrote:
> > > If Euphoria code is read and parsed before running then
> > > Why can't the parser use the idea of of using #if #else #endif to
> > > to control what code is read or not read by the parser
> > > in other words conditionally process the input.
> > It's definitely possible to do this.  But not necessarily simple or easy.
> 
> #if platform() = LINUX then
>   -- do something
> #else
>   -- do something else
> #end if
> 
> > You're basically embedding another language into euphoria--and one that 
> > executes immediately, changing the state of the interpreter.
> 
> I don't see this, but I'm not an expert on interpreters either. So here's my
> POV: For the conditional above, the interpreter can simply treat the
> disqualified
> code as comments, can't it? The interpreter isn't executing code, it's just
> determining what should be included in the program code. So, if I'm on Linux,
> the code in the else clause above will not be included in the final program
> (and the lines starting with '#' get stripped as well).

Well, you'd have to have a way to interpret and execute the statement after
the hash.  And not let it interfere with the 'normal' operation of the 
interpreter.

> This would work for dynamic includes:
> 
> #if platform() = LINUX then
>    include linux.e
> #else
>    include winblows.e
> #end if

To do this, you'd need two symbol tables, and execute the code immediately.
Eu isn't really set up to do this anymore, and you'd have to be tricky 
about swapping the symbol tables out and knowing when to interpret and 
when to execute each type of code.  Which is why I think it would be 
easier to simply add a simplified macro language (even if it's just a 
stripped down version of Eu) that gets parsed separately from normal
Eu code.  Alternatively, you could write a separate preprocessor based
on the interpreter.

Matt Lewis

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu