Introduction

September 1, 2020 · View on GitHub

Currently this is a living document as there's still alot to define and write down regarding the Luf language. However, here you can find the basic internal information regarding its its defintion.

Precedence

The order of which expressions are executed is as follow where the highest precedence is executed before a lower precedence.

NameTokens
lowestExpressions not defined here
range..
oror
andand
assign=, +=, -=, *=, /=
equals==, !=,
less_greater<, >, <=, >=
bitwise_or`
bitwise_xor^
bitwise_and&
shift<<, >>
sum+, -
product%, /, *
prefix!, - (negation), ~
callsome_function()
index. i.e list.len

Arithmetic

Please note that not all arithmetic has yet been implemented. There's still a few assign-and-op shorthands missing

NameSyntaxTypes
Additiona + b, a += bint, string
Substractiona - b, a -= bint
Multiplicationa * b, a *= bint
Divisiona / b, a =/ bint
Remainder divisiona % bint
Negation-aint
Bitwise xora ^ bint
Bitwise ora | bint
Bitwise anda & bint
Bitwise not~aint
Shift lefta << bint
Shift righta >> bint
anda and bbool
ora or bbool
not bool!abool
equala == bbool, int, string
Not equala != bbool, int, string
Greater thana > b, a >= bint
Less thana < b, a <= bint

Bytecode

All VM instructions are 24 bits. The first bit of the instruction contains the opcode, where the remaining 16 bits can be used to point to another instruction or define a parameter. For example, it can contain the value 2 to the opcode make_array to specify its length.

All instructions with its definitions will be documented here soon™.

Types

Currently the following types are implemented.

syntaxNotes
int64 bit signed integer
stringutf-8 encoded list of characters
boolnative zig boolean (u1)
[5]typelist of type of length 5
[5]type1:type2map with type1 as key and type2 as value of length 5

In the future users can specify their own Types using composable Structs.