Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions bindings/zig/root.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
extern fn tree_sitter_c() callconv(.c) *const anyopaque;

pub fn language() *const anyopaque {
return tree_sitter_c();
}
17 changes: 17 additions & 0 deletions bindings/zig/test.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const testing = @import("std").testing;

const ts = @import("tree-sitter");
const root = @import("tree-sitter-c");
const Language = ts.Language;
const Parser = ts.Parser;

test "can load grammar" {
const parser = Parser.create();
defer parser.destroy();

const lang: *const ts.Language = @ptrCast(root.language());
defer lang.destroy();

try testing.expectEqual(void{}, parser.setLanguage(lang));
try testing.expectEqual(lang, parser.getLanguage());
}
93 changes: 93 additions & 0 deletions build.zig

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions build.zig.zon

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion tree-sitter.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"node": true,
"python": true,
"rust": true,
"swift": true
"swift": true,
"zig": true
}
}