Parsifal Software

Extensible Interpreter Development Kit



All of the interpreters in the kit are implemented as reentrant functions, suitable for use where thread safety is an issue. All interpreters use a common interface to their host program, which permits the host program to set the values of variables before starting the interpreter and to query the values of variables after execution of a script.

Since all of the interpreters are functionally interchangeable, a single main program, contained in driver\demo.cpp, suffices to demonstrate the host program interface for any of the interpreters.

The common symbol table mechanism used by the interpreters allows the values of variables to be both set and queried by the host program. Thus values can be initialized before a script is interpreted and results can be queried after execution. Since the symbol table is completely separate from the script interpreters, a given symbol table can be used with any number of scripts.

The symbol table actually consists of two separate objects, an AgDictionary<AgString> object which identifies variable names, and a Dataset object which contains a reference to the dictionary and a value for each variable in the dictionary. Any number of Dataset objects can share the same dictionary.

Organization of the Code

To minimize the difficulties in understanding how a particular interpreter works, the code for the interpreters has been organized into a number of modules which are shared among the various interpreters, so that the interpreters have a substantial amount of commonality in their underpinnings. Each module is accompanied by detailed documentation.

The modules fall into three basic classes: the language independent modules, which are found in the support directory, the CLL language dependent modules, which are found in the cll, and the PLL language dependent modules which are found in the pll directory. Each of these directories contains subdirectories as follows:

These directories contain all files required for implementing the baseline interpreters.
These directories contain all files required for implementing the complex arithmetic examples.
These directories contain all files required for implementing the arrays and subscripts examples.
These directories contain all files required for implementing the structures and objects examples.
These directories contain all files required for implementing the local function definition examples.
These directories contain all files required for implementing the combined arrays, structures and functions examples.
The language independent modules are as follows: The language dependent modules are the parser modules. Two baseline versions of each module exist, one for CLL, one for PLL: In addition, two more modules are common to all versions of all the interpreters:
  • Main Program
    The driver\demo.cpp file contains a simple command line main program which carries out the following operations:
    1. Reads a script file specified on the command line.
    2. Sets up an AgDictionary<AgString> object to serve as symbol dictionary.
    3. Adds some variables to the dictionary.
    4. Creates a Dataset object with a reference to the dictionary.
    5. Initializes some variables in the Dataset object.
    6. Invokes the interpreter, using the common interface.
    7. Sorts the variables in the dictionary.
    8. Prints out the name and value of each variable in the dictionary.

    This main program is intended only to demonstrate how an interpreter can be invoked from a host program. Since all the interpreters implement the same interface, this main program can be used with any of them.

  • AnaGram Class Library
    The class library, AGCLIB1, is not, properly speaking, a part of the kit. AGCLIB1 is a simple, compact collection of classes designed to support AnaGram examples. The classes were designed from a minimalist point of view so that users can substitute the class library they prefer with as little difficulty as possible, should it be appropriate.

Compiling and Linking

Make files have been provided for users of six different compilers:
Directory Compiler Make Command
msvc Miscrosoft Visual C++ nmake
borland Borland C++ make
watcom Watcom C++ wmake
vacpp IBM Visual Age for C++ nmake
gcc gcc on *nix Systems make
intel Intel on Linux Systems make

Each of these directories contains subdirectories to segregate CLL and PLL interpreters. Each of these subdirectories in turn contains subdirectories for the baseline interpreters and for each of the extension examples.

Make files have been provided at each level of the directory structure. Thus, the nmake command when executed from the msvc directory uses Microsoft Visual C++ to make all 48 different interpreters. From the msvc\cll directory, the nmake command will make only the 24 CLL interpreters. From the msvc\cll\base directory, nmake will make only the four baseline CLL interpreters. In this latter directory, nmake can take an optional argument to make just one of the four baseline interpreters. The same structure is used for all six compilers supported.

The make files also run simple tests. The tests are found in the test\cll and test\pll directories. The test files are described here.

Note that if any changes are made to the AGCLIB1 class library, it should be rebuilt using the corresponding makefile. See here.

If you are using some other compiler, here are the modules you need to compile and link:
Interpreter Modules
dxi dxi.cpp
dci dci.cpp
astxi astxi.cpp
astci astci.cpp
Two modules belonging to the AGCLIB1 Class Library are also required:

  • agabt.cpp
  • agbstr.cpp

Table of Contents | Parsifal Software Home Page

Extensible Interpreter Development Kit
Copyright © 1997-2002, Parsifal Software.
All Rights Reserved.