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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
The sets of combinators suggested by Hughes and Wadler slightly differ in details; however both of them share a similar relevant properties.
- 2.
- 3.
We use square brackets to denote multi-symbol terminals.
- 4.
References
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)
Azero, P., Swierstra, S.D.: Optimal Pretty-Printing Combinators. http://www.cs.ruu.nl/groups/ST/Software/PP, (1998)
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)
Chitil, O.: Pretty printing with lazy dequeues. ACM Trans. Program. Lang. Syst. 27, 163–184 (2005)
Comon, H., Dauchet, M., Gilleron, R. et al.: Tree Automata Techniques and Applications. http://www.grappa.univ-lille3.fr/tata, (2007)
Hughes, J.: The design of a pretty-printing library. In: Jeuring, J., Meijer, E. (eds.) AFP 1995. LNCS, vol. 925. Springer, Heidelberg (1995)
Jackson, S., Devanbu, P., Ma, K.: Stable, flexible, peephole pretty-printing. J. Sci. Comput. Program. 72(1–2), 40–51 (2008)
De Jonge, M.: A pretty-printer for every occasion. In: Proceedings of the 2nd International Symposium on Constructing Software Engineering Tools (2000)
De Jonge, M.: Pretty-printing for software reengineering. In: Proceedings of the International Conference On Software Maintenance (2002)
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)
Oppen, D.C.: Pretty-printing. ACM Transact. Program. Lang. Syst. 2(4), 465–483 (1980)
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)
Swierstra, S.D., Chitil, O.: Linear, bounded, functional pretty-printing. J. Funct. Program. 19, 1–16 (2009)
van den Brand, M., Visser, E.: Generation of formatters for context-free languages. ACM Trans. Softw. Eng. Methodol. 5(1), 1–41 (1996)
Wadler, P.: A Prettier Printer: The Fun of Programming. Palgrave MacMillan (2003)
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights 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)