Quick reference for the Tea language: syntax, built-ins, and core constructs. Tea is meant for small scripts and automation, not as a full “full-stack” language.

Language

Syntax

Keywords

Control flow: if, else, for, while, return, fn, break, continue, import, export, throw. Booleans: true, false.

Identifiers

Start with a letter or underscore, then letters, digits, or underscores: [A-Za-z_][A-Za-z0-9_]*. Names are case-sensitive.

Literals

Comments

Types

Explicit types (lowercase, as in the lexer): int, float, str, bool, void, array, dict.

int n = 10;
str s = "text";
bool ok = true;
array xs = [1, 2, 3];
dict d = {name: "tea", year: 2026};

Variables and functions

Declare with a type and optional initializer; functions use fn, return type before the name, or void when there is no return value. Variadic functions use ...name.

int x;
x = 1;

int fn add(int a, int b) {
    return a + b;
};

void fn greet(str name) {
    print("Hello, " + name);
};

void fn log(...parts) {
    print(parts);
};

Operators

Control flow

Conditionals

if (condition) {
    // ...
} else {
    // ...
};

Loops

for (int i = 0; i < len(xs); i = i + 1) {
    if (i == 10) {
        break;
    };
    print(xs[i]);
};

while (n > 0) {
    n = n - 1;
};

Indexing

Arrays and strings use integer indexes; dictionaries use keys. Indexing can be nested.

array xs = ["tea", "cup"];
dict page = {title: "Home", tags: xs};

print(xs[0]);              // tea
print(page["tags"][1]);    // cup
print("tea"[0]);           // t

Built-ins and I/O

The runtime provides, among others:

HTTP client

http sends plain http:// requests and returns a dictionary with status, body, headers, and error. Convenience wrappers are available as request, get, post, put, patch, and delete.

dict response = get("http://127.0.0.1:8080/hello");
assert(response["status"], 200);

dict created = post("http://127.0.0.1:8080/items", "{\"ok\":true}");
dict payload = json(created["body"]);

dict custom = http({
    method: "PUT",
    url: "http://127.0.0.1:8080/items/1",
    headers: {"Content-Type": "application/json"},
    body: "{\"name\":\"tea\"}"
});

HTTP server

serve starts a simple HTTP server. The handler receives a request dict (method, path, query, body, headers) and returns a response dict (status, headers, body).

dict fn app(dict req) {
    return {
        status: 200,
        headers: {"Content-Type": "text/plain"},
        body: "hello from tea"
    };
};

serve({port: 8080, handler: app});

More helpers can be pulled in via import from libraries (for example common/string.t with replace, replaceMany, and so on).