node-info | R Documentation |
Get more precise information on a node
node_matches(x, ..., files = NULL)
node_inside(x, ..., files = NULL)
node_has(x, ..., files = NULL)
node_precedes(x, ..., files = NULL)
node_follows(x, ..., files = NULL)
x |
A node, either from |
... |
Any number of rules created with |
files |
A vector of filenames containing rules. Those must be |
A list containing as many elements as there are nodes as input.
src <- "
print('hi')
fn <- function() {
print('hello')
}
"
root <- src |>
tree_new() |>
tree_root()
some_node <- root |>
node_find(ast_rule(pattern = "print($A)"))
node_text(some_node)
# Check if a node matches a specific rule
some_node |>
node_get_match("A") |>
node_matches(ast_rule(kind = "argument"))
# Check if a node is inside another one
some_node |>
node_get_match("A") |>
node_inside(ast_rule(kind = "call"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.