annotate DEPENDENCIES/generic/include/boost/spirit/home/qi/nonterminal/grammar.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 /*=============================================================================
Chris@16 2 Copyright (c) 2001-2011 Joel de Guzman
Chris@16 3
Chris@16 4 Distributed under the Boost Software License, Version 1.0. (See accompanying
Chris@16 5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 6 ==============================================================================*/
Chris@16 7 #if !defined(BOOST_SPIRIT_GRAMMAR_FEBRUARY_19_2007_0236PM)
Chris@16 8 #define BOOST_SPIRIT_GRAMMAR_FEBRUARY_19_2007_0236PM
Chris@16 9
Chris@16 10 #if defined(_MSC_VER)
Chris@16 11 #pragma once
Chris@16 12 #endif
Chris@16 13
Chris@16 14 #include <boost/spirit/home/support/unused.hpp>
Chris@16 15 #include <boost/spirit/home/support/info.hpp>
Chris@16 16 #include <boost/spirit/home/support/assert_msg.hpp>
Chris@16 17 #include <boost/spirit/home/qi/domain.hpp>
Chris@16 18 #include <boost/spirit/home/qi/nonterminal/rule.hpp>
Chris@16 19 #include <boost/spirit/home/qi/nonterminal/nonterminal_fwd.hpp>
Chris@16 20 #include <boost/spirit/home/qi/reference.hpp>
Chris@16 21 #include <boost/noncopyable.hpp>
Chris@16 22 #include <boost/type_traits/is_same.hpp>
Chris@16 23
Chris@16 24 namespace boost { namespace spirit { namespace qi
Chris@16 25 {
Chris@16 26 template <
Chris@16 27 typename Iterator, typename T1, typename T2, typename T3
Chris@16 28 , typename T4>
Chris@16 29 struct grammar
Chris@16 30 : proto::extends<
Chris@16 31 typename proto::terminal<
Chris@16 32 reference<rule<Iterator, T1, T2, T3, T4> const>
Chris@16 33 >::type
Chris@16 34 , grammar<Iterator, T1, T2, T3, T4>
Chris@16 35 >
Chris@16 36 , parser<grammar<Iterator, T1, T2, T3, T4> >
Chris@16 37 , noncopyable
Chris@16 38 {
Chris@16 39 typedef Iterator iterator_type;
Chris@16 40 typedef rule<Iterator, T1, T2, T3, T4> start_type;
Chris@16 41 typedef typename start_type::sig_type sig_type;
Chris@16 42 typedef typename start_type::locals_type locals_type;
Chris@16 43 typedef typename start_type::skipper_type skipper_type;
Chris@16 44 typedef typename start_type::encoding_type encoding_type;
Chris@16 45 typedef grammar<Iterator, T1, T2, T3, T4> base_type;
Chris@16 46 typedef reference<start_type const> reference_;
Chris@16 47 typedef typename proto::terminal<reference_>::type terminal;
Chris@16 48
Chris@16 49 static size_t const params_size = start_type::params_size;
Chris@16 50
Chris@16 51 template <typename Context, typename Iterator_>
Chris@16 52 struct attribute
Chris@16 53 {
Chris@16 54 typedef typename start_type::attr_type type;
Chris@16 55 };
Chris@16 56
Chris@16 57 grammar(
Chris@16 58 start_type const& start
Chris@16 59 , std::string const& name = "unnamed-grammar")
Chris@16 60 : proto::extends<terminal, base_type>(terminal::make(reference_(start)))
Chris@16 61 , name_(name)
Chris@16 62 {}
Chris@16 63
Chris@16 64 // This constructor is used to catch if the start rule is not
Chris@16 65 // compatible with the grammar.
Chris@16 66 template <typename Iterator_,
Chris@16 67 typename T1_, typename T2_, typename T3_, typename T4_>
Chris@16 68 grammar(
Chris@16 69 rule<Iterator_, T1_, T2_, T3_, T4_> const&
Chris@16 70 , std::string const& = "unnamed-grammar")
Chris@16 71 {
Chris@16 72 // If you see the assertion below failing then the start rule
Chris@16 73 // passed to the constructor of the grammar is not compatible with
Chris@16 74 // the grammar (i.e. it uses different template parameters).
Chris@16 75 BOOST_SPIRIT_ASSERT_MSG(
Chris@16 76 (is_same<start_type, rule<Iterator_, T1_, T2_, T3_, T4_> >::value)
Chris@16 77 , incompatible_start_rule, (rule<Iterator_, T1_, T2_, T3_, T4_>));
Chris@16 78 }
Chris@16 79
Chris@16 80 std::string name() const
Chris@16 81 {
Chris@16 82 return name_;
Chris@16 83 }
Chris@16 84
Chris@16 85 void name(std::string const& str)
Chris@16 86 {
Chris@16 87 name_ = str;
Chris@16 88 }
Chris@16 89
Chris@16 90 template <typename Context, typename Skipper, typename Attribute>
Chris@16 91 bool parse(Iterator& first, Iterator const& last
Chris@16 92 , Context& context, Skipper const& skipper
Chris@16 93 , Attribute& attr_) const
Chris@16 94 {
Chris@16 95 return this->proto_base().child0.parse(
Chris@16 96 first, last, context, skipper, attr_);
Chris@16 97 }
Chris@16 98
Chris@16 99 template <typename Context>
Chris@16 100 info what(Context&) const
Chris@16 101 {
Chris@16 102 return info(name_);
Chris@16 103 }
Chris@16 104
Chris@16 105 // bring in the operator() overloads
Chris@16 106 start_type const& get_parameterized_subject() const
Chris@16 107 { return this->proto_base().child0.ref.get(); }
Chris@16 108 typedef start_type parameterized_subject_type;
Chris@16 109 #include <boost/spirit/home/qi/nonterminal/detail/fcall.hpp>
Chris@16 110
Chris@16 111 std::string name_;
Chris@16 112
Chris@16 113 };
Chris@16 114 }}}
Chris@16 115
Chris@16 116 namespace boost { namespace spirit { namespace traits
Chris@16 117 {
Chris@16 118 ///////////////////////////////////////////////////////////////////////////
Chris@16 119 template <
Chris@16 120 typename IteratorA, typename IteratorB, typename Attribute
Chris@16 121 , typename Context, typename T1, typename T2, typename T3, typename T4>
Chris@16 122 struct handles_container<
Chris@16 123 qi::grammar<IteratorA, T1, T2, T3, T4>, Attribute, Context, IteratorB>
Chris@16 124 : traits::is_container<
Chris@16 125 typename attribute_of<
Chris@16 126 qi::grammar<IteratorA, T1, T2, T3, T4>, Context, IteratorB
Chris@16 127 >::type
Chris@16 128 >
Chris@16 129 {};
Chris@16 130 }}}
Chris@16 131
Chris@16 132 #endif