Generation of formatters for context-free languages
- 1 January 1996
- journal article
- Published by Association for Computing Machinery (ACM) in ACM Transactions on Software Engineering and Methodology
- Vol. 5 (1) , 1-41
- https://doi.org/10.1145/226155.226156
Abstract
Good documentation is important for the production of reusable and maintainable software. For the production of accurate documentation it is necessary that the original program text is not copied manually to obtain a typeset version. Apart from being tedious, this will invariably introduce errors. The production of tools that support the production of legible and accurate documentation is a software engineering challenge in itself. We present an algebraic approach to the generation of tools that produce typographically effective presentations of computer programs. A specification of a formatter is generated from the context-free grammar of a (programming) language. These generated formatters translate abstract syntax trees of programs into box expressions. Box expressions are translated by language-independent interpreters of the box language into ASCII or T E X. The formatting rules that are generated can easily be tuned in order to get the desired formatting of programs. We demonstrate this by means of real-life applications. Furthermore, we give a practical solution for the problem of formatting comments, which occur in the original text. The formatter generation approach proposed in this article can be used to generate formatting programs for arbitrary programming environments. Our formatter generation approach can be used to automatically generate formatters that have to be programmed explicitly in other systems.Keywords
This publication has 10 references indexed in Scilit:
- A meta-environment for generating programming environmentsACM Transactions on Software Engineering and Methodology, 1993
- A design rationale for a language‐based editorSoftware: Practice and Experience, 1991
- A Process Specification Formalism1Fundamenta Informaticae, 1990
- TuringTool: a user interface to aid in the software maintenance taskIEEE Transactions on Software Engineering, 1990
- The syntax definition formalism SDF—reference manual—ACM SIGPLAN Notices, 1989
- A language-independent prettyprinterSoftware: Practice and Experience, 1989
- User‐adaptable prettyprintingSoftware: Practice and Experience, 1989
- Target code generation from G-machine codePublished by Springer Nature ,1987
- Context-sensitive editing with PSG environmentsPublished by Springer Nature ,1986
- PrettyprintingACM Transactions on Programming Languages and Systems, 1980