Skip to content

Lexemes

A keyword is a word reserved by the language for its own syntax.

KeywordPurpose
letBinds a value to a name inside a function
mutMarks a mutable binding or writable type
constDefines a compile-time constant
fnDefines a function or method
structDefines a type with fields
enumDefines a type with variants
interfaceDefines a set of methods a type can satisfy
implDefines methods on a type
typeDefines a type or type alias
asConverts between types, or names a pattern
KeywordPurpose
ifTakes a branch when a condition holds
elseTakes the remaining branch
matchSelects a branch by pattern matching
forIterates over values
inNames what a for loop iterates
whileRepeats while a condition holds
loopRepeats until a break
breakExits the enclosing loop
continueSkips to the next iteration
returnExits the enclosing function
KeywordPurpose
tryScopes ? to a block
deferRuns an expression on function exit
recoverCatches a panic
assertStates an expected result in a test
KeywordPurpose
taskStarts a concurrent task (goroutine)
selectWaits on several channel operations
KeywordPurpose
importBrings a package into scope
pubMakes an item visible outside its package

An identifier is a name given to a declaration. It starts with a letter or underscore, followed by any number of letters, digits, or underscores. Identifiers are case-sensitive.

foovariable, function, parameter
Pointtype, type parameter
MAX_SIZEconstant
_countdiscarded

A lone _ is not an identifier. It discards a value, and later code cannot read it.

Integer literals are of type int.

let count = 42

Underscore separators improve readability. They cannot be leading, trailing, or consecutive.

1_000separator
_1000identifier
1000_error: trailing underscore
1__000error: consecutive underscores

Hex, octal, and binary literals use prefixes 0x, 0o, and 0b. Leading-zero octal is not allowed.

let hex = 0xFF
let octal = 0o755
let binary = 0b1010_0001
let octal = 0755error: leading zero

Float literals are of type float64. A decimal point requires digits on both sides.

let pi = 3.14159
let half = 0.5

Exponent notation uses e with an optional sign.

let small = 1.5e-3
let large = 6.02e23

An i suffix on a decimal literal creates an imaginary value, for use with complex64 and complex128.

let unit = 1i
let point = 3 + 4i

Boolean literals are of type bool.

let yes = true
let no = false

String literals are of type string. They are enclosed in double quotes and may be multiline.

let greeting = "Hello, world!"
let escaped = "line one\nline two"
let quoted = "She said \"hi\""
let multiline = "This is
a very long
multiline string."

A newline between the opening and closing " is preserved in the value as a \n byte. Source-code indentation inside a multiline string is part of the value.

Escape sequences:

SequenceMeaning
\\Backslash
\"Double quote
\nNewline
\rCarriage return
\tTab
\0Null
\aAlert
\bBackspace
\fForm feed
\vVertical tab
\xHHHex value, two digits
\oooOctal value, three digits
\u{HEX}Unicode code point, any hex digits
\UHHHHHHHHUnicode code point, eight hex digits

Raw strings begin with r" and treat backslashes as plain characters.

let pattern = r"([a-zA-Z])(\d)"
let path = r"C:\Users\me"
let block = r"line one
line two"

Raw strings cannot contain ". For text with quotes, use a regular string with \".

Format strings begin with f" and accept interpolations in {}.

let greeting = f"Hello, {user.name}! You have {user.unread} new messages."
let total = f"Total: {price * quantity}"

Use {{ and }} to escape braces.

let text = f"{{name}} is {user.name}"{name} is Alice

Runes are enclosed in single quotes.

let c = 'a'
let newline = '\n'
let null = '\0'

Runes use the same escape sequences, with \' in place of \".

Slice literals are of type Slice. An annotation or a parameter can declare them as Array instead. They are enclosed in square brackets, and all elements must have the same type.

let nums = [1, 2, 3]inferred as Slice<int>
let pair: Array<int, 2> = [1, 2]annotated as Array<int, 2>
let empty: Slice<int> = []ambiguous, requires annotation

Tuple literals are of type (A, B, ...), with one type per element. They are enclosed in round brackets and hold two to five elements, accessed by position.

let pair = (42, "hello")
let first = pair.042
let second = pair.1"hello"
let triple = (1, true, "three")
let (a, b, c) = triplea is 1, b is true, c is "three"

For more than five elements, use a struct with named fields.

Line comments start with // and extend to the end of the line.

let timeout = 30 // seconds

Doc comments start with /// and document the item that follows.

/// Returns the sum of two integers.
fn add(a: int, b: int) -> int {
a + b
}

File comments start with //! at the top of the file. They are preserved at the top of the generated Go file.

//! Copyright 2026 Acme Corp.
//! SPDX-License-Identifier: Apache-2.0
import "strings"

A shebang starts with #! at the top of the file and makes the file directly runnable.

#!/usr/bin/env -S lis run
import "go:fmt"
import "go:os"
fn main() {
fmt.Println(f"Hello, {os.Args[1]}!")
}
Terminal window
chmod +x greet.lis && ./greet.lis alice

See Scripts

Semicolons are never required. lis format removes any you write.