/*============================================================================= Copyright (c) 1998-2003 Joel de Guzman Copyright (c) 2003 Vaclav Vesely 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) =============================================================================*/ #if !defined(BOOST_SPIRIT_DISTINCT_HPP) #define BOOST_SPIRIT_DISTINCT_HPP #include #include #include #include #include #include #include #include namespace boost { namespace spirit { //----------------------------------------------------------------------------- // distinct_parser class template class distinct_parser { public: typedef contiguous< sequence< chseq, negated_empty_match_parser< TailT > > > result_t; distinct_parser() : tail(chset()) { } explicit distinct_parser(parser const & tail_) : tail(tail_.derived()) { } explicit distinct_parser(CharT const* letters) : tail(chset_p(letters)) { } result_t operator()(CharT const* str) const { return lexeme_d[chseq_p(str) >> ~epsilon_p(tail)]; } TailT tail; }; //----------------------------------------------------------------------------- // distinct_directive class template class distinct_directive { public: template struct result { typedef contiguous< sequence< ParserT, negated_empty_match_parser< TailT > > > type; }; distinct_directive() : tail(chset()) { } explicit distinct_directive(CharT const* letters) : tail(chset_p(letters)) { } explicit distinct_directive(parser const & tail_) : tail(tail_.derived()) { } template typename result::type>::type operator[](ParserT const &subject) const { return lexeme_d[as_parser::convert(subject) >> ~epsilon_p(tail)]; } TailT tail; }; //----------------------------------------------------------------------------- // dynamic_distinct_parser class template class dynamic_distinct_parser { public: typedef typename ScannerT::value_t char_t; typedef rule< typename no_actions_scanner< typename lexeme_scanner::type >::type > tail_t; typedef contiguous< sequence< chseq, negated_empty_match_parser< tail_t > > > result_t; dynamic_distinct_parser() : tail(nothing_p) { } template explicit dynamic_distinct_parser(parser const & tail_) : tail(tail_.derived()) { } explicit dynamic_distinct_parser(char_t const* letters) : tail(chset_p(letters)) { } result_t operator()(char_t const* str) const { return lexeme_d[chseq_p(str) >> ~epsilon_p(tail)]; } tail_t tail; }; //----------------------------------------------------------------------------- // dynamic_distinct_directive class template class dynamic_distinct_directive { public: typedef typename ScannerT::value_t char_t; typedef rule< typename no_actions_scanner< typename lexeme_scanner::type >::type > tail_t; template struct result { typedef contiguous< sequence< ParserT, negated_empty_match_parser< tail_t > > > type; }; dynamic_distinct_directive() : tail(nothing_p) { } template explicit dynamic_distinct_directive(parser const & tail_) : tail(tail_.derived()) { } explicit dynamic_distinct_directive(char_t const* letters) : tail(chset_p(letters)) { } template typename result::type>::type operator[](ParserT const &subject) const { return lexeme_d[as_parser::convert(subject) >> ~epsilon_p(tail)]; } tail_t tail; }; //----------------------------------------------------------------------------- } // namespace spirit } // namespace boost #endif // !defined(BOOST_SPIRIT_DISTINCT_HPP)