Skip to content

Commit

Permalink
Allow for early termination of the visitor
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasPietzschmann committed Aug 30, 2024
1 parent f836948 commit 0e46211
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion R/visit.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ visit_node <- function(node, callback) {
return()
}

callback(node)
res <- callback(node)
# Exit early if the callback returns FALSE
if (isFALSE(res)) {
return()
}

# same logic as the builtin visitor (while explicitly specifying if an entry is a single node or a list)
# https://github.com/Code-Inspect/flowr/blob/main/src/r-bridge/lang-4.x/ast/model/processing/visitor.ts#L22
Expand Down

0 comments on commit 0e46211

Please sign in to comment.