Abstract
This paper presents a technique for the efficient incremental evaluation of Attribute Grammars. Through its generality, the applied approach may be affective too in the evaluation of Higher order Attribute Grammars. Our approach is an extension of a simpler algorithm for incremental evaluation, where functions, corresponding to visit sequences, are cached. Consequently, attributes are now either found in the cache or they are recomputed, so there is no longer need to represent the attributed tree explicitly. We may share common subtrees, avoiding repeated attribute evaluation, thus solving a typical HAG problem.
We propose the following change: instead of explicitly representing the tree and calling visit sequence functions to compute the attributes, the tree is represented through a set of visit functions corresponding to the successive visits. These functions are constructed using the visit sequences as building blocks.
This technique has two major advantages. Firstly, a visit function characterizes precisely that part of the tree that would actually have been visited in the previous approach, thus increasing the number of cache hits. Secondly, copyrules may be removed during the construction phase. This results in shortcircuiting copychains and in minimizing the number of recomputed functions.
Preview
Unable to display preview. Download preview PDF.
References
Alblas, Henk. Introduction to Attribute Grammars. In H. Alblas and B. Melichar (Eds.) Attribute Grammars, Applications and Systems (SAGA '91), Lecture Notes in Computer Science, Vol. 545, pages 1–115, Springer-Verlag, June 1991.
Deransart, Pierre, Martin Jourdan and Bernard Lorho. Attribute Grammars. Definitions, Systems and Bibliography. Lecture Notes in Computer Science, Vol. 323, Springer-Verlag, August 1988.
Deransart, P, M Jourdan (Eds.). Attribute Grammars and their Applications (WAGA '90). Lecture Notes in Computer Science, Vol. 461, Springer-Verlag, September 1990.
Hudak, Paul and Joseph H. Fasel. A Gentle Introduction to Haskell. In ACM SIGPLAN Notices Haskell special issue, Vol. 27, No. 5, May 1992.
Hudak, P., S. Peyton-Jones and P. Wadler (Eds.). Report on the Programming Language Haskell, A Non-strict Purely Functional Language (Version 1.2). In ACM SIGPLAN Notices Haskell special issue, Vol. 27, No. 5, May 1992.
Hughes, John. Lazy memo-functions. In Jean-Pierre Jouannaud (Ed.) Functional Programming Languages and Computer Architecture, Lecture Notes in Computer Science, Vol. 201, pages 129–146, Springer-verlag, 1985.
Jones, Mark P. Introduction to Gofer 2.20, Oxford Programming Research Group, November 1991.
Kastens, Uwe. Ordered Attributed Grammars. In Acta Informatica, Vol. 13, pages 229–256, 1980.
Knuth, Donald E. Semantics of context-free languages. In Mathematical Systems Theory, Vol. 2, No. 2, pages 127–145, Springer-Verlag, 1968.
Knuth, Donald E. Semantics of context-free languages (correction). In Mathematical Systems Theory, Vol. 5, No. 1, pages 95–96, Springer-Verlag, 1971.
Pugh, W. W. Incremental Computation and the Incremental Evaluation of Functional Programs. Technical Report 88-936 and Ph.D. Thesis, Department of Computer Science, Cornell University, Ithaca, N.Y., August 1988.
Swierstra, S.D. and H.H. Vogt. Higher Order Attribute Grammars. In H. Alblas and B. Melichar (Eds.) Attribute Grammars, Applications and Systems (SAGA '91), Lecture Notes in Computer Science, Vol. 545, pages 256–296, Springer-Verlag, June 1991.
Teitelbaum, Tim and Richard Chapman. Higher-Order Attribute Grammars and Editing Environments. In Proceedings of the SIGPLAN '90 Conference on Programming Language Design and Implementation, Vol. 25, No. 6 (proceedings), pages 197–208, June 1990.
Turner, D.A. Miranda: A non-strict functional language with polymorphic types. In Jean-Pierre Jouannaud (Ed.) Functional Programming Languages and Computer Architecture, Lecture Notes in Computer Science, Vol. 201, pages 1–16, Springer-Verlag, 1985.
Vogt, H.H., S.D. Swierstra and M.F. Kuiper. Higher Order Attribute Grammars. In Proceedings of the SIGPLAN '89 Conference on Programming Language Design and Implementation, Vol. 24, No. 7 (proceedings), pages 131–145, June 1989.
Vogt, Harald, Doaitse Swierstra and Matthijs Kuiper. Efficient Incremental Evaluation of Higher Order Attribute Grammars. In J. Maluszyński and M. Wirsing (Eds.) Programming Language Implementation and Logic Programming (PLILP '91), Lecture Notes in Computer Science, Vol. 528, pages 231–242, Springer-Verlag, 1991.
Yeh, D. On incremental evaluation of ordered attributed grammars. In BIT, Vol. 23, pages 308–320, 1983.
Author information
Authors and Affiliations
Editor information
Rights and permissions
Copyright information
© 1992 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Pennings, M., Swierstra, D., Vogt, H. (1992). Using cached functions and constructors for incremental attribute evaluation. In: Bruynooghe, M., Wirsing, M. (eds) Programming Language Implementation and Logic Programming. PLILP 1992. Lecture Notes in Computer Science, vol 631. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-55844-6_132
Download citation
DOI: https://doi.org/10.1007/3-540-55844-6_132
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-55844-6
Online ISBN: 978-3-540-47297-1
eBook Packages: Springer Book Archive