1 /*=============================================================================
2 Copyright (c) 2001-2010 Hartmut Kaiser
3 Copyright (c) 2001-2010 Joel de Guzman
5 Distributed under the Boost Software License, Version 1.0. (See accompanying
6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 =============================================================================*/
8 #if !defined(BOOST_SPIRIT_TEST_MATCH_MANIP_HPP)
9 #define BOOST_SPIRIT_TEST_MATCH_MANIP_HPP
11 #include <boost/spirit/include/qi_match.hpp>
13 #include <boost/spirit/include/support_argument.hpp>
14 #include <boost/spirit/include/qi_action.hpp>
15 #include <boost/spirit/include/qi_numeric.hpp>
16 #include <boost/spirit/include/qi_operator.hpp>
17 #include <boost/spirit/include/qi_char.hpp>
18 #include <boost/spirit/include/qi_operator.hpp>
19 #include <boost/spirit/include/qi_stream.hpp>
20 #include <boost/spirit/include/qi_match_auto.hpp>
21 #include <boost/phoenix/core.hpp>
22 #include <boost/phoenix/operator.hpp>
23 #include <boost/phoenix/statement.hpp>
30 #include <boost/core/lightweight_test.hpp>
32 ///////////////////////////////////////////////////////////////////////////////
33 template <typename Char, typename Expr>
34 bool test(Char const *toparse, Expr const& expr)
36 namespace spirit = boost::spirit;
37 BOOST_SPIRIT_ASSERT_MATCH(spirit::qi::domain, Expr);
39 std::istringstream istrm(toparse);
40 istrm.unsetf(std::ios::skipws);
41 istrm >> spirit::qi::compile<spirit::qi::domain>(expr);
42 return istrm.good() || istrm.eof();
45 template <typename Char, typename Expr, typename CopyExpr, typename CopyAttr
46 , typename Skipper, typename Attribute>
47 bool test(Char const *toparse,
48 boost::spirit::qi::detail::match_manip<
49 Expr, CopyExpr, CopyAttr, Skipper, Attribute> const& mm)
51 std::istringstream istrm(toparse);
52 istrm.unsetf(std::ios::skipws);
54 return istrm.good() || istrm.eof();
57 ///////////////////////////////////////////////////////////////////////////////
58 bool is_list_ok(std::list<char> const& l)
60 std::list<char>::const_iterator cit = l.begin();
61 if (cit == l.end() || *cit != 'a')
63 if (++cit == l.end() || *cit != 'b')
66 return ++cit != l.end() && *cit == 'c';