// Copyright (c) 2001-2010 Hartmut Kaiser // Copyright (c) 2001-2010 Joel de Guzman // Copyright (c) 2003 Vaclav Vesely // // Distributed under 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) #if !defined(SPIRIT_REPOSITORY_QI_DISTINCT_MAY_20_2009_0825M) #define SPIRIT_REPOSITORY_QI_DISTINCT_MAY_20_2009_0825M #if defined(_MSC_VER) #pragma once #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /////////////////////////////////////////////////////////////////////////////// namespace boost { namespace spirit { /////////////////////////////////////////////////////////////////////////// // Enablers /////////////////////////////////////////////////////////////////////////// // enables distinct(...)[...] template struct use_directive > > : mpl::true_ {}; // enables *lazy* distinct(...)[...] template <> struct use_lazy_directive : mpl::true_ {}; }} /////////////////////////////////////////////////////////////////////////////// namespace boost { namespace spirit { namespace repository {namespace qi { using repository::distinct_type; using repository::distinct; template struct distinct_parser : spirit::qi::unary_parser > { template struct attribute : traits::attribute_of {}; distinct_parser(Subject const& subject, Tail const& tail) : subject(subject), tail(tail) {} template bool parse(Iterator& first, Iterator const& last , Context& context, Skipper const& skipper, Attribute& attr) const { Iterator iter = first; spirit::qi::skip_over(iter, last, skipper); if (!subject.parse(iter, last, context , spirit::qi::detail::unused_skipper(skipper), attr)) return false; Iterator i = iter; if (tail.parse(i, last, context, unused, unused)) return false; first = iter; return true; } template info what(Context& /*ctx*/) const { return info("distinct"); } Subject subject; Tail tail; }; }}}} /////////////////////////////////////////////////////////////////////////////// namespace boost { namespace spirit { namespace qi { /////////////////////////////////////////////////////////////////////////// // Parser generators: make_xxx function (objects) /////////////////////////////////////////////////////////////////////////// template struct make_directive< terminal_ex > , Subject, Modifiers> { typedef typename result_of::compile::type tail_type; typedef repository::qi::distinct_parser< Subject, tail_type, Modifiers> result_type; template result_type operator()(Terminal const& term, Subject const& subject , Modifiers const& modifiers) const { return result_type(subject , compile(fusion::at_c<0>(term.args), modifiers)); } }; }}} namespace boost { namespace spirit { namespace traits { template struct has_semantic_action< repository::qi::distinct_parser > : unary_has_semantic_action {}; }}} #endif