Skip to main content

Memoized Zipper-Based Attribute Grammars

  • Conference paper
  • First Online:
Programming Languages (SBLP 2016)

Part of the book series: Lecture Notes in Computer Science ((LNPSE,volume 9889))

Included in the following conference series:

Abstract

Attribute Grammars are a powerfull, well-known formalism to implement and reason about programs which, by design, are conveniently modular.

In this work we focus on a state of the art Zipper-based embedding of Attribute Grammars and further improve its performance through controlling attribute (re)evaluation by using memoization techniques. We present the results of our optimization by comparing their impact in various implementations of different, well-studied Attribute Grammars.

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

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    This binding can be seen in the definition of \( globmin \), in \(C_{ Root }\rightarrow locmin \;( tree \; t )\).

  2. 2.

    https://hackage.haskell.org/package/HList.

  3. 3.

    https://hackage.haskell.org/package/ZipperAG.

  4. 4.

    This could also be represented in terms of a State monad, but we will not take that alternative in this paper.

References

  1. Badouel, E., Fotsing, B., Tchougong, R.: Yet another implementation of attribute evaluation. Research Report RR-6315, Inria (2007)

    Google Scholar 

  2. Badouel, E., Fotsing, B., Tchougong, R.: Attribute grammars as recursion schemes over cyclic representations of zippers. Electron. Notes Theory Comput. Sci. 229(5), 39–56 (2011)

    Article  MathSciNet  MATH  Google Scholar 

  3. Balestrieri, F.: The productivity of polymorphic stream equations and the composition of circular traversals. PhD thesis, University of Nottingham (2015)

    Google Scholar 

  4. Bird, R.S.: Using circular programs to eliminate multiple traversals of data. Acta Inf. 21, 239–250 (1984)

    Article  MATH  Google Scholar 

  5. de Moor, O., Backhouse, K., Swierstra, D.: First-class attribute grammars. In: 3rd Workshop on Attribute Grammars and their Applications, Ponte de Lima, Portugal, pp. 1–20 (2000)

    Google Scholar 

  6. Dijkstra, A., Fokker, J., Swierstra, S.D.: The architecture of the Utrecht Haskell compiler. In: Haskell Symposium, pp. 93–104 (2009)

    Google Scholar 

  7. Dijkstra, A., Swierstra, D.: Typing Haskell with an attribute grammar (part I). Technical report UU-CS-2004-037, Institute of Information and Computing Sciences, Utrecht University (2004)

    Google Scholar 

  8. Fernandes, J.P., Saraiva, J.: Tools and libraries to model and manipulate circular programs. In: Symposium on Partial Evaluation and Program Manipulation, pp. 102–111. ACM (2007)

    Google Scholar 

  9. Huet, G.: The zipper. J. Funct. Program. 7(5), 549–554 (1997)

    Article  MathSciNet  MATH  Google Scholar 

  10. Kastens, U., Pfahler, P., Jung, M.: The Eli system. In: Koskimies, K. (ed.) CC 1998. LNCS, vol. 1383, pp. 294–297. Springer, Heidelberg (1998)

    Chapter  Google Scholar 

  11. Kiselyov, O., Lämmel, R., Schupke, K.: Strongly typed heterogeneous collections. In: Workshop on Haskell, pp. 96–107. ACM (2004)

    Google Scholar 

  12. Knuth, D.: Semantics of context-free languages. Math, Syst. Theory, 2(2) (1968). Correction: Math. Syst. Theory, 5(1) (1971)

    Google Scholar 

  13. Kuiper, M., Saraiva, J.: Lrc — a generator for incremental language-oriented tools. In: Koskimies, K. (ed.) CC 1998. LNCS, vol. 1383, pp. 298–301. Springer, Heidelberg (1998)

    Chapter  Google Scholar 

  14. Magnusson, E., Hedin, G.: Circular reference attributed grammars - their evaluation and applications. Sci. Comput. Program. 68(1), 21–37 (2007)

    Article  MathSciNet  MATH  Google Scholar 

  15. Martins, P., Fernandes, J.P., Saraiva, J.: Zipper-based attribute grammars and their extensions. In: Du Bois, A.R., Trinder, P. (eds.) SBLP 2013. LNCS, vol. 8129, pp. 135–149. Springer, Heidelberg (2013)

    Chapter  Google Scholar 

  16. Martins, P., Fernandes, J.P., Saraiva, J., Van Wyk, E., Sloane, A.: Embedding attribute grammars and their extensions using functional zippers. Science of Computer Programming (2016, in Press)

    Google Scholar 

  17. Middelkoop, A., Dijkstra, A., Swierstra, S.D.: Iterative type inference with attribute grammars. In International Conference on Generative Programming, pp. 43–52. ACM (2010)

    Google Scholar 

  18. Norell, U., Gerdes, A.: Attribute grammars in Erlang. In: Workshop on Erlang, 2015, pp. 1–12. ACM (2015)

    Google Scholar 

  19. Saraiva, J.: Purely functional implementation of attribute grammars. PhD thesis, Utrecht University, The Netherlands, December 1999

    Google Scholar 

  20. Saraiva, J., Swierstra, S.D.: Generating spreadsheet-like tools from strong attribute grammars. In: Pfenning, F., Macko, M. (eds.) GPCE 2003. LNCS, vol. 2830, pp. 307–323. Springer, Heidelberg (2003)

    Chapter  Google Scholar 

  21. Sloane, A.M., Kats, L.C.L., Visser, E.: A pure object-oriented embedding of attribute grammars. Electron. Notes Theory Comput. Sci. 253(7), 205–219 (2010)

    Article  Google Scholar 

  22. Swierstra, D., Azero, P., Saraiva, J.: Designing and implementing combinator languages. In: Swierstra, S.D., Oliveira, J.N. (eds.) AFP 1998. LNCS, vol. 1608. Springer, Heidelberg (1999)

    Chapter  Google Scholar 

  23. Uustalu, T., Vene, V.: Comonadic functional attribute evaluation. In: Trends in Functional Programming, vol. 10, pp. 145–162. Intellect Books (2005)

    Google Scholar 

  24. Van Wyk, E., Bodin, D., Gao, J., Krishnan, L.: Silver: an extensible attribute grammar system. Electron. Notes Theory Comput. Sci. 203(2), 103–116 (2008)

    Article  MATH  Google Scholar 

  25. Viera, M., Swierstra, D., Swierstra, W.: First-class, attribute grammars fly: how to do aspect oriented programming in Haskell. In: International Conference on Functional Programming, pp. 245–256. ACM (2009)

    Google Scholar 

  26. Vogt, H., Swierstra, S.D., Kuiper, M.: Higher order attribute grammars. SIGPLAN Notices 24(7), 131–145 (1989)

    Article  MATH  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Pedro Martins .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2016 Springer International Publishing Switzerland

About this paper

Cite this paper

Fernandes, J.P., Martins, P., Pardo, A., Saraiva, J., Viera, M. (2016). Memoized Zipper-Based Attribute Grammars. In: Castor, F., Liu, Y. (eds) Programming Languages. SBLP 2016. Lecture Notes in Computer Science(), vol 9889. Springer, Cham. https://doi.org/10.1007/978-3-319-45279-1_4

Download citation

  • DOI: https://doi.org/10.1007/978-3-319-45279-1_4

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-319-45278-4

  • Online ISBN: 978-3-319-45279-1

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics