Add --dot flag to parse subcommand, for printing tree as DOT graph
This commit is contained in:
parent
8389ffd2a1
commit
97fd990822
10 changed files with 106 additions and 43 deletions
|
|
@ -346,6 +346,9 @@ extern "C" {
|
|||
pub fn ts_tree_language(arg1: *const TSTree) -> *const TSLanguage;
|
||||
}
|
||||
extern "C" {
|
||||
#[doc = " Get the array of included ranges that was used to parse the syntax tree."]
|
||||
#[doc = ""]
|
||||
#[doc = " The returned pointer must be freed by the caller."]
|
||||
pub fn ts_tree_included_ranges(arg1: *const TSTree, length: *mut u32) -> *mut TSRange;
|
||||
}
|
||||
extern "C" {
|
||||
|
|
@ -375,6 +378,10 @@ extern "C" {
|
|||
length: *mut u32,
|
||||
) -> *mut TSRange;
|
||||
}
|
||||
extern "C" {
|
||||
#[doc = " Write a DOT graph describing the syntax tree to the given file."]
|
||||
pub fn ts_tree_print_dot_graph(arg1: *const TSTree, file_descriptor: ::std::os::raw::c_int);
|
||||
}
|
||||
extern "C" {
|
||||
#[doc = " Get the node's type as a null-terminated string."]
|
||||
pub fn ts_node_type(arg1: TSNode) -> *const ::std::os::raw::c_char;
|
||||
|
|
|
|||
|
|
@ -775,6 +775,16 @@ impl Tree {
|
|||
result
|
||||
}
|
||||
}
|
||||
|
||||
/// Print a graph of the tree to the given file descriptor.
|
||||
/// The graph is formatted in the DOT language. You may want to pipe this graph
|
||||
/// directly to a `dot(1)` process in order to generate SVG output.
|
||||
#[cfg(unix)]
|
||||
#[doc(alias = "ts_tree_print_dot_graph")]
|
||||
pub fn print_dot_graph(&self, file: &impl AsRawFd) {
|
||||
let fd = file.as_raw_fd();
|
||||
unsafe { ffi::ts_tree_print_dot_graph(self.0.as_ptr(), fd) }
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for Tree {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue