1 // Copyright Abel Sinkovics (abel@sinkovics.hu) 2011. 2 // Distributed under the Boost Software License, Version 1.0. 3 // (See accompanying file LICENSE_1_0.txt or copy at 4 // http://www.boost.org/LICENSE_1_0.txt) 5 6 #include <boost/metaparse/repeated.hpp> 7 #include <boost/metaparse/sequence.hpp> 8 #include <boost/metaparse/lit_c.hpp> 9 #include <boost/metaparse/debug_parsing_error.hpp> 10 11 #include <boost/metaparse/build_parser.hpp> 12 #include <boost/metaparse/string.hpp> 13 14 #include <boost/mpl/apply.hpp> 15 16 using boost::metaparse::sequence; 17 using boost::metaparse::lit_c; 18 using boost::metaparse::repeated; 19 using boost::metaparse::build_parser; 20 using boost::metaparse::debug_parsing_error; 21 22 using boost::mpl::apply; 23 24 /* 25 * The grammar 26 * 27 * s ::= a*b 28 */ 29 typedef sequence<repeated<lit_c<'a'> >, lit_c<'b'> > s; 30 31 typedef build_parser<s> test_parser; 32 33 #if BOOST_METAPARSE_STD < 2011 34 35 typedef boost::metaparse::string<'a','a','a','c'> invalid_input; 36 37 #else 38 39 typedef BOOST_METAPARSE_STRING("aaac") invalid_input; 40 41 #endif 42 43 debug_parsing_error<test_parser, invalid_input> debug; 44 main()45int main() 46 { 47 // This causes an error 48 // apply<test_parser, invalid_input>::type(); 49 } 50 51 52