Link to home
Start Free TrialLog in
Avatar of gilad_no
gilad_no

asked on

Building an Interpreter

Hi all,

 Where can I learn to build a simple interpreter ?
 I want to add scripting option to my application. I found various sources, but non of them was sufficient. I don't want to build a compiler. I know how to process input, but I don't know how to handle loops and jumps in runtime. I found an example in Java but it was too complicated. Does any one knows a simple example in C ?
Avatar of JackThornton
JackThornton

The best way to add scripting options to your program is not to roll your own interpreter, but to leverage Microsoft ActiveScript.
In order to use active scripting, you need to do the following things:

(1) Add "automation" support to your program. That means create one or more COM/ActiveX object(s) that exposes the functionality you want to give your script writers, and make sure these objects present either a dual or straight IDispatch-derived interface.

(2) Follow the directions and samples from the MSDN scripting site :
http://msdn.microsoft.com/scripting/default.htm

Also look up IActiveScript and IActiveScriptDebug using the search program of your choice to find articles and code examples.

The ActiveScripting interfaces give you a polymorphic interface to multiple scripting engines - that means your customers can write scripts in *any* ActiveScripting language available either from Microsoft or third parties. That includes javascript, VBScript, Perl, Tk/tcl, Python, Forth, etc. etc. etc. And it is very easy to implement. And you don't have to write your own interpreter, which can be a college-course subject all by itself.

- jack
Avatar of gilad_no

ASKER

I need to build my own interperter. I want to add an option to enhance the scripting language. I know the basic idea of parsing text, but I don't know how implementate it at runtime. If I run the script in memory, how can I jump to other place in the script ? I know how to build a compiler but not an interperter. Another reason I don't want to use ready-made one, is that I want to learn how it works :)
ASKER CERTIFIED SOLUTION
Avatar of JackThornton
JackThornton

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial