Aspen

A toy programming language

Control Flow

Aspen has the standard control flow constructs found in many programming languages: if, while and for.

If Statements

The if statement takes a boolean expression. If the expression evaluates to true then the block following will be executed.

if (/* condition */) {
    // code...
}

The code following any control flow construct must be a block. The following is not allowed:

if (true)
    print "Not allowed";

if statements can be chained with else if and else.

if (/* condition */) {
    // code...
} else if (/* condition */) {
    // code...
} else {
    // code...
}

While Loops

A while loop takes a boolean expression. The code in a while loop is executed until the boolean expression is false.

let i i64 = 0;
while (i < 10) {
    print i;
    i = i + 1;
}

For Loops

for loops are what you expect.

for (let i i64 = 0; i < 10; i = i + 1) {
    print i;
}

Aspen does not have the ++ or += operator commonly found in other programming languages.