Skip to main content

Values

Integer Literals

decimal := 114514;
hex := 0xff;
another_hex := 0xFF;
octal := 0o76;
binary := 0b100111;

//underscores may be placed between two digits as a visual separator
underscore_separator := 100_000_000;

Float Literals

floating_point := 123.0E+77;
another_float := 123.0;
yet_another := 123.0e+77;

hex_floating_point := 0x103.70p-5;
another_hex_float := 0x103.70;
yet_another_hex_float := 0x103.70P-5;

//underscores may be placed between two digits as a visual separator
lightspeed := 299_792_458.000_000;
nanosecond := 0.000_000_001;
more_hex := 0x1234_5678.9ABC_CDEFp-10;

Character Literals

A character literal is a character quote by '':

char : test "Character Literals" = {
c := 'a':c8;
nl := '\n':c8;
}

String Literals

String Literals

A string literal is a character sequence quoted by "", the character sequence may contains escape sequences:

string : test "String Literals" = {
str1 := "Hello World!";
escape := "next line\n";
}

Interpolated String Literals

A interpolated string literal is a character sequence which contains capture expressions. The interpolated string literal needs to be quoted by "":

fstring : test "Interpolated String Literals" = {
i := 42:i32;
b := true;
arr : [_]i32 = {1, 1, 5};
fstr := "i = i$, b = b$, arr = arr$";
assert(fstr == "i = 42, b = true, arr = {1, 1, 5}");
}

Raw String Literals

A raw string literal is a character sequence quoted by R"()":

raw_string : test "Raw String Literals" = {
no_escape := R"(next line\n)";
assert(no_escape == "next line\\n");
}

Interpolated Raw String Literals

A raw string literal is a character sequence quoted by R"()", the character sequence contains capture expressions:

raw_fstring : test "Interpolated Raw String Literals" = {
i := 42:i32;
b := true;
arr : [_]i32 = {1, 1, 5};
fstr := R"(i = "i$", b = "b$", arr = "arr$")";
assert(fstr == "i = \"42\", b = \"true\", arr = \"{1, 1, 5}\"");
}

Multiline String Literals

Multiline string literals have no escapes and can span across multiple lines. To start a multiline string literal, use the """ token.

multiline_string : test "Multiline String Literals" = {
multiline_str := """
#include <stdio.h>

int main(int argc, char **argv) {
printf("hello world\n");
return 0;
}"""
;
}

Escape Sequences

Escape SequenceDescription
\\'Single quote
\\"Double quote
\\?Question mark
\\\\Backslash
\\aAudible bell
\\bBackspace
\\fForm feed - new page
\\nLine feed - new line
\\rCarriage return
\\tHorizontal tab
\\vVertical tab
\\u{NNN}Arbitrary Unicode value