Abstract
Oliveira and Cook (2012) and Oliveira et al. (2013) have recently introduced object algebras as a program structuring technique to improve the modularity and extensibility of programs. We analyze the relationship between object algebras and attribute grammars (AGs), a formalism to augment context-free grammars with attributes. We present an extension of the object algebra technique with which the full class of L-attributed grammars - an important class of AGs that corresponds to one-pass compilers - can be encoded in Scala. The encoding is modular (attributes can be defined and type-checked separately), scalable (the size of the encoding is linear in the size of the AG specification) and compositional (each AG artifact is represented as a semantic object of the host language). To evaluate these claims, we have formalized the encoding and re-implemented a one-pass compiler for a subset of C with our technique. We also discuss how advanced features of modern AG systems, such as higher-order and parameterized attributes, reference attributes, and forwarding can be supported.
- G. V. Bochmann. Semantic evaluation from left to right. Communications of the ACM, 19(2):55--62, 1976. Google Scholar
Digital Library
- P. Buchlovsky and H. Thielecke. A type-theoretic reconstruction of the visitor pattern. In Proceedings of the Conference on Mathematical Foundations of Programming Semantics, pages 309--329. Elsevier ENTCS 155, 2006. Google Scholar
Digital Library
- J. Carette, O. Kiselyov, and C. Shan. Finally tagless, partially evaluated. In Proceedings of the Asian Symposium on Programming Languages and Systems, pages 222--238. Springer LNCS 4807, 2007. Google Scholar
Digital Library
- J. Carette, O. Kiselyov, and C. Shan. Finally tagless, partially evaluated: Tagless staged interpreters for simpler typed languages. Journal of Functional Programming, 19(5):509--543, Sept. 2009. Google Scholar
Digital Library
- L. M. Chirica and D. F. Martin. An order-algebraic definition of Knuthian semantics. Mathematical Systems Theory, 13:1--27, 1979.Google Scholar
Cross Ref
- O. De Moor, K. Backhouse, and S. D. Swierstra. First-class attribute grammars. Informatica, 24, 2000.Google Scholar
- P. Deransart, M. Jourdan, and B. Lorho. Attribute Grammars: Definitions, Systems, and Bibliography. Springer LNCS 323, 1988. Google Scholar
Digital Library
- É. Duris, D. Parigot, G. Roussel, and M. Jourdan. Attribute grammars and folds: Generic control operators. Rapport de recherche RR-2957, INRIA, 1996.Google Scholar
- J. Gibbons. Design patterns as higher-order datatype-generic programs. In Proceedings of the Workshop on Generic Programming, pages 1--12. ACM, 2006. Google Scholar
Digital Library
- G. Hedin. Reference attributed grammars. Informatica (Slovenia), 24(3):301--317, 2000.Google Scholar
- G. Hedin. An introductory tutorial on JastAdd attribute grammars. In Proceedings of the Summer School Conference on Generative and Transformational Techniques in Software Engineering, pages 166--200. Springer LNCS 6491, 2011. Google Scholar
Digital Library
- R. Hinze. Generics for the masses. In Proceedings of the International Conference on Functional Programming, pages 236--243. ACM, 2004. Google Scholar
Digital Library
- R. Hinze. Generics for the masses. Journal of Functional Programming, 16(4-5):451--483, July 2006. Google Scholar
Digital Library
- C. Hofer, K. Ostermann, T. Rendel, and A. Moors. Polymorphic embedding of DSLs. In Proceedings of the Conference on Generative Programming and Component Engineering. ACM, 2008. Google Scholar
Digital Library
- T. Johnsson. Attribute grammars as a functional programming paradigm. In Proceedings of the Conference on Functional Programming Languages and Computer Architecture, pages 154--173, 1987. Google Scholar
Digital Library
- P. M. Lewis, D. J. Rosenkrantz, and R. E. Stearns. Attributed translations. Journal of Computer and System Sciences, 9(3):279--307, Dec. 1974. Google Scholar
Digital Library
- E. Magnusson and G. Hedin. Circular reference attributed grammars: Their evaluation and applications. Science of Computer Programming, 68(1):21--37, Aug. 2007. Google Scholar
Digital Library
- A. Middelkoop, A. Dijkstra, and S. D. Swierstra. Visitor-based attribute grammars with side effect. In Proceedings of the Workshop on Generative Technologies, pages 47--69. Elsevier ENTCS 264(5), 2011. Google Scholar
Digital Library
- M. Odersky and M. Zenger. Independently extensible solutions to the expression problem. In Proceedings of the Workshop on Foundations of Object-Oriented Languages, 2005.Google Scholar
- B. C. Oliveira, M. Wang, and J. Gibbons. The visitor pattern as a reusable, generic, type-safe component. In Proceedings of the Conference on Object-Oriented Programming, Systems, Languages and Applications, pages 439--456. ACM, 2008. Google Scholar
Digital Library
- B. C. d. S. Oliveira and W. R. Cook. Extensibility for the masses: Practical extensibility with object algebras. In Proceedings of the European Conference on Object-Oriented Programming, pages 2--27. Springer LNCS 7313, 2012. Google Scholar
Digital Library
- B. C. d. S. Oliveira and J. Gibbons. Typecase: A design pattern for type-indexed functions. In Proceedings of the Haskell Workshop. ACM, 2005. ISBN 1-59593-071-X. Google Scholar
Digital Library
- B. C. d. S. Oliveira, T. van der Storm, A. Loh, and W. R. Cook. Feature-oriented programming with object algebras. In Proceedings of the European Conference on Object-Oriented Programming. Springer LNCS 7920, 2013. Google Scholar
Digital Library
- J. Paakki. Attribute grammar paradigms: A high-level methodology in language implementation. ACM Computing Surveys, 27(2):196--255, June 1995. Google Scholar
Digital Library
- A. M. Sloane, L. C. Kats, and E. Visser. A pure embedding of attribute grammars. Science of Computer Programming, 78(10):1752--1769, 2013. Google Scholar
Digital Library
- S. D. Swierstra, P. R. Azero Alcocer, and J. Saraiva. Designing and implementing combinator languages. In Advanced Functional Programming, pages 150--206, 1998.Google Scholar
- E. Van Wyk, O. De Moor, K. Backhouse, and P. Kwiatkowski. Forwarding in attribute grammars for modular language design. In Proceedings of the Conference on Compiler Construction, pages 128--142. Springer LNCS 2304, 2002. Google Scholar
Digital Library
- E. Van Wyk, L. Krishnan, A. Schwerdfeger, and D. Bodin. Attribute grammar-based language extensions for Java. In Proceedings of the European Conference on Object-Oriented Programming. Springer LNCS 4609, 2007. Google Scholar
Digital Library
- M. Viera, S. D. Swierstra, andW. Swierstra. Attribute grammars fly first-class: How to do aspect oriented programming in Haskell. In Proceedings of the International Conference on Functional Programming, pages 245--256. ACM, 2009. Google Scholar
Digital Library
- H. H. Vogt, S. D. Swierstra, and M. F. Kuiper. Higher order attribute grammars. In Proceedings of the Conference on Programming Language Design and Implementation, pages 131--145. ACM, 1989. Google Scholar
Digital Library
- P. Wadler. The expression problem. Note to Java Genericity mailing list, Nov. 1998.Google Scholar
Index Terms
From object algebras to attribute grammars
Recommendations
From object algebras to attribute grammars
OOPSLA '14: Proceedings of the 2014 ACM International Conference on Object Oriented Programming Systems Languages & ApplicationsOliveira and Cook (2012) and Oliveira et al. (2013) have recently introduced object algebras as a program structuring technique to improve the modularity and extensibility of programs. We analyze the relationship between object algebras and attribute ...
The Interpretation of Meta Grammars Describing Syntax-Directed Interpreters Using an Attribute Grammar Interpreter
A syntax-directed interpreter of attribute grammars is applied to interpret meta grammars describing translators. A specific example is used which concerns the formal description of the same syntax-directed interpreter of attribute grammars for ...
A Classification of Noncircular Attribute Grammars Based on the Look-Ahead Behavior
We propose a family of static evaluators for subclasses of the well-defined (i.e., noncircular) attribute grammars. These evaluators augment the evaluator for the absolutely noncircular attribute grammars with look-ahead behaviors. Because this family ...







Comments