Skip to main content

Generating Rewritable Abstract Syntax Trees

A Foundation for the Rapid Development of Source Code Transformation Tools

  • Conference paper
Software Language Engineering (SLE 2008)

Part of the book series: Lecture Notes in Computer Science ((LNPSE,volume 5452))

Included in the following conference series:

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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. ASC Center for Astrophysical Thermonuclear Flashes, http://www.flash.uchicago.edu

  2. Bečička, J., Hřebejk, P., Zajac, P.: (Sun Microsystems): Using Java 6 compiler as a refactoring and an anaysis engine. In: 1st Workshop on Refactoring Tools (2007)

    Google Scholar 

  3. Bowdidge, R.: (Apple Computer): Personal communication

    Google Scholar 

  4. Celentano, A.: Incremental LR parsers. Acta Inf. 10, 307–321 (1978)

    Article  MathSciNet  MATH  Google Scholar 

  5. Cordy, J.: The TXL source transformation language. Sci. Comp. Prog. 61, 190–210 (2006)

    MathSciNet  MATH  Google Scholar 

  6. Cormen, T., Leiserson, C., Rivest, R., Stein, C.: Introduction to Algorithms. 2/e. MIT Press, Cambridge (2001)

    MATH  Google Scholar 

  7. De Jonge, M., Visser, E., Visser, J.: XT: A bundle of program transformation tools. In: Proc. Lang. Descriptions, Tools and Applications 2001. Elec. Notes in Theoretical Comp. Sci, vol. 44, pp. 211–218 (2001)

    Google Scholar 

  8. DeRemer, F.: Practical translators for LR(k) languages. PhD thesis, MIT (1969)

    Google Scholar 

  9. Eclipse C/C++ Development Tools, http://www.eclipse.org/cdt

  10. Eclipse Java Development Tools, http://www.eclipse.org/jdt

  11. Ernst, M., Badros, G., Notkin, D.: An empirical analysis of C preprocessor use. IEEE Trans. on Software Eng. 28, 1146–1170 (2002)

    Article  Google Scholar 

  12. Gamma, E., Helm, R., Johnson, R., Vlissides, J.: Design patterns: Elements of reusable object-oriented software. Addison-Wesley, Reading (1994)

    MATH  Google Scholar 

  13. Garrido, A., Johnson, R.: Challenges of refactoring C programs. In: Proc. Intl. Workshop on Principles of Software Evolution, pp. 6–14 (2002)

    Google Scholar 

  14. Garrido, A.: Program refactoring in the presence of preprocessor directives. PhD thesis, University of Illinois at Urbana-Champaign (2005)

    Google Scholar 

  15. Garrido, A., Johnson, R.: Refactoring C with conditional compilation. In: Proc. 18th IEEE Intl. Conf. on Automated Software Eng., pp. 323–326 (2003)

    Google Scholar 

  16. Hopcroft, J., Motwani, R., Ulman, J.: Introduction to automata theory, languages, and computation. 2/e. Addison-Wesley, Reading (2001)

    Google Scholar 

  17. IBEAM, http://www.ibeam.org

  18. ISO/IEC 9899:1999: Programming Languages – C

    Google Scholar 

  19. ISO/IEC 14882:2003: Programming Languages – C++

    Google Scholar 

  20. JJTree, https://javacc.dev.java.net/doc/JJTree.html

  21. Kort, J., Lämmel, R.: Parse-tree annotations meet re-engineering concerns. In: Proc. Source Code Analysis and Manipulation, pp. 161–172 (2003)

    Google Scholar 

  22. Lämmel, R.: Towards generic refactoring. In: Proc. ACM SIGPLAN Workshop on Rule-Based Prog., pp. 15–28 (2002)

    Google Scholar 

  23. LPG, http://sourceforge.net/projects/lpg/

  24. Ludwig, http://jeff.over.bz/software/ludwig

  25. McCloskey, B., Brewer, E.: ASTEC: A new approach to refactoring C. In: Proc. 13th ACM SIGSOFT Intl. Symp. Found. Software Eng., pp. 21–30 (2005)

    Google Scholar 

  26. Mens, T., Van Eetvelde, N., Demeyer, S., Janssens, D.: Formalizing refactorings with graph transformations. J. Software Maint. and Evolution 17, 247–276 (2005)

    Article  Google Scholar 

  27. Parr, T.: The definitive ANTLR reference: Building domain-specific languages. Pragmatic Bookshelf, Raleigh (2007)

    Google Scholar 

  28. Photran, http://www.eclipse.org/photran

  29. Platoff, M., Wagner, M., Camaratta, J.: An integrated program representation and toolkit for the maintenance of C programs. In: Proc. Conf. Software Maint., pp. 129–137 (1991)

    Google Scholar 

  30. Sellink, M., Verhoef, C.: Scaffolding for software renovation. In: Proc. Conf. Software Maint. Reeng., pp. 161–172 (2000)

    Google Scholar 

  31. Stallman, R., Weinberg, Z.: The C preprocessor, http://gcc.gnu.org/onlinedocs/cpp.pdf

  32. Tomita, M.: Generalized LR parsing. Springer, Heidelberg (1991)

    Book  MATH  Google Scholar 

  33. van den Brand, M.G.J., van Deursen, A., Heering, J., de Jong, H.A., de Jonge, M., Kuipers, T., Klint, P., Moonen, L., Olivier, P.A., Scheerder, J., Vinju, J.J., Visser, E., Visser, J.: The ASF+SDF meta-environment: A component-based language development environment. In: Wilhelm, R. (ed.) CC 2001. LNCS, vol. 2027, pp. 365–370. Springer, Heidelberg (2001)

    Chapter  Google Scholar 

  34. Visser, E.: Stratego: A language for program transformation based on rewriting strategies. In: Middeldorp, A. (ed.) RTA 2001. LNCS, vol. 2051, pp. 357–361. Springer, Heidelberg (2001)

    Chapter  Google Scholar 

  35. Vlissides, J.: Pattern hatching: Design patterns applied. Addison-Wesley, Reading (1998)

    Google Scholar 

  36. Wang, D., Appel, A., Korn, J., Serra, C.: The Zephyr abstract syntax description language. In: USENIX Workshop on Domain-Specific Langauges (1997)

    Google Scholar 

  37. Wile, D.: Abstract syntax from concrete syntax. In: Proc. 19th Intl. Conf. on Software Eng., pp. 472–480 (1997)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2009 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Overbey, J.L., Johnson, R.E. (2009). Generating Rewritable Abstract Syntax Trees. In: Gašević, D., Lämmel, R., Van Wyk, E. (eds) Software Language Engineering. SLE 2008. Lecture Notes in Computer Science, vol 5452. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-00434-6_8

Download citation

  • DOI: https://doi.org/10.1007/978-3-642-00434-6_8

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-642-00433-9

  • Online ISBN: 978-3-642-00434-6

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics