File indexing completed on 2025-01-19 09:47:45
0001
0002
0003
0004
0005
0006
0007 #if !defined(BOOST_SPIRIT_GRAMMAR_FEBRUARY_19_2007_0236PM)
0008 #define BOOST_SPIRIT_GRAMMAR_FEBRUARY_19_2007_0236PM
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/qi/domain.hpp>
0018 #include <boost/spirit/home/qi/nonterminal/rule.hpp>
0019 #include <boost/spirit/home/qi/nonterminal/nonterminal_fwd.hpp>
0020 #include <boost/spirit/home/qi/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 qi
0027 {
0028 template <
0029 typename Iterator, typename T1, typename T2, typename T3
0030 , typename T4>
0031 struct grammar
0032 : proto::extends<
0033 typename proto::terminal<
0034 reference<rule<Iterator, T1, T2, T3, T4> const>
0035 >::type
0036 , grammar<Iterator, T1, T2, T3, T4>
0037 >
0038 , parser<grammar<Iterator, T1, T2, T3, T4> >
0039 , noncopyable
0040 {
0041 typedef Iterator iterator_type;
0042 typedef rule<Iterator, T1, T2, T3, T4> start_type;
0043 typedef typename start_type::sig_type sig_type;
0044 typedef typename start_type::locals_type locals_type;
0045 typedef typename start_type::skipper_type skipper_type;
0046 typedef typename start_type::encoding_type encoding_type;
0047 typedef grammar<Iterator, T1, T2, T3, T4> base_type;
0048 typedef reference<start_type const> reference_;
0049 typedef typename proto::terminal<reference_>::type terminal;
0050
0051 static size_t const params_size = start_type::params_size;
0052
0053 template <typename Context, typename Iterator_>
0054 struct attribute
0055 {
0056 typedef typename start_type::attr_type type;
0057 };
0058
0059 grammar(
0060 start_type const& start
0061 , std::string const& name = "unnamed-grammar")
0062 : proto::extends<terminal, base_type>(terminal::make(reference_(start)))
0063 , name_(name)
0064 {}
0065
0066
0067
0068 template <typename Iterator_,
0069 typename T1_, typename T2_, typename T3_, typename T4_>
0070 grammar(
0071 rule<Iterator_, T1_, T2_, T3_, T4_> const&
0072 , std::string const& = "unnamed-grammar")
0073 {
0074
0075
0076
0077 BOOST_SPIRIT_ASSERT_MSG(
0078 (is_same<start_type, rule<Iterator_, T1_, T2_, T3_, T4_> >::value)
0079 , incompatible_start_rule, (rule<Iterator_, T1_, T2_, T3_, T4_>));
0080 }
0081
0082 std::string name() const
0083 {
0084 return name_;
0085 }
0086
0087 void name(std::string const& str)
0088 {
0089 name_ = str;
0090 }
0091
0092 template <typename Context, typename Skipper, typename Attribute>
0093 bool parse(Iterator& first, Iterator const& last
0094 , Context& context, Skipper const& skipper
0095 , Attribute& attr_) const
0096 {
0097 return this->proto_base().child0.parse(
0098 first, last, context, skipper, attr_);
0099 }
0100
0101 template <typename Context>
0102 info what(Context&) const
0103 {
0104 return info(name_);
0105 }
0106
0107
0108 start_type const& get_parameterized_subject() const
0109 { return this->proto_base().child0.ref.get(); }
0110 typedef start_type parameterized_subject_type;
0111 #include <boost/spirit/home/qi/nonterminal/detail/fcall.hpp>
0112
0113 std::string name_;
0114
0115 };
0116 }}}
0117
0118 namespace boost { namespace spirit { namespace traits
0119 {
0120
0121 template <
0122 typename IteratorA, typename IteratorB, typename Attribute
0123 , typename Context, typename T1, typename T2, typename T3, typename T4>
0124 struct handles_container<
0125 qi::grammar<IteratorA, T1, T2, T3, T4>, Attribute, Context, IteratorB>
0126 : traits::is_container<
0127 typename attribute_of<
0128 qi::grammar<IteratorA, T1, T2, T3, T4>, Context, IteratorB
0129 >::type
0130 >
0131 {};
0132 }}}
0133
0134 #endif