Skip to content
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ Imports:
R.cache (>= 0.15.0),
rlang (>= 0.1.1),
rprojroot (>= 1.1),
tibble (>= 1.4.2),
tools,
vctrs (>= 0.4.1),
withr (>= 1.0.0),
Expand All @@ -45,6 +44,7 @@ Suggests:
rmarkdown,
roxygen2,
rstudioapi (>= 0.7),
tibble (>= 1.4.2),
testthat (>= 3.0.0)
VignetteBuilder:
knitr
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ importFrom(rlang,is_installed)
importFrom(rlang,seq2)
importFrom(rlang,warn)
importFrom(rlang,with_handlers)
importFrom(tibble,tribble)
importFrom(utils,capture.output)
importFrom(utils,tail)
importFrom(utils,write.table)
2 changes: 1 addition & 1 deletion R/environments.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ parser_version_find <- function(pd) {
#' @details
#' * `parser_version`: Needed to dispatch between parser versions, see
#' [parser_version_set()] for details.
#' * `stylerignore`: A tibble with parse data containing tokens that fall within
#' * `stylerignore`: A data frame with parse data containing tokens that fall within
#' a stylerignore sequence. This is used after serializing the flattened
#' parse table to apply the initial formatting to these tokens. See
#' [stylerignore] for details.
Expand Down
2 changes: 1 addition & 1 deletion R/nest.R
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ set_spaces <- function(spaces_after_prefix, force_one) {
#' a parent to other tokens (called internal) and such that are not (called
#' child). Then, the token in child are joined to their parents in internal
#' and all token information of the children is nested into a column "child".
#' This is done recursively until we are only left with a nested tibble that
#' This is done recursively until we are only left with a nested data frame that
#' contains one row: The nested parse table.
#' @param pd_flat A flat parse table including both terminals and non-terminals.
#' @seealso [compute_parse_data_nested()]
Expand Down
6 changes: 3 additions & 3 deletions R/nested-to-tree.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ create_tree_from_pd_with_default_style_attributes <- function(pd,
}


#' Convert a nested tibble into a node tree
#' Convert a nested data frame into a node tree
#'
#' This function is convenient to display all nesting levels of a nested tibble
#' This function is convenient to display all nesting levels of a nested data frame
#' at once.
#' @param pd_nested A nested tibble.
#' @param pd_nested A nested data frame.
#' @param structure_only Whether or not create a tree that represents the
#' structure of the expression without any information on the tokens. Useful
#' to check whether two structures are identical.
Expand Down
53 changes: 27 additions & 26 deletions R/token-define.R
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
token <- tibble::tribble(
~text, ~class, ~token,
"&", "logical", "AND",
"&&", "logical", "AND2",
"|", "logical", "OR",
"||", "logical", "OR2",
">", "logical", "GT",
"<", "logical", "LT",
"<=", "logical", "LE",
">=", "logical", "GE",
"!=", "logical", "NE",
"==", "logical", "EQ",
"=", "assign_left", "EQ_SUB",
"=", "assign_left", "EQ_ASSIGN",
"<-", "assign_left", "LEFT_ASSIGN",
"->", "assign_right", "RIGHT_ASSIGN",
"+", "math", "'+'",
"-", "math", "'-'",
"*", "math", "'*'",
"/", "math", "'/'",
"^", "math", "'^'",
"~", "formula", "'~'",
"if", "cond", "IF",
"else", "cond", "ELSE",
"in", "loop_cond", "IN",
"while", "loop_cond", "WHILE"
token <- rbind.data.frame(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another option would be as.data.frame(matrix(ncol = 3, byrow = TRUE, c(...)))

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion. But I think I will just retain it like this for now.

c("&", "logical", "AND"),
c("&&", "logical", "AND2"),
c("|", "logical", "OR"),
c("||", "logical", "OR2"),
c(">", "logical", "GT"),
c("<", "logical", "LT"),
c("<=", "logical", "LE"),
c(">=", "logical", "GE"),
c("!=", "logical", "NE"),
c("==", "logical", "EQ"),
c("=", "assign_left", "EQ_SUB"),
c("=", "assign_left", "EQ_ASSIGN"),
c("<-", "assign_left", "LEFT_ASSIGN"),
c("->", "assign_right", "RIGHT_ASSIGN"),
c("+", "math", "'+'"),
c("-", "math", "'-'"),
c("*", "math", "'*'"),
c("/", "math", "'/'"),
c("^", "math", "'^'"),
c("~", "formula", "'~'"),
c("if", "cond", "IF"),
c("else", "cond", "ELSE"),
c("in", "loop_cond", "IN"),
c("while", "loop_cond", "WHILE"),
stringsAsFactors = FALSE
)

colnames(token) <- c("text", "class", "token")
math_token <- token$token[token$class == "math"]
logical_token <- token$token[token$class == "logical"]
left_assignment_token <- token$token[token$class == "assign_left"]
Expand Down
1 change: 0 additions & 1 deletion R/ui-styling.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#' @keywords api
#' @importFrom tibble tribble
#' @importFrom magrittr %>%
NULL

Expand Down
4 changes: 2 additions & 2 deletions R/utils-navigate-nest.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ previous_non_comment <- function(pd, pos) {
#' next terminal
#' @param pd A nest.
#' @param stack Whether or not to also return information on the tokens that
#' are between `pd` and the first terminal, so the returned tibble can be
#' are between `pd` and the first terminal, so the returned data frame can be
#' understood as a transition path from `pd` to the next terminal, instead of
#' the information at the terminal only. The order is inside-out,
#' i.e. the first non-terminal on top, the terminal last.
#' @param vars The variables to return.
#' @param 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.
#' @return
#' Returns a tibble (which is **not** a valid parse table for
#' Returns a data frame (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
Expand Down
1 change: 1 addition & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ cli
CMD
codecov
coercible
coercions
compat
config
CONST
Expand Down
2 changes: 1 addition & 1 deletion man/create_node_from_nested.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions man/create_node_from_nested_root.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/env_current.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/nest_parse_data.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/next_terminal.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/testthat/alignment/tribble-three-cols-in.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tibble::tribble(
tribble(
~x, ~y, ~z,
"one", TRUE, 1L,
"two", FALSE, 2L
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/alignment/tribble-three-cols-out.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tibble::tribble(
tribble(
~x, ~y, ~z,
"one", TRUE, 1L,
"two", FALSE, 2L
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-roxygen-examples-complete.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


test_that("analogous to test-roxygen-examples-complete", {
expect_warning(test_collection(
"roxygen-examples-complete", "^1[^1234567890]",
Expand Down