Linguist - a whistle-stop tour

First here's a simple four-function calculator written using a Linguist script. It can run either as an applet or as an application without recompiling. The source script file is Calculator.ls.

The applet/application itself is LS.class. This is a front-end for the Linguist compiler and runtime interpreter and takes as arguments the name of the script and optional parameters as described below.

Here is a crude demonstration of Linguist graphics, based on some images originally intended for a simple platform game. It too can be run either as an application or an applet. In either case it uses a set of scripts, as follows:

Demo.ls The main program, that launches each of the other scripts. It manages the main window, the stage and the background image.
Keeper.ls Controls the red robot (that likes fish).
Foxey.ls Controls the player character.
Scroller.ls Handles scrolling of the background image.

Clicking in a 50-pixel band on either side of the backdrop causes the image to scroll. Foxey always follows the click. Take care not to click on Foxey or the Keeper as they currently eat mouse clicks.

To run the demo as an application, use this command line:

java LS Demo.lrun

To compile the script(s) then run, use

java LS Demo.ls -r

To create the .lrun file, use -o instead of -r.

To run the debugger (see below), use

java LS Demo.ls -d


Linguist is a tool for building custom script languages. In this case the language is for multimedia. We provide all the core classes for managing scripts; the user of the package defines his script language and writes the compile, runtime and debug handlers in Java. We supply the source of all the handlers for the multimedia language, as a starting point. Click -<here>- for some outline documentation of the system.


The debugger needs a lot more work, but here's a brief guide. Run this command:

java LS Demo.ls -d

There should now be three windows. The main one, 'Linguist', has three control buttons and a panel for displaying variables. The second is the Script Observer, which should be showing the source of Demo.ls. The third is the Script List window, which currently shows just the name 'Demo'. Here's what you do.

Re-arrange the windows if necessary to a convenient format so you can see their contents. Now try clicking on lines in the Script Observer. If you click on a command you get a red blob; this indicates a breakpoint has been set. Click on a variable and you get a green blob and the variable is opened in the main window. So select all the variables; MainWindow, Stage, Backdrop and X.

Clicking on a variable name in the main Linguist window opens up another window that contains more information about the variable. The content of this last window is up to the script builder; we merely provide the framework.

The Step button single-steps the script; Run runs it and Exit stops it and exits. So let's single-step a few lines. The first thing that happens is the main window gets created. If you drag it around you'll see its location changing in the variable panel. After that the script creates a Stage (a subclass of Canvas) and an Actor; loads a JPEG image into the Actor and shows it.

Stepping through some more launches the other scripts. Because we're stepping they start off paused. There's nothing more this script does, so hit the run button. In the Script List you'll see the main program is running and all the others are paused.

Click on the Keeper in the Script List. The context changes to that module; you can select variables here for view. But first, hit the run button. With any luck the Keeper is now running. You can examine its variables as it runs; or hit a command line to set a breakpoint. The variables continue to update even while the script is running.

Similarly for the other modules; each can be examined without any effect on the others.


Very brief 'How it Works'

With the help of classes written for the script language being implemented, Linguist compiles the script into a Vector of runtime handler classes. The runtime calls the execute() method of each class, which performs its duties and returns the index of the next instruction. This keeps the overhead low. Each script has its own program Vector and runs in its own thread, though scripts can hand variables back and forth.