DSL in C plus plus Template Metaprogram

被引:1
|
作者
Porkolab, Zoltan [1 ]
Sinkovics, Abel [1 ]
Siroki, Istvan [1 ]
机构
[1] Eotvos Lorand Univ, Dept Programming Languages & Compilers, Fac Informat, Pazmany Peter Setany 1-C, H-1117 Budapest, Hungary
关键词
D O I
10.1007/978-3-319-15940-9_3
中图分类号
TP [自动化技术、计算机技术];
学科分类号
0812 ;
摘要
Domain specific language integration has to provide the right balance between the expressive power of the DSL and the implementation and maintenance cost of the applied integration techniques. 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 using the C++ template metaprogramming library called Metaparse. The parser generator is the 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 Metaparse leads to self-documenting maintenable C++ source code.
引用
收藏
页码:76 / 114
页数:39
相关论文
共 50 条
  • [41] Fake Run-Time Selection of Template Arguments in C plus
    Langr, Daniel
    Tvrdik, Pavel
    Dytrych, Tomas
    Draayer, Jerry P.
    OBJECTS, MODELS, COMPONENTS, PATTERNS, TOOLS 2012, 2012, 7304 : 140 - 154
  • [42] Quantum plus plus : A modern C plus plus quantum computing library
    Gheorghiu, Vlad
    PLOS ONE, 2018, 13 (12):
  • [43] aflow plus plus : A C plus plus framework for autonomous materials design
    Oses, Corey
    Esters, Marco
    Hicks, David
    Divilov, Simon
    Eckert, Hagen
    Friedrich, Rico
    Mehl, Michael J.
    Smolyanyuk, Andriy
    Campilongo, Xiomara
    van de Walle, Axel
    Schroers, Jan
    Kusne, A. Gilad
    Takeuchi, Ichiro
    Zurek, Eva
    Nardelli, Marco Buongiorno
    Fornari, Marco
    Lederer, Yoav
    Levy, Ohad
    Toher, Cormac
    Curtarolo, Stefano
    COMPUTATIONAL MATERIALS SCIENCE, 2023, 217
  • [44] The magnetic spectrum of beta rays emitted by the ThB plus C plus C' plus C"
    Arnoult, R
    COMPTES RENDUS HEBDOMADAIRES DES SEANCES DE L ACADEMIE DES SCIENCES, 1934, 198 : 1603 - 1605
  • [45] The magnetic spectrum of beta rays emitted by AcB plus C plus C' plus C''
    Graf, T
    COMPTES RENDUS HEBDOMADAIRES DES SEANCES DE L ACADEMIE DES SCIENCES, 1933, 197 : 238 - 241
  • [46] The Pinocchio C plus plus library
    Carpentier, Justin
    Saurel, Guilhem
    Buondonno, Gabriele
    Mirabel, Joseph
    Lamiraux, Florent
    Stasse, Olivier
    Mansard, Nicolas
    2019 IEEE/SICE INTERNATIONAL SYMPOSIUM ON SYSTEM INTEGRATION (SII), 2019, : 614 - 619
  • [47] Mathematizing C plus plus Concurrency
    Batty, Mark
    Owens, Scott
    Sarkar, Susmit
    Sewell, Peter
    Weber, Tjark
    ACM SIGPLAN NOTICES, 2011, 46 (01) : 55 - 66
  • [48] C plus plus constructors - Response
    Meyers, S
    DR DOBBS JOURNAL, 1997, 22 (08): : 12 - 12
  • [49] Programming with C plus plus concepts
    Jaervi, Jaakko
    Marcus, Mat
    Smith, Jacob N.
    SCIENCE OF COMPUTER PROGRAMMING, 2010, 75 (07) : 596 - 614
  • [50] C plus plus string performance
    Kochubeevsky, L
    DR DOBBS JOURNAL, 2003, 28 (10): : 28 - +