Skip to contents

A minimal constant-folder: finds assignments of the exact shape name <- "literal" (or =/<<-) at the START of a (comment-free) line — the same "top level" approximation repro_defined_vars() uses — and returns the literal each name was last assigned. Only a bare quoted string is resolved (no concatenation, no function calls); anything else leaves that name absent from the result, so a caller asking for an unresolvable name gets NA, never a guess.

Usage

.repro_simple_string_vars(code_text, calls = FALSE)

Arguments

code_text

the code text for a single file, comments already stripped

calls

also resolve a call holding one quoted text and nothing else, paste0("..."), paste("..."), file.path("..."), path.expand("...") or normalizePath("..."), which give that text: a folder on the authors' computer was held as main_address = paste0("~/Library/...") in 10.1111/1365-2435.14620 (#578, item 4). FALSE by default.

Value

a named character vector (name = literal value), possibly empty