Affiliation:
1. Computer Systems Laboratory, Stanford University, Stanford, CA
Abstract
An algorithm for prettyprinting is given. For an input stream of length
n
and an output device with linewidth
m
, the algorithm requires time
O
(
n
) and space
O
(
m
). The algorithm is described in terms of two parallel processes: the first scans the input stream to determine the space required to print logical blocks of tokens; the second uses this information to decide where to break lines of text; the two processes communicate by means of a buffer of size
O
(
m
). The algorithm does not wait for the entire stream to be input, but begins printing as soon as it has received a full line of input. The algorithm is easily implemented.
Publisher
Association for Computing Machinery (ACM)
Cited by
47 articles.
订阅此论文施引文献
订阅此论文施引文献,注册后可以免费订阅5篇论文的施引文献,订阅后可以查看论文全部施引文献
1. Holon programming regained;TUGboat;2024
2. A Pretty Expressive Printer;Proceedings of the ACM on Programming Languages;2023-10-16
3. Effects as capabilities: effect handlers and lightweight effect polymorphism;Proceedings of the ACM on Programming Languages;2020-11-13
4. Interaction with Formal Mathematical Documents in Isabelle/PIDE;Lecture Notes in Computer Science;2019
5. Towards a universal code formatter through machine learning;Proceedings of the 2016 ACM SIGPLAN International Conference on Software Language Engineering;2016-10-20