Stepwise evaluation of attribute grammars

Attribute Grammars are a powerful formalism to specify and implement the semantics of programming languages (e.g. as in a compiler), in particular when the semantics are syntax directed. Advanced type systems, however, use nondeterminism in their specifications to encode decisions that are independent of syntax. The implementation of such decisions is hard to express algorithmically using conventional attribute evaluation. This paper presents Stepwise Attribute Grammars (SAGs). In a SAG, nondeterministic choices can be expressed in a natural way in conjunction with unambiguous resolution strategies based on attribute values. SAGs preserve the functional relationships between attributes and support on-demand evaluation. Nondeterminism is encoded as a choice between the semantic results of children. Evaluation of a child can be performed in a stepwise fashion: it is paused after each step and yields a progress report with intermediate results, until the child is reduced to its semantic value. This facilitates a breadth-first exploration of choices, until choices can be resolved based on the progress reports.

[1]  S. Doaitse Swierstra,et al.  Iterative type inference with attribute grammars , 2010, GPCE '10.

[2]  John Tang Boyland,et al.  Conditional attribute grammars , 1996, TOPL.

[3]  M. J. Walsteijn,et al.  Attribute grammars in Prolog , 1986 .

[4]  Didier Parigot,et al.  Internals and Externals of the FNC-2 Attribute Grammar System , 1991, Attribute Grammars, Applications and Systems.

[5]  Bijan Arbab Compiling Circular Attribute Grammars Into Prolog , 1986, IBM J. Res. Dev..

[6]  Eelco Visser,et al.  Generalized type-based disambiguation of meta programs with concrete object syntax , 2005, GPCE'05.

[7]  S. Doaitse Swierstra,et al.  Higher order attribute grammars , 1989, PLDI '89.

[8]  Görel Hedin,et al.  Circular reference attributed grammars - their evaluation and applications , 2003, Sci. Comput. Program..

[9]  S. Doaitse Swierstra,et al.  Polish parsers, step by step , 2003, ACM SIGPLAN Notices.

[10]  Eelco Visser,et al.  Disambiguation Filters for Scannerless Generalized LR Parsers , 2002, CC.

[11]  Larry G. Jones,et al.  Efficient evaluation of circular attribute grammars , 1990, TOPL.

[12]  Sebastian Fischer,et al.  Purely functional lazy non-deterministic programming , 2009, Journal of Functional Programming.

[13]  Jukka Paakki,et al.  PROFIT: A System Integrating Logic Programming and Attribute Grammars , 1991, PLILP.

[14]  Ralf Hinze,et al.  Deriving backtracking monad transformers , 2000, ICFP '00.

[15]  S. Doaitse Swierstra,et al.  The architecture of the Utrecht Haskell compiler , 2009, Haskell.

[16]  Joao Paulo Saraiva,et al.  Purely Functional Implementation of Attribute Grammars , 1999 .

[17]  Amr Sabry,et al.  Backtracking, interleaving, and terminating monad transformers: (functional pearl) , 2005, ICFP '05.

[18]  S. Doaitse Swierstra,et al.  Combinator Parsing: A Short Tutorial , 2009, LerNet ALFA Summer School.

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

[20]  S. Doaitse Swierstra,et al.  Typing Haskell with an Attribute Grammar , 2004, Advanced Functional Programming.

[21]  Uwe Kastens,et al.  Ordered attributed grammars , 1980, Acta Informatica.

[22]  Chris D. Marlin Coroutines: A Programming Methodology, a Language Design and an Implementation , 1980, Lecture Notes in Computer Science.

[23]  John Launchbury,et al.  Recursive monadic bindings , 2000, ICFP '00.