language_next_state: Language state advancement

View source: R/language.R

language_next_stateR Documentation

Language state advancement

Description

Get the next state in the grammar.

Usage

language_next_state(x, state, symbol)

Arguments

x

⁠[tree_sitter_language]⁠

A tree-sitter language object.

state, symbol

⁠[integer]⁠

Vectors of equal length containing the current state and symbol information.

Value

A single integer representing the next state.

Examples


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

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

# Navigate to function definition
node <- node_child(node, 1)
node <- node_child(node, 3)
node

state <- node_parse_state(node)
symbol <- node_grammar_symbol(node)

# Function definition symbol
language_symbol_name(language, 85)

# Next state (this is all grammar dependent)
language_next_state(language, state, symbol)


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