Hi All,
Clash macro language description.
Please read it (and criticize it)
Rules:
1. Basic types: Number (no distinction between real and integers)
String
Boolean (true and false)
2. Non case sensitive.
3. Two different kind of code module: Library
Trigger
4. Library: only functions and local variables in functions, but no constants and global variables.
Trigger: functions, variables, constants and the main function which has the same name like the trigger source code and will start when the system call that trigger.
5. Functions can contain variable declaration, but no constant declaration. Those variables are local in the function.
6. Comments with // (double slash).
Syntax:
Library source file:
// here start the library source code
Library;
Number | String | Boolean | Void Function1(Type Name, Type Name, ...) {
Variable
Type Name1 := Value;
Type Name2 := Value;
EndVariable
Statements;
Return;
}
Number | String | Boolean | Void Function2(Type Name, Type Name, ...) {
Variable
Type Name1 := Value;
Type Name2 := Value;
EndVariable
Statements;
Return;
}
// Here is the end of the library source code. The file name must have a .cli extension.
// Here starts the trigger source code.
Trigger;
Library Library1Name;
Library Library2Name;
Constant
Type Name1 := Value;
Type Name2 := Value;
EndConstant
Variable
Type Name1 := Value;
Type Name2 := Value;
Array Type Name1[Index1, Index2, ...];
Array Type Name2[Index1, Index2, ...];
EndVariable;
Number | String | Boolean | Void Function1(Type Name, Type Name, ...) {
Variable
Type Name1 := Value;
Type Name2 := Value;
EndVariable
Statements;
Return;
}
Number | String | Boolean | Void Function2(Type Name, Type Name, ...) {
Variable
Type Name1 := Value;
Type Name2 := Value;
EndVariable
Statements;
Return;
}
Void Trigger(Type Name, Type Name, ... ) {
Variable
Type Name1 := Value;
Type Name2 := Value;
EndVariable
Statements;
Return;
}
// Here is the end of the trigger source code. The file name must have a .ctr extension.
The Trigger function ALWAYS Void. The Trigger Function name the same like the trigger source code name and the same like the built in trigger name:
Let say we have a trigger in the game: EndOfTurn
In this case the trigger source code name is: EndOfTurn.ctr
The trigger main function:
Void EndOfTurn(Turn Number) {
Variable
Type Name1 := Value;
Type Name2 := Value;
Variableend
Statement1;
.
.
.
StatementN;
Return;
}
Instructions:
Statements:
Simple Statements:
Assignment:
variable := expression;
expression: must be type compatible with the variable
Void function calls:
i.e.:
MyFunction(First,Second);
Structured statements:
1. Compound statement:
All the simple statements between the { and } brackets.
i.e.:
{
a := 158;
b := MyFunc(125,25);
}
2. If statement:
If (Boolean expression)
Simple or compound statement1
//optional
else
Simple or compound statement2
If the Boolean expression is true then statement1 is executed, otherwise the statement2 is executed.
3. While statement:
While (Boolean expression)
Simple or compound statement
The while statement executes as long as the Boolean expression returns true.
4. Do While statement:
Do
Simple or compound statement
While (Boolean expression)
The while statement executes as long as the Boolean expression returns true.
5. For statement:
For(Initial value, final value, counter)
Simple or compound statement
The for statement executes as long as the final value is true.
Expression:
The order of the execution can be determined by brackets ( and )
1. Numeric:
Constant (i.e. 16)
Variable (i.e. N)
Function Sum(A, B, C);
Addition + Op1 + Op2 (i.e. 16+12)
Subtraction - Op1 - Op2 (i.e. 16-N)
Multiplication * Op1 * Op2 (i.e. 12*N)
Division / Op1 / Op2 (i.e. 12/2)
Negation - -Op (i.e. -N)
Increment ++ ++Op or Op++ (i.e. ++N) Op must be a number variable!
Decrement -- --Op or Op-- (i.e. N--) Op must be a number variable!
2. String
Constant (i.e. 'AbcD')
Variable (i.e. S)
Function Uppercase('abc');
Concatenation + Op1 + Op2 (i.e. S+'cd')
3. Boolean
Constant (i.e. true)
Variable (i.e. T)
Function Good();
And & Op1 & Op2
Or | Op1 | Op2
Not ! ! Op
Relational operators (Result ALWAYS Boolean)
Numeric: (Op1 and Op2 are numeric expressions)
Equality = Op1 = Op2
Inequality != Op1 != Op2
Less-than < Op1 < Op2
Greater-than > Op1 > Op2
Less-than or equal to <= Op1 <= Op2
Greater-than or equal to >= Op1 >= Op2
String: (Op1 and Op2 are string expressions)
Equality = Op1 = Op2
Inequality <> Op1 <> Op2
Calling Order:
Let say we wold like to play with the "myscenario" scenario. The system first start to load all the triggers and libraries from the default directory After looking for triggers and libraries in the "myscenario" scenario directory:
i.e.:
first ...\default\mod\*.ctr (triggers)
...\default\mod\*.clb (libraries)
after
...\myscenario\mod\*.ctr (triggers)
...\myscenario\mod\*.clb (libraries)
If the system find triggers in the "myscenario" library with the same names like the defaults, then the system will use those "myscenario" triggers to control the game.
Blade Runner
[This message has been edited by Blade Runner (edited August 13, 1999).]
Clash macro language description.
Please read it (and criticize it)
Rules:
1. Basic types: Number (no distinction between real and integers)
String
Boolean (true and false)
2. Non case sensitive.
3. Two different kind of code module: Library
Trigger
4. Library: only functions and local variables in functions, but no constants and global variables.
Trigger: functions, variables, constants and the main function which has the same name like the trigger source code and will start when the system call that trigger.
5. Functions can contain variable declaration, but no constant declaration. Those variables are local in the function.
6. Comments with // (double slash).
Syntax:
Library source file:
// here start the library source code
Library;
Number | String | Boolean | Void Function1(Type Name, Type Name, ...) {
Variable
Type Name1 := Value;
Type Name2 := Value;
EndVariable
Statements;
Return;
}
Number | String | Boolean | Void Function2(Type Name, Type Name, ...) {
Variable
Type Name1 := Value;
Type Name2 := Value;
EndVariable
Statements;
Return;
}
// Here is the end of the library source code. The file name must have a .cli extension.
// Here starts the trigger source code.
Trigger;
Library Library1Name;
Library Library2Name;
Constant
Type Name1 := Value;
Type Name2 := Value;
EndConstant
Variable
Type Name1 := Value;
Type Name2 := Value;
Array Type Name1[Index1, Index2, ...];
Array Type Name2[Index1, Index2, ...];
EndVariable;
Number | String | Boolean | Void Function1(Type Name, Type Name, ...) {
Variable
Type Name1 := Value;
Type Name2 := Value;
EndVariable
Statements;
Return;
}
Number | String | Boolean | Void Function2(Type Name, Type Name, ...) {
Variable
Type Name1 := Value;
Type Name2 := Value;
EndVariable
Statements;
Return;
}
Void Trigger(Type Name, Type Name, ... ) {
Variable
Type Name1 := Value;
Type Name2 := Value;
EndVariable
Statements;
Return;
}
// Here is the end of the trigger source code. The file name must have a .ctr extension.
The Trigger function ALWAYS Void. The Trigger Function name the same like the trigger source code name and the same like the built in trigger name:
Let say we have a trigger in the game: EndOfTurn
In this case the trigger source code name is: EndOfTurn.ctr
The trigger main function:
Void EndOfTurn(Turn Number) {
Variable
Type Name1 := Value;
Type Name2 := Value;
Variableend
Statement1;
.
.
.
StatementN;
Return;
}
Instructions:
Statements:
Simple Statements:
Assignment:
variable := expression;
expression: must be type compatible with the variable
Void function calls:
i.e.:
MyFunction(First,Second);
Structured statements:
1. Compound statement:
All the simple statements between the { and } brackets.
i.e.:
{
a := 158;
b := MyFunc(125,25);
}
2. If statement:
If (Boolean expression)
Simple or compound statement1
//optional
else
Simple or compound statement2
If the Boolean expression is true then statement1 is executed, otherwise the statement2 is executed.
3. While statement:
While (Boolean expression)
Simple or compound statement
The while statement executes as long as the Boolean expression returns true.
4. Do While statement:
Do
Simple or compound statement
While (Boolean expression)
The while statement executes as long as the Boolean expression returns true.
5. For statement:
For(Initial value, final value, counter)
Simple or compound statement
The for statement executes as long as the final value is true.
Expression:
The order of the execution can be determined by brackets ( and )
1. Numeric:
Constant (i.e. 16)
Variable (i.e. N)
Function Sum(A, B, C);
Addition + Op1 + Op2 (i.e. 16+12)
Subtraction - Op1 - Op2 (i.e. 16-N)
Multiplication * Op1 * Op2 (i.e. 12*N)
Division / Op1 / Op2 (i.e. 12/2)
Negation - -Op (i.e. -N)
Increment ++ ++Op or Op++ (i.e. ++N) Op must be a number variable!
Decrement -- --Op or Op-- (i.e. N--) Op must be a number variable!
2. String
Constant (i.e. 'AbcD')
Variable (i.e. S)
Function Uppercase('abc');
Concatenation + Op1 + Op2 (i.e. S+'cd')
3. Boolean
Constant (i.e. true)
Variable (i.e. T)
Function Good();
And & Op1 & Op2
Or | Op1 | Op2
Not ! ! Op
Relational operators (Result ALWAYS Boolean)
Numeric: (Op1 and Op2 are numeric expressions)
Equality = Op1 = Op2
Inequality != Op1 != Op2
Less-than < Op1 < Op2
Greater-than > Op1 > Op2
Less-than or equal to <= Op1 <= Op2
Greater-than or equal to >= Op1 >= Op2
String: (Op1 and Op2 are string expressions)
Equality = Op1 = Op2
Inequality <> Op1 <> Op2
Calling Order:
Let say we wold like to play with the "myscenario" scenario. The system first start to load all the triggers and libraries from the default directory After looking for triggers and libraries in the "myscenario" scenario directory:
i.e.:
first ...\default\mod\*.ctr (triggers)
...\default\mod\*.clb (libraries)
after
...\myscenario\mod\*.ctr (triggers)
...\myscenario\mod\*.clb (libraries)
If the system find triggers in the "myscenario" library with the same names like the defaults, then the system will use those "myscenario" triggers to control the game.
Blade Runner
[This message has been edited by Blade Runner (edited August 13, 1999).]
Comment