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