Abstract
This paper describes a tool for the transformation of attributed trees using pattern matching. The trees to be processed are defined by a formalism based on contextfree grammars. Operations for trees such as composition and decomposition are provided. The approach can be characterized as an amalgamation of trees or terms including pattern matching, with recursion, attribute grammars, and imperative programming. Transformations can either modify the input trees or map them to arbitrary output. Possible applications are the various transformation tasks in compilers such as semantic analysis, optimization, or the generation of intermediate representations. The design goals have been to combine an expressive and high level technique for transformation with flexibility, efficiency, and practical usability. A reliable development style is supported by static typing and checks for the single assignment property of variables. We give some example transformations and describe the input language of our tool called puma. The relationship to similar work is discussed. Finally, experimental results are presented that demonstrate the efficiency of our approach.
Chapter PDF
Similar content being viewed by others
References
A. V. Aho, M. Ganapathi and S. W. K. Tjiang, Code Generation Using Tree Matching and Dynamic Programming, ACM Trans. Prog. Lang. and Systems 11, 4 (Oct. 1989), 491–516.
R. Burstall, D. MacQueen and D. Sannella, HOPE: An Experimental Applicative Language, Report CSR-62-80, Computer Science Department, Edinburgh, 1980.
I. H. Carmichael and J. R. Cordy, TXL — Tree Transformation Language, Syntax and Informal Semantics, Dept. of Computing and Information Sciences, Queens's Univeristy, Kingston, Apr. 1991.
W. F. Clocksin and C. S. Mellish, Programming in Prolog, Springer Verlag, Berlin, 1984.
J. R. Cordy and E. Promislow, Specification and Automatic Prototype Implementation of Polymorphic Objects in TURING using the TXL Dialect Processor, Proc. IEEE 1990 International Conference on Computer Languages, New Orleans, Mar. 1990, 145–154.
H. Emmelmann, F. W. Schröer and R. Landwehr, BEG — a Generator for Efficient Back Ends, SIGPLAN Notices 24, 7 (July 1989), 227–237.
J. Grosch, Ag — An Attribute Evaluator Generator, Compiler Generation Report No. 16, GMD Forschungsstelle an der Universität Karlsruhe, Aug. 1989.
J. Grosch and H. Emmelmann, A Tool Box for Compiler Construction, LNCS 477, (Oct. 1990), 106–116, Springer Verlag.
J. Grosch, Puma — A Generator for the Transformation of Attributed Trees, Compiler Generation Report No. 26, GMD Forschungsstelle an der Universität Karlsruhe, July 1991.
J. Grosch, Tool Support for Data Structures, Structured Programming 12, (1991), 31–38.
R. Heckmann and G. Sander, Trafola-H Reference Manual, Prospectra Project Report, Universität des Saarlandes, Saarbrücken, 1991.
IRDATA, Industrial Robot Data, DIN 66313, Beuth-Verlag, Berlin, 1991.
IRL, Industrial Robot Language, DIN 66312, Beuth-Verlag, Berlin, to appear, 1992.
M. Jourdan and D. Parigot, Application Development with the FNC-2 Attribute Grammar System, LNCS 477, (Oct. 1990), 11–25, Springer Verlag.
U. Kastens, B. Hutt and E. Zimmermann, GAG: A Practical Compiler Generator, Springer Verlag, Heidelberg, 1982.
D. E. Knuth, Semantics of Context-Free Languages, Mathematical Systems Theory 2, 2 (June 1968), 127–146.
C. H. A. Koster, Affix Grammars, in ALGOL 68 Implementation, J. E. L. Peck (ed.), North Holland, Amsterdam, 1971, 95–109.
C. H. A. Koster, CDL: A Compiler Implementation Language, LNCS 47, (1977), 341–351, Springer Verlag.
P. Lipps, U. Möncke, M. Olk and R. Wilhelm, Attribute (Re)evaluation in OPTRAN, Acta Inf. 26, (1988), 213–239.
P. Lipps, U. Möncke and R. Wilhelm, OPTRAN — A Language/System for the Specification of Program Transformations, System Overview and Experiences, LNCS 371, (1989), 52–65, Springer Verlag.
J. McCarthy, P. W. Abrahams, D. J. Edwards, T. R. Hart and M. I. Levin, Lisp 1.5 Programmer's Manual, MIT Press, Cambridge, MA, 1965.
R. Milner, The Standard ML Core Language, Polymorphism 2, 2 (1985),.
K. V. Nori, U. Ammann, K. Jensen, H. H. Nägeli and C. Jacobi, The Pascal-P Compiler: Implementation Notes, Bericht 10, Eidgenössische Technische Hochschule, Zürich, July 1976.
J. Paakki, A Prolog-Based Compiler Writing Tool, in Proceedings of the Workshop on Compiler Compiler and High Speed Compilation, D. Hammer (ed.), Berlin, GDR, 1989, 107–117.
D. A. Turner, Miranda: A Nonstrict Functional Language with Polymorphic Types, LNCS 201, (1985), 1–16, Springer Verlag.
J. Vollmer, The Compiler Construction System GENTLE, GMD-Arbeitspapier Nr. 508, GMD Forschungsstelle an der Universität Karlsruhe, Feb. 1991.
W. M. Waite, J. Grosch and F. W. Schröer, Three Compiler Specifications, GMD-Studie Nr. 166, GMD Forschungsstelle an der Universität Karlsruhe, Aug. 1989.
D. A. Watt, Analysis Oriented Two Level Grammars, Ph. D. thesis, University of Glasgow, Glasgow, 1974.
Author information
Authors and Affiliations
Editor information
Rights and permissions
Copyright information
© 1992 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Grosch, J. (1992). Transformation of attributed trees using pattern matching. In: Kastens, U., Pfahler, P. (eds) Compiler Construction. CC 1992. Lecture Notes in Computer Science, vol 641. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-55984-1_1
Download citation
DOI: https://doi.org/10.1007/3-540-55984-1_1
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-55984-9
Online ISBN: 978-3-540-47335-0
eBook Packages: Springer Book Archive