Skip to content

Commit

Permalink
Merge pull request #7 from poolsideai/psarna/ada
Browse files Browse the repository at this point in the history
ada: initial commit
  • Loading branch information
psarna authored Jun 17, 2024
2 parents aa2e8d6 + 7aacc4c commit 4e12a45
Show file tree
Hide file tree
Showing 5 changed files with 69,358 additions and 0 deletions.
10 changes: 10 additions & 0 deletions _automation/grammars.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
[
{
"language": "ada",
"url": "https://github.com/briot/tree-sitter-ada",
"files": [
"parser.c"
],
"reference": "master",
"revision": "e8e2515465cc2d7c444498e68bdb9f1d86767f95",
"updateBasedOn": "commit"
},
{
"language": "bash",
"url": "https://github.com/tree-sitter/tree-sitter-bash",
Expand Down
15 changes: 15 additions & 0 deletions ada/binding.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package ada

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

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

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

import (
"context"
"testing"

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

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

n, err := sitter.ParseCtx(context.Background(), []byte("A := 42;"), ada.GetLanguage())
assert.NoError(err)
assert.Equal(
"(compilation (compilation_unit (assignment_statement variable_name: (identifier) (expression (term (numeric_literal))))))",
n.String(),
)
}
Loading

0 comments on commit 4e12a45

Please sign in to comment.