query-accessors | R Documentation |
query_pattern_count()
returns the number of patterns in a query.
query_capture_count()
returns the number of captures in a query.
query_string_count()
returns the number of string literals in a query.
query_start_byte_for_pattern()
returns the byte where the i
th pattern
starts in the query source
.
query_pattern_count(x)
query_capture_count(x)
query_string_count(x)
query_start_byte_for_pattern(x, i)
x |
A query. |
i |
The |
query_pattern_count()
, query_capture_count()
, and
query_string_count()
return a single double count value.
query_start_byte_for_pattern()
returns a single double for the start byte
if there was an i
th pattern, otherwise it returns NA
.
source <- '(binary_operator
lhs: (identifier) @lhs
operator: _ @operator
rhs: (function_definition) @rhs
(#eq? @lhs "fn")
)'
language <- treesitter.r::language()
query <- query(language, source)
query_pattern_count(query)
query_capture_count(query)
query_string_count(query)
text <- "
fn <- function() {}
fn2 <- function() {}
fn <- 5
fn <- function(a, b, c) { a + b + c }
"
parser <- parser(language)
tree <- parser_parse(parser, text)
node <- tree_root_node(tree)
query_matches(query, node)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.