Lexemes
Keywords
Section titled “Keywords”A keyword is a word reserved by the language for its own syntax.
Declarations
Section titled “Declarations”| Keyword | Purpose |
|---|---|
let | Binds a value to a name inside a function |
mut | Marks a mutable binding or writable type |
const | Defines a compile-time constant |
fn | Defines a function or method |
struct | Defines a type with fields |
enum | Defines a type with variants |
interface | Defines a set of methods a type can satisfy |
impl | Defines methods on a type |
type | Defines a type or type alias |
as | Converts between types, or names a pattern |
Control flow
Section titled “Control flow”| Keyword | Purpose |
|---|---|
if | Takes a branch when a condition holds |
else | Takes the remaining branch |
match | Selects a branch by pattern matching |
for | Iterates over values |
in | Names what a for loop iterates |
while | Repeats while a condition holds |
loop | Repeats until a break |
break | Exits the enclosing loop |
continue | Skips to the next iteration |
return | Exits the enclosing function |
Failure handling
Section titled “Failure handling”| Keyword | Purpose |
|---|---|
try | Scopes ? to a block |
defer | Runs an expression on function exit |
recover | Catches a panic |
assert | States an expected result in a test |
Concurrency
Section titled “Concurrency”| Keyword | Purpose |
|---|---|
task | Starts a concurrent task (goroutine) |
select | Waits on several channel operations |
Packages
Section titled “Packages”| Keyword | Purpose |
|---|---|
import | Brings a package into scope |
pub | Makes an item visible outside its package |
Identifiers
Section titled “Identifiers”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, parameterPointtype, type parameterMAX_SIZEconstant_countdiscardedA lone _ is not an identifier. It discards a value, and later code cannot read it.
Literals
Section titled “Literals”Numerics
Section titled “Numerics”Integer literals are of type int.
let count = 42Underscore separators improve readability. They cannot be leading, trailing, or consecutive.
1_000separator_1000identifier1000_error: trailing underscore1__000error: consecutive underscoresHex, octal, and binary literals use prefixes 0x, 0o, and 0b. Leading-zero octal is not allowed.
let hex = 0xFFlet octal = 0o755let binary = 0b1010_0001let octal = 0755error: leading zeroFloat literals are of type float64. A decimal point requires digits on both sides.
let pi = 3.14159let half = 0.5Exponent notation uses e with an optional sign.
let small = 1.5e-3let large = 6.02e23An i suffix on a decimal literal creates an imaginary value, for use with complex64 and complex128.
let unit = 1ilet point = 3 + 4iBooleans
Section titled “Booleans”Boolean literals are of type bool.
let yes = truelet no = falseStrings
Section titled “Strings”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 isa very longmultiline 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:
| Sequence | Meaning |
|---|---|
\\ | Backslash |
\" | Double quote |
\n | Newline |
\r | Carriage return |
\t | Tab |
\0 | Null |
\a | Alert |
\b | Backspace |
\f | Form feed |
\v | Vertical tab |
\xHH | Hex value, two digits |
\ooo | Octal value, three digits |
\u{HEX} | Unicode code point, any hex digits |
\UHHHHHHHH | Unicode code point, eight hex digits |
Raw strings
Section titled “Raw strings”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 oneline two"Raw strings cannot contain ". For text with quotes, use a regular string with \".
Format strings
Section titled “Format strings”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 AliceRunes are enclosed in single quotes.
let c = 'a'let newline = '\n'let null = '\0'Runes use the same escape sequences, with \' in place of \".
Slices and arrays
Section titled “Slices and arrays”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 annotationTuples
Section titled “Tuples”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.042let 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.
Trivia
Section titled “Trivia”Comments
Section titled “Comments”Line comments start with // and extend to the end of the line.
let timeout = 30 // secondsDoc 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"Shebang
Section titled “Shebang”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]}!")}chmod +x greet.lis && ./greet.lis aliceSee Scripts
Semicolons
Section titled “Semicolons”Semicolons are never required. lis format removes any you write.