node_symbol: Node symbol

View source: R/node.R

node_symbolR Documentation

Node symbol

Description

node_symbol() returns the symbol id of the current node as an integer.

Usage

node_symbol(x)

Arguments

x

⁠[tree_sitter_node]⁠

A node.

Value

A single integer.

Examples


language <- treesitter.r::language()
parser <- parser(language)

text <- "fn <- function() { 1 + 1 }"
tree <- parser_parse(parser, text)
node <- tree_root_node(tree)

# Top level program node
node_symbol(node)

# The whole `<-` binary operator node
node <- node_child(node, 1)
node_symbol(node)

# Just the literal `<-` operator itself
node <- node_child_by_field_name(node, "operator")
node_symbol(node)


treesitter documentation built on June 24, 2024, 5:07 p.m.