I wrote the following recursive rule in boost :: spirit :: x3, but it only compiles in g ++ / clang, not VS2017 (15.5.3):
#include <iostream> #include <boost/spirit/home/x3.hpp> namespace lex3 { namespace x3 = boost::spirit::x3; x3::rule<struct foo_class> const foo = "foo"; x3::rule<struct bar_class> const bar = "bar"; auto bar_def = *((x3::char_ - "/*") - "*/") >> *(foo > *((x3::char_ - "/*") - "*/")); auto foo_def = "/*" > bar > "*/"; BOOST_SPIRIT_DEFINE(foo) BOOST_SPIRIT_DEFINE(bar) } int main(int argc, char** argv) { std::string input = "/* a /* nested */ comment */"; auto f = input.begin(); auto l = input.end(); if (parse(f, l, lex3::foo) && (f == l)) std::cout << "Parse success.\n"; else std::cout << "Parse failure (remainder: " << std::string(f, l) << ").\n"; return 0; }
Link Coliru, g ++
link Coliru, clang ++
How do I make this work in VS2017 (if possible)?
PS: The toolkit for the platform is installed in v141, the ISO standard is set to C ++ 17, the accelerated version is 1.66.0
PPS: Compilation errors are as follows
error C2039: 'insert': is not a member of 'boost::spirit::x3::unused_type' note: see declaration of 'boost::spirit::x3::unused_type' error C2039: 'end': is not a member of 'boost::spirit::x3::unused_type' note: see declaration of 'boost::spirit::x3::unused_type' error C2039: 'begin': is not a member of 'boost::spirit::x3::unused_type' note: see declaration of 'boost::spirit::x3::unused_type'
source share