ABSTRACT
A Domain-Specific Embedded Language (DSEL) is a miniature language-within-a-language for solving problems in a particular domain. One technique for creating efficient and expressive DSELs in C++ is to use expression templates, but this technique is not for the faint of heart. Such libraries are difficult to write and maintain due to the esoteric nature of template meta-programming, and difficult to use because of the often impenetrable compiler error messages they generate. Existing tools help somewhat, but do not provide the support that language designers have come to expect: something like BNF for defining the language's grammar and associated semantic actions. This paper describes Proto, a C++ library that implements a compiler construction toolkit for embedded languages. The benefits of grammar-based DSELs are shown by contrasting them to other existing approaches to DSEL design. The nature of embedded languages with constrained grammars and their implications for a embedded compiler construction toolkit is briefly explored. Some examples are shown where library interfaces can be made more expressive through the use of grammar-based DSELs.
- L. A. N. L. Advanced Computing Laboratory. PETE. http://acts.nersc.gov/pete/.Google Scholar
- L. A. N. L. Advanced Computing Laboratory. POOMA. http://www.nongnu.org/freepooma/.Google Scholar
- J. de Guzman and H. Kaiser. The Spirit Parser Framework. http://spirit.sourceforge.net.Google Scholar
- J. de Guzman, D. Marsden, and T. Schwinger. Boost. Fusion. http://spirit.sourceforge.net/dl_more/fusion_v2/libs/fusion/doc/html/index.html.Google Scholar
- P. Dimov. Proposed Text for Parallel Task Execution. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2185.html.Google Scholar
- P. Dimov. Transporting Values and Exceptions between Threads. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2096.html.Google Scholar
- P. Dimov, D. Gregor, J. Järvi, and G. Powell. A Proposal to Add an Enhanced Binder to the Library Technical Report. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1438.htm.Google Scholar
- H. Hinnant. future groups. [email protected], July 2007. c++std-lib-19057.Google Scholar
- J. Järvi and G. Powell. The Boost Lambda Library. http://boost.org/doc/html/lambda.html.Google Scholar
- J. Järvi, B. Stroustrup, and G. Dos Reis. Decltype (revision 7): proposed wording. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2343.pdf.Google Scholar
- J. Järvi, J. Willcock, and A. Lumsdaine. Boost. Enable_if. http://boost.org/libs/utility/enable_if.html.Google Scholar
- S. C. Johnson. Yacc: Yet another compiler compiler. In UNIX Programmer's Manual, volume 2, pages 353--387. Holt, Rinehart, and Winston, New York, NY, USA, 1979.Google Scholar
- H. Kaiser and T. Schütt. futures based on boost. threads, 2005. http://boost-consulting.com/vault/index.php? action=downloadfile&filename=futures.zip&directory=Concurrent%20Programming.Google Scholar
- E. Niebler. Boost. Xpressive. http://boost.org/doc/html/xpressive.html.Google Scholar
- H. Sutter. Thread API interface tweaks. [email protected], August 2006.Google Scholar
- T. Veldhuizen. Blitz++: Object Oriented Scientific Computing. http://www.oonumerics.org/blitz/.Google Scholar
- T. Veldhuizen. Blitz++: The Library That Thinks It Is A Compiler. In SciTools, 1998. http://www.oonumerics.org/blitz/blitztalk.ps.Google Scholar
- T. L. Veldhuizen. Expression templates. C++ Report, 7(5):26--31, June 1995. Reprinted in C++ Gems, ed. Stanley Lippman.Google ScholarDigital Library
- A. Vertleyb and P. Holt. Boost.Typeof. http://boost.org/doc/html/typeof.html.Google Scholar
- M. Werle. Daixtrose, Differentiable Expression Templates. http://daixtrose.sourceforge.net/index.html.Google Scholar
- A. Williams. Thread Pools and Futures. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2276.html.Google Scholar
Recommendations
Layout-sensitive language extensibility with SugarHaskell
Haskell '12: Proceedings of the 2012 Haskell SymposiumProgrammers need convenient syntax to write elegant and concise programs. Consequently, the Haskell standard provides syntactic sugar for some scenarios (e.g., do notation for monadic code), authors of Haskell compilers provide syntactic sugar for more ...
Layout-sensitive language extensibility with SugarHaskell
Haskell '12Programmers need convenient syntax to write elegant and concise programs. Consequently, the Haskell standard provides syntactic sugar for some scenarios (e.g., do notation for monadic code), authors of Haskell compilers provide syntactic sugar for more ...
Languages as libraries
PLDI '11Programming language design benefits from constructs for extending the syntax and semantics of a host language. While C's string-based macros empower programmers to introduce notational shorthands, the parser-level macros of Lisp encourage ...
Comments