1 /*=============================================================================
2 Copyright (c) 2001-2011 Hartmut Kaiser
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 =============================================================================*/
7 #if !defined(BOOST_SPIRIT_TEST_PARSER_SEP_24_2007_0558PM)
8 #define BOOST_SPIRIT_TEST_PARSER_SEP_24_2007_0558PM
10 #include <boost/spirit/include/qi_parse.hpp>
11 #include <boost/spirit/include/qi_what.hpp>
15 template <typename Char, typename Parser, typename Lexer>
16 inline bool test_parser(Char const* in, Parser const& p, Lexer& lex,
17 bool full_match = true)
19 // we don't care about the result of the "what" function.
20 // we only care that all parsers have it:
21 boost::spirit::qi::what(p);
24 std::string::iterator it_in = str.begin();
25 std::string::iterator end_in = str.end();
27 typedef typename Lexer::iterator_type iterator_type;
29 iterator_type iter = lex.begin(it_in, end_in);
30 iterator_type end = lex.end();
32 return boost::spirit::qi::parse(iter, end, p)
33 && (!full_match || (iter == end));
36 template <typename Char, typename Parser, typename Lexer, typename Skipper>
37 inline bool test_parser(Char const* in, Parser const& p, Lexer& lex,
38 Skipper const& s, bool full_match = true)
40 // we don't care about the result of the "what" function.
41 // we only care that all parsers have it:
42 boost::spirit::qi::what(p);
45 std::string::iterator it_in = str.begin();
46 std::string::iterator end_in = str.end();
48 typedef typename Lexer::iterator_type iterator_type;
50 iterator_type iter = lex.begin(it_in, end_in);
51 iterator_type end = lex.end();
53 return boost::spirit::qi::phrase_parse(iter, end, p, s)
54 && (!full_match || (iter == end));