How To Build A Euphoria Interpreter In 30 Minutes
- Posted by Mike The Spike <mtsreborn at yahoo.com> Feb 02, 2001
- 386 views
How would you like to build your own cool Euphoria/Py/C/Foolanguage interpreter using Euphoria, that runs at EXACTLY the speed of RDS Euphoria, and sell it? Plus, do all this in (less than) 30 minutes, IN EUPHORIA! Your interpreter supports binding too! And can expose your own cool built-in functions to the programs you interpret! How is this possible? well, let's just say I have being proclaimed to be a great thinker more than once. While David Cuny is breaking his ass to implement a 'PY' programming language in Euphoria that runs about a few hundreds times slower, he could have easily done it in 1-10th of the time and get it to run at the speed of Euphoria, OR EVEN FASTER! Eager to know how to do this huh? I'll tell ya. I'll tell you because I feel like Robert does not want to implement features such as Dynamic Interpretation or an Open Euphoria just yet because he fears that people will build their own Euphoria interpreters using his code. That's EXACTLY what we're gonna do, and believe me, it's even EASIER than if you'd have an Open Euphoria or something like that. So Rob don't have anything to fear anymore (don't you just *hate* me?). (Tip to David Cuny: start your own RDS by implementing PY like I will describe, and use your Eu To Java translator as a replacement to Eu To C by RDS, and become the next RDS!). How To Create Your Own Lightning-Fast Euphoria Interpreter In Euphoria -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* By Mike The Spike Think about it... When you bind your program to the (free, public domain) Ex.exe or Exw.exe, what happens? How does Ex.exe know what code to run? Simple. Your program is placed, shrouded, at the end of ex.exe or exw.exe, when ran, the interpreter executes the code it finds appended to it. We can use this system to implement our own DYNAMIC BINDER! To create your own Euphoria interpreter wich you can sell, do the following; 1. Write a program that can shroud an input source file and bind it to itself. 2. Then calls system() to run itself again, with the new extra code appended to it. 3. Voila! The Euphoria source your program was called with starts executing! Then, later, do this to create a binder: 1. Write a program that can shroud an input file and bind it to a simple program you bound with bind.ex, wich does nothing at all (but keeps things legal). 2. The user can now distribute this stand-alone executable! And start-up speeds are EXACTLY as fast as when you'd use RDS' bind.ex to create a stand-alone executable. Easy huh? You can add several pre-processing passes on the code handed to you, it could even be for example Visual Basic code wich you first translate to Euphoria and THEN shroud, bind and run. Sure this is a quicky 'How To' and don't go into depths of how to shroud and bind stuff (shrouding is extremely easy BTW, very, very easy). Use this technique to create a multi-platform BASIC interpreter (again, David could use some of his previous code like QBASIC To Euphoria), that runs at the speed of Euphoria! I'm guessing RDS is feeling a bit sweaty right now... But hey, my job is to make Euphoria better, and this is just another way to push improvements onto the reality stack at the speed of ASM. (wha?) Mike The Spike