Skip to content

Commit b0a0198

Browse files
committed
feat: release 1.0.3
1 parent 629280b commit b0a0198

File tree

14 files changed

+20108
-19984
lines changed

14 files changed

+20108
-19984
lines changed

CMakeLists.txt

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
cmake_minimum_required(VERSION 3.13)
2+
3+
project(tree-sitter-matlab
4+
VERSION "1.0.3"
5+
DESCRIPTION "MATLAB tree-sitter parser"
6+
HOMEPAGE_URL "https://github.com/tree-sitter/tree-sitter-matlab"
7+
LANGUAGES C)
8+
9+
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
10+
option(TREE_SITTER_REUSE_ALLOCATOR "Reuse the library allocator" OFF)
11+
12+
set(TREE_SITTER_ABI_VERSION 14 CACHE STRING "Tree-sitter ABI version")
13+
if(NOT ${TREE_SITTER_ABI_VERSION} MATCHES "^[0-9]+$")
14+
unset(TREE_SITTER_ABI_VERSION CACHE)
15+
message(FATAL_ERROR "TREE_SITTER_ABI_VERSION must be an integer")
16+
endif()
17+
18+
find_program(TREE_SITTER_CLI tree-sitter DOC "Tree-sitter CLI")
19+
20+
add_custom_command(OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/src/parser.c"
21+
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/grammar.json"
22+
COMMAND "${TREE_SITTER_CLI}" generate src/grammar.json
23+
--abi=${TREE_SITTER_ABI_VERSION}
24+
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
25+
COMMENT "Generating parser.c")
26+
27+
add_library(tree-sitter-matlab src/parser.c)
28+
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/scanner.c)
29+
target_sources(tree-sitter-matlab PRIVATE src/scanner.c)
30+
endif()
31+
target_include_directories(tree-sitter-matlab PRIVATE src)
32+
33+
target_compile_definitions(tree-sitter-matlab PRIVATE
34+
$<$<BOOL:${TREE_SITTER_REUSE_ALLOCATOR}>:TREE_SITTER_REUSE_ALLOCATOR>
35+
$<$<CONFIG:Debug>:TREE_SITTER_DEBUG>)
36+
37+
set_target_properties(tree-sitter-matlab
38+
PROPERTIES
39+
C_STANDARD 11
40+
POSITION_INDEPENDENT_CODE ON
41+
SOVERSION "${TREE_SITTER_ABI_VERSION}.${PROJECT_VERSION_MAJOR}"
42+
DEFINE_SYMBOL "")
43+
44+
configure_file(bindings/c/tree-sitter-matlab.pc.in
45+
"${CMAKE_CURRENT_BINARY_DIR}/tree-sitter-matlab.pc" @ONLY)
46+
47+
include(GNUInstallDirs)
48+
49+
install(FILES bindings/c/tree-sitter-matlab.h
50+
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/tree_sitter")
51+
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/tree-sitter-matlab.pc"
52+
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig")
53+
install(TARGETS tree-sitter-matlab
54+
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
55+
56+
add_custom_target(ts-test "${TREE_SITTER_CLI}" test
57+
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
58+
COMMENT "tree-sitter test")

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "tree-sitter-matlab"
33
description = "MATLAB grammar for the tree-sitter parsing library"
4-
version = "1.0.2"
4+
version = "1.0.3"
55
keywords = ["incremental", "parsing", "MATLAB"]
66
categories = ["parsing", "text-editors"]
77
repository = "https://github.com/tree-sitter/tree-sitter-matlab"

bindings/node/binding_test.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const assert = require("node:assert");
2+
const { test } = require("node:test");
3+
4+
const Parser = require("tree-sitter");
5+
6+
test("can load grammar", () => {
7+
const parser = new Parser();
8+
assert.doesNotThrow(() => parser.setLanguage(require(".")));
9+
});

bindings/python/tests/test_binding.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from unittest import TestCase
2+
3+
import tree_sitter, tree_sitter_matlab
4+
5+
6+
class TestLanguage(TestCase):
7+
def test_can_load_grammar(self):
8+
try:
9+
tree_sitter.Language(tree_sitter_matlab.language())
10+
except Exception:
11+
self.fail("Error loading Matlab grammar")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import XCTest
2+
import SwiftTreeSitter
3+
import TreeSitterMatlab
4+
5+
final class TreeSitterMatlabTests: XCTestCase {
6+
func testCanLoadGrammar() throws {
7+
let parser = Parser()
8+
let language = Language(language: tree_sitter_matlab())
9+
XCTAssertNoThrow(try parser.setLanguage(language),
10+
"Error loading Matlab grammar")
11+
}
12+
}

go.mod

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module github.com/tree-sitter/tree-sitter-matlab
2+
3+
go 1.22
4+
5+
require github.com/tree-sitter/go-tree-sitter v0.24.0

package.json

+6-15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tree-sitter-matlab",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"description": "MATLAB tree-sitter parser",
55
"main": "bindings/node",
66
"types": "bindings/node",
@@ -24,25 +24,16 @@
2424
"tree-sitter-cli": "^0.20.8",
2525
"prebuildify": "^6.0.0"
2626
},
27-
"tree-sitter": [
28-
{
29-
"scope": "source.m",
30-
"file-types": [
31-
"m"
32-
],
33-
"highlights": "queries/neovim/highlights.scm"
34-
}
35-
],
36-
"scripts": {
37-
"install": "node-gyp-build",
38-
"prebuildify": "prebuildify --napi --strip"
39-
},
4027
"files": [
4128
"grammar.js",
4229
"binding.gyp",
4330
"prebuilds/**",
4431
"bindings/node/*",
4532
"queries/*",
4633
"src/**"
47-
]
34+
],
35+
"scripts": {
36+
"install": "node-gyp-build",
37+
"prebuildify": "prebuildify --napi --strip"
38+
}
4839
}

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
55
[project]
66
name = "tree-sitter-matlab"
77
description = "Matlab grammar for tree-sitter"
8-
version = "1.0.2"
8+
version = "1.0.3"
99
keywords = ["incremental", "parsing", "tree-sitter", "matlab"]
1010
classifiers = [
1111
"Intended Audience :: Developers",

src/grammar.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"$schema": "https://tree-sitter.github.io/tree-sitter/assets/schemas/grammar.schema.json",
23
"name": "matlab",
34
"word": "identifier",
45
"rules": {

src/node-types.json

+1
Original file line numberDiff line numberDiff line change
@@ -2671,6 +2671,7 @@
26712671
{
26722672
"type": "source_file",
26732673
"named": true,
2674+
"root": true,
26742675
"fields": {},
26752676
"children": {
26762677
"multiple": true,

0 commit comments

Comments
 (0)