Add --dot flag to parse subcommand, for printing tree as DOT graph

This commit is contained in:
Max Brunsfeld 2023-02-13 12:33:34 -08:00
parent 8389ffd2a1
commit 97fd990822
10 changed files with 106 additions and 43 deletions

View file

@ -1,3 +1,4 @@
#include <unistd.h>
#include "tree_sitter/api.h"
#include "./array.h"
#include "./get_changed_ranges.h"
@ -123,6 +124,8 @@ TSRange *ts_tree_get_changed_ranges(const TSTree *self, const TSTree *other, uin
return result;
}
void ts_tree_print_dot_graph(const TSTree *self, FILE *file) {
void ts_tree_print_dot_graph(const TSTree *self, int fd) {
FILE *file = fdopen(dup(fd), "a");
ts_subtree_print_dot_graph(self->root, self->language, file);
fclose(file);
}