Skip to main content

Using cached functions and constructors for incremental attribute evaluation

  • Conference paper
  • First Online:
Programming Language Implementation and Logic Programming (PLILP 1992)

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 631))

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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 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.

    Google Scholar 

  2. Deransart, Pierre, Martin Jourdan and Bernard Lorho. Attribute Grammars. Definitions, Systems and Bibliography. Lecture Notes in Computer Science, Vol. 323, Springer-Verlag, August 1988.

    Google Scholar 

  3. Deransart, P, M Jourdan (Eds.). Attribute Grammars and their Applications (WAGA '90). Lecture Notes in Computer Science, Vol. 461, Springer-Verlag, September 1990.

    Google Scholar 

  4. Hudak, Paul and Joseph H. Fasel. A Gentle Introduction to Haskell. In ACM SIGPLAN Notices Haskell special issue, Vol. 27, No. 5, May 1992.

    Google Scholar 

  5. 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.

    Google Scholar 

  6. 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.

    Google Scholar 

  7. Jones, Mark P. Introduction to Gofer 2.20, Oxford Programming Research Group, November 1991.

    Google Scholar 

  8. Kastens, Uwe. Ordered Attributed Grammars. In Acta Informatica, Vol. 13, pages 229–256, 1980.

    Google Scholar 

  9. Knuth, Donald E. Semantics of context-free languages. In Mathematical Systems Theory, Vol. 2, No. 2, pages 127–145, Springer-Verlag, 1968.

    Google Scholar 

  10. Knuth, Donald E. Semantics of context-free languages (correction). In Mathematical Systems Theory, Vol. 5, No. 1, pages 95–96, Springer-Verlag, 1971.

    Google Scholar 

  11. 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.

    Google Scholar 

  12. 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.

    Google Scholar 

  13. 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.

    Google Scholar 

  14. 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.

    Google Scholar 

  15. 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.

    Google Scholar 

  16. 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.

    Google Scholar 

  17. Yeh, D. On incremental evaluation of ordered attributed grammars. In BIT, Vol. 23, pages 308–320, 1983.

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Maurice Bruynooghe Martin Wirsing

Rights and permissions

Reprints 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

Publish with us

Policies and ethics