Learn R Programming

treesitter (version 0.3.0)

text_parse: 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)

Value

A root node.

Arguments

x

[string]

The text to parse.

language

[tree_sitter_language]

The language to parse with.

Examples

Run this code
if (FALSE) { # rlang::is_installed("treesitter.r")
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)
}

Run the code above in your browser using DataLab