-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
373 additions
and
251 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
using System.Runtime.InteropServices; | ||
using TreeSitterSharp.Native; | ||
using TreeSitterSharp; | ||
|
||
namespace TreeSitterSharp.Json | ||
{ | ||
internal unsafe class JsonLanguageProvider : ILanguageProvider | ||
{ | ||
[DllImport("tree-sitter-json", EntryPoint = "tree_sitter_json", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] | ||
private static extern TsLanguage* tree_sitter_json(); | ||
|
||
public static Language GetLanguage() => new(tree_sitter_json()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,20 @@ | ||
| ||
using System.Text; | ||
|
||
namespace TreeSitterSharp.Json; | ||
public class JsonParser() : Parser(JsonLanguageProvider.GetLanguage()); | ||
|
||
public class JsonParser : Parser<JsonSyntaxTree, JsonSyntaxNode, JsonParser> | ||
{ | ||
public JsonParser() : base(JsonLanguageProvider.GetLanguage()) | ||
{ | ||
|
||
} | ||
|
||
public override JsonSyntaxTree Parse(Span<byte> code) | ||
{ | ||
unsafe | ||
{ | ||
return new(ParseCore(code)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using TreeSitterSharp.Native; | ||
|
||
namespace TreeSitterSharp.Json; | ||
public class JsonSyntaxNode : SyntaxNode<JsonSyntaxTree, JsonSyntaxNode>, ISyntaxNodeCreation<JsonSyntaxTree, JsonSyntaxNode> | ||
{ | ||
protected internal JsonSyntaxNode(TsNode node) : base(node) | ||
{ | ||
} | ||
|
||
public static JsonSyntaxNode Create(TsNode node) => new(node); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using TreeSitterSharp.Native; | ||
|
||
namespace TreeSitterSharp.Json; | ||
public class JsonSyntaxTree : SyntaxTree<JsonSyntaxNode, JsonSyntaxTree>, ISyntaxTreeCreation<JsonSyntaxNode, JsonSyntaxTree> | ||
{ | ||
internal unsafe JsonSyntaxTree(TsTree* tree) : base(tree) | ||
{ | ||
} | ||
|
||
public override JsonSyntaxTree Copy() | ||
{ | ||
unsafe | ||
{ | ||
return new(Ts.tree_copy(_tree)); | ||
} | ||
} | ||
|
||
public override JsonSyntaxNode Root { get; } | ||
public static unsafe JsonSyntaxTree Create(TsTree* tree) => new(tree); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.