Lazy stateless incremental evaluation machinery for attribute grammars

  • Authors:
  • Jeroen Bransen;Atze Dijkstra;S. Doaitse Swierstra

  • Affiliations:
  • Utrecht University, Utrecht, Netherlands;Utrecht University, Utrecht, Netherlands;Utrecht University, Utrecht, Netherlands

  • Venue:
  • Proceedings of the ACM SIGPLAN 2014 Workshop on Partial Evaluation and Program Manipulation
  • Year:
  • 2014

Quantified Score

Hi-index 0.00

Visualization

Abstract

Many computer programs work with data that changes over time. Computations done over such data usually are repeated completely after a change in the data. For complex computations such repetitive recomputation can become too inefficient. When these recomputations take place on data which has only changed slightly, it often is possible to reformulate the computation to an incremental version which reuses the result of the computation on previous data. Such a situation typically occurs in compilers and editors for structured data (like a program) where program analyses and transformations (for example error checking) are done while editing. Although rewriting to incremental versions thus offers a solution to this problem, a manual rewrite of an already complex computation to its incremental counterpart is tedious, error prone, and inhibits further development of the original computation. We therefore intend to generate such incremental counterparts (semi)automatically by focusing on computations expressed using Attribute Grammars (AGs). In this paper we do groundwork for this goal and develop machinery for incremental attribute grammar evaluation based on change propagation and pure functions. We use pretty printing with free variable annotation to explain our techniques. Furthermore, our techniques also expose rules of conduct for a programmer desiring incrementality: the automatic translation of code to an incremental version does not always directly result in efficiency improvements because code often is written in a style unsuitable for automatic incrementalization. We show some common cases in which (small) code changes facilitating incrementality are required. We evaluate the effectiveness of the overall approach using a simple benchmark for the example, and a more extensive benchmark based on constraint-based type inference implemented with AGs.