ABSTRACT
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.
- B. Arbab. Compiling Circular Attribute Grammars into Prolog. IBM Journal on Research and Development, 30:294--309, May 1986. Google ScholarDigital Library
- J. T. Boyland. Conditional Attribute Grammars. ACM Transactions on Programming Languages and Systems, 18(1):73--108, 1996. Google ScholarDigital Library
- M. Bravenboer, R. Vermaas, J. J. Vinju, and E. Visser. Generalized Type-Based Disambiguation of Meta Programs with Concrete Object Syntax. In GPCE '05, pages 157--172, 2005. Google ScholarDigital Library
- A. Dijkstra, J. Fokker, and S. D. Swierstra. The Architecture of the Utrecht Haskell Compiler. In Haskell Symposium, pages 93--104, 2009. Google ScholarDigital Library
- A. Dijkstra and S. D. Swierstra. Typing Haskell with an Attribute Grammar. In AFP '04, pages 1--72, 2004. Google ScholarDigital Library
- A. Dijkstra, G. van den Geest, B. Heeren, and S. D. Swierstra. Modelling Scoped Instances with Constraint Handling Rules. https://subversion.cs.uu.nl/repos/project.UHC.pub/trunk/pdf/20070406-2213-icfp07-chr-locinst.pdf, 2007.Google Scholar
- L. Erkök and J. Launchbury. Recursive Monadic Bindings. In ICFP '00, pages 174--185, 2000. Google ScholarDigital Library
- S. Fischer, O. Kiselyov, and C. Shan. Purely Functional Lazy Non-deterministic Programming. In ICFP '09, pages 11--22, 2009. Google ScholarDigital Library
- R. Hinze. Deriving Backtracking Monad Transformers. In ICFP '00, ICFP '00, pages 186--197, 2000. Google ScholarDigital Library
- R. J. M. Hughes and S. D. Swierstra. Polish Parsers, Step by Step. In ICFP '03, pages 239--248, 2003. Google ScholarDigital Library
- L. G. Jones. Efficient Evaluation of Circular Attribute Grammars. ACM Transactions on Programming Languages and Systems, 12(3):429--462, 1990. Google ScholarDigital Library
- M. Jourdan and D. Parigot. Internals and Externals of the FNC-2 Attribute Grammar System. In AGAS '91, pages 485--504, 1991. Google ScholarDigital Library
- U. Kastens. Ordered Attributed Grammars. Acta Informatica, 13:229--256, 1980.Google ScholarDigital Library
- O. Kiselyov. Iteratee IO: safe, practical, declarative input processing. http://okmij.org/ftp/Streams.html, 2008.Google Scholar
- O. Kiselyov, C. Shan, D. P. Friedman, and A. Sabry. Backtracking, Interleaving, and Terminating Monad Transformers (functional pearl). In ICFP '05, pages 192--203, 2005. Google ScholarDigital Library
- D. E. Knuth. Semantics of Context-Free Languages. Mathematical Systems Theory, 2(2):127--145, 1968.Google ScholarCross Ref
- E. Magnusson and G. Hedin. Circular Reference Attributed Grammars - their Evaluation and Applications. SCP '07, 68(1):21--37, 2007. Google ScholarDigital Library
- C. D. Marlin. Coroutines: A Programming Methodology, a Language Design and an Implementation, volume 95 of LNCS. Springer, 1980. Google ScholarDigital Library
- A. Middelkoop, A. Dijkstra, and S. D. Swierstra. Iterative Type Inference with Attribute Grammars. In GPCE '10, pages 43--52, 2010. Google ScholarDigital Library
- A. Middelkoop, A. Dijkstra, and S. D. Swierstra. Stepwise Evaluation of Attribute Grammars (extended version). http://people.cs.uu.nl/ariem/stepwise.pdf, 2010.Google Scholar
- J. Paakki. PROFIT: A System Integrating Logic Programming and Attribute Grammars. In PLILP '91, pages 243--254, 1991.Google Scholar
- J. Saraiva and S. D. Swierstra. Purely Functional Implementation of Attribute Grammars. Technical report, Universiteit Utrecht, 1999.Google Scholar
- S. D. Swierstra. Combinator Parsing: A Short Tutorial. In Language Engineering and Rigorous Software Development, volume 5520, pages 252--300, 2009. Google ScholarDigital Library
- M. van den Brand, J. Scheerder, J. J. Vinju, and E. Visser. Disambiguation Filters for Scannerless Generalized LR Parsers. In CC '02, pages 143--158, 2002. Google ScholarDigital Library
- H. Vogt, S. D. Swierstra, and M. F. Kuiper. Higher-Order Attribute Grammars. In PLDI '89, pages 131--145, 1989. Google ScholarDigital Library
- M. J. Walsteijn and M. F. Kuiper. Attribute Grammars in Prolog. http://www.cs.uu.nl/research/techreps/repo/CS-1986/1986-14.pdf, 1986.Google Scholar
Index Terms
- Stepwise evaluation of attribute grammars
Recommendations
Remote attribute grammars
Describing the static semantics of programming languages with attribute grammars is eased when the formalism allows direct dependencies to be induced between rules for nodes arbitrarily far away in the tree. Such direct non-local dependencies cannot be ...
The formal power of one-visit attribute grammars
An attribute grammar is one-visit if the attributes can be evaluated by walking through the derivation tree in such a way that each subtree is visited at most once. One-visit (1V) attribute grammars are compared with one-pass left-to-right (L) attribute ...
Comments