Abstract
Attribute grammars are a suitable formalism to express complex software language analysis and manipulation algorithms, which rely on multiple traversals of the underlying syntax tree. Recently, Attribute Grammars have been extended with mechanisms such as references and high-order and circular attributes. Such extensions provide a powerful modular mechanism and allow the specification of complex fix-point computations. This paper defines an elegant and simple, zipper-based embedding of attribute grammars and their extensions as first class citizens. In this setting, language specifications are defined as a set of independent, off-the-shelf components that can easily be composed into a powerful, executable language processor. Several real examples of language specification and processing programs have been implemented in this setting.
This work is funded by ERDF - European Regional Development Fund through the COMPETE Programme (operational programme for competitiveness) and by National Funds through the FCT - Fundação para a Ciência e a Tecnologia (Portuguese Foundation for Science and Technology) within projects FCOMP-01-0124-FEDER-020532 and FCOMP-01-0124-FEDER-022701.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
Knuth, D.: Semantics of Context-free Languages. Mathematical Systems Theory 2(2) (June 1968); Correction: Mathematical Systems Theory 5(1) (March 1971)
Dijkstra, A., Fokker, J., Swierstra, S.D.: The architecture of the utrecht haskell compiler. In: Weirich, S. (ed.) Haskell, pp. 93–104. ACM (2009)
Swierstra, D., Azero, P., Saraiva, J.: Designing and Implementing Combinator Languages. In: Swierstra, S.D., Oliveira, J.N. (eds.) AFP 1998. LNCS, vol. 1608, pp. 150–206. Springer, Heidelberg (1999)
Fernandes, J.P., Saraiva, J.: Tools and Libraries to Model and Manipulate Circular Programs. In: Proceedings of the ACM SIGPLAN 2007 Symposium on Partial Evaluation and Program Manipulation, PEPM 2007, pp. 102–111. ACM Press (2007)
Middelkoop, A., Dijkstra, A., Swierstra, S.D.: Iterative type inference with attribute grammars. In: Visser, E., Järvi, J. (eds.) GPCE, pp. 43–52. ACM (2010)
Vogt, H.H., Swierstra, S.D., Kuiper, M.F.: Higher order attribute grammars. SIGPLAN Not. 24(7), 131–145 (1989)
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)
Magnusson, E., Hedin, G.: Circular reference attributed grammars - their evaluation and applications. Sci. Comput. Program. 68(1), 21–37 (2007)
Van Wyk, E., Bodin, D., Gao, J., Krishnan, L.: Silver: an extensible attribute grammar system. Electron. Notes Theor. Comput. Sci. 203(2), 103–116 (2008)
Ekman, T., Hedin, G.: The jastadd extensible java compiler. SIGPLAN Not. 42(10), 1–18 (2007)
Sloane, A.M., Kats, L.C.L., Visser, E.: A pure object-oriented embedding of attribute grammars. Electron. Notes Theor. Comput. Sci. 253(7), 205–219 (2010)
Huet, G.: The zipper. Journal of Functional Programming 7(5), 549–554 (1997)
Paakki, J.: Attribute grammar paradigms a high-level methodology in language implementation. ACM Comput. Surv. 27(2), 196–255 (1995)
Adams, M.D.: Scrap your zippers: a generic zipper for heterogeneous types. In: Proceedings of the 6th ACM SIGPLAN Workshop on Generic Programming, WGP 2010, pp. 13–24. ACM, New York (2010)
Lämmel, R., Jones, S.P.: Scrap your boilerplate: a practical design pattern for generic programming. In: Procs. of the 2003 ACM SIGPLAN Inter. WorkShop on Types in Language Design and Implementation, TLDI 2003, pp. 26–37. ACM (2003)
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)
Magnusson, E., Hedin, G.: Circular reference attributed grammars - their evaluation and applications. Sci. Comput. Program. 68(1), 21–37 (2007)
Bird, R.: Using circular programs to eliminate multiple traversals of data. Acta Informatica 21, 239–250 (1984)
Martins, P., Fernandes, J.P., Saraiva, J.: A purely functional combinator language for software quality assessment. In: Symposium on Languages, Applications and Technologies, SLATE 2012. OASICS, vol. 21, pp. 51–69. Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik (2012)
Martins, P., Fernandes, J.P., Saraiva, J.: A web portal for the certification of open source software. In: 6th International Workshop on Foundations and Techniques for Open Source Software Certification, OPENCERT 2012. LNCS (2012) (to appear)
Martins, P., Carvalho, N., Fernandes, J.P., Almeida, J.J., Saraiva, J.: A framework for modular and customizable software analysis. In: Murgante, B., Misra, S., Carlini, M., Torre, C.M., Nguyen, H.-Q., Taniar, D., Apduhan, B.O., Gervasi, O. (eds.) ICCSA 2013, Part II. LNCS, vol. 7972, pp. 443–458. Springer, Heidelberg (2013)
Uustalu, T., Vene, V.: Comonadic functional attribute evaluation. In: Trends in Functional Programming, vol. (10), pp. 145–162. Intellect Books (2005)
Badouel, E., Fotsing, B., Tchougong, R.: Yet another implementation of attribute evaluation. Research Report RR-6315, INRIA (2007)
Badouel, E., Fotsing, B., Tchougong, R.: Attribute grammars as recursion schemes over cyclic representations of zippers. Electronic Notes Theory Computer Science 229(5), 39–56 (2011)
Yakushev, A.R., Holdermans, S., Löh, A., Jeuring, J.: Generic programming with fixed points for mutually recursive datatypes. In: Procs. of the 14th ACM SIGPLAN International Conference on Functional Programming, pp. 233–244 (2009)
Johnsson, T.: Attribute grammars as a functional programming paradigm. In: Kahn, G. (ed.) Functional Programming Languages and Computer Architecture. LNCS, vol. 274, pp. 154–173. Springer, Heidelberg (1987)
Kuiper, M., Swierstra, D.: Using attribute grammars to derive efficient functional programs. In: Computing Science in the Netherlands (November 1987)
de Moor, O., Backhouse, K., Swierstra, S.D.: First-class attribute grammars. Informatica (Slovenia) 24(3) (2000)
Viera, M., Swierstra, D., Swierstra, W.: Attribute Grammars Fly First-class: how to do Aspect Oriented Programming in Haskell. In: Procs. of the 14th ACM SIGPLAN Int. Conf. on Functional Programming, ICFP 2009, pp. 245–256 (2009)
Viera, M.: First Class Syntax, Semantics, and Their Composition. PhD thesis, Utrecht University, The Netherlands (2013)
Siek, J.: General purpose languages should be metalanguages. In: Procs. of ACM SIGPLAN Workshop on Partial Evaluation and Program Manipulation, pp. 3–4 (2010)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2013 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Martins, P., Fernandes, J.P., Saraiva, J. (2013). Zipper-Based Attribute Grammars and Their Extensions. In: Du Bois, A.R., Trinder, P. (eds) Programming Languages. SBLP 2013. Lecture Notes in Computer Science, vol 8129. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-40922-6_10
Download citation
DOI: https://doi.org/10.1007/978-3-642-40922-6_10
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-642-40921-9
Online ISBN: 978-3-642-40922-6
eBook Packages: Computer ScienceComputer Science (R0)