1 /*=============================================================================
2 Copyright (c) 1998-2003 Joel de Guzman
3 http://spirit.sourceforge.net/
5 Use, modification and distribution is subject to the Boost Software
6 License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7 http://www.boost.org/LICENSE_1_0.txt)
8 =============================================================================*/
9 #if !defined(BOOST_SPIRIT_PARSER_IPP)
10 #define BOOST_SPIRIT_PARSER_IPP
12 namespace boost { namespace spirit {
14 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
16 ///////////////////////////////////////////////////////////////////////////
18 // Generic parse function implementation
20 ///////////////////////////////////////////////////////////////////////////
21 template <typename IteratorT, typename DerivedT>
22 inline parse_info<IteratorT>
24 IteratorT const& first_
25 , IteratorT const& last
26 , parser<DerivedT> const& p)
28 IteratorT first = first_;
29 scanner<IteratorT, scanner_policies<> > scan(first, last);
30 match<nil_t> hit = p.derived().parse(scan);
31 return parse_info<IteratorT>(
32 first, hit, hit && (first == last), hit.length());
35 ///////////////////////////////////////////////////////////////////////////
37 // Parse function for null terminated strings implementation
39 ///////////////////////////////////////////////////////////////////////////
40 template <typename CharT, typename DerivedT>
41 inline parse_info<CharT const*>
42 parse(CharT const* str, parser<DerivedT> const& p)
44 CharT const* last = str;
47 return parse(str, last, p);
50 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
52 }} // namespace boost::spirit