source: NonGTP/Boost/boost/spirit/core/impl/parser.ipp @ 857

Revision 857, 1.8 KB checked in by igarcia, 19 years ago (diff)
Line 
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{
14    ///////////////////////////////////////////////////////////////////////////
15    //
16    //  Generic parse function implementation
17    //
18    ///////////////////////////////////////////////////////////////////////////
19    template <typename IteratorT, typename DerivedT>
20    inline parse_info<IteratorT>
21    parse(
22        IteratorT const& first_
23      , IteratorT const& last
24      , parser<DerivedT> const& p)
25    {
26        IteratorT first = first_;
27        scanner<IteratorT, scanner_policies<> > scan(first, last);
28        match<nil_t> hit = p.derived().parse(scan);
29        return parse_info<IteratorT>(
30            first, hit, hit && (first == last), hit.length());
31    }
32
33    ///////////////////////////////////////////////////////////////////////////
34    //
35    //  Parse function for null terminated strings implementation
36    //
37    ///////////////////////////////////////////////////////////////////////////
38    template <typename CharT, typename DerivedT>
39    inline parse_info<CharT const*>
40    parse(CharT const* str, parser<DerivedT> const& p)
41    {
42        CharT const* last = str;
43        while (*last)
44            last++;
45        return parse(str, last, p);
46    }
47
48}} // namespace boost::spirit
49
50#endif
51
Note: See TracBrowser for help on using the repository browser.