Efficient incremental evaluation of higher order attribute grammars
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|).
KeywordsSubsequent Visit Context Free Grammar Semantic Function Incremental Evaluation Attribute Grammar
Unable to display preview. Download preview PDF.
- [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
- [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
- [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
- [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
- [Kastens 80]Kastens, U. Ordered Attributed Grammars. Acta Informatica, 13, pages 229–256, 1980.Google Scholar
- [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
- [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
- [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
- [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
- [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
- [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
- [Yeh 83]Yeh, D. On incremental evaluation of ordered attributed grammars. BIT, 23:308–320, 1983.Google Scholar