Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Summpot committed Aug 19, 2023
1 parent 84cbe2e commit 2c038f1
Show file tree
Hide file tree
Showing 22 changed files with 305 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "native/sources/tree-sitter/src"]
path = native/sources/tree-sitter/src
url = https://github.com/Summpot/tree-sitter
url = https://github.com/tree-sitter/tree-sitter
[submodule "native/sources/tree-sitter-lua/src"]
path = native/sources/tree-sitter-lua/src
url = https://github.com/Azganoth/tree-sitter-lua
Expand Down
9 changes: 5 additions & 4 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="libtree-sitter" Version="0.3.17" />
<PackageVersion Include="libtree-sitter-c" Version="0.3.17" />
<PackageVersion Include="libtree-sitter-cpp" Version="0.3.17" />
<PackageVersion Include="libtree-sitter-lua" Version="0.3.17" />
<PackageVersion Include="libtree-sitter" Version="0.3.18" />
<PackageVersion Include="libtree-sitter-c" Version="0.3.18" />
<PackageVersion Include="libtree-sitter-cpp" Version="0.3.18" />
<PackageVersion Include="libtree-sitter-json" Version="0.3.18" />
<PackageVersion Include="libtree-sitter-lua" Version="0.3.18" />
<PackageVersion Include="GitVersion.MsBuild" Version="5.12.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.7.0" />
<PackageVersion Include="xunit" Version="2.5.0" />
Expand Down
20 changes: 16 additions & 4 deletions TreeSitterSharp.sln
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,17 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "解决方案项", "解决
README.md = README.md
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TreeSitterSharp.C", "src\TreeSitterSharp.C\TreeSitterSharp.C.csproj", "{4612E944-9A22-4D15-8065-3B65E707698F}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TreeSitterSharp.C", "src\TreeSitterSharp.C\TreeSitterSharp.C.csproj", "{4612E944-9A22-4D15-8065-3B65E707698F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TreeSitterSharp.Cpp", "src\TreeSitterSharp.Cpp\TreeSitterSharp.Cpp.csproj", "{1D6EF250-CDDF-47BB-AD6C-FA6CD5E683CE}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TreeSitterSharp.Cpp", "src\TreeSitterSharp.Cpp\TreeSitterSharp.Cpp.csproj", "{1D6EF250-CDDF-47BB-AD6C-FA6CD5E683CE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TreeSitterSharp.Lua", "src\TreeSitterSharp.Lua\TreeSitterSharp.Lua.csproj", "{4C839950-8118-4958-A0AE-1569A71D4A11}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TreeSitterSharp.Lua", "src\TreeSitterSharp.Lua\TreeSitterSharp.Lua.csproj", "{4C839950-8118-4958-A0AE-1569A71D4A11}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TreeSitterSharp.C.Tests", "tests\TreeSitterSharp.C.Tests\TreeSitterSharp.C.Tests.csproj", "{2109968E-BA8C-45CF-9A5F-582A9214E7A0}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TreeSitterSharp.C.Tests", "tests\TreeSitterSharp.C.Tests\TreeSitterSharp.C.Tests.csproj", "{2109968E-BA8C-45CF-9A5F-582A9214E7A0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TreeSitterSharp.Json", "src\TreeSitterSharp.Json\TreeSitterSharp.Json.csproj", "{D58314E0-74AD-41D6-8FF1-A653E6BBDB98}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TreeSitterSharp.Json.Tests", "tests\TreeSitterSharp.Json.Tests\TreeSitterSharp.Json.Tests.csproj", "{9CD39ADD-A840-48AF-8A16-5CF16631DE00}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -52,6 +56,14 @@ Global
{2109968E-BA8C-45CF-9A5F-582A9214E7A0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2109968E-BA8C-45CF-9A5F-582A9214E7A0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2109968E-BA8C-45CF-9A5F-582A9214E7A0}.Release|Any CPU.Build.0 = Release|Any CPU
{D58314E0-74AD-41D6-8FF1-A653E6BBDB98}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D58314E0-74AD-41D6-8FF1-A653E6BBDB98}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D58314E0-74AD-41D6-8FF1-A653E6BBDB98}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D58314E0-74AD-41D6-8FF1-A653E6BBDB98}.Release|Any CPU.Build.0 = Release|Any CPU
{9CD39ADD-A840-48AF-8A16-5CF16631DE00}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9CD39ADD-A840-48AF-8A16-5CF16631DE00}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9CD39ADD-A840-48AF-8A16-5CF16631DE00}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9CD39ADD-A840-48AF-8A16-5CF16631DE00}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
4 changes: 3 additions & 1 deletion native/sources/tree-sitter-c/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ project('tree-sitter-c', 'c')

