diff options
Diffstat (limited to 'bindings/go')
-rw-r--r-- | bindings/go/binding.go | 13 | ||||
-rw-r--r-- | bindings/go/binding_test.go | 15 | ||||
-rw-r--r-- | bindings/go/go.mod | 5 |
3 files changed, 33 insertions, 0 deletions
diff --git a/bindings/go/binding.go b/bindings/go/binding.go new file mode 100644 index 0000000..353f400 --- /dev/null +++ b/bindings/go/binding.go @@ -0,0 +1,13 @@ +package tree_sitter_gsp + +// #cgo CFLAGS: -std=c11 -fPIC +// #include "../../src/parser.c" +// // NOTE: if your language has an external scanner, add it here. +import "C" + +import "unsafe" + +// Get the tree-sitter Language for this grammar. +func Language() unsafe.Pointer { + return unsafe.Pointer(C.tree_sitter_gsp()) +} diff --git a/bindings/go/binding_test.go b/bindings/go/binding_test.go new file mode 100644 index 0000000..c4efff1 --- /dev/null +++ b/bindings/go/binding_test.go @@ -0,0 +1,15 @@ +package tree_sitter_gsp_test + +import ( + "testing" + + tree_sitter "github.com/smacker/go-tree-sitter" + "github.com/tree-sitter/tree-sitter-gsp" +) + +func TestCanLoadGrammar(t *testing.T) { + language := tree_sitter.NewLanguage(tree_sitter_gsp.Language()) + if language == nil { + t.Errorf("Error loading Gsp grammar") + } +} diff --git a/bindings/go/go.mod b/bindings/go/go.mod new file mode 100644 index 0000000..38c34a6 --- /dev/null +++ b/bindings/go/go.mod @@ -0,0 +1,5 @@ +module github.com/tree-sitter/tree-sitter-gsp + +go 1.22 + +require github.com/smacker/go-tree-sitter v0.0.0-20230720070738-0d0a9f78d8f8 |