parser-parse | R Documentation |
parser_parse()
performs an initial parse of text
, a string typically
containing contents of a file. It returns a tree
for further
manipulations.
parser_reparse()
performs a fast incremental reparse. text
is typically
a slightly modified version of the original text
with a new "edit"
applied. The position of the edit is described by the byte and point
arguments to this function. The tree
argument corresponds to the original
tree
returned by parser_parse()
.
All bytes and points should be 0-indexed.
parser_parse(x, text, ..., encoding = "UTF-8")
parser_reparse(
x,
text,
tree,
start_byte,
start_point,
old_end_byte,
old_end_point,
new_end_byte,
new_end_point,
...,
encoding = "UTF-8"
)
x |
A parser. |
text |
The text to parse. |
... |
These dots are for future extensions and must be empty. |
encoding |
The expected encoding of the |
tree |
The original tree returned by |
start_byte , start_point |
The starting byte and starting point of the edit location. |
old_end_byte , old_end_point |
The old ending byte and old ending point of the edit location. |
new_end_byte , new_end_point |
The new ending byte and new ending point of the edit location. |
A new tree
.
language <- treesitter.r::language()
parser <- parser(language)
text <- "1 + foo"
tree <- parser_parse(parser, text)
tree
text <- "1 + bar(foo)"
parser_reparse(
parser,
text,
tree,
start_byte = 4,
start_point = point(0, 4),
old_end_byte = 7,
old_end_point = point(0, 7),
new_end_byte = 12,
new_end_point = point(0, 12)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.