Skip to content

nick-ulle/rstatic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rstatic

Important

This package is in hibernation: inactive, although I might revisit it in the future.

In the meantime, check out flowr for your R code analysis needs.

rstatic is a package that makes it easier to analyze R code. These are the guiding principles:

  • Reference semantics make code easier to transform. Want to make major code transformations without losing track of an important expression? References have you covered. rstatic's code objects have reference semantics by way of R6.

  • Method dispatch on code objects makes recursive descent algorithms easier to understand. This is more effective if code is organized into meaningful, extensible classes. rstatic's class hierarchy is arranged according to the semantics of R.

  • Access to the parent of a node in an abstract syntax tree is useful for some analyses. rstatic transparently keeps track of each node's parents.

  • Access to code elements by name is clearer than by index. We'd rather write my_call$args[[2]] to access a call's second argument than my_call[[3]]. rstatic uses a consistent set of names for code elements.

  • Abstract syntax trees are not ideal for analyses that need control- and data-flow information. rstatic can convert code to a control flow graph in static single assignment (SSA) form. SSA form exposes data flows by giving each variable definition a unique name.

The codetools and CodeDepends packages use R's built-in language objects to extract similar information from code. They may be more appropriate for quick, ad-hoc analyses.

Installation

rstatic is unstable and under active development, so it's not yet available on CRAN. To install, open an R prompt and run:

install.packages("devtools")

devtools::install_github("nick-ulle/rstatic")

Usage

The package includes a vignette that serves as an introduction. To access the vignette, open an R prompt and run:

library(rstatic)
vignette("rstatic-intro")

Known Issues

See the to-do list.