1 #ifndef BOOST_METAPARSE_V1_BUILD_PARSER_HPP 2 #define BOOST_METAPARSE_V1_BUILD_PARSER_HPP 3 4 // Copyright Abel Sinkovics (abel@sinkovics.hu) 2009 - 2010. 5 // Distributed under the Boost Software License, Version 1.0. 6 // (See accompanying file LICENSE_1_0.txt or copy at 7 // http://www.boost.org/LICENSE_1_0.txt) 8 9 #include <boost/metaparse/v1/fwd/build_parser.hpp> 10 #include <boost/metaparse/v1/start.hpp> 11 #include <boost/metaparse/v1/get_result.hpp> 12 #include <boost/metaparse/v1/get_position.hpp> 13 #include <boost/metaparse/v1/get_message.hpp> 14 #include <boost/metaparse/v1/get_line.hpp> 15 #include <boost/metaparse/v1/get_col.hpp> 16 #include <boost/metaparse/v1/is_error.hpp> 17 18 #include <boost/mpl/eval_if.hpp> 19 20 #include <boost/static_assert.hpp> 21 22 namespace boost 23 { 24 namespace metaparse 25 { 26 namespace v1 27 { 28 template <int Line, int Col, class Msg> 29 struct x__________________PARSING_FAILED__________________x 30 { 31 BOOST_STATIC_ASSERT(Line == Line + 1); 32 }; 33 34 template <class P, class S> 35 struct parsing_failed : 36 x__________________PARSING_FAILED__________________x< 37 get_line< 38 get_position<typename P::template apply<S, start> > 39 >::type::value, 40 get_col< 41 get_position<typename P::template apply<S, start> > 42 >::type::value, 43 typename get_message<typename P::template apply<S, start> >::type 44 > 45 {}; 46 47 template <class P> 48 struct build_parser 49 { 50 typedef build_parser type; 51 52 template <class S> 53 struct apply : 54 boost::mpl::eval_if< 55 typename is_error<typename P::template apply<S, start> >::type, 56 parsing_failed<P, S>, 57 get_result<typename P::template apply<S, start> > 58 > 59 {}; 60 }; 61 } 62 } 63 } 64 65 #endif 66 67