Back


Package Organization

Linguist comprises a highly-organized set of Java 1.1 classes, all of which are provided as Java source for you to use as the starting point for your own productions. These are the major package groupings. First the standard language packages, that implement the language features as we supply them:

basic
awt
graphics
media

and then the support classes that provide the compiler and runtime infrastructure:

compiler
debug
linguist
quickshow
runtime

Here are the major features of each package:


The basic package contains all of the keyword handlers for the basic language features, as documented in the Reference. The package contains a number of standard classes for processing condition and value and for handling errors, and below this are five sub-packages:

condition
handler
keyword
runtime
value

The condition sub-package contains run-time handlers for conditional expressions. Suppose your script has the line

if X is greater than 25 stop

The compiler handler for the if keyword scans the variable X, then looks for a conditional expression, in this case is greater than. It has no methods of its own for processing conditions, so it asks basic.BLGetCondition to process the condition and return a suitable handler if it can. This particular condition is part of the basic package, so a handler from the basic.condition sub-package is returned. (The use of handlers is fundamental to the operation of Linguist, so it will be explained many times in different ways. Don't worry if it's not clear now.)

The handler sub-package contains run-time handlers for each feature of the script language. When the compiler has finished parsing a feature it creates a handler, which is your own derivative of a standard Java class provided by us. The handlers are placed into an array; this becomes the program itself. Each handler has constructor and execution methods, so the overhead in running a script is low.

The keyword sub-package contains the classes that actually do most of the script compilation. This is the key to the way Linguist works. Because these classes are under your control, rather than being buried in a monolithic compiler, you can safely make changes to and extend the syntax of your script language.

The runtime sub-package contains miscellaneous classes such as a background handler for the package and a class that contains error messages which may need to be translated to another language.

The value sub-package has a similar purpose to condition. It handles any value that your script requires. Those in the basic package deal with numeric and string values, that is, anything that translate to a number or a string. So left 4 of Line is a string value, while the length of Line is numeric. (Both assume Line to be a string buffer).


The awt package is the second of the language packages supplied with Linguist. See the Reference for a description of each command handled. It contains the same sub-packages as basic, so the same general notes apply.


The graphics package is the third of the language packages supplied with Linguist. See the Reference for a description of each command handled. It contains the same sub-packages as basic, so the same general notes apply.


The media package is the fourth of the language packages supplied with Linguist, the along with basic and graphics. See the Reference for a description of each command handled. Note: Only systems that have a port of the Java Media Framework can use the media package..


The compiler package is one of those for which we mostly supply only the class files. This contains methods to scan the source script, parse it into tokens, look for suitable handlers and call them to do the actual script compilation. If a script handler is unable to understand a particular command but does not detect an error it returns null, which causes the compiler to submit the same request to the next package, and so on until a handler has been received or there are no more packages. This strategy is the key to the flexibility of Linguist.


The debug package contains the core of the debugger, enhanced by handlers in each of the main keyword packages. We only supply the class files as there are no methods you need to know about.


The linguist package contains miscellaneous classes that are central to the operation of Linguist. Most of the classes in the language packages (basic, standard, graphics and media) are derived from classes in this package.


The quickshow package contains graphics classes that implement a high-level Actor-Stage view of interactive graphics. The quickshow classes are available separately for use with Java applets or applications. Documentation is available elsewhere on this site.


The runtime package contains the core of the runtime interpreter, that takes successive handlers from the program array and calls their execute() method. Each one returns the index of the next instruction, so the interpreter loop is in fact very small and fast.


Back