Attribute Grammars as Recursion Schemes over Cyclic Representations of Zippers

Evaluation of attributes w.r.t. an attribute grammar can be obtained by inductively computing a function expressing the dependencies of the synthesized attributes on inherited attributes. This higher-order functional approach to attribute grammars leads to a straightforward implementation using a higher-order lazy functional language like Haskell. The resulting evaluation functions are, however, not easily amenable to optimization rules. We present an alternative first-order functional interpretation of attribute grammars where the input tree is replaced with an extended cyclic tree each node of which is aware of its context viewed as an additional child tree. By the way, we demonstrate that these cyclic representations of zippers (trees with their context) are natural generalizations of doubly-linked lists to trees over an arbitrary signature.

[1]  Joseph A. Goguen,et al.  Initial Algebra Semantics and Continuous Algebras , 1977, J. ACM.

[2]  Bruno Courcelle,et al.  Attribute Grammars and Recursive Program Schemes I , 1982, Theoretical Computer Science.

[3]  Graham Hutton,et al.  Monadic parsing in Haskell , 1998, Journal of Functional Programming.

[4]  Richard S. Bird Using circular programs to eliminate multiple traversals of data , 2004, Acta Informatica.

[5]  Donald E. Knuth,et al.  Semantics of context-free languages , 1968, Mathematical systems theory.

[6]  Tarmo Uustalu,et al.  Comonadic functional attribute evaluation , 2005, Trends in Functional Programming.

[7]  Kevin Backhouse,et al.  A Functional Semantics of Attribute Grammars , 2002, TACAS.

[8]  Robert Giegerich,et al.  Attribute coupled grammars , 1984, SIGPLAN '84.

[9]  Didier Parigot,et al.  Structure-directed Genericity in Functional Programming and Attribute Grammars , 1997 .

[10]  João Saraiva,et al.  Designing and Implementing Combinator Languages , 1998, Advanced Functional Programming.

[11]  S. D. Swierstra,et al.  Using attribute grammars to derive efficient functional programs , 1986 .

[12]  Nils Klarlund,et al.  Graph types , 1993, POPL '93.

[13]  Brian H. Mayoh,et al.  Attribute Grammars and Mathematical Semantics , 1978, SIAM J. Comput..

[14]  Jukka Paakki,et al.  Attribute grammar paradigms—a high-level methodology in language implementation , 1995, CSUR.

[15]  Bernard Fotsing,et al.  Yet Another Implementation of Attribute Evaluation , 2007 .

[16]  Gérard P. Huet,et al.  The Zipper , 1997, Journal of Functional Programming.

[17]  Johan Jeuring,et al.  A translation from attribute grammars to catamorphisms , 1991 .

[18]  David F. Martin,et al.  An order-algebraic definition of knuthian semantics , 1979, Mathematical systems theory.

[19]  A. Augusteijn,et al.  Functional programming, program transformations and compiler construction , 1993 .

[20]  Thomas Johnsson,et al.  Attribute grammars as a functional programming paradigm , 1987, FPCA.

[21]  Patricia Johann,et al.  Initial Algebra Semantics Is Enough! , 2007, TLCA.

[22]  Didier Parigot,et al.  Declarative Program Transformation: A Deforestation Case-Study , 1999, PPDP.

[23]  Éric Badouel,et al.  Growing a Domain Specific Language with Split Extensions , 2007 .