百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
L

ltreesitter

> 编程语言
开源

Lua 语言的独立树坐者绑定

100 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

Lua 语言的独立树坐者绑定

ltreesitter

Tree sitter bindings for Lua

Current tree-sitter version: v0.26.12

Documentation

Documentation can be found at this repo's github pages (Which are autogenerated using the Teal script scripts/docgen.tl)

Installation

ltreesitter is avaliable on luarocks

luarocks install ltreesitter

or the latest main branch

luarocks install --dev ltreesitter

Examples

Looking for a quick start? These snippets should be descriptive enough to get you started. If you need more detail, take a look at the documentation

Setup

Loading parsers you have installed on your system

lua
local ltreesitter = require("ltreesitter")

ltreesitter.require

Assuming you have a compiled c parser named c.so (or c.dll on windows) in ~/.tree-sitter/bin/ or package.cpath

lua
local c_language = ltreesitter.require("c")
local c_parser = c_language:parser()

You have a parser.so (or .dll or .dynlib) with the symbol tree_sitter_lua to load the language

lua
local lua_language = ltreesitter.require("parser", "lua")

ltreesitter.load

load will just directly load from the filename given.

lua
local local_c = ltreesitter.load("./c-parser.so", "c")

Using a path without a path separator may have unintended consequences, so when in doubt, include a leading ./ or use an absolute path.

For more information, look into how dlopen and LoadLibrary find paths.

Basic parsing and usage of trees and nodes

lua
local source_code = [[
#include 

// a function that does stuff
static void stuff_doer(void) {
    printf("I'm doing stuff! :D\n");
}

int main(int argc, char **argv) {
    stuff_doer();
    return 0;
}
]]

local tree = c_parser:parse_string(source_code)
print(tree) -- tostring (which print calls automatically) will return the string of s-expressions of trees and nodes

for child in tree:root():named_children() do -- some iterators over nodes' children are provided
   print(child)
end

Queries

Using the above c_language, c_parser, and tree

…

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Cluaparsingtealtree-sitter

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言