Skip to content

Syntax Reference

This page gives an in-depth overview of syntax element types for *.tls and *.tl file types.

Tacholang Script files serve the purpose of declarative configuration files. Whilst they allow for calling methods, declaring methods or classes is not possible. They also do not run on the same stdlib as regular Tacholang. A TLS provider must explicitly expose all methods.

A generic TLS file can use a format specifier at the start of the file (has to be the first statement), which defines the possible declarations a TLS file may hold, as well as any pre-defined variables or methods. A format may also introduce new data types.

Example of format specifiers:

!builtin core/format // The built-in format, which lets you create new formats
!github external/my-lib file format.tls // Fetch a file from a GitHub repository
!url https://strokkur.net/my-own-format // Fetch from URL

Single-line comments can be defined with //. Multiline comments with /* */.

A couple of data types exists.

Type NameDescriptionExample
identifierA word of alphanumerical characters, -, and _.log4tl, discord_tl, disable-boot
intA whole number, may be negative. 64 bits.5, -26, 0x80
uintA whole, positive number. 64 bits.83, 0xFFAA
floatA floating-point number. 128 bits. Signed.26.005, -0.00006
ufloatA positive floating-point number. 128 bits.8882.2, 25
stringA string of characters, enclosed in "."foo", "Templates: ${true}"
charA single unicode character.'a', '\u2556, \a32
boolA true of false value.true, false

A TLS file always defines these data types. However, the format may introduce additional data types not listed here via typedef <name> <regex> declarations in a format definition file.

TLS supports variables. These can be defined anywhere and are scoped according to regular variable scope rules. This means variables cannot be accessed before they are defined. If inside a block, a variable falls out of scope once the block ends. Variables can be re-declared, in which case the previous variable falls out of scope.

In TLS, variables are implicitly final (the keyword does not even exist) and have to have a value set initially. The variable name must contain only alphanumerical, _, $ characters. The variable name must start with an alphabetical or _ character.

Examples:

string lib_version = "26.2.4"
string lib_version = "${lib_version}-beta.2"
ufloat = 26 + 24
classref = mod.util.TargetUtil

A declaration ist how configuration values are set. A declaration always has a name. It may have any number of parameters, and it may have any number of flags (which each may have additional parameters).

The following are all valid declarations:

configure-arm64
configure-x86 native-cpu // native-cpu is a flag
add-library "libraryname" // string parameter
timeout 60 unit seconds // flag unit has a literal parameter

Declarations may also be scoped. A scope declaration adds a code block. There may be methods, variables, and additional declaration types, which are only resolvable within the scoped declaration.

build {
name "${project_name}-${architecture}""
version "${project_version}+${git_ref_short}"
}
// Overloaded scoped declaration with a literal parameter
build x86 {
name project_name
version "${project_version}+${git_ref_short}"
}