Skip to content
Open
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
12 changes: 12 additions & 0 deletions _automation/grammars.json
Original file line number Diff line number Diff line change
Expand Up @@ -347,5 +347,17 @@
"reference": "gh-pages",
"revision": "c67ecbd37d8d12f22e4cc7138afd14bc20253e10",
"updateBasedOn": "commit"
},
{
"language": "matlab",
"url": "https://github.com/acristoffers/tree-sitter-matlab",
"files": [
"parser.c",
"parser.h",
"scanner.c"
],
"reference": "v1.2.0",
"revision": "96a3e8fb0a4ebd0db64db6b52043483937e9ca3a",
"updateBasedOn": "tag"
}
]
15 changes: 15 additions & 0 deletions matlab/binding.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package matlab

//#include "parser.h"
//TSLanguage *tree_sitter_matlab();
import "C"
import (
"unsafe"

sitter "github.com/smacker/go-tree-sitter"
)

func GetLanguage() *sitter.Language {
ptr := unsafe.Pointer(C.tree_sitter_matlab())
return sitter.NewLanguage(ptr)
}
19 changes: 19 additions & 0 deletions matlab/binding_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package matlab_test

import (
"context"
"testing"

sitter "github.com/smacker/go-tree-sitter"
"github.com/smacker/go-tree-sitter/matlab"
"github.com/stretchr/testify/assert"
)

func TestGrammar(t *testing.T) {
assert := assert.New(t)

n, err := sitter.ParseCtx(context.Background(), []byte("function result = myFunction(x)\n result = x * 2;\nend"), matlab.GetLanguage())
assert.NoError(err)
assert.NotNil(n)
assert.Contains(n.String(), "function")
}
Loading