Difference between revisions of "The Script Programming Language"
(→Files) |
(→Files) |
||
Line 56: | Line 56: | ||
− | + | == <br />Files == | |
Source files for the script compiler have the extension .sc, header (include) files have the extension .sh. Source files may have any filename -- banner.sc and castle.sc are two examples. The output file from the compilation will have the name script.nnn where nnn is determined from the script# command (covered below) which is present in the file. | Source files for the script compiler have the extension .sc, header (include) files have the extension .sh. Source files may have any filename -- banner.sc and castle.sc are two examples. The output file from the compilation will have the name script.nnn where nnn is determined from the script# command (covered below) which is present in the file. |
Revision as of 18:34, 28 November 2015
The Script Programming Language
Author: Jeff Stephenson
Date: 4 April 1988
Introduction
The Script adventure game language is an object-oriented language with a Lisp-like syntax. It is compiled by the sc compiler into the pseudo-code which is used by the interpreter, sci.
We will begin our discussion of the language with its basic Lisp-like characteristics, then go on to the object-oriented parts of the language.
As is Lisp, Script is based on parenthesized expressions which return values. An expression is of the form
Code:(procedure [parameter parameter ...]).
The parameters to a procedure may themselves be expressions to be evaluated, and may be nested until you lose track of the parentheses.
Unlike Lisp, the procedure itself may NOT be the result of an evaluation. An example of an expression is
Code:(+ (- y 2) (/ x 3))
which would be written in infix notation as
Code:(y - 2) + (x / 3).
All expressions are guaranteed to be evaluated from left to right. Thus,
Code:(= x 4) (= y (/ (+= x 4) (/= x 2)))
will result in y = 2 and x = 4.
Comments in Script begin with a semi-colon, ';', and continue to the end of the line.
Files
Source files for the script compiler have the extension .sc, header (include) files have the extension .sh. Source files may have any filename -- banner.sc and castle.sc are two examples. The output file from the compilation will have the name script.nnn where nnn is determined from the script# command (covered below) which is present in the file.
There are six files besides the source file and any user-defined header files which are involved in a compilation.
classdef
This file contains the information about the structure of the classes which have been defined in the application. It is read automatically by the compiler and is rewritten by the compiler after a successful compilation in order to keep it up to date. The user need not be concerned with it.
selector
This contains definitions of selectors which are used in object-oriented programming. It is automatically included in a compile and, like classdef, is rewritten after a successful compile. Any symbol in a properties or methods statement or in the selector position in a send to an object is assumed to be a selector and is assigned a selector number in included in selector.
kernel.sh
This contains the definitions for interfacing with the kernel (the machine language interpreter). It is maintained by the kernel programmers and is automatically included in system.sh.
system.sh
This contains the definitions for interfacing with the various system classes. It is initially provided by the kernel programmers. If you wish to tweak the system scripts yourself, you will also be responsible for maintaining your copy of system.sh. It should be included in all compiles.
vocab.000
This is the compiled output of vocab.txt, generated by the vocabulary compiler vc. It is automatically included in a compile.
classtbl
This is an output file of the compiler which is used by the kernel to determine which script a given class is defined in. You needn't do anything to it other than not delete it.