incdir = include_directories('src/src')

library('tree-sitter-c', 'src/src/parser.c', include_directories : incdir)
shared_library('tree-sitter-lua',
sources : ['src/src/parser.c'],
include_directories : incdir)
4 changes: 3 additions & 1 deletion native/sources/tree-sitter-cpp/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ project('tree-sitter-cpp', 'c')

incdir = include_directories('src/src')

library('tree-sitter-cpp', 'src/src/parser.c', 'src/src/scanner.c', include_directories : incdir)
shared_library('tree-sitter-cpp',
sources : ['src/src/parser.c', 'src/src/scanner.c'],
include_directories : incdir)
2 changes: 1 addition & 1 deletion native/sources/tree-sitter-cpp/src
4 changes: 3 additions & 1 deletion native/sources/tree-sitter-json/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ project('tree-sitter-json', 'c')

incdir = include_directories('src/src')

library('tree-sitter-json', 'src/src/parser.c', include_directories : incdir)
shared_library('tree-sitter-json',
sources : ['src/src/parser.c'],
include_directories : incdir)
4 changes: 3 additions & 1 deletion native/sources/tree-sitter-lua/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ project('tree-sitter-lua', 'c')

incdir = include_directories('src/src')

library('tree-sitter-lua', 'src/src/parser.c', 'src/src/scanner.c', include_directories : incdir)
shared_library('tree-sitter-lua',
sources : ['src/src/parser.c', 'src/src/scanner.c'],
include_directories : incdir)
11 changes: 10 additions & 1 deletion native/sources/tree-sitter/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,13 @@ project('tree-sitter', 'c')

incdir = include_directories('src/lib/include')

library('tree-sitter', 'src/lib/src/lib.c', include_directories : incdir)
if host_machine.system() == 'windows'
morekwargs = {'vs_module_defs': 'tree-sitter.def'}
else
morekwargs = {}
endif

shared_library('tree-sitter',
sources : ['src/lib/src/lib.c'],
include_directories : incdir,
kwargs : morekwargs)
131 changes: 131 additions & 0 deletions native/sources/tree-sitter/tree-sitter.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
EXPORTS
ts_parser_new
ts_parser_delete
ts_parser_language
ts_parser_set_language
ts_parser_set_included_ranges
ts_parser_included_ranges
ts_parser_parse
ts_parser_parse_string
ts_parser_parse_string_encoding
ts_parser_reset
ts_parser_set_timeout_micros
ts_parser_timeout_micros
ts_parser_set_cancellation_flag
ts_parser_cancellation_flag
ts_parser_set_logger
ts_parser_logger
ts_parser_print_dot_graphs
ts_tree_copy
ts_tree_delete
ts_tree_root_node
ts_tree_root_node_with_offset
ts_tree_language
ts_tree_included_ranges
ts_tree_edit
ts_tree_get_changed_ranges
ts_tree_print_dot_graph
ts_node_type
ts_node_symbol
ts_node_language
ts_node_grammar_type
ts_node_grammar_symbol
ts_node_start_byte
ts_node_start_point
ts_node_end_byte
ts_node_end_point
ts_node_string
ts_node_is_null
ts_node_is_named
ts_node_is_missing
ts_node_is_extra
ts_node_has_changes
ts_node_has_error
ts_node_is_error
ts_node_parse_state
ts_node_next_parse_state
ts_node_parent
ts_node_child
ts_node_field_name_for_child
ts_node_child_count
ts_node_named_child
ts_node_named_child_count
ts_node_child_by_field_name
ts_node_child_by_field_id
ts_node_next_sibling
ts_node_prev_sibling
ts_node_next_named_sibling
ts_node_prev_named_sibling
ts_node_first_child_for_byte
ts_node_first_named_child_for_byte
ts_node_descendant_count
ts_node_descendant_for_byte_range
ts_node_descendant_for_point_range
ts_node_named_descendant_for_byte_range
ts_node_named_descendant_for_point_range
ts_node_edit
ts_node_eq
ts_tree_cursor_new
ts_tree_cursor_delete
ts_tree_cursor_reset
ts_tree_cursor_reset_to
ts_tree_cursor_current_node
ts_tree_cursor_current_field_name
ts_tree_cursor_current_field_id
ts_tree_cursor_goto_parent
ts_tree_cursor_goto_next_sibling
ts_tree_cursor_goto_previous_sibling
ts_tree_cursor_goto_first_child
ts_tree_cursor_goto_last_child
ts_tree_cursor_goto_descendant
ts_tree_cursor_current_descendant_index
ts_tree_cursor_current_depth
ts_tree_cursor_goto_first_child_for_byte
ts_tree_cursor_goto_first_child_for_point
ts_tree_cursor_copy
ts_query_new
ts_query_delete
ts_query_pattern_count
ts_query_capture_count
ts_query_string_count
ts_query_start_byte_for_pattern
ts_query_predicates_for_pattern
ts_query_is_pattern_rooted
ts_query_is_pattern_non_local
ts_query_is_pattern_guaranteed_at_step
ts_query_capture_name_for_id
ts_query_capture_quantifier_for_id
ts_query_string_value_for_id
ts_query_disable_capture
ts_query_disable_pattern
ts_query_cursor_new
ts_query_cursor_delete
ts_query_cursor_exec
ts_query_cursor_did_exceed_match_limit
ts_query_cursor_match_limit
ts_query_cursor_set_match_limit
ts_query_cursor_set_byte_range
ts_query_cursor_set_point_range
ts_query_cursor_next_match
ts_query_cursor_remove_match
ts_query_cursor_next_capture
ts_query_cursor_set_max_start_depth
ts_language_symbol_count
ts_language_state_count
ts_language_symbol_name
ts_language_symbol_for_name
ts_language_field_count
ts_language_field_name_for_id
ts_language_field_id_for_name
ts_language_symbol_type
ts_language_version
ts_language_next_state
ts_lookahead_iterator_new
ts_lookahead_iterator_delete
ts_lookahead_iterator_reset_state
ts_lookahead_iterator_reset
ts_lookahead_iterator_language
ts_lookahead_iterator_next
ts_lookahead_iterator_current_symbol
ts_lookahead_iterator_current_symbol_name
ts_set_allocator
18 changes: 18 additions & 0 deletions src/TreeSitterSharp.Json/JsonLanguageProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using TreeSitterSharp.Native;

namespace TreeSitterSharp.Json
{
public unsafe class JsonLanguageProvider : ILanguageProvider
{
[DllImport("libtree-sitter-json", EntryPoint = "tree_sitter_json", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
private static extern unsafe TsLanguage* tree_sitter_json();

public static Language GetLanguage() => Language.FromNative(tree_sitter_json());
}
}
23 changes: 23 additions & 0 deletions src/TreeSitterSharp.Json/TreeSitterSharp.Json.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>true</IsPackable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="libtree-sitter-json" />
<PackageReference Include="GitVersion.MsBuild">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\TreeSitterSharp\TreeSitterSharp.csproj" />
</ItemGroup>

</Project>
Loading

0 comments on commit 2c038f1

Please sign in to comment.