Syntax

Keywords

Any identifier that is used in a syntactical element cannot be used as a lexical identifier such as a function or variable name.

Comments

Comments are denoted with two forward slashes. The comment lasts until the end of the current line. There are no multiline comments. It is customary but not necessary for comments to end in full stops.

// This is a comment.
/// This is a documentation comment.

Identifiers

Identifiers may contain any alphanumeric characters, underscores and any unicode characters that are not whitespace. They cannot consist entirely of numeric digits. These are all valid identifiers:

variable
variable_name
_unused_variable
CONSTANT
_UNUSED_constant
_1234
123_numeric

Identifiers can also contain prime tokens after the first character.

identifier'
i'dentifier''

The prime token cannot exist as a prefix or stand alone in an identifier.

// The following are NOT valid identifiers.
'identifier
'
''

Blocks

Lexical blocks are denoted through indentation levels.

outer_block
    inner_block
        inner_most_block
    inner_block
outer_block

Indentation levels use tabular characters and not spaces. The indentation must consist of a contiguous set of tabular characters at the start of the line.

Functions

fn identifier(parameter: Type) -> ReturnType:

Functions always begin with the fn keyword. The set of parameters may be empty to denote a function that does not take in any arguments. The return type may be omitted if the function returns the unit type:

fn identifier():

The function signature must end with a colon to denote the beginning of the function body. The body consists of a single expression which may be a block.

Structures

data Structure:
    field: Type,

Structures begin with the data keyword. A colon is used to denote the beginning of the structure body. Each field except the last must end with a list separator. The body ends when the block closes.

The structure fields may all be placed on the same line. In this case, the body ends when the line ends.

data Structure: field: Type,

Last updated