Skip to main content

Respect Your Parents: How Attribution and Rewriting Can Get Along

  • Conference paper
Software Language Engineering (SLE 2014)

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

Included in the following conference series:

Abstract

Attribute grammars describe how to decorate static trees. Rewriting systems describe how to transform trees into new trees. Attribution is undermined by rewriting because a node may appear in both the source and product of a transformation. If an attribute of that node depends on the node’s context, then a previously computed value may not be valid. We explore this problem and formalise it as a question of ancestry: the context of a node is given by the tree’s parent relationships and we must use the appropriate parents to calculate attributes that depend on the context. We show how respecting parents naturally leads to a view of context-dependent attributes as tree-indexed attribute families. Viewed in this way, attribution co-exists easily with rewriting transformations. We demonstrate the practicality of our approach by describing our implementation in the Kiama language processing library.

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 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

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. van den Brand, M.G.J., Klint, P.: ATerms for manipulation and exchange of structured data: It’s all about sharing. Information and Software Technology 49(1), 55–64 (2007)

    Article  Google Scholar 

  2. Sloane, A.M.: Lightweight language processing in kiama. In: Fernandes, J.M., Lämmel, R., Visser, J., Saraiva, J. (eds.) Generative and Transformational Techniques in Software Engineering III. LNCS, vol. 6491, pp. 408–425. Springer, Heidelberg (2011)

    Chapter  Google Scholar 

  3. Sloane, A.M., Kats, L.C.L., Visser, E.: A pure embedding of attribute grammars. Science of Computer Programming 78, 1752–1769 (2013)

    Article  Google Scholar 

  4. Hedin, G., Magnusson, E.: JastAdd: an aspect-oriented compiler construction system. Science of Computer Programming 47(1), 37–58 (2003)

    Article  MATH  MathSciNet  Google Scholar 

  5. Van Wyk, E., Bodin, D., Gao, J., Krishnan, L.: Silver: An extensible attribute grammar system. Science of Computer Programming 75, 39–54 (2010)

    Article  MATH  MathSciNet  Google Scholar 

  6. Bravenboer, M., Kalleberg, K.T., Vermaas, R., Visser, E.: Stratego/XT 0.16: components for transformation systems. In: Proceedings of the 2006 ACM SIGPLAN Symposium on Partial Evaluation and Semantics-Based Program Manipulation, pp. 95–99. ACM (2006)

    Google Scholar 

  7. Odersky, M., Spoon, L., Venners, B.: Programming in Scala, 2nd edn. Artima Press (2010)

    Google Scholar 

  8. Emir, B., Odersky, M., Williams, J.: Matching objects with patterns. In: Ernst, E. (ed.) ECOOP 2007. LNCS, vol. 4609, pp. 273–298. Springer, Heidelberg (2007)

    Chapter  Google Scholar 

  9. Reps, T.W.: Generating Language-based Environments. Massachusetts Institute of Technology, Cambridge (1984)

    MATH  Google Scholar 

  10. Saraiva, J., Swierstra, S.D., Kuiper, M.: Functional incremental attribute evaluation. In: Watt, D.A. (ed.) CC 2000. LNCS, vol. 1781, pp. 279–294. Springer, Heidelberg (2000)

    Chapter  Google Scholar 

  11. Bransen, J., Dijkstra, A., Swierstra, S.D.: Lazy stateless incremental evaluation machinery for attribute grammars. In: Proceedings of the Workshop on Partial Evaluation and Program Manipulation, pp. 145–156. ACM (2014)

    Google Scholar 

  12. Bürger, C.: RACR: A Scheme Library for Reference Attribute Grammar Controlled Rewriting. Dresden University of Technology (2014), http://racr.googlecode.com

  13. Magnusson, E., Hedin, G.: Circular reference attributed grammars–their evaluation and applications. Science of Computer Programming 68(1), 21–37 (2007)

    Article  MATH  MathSciNet  Google Scholar 

  14. Ekman, T., Hedin, G.: Rewritable reference attributed grammars. In: Odersky, M. (ed.) ECOOP 2004. LNCS, vol. 3086, pp. 147–171. Springer, Heidelberg (2004)

    Chapter  Google Scholar 

  15. Van Wyk, E., de Moor, O., Backhouse, K., Kwiatkowski, P.: Forwarding in attribute grammars for modular language design. In: Nigel Horspool, R. (ed.) CC 2002. LNCS, vol. 2304, pp. 128–142. Springer, Heidelberg (2002)

    Chapter  Google Scholar 

  16. Johnsson, T.: Attribute grammars as a functional programming paradigm. In: Kahn, G. (ed.) FPCA 1987. LNCS, vol. 274, pp. 154–173. Springer, Heidelberg (1987)

    Chapter  Google Scholar 

  17. Adams, M.D.: Scrap your zippers: a generic zipper for heterogeneous types. In: Proceedings of the ACM SIGPLAN Workshop on Generic Programming, pp. 13–24. ACM (2010)

    Google Scholar 

  18. 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 

  19. Gaillourdet, J.-M., Michel, P., Poetzsch-Heffter, A., Rauch, N.: A generic functional representation of sorted trees supporting attribution. In: Voronkov, A., Weidenbach, C. (eds.) Programming Logics. LNCS, vol. 7797, pp. 72–89. Springer, Heidelberg (2013), http://dx.doi.org/10.1007/978-3-642-37651-1_4

    Chapter  Google Scholar 

  20. Kats, L., Sloane, A.M., Visser, E.: Decorated attribute grammars: Attribute evaluation meets strategic programming. In: de Moor, O., Schwartzbach, M.I. (eds.) CC 2009. LNCS, vol. 5501, pp. 142–157. Springer, Heidelberg (2009)

    Chapter  Google Scholar 

  21. Linton, M.A.: Implementing relational views of programs. In: Proceedings of the Symposium on Practical Software Development Environments, pp. 132–140. ACM (1984)

    Google Scholar 

  22. Klint, P., van der Storm, T., Vinju, J.: EASY meta-programming with rascal. In: Fernandes, J.M., Lämmel, R., Visser, J., Saraiva, J. (eds.) Generative and Transformational Techniques in Software Engineering III. LNCS, vol. 6491, pp. 222–289. Springer, Heidelberg (2011)

    Chapter  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2014 Springer International Publishing Switzerland

About this paper

Cite this paper

Sloane, A.M., Roberts, M., Hamey, L.G.C. (2014). Respect Your Parents: How Attribution and Rewriting Can Get Along. In: Combemale, B., Pearce, D.J., Barais, O., Vinju, J.J. (eds) Software Language Engineering. SLE 2014. Lecture Notes in Computer Science, vol 8706. Springer, Cham. https://doi.org/10.1007/978-3-319-11245-9_11

Download citation

  • DOI: https://doi.org/10.1007/978-3-319-11245-9_11

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-319-11244-2

  • Online ISBN: 978-3-319-11245-9

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics