text_parse: Parse a snippet of text

View source: R/parse.R

text_parseR 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)


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