From 0d96613d9aa41f93ebb440bb1aa383456b49f28f Mon Sep 17 00:00:00 2001 From: Alexander Foremny Date: Fri, 15 Dec 2023 07:40:33 +0100 Subject: 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 --- app/TreeSitter/bridge.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 app/TreeSitter/bridge.c (limited to 'app/TreeSitter/bridge.c') 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); +} -- cgit v1.2.3