< Game interface Index Compiler >

Language grammars

The Simple Item Languange (Silly) is an object-oriented language used to describe separate chunks of interrelated data called items. It defines a syntax, but no semantics. Types of items are defined in a grammar constituting a language of its own.

Grammar and data are stored in separate text files. The compiler translates data files into binary data according to the definition in a grammar file. The binary data has to be read by a specific program and interpreted according to the semantics of the grammar.

Silly was developed as a means to describe adventure games, but it may be used for several other purposes. If you are interested in the mapping from data files to binary data, send me an email.

Syntax

Note:

Grammars

An item type definition has a type name and an ID. It declares a list of attributes with a data type and a default value. A type definition has the following form:

TYPENAME <TYPEID>
{
    ATTRIBUTE=TYPE DEFAULT
    ...
}

keydescriptionformat
TYPENAMEname of the typea character string without spaces
TYPEIDinternal ID of the type used in the binary forman integer
ATTRIBUTEname of an attributea character string without spaces
TYPEtype of the attributesee below for valid data types
DEFAULTdefault value of the attribute (optional)see below for the format of data elements

A grammar file consists of a list of item type definitions. The first is always the global type that has no type ID. All type names and type IDs must be distinct. Also, the attributes of each item type have to be different.

Data

An item has an item type and a name. It assigns values to the attributes declared in its item type. There are two formats for item definitions:

TYPENAME <ITEMNAME>
{
    ATTRIBUTE=VALUE
    ...
}

TYPENAME <ITEMNAME> {VALUE1 | VALUE2 | ... | VALUEn}

keydescriptionformat
TYPENAMEtype of the itema character string without spaces
ITEMNAMEname of the itema character string without spaces
ATTRIBUTEname of an attributea character string without spaces
VALUEvalue of the attributesee below for the format of data elements

In the first format, the order of the attributes is arbitrary. In the second case, the values are assigned to the attributes according to the order in the item type declaration. An item is valid only if all attributes have a value. If no value is given explicitly, the default value is used if it is defined.

A data file is a list of item definitions. The first must have the global type and an empty name. No other item may have the global type or an empty name. All item names have to be unique.

Note: Definitions in the second format may span several lines, but the opening bracket has to be in the first line and line breaks must not be inside of a single value including lists.

Data Types

Data types define possible values of attributes. There are basic types like numbers and character strings, items and references, and lists with elements of the same type.

Basic Types

The elements of basic types are basic in the sense of being not composed of other elements. Even if they consist of several characters, they are always processed as a unite.

typeelementsformatremarks
boolboolean value0/1, t/f, T/Ftrue/false
stringstring of characters"...", ...\n = new line
filefilename as string"...", ...
bytesingle bytecharacter, 00 ... FF 
intinteger number... -1 0 1 ... 
varinteger variablea ... z, A ... Zother characters may be special variables
valueinteger variable or numberint, var 
pointpoint on screen(X,Y)screen coordinates; X, Y: int
vpointvariable point(X,Y)screen coordinates; X, Y: value
colourRGB-colour(R,G,B)red, green, blue; 0 ... 255; (-) means no colour

Note: int must be a number, var must be a variable name, and value may be either. In vpoint, either coordinate may be a number or a variable. All variables have initially the value 0.

Hint: If you want to use more remarkable names for variables, use the #define compiler directive.

Items and References

Items can be either used directly as the value of an attribute (without the name) or they are defined separately with a name. In the latter case, the item may be referred to by other items using that name (including the brackets). (In fact, items that are never referred to are useless.) The empty reference (aka null pointer) <> is also defined.

Instead of item references, item variables may be used. Like integer variables, item variables are single letters. Other characters may be special variables.

Lists

A list is an ordered collection of elements with the same data type. The elements of the list are enclosed by square brackets and separated by spaces. The elements of a list may span several lines.

Note: