Advertisement

A Pretty Good Formatting Pipeline

  • Anya Helene Bagge
  • Tero Hasu
Part of the Lecture Notes in Computer Science book series (LNCS, volume 8225)

Abstract

Proper formatting makes the structure of a program apparent and aids program comprehension. The need to format code arises in code generation and transformation, as well as in normal reading and editing situations. Commonly used pretty-printing tools in transformation frameworks provide an easy way to produce indented code that is fairly readable for humans, without reaching the level of purpose-built reformatting tools, such as those built into IDEs. This paper presents a library of pluggable components, built to support style-based formatting and reformatting of code, and to enable further experimentation with code formatting.

Keywords

Parse Tree Control Token Code Format Abstract Syntax Tree Java Library 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    van den Brand, M.G.J., Visser, E.: Generation of formatters for context-free languages. ACM Transactions on Software Engineering and Methodology 5(1), 1–41 (1996)CrossRefGoogle Scholar
  2. 2.
    Chitil, O.: Pretty printing with lazy dequeues. ACM Trans. Program. Lang. Syst. 27, 163–184 (2005)CrossRefGoogle Scholar
  3. 3.
    Coutaz, J.: A layout abstraction for user-system interface. SIGCHI Bull. 16(3), 18–24 (1985), http://doi.acm.org/10.1145/1044201.1044202 CrossRefGoogle Scholar
  4. 4.
    Flatt, M.: PLT: Reference: Racket. Tech. Rep. PLT-TR-2010-1, PLT Inc (2010), http://racket-lang.org/tr1/
  5. 5.
    Hughes, J.: The design of a pretty-printing library. In: Jeuring, J., Meijer, E. (eds.) AFP 1995. LNCS, vol. 925, pp. 53–96. Springer, Heidelberg (1995)CrossRefGoogle Scholar
  6. 6.
    Jackson, S., Devanbu, P., Ma, K.L.: Stable, flexible, peephole pretty-printing. Science of Computer Programming 72(1-2), 40–51 (2008)MathSciNetCrossRefGoogle Scholar
  7. 7.
    James, R.P., Sabry, A.: Yield: Mainstream delimited continuations. In: First International Workshop on the Theory and Practice of Delimited Continuations, TPDC 2011 (May 2011)Google Scholar
  8. 8.
    de Jonge, M.: A pretty-printer for every occasion. In: Ferguson, I., Gray, J., Scott, L. (eds.) Proceedings of the 2nd International Symposium on Constructing Software Engineering Tools (CoSET 2000), University of Wollongong, Australia, pp. 68–77 (June 2000)Google Scholar
  9. 9.
    Kiselyov, O., Peyton-Jones, S., Sabry, A.: Lazy v. Yield: Incremental, linear pretty-printing. In: Jhala, R., Igarashi, A. (eds.) APLAS 2012. LNCS, vol. 7705, pp. 190–206. Springer, Heidelberg (2012)CrossRefGoogle Scholar
  10. 10.
    Klint, P., van der Storm, T., Vinju, J.: Rascal: A domain specific language for source code analysis and manipulation. In: SCAM 2009: Proceedings of the 2009 Ninth IEEE International Working Conference on Source Code Analysis and Manipulation, pp. 168–177. IEEE Computer Society, Washington, DC (2009)CrossRefGoogle Scholar
  11. 11.
    McKeeman, W.M.: Algorithm 268: Algol 60 reference language editor. Commun. ACM 8(11), 667–668 (1965)CrossRefGoogle Scholar
  12. 12.
    Miara, R.J., Musselman, J.A., Navarro, J.A., Shneiderman, B.: Program indentation and comprehensibility. Commun. ACM 26(11), 861–867 (1983)CrossRefGoogle Scholar
  13. 13.
    Okasaki, C.: Purely Functional Data Structures. Cambridge University Press (1999)Google Scholar
  14. 14.
    Oppen, D.C.: Prettyprinting. ACM Trans. Program. Lang. Syst. 2, 465–483 (1980)CrossRefGoogle Scholar
  15. 15.
    Reiss, S.P.: Automatic code stylizing. In: 22nd IEEE/ACM International Conference on Automated Software Engineering (ASE), Atlanta, Georgia, pp. 74–83 (November 2007)Google Scholar
  16. 16.
    Swierstra, S.D.: Linear, online, functional pretty printing (corrected and extended version). Tech. Rep. UU-CS-2004-025a, Department of Information and Computing Sciences, Utrecht University (2004)Google Scholar
  17. 17.
    Swierstra, S.D., Chitil, O.: Linear, bounded, functional pretty-printing. Journal of Functional Programming 19(1), 1–16 (2009)MathSciNetCrossRefzbMATHGoogle Scholar
  18. 18.
    Wadler, P.: A prettier printer. In: Gibbons, J., de Moor, O. (eds.) The Fun of Programming. Cornerstones of Computing. Palgrave Macmillan (June 2005)Google Scholar
  19. 19.
    Wadler, P., Taha, W., Macqueen, D.: How to add laziness to a strict language without even being odd. In: Workshop on Standard ML, Baltimore, Maryland (1998)Google Scholar

Copyright information

© Springer International Publishing Switzerland 2013

Authors and Affiliations

  • Anya Helene Bagge
    • 1
  • Tero Hasu
    • 1
  1. 1.Bergen Language Design Laboratory, Dept. of InformaticsUniversity of BergenNorway

Personalised recommendations