Skip to contents

Find the kind of a node

Usage

node_kind(x)

Arguments

x

A node, either from tree_root() or from another node_*() function.

Examples

src <- "x <- rnorm(100, mean = 2)
    any(duplicated(y))
    x <- z + 1
    any(duplicated(x))"

root <- src |>
  tree_new() |>
  tree_root()

root |>
  node_find(ast_rule(pattern = "any(duplicated($VAR))")) |>
  node_kind()
#> $rule_1
#> [1] "call"
#> 

root |>
  node_find(ast_rule(pattern = "$X + $VALUE")) |>
  node_kind()
#> $rule_1
#> [1] "binary_operator"
#>