1. Euphoria Interpter ?
- Posted by Bernie Ryan <xotron at bluefrog.com> Nov 17, 2005
- 1347 views
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. Bernie My files in archive: w32engin.ew mixedlib.e eu_engin.e win32eru.exw Can be downloaded here: http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan
2. Re: Euphoria Interpter ?
- Posted by Matt Lewis <matthewwalkerlewis at gmail.com> Nov 17, 2005
- 1340 views
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. You're basically embedding another language into euphoria--and one that executes immediately, changing the state of the interpreter. I don't see an easy way you could use too much of the builtin routines without some big hacks. Matt Lewis
3. Re: Euphoria Interpter ?
- Posted by cklester <cklester at yahoo.com> Nov 17, 2005
- 1344 views
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). This would work for dynamic includes: #if platform() = LINUX then include linux.e #else include winblows.e #end if -=ck "Programming in a state of EUPHORIA." http://www.cklester.com/euphoria/
4. Re: Euphoria Interpter ?
- Posted by Matt Lewis <matthewwalkerlewis at gmail.com> Nov 17, 2005
- 1331 views
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
5. Re: Euphoria Interpter ?
- Posted by cklester <cklester at yahoo.com> Nov 17, 2005
- 1341 views
This message has been heavily edited. Please see prior versions for clearer context. Matt Lewis wrote: > cklester wrote: > > > > For the conditional above, the interpreter can simply treat the disqualified > > code as comments, can't it? > > Well, you'd have to have a way to interpret and execute the statement after > the hash. Oh, yeah. Duh! 8) > And not let it interfere with the 'normal' operation of the > interpreter. That's easy. For you, I mean. :D > > 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. Oh, yeah. I told you I wasn't an expert! I guess I didn't think it would be a big deal to be able to run "platform()" outside of the program's "space." -=ck "Programming in a state of EUPHORIA." http://www.cklester.com/euphoria/
6. Re: Euphoria Interpter ?
- Posted by Bernie Ryan <xotron at bluefrog.com> Nov 17, 2005
- 1321 views
- Last edited Nov 18, 2005
Matt Lewis wrote: > It's definitely possible to do this. But not necessarily simple or easy. > You're basically embedding another language into euphoria--and one that > executes immediately, changing the state of the interpreter. I don't see > an easy way you could use too much of the builtin routines without some > big hacks. Matt: I don't think it is as complicated as you think. This is what I mean. #define LINUX -- at the top of the program I place this or #define WIN32 -- depending on what I define at top of program the parser only -- parses the code that meets the defined condition. #IF Linux include linux.eu for i = 1 to 200 do do somthing end for #ELSIF WIN32 include win32.ew for i = 1 to 200 do do somthing end for #ELSE include dos.e for i = 1 to 200 do do somthing end for #ENDIF Bernie My files in archive: w32engin.ew mixedlib.e eu_engin.e win32eru.exw Can be downloaded here: http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan
7. Re: Euphoria Interpter ?
- Posted by Matt Lewis <matthewwalkerlewis at gmail.com> Nov 17, 2005
- 1345 views
- Last edited Nov 18, 2005
Bernie Ryan wrote: > > Matt Lewis wrote: > > It's definitely possible to do this. But not necessarily simple or easy. > > You're basically embedding another language into euphoria--and one that > > executes immediately, changing the state of the interpreter. I don't see > > an easy way you could use too much of the builtin routines without some > > big hacks. > > > Matt: > > I don't think it is as complicated as you think. This is > what I mean. > > #define LINUX -- at the top of the program I place this or #define WIN32 > -- depending on what I define at top of program the parser only > -- parses the code that meets the defined condition. > > #IF Linux > include linux.eu > for i = 1 to 200 do > do somthing > end for > #ELSIF WIN32 > include win32.ew > for i = 1 to 200 do > do somthing > end for > #ELSE > include dos.e > for i = 1 to 200 do > do somthing > end for > #ENDIF That's an example of embedding a macro language. And it would be very useful. I would use this with wxEuphoria (I currently have a perl script that comments and uncomments based on similar directives). However, it would take about 5 seconds before someone else asked why they couldn't do something much more complicated. I guess I was just thinking about that inevitability... Matt Lewis
8. Re: Euphoria Interpter ?
- Posted by cklester <cklester at yahoo.com> Nov 17, 2005
- 1339 views
- Last edited Nov 18, 2005
Matt Lewis wrote: > That's an example of embedding a macro language. And it would be very > useful. I would use this with wxEuphoria (I currently have a perl script > that comments and uncomments based on similar directives). However, it > would take about 5 seconds before someone else asked why they couldn't do > something much more complicated. Let people ask. Questions never hurt anybody! At least we'd have additional, useful functionality, upon which our empire could expand! Sorry. Got maniacal for a second. -=ck "Programming in a state of EUPHORIA." http://www.cklester.com/euphoria/
9. Re: Euphoria Interpter ?
- Posted by petelomax at fastmail.fm Nov 18, 2005
- 1319 views
On Thu, 17 Nov 2005 11:22:52 -0800, "Bernie Ryan" <guest at RapidEuphoria.com> said: > I don't think it is as complicated as you think. This is > what I mean. > > #define LINUX -- at the top of the program I place this or #define WIN32 > -- depending on what I define at top of program the parser only > -- parses the code that meets the defined condition. > > #IF Linux > include linux.eu > for i = 1 to 200 do > do somthing > end for > #ELSIF WIN32 > include win32.ew > for i = 1 to 200 do > do somthing > end for > #ELSE > include dos.e > for i = 1 to 200 do > do somthing > end for > #ENDIF > Bernie my $0.02: that is just so LAME. why not include #if linux linux #elsif win32 win32 #else dos #endif . #if linux eu #elsif win32 ew #else e #endif for #if linux l #elsif win32 w #else d #endif = .... OR == write/use include files which run on multiple platforms OR == write a stub for each platform: main.eu: include linux.eu include main.e main.ew: include win32.ew include main.e main.ex include dos.ex include main.e why, oh why, mangle a platform-independent language just because you cannot write platform-independent includes?????!!??? Pete -- petelomax at fastmail.fm -- http://www.fastmail.fm - Does exactly what it says on the tin
10. Re: Euphoria Interpter ?
- Posted by "Juergen Luethje" <j.lue at gmx.de> Nov 18, 2005
- 1331 views
petelomax wrote: > On Thu, 17 Nov 2005 11:22:52 -0800, "Bernie Ryan" said: > >> I don't think it is as complicated as you think. This is >> what I mean. >> >> #define LINUX -- at the top of the program I place this or #define WIN32 >> -- depending on what I define at top of program the parser only >> -- parses the code that meets the defined condition. >> >> #IF Linux >> include linux.eu >> for i = 1 to 200 do >> do somthing >> end for >> #ELSIF WIN32 >> include win32.ew >> for i = 1 to 200 do >> do somthing >> end for >> #ELSE >> include dos.e >> for i = 1 to 200 do >> do somthing >> end for >> #ENDIF >> Bernie > > my $0.02: that is just so LAME. why not > include > #if linux > linux > #elsif win32 > win32 > #else > dos > #endif > . > #if linux > eu > #elsif win32 > ew > #else > e > #endif > for > #if linux > l > #elsif win32 > w > #else > d > #endif > = > .... > > OR > == > write/use include files which run on multiple platforms This is the same problem as writing programs which run on multiple platforms, just on a different level. > OR > == > write a stub for each platform: > main.eu: > include linux.eu > include main.e > > main.ew: > include win32.ew > include main.e > > main.ex > include dos.ex > include main.e After my experience, this is often not easy because of the lack of forward referencing in Euphoria. > why, oh why, mangle a platform-independent language just because you > cannot write platform-independent includes?????!!??? I'm afraid I don't understand what you mean. Can you please elaborate? Regards, Juergen -- Have you read a good program lately?
11. Re: Euphoria Interpter ?
- Posted by Matt Lewis <matthewwalkerlewis at gmail.com> Nov 18, 2005
- 1336 views
cklester wrote: > > Matt Lewis wrote: > > > However, it would take about 5 seconds before someone else asked why > > they couldn't do something much more complicated. > > Let people ask. Questions never hurt anybody! At least we'd have additional, > useful functionality, upon which our empire could expand! > I did. And you did, didn't you? I knew I could count on you. :) Matt Lewis