if (FALSE) { # rlang::is_installed("treesitter.r")
language <- treesitter.r::language()
parser <- parser(language)
text <- "fn <- function(a, b = 2) { a + b + 2 }"
tree <- parser_parse(parser, text)
node <- tree_root_node(tree)
node_show_s_expression(node)
node_show_s_expression(node, max_lines = 5)
# This is more like a typical abstract syntax tree
node_show_s_expression(
node,
show_anonymous = FALSE,
show_locations = FALSE,
dangling_parenthesis = FALSE
)
}
Run the code above in your browser using DataLab