| < Game interface | Index | Compiler > |
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.
Note:
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
...
}
| key | description | format |
|---|---|---|
| TYPENAME | name of the type | a character string without spaces |
| TYPEID | internal ID of the type used in the binary form | an integer |
| ATTRIBUTE | name of an attribute | a character string without spaces |
| TYPE | type of the attribute | see below for valid data types |
| DEFAULT | default 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.
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}
| key | description | format |
|---|---|---|
| TYPENAME | type of the item | a character string without spaces |
| ITEMNAME | name of the item | a character string without spaces |
| ATTRIBUTE | name of an attribute | a character string without spaces |
| VALUE | value of the attribute | see 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 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.
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.
| type | elements | format | remarks |
|---|---|---|---|
| bool | boolean value | 0/1, t/f, T/F | true/false |
| string | string of characters | "...", ... | \n = new line |
| file | filename as string | "...", ... | |
| byte | single byte | character, 00 ... FF | |
| int | integer number | ... -1 0 1 ... | |
| var | integer variable | a ... z, A ... Z | other characters may be special variables |
| value | integer variable or number | int, var | |
| point | point on screen | (X,Y) | screen coordinates; X, Y: int |
| vpoint | variable point | (X,Y) | screen coordinates; X, Y: value |
| colour | RGB-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 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.
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:
[Type {...} Type {...}] you may use Type [{...} {...}]