-
Notifications
You must be signed in to change notification settings - Fork 10
Home
The compiler for Expression 3 is a huge work in progress and there for the syntax of this language is likly to change over the course of its development.
Expression 3 uses a language based on expression advanced 2 but is closer to c#, it is often described as a lua and c# mash up.
Expression 3 support 2 styles of comments. Single line
//Example of a single line comment
Multi line
/* Example
of a multi line
comment */
In expression 3 a block of code is wrapped in curly brackets.
{
// Example
}
These brackets can be omitted causing only the first line to be used as the block.
An if statement is a conditional statement that will execute a block of code only under certain conditions.
if (Condition) block
elseif (Condition) block
else block`
if (false) {
debug.print(0)
} elseif (false) {
debug.print(1)
} else {
debug.print(2)
}
These statements will only execute a block of code based on if the code is running server side or client side.
server block
client block
server {
debug.print("server");
}
client {
debug.print("client");
}
All assignment statements in expression 3 can be used to assign one or more values at once.#
When defining a variable it is important to note that it is nested to its current block.
class variable[, variable]* = expression[, expression]*;
number a = 7;
string first, last = "John", "Doe";
Same as a definition statement except defines a global variable, these variables are not nested to there current block.
global class variable[, variable]* = expression[, expression]*;
global number a = 7;
global string first, last = "John", "Doe";
Assignments are used to assign a value to an existing variable.
variable[, variable]* = expression[, expression]*;
a = 7;
first, last = "John", "Doe";
Arithmetic assignments are used to perform an arithmetic operation on a variable and then assign the result of that operation to the variable.
variable[, variable]* += expression[, expression]*;
exampleVar, anotherVar += 100, 200;
variable[, variable]* -= expression[, expression]*;
exampleVar, anotherVar -= 100, 200;
variable[, variable]* \= expression[, expression]*;
exampleVar, anotherVar \= 100, 200;
variable[, variable]* *= expression[, expression]*;
exampleVar, anotherVar *= 100, 200;
Expression 3 supports user defined functions.
function type variable([type parameter,]*) block
function int example(int a, int b) {
return a + b;
}
Delegates are function templates and are used by the compiler to retain information about a functions parameters as well as its return values. This will be covered in depth in a later section.
delegate type variable([type,]*) {
return number
}
delegate string example(string, string) {
return 1
}
The number that appears after return is the amount of values returned of type.
Expression ? Expression : Expression
Expression || Expression
Expression && Expression
Expression ^^ Expression
Expression | Expression
Expression & Expression
Expression & Expression
Expression == Expression
Expression != Expression
This is a nifty addition to expression 3 that allows you to compare if 1 value is equal to any of a list of values.
Expression == [[Expression,*]]
1 == [1, 2, 3]
Just like the previous this allows you to compare if 1 value not is equal to any of a list of values.
Expression != [[Expression,*]]
Expression > Expression
Expression < Expression
Expression >= Expression
Expression <= Expression
Expression << Expression
Expression >> Expression
Expression + Expression
Expression - Expression
Expression / Expression
Expression * Expression
Expression ^ Expression
Expression % Expression
+Expression
-Expression
!Expression
#Expression
The casting operator takes a class. The Compiler will then try to convert the value on the right to that class.
(Class) Expression
number i = (number) 101;
A Constructor is used to create an object.
new Class([expression,]*)
new vector.3d(1, 1, 1)
In expression 3 some objects can be called, user functions being the main one.
Value([Expression,]*)
//No good examples currently exist.
In expression 3 all functions exist with in a library.
Library.Function([Expression,]*)
debug.print(278)
Value.Method([Expression,]*)
"string".find("s")
Events are lambda based callbacks that are used to repsond to events outside the main execution. Events work simular to the hook system in gmod lua.
event.add(string event name, string callback id, function callback )
event.add("Think", "example", function() { system.print("think") })
Simularly you can remove event call backs
event.remove(string event name, string callback id)
event.remove("Think", "example")