TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/tree-sitter/tree-sitter/llms.txt
Use this file to discover all available pages before exploring further.
build command compiles your parser into a dynamically-loadable library, either as a shared object (.so, .dylib, or .dll) or as a Wasm module.
b
Path Argument
The optional path argument allows you to specify the directory of the parser to build. If not supplied, the CLI will attempt to build the parser in the current working directory.Compiler Configuration
You can customize the compilation process with environment variables:CC- Change the compiler executableCFLAGS- Add extra compiler flagsMACOSX_DEPLOYMENT_TARGET- Minimum macOS version (macOS only)IPHONEOS_DEPLOYMENT_TARGET- Minimum iOS version (iOS only)
Symbol Validation
On Unix platforms, the CLI usesnm to validate symbols in your parser library. This ensures:
- All non-tree-sitter functions are marked
staticto avoid conflicts - If an external scanner is used, all required symbols are present:
tree_sitter_<name>_external_scanner_createtree_sitter_<name>_external_scanner_destroytree_sitter_<name>_external_scanner_serializetree_sitter_<name>_external_scanner_deserializetree_sitter_<name>_external_scanner_scan
Options
Compile the parser as a Wasm module. Requires the Wasi SDK indicated by the
TREE_SITTER_WASI_SDK_PATH environment variable.If you don’t have the binary, the CLI will attempt to download it to <CACHE_DIR>/tree-sitter/wasi-sdk/, where <CACHE_DIR> follows XDG base directory or Windows Known Folder conventions.Specify where to output the shared object file (native or Wasm). Accepts either an absolute or relative path.If not supplied, the CLI will attempt to determine the language name based on the parent directory name. If that fails, it defaults to
parser, generating parser.so or parser.wasm in the current directory.Reuse the allocator set in the core library for the parser’s external scanner. Useful when the application overrides the default allocator and wants to ensure all parsers use it for external scanner allocations.
Compile the parser with debug flags enabled. Useful when debugging issues with tools like
gdb or lldb.Display verbose build information including working directory, compiler, arguments, and environment variables.