Tell me what the next terminal is
If the first is a terminal, return it. If not, go inside it and search the next terminal
next_terminal( pd, stack = FALSE, vars = c("pos_id", "token", "text"), tokens_exclude = c() )
pd |
A nest. |
stack |
Whether or not to also return information on the tokens that
are between |
vars |
The variables to return. |
tokens_exclude |
A vector with tokens to exclude. This can be helpful if one wants to find the next token that is not a comment for example. |
Returns a tibble (which is not a valid parse table for
stack = TRUE
), with vars
and another variable position
that denotes
the index each element in the transition. This can be helpful in conjunction
with purrr::pluck()
or purrr::modify_in()
to reach the terminal in the
nested structure.
withr::with_options( list(styler.cache_name = NULL), # temporarily deactivate cache { pd <- styler:::compute_parse_data_nested("if (TRUE) f()") styler:::next_terminal(pd) } )
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.