Abstract: Program slicing is an important technique to assist program comprehension. A program slicer identifies the parts of a program that are relevant to a given variable, e.g. a visualization or statistical test. The resulting slice can then help R programmers and researchers to understand the program by reducing the amount of code to be considered. We present flowR, a novel program slicer and dataflow analyzer for the R programming language. Given an R program and a variable of interest, flowR can return the resulting slice as a subset of the program or highlight the relevant parts directly in the input. Currently, flowR provides a read-eval-print loop, a server connection, an extension for Visual Studio Code, RStudio, and Positron. flowR is available as a docker image. flowR uses a five-step pipeline architecture, starting with a parser to convert the program into an abstract syntax tree (AST). After normalizing the AST, the dataflow extraction works as a stateful fold over the AST, incrementally constructing the graph of each subtree. The calculation of the program slice reduces to a reachability traversal of the dataflow graph which contains the uses and definitions of all variables. Finally, the slice is either reconstructed as R code or highlighted in the input.
0 commit comments