[go: up one dir, main page]
More Web Proxy on the site http://driver.im/ skip to main content
10.1145/1868294.1868315acmconferencesArticle/Chapter ViewAbstractPublication PagesgpceConference Proceedingsconference-collections
research-article

Domain-specific language integration with compile-time parser generator library

Published: 10 October 2010 Publication History

Abstract

Smooth integration of domain-specific languages into a general purpose host language requires absorbing of domain code written in arbitrary syntax. The integration should cause minimal syntactical and semantic overhead and introduce minimal dependency on external tools. In this paper we discuss a DSL integration technique for the C++ programming language. The solution is based on compile-time parsing of the DSL code. The parser generator is a C++ template metaprogram reimplementation of a runtime Haskell parser generator library. The full parsing phase is executed when the host program is compiled. The library uses only standard C++ language features, thus our solution is highly portable. As a demonstration of the power of this approach, we present a highly efficient and type-safe version of printf and the way it can be constructed using our library. Despite the well known syntactical difficulties of C++ template metaprograms, building embedded languages using our library leads to self-documenting C++ source code.

References

[1]
}}D. Abrahams, A. Gurtovoy, C++ template metaprogramming, Concepts, Tools, and Techniques from Boost and Beyond, Addison-Wesley, Boston, 2004.
[2]
}}A. Alexandrescu, Modern C++ Design: Generic Programming and Design Patterns Applied, Addison-Wesley, 2001.
[3]
}}ANSI/ISO C++ Committee, Programming Languages -- C++, ISO/IEC 14882:1998(E), American National Standards Institute, 1998.
[4]
}}K. Czarnecki, U. W. Eisenecker, R. Glück, D. Vandevoorde, T. Veldhuizen, Generative Programming and Active Libraries, Springer-Verlag, 2000.
[5]
}}K. Czarnecki, U. W. Eisenecker, Generative Programming: Methods, Tools and Applications, Addison-Wesley, 2000.
[6]
}}G. Dos Reis, B. Stroustrup, Specifying C++ concepts, Proceedings of the 33rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL), 2006, pp. 295--308.
[7]
}}Paul Hudak, Building domain-specific embedded languages, ACM Computing Surveys (CSUR), Volume 28, Issue 4es (1996)
[8]
}}Y. Gil, K. Lenz, Simple and Safe SQL queries with C++ templates, In: Charles Consela and Julia L. Lawall (eds), Generative Programming and Component Engineering, 6th International Conference, GPCE 2007, Salzburg, Austria, October 1--3, 2007, pp.13--24.
[9]
}}Douglas Gregor, Jaakko Jarvi, Variadic templates for C++, Symposium on Applied Computing, Proceedings of the 2007 ACM symposium on Applied computing, Seoul, Korea (2007), pp.1101--1108.
[10]
}}D. Gregor, J. Jarvi, J.G. Siek, G. Dos Reis, B. Stroustrup, A. Lumsdaine, Concepts: Linguistic Support for Generic Programming in C++, In Proceedings of the 2006 ACM SIGPLAN conference on Object-oriented programming, systems, languages, and applications (OOPSLA'06), October 2006.
[11]
}}B. Karlsson, Beyond the C++ Standard Library, An Introduction to Boost, Addison-Wesley, 2005.
[12]
}}D. R. Musser, A. A. Stepanov, Algorithm-oriented Generic Libraries, Software-practice and experience 27(7), 1994, pp.623--642.
[13]
}}B. McNamara, Y. Smaragdakis: Static interfaces in C++. In First Workshop on C++ Template Metaprogramming, October 2000
[14]
}}B. O'Sullivan, J. Goerzen, D. Stewart, Real World Haskell, O'Reilly, 2008. ISBN: 978-0--596--51498--3
[15]
}}Z. Porkoláb, J. Mihalicza, Á. Sipos, Debugging C++ template metaprograms, In: Stan Jarzabek, Douglas C. Schmidt, Todd L. Veldhuizen (Eds.): Generative Programming and Component Engineering, 5th International Conference, GPCE 2006, Portland, Oregon, USA, October 22--26, 2006, Proceedings. ACM 2006 ISBN 1--59593--237--2, pp. 255--264.
[16]
}}J. Siek and A. Lumsdaine: Concept checking: Binding parametric polymorphism in C++, In First Workshop on C++ Template Metaprogramming, October 2000
[17]
}}J. Siek, A. Lumsdaine, Essential Language Support for Generic Programming, Proceedings of the ACM SIGPLAN 2005 conference on Programming language design and implementation, New York, USA, pp 73--84.
[18]
}}C. Simonyi, M. Christerson, S. Clifford, Intentional software, In Proceedings of the 21st annual ACM SIGPLAN conference on Object-oriented programming systems, languages, and applications, October 22--26, 2006, Portland, Oregon, USA, pp. 451--465.
[19]
}}B. Stroustrup, The C++ Programming Language Special Edition, Addison-Wesley, 2000.
[20]
}}B. Stroustrup, Evolving a language in and for the real world: C++ 1991--2006. ACM HOPL-III. June 2007
[21]
}}Laurence Tratt, The Converge programming language, Technical report TR-05-01, Department of Computer Science, King's College London, 2005.
[22]
}}E. Unruh, Prime number computation, ANSI X3J16--94-0075/ISO WG21--462.
[23]
}}D. Vandevoorde, N. M. Josuttis, C++ Templates: The Complete Guide, Addison-Wesley, 2003.
[24]
}}T. Veldhuizen, D. Gannon, Active libraries: Rethinking the roles of compilers and libraries. In Proceedings of the SIAM Workshop on Object Oriented Methods for Inter-operable Scientic and Engineering Computing (OO'98). SIAM Press, 1998 pp. 21--23
[25]
}}T. Veldhuizen, Using C++ Template Metaprograms, C++ Report vol. 7, no. 4, 1995, pp. 36--43.
[26]
}}T. Veldhuizen, Expression Templates, C++ Report vol. 7, no. 5, 1995, pp. 26--31.
[27]
}}E. Visser, Program Transformation with Stratego/XT: Rules, Strategies, Tools, and Systems in StrategoXT-0.9. In C. Lengauer et al., editors, Domain-Specific Program Generation, vol. 3016 of Lecture Notes in Computer Science, pp. 216--238. Spinger-Verlag, June 2004.
[28]
}}E.R. Van Wyk, A.C. Schwerdfeger, Context-aware scanning for parsing extensible languages, Proceedings of the 6th international conference on Generative programming and component engineering, October 01-03, 2007, Salzburg, Austria, pp. 63--72.
[29]
}}M. Zalewski, A. P. Priesnitz, C. Ionescu, N. Botta, and S. Schupp, Multi-language library development: From Haskell type classes to C++ concepts, In MPOOL 2007 Ecoop workshp, 2007.
[30]
}}I. Zólyomi, Z. Porkoláb, Towards a template introspection library, LNCS Vol.3286 (2004), pp.266--282.
[31]
}}L. Andersson: Parsing with Haskell, October 28, 2001, http://www.cs.lth.se/eda120/assignment4/parser.pdf
[32]
}}The boost lambda library. http://www.boost.org/doc/libs/1_39_0/doc/html/lambda.html
[33]
}}The boost metaprogram libraries. http://www.boost.org/doc/libs/1_39_0/libs/mpl/doc
[34]
}}The boost preprocessor metaprogramming library. http://www.boost.org/doc/libs/1_41_0/libs/preprocessor/doc/index.html
[35]
}}The boost proto library. http://www.boost.org/doc/libs/1_37_0/doc/html/proto.html
[36]
}}The boost xpressive regular library. http://www.boost.org/doc/libs/1_38_0/doc/html/xpressive.html
[37]
}}The Intentional Software. http://intentsoft.com/
[38]
}}The printf grammar. http://www.cplusplus.com/reference/clibrary/cstdio/printf/
[39]
}}The Stratego Program Transformation Language. http://strategoxt.org/
[40]
}}Bjane Stroustrup's C++0x FAQ, http://www.research.att.com/~bs/C++0xFAQ.html
[41]
}}Template Haskell http://www.haskell.org/haskellwiki/Template_Haskell
[42]
}}Python Programming Language http://www.python.org
[43]
}}The Icon Programming Language http://www.cs.arizona.edu/icon
[44]
}}Katahdin http://www.chrisseaton.com/katahdin
[45]
}}The XMF programming language http://itcentre.tvu.ac.uk/~clark/xmf.html
[46]
}}The source code of mpllibs http://github.com/sabel83/mpllibs

