Skip to content

API Reference โ€‹

Every signature below is taken from the actual source (src/). Import everything through one module:

zig
const treesitter = @import("treesitter");

Parser

Create parsers, load languages, parse source incrementally.

Parser.init(allocator) Parser

Read the reference โ†’

Tree

Own the syntax tree, its text, and its node pool.

Parser.parseString(source) Tree

Read the reference โ†’

Node

Lightweight, allocation-free handles into a tree.

Tree.rootNode() Node

Read the reference โ†’

TreeCursor

Stateful traversal with depth and field tracking.

Tree.cursor() TreeCursor

Read the reference โ†’

Language

Generic grammar data: symbols, tables, fields, metadata.

Parser.setLanguage(Language)

Read the reference โ†’

Query

Compiled structural patterns with captures and predicates.

Parser.compileQuery(source) Query

Read the reference โ†’

QueryCursor

Execute queries and iterate matches.

Parser.queryCursor() QueryCursor

Read the reference โ†’

Input

Memory, callback, and reader-backed sources.

Parser.parseWithInput(old, edit, input)

Read the reference โ†’

Released under the MIT License.