Generating Rewritable Abstract Syntax Trees

  • Authors:
  • Jeffrey L. Overbey;Ralph E. Johnson

  • Affiliations:
  • University of Illinois at Urbana-Champaign, Urbana, USA IL 61801;University of Illinois at Urbana-Champaign, Urbana, USA IL 61801

  • Venue:
  • Software Language Engineering
  • Year:
  • 2009

Quantified Score

Hi-index 0.00

Visualization

Abstract

Building a production-quality refactoring engine or similar source code transformation tool traditionally requires a large amount of hand-written, language-specific support code. We describe a system which reduces this overhead by allowing both a parser and a fully rewritable AST to be generated automatically from an annotated grammar, requiring little or no additional hand-written code. The rewritable AST is ideal for implementing program transformations that preserve the formatting of the original sources, including spacing and comments, and the system can be augmented to allow transformation of C-preprocessed sources even when the target language is not C or C++. Moreover, the AST design is fully customizable, allowing it to resemble a hand-coded tree. The amount of required annotation is typically quite small, and the annotated grammar is often an order of magnitude smaller than the generated code.