Basic Syntax

Comments

In TL5 Single line comments start with ;, multi-line comments start with [;, and end with ;]. Comments that are not in line start are not supported yet - but will be supported in the final syntax.

; single line comment
[; <-- multi-line comment start
multi
line
comment
multi-line comment end --> ;]
var Uint32 x  ; not supported yet :(

Some suggest to change this in the final syntax to be as in C with //, /* and */.

Documentation

Documentation have their own dedicated syntax: they start and end with ~~~. Documentation must be placed at line start and may be single or multi-line.

In TL5 documentation are treated as comments. In the final syntax they must come before the element they are documenting, they could be used dynamically in the code, and would be used to automatically generate external documentation.

~~~ single line documentation ~~~
func documented-function()
    ; do stuff

~~~  <-- multi-line documentation start
multi
line
documentation
multi-line documentation end --> ~~~
func another-documented-function()
    ; do stuff

Operators

  • assignment: :=

  • arithmetic: +, -, *, div, mod, clamp, wraparound

  • assignment and arithmetic: +=, -=, *=

  • bitwise: bnot, bor, band, xor, shr, shl

  • relational (arithmetic): =, <>, <, >, <=, >=

  • relational (referential): is, is-not, ?

  • logical: not, or, and

  • miscellaneous: ., [], [:], (), :=:

Any operator may be followed by a line brake with additional indentation of exactly 8 spaces:

x := 3 +
        4
y :=
        3 + 4
z :=
        3 +
        4

Operator Precedence

  1. . [] () ?, left-to-right

  2. bnot

  3. - +, * div mod, bor band xor shr shl, left-to-right [1]

  4. = != > < >= <= is is-not, left-to-right [2]

  5. not

  6. or, and, left-to-right [1]

  7. clamp wraparound, only one allowed

  8. := += -= *= :=:, only one allowed

[1] cannot combine operators from different sub-groups of this group, they must be separated using (), for example a + b * c is not legal and should be changed to a + (b * c)

[2] multiple operators from this group combined will be separated with and operator, for example, a < b < c < d is treated as a < b and b < c and c < d

Modules

In TL5 each Lumi file is declared under a single module, multiple files may be declared under the same module.

The first line of each file must declare its module using the module keyword:

module my-module-name

Only a single documentation block can come before it.

Using any item of another module must come after the other module prefix:

var other-module.SomeType variable
other-moudle.function(user variable)

In the final syntax modules and libraries support will be greatly extended - the exact syntax is still under planning.