1. General Syntax
GSL Source Files need to have the extension .gsl. The encoding should be UTF-8 or ISO-Latin-1. A Source File is executed from top to bottom.
GSL is case sensitive, all keywords are written in lower case letters only. So, "if" is not equals to "If" or "IF".
GSL doesn't use whitespaces, tabs or newlines for parsing. So, you can format your script as you wish. The following
three code snippets are semantically equivalent:
if(a>b){i=4;}
if(a > b)
{
i = 4;
}
Statements which are surrounded by curly braces are considered a statement block. Nonglobal variables defined inside such a block are not visible outside of it.
{
int i = 5;
}
i = 6;
The line "i = 6;" will throw an error, because i is defined inside a block and is not visible after leaving the block.
A statement block itself is again a statement. So you can use a statement block everywhere, where you could also use a single statement.
A prominent example is the if (or any other control structure):
if(a > b){
statement1;
statement2;
...
}
Comments are parts of text which are ignored by the compiler. There are two sorts of comments in GSL.
Line comments, which end at the end of the line. These start with //
Block comments, which start with /* and end with */. They can include many lines.
Here is an example for both types
/*
This
comment
can
range
over
several
lines */
These words are part of the language gsl and may not be used as identifiers (var names, function names, type names).
Basic keywords:
- break
- catch
- continue
- else
- extends
- extern
- for
- global
- if
- instanceof
- namespace
- new
- null
- return
- this
- trap
- try
- typedef
- type
- typetostr
- strtotype
- unset
- while
The boolean literals:
The type names (case insensitiv for the first letter):
- array Array
- bool Bool
- container Container
- float Float
- int Int
- object Object
- string String
- struct Struct
- var Var
- void Void