Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:08:56

0001 /*=============================================================================
0002     Copyright (c) 2001-2003 Joel de Guzman
0003     http://spirit.sourceforge.net/
0004 
0005   Distributed under the Boost Software License, Version 1.0. (See accompanying
0006   file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0007 =============================================================================*/
0008 #ifndef BOOST_SPIRIT_PARAMETRIC_HPP
0009 #define BOOST_SPIRIT_PARAMETRIC_HPP
0010 
0011 ///////////////////////////////////////////////////////////////////////////////
0012 #include <boost/spirit/home/classic/namespace.hpp>
0013 #include <boost/spirit/home/classic/core/parser.hpp>
0014 #include <boost/spirit/home/classic/core/composite/composite.hpp>
0015 #include <boost/spirit/home/classic/core/primitives/primitives.hpp>
0016 
0017 namespace boost { namespace spirit {
0018 
0019 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
0020 
0021     ///////////////////////////////////////////////////////////////////////////
0022     //
0023     //  f_chlit class [ functional version of chlit ]
0024     //
0025     ///////////////////////////////////////////////////////////////////////////
0026     template <typename ChGenT>
0027     struct f_chlit : public char_parser<f_chlit<ChGenT> >
0028     {
0029         f_chlit(ChGenT chgen_)
0030         : chgen(chgen_) {}
0031 
0032         template <typename T>
0033         bool test(T ch) const
0034         { return ch == chgen(); }
0035 
0036         ChGenT   chgen;
0037     };
0038 
0039     template <typename ChGenT>
0040     inline f_chlit<ChGenT>
0041     f_ch_p(ChGenT chgen)
0042     { return f_chlit<ChGenT>(chgen); }
0043 
0044     ///////////////////////////////////////////////////////////////////////////
0045     //
0046     //  f_range class [ functional version of range ]
0047     //
0048     ///////////////////////////////////////////////////////////////////////////
0049     template <typename ChGenAT, typename ChGenBT>
0050     struct f_range : public char_parser<f_range<ChGenAT, ChGenBT> >
0051     {
0052         f_range(ChGenAT first_, ChGenBT last_)
0053         : first(first_), last(last_)
0054         {}
0055 
0056         template <typename T>
0057         bool test(T ch) const
0058         {
0059             BOOST_SPIRIT_ASSERT(first() <= last());
0060             return (ch >= first()) && (ch <= last());
0061         }
0062 
0063         ChGenAT first;
0064         ChGenBT last;
0065     };
0066 
0067     template <typename ChGenAT, typename ChGenBT>
0068     inline f_range<ChGenAT, ChGenBT>
0069     f_range_p(ChGenAT first, ChGenBT last)
0070     { return f_range<ChGenAT, ChGenBT>(first, last); }
0071 
0072     ///////////////////////////////////////////////////////////////////////////
0073     //
0074     //  f_chseq class [ functional version of chseq ]
0075     //
0076     ///////////////////////////////////////////////////////////////////////////
0077     template <typename IterGenAT, typename IterGenBT>
0078     class f_chseq : public parser<f_chseq<IterGenAT, IterGenBT> >
0079     {
0080     public:
0081 
0082         typedef f_chseq<IterGenAT, IterGenBT> self_t;
0083 
0084         f_chseq(IterGenAT first_, IterGenBT last_)
0085         : first(first_), last(last_) {}
0086 
0087         template <typename ScannerT>
0088         typename parser_result<self_t, ScannerT>::type
0089         parse(ScannerT const& scan) const
0090         {
0091             typedef typename parser_result<self_t, ScannerT>::type result_t;
0092             return impl::string_parser_parse<result_t>(first(), last(), scan);
0093         }
0094 
0095     private:
0096 
0097         IterGenAT first;
0098         IterGenBT last;
0099     };
0100 
0101     template <typename IterGenAT, typename IterGenBT>
0102     inline f_chseq<IterGenAT, IterGenBT>
0103     f_chseq_p(IterGenAT first, IterGenBT last)
0104     { return f_chseq<IterGenAT, IterGenBT>(first, last); }
0105 
0106     ///////////////////////////////////////////////////////////////////////////
0107     //
0108     //  f_strlit class [ functional version of strlit ]
0109     //
0110     ///////////////////////////////////////////////////////////////////////////
0111     template <typename IterGenAT, typename IterGenBT>
0112     class f_strlit : public parser<f_strlit<IterGenAT, IterGenBT> >
0113     {
0114     public:
0115 
0116         typedef f_strlit<IterGenAT, IterGenBT> self_t;
0117 
0118         f_strlit(IterGenAT first, IterGenBT last)
0119         : seq(first, last) {}
0120 
0121         template <typename ScannerT>
0122         typename parser_result<self_t, ScannerT>::type
0123         parse(ScannerT const& scan) const
0124         {
0125             typedef typename parser_result<self_t, ScannerT>::type result_t;
0126             return impl::contiguous_parser_parse<result_t>
0127                 (seq, scan, scan);
0128         }
0129 
0130     private:
0131 
0132         f_chseq<IterGenAT, IterGenBT> seq;
0133     };
0134 
0135     template <typename IterGenAT, typename IterGenBT>
0136     inline f_strlit<IterGenAT, IterGenBT>
0137     f_str_p(IterGenAT first, IterGenBT last)
0138     { return f_strlit<IterGenAT, IterGenBT>(first, last); }
0139 
0140 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
0141 
0142 }} // namespace BOOST_SPIRIT_CLASSIC_NS
0143 
0144 #endif