The full syntax description

Program

The compiler expects input code to be a "program", a program is defined as a list of the following statements:

Directives

Directives follow the format:

#Directive Parameter

Directives are direct instructions for the compiler, and do not generate any code.

The include directive will copy-paste the contents of another file into the position the directive is at.

Declare

Declare statements follow the format:

Declare ReturnType FunctionName(ParameterTypeList)

Declare statements are use to tell the compiler what types FunctionName should be passed (and will return) before it has parsed the full definition of FunctionName

DllImport

DllImport statements follow the format:

DllImport ReturnType FunctionName(ParameterTypeList) {DllFileName.dll, FunctionNameInsideDLL}

Define

Define statements follow the format:

Define ReturnType FunctionName(ParameterList) export {
    Body
}

Struct

Struct statements follow the format:

struct StructName {
    Type Name,
    Type Name,
    union {
        Type Name,
        Type Name
    },
    Type Name
}

Global

Global declarations follow the same format as regular declarations. However, global declarations make variables that are program-wide, and can be used from any function. Additionally, global declarations run just before Main is run, making them a suitable method to run setup code.

Statements

Statements follow multiple different formats, depending on the type of statement.

It is important to note that this 'statement' category does not include the program statements, which are not allowed inside of functions.

All of the above statements are allowed inside of functions and other structures such as for loops or if statements.

Declarations

Declarations follow the format(s):

TypeName VariableName
TypeName VariableName := Value

Variables that do not have a default value should be considered to have an undefined value until they are otherwise assigned.

Keywords

Keyword statements follow multiple different formats, depending on the keyword used.

These are all of the statements implemented, there are no while loops.

If

If statements follow a single variable format, depending on the structure of the if statement:

if (Condition) {
    Body
}
else if (OtherCondition) {
    Body
}
else {
    Body
}

else if can be repeated any number of times, for any number of conditions. There can only be one else for each if statement.

For

For loops follow the format:

for (Init, Condition, Step) {
    Body
}

Init can optionally be a declaration and is run before the loop first stats, and never again.

Condition is checked before the loop runs an iteration, and if it is false, the loop will stop.

Step is run after each iteration of the loop.

Break-Continue

Break and continue both follow the format:

Break
Continue

With no extra code.

The break and continue statements are only valid inside of for loops.

Return

Return statements follow the format:

Return Value

Value must evaluate to a type compatible to the return type of the current function.

Expression-Statements

Expression statements follow the format:

Expression

If Expression does not call a function or set a variable, it will be eliminated by the compiler during dead-code elimination.

Expression

Expressions follow many formats, examples:

A := B + C
(2 - E) / 2
9999 + *(G) % H

Additionally, there is the format:

Something[SomethingElse]

Where Something is an expression which results in a pointer-type, and SomethingElse results in an integer, which will be used as an index into Something.

Operators are listed on this page

Types

A type is simply a combination of a identifier, with any number of *s after it (each * increases the level of nested pointers)

The base type names are

With pointer (and pointer-pointer) types for each, like:

void*  - Pointer to void
i16**  - Pointer to a pointer to an i16
i8*    - Pointer to an i8

void*****************    - Pointer to a pointer to a pointer to a pointer to a pointer to a pointer to a pointer.... you get it

Names

Names are simply combinations of characters and numbers. Names must start with a-z, but can contain numbers after the first letter.