File indexing completed on 2025-01-19 09:47:37
0001
0002
0003
0004
0005
0006
0007 #if !defined(BOOST_SPIRIT_KARMA_GRAMMAR_MAR_05_2007_0542PM)
0008 #define BOOST_SPIRIT_KARMA_GRAMMAR_MAR_05_2007_0542PM
0009
0010 #if defined(_MSC_VER)
0011 #pragma once
0012 #endif
0013
0014 #include <boost/spirit/home/support/unused.hpp>
0015 #include <boost/spirit/home/support/info.hpp>
0016 #include <boost/spirit/home/support/assert_msg.hpp>
0017 #include <boost/spirit/home/karma/domain.hpp>
0018 #include <boost/spirit/home/karma/nonterminal/rule.hpp>
0019 #include <boost/spirit/home/karma/nonterminal/nonterminal_fwd.hpp>
0020 #include <boost/spirit/home/karma/reference.hpp>
0021 #include <boost/noncopyable.hpp>
0022 #include <boost/proto/extends.hpp>
0023 #include <boost/proto/traits.hpp>
0024 #include <boost/type_traits/is_same.hpp>
0025
0026 namespace boost { namespace spirit { namespace karma
0027 {
0028 template <
0029 typename OutputIterator, typename T1, typename T2, typename T3
0030 , typename T4>
0031 struct grammar
0032 : proto::extends<
0033 typename proto::terminal<
0034 reference<rule<OutputIterator, T1, T2, T3, T4> const>
0035 >::type
0036 , grammar<OutputIterator, T1, T2, T3, T4>
0037 >
0038 , generator<grammar<OutputIterator, T1, T2, T3, T4> >
0039 , noncopyable
0040 {
0041 typedef OutputIterator iterator_type;
0042 typedef rule<OutputIterator, T1, T2, T3, T4> start_type;
0043 typedef typename start_type::properties properties;
0044 typedef typename start_type::sig_type sig_type;
0045 typedef typename start_type::locals_type locals_type;
0046 typedef typename start_type::delimiter_type delimiter_type;
0047 typedef typename start_type::encoding_type encoding_type;
0048 typedef grammar<OutputIterator, T1, T2, T3, T4> base_type;
0049 typedef reference<start_type const> reference_;
0050 typedef typename proto::terminal<reference_>::type terminal;
0051
0052 static size_t const params_size = start_type::params_size;
0053
0054 template <typename Context, typename Unused>
0055 struct attribute
0056 {
0057 typedef typename start_type::attr_type type;
0058 };
0059
0060
0061 typedef detail::output_iterator<OutputIterator, properties>
0062 output_iterator;
0063
0064 grammar(start_type const& start
0065 , std::string const& name_ = "unnamed-grammar")
0066 : proto::extends<terminal, base_type>(terminal::make(reference_(start)))
0067 , name_(name_)
0068 {}
0069
0070
0071
0072 template <typename Iterator_, typename T1_, typename T2_, typename T3_,
0073 typename T4_>
0074 grammar(rule<Iterator_, T1_, T2_, T3_, T4_> const&
0075 , std::string const& = "unnamed-grammar")
0076 {
0077
0078
0079
0080 BOOST_SPIRIT_ASSERT_MSG(
0081 (is_same<start_type, rule<Iterator_, T1_, T2_, T3_, T4_> >::value)
0082 , incompatible_start_rule, (rule<Iterator_, T1_, T2_, T3_, T4_>));
0083 }
0084
0085 std::string name() const
0086 {
0087 return name_;
0088 }
0089
0090 void name(std::string const& str)
0091 {
0092 name_ = str;
0093 }
0094
0095 template <typename Context, typename Delimiter, typename Attribute>
0096 bool generate(output_iterator& sink, Context& context
0097 , Delimiter const& delim, Attribute const& attr) const
0098 {
0099 return this->proto_base().child0.generate(
0100 sink, context, delim, attr);
0101 }
0102
0103 template <typename Context>
0104 info what(Context&) const
0105 {
0106 return info(name_);
0107 }
0108
0109
0110 start_type const& get_parameterized_subject() const
0111 { return this->proto_base().child0.ref.get(); }
0112 typedef start_type parameterized_subject_type;
0113 #include <boost/spirit/home/karma/nonterminal/detail/fcall.hpp>
0114
0115 std::string name_;
0116 };
0117 }}}
0118
0119 namespace boost { namespace spirit { namespace traits
0120 {
0121
0122 template <
0123 typename IteratorA, typename IteratorB, typename Attribute
0124 , typename Context, typename T1, typename T2, typename T3, typename T4>
0125 struct handles_container<
0126 karma::grammar<IteratorA, T1, T2, T3, T4>, Attribute, Context
0127 , IteratorB>
0128 : detail::nonterminal_handles_container<
0129 typename attribute_of<
0130 karma::grammar<IteratorA, T1, T2, T3, T4>
0131 , Context, IteratorB
0132 >::type, Attribute>
0133 {};
0134 }}}
0135
0136 #endif