Learn R Programming

treesitter (version 0.3.0)

node_walk: Generate a TreeCursor iterator

Description

node_walk() creates a TreeCursor starting at the current node. You can use it to "walk" the tree more efficiently than using node_child() and other similar node functions.

Usage

node_walk(x)

Value

A TreeCursor object.

Arguments

x

[tree_sitter_node]

A node.

Examples

Run this code
if (FALSE) { # rlang::is_installed("treesitter.r")
language <- treesitter.r::language()
parser <- parser(language)

text <- "1 + foo"
tree <- parser_parse(parser, text)
node <- tree_root_node(tree)

cursor <- node_walk(node)

cursor$goto_first_child()
cursor$goto_first_child()
cursor$node()
cursor$goto_next_sibling()
cursor$node()
}

Run the code above in your browser using DataLab