1 // Copyright (c) 2001-2011 Hartmut Kaiser
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 #if !defined(BOOST_SPIRIT_REPOSITORY_QI_ITER_POS_NOV_20_2009_1245PM)
7 #define BOOST_SPIRIT_REPOSITORY_QI_ITER_POS_NOV_20_2009_1245PM
9 #include <boost/spirit/include/qi_parse.hpp>
11 ///////////////////////////////////////////////////////////////////////////////
12 // definition the place holder
13 namespace boost { namespace spirit { namespace repository { namespace qi
15 BOOST_SPIRIT_TERMINAL(iter_pos);
18 ///////////////////////////////////////////////////////////////////////////////
19 // implementation the enabler
20 namespace boost { namespace spirit
22 // We want custom_parser::iter_pos to be usable as a terminal only,
23 // and only for parser expressions (qi::domain).
25 struct use_terminal<qi::domain, repository::qi::tag::iter_pos>
30 ///////////////////////////////////////////////////////////////////////////////
31 // implementation of the parser
32 namespace boost { namespace spirit { namespace repository { namespace qi
34 struct iter_pos_parser
35 : boost::spirit::qi::primitive_parser<iter_pos_parser>
37 // Define the attribute type exposed by this parser component
38 template <typename Context, typename Iterator>
41 typedef Iterator type;
44 // This function is called during the actual parsing process
45 template <typename Iterator, typename Context
46 , typename Skipper, typename Attribute>
47 bool parse(Iterator& first, Iterator const& last
48 , Context&, Skipper const& skipper, Attribute& attr) const
50 boost::spirit::qi::skip_over(first, last, skipper);
51 boost::spirit::traits::assign_to(first, attr);
55 // This function is called during error handling to create
56 // a human readable string for the error context.
57 template <typename Context>
58 boost::spirit::info what(Context&) const
60 return boost::spirit::info("iter_pos");
65 ///////////////////////////////////////////////////////////////////////////////
66 // instantiation of the parser
67 namespace boost { namespace spirit { namespace qi
69 // This is the factory function object invoked in order to create
70 // an instance of our iter_pos_parser.
71 template <typename Modifiers>
72 struct make_primitive<repository::qi::tag::iter_pos, Modifiers>
74 typedef repository::qi::iter_pos_parser result_type;
76 result_type operator()(unused_type, unused_type) const