Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Attribute of qi parsers
#include <iostream> #include <typeinfo> #include <boost/spirit/include/qi.hpp> template <typename Expr, typename Iterator = boost::spirit::unused_type> struct attribute_of_qi_component { typedef typename boost::spirit::result_of::compile< boost::spirit::qi::domain, Expr >::type parser_expression_type; typedef typename boost::spirit::traits::attribute_of< parser_expression_type, boost::spirit::unused_type, Iterator >::type type; }; struct string{}; template <typename Parser> void print_attribute(const std::string& parser_text,Parser) { std::cout << "------------------------------------------------------------------------------------\n"; std::cout << "Attribute of: \"" << parser_text << "\"" << std::endl; std::cout << typeid(typename attribute_of_qi_component<Parser>::type).name() << std::endl; } #define IM_LAZY_MACRO(PARSER) #PARSER,PARSER int main() { using boost::spirit::qi::char_; using boost::spirit::qi::attr; using boost::spirit::qi::lit; boost::spirit::qi::rule<std::string::const_iterator,string()> type,delimiter,name; boost::spirit::qi::rule<std::string::const_iterator,uint32_t()> length; print_attribute(IM_LAZY_MACRO( lit("record") >> char_('{') >> type >> delimiter >> length >> name >> char_('}') )); print_attribute(IM_LAZY_MACRO( lit("record") >> lit('{') >> type >> delimiter >> length >> name >> lit('}') )); print_attribute(IM_LAZY_MACRO( lit("record") >> lit('{') >> type >> (delimiter | attr("")) >> (length | attr(0)) >> name >> lit('}') )); print_attribute(IM_LAZY_MACRO( lit("record") >> lit('{') >> type >> (delimiter | attr(string())) >> (length | attr(uint32_t(0))) >> name >> lit('}') )); }
run
|
edit
|
history
|
help
0
Revers find file in windows
#26.fix
Wide string to lowercase
Regex success
#10.1
trying to find if reinterpret_cast preserves calling convention
Affine Key Finder and Decrypter
Hangman
multiplie linked list numbers
VC++ error LNK2001 with combined use of non-type template parameters