Back
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. The standard language packages implement the language features as we supply them. Here is a list of the more common ones; the distribution may well include others.:
Here are the major features of each package:
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 examples assume Line to be a string buffer).