/usr/include/boost/spirit/home/classic/dynamic/impl
Edit: /usr/include/boost/spirit/home/classic/dynamic/impl/select.ipp (4111B)
/*=============================================================================
Copyright (c) 2003 Hartmut Kaiser
http://spirit.sourceforge.net/
Use, modification and distribution is subject to the Boost Software
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#ifndef BOOST_SPIRIT_SELECT_IPP
#define BOOST_SPIRIT_SELECT_IPP
#include
#include
#include
///////////////////////////////////////////////////////////////////////////////
namespace boost { namespace spirit {
BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
///////////////////////////////////////////////////////////////////////////////
namespace impl {
///////////////////////////////////////////////////////////////////////////////
template
struct as_embedded_parser : public as_parser
{
typedef typename as_parser::type::derived_t::embed_t type;
};
///////////////////////////////////////////////////////////////////////////////
// no implementation here to catch unknown BehaviourT template arguments
template
struct select_match_gen;
// implementation for the select_default_no_fail behaviour
template
struct select_match_gen {
template
static ResultT
do_ (ScannerT const &scan)
{
return scan.create_match(0, -1, scan.first, scan.first);
}
};
// implementation for the select_default_fail behaviour
template
struct select_match_gen {
template
static ResultT
do_ (ScannerT const &scan)
{
return scan.no_match();
}
};
///////////////////////////////////////////////////////////////////////////////
template
struct parse_tuple_element {
BOOST_STATIC_CONSTANT(int, index = (TupleT::length - N));
template
static ResultT
do_(TupleT const &t, ScannerT const &scan)
{
typedef typename ::phoenix::tuple_element::type parser_t;
typedef typename ScannerT::iterator_t iterator_t;
typedef typename parser_result::type result_t;
iterator_t save(scan.first);
result_t result(t[::phoenix::tuple_index()].parse(scan));
if (result) {
return scan.create_match(result.length(), TupleT::length - N,
save, scan.first);
}
scan.first = save; // reset the input stream
return parse_tuple_element::
do_(t, scan);
}
};
template
struct parse_tuple_element<1, ResultT, TupleT, BehaviourT> {
BOOST_STATIC_CONSTANT(int, index = (TupleT::length - 1));
template
static ResultT
do_(TupleT const &t, ScannerT const &scan)
{
typedef typename ::phoenix::tuple_element::type parser_t;
typedef typename ScannerT::iterator_t iterator_t;
typedef typename parser_result::type result_t;
iterator_t save(scan.first);
result_t result(t[::phoenix::tuple_index()].parse(scan));
if (result) {
return scan.create_match(result.length(), TupleT::length - 1,
save, scan.first);
}
scan.first = save; // reset the input stream
return select_match_gen::do_(scan);
}
};
///////////////////////////////////////////////////////////////////////////////
} // namespace impl
BOOST_SPIRIT_CLASSIC_NAMESPACE_END
}} // namespace boost::spirit
#endif // BOOST_SPIRIT_SELECT_IPP