aboutsummaryrefslogtreecommitdiffstats
path: root/app/TreeSitter/bridge.c
diff options
context:
space:
mode:
authorLibravatar Alexander Foremny <aforemny@posteo.de>2023-12-15 07:40:33 +0100
committerLibravatar Alexander Foremny <aforemny@posteo.de>2023-12-18 05:26:24 +0100
commit0d96613d9aa41f93ebb440bb1aa383456b49f28f (patch)
tree8338371bcdeb58957f3b312517cebc9763b380ba /app/TreeSitter/bridge.c
parent4013b920f51790a88b5afce5be72c52b8cb2adc6 (diff)
feat: drop haskell-tree-sitter
Drop haskell-tree-sitter in favor of custom bindings to tree-sitter. haskell-tree-sitter is outdated and seems unmaintained. The implementation add low-level bindings to tree-sitter and traverses the AST in Haskell. We suspect that many FFI calls are more expensive than performing just a single API call to a C function that does the traversal. This will be addressed in upcoming commits. @prerequisite-for add-languages-elm-shell-nix
Diffstat (limited to 'app/TreeSitter/bridge.c')
-rw-r--r--app/TreeSitter/bridge.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/app/TreeSitter/bridge.c b/app/TreeSitter/bridge.c
new file mode 100644
index 0000000..904c88e
--- /dev/null
+++ b/app/TreeSitter/bridge.c
@@ -0,0 +1,34 @@
+#include "tree_sitter/api.h"
+#include "string.h"
+
+void ts_tree_root_node_p(TSTree *tree, TSNode *node) {
+ (*node) = ts_tree_root_node(tree);
+}
+
+uint32_t ts_node_named_child_count_p(TSNode *node) {
+ return ts_node_named_child_count(*node);
+}
+
+uint32_t ts_node_start_byte_p(TSNode *node) {
+ return ts_node_start_byte(*node);
+}
+
+uint32_t ts_node_end_byte_p(TSNode *node) {
+ return ts_node_end_byte(*node);
+}
+
+uint32_t ts_node_start_point_p(TSNode *node, TSPoint *point) {
+ (*point) = ts_node_start_point(*node);
+}
+
+uint32_t ts_node_end_point_p(TSNode *node, TSPoint *point) {
+ (*point) = ts_node_end_point(*node);
+}
+
+const char* ts_node_type_p(TSNode *node) {
+ return ts_node_type(*node);
+}
+
+void ts_node_named_child_p(TSNode* self, uint32_t child_index, TSNode* node) {
+ (*node) = ts_node_named_child(*self, child_index);
+}