Guido Krüger's Web Service

The LScript Language


Introduction

Today most programs provide a lot of configuration options which must be customized properly to meet the user's needs. This could be done be either using dialogs in which the user has to do all neccessary customizations by hand or by means of a scripting language which is harder to learn but gives better automation capabilities to the customizer.

The LScript language is a simple and small scripting language based on LISP. It is written in Java and could easily be used to customize applets or applications. It provides a simple extension mechanism which allows adding further capabilities by providing language plugins written in Java (similar to TCL/TK). Due to the nature of LISP (almost everything worth noting is a function), even new control structures could be added easily:

The LScript interpreter does not attempt to emulate large LISP systems like Common Lisp or Scheme. Instead, it provides a small and easy-to-use language which has inherited it's major character from LISP like languages. The basic LScript system comes with the following plugins:

Please note that the current state of the LScript system is unfinished. Actually, it was a two-day hack plus one or two days debugging and performance tuning (thanks to the JProbe profiler from KL Group). There is no still no proper documentation (even no inline documentation) and a number of features are not yet implemented (i.e. user-defined functions). Send me an e-mail if you are interested in the project.

For now you may take a look at the LScript Short Reference which gives an overview of the most important features.

Examples

The LScript language comes with a simple interpreter application which could be used to run LScript code from the command line or from a file. The interpreter has been written as a Java application and is loctated at gk.lscript.LScript. It could be started at the command with either a LScript program as argument or a file name with LScript code (prefixed by the @ character). For example, the call
java gk.lscript.LScript "(println 1)"
creates the output:
1
<eof>
To compute the sum from 1 to 100 one could use the following program sum.lsp:
(setq sum 0)
(setq i 1)
(while (<= i 100)
   (setq sum (+ sum i))
   (setq i (add1 i)))
(println "sum(1..100) = " sum)
which is invoked using:
java gk.lscript.LScript @sum.lsp
The output is:
sum(1..100) = 5050
<eof>
To further demonstrate the capabilities of the LScript language, I wrote a simple Applet which executes LScript code given as an argument inside the paint() method. A simple GraphicPlugin provides AWT line drawing capabilites which are used to create a number of graphical effects. Switch to the example page to view some of the results. The LScript interpreter has some JDK 1.1 code in it so you need at least IE 4 or NS 4 to load the applets.
© 1995-2004 Guido Krüger - Last updated 31 Dec 2003 - Back to top-level page