skip to main content
10.1145/1988783.1988788acmotherconferencesArticle/Chapter ViewAbstractPublication PagesldtaConference Proceedingsconference-collections
research-article

Stepwise evaluation of attribute grammars

Published:26 March 2011Publication History

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.

References

  1. B. Arbab. Compiling Circular Attribute Grammars into Prolog. IBM Journal on Research and Development, 30:294--309, May 1986. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. J. T. Boyland. Conditional Attribute Grammars. ACM Transactions on Programming Languages and Systems, 18(1):73--108, 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  4. A. Dijkstra, J. Fokker, and S. D. Swierstra. The Architecture of the Utrecht Haskell Compiler. In Haskell Symposium, pages 93--104, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. A. Dijkstra and S. D. Swierstra. Typing Haskell with an Attribute Grammar. In AFP '04, pages 1--72, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. 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 ScholarGoogle Scholar
  7. L. Erkök and J. Launchbury. Recursive Monadic Bindings. In ICFP '00, pages 174--185, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. S. Fischer, O. Kiselyov, and C. Shan. Purely Functional Lazy Non-deterministic Programming. In ICFP '09, pages 11--22, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. R. Hinze. Deriving Backtracking Monad Transformers. In ICFP '00, ICFP '00, pages 186--197, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. R. J. M. Hughes and S. D. Swierstra. Polish Parsers, Step by Step. In ICFP '03, pages 239--248, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. L. G. Jones. Efficient Evaluation of Circular Attribute Grammars. ACM Transactions on Programming Languages and Systems, 12(3):429--462, 1990. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. M. Jourdan and D. Parigot. Internals and Externals of the FNC-2 Attribute Grammar System. In AGAS '91, pages 485--504, 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. U. Kastens. Ordered Attributed Grammars. Acta Informatica, 13:229--256, 1980.Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. O. Kiselyov. Iteratee IO: safe, practical, declarative input processing. http://okmij.org/ftp/Streams.html, 2008.Google ScholarGoogle Scholar
  15. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  16. D. E. Knuth. Semantics of Context-Free Languages. Mathematical Systems Theory, 2(2):127--145, 1968.Google ScholarGoogle ScholarCross RefCross Ref
  17. E. Magnusson and G. Hedin. Circular Reference Attributed Grammars - their Evaluation and Applications. SCP '07, 68(1):21--37, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. C. D. Marlin. Coroutines: A Programming Methodology, a Language Design and an Implementation, volume 95 of LNCS. Springer, 1980. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. A. Middelkoop, A. Dijkstra, and S. D. Swierstra. Iterative Type Inference with Attribute Grammars. In GPCE '10, pages 43--52, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. 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 ScholarGoogle Scholar
  21. J. Paakki. PROFIT: A System Integrating Logic Programming and Attribute Grammars. In PLILP '91, pages 243--254, 1991.Google ScholarGoogle Scholar
  22. J. Saraiva and S. D. Swierstra. Purely Functional Implementation of Attribute Grammars. Technical report, Universiteit Utrecht, 1999.Google ScholarGoogle Scholar
  23. S. D. Swierstra. Combinator Parsing: A Short Tutorial. In Language Engineering and Rigorous Software Development, volume 5520, pages 252--300, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  25. H. Vogt, S. D. Swierstra, and M. F. Kuiper. Higher-Order Attribute Grammars. In PLDI '89, pages 131--145, 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. 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 ScholarGoogle Scholar

Index Terms

  1. Stepwise evaluation of attribute grammars

    Recommendations

    Comments

    Login options

    Check if you have access through your login credentials or your institution to get full access on this article.

    Sign in
    • Published in

      cover image ACM Other conferences
      LDTA '11: Proceedings of the Eleventh Workshop on Language Descriptions, Tools and Applications
      March 2011
      91 pages
      ISBN:9781450306652
      DOI:10.1145/1988783

      Copyright © 2011 ACM

      Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 26 March 2011

      Permissions

      Request permissions about this article.

      Request Permissions

      Check for updates

      Qualifiers

      • research-article
    • Article Metrics

      • Downloads (Last 12 months)1
      • Downloads (Last 6 weeks)0

      Other Metrics

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader