| parser-parse {treesitter} | R Documentation | 
Parse or reparse text
Description
-  parser_parse()performs an initial parse oftext, a string typically containing contents of a file. It returns atreefor further manipulations.
-  parser_reparse()performs a fast incremental reparse.textis typically a slightly modified version of the originaltextwith a new "edit" applied. The position of the edit is described by the byte and point arguments to this function. Thetreeargument corresponds to the originaltreereturned byparser_parse().
All bytes and points should be 0-indexed.
Usage
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"
)
Arguments
| 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. | 
Value
A new tree.
Examples
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)
)