Advertisement

Efficient incremental evaluation of higher order attribute grammars

  • Harald Vogt
  • Doaitse Swierstra
  • Matthijs Kuiper
Session: Grammars
Part of the Lecture Notes in Computer Science book series (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|).

Keywords

Subsequent Visit Context Free Grammar Semantic Function Incremental Evaluation Attribute Grammar 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. [Deransart, Jourdan and Lorho 88]
    Deransart, P., M. Jourdan and B. Lorho. Attribute Grammars: Definitions, Systems and Bibliography. LNCS 323, Springer Verlag, Aug. 1988.Google Scholar
  2. [WAGA 90]
    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 82]
    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 85]
    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 80]
    Kastens, U. Ordered Attributed Grammars. Acta Informatica, 13, pages 229–256, 1980.Google Scholar
  6. [Pugh 88]
    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 and Teitelbaum 88]
    Reps, T. and T. Teitelbaum. The Synthesizer Generator: A System for Constructing Language-Based Editors. Springer-Verlag, NY, 1988.Google Scholar
  8. [Swierstra and Vogt 91]
    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. [TC90]
    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 1985]
    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, Swierstra and Kuiper 89]
    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 83]
    Yeh, D. On incremental evaluation of ordered attributed grammars. BIT, 23:308–320, 1983.Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 1991

Authors and Affiliations

  • Harald Vogt
    • 1
  • Doaitse Swierstra
    • 1
  • Matthijs Kuiper
    • 1
  1. 1.Department of Computer ScienceUtrecht UniversityUtrechtThe Netherlands

Personalised recommendations