Parses the code and walks each top-level expression with the visitor.
Arguments
- code
Character(1). R code to parse and walk.
- visitor
A visitor list (see
walk_ast()).
Examples
# Find all function calls in a code string
visitor <- list(
on_call = function(expr, fn_name, depth) fn_name
)
walk_code("x <- mean(1:10)\ny <- sum(x)", visitor)
#> [[1]]
#> [1] "<-"
#>
#> [[2]]
#> [1] "mean"
#>
#> [[3]]
#> [1] ":"
#>
#> [[4]]
#> [1] "<-"
#>
#> [[5]]
#> [1] "sum"
#>