annotate DEPENDENCIES/generic/include/boost/wave/grammars/cpp_defined_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 Boost.Wave: A Standard compliant C++ preprocessor library
Chris@16 3
Chris@16 4 http://www.boost.org/
Chris@16 5
Chris@16 6 Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost
Chris@16 7 Software License, Version 1.0. (See accompanying file
Chris@16 8 LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 9 =============================================================================*/
Chris@16 10
Chris@16 11 #if !defined(CPP_DEFINED_GRAMMAR_HPP_F48287B2_DC67_40A8_B4A1_800EFBD67869_INCLUDED)
Chris@16 12 #define CPP_DEFINED_GRAMMAR_HPP_F48287B2_DC67_40A8_B4A1_800EFBD67869_INCLUDED
Chris@16 13
Chris@16 14 #include <boost/wave/wave_config.hpp>
Chris@16 15
Chris@16 16 #include <boost/assert.hpp>
Chris@16 17 #include <boost/spirit/include/classic_core.hpp>
Chris@16 18 #include <boost/spirit/include/classic_closure.hpp>
Chris@16 19 #include <boost/spirit/include/classic_assign_actor.hpp>
Chris@16 20 #include <boost/spirit/include/classic_push_back_actor.hpp>
Chris@16 21
Chris@16 22 #include <boost/wave/token_ids.hpp>
Chris@16 23 #include <boost/wave/util/pattern_parser.hpp>
Chris@16 24 #include <boost/wave/grammars/cpp_defined_grammar_gen.hpp>
Chris@16 25
Chris@16 26 #if !defined(spirit_append_actor)
Chris@16 27 #define spirit_append_actor(actor) boost::spirit::classic::push_back_a(actor)
Chris@16 28 #define spirit_assign_actor(actor) boost::spirit::classic::assign_a(actor)
Chris@16 29 #endif // !defined(spirit_append_actor)
Chris@16 30
Chris@16 31 // this must occur after all of the includes and before any code appears
Chris@16 32 #ifdef BOOST_HAS_ABI_HEADERS
Chris@16 33 #include BOOST_ABI_PREFIX
Chris@16 34 #endif
Chris@16 35
Chris@16 36 ///////////////////////////////////////////////////////////////////////////////
Chris@16 37 namespace boost {
Chris@16 38 namespace wave {
Chris@16 39 namespace grammars {
Chris@16 40
Chris@16 41 ///////////////////////////////////////////////////////////////////////////////
Chris@16 42 // define, whether the rule's should generate some debug output
Chris@16 43 #define TRACE_CPP_DEFINED_GRAMMAR \
Chris@16 44 bool(BOOST_SPIRIT_DEBUG_FLAGS_CPP & BOOST_SPIRIT_DEBUG_FLAGS_DEFINED_GRAMMAR) \
Chris@16 45 /**/
Chris@16 46
Chris@16 47 template <typename ContainerT>
Chris@16 48 struct defined_grammar :
Chris@16 49 public boost::spirit::classic::grammar<defined_grammar<ContainerT> >
Chris@16 50 {
Chris@16 51 defined_grammar(ContainerT &result_seq_)
Chris@16 52 : result_seq(result_seq_)
Chris@16 53 {
Chris@16 54 BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR_NAME(*this, "defined_grammar",
Chris@16 55 TRACE_CPP_DEFINED_GRAMMAR);
Chris@16 56 }
Chris@16 57
Chris@16 58 template <typename ScannerT>
Chris@16 59 struct definition
Chris@16 60 {
Chris@16 61 typedef boost::spirit::classic::rule<ScannerT> rule_t;
Chris@16 62
Chris@16 63 rule_t defined_op;
Chris@16 64 rule_t identifier;
Chris@16 65
Chris@16 66 definition(defined_grammar const &self)
Chris@16 67 {
Chris@16 68 using namespace boost::spirit::classic;
Chris@16 69 using namespace boost::wave;
Chris@16 70 using namespace boost::wave::util;
Chris@16 71
Chris@16 72 defined_op // parens not required, see C++ standard 16.1.1
Chris@16 73 = ch_p(T_IDENTIFIER) // token contains 'defined'
Chris@16 74 >> (
Chris@16 75 ( ch_p(T_LEFTPAREN)
Chris@16 76 >> identifier
Chris@16 77 >> ch_p(T_RIGHTPAREN)
Chris@16 78 )
Chris@16 79 | identifier
Chris@16 80 )
Chris@16 81 ;
Chris@16 82
Chris@16 83 identifier
Chris@16 84 = ch_p(T_IDENTIFIER)
Chris@16 85 [
Chris@16 86 spirit_append_actor(self.result_seq)
Chris@16 87 ]
Chris@16 88 | pattern_p(KeywordTokenType, TokenTypeMask|PPTokenFlag)
Chris@16 89 [
Chris@16 90 spirit_append_actor(self.result_seq)
Chris@16 91 ]
Chris@16 92 | pattern_p(OperatorTokenType|AltExtTokenType,
Chris@16 93 ExtTokenTypeMask|PPTokenFlag)
Chris@16 94 [
Chris@16 95 spirit_append_actor(self.result_seq)
Chris@16 96 ]
Chris@16 97 | pattern_p(BoolLiteralTokenType, TokenTypeMask|PPTokenFlag)
Chris@16 98 [
Chris@16 99 spirit_append_actor(self.result_seq)
Chris@16 100 ]
Chris@16 101 ;
Chris@16 102
Chris@16 103 BOOST_SPIRIT_DEBUG_TRACE_RULE(defined_op, TRACE_CPP_DEFINED_GRAMMAR);
Chris@16 104 BOOST_SPIRIT_DEBUG_TRACE_RULE(identifier, TRACE_CPP_DEFINED_GRAMMAR);
Chris@16 105 }
Chris@16 106
Chris@16 107 // start rule of this grammar
Chris@16 108 rule_t const& start() const
Chris@16 109 { return defined_op; }
Chris@16 110 };
Chris@16 111
Chris@16 112 ContainerT &result_seq;
Chris@16 113 };
Chris@16 114
Chris@16 115 ///////////////////////////////////////////////////////////////////////////////
Chris@16 116 #undef TRACE_CPP_DEFINED_GRAMMAR
Chris@16 117
Chris@16 118 ///////////////////////////////////////////////////////////////////////////////
Chris@16 119 //
Chris@16 120 // The following parse function is defined here, to allow the separation of
Chris@16 121 // the compilation of the defined_grammar from the function
Chris@16 122 // using it.
Chris@16 123 //
Chris@16 124 ///////////////////////////////////////////////////////////////////////////////
Chris@16 125
Chris@16 126 #if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION != 0
Chris@16 127 #define BOOST_WAVE_DEFINED_GRAMMAR_GEN_INLINE
Chris@16 128 #else
Chris@16 129 #define BOOST_WAVE_DEFINED_GRAMMAR_GEN_INLINE inline
Chris@16 130 #endif
Chris@16 131
Chris@16 132 // The parse_operator_define function is instantiated manually twice to
Chris@16 133 // simplify the explicit specialization of this template. This way the user
Chris@16 134 // has only to specify one template parameter (the lexer type) to correctly
Chris@16 135 // formulate the required explicit specialization.
Chris@16 136 // This results in no code overhead, because otherwise the function would be
Chris@16 137 // generated by the compiler twice anyway.
Chris@16 138
Chris@16 139 template <typename LexIteratorT>
Chris@16 140 BOOST_WAVE_DEFINED_GRAMMAR_GEN_INLINE
Chris@16 141 boost::spirit::classic::parse_info<
Chris@16 142 typename defined_grammar_gen<LexIteratorT>::iterator1_type
Chris@16 143 >
Chris@16 144 defined_grammar_gen<LexIteratorT>::parse_operator_defined (
Chris@16 145 iterator1_type const &first, iterator1_type const &last,
Chris@16 146 token_sequence_type &found_qualified_name)
Chris@16 147 {
Chris@16 148 using namespace boost::spirit::classic;
Chris@16 149 using namespace boost::wave;
Chris@16 150
Chris@16 151 defined_grammar<token_sequence_type> g(found_qualified_name);
Chris@16 152 return boost::spirit::classic::parse (
Chris@16 153 first, last, g, ch_p(T_SPACE) | ch_p(T_CCOMMENT));
Chris@16 154 }
Chris@16 155
Chris@16 156 template <typename LexIteratorT>
Chris@16 157 BOOST_WAVE_DEFINED_GRAMMAR_GEN_INLINE
Chris@16 158 boost::spirit::classic::parse_info<
Chris@16 159 typename defined_grammar_gen<LexIteratorT>::iterator2_type
Chris@16 160 >
Chris@16 161 defined_grammar_gen<LexIteratorT>::parse_operator_defined (
Chris@16 162 iterator2_type const &first, iterator2_type const &last,
Chris@16 163 token_sequence_type &found_qualified_name)
Chris@16 164 {
Chris@16 165 using namespace boost::spirit::classic;
Chris@16 166 using namespace boost::wave;
Chris@16 167
Chris@16 168 defined_grammar<token_sequence_type> g(found_qualified_name);
Chris@16 169 return boost::spirit::classic::parse (
Chris@16 170 first, last, g, ch_p(T_SPACE) | ch_p(T_CCOMMENT));
Chris@16 171 }
Chris@16 172
Chris@16 173 #undef BOOST_WAVE_DEFINED_GRAMMAR_GEN_INLINE
Chris@16 174
Chris@16 175 ///////////////////////////////////////////////////////////////////////////////
Chris@16 176 } // namespace grammars
Chris@16 177 } // namespace wave
Chris@16 178 } // namespace boost
Chris@16 179
Chris@16 180 // the suffix header occurs after all of the code
Chris@16 181 #ifdef BOOST_HAS_ABI_HEADERS
Chris@16 182 #include BOOST_ABI_SUFFIX
Chris@16 183 #endif
Chris@16 184
Chris@16 185 #endif // !defined(CPP_DEFINED_GRAMMAR_HPP_F48287B2_DC67_40A8_B4A1_800EFBD67869_INCLUDED)