Back

Linguist Reference

At the heart of Linguist are a compiler and a runtime interpreter for a high-level scripting language. But instead of the language being a fixed entity it's completely customizable to do whatever you need, provided you keep to a general overall syntax structure. More on this later.

Before you get the impression we're trying to tempt you away from Java, we hasten to stress that most of the work you do with Linguist is in fact pure, unadulterated Java. But your customers may prefer to work with a simpler language. Linguist is the bridge that enables them to describe the features they want by scripting, while you code the engine underneath in Java, the way you prefer.

Linguist as supplied includes a core set of classes and a set of packages that together comprise a sample scripting language. The full source is supplied for you to use as a starting point for your own custom language. Or you can add classes (handlers) to the ones we supply.

The standard classes are in the following packages. Some of these have overlapping functionality, while others are unlikely to be used in combination. For example, 'swing' cannot be used at the same time as 'servlet' (because they share the same initial letter) but it's most unlikely that a servlet will need a GUI. See the note below about Repackage.

Each of these is documented in the following pages.

The basic package supports two variable types: 64-bit integers and strings. It has a full set of arithmetic, logical and control operators, including keywords to launch concurrent scripts and enable communication between multiple compiled scripts.

The comms package is a small addition that provides support for serial ports. It is separate from the basic package because it requires the javax.comm extension classes that are not available for all platforms.

The window package provides wrappers for standard AWT components provided with the JDK.

The graphics package adds a high-level object-oriented graphics function set, using the metaphor of a Stage with multiple Actors. It understands Z-ordering and concurrent independent actions, eliminating much of the hard work of constructing interactive graphics applications. It also provides a wrapper for the ICESoft Browser for users who are willing to obtain an appropriate license from its supplier.

The swing package encapsulates functionality from the JFC Swing classes. When complete, this package will provide wrappers round many of the components provided by Swing, along with the means to use these components easily and flexibly. Note: If you use 'swing' you won't require the 'window' or 'graphics' packages since it will eventually provide all their functionality and then some.

The media package uses the Java Media Framework to handle audio and video in a flexible and easy-to-use manner. To use this package you must obtain and install a copy of the Java Media Framework from Sun or another appropriate source.

The data package manages databases using JDBC. It also includes an application server to decouple the application from the database and to provide somewhere to place business logic.

The servlet package provides variables and commands for implementing scripted servlets, including high-level constructs for generating HTML.

Additionally, there are some commands built into the compiler core. The names themselves are defined in one of the compiler modules, where they can be changed easily. Here are the commands:

compile <name>

When the compiler encounters a run command it saves the name of the script in a table. At the end of compilation it then compiles all the scripts it found. This can cause an unnecessary and time-consuming amount of extra compiling work so you can specifiy which files should be recompiled if found in run commands. Once the first compile command has been found, only files listed in compile commands will be recompiled, and then only if they also appear in run commands.

include <name>

Use this command to take text from another file for compiling. A source-level library, in effect.

begin ... end

Makes a single command comprising several other commands, which may also include begin ... end blocks and so on.


The Repackage class

Occasionally you may have the need to change the name of package, such as in the unlikely event that your servlet requires a Swing interface. The Repackage class will do this for you, including the changes needed inside the documentation files. You will probably still have some minor changes to make yourself, but it saves you most of the work.


Back