Skip to main content

Polynomial-Time Optimal Pretty-Printing Combinators with Choice

  • Conference paper
  • First Online:

Part of the book series: Lecture Notes in Computer Science ((LNTCS,volume 8974))

Abstract

We describe pretty-printing combinators with choice which provide optimal document layout in polynomial time. Bottom-up tree rewriting and dynamic programming (BURS) is used to calculate a set of possible layouts for a given output width. We also present the results of suggested approach evaluation and discuss its application for the implementation of pretty-printers.

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

Buying options

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 EPUB and 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

Learn about institutional subscriptions

Notes

  1. 1.

    The sets of combinators suggested by Hughes and Wadler slightly differ in details; however both of them share a similar relevant properties.

  2. 2.

    http://www.cs.uu.nl/wiki/HUT/WebHome.

  3. 3.

    We use square brackets to denote multi-symbol terminals.

  4. 4.

    http://github.com/anlun/polynomialPPCombinators.

References

  1. Aho, A.V., Ganapathi, M., Tjiang, S.W.K.: Code generation using tree matching and dynamic programming. ACM Trans. Program. Lang. Syst. 11(4), 491–516 (1989)

    Article  Google Scholar 

  2. Azero, P., Swierstra, S.D.: Optimal Pretty-Printing Combinators. http://www.cs.ruu.nl/groups/ST/Software/PP, (1998)

  3. Swierstra, S.D., Alcocer, P.R.A., Saraiva, J.: Designing and implementing combinator languages. In: Swierstra, S.D., Oliveira, J.N., Henriques, P.R. (eds.) AFP 1998. LNCS, vol. 1608. Springer, Heidelberg (1999)

    Chapter  Google Scholar 

  4. Chitil, O.: Pretty printing with lazy dequeues. ACM Trans. Program. Lang. Syst. 27, 163–184 (2005)

    Article  Google Scholar 

  5. Comon, H., Dauchet, M., Gilleron, R. et al.: Tree Automata Techniques and Applications. http://www.grappa.univ-lille3.fr/tata, (2007)

  6. Hughes, J.: The design of a pretty-printing library. In: Jeuring, J., Meijer, E. (eds.) AFP 1995. LNCS, vol. 925. Springer, Heidelberg (1995)

    Chapter  Google Scholar 

  7. Jackson, S., Devanbu, P., Ma, K.: Stable, flexible, peephole pretty-printing. J. Sci. Comput. Program. 72(1–2), 40–51 (2008)

    Article  MathSciNet  Google Scholar 

  8. De Jonge, M.: A pretty-printer for every occasion. In: Proceedings of the 2nd International Symposium on Constructing Software Engineering Tools (2000)

    Google Scholar 

  9. De Jonge, M.: Pretty-printing for software reengineering. In: Proceedings of the International Conference On Software Maintenance (2002)

    Google Scholar 

  10. Costanzo, D., Shao, Z.: A case for behavior-preserving actions in separation logic. In: Jhala, R., Igarashi, A. (eds.) APLAS 2012. LNCS, vol. 7705, pp. 332–349. Springer, Heidelberg (2012)

    Chapter  Google Scholar 

  11. Oppen, D.C.: Pretty-printing. ACM Transact. Program. Lang. Syst. 2(4), 465–483 (1980)

    Article  Google Scholar 

  12. Swierstra, S.D.: Linear, Online, Functional Pretty Printing (corrected and extended version). Technical report, UU-CS-2004-025a. Institute of Information and Computing Sciences, Utrecht University (2004)

    Google Scholar 

  13. Swierstra, S.D., Chitil, O.: Linear, bounded, functional pretty-printing. J. Funct. Program. 19, 1–16 (2009)

    Article  MATH  Google Scholar 

  14. van den Brand, M., Visser, E.: Generation of formatters for context-free languages. ACM Trans. Softw. Eng. Methodol. 5(1), 1–41 (1996)

    Article  Google Scholar 

  15. Wadler, P.: A Prettier Printer: The Fun of Programming. Palgrave MacMillan (2003)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Anton Podkopaev .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2015 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Podkopaev, A., Boulytchev, D. (2015). Polynomial-Time Optimal Pretty-Printing Combinators with Choice. In: Voronkov, A., Virbitskaite, I. (eds) Perspectives of System Informatics. PSI 2014. Lecture Notes in Computer Science(), vol 8974. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-662-46823-4_21

Download citation

  • DOI: https://doi.org/10.1007/978-3-662-46823-4_21

  • Published:

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-662-46822-7

  • Online ISBN: 978-3-662-46823-4

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics