1/*============================================================================= 2 Copyright (c) 1998-2003 Joel de Guzman 3 http://spirit.sourceforge.net/ 4 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 11 12namespace boost { namespace spirit { 13 14BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN 15 16 /////////////////////////////////////////////////////////////////////////// 17 // 18 // Generic parse function implementation 19 // 20 /////////////////////////////////////////////////////////////////////////// 21 template <typename IteratorT, typename DerivedT> 22 inline parse_info<IteratorT> 23 parse( 24 IteratorT const& first_ 25 , IteratorT const& last 26 , parser<DerivedT> const& p) 27 { 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()); 33 } 34 35 /////////////////////////////////////////////////////////////////////////// 36 // 37 // Parse function for null terminated strings implementation 38 // 39 /////////////////////////////////////////////////////////////////////////// 40 template <typename CharT, typename DerivedT> 41 inline parse_info<CharT const*> 42 parse(CharT const* str, parser<DerivedT> const& p) 43 { 44 CharT const* last = str; 45 while (*last) 46 last++; 47 return parse(str, last, p); 48 } 49 50BOOST_SPIRIT_CLASSIC_NAMESPACE_END 51 52}} // namespace boost::spirit 53 54#endif 55 56