text_parse {treesitter}R Documentation

Parse a snippet of text

Description

text_parse() is a convenience utility for quickly parsing a small snippet of text using a particular language and getting access to its root node. It is meant for demonstration purposes. If you are going to need to reparse the text after an edit has been made, you should create a full parser with parser() and use parser_parse() instead.

Usage

text_parse(x, language)

Arguments

x

⁠[string]⁠

The text to parse.

language

⁠[tree_sitter_language]⁠

The language to parse with.

Value

A root node.

Examples


language <- treesitter.r::language()
text <- "map(xs, function(x) 1 + 1)"

# Note that this directly returns the root node, not the tree
text_parse(text, language)


[Package treesitter version 0.1.0 Index]