Skip to content
Rusketh edited this page Nov 16, 2016 · 47 revisions

Expression Three

Syntax

Work in progress

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.

Similarities

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.

Comments

Expression 3 support 2 styles of comments. Single line

//Example of a single line comment

Multi line

/* Example
of a multi line
comment */

Blocks

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.

Statements

If Statement

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`

Server and Client Statement

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

Assignments

All assignment statements in expression 3 can be used to assign one or more values at once.#

Definition statement

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";
Global definition statement

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";
Assignment statement

Assignments are used to assign a value to an existing variable.

variable[, variable]* = expression[, expression]*;

a = 7;
first, last = "John", "Doe";
Arithmetic assignment statement

Arithmetic assignments are used to perform an arithmetic operation on a variable and then assign the result of that operation to the variable.

Additon
 variable[, variable]* += expression[, expression]*;

 exampleVar, anotherVar += 100, 200;
Subtraction
 variable[, variable]* -= expression[, expression]*;

 exampleVar, anotherVar -= 100, 200;
Division
 variable[, variable]* \= expression[, expression]*;

 exampleVar, anotherVar \= 100, 200;
Multiplication
 variable[, variable]* *= expression[, expression]*;

 exampleVar, anotherVar *= 100, 200;

User Function statement

Expression 3 supports user defined functions.

function type variable([type parameter,]*) block

function int example(int a, int b) {
    return a + b;
}

Delegates

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.

function type variable([type,]*) {
    return number
}

function string example(string, string) {
    return 1
}

The number that appears after return is the amount of values returned of type.

Expressions

Operators

Ternary (Conditional)
Expression ? Expression : Expression
Logical Or
Expression || Expression
Logical And
Expression && Expression
Binary Xor
Expression ^^ Expression
Binary Or
Expression | Expression
Binary And
Expression & Expression
Binary And
Expression & Expression
Equal To
Expression == Expression
Not Equal To
Expression != Expression
Grater Than
Expression > Expression
Less Than
Expression < Expression
Grater Or Equal To
Expression >= Expression
Less or Equal To
Expression <= Expression
Binary Shift Left
Expression << Expression
Binary Shift Right
Expression >> Expression
Addition
Expression + Expression
Subtraction
Expression - Expression
Division
Expression / Expression
Multiplication
Expression * Expression
Exponent
Expression ^ Expression
Modulus
Expression % Expression
Positive
+Expression
Negative
-Expression
Not
!Expression
Lengh
#Expression
Cast

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;

Constructors

A Constructor is used to create an object.

new Class(expression[, expression]*)

new vector.3d(1, 1, 1)
Clone this wiki locally