Cited By

View all

Index Terms

  1. Domain-specific language integration with compile-time parser generator library

    Recommendations

    Comments

    Please enable JavaScript to view thecomments powered by Disqus.

    Information & Contributors

    Information

    Published In

    cover image ACM Conferences
    GPCE '10: Proceedings of the ninth international conference on Generative programming and component engineering
    October 2010
    198 pages
    ISBN:9781450301541
    DOI:10.1145/1868294
    • General Chair:
    • Eelco Visser,
    • Program Chair:
    • Jaakko Järvi
    • cover image ACM SIGPLAN Notices
      ACM SIGPLAN Notices  Volume 46, Issue 2
      GPCE '10
      Febuary 2011
      185 pages
      ISSN:0362-1340
      EISSN:1558-1160
      DOI:10.1145/1942788
      Issue’s Table of Contents
    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]

    Sponsors

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 10 October 2010

    Permissions

    Request permissions for this article.

    Check for updates

    Author Tags

    1. C++ template metaprogram
    2. DSL integration
    3. haskell
    4. parser generator

    Qualifiers

    • Research-article

    Conference

    GPCE'10
    Sponsor:
    GPCE'10: Generative Programming and Component Engineering
    October 10 - 13, 2010
    Eindhoven, The Netherlands

    Acceptance Rates

    GPCE '10 Paper Acceptance Rate 18 of 59 submissions, 31%;
    Overall Acceptance Rate 56 of 180 submissions, 31%

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • Downloads (Last 12 months)7
    • Downloads (Last 6 weeks)2
    Reflects downloads up to 20 Dec 2024

    Other Metrics

    Citations

    Cited By

    View all
    • (2020)A DSL for Resource Checking Using Finite State Automaton-Driven Symbolic ExecutionOpen Computer Science10.1515/comp-2020-012011:1(107-115)Online publication date: 17-Dec-2020
    • (2019)Symbolic Execution with Finite State Automata2019 IEEE 15th International Scientific Conference on Informatics10.1109/Informatics47936.2019.9119287(000293-000298)Online publication date: Nov-2019
    • (2015)DSL in C++ Template MetaprogramCentral European Functional Programming School10.1007/978-3-319-15940-9_3(76-114)Online publication date: 21-Mar-2015
    • (2014)LibDSL: a library for developing embedded domain specific languages in d via template metaprogrammingACM SIGPLAN Notices10.1145/2775053.265877050:3(63-72)Online publication date: 15-Sep-2014
    • (2014)LibDSL: a library for developing embedded domain specific languages in d via template metaprogrammingProceedings of the 2014 International Conference on Generative Programming: Concepts and Experiences10.1145/2658761.2658770(63-72)Online publication date: 15-Sep-2014
    • (2013)Domain-Specific Language Integration with C++ Template MetaprogrammingFormal and Practical Aspects of Domain-Specific Languages10.4018/978-1-4666-2092-6.ch002(32-55)Online publication date: 2013
    • (2012)LLDSALProceedings of the seventh workshop on Domain-Specific Aspect Languages10.1145/2162037.2162043(15-20)Online publication date: 27-Mar-2012
    • (2011)Nested Lambda Expressions with Let Expressions in C++ Template MetaprogramsElectronic Notes in Theoretical Computer Science (ENTCS)10.1016/j.entcs.2011.11.036279:3(27-40)Online publication date: 1-Dec-2011
    • (2011)Functional Extensions to the Boost Metaprogram LibraryElectronic Notes in Theoretical Computer Science (ENTCS)10.1016/j.entcs.2011.06.006264:5(85-101)Online publication date: 1-Jul-2011
    • (2018)Automatic checking of the usage of the C++ 11 move semanticsActa Cybernetica10.14232/actacyb.22.1.2015.222:1(5-20)Online publication date: 20-Dec-2018

    View Options

    Login options

    View options

    PDF

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader

    Media

    Figures

    Other

    Tables

    Share

    Share

    Share this Publication link

    Share on social media