diff --git a/bindings/go/binding_interface.go b/bindings/go/binding_interface.go new file mode 100644 index 0000000..cab033a --- /dev/null +++ b/bindings/go/binding_interface.go @@ -0,0 +1,13 @@ +package tree_sitter_ocaml + +// #cgo CFLAGS: -I../../include -std=c11 -fPIC +// #include "../../grammars/interface/src/parser.c" +// #include "../../grammars/interface/src/scanner.c" +import "C" + +import "unsafe" + +// Get the tree-sitter Language for OCaml interfaces. +func OCamlInterface() unsafe.Pointer { + return unsafe.Pointer(C.tree_sitter_ocaml_interface()) +} diff --git a/bindings/go/binding_ocaml.go b/bindings/go/binding_ocaml.go new file mode 100644 index 0000000..791d62d --- /dev/null +++ b/bindings/go/binding_ocaml.go @@ -0,0 +1,13 @@ +package tree_sitter_ocaml + +// #cgo CFLAGS: -I../../include -std=c11 -fPIC +// #include "../../grammars/ocaml/src/parser.c" +// #include "../../grammars/ocaml/src/scanner.c" +import "C" + +import "unsafe" + +// Get the tree-sitter Language for OCaml. +func OCaml() unsafe.Pointer { + return unsafe.Pointer(C.tree_sitter_ocaml()) +} diff --git a/bindings/go/binding_test.go b/bindings/go/binding_test.go new file mode 100644 index 0000000..d78360a --- /dev/null +++ b/bindings/go/binding_test.go @@ -0,0 +1,22 @@ +package tree_sitter_ocaml_test + +import ( + "testing" + + tree_sitter "github.com/smacker/go-tree-sitter" + tree_sitter_ocaml "github.com/tree-sitter/tree-sitter-ocaml" +) + +func TestCanLoadOCamlGrammar(t *testing.T) { + language := tree_sitter.NewLanguage(tree_sitter_ocaml.OCaml()) + if language == nil { + t.Errorf("Error loading OCaml grammar") + } +} + +func TestCanLoadOCamlInterfaceGrammar(t *testing.T) { + language := tree_sitter.NewLanguage(tree_sitter_ocaml.OCamlInterface()) + if language == nil { + t.Errorf("Error loading OCamlInterface grammar") + } +} diff --git a/bindings/go/go.mod b/bindings/go/go.mod new file mode 100644 index 0000000..9c69e1f --- /dev/null +++ b/bindings/go/go.mod @@ -0,0 +1,5 @@ +module github.com/tree-sitter/tree-sitter-ocaml + +go 1.22 + +require github.com/smacker/go-tree-sitter v0.0.0-20240214120134-1f283e24f560