Skip to main content

Syntax

Easel code is written in files with the filename extension .easel.

An Easel file consists of a series of declarations, most commonly function declarations. Other kinds of declarations include constants, properties, buffs and accumulators. Declarations often contain a block of statements.

Example of a simple Easel file:

pub const MaximumThreshold = 321 // static constant declaration

// Declare a function named MyFunction1, with its parameters and statements
pub fn MyFunction1(x) {
let y = 123 // declare a variable named 'y', assign its initial value of 123

DoSomething1 // call function DoSomething1 without arguments

if x < MaximumThreshold { // if statement
DoSomethingElse(x, y) // call function DoSomethingElse with arguments
}
}

Statements

A statement block consists one statement per line, enclosed with braces ({ and }). A statement is a single instruction to the computer. If a statement ends with punctuation that leaves it unfinished at the end of a line, it will continue on the next line.

A semicolon (;) can be used to separate multiple statements on the same line. Unlike other programming languages, Easel statements do not and should not end with a semicolon.

pub fn MyFunction1() {
CallAFunction("This is a statement")
CallAnotherFunction("This is another statement")
CallFunction3(
"This statement continues onto multiple lines" +
"because the brackets have not been closed yet" +
"and the lines end with a + operators which need a right hand side value"
)
CallAFunction("This line has statements"); CallAFunction("separated by a semicolon")
}

The most common form of statement is a function call, but there are other kinds of statements such as variable declarations, control flow statements, and behaviors.

Expressions

Commonly, statements include expressions. An expression is a combination of values, variables, operators and functions that can be evaluated to a one or more value. For example, 1 + 2 is an expression that evaluates to 3.

Expressions are evaluated according to operator precedence and associativity, so 1 + 2 * 3 equals 7. Parentheses can be used to override the default precedence and associativity, so (1 + 2) * 3 equals 9.

Whitespace

Whitespace (tabs and spaces) is insignificant, so you can and should use them to make your code more readable, for example by indenting code inside a block.

Comments

Comments can be written anywhere in a file and are demarked by either // at the beginning of their line, or between a pair of /* and */ markers.

// This is a single-line comment

/*
this is a multiple line comment
*/

Documentation comments are written using /// and are used to automatically generate reference documentation for your code.

/// This is a documentation comment which describes what MyFunction does
fn MyFunction() { }

Identifiers

An identifier is a name given to a variable, function, or other item in your code. Identifiers consist of one or more alphanumeric characters and the underscore (_) character. Whether an identifier can begin with a lowercase or uppercase letter depends on its purpose. For example, local variables must begin with a lowercase letter, whereas function names must begin with an uppercase letter.

Identifiers can also contain colon (:) characters, as long as they are not the first or last letter. The colon must immediately be followed by a letter. This can be used to group related identifiers together, somewhat like the concept of a namespace in other progrmaming languages, but it has no special meaning to the compiler.

pub const MyConstant = 456 // global identifiers must begin with an uppercase letter
pub fn Movement:MoveFast() { // colons are allowed in identifiers to help with namespacing
let myVariable = 123 // local identifier must begin with a lowercase letter
}