Skip to main content

Efficient incremental evaluation of higher order attribute grammars

  • Session: Grammars
  • Conference paper
  • First Online:
Programming Language Implementation and Logic Programming (PLILP 1991)

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

Abstract

This paper presents a new algorithm for the incremental evaluation of Ordered Attribute Grammars (OAGs), which also solves the problem of the incremental evaluation of Ordered Higher order Attribute Grammars (OHAGs). Two new approaches are used in the algorithm.

First, instead of caching all results of semantic functions in the grammar, all results of visits to trees are cached. There are no attributed trees, because all attributes are stored in the cache. Trees are build using hash consing, thus sharing multiple instances of the same tree and avoiding repeated attributions of the same tree with the same inherited attributes. Second, each visit computes not only synthesized attributes but also bindings for subsequent visits. Bindings, which contain attribute values computed in one visit and used in subsequent visits, are also stored in the cache. As a result, second and further visits get a subtree containing only all necessary earlier computed values (the bindings) as a parameter.

The algorithm runs in O(|Affected| + |paths_to_roots|) steps after modifying subtrees, where paths_to_roots is the sum of the lengths of all paths from the root to all modified subtrees, which is almost as good as an optimal algorithm for first order AGs, which runs in O(|Affected|).

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. Deransart, P., M. Jourdan and B. Lorho. Attribute Grammars: Definitions, Systems and Bibliography. LNCS 323, Springer Verlag, Aug. 1988.

    Google Scholar 

  2. Deransart, P., M. Jourdan (Eds.). Attribute Grammars and their Applications. Proceedings of the International Workshop on Attribute Grammars and their Applications (WAGA), LNCS 461, Paris, September 19–21, 1990.

    Google Scholar 

  3. Hughes, R.J.M. Super-combinators: A New Implementation Method for Applicative Languages. In Proc. ACM Symp. on Lisp and Functional Progr., Pittsburgh, 1982.

    Google Scholar 

  4. Hughes, R.J.M. Lazy memo functions. In Proc. Conference on Functional Progr. and Comp. Architecture, Nancy, pages 129–146, LNCS 201, Springer Verlag, 1985.

    Google Scholar 

  5. Kastens, U. Ordered Attributed Grammars. Acta Informatica, 13, pages 229–256, 1980.

    Google Scholar 

  6. Pugh, W.W. Incremental Computation and the Incremental Evaluation of Functional Programs. Tech. Rep. 88-936 and Ph.D. Thesis, Dept. of Computer Science, Cornell Univ., Ithaca, N.Y., Aug. 1988.

    Google Scholar 

  7. Reps, T. and T. Teitelbaum. The Synthesizer Generator: A System for Constructing Language-Based Editors. Springer-Verlag, NY, 1988.

    Google Scholar 

  8. Swierstra, S.D. and H.H. Vogt. Higher Order Attribute Grammars. In the proceedings of the International Summer School on Attribute Grammars, Applications and Systems, (To Appear), Prague, June 4–13, 1991.

    Google Scholar 

  9. Teitelbaum, T. and R. Chapman. Higher-Order Attribute Grammars and Editing Environments. ACM SIGPLAN '90 Conference on Programming Language Design and Implementation, White Plains, New York, pages 197–208, June, 1990.

    Google Scholar 

  10. Turner, D.A. Miranda: A non-strict functional language with polymorphic types. In J. Jouannaud, editor, Funct. Progr. Lang. and Comp. Arch., pages 1–16, Springer, 1985.

    Google Scholar 

  11. Vogt, H.H., S.D. Swierstra and M.F. Kuiper. Higher Order Attribute Grammars. ACM SIGPLAN '89 Conference on Programming Language Design and Implementation, Portland, Oregon, pages 131–145, June, 1989.

    Google Scholar 

  12. Yeh, D. On incremental evaluation of ordered attributed grammars. BIT, 23:308–320, 1983.

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Jan Maluszyński Martin Wirsing

Rights and permissions

Reprints and permissions

Copyright information

© 1991 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Vogt, H., Swierstra, D., Kuiper, M. (1991). Efficient incremental evaluation of higher order attribute grammars. In: Maluszyński, J., Wirsing, M. (eds) Programming Language Implementation and Logic Programming. PLILP 1991. Lecture Notes in Computer Science, vol 528. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-54444-5_102

Download citation

  • DOI: https://doi.org/10.1007/3-540-54444-5_102

  • Published:

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-54444-9

  • Online ISBN: 978-3-540-38362-8

  • eBook Packages: Springer Book Archive

Publish with us

Policies and ethics