Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Parsing based on constexpr

Metaparse is based on template metaprogramming, however, C++11 provides constexpr, which can be used for parsing at compile-time as well. While implementing parsers based on constexpr is easier for a C++ developer, since its syntax resembles the regular syntax of the language, the result of parsing has to be a constexpr value. Parsers based on template metaprogramming can build types as the result of parsing. These types may be boxed constexpr values but can be metafunction classes, classes with static functions which can be called at runtime, etc.

When a parser built with Metaparse needs a sub-parser for processing a part of the input text and generating a constexpr value as the result of parsing, one can implement the sub-parser based on constexpr functions. Metaparse can be integrated with them and lift their results into C++ template metaprogramming. An example demonstrating this feature can be found among the examples (constexpr_parser). This capability makes it possible to integrate Metaparse with parsing libraries based on constexpr.


PrevUpHomeNext