Skip to main content

The Kennedy-Warren Algorithm Revisited: Ordering Attribute Grammars

  • Conference paper

Part of the Lecture Notes in Computer Science book series (LNPSE,volume 7149)

Abstract

Attribute Grammars (AGs) are a powerful tool for defining an executable semantics of a programming language, and thus for implementing a compiler. An execution plan for an AG determines a static evaluation order for the attributes which are defined as part of an AG specification. In building the Utrecht Haskell Compiler (UHC), a large scale AG project, we discovered that the Ordered AG approach (Kastens, 1980) for building such plans becomes impractical: the additional dependencies between attributes introduced by this algorithm too often result in grammars for which no execution plan can be generated.

To avoid such problems we have implemented a refined version of the algorithm of Kennedy and Warren (1976) as part of our purely functional AG system and show how this algorithm solves the problems that surface with the Ordered AG approach. Furthermore, we present the results of applying this algorithm to the UHC code and show that this approach in some cases also has a positive effect on the runtime of the resulting program.

Keywords

  • Attribute Grammars
  • Haskell
  • Dependency graph
  • Ordered

This is a preview of subscription content, access via your institution.

Buying options

Chapter
USD   29.95
Price excludes VAT (Canada)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   39.99
Price excludes VAT (Canada)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD   54.99
Price excludes VAT (Canada)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  • Dijkstra, A., Fokker, J., Swierstra, S.D.: The architecture of the Utrecht Haskell compiler. In: Proceedings of the 2nd ACM SIGPLAN Symposium on Haskell, Haskell 2009, pp. 93–104. ACM, New York (2009)

    Google Scholar 

  • Kastens, U.: Ordered attributed grammars. Acta Informatica 13, 229–256 (1980), doi:10.1007/BF00288644

    CrossRef  MathSciNet  MATH  Google Scholar 

  • Kennedy, K., Warren, S.K.: Automatic generation of efficient evaluators for attribute grammars. In: Proceedings of the 3rd ACM SIGACT-SIGPLAN Symposium on Principles on Programming Languages, POPL 1976, pp. 32–49. ACM, New York (1976)

    Google Scholar 

  • Knuth, D.E.: Semantics of context-free languages. Theory of Computing Systems 2(2), 127–145 (1968)

    MathSciNet  MATH  Google Scholar 

  • Knuth, D.E.: Semantics of context-free languages: Correction. Theory of Computing Systems 5, 95–96 (1971), doi:10.1007/BF01702865

    MathSciNet  MATH  Google Scholar 

  • Middelkoop, A.: Inference with Attribute Grammars. PhD thesis, Utrecht University (2011)

    Google Scholar 

  • Reps, T., Teitelbaum, T.: The synthesizer generator. SIGPLAN Not. 19, 42–48 (1984)

    CrossRef  MATH  Google Scholar 

  • Saraiva, J.: Purely Functional Implementation of Attribute Grammars. PhD thesis, Utrecht University (1999)

    Google Scholar 

  • Swierstra, S.D., Baars, A.: Attribute Grammar System (2005), http://www.cs.uu.nl/wiki/HUT/AttributeGrammarSystem

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and Permissions

Copyright information

© 2012 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Bransen, J., Middelkoop, A., Dijkstra, A., Swierstra, S.D. (2012). The Kennedy-Warren Algorithm Revisited: Ordering Attribute Grammars. In: Russo, C., Zhou, NF. (eds) Practical Aspects of Declarative Languages. PADL 2012. Lecture Notes in Computer Science, vol 7149. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-27694-1_14

Download citation

  • DOI: https://doi.org/10.1007/978-3-642-27694-1_14

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-642-27693-4

  • Online ISBN: 978-3-642-27694-1

  • eBook Packages: Computer ScienceComputer Science (R0)