Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:53:39

0001 /*=============================================================================
0002     Boost.Wave: A Standard compliant C++ preprocessor library
0003 
0004     http://www.boost.org/
0005 
0006     Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost
0007     Software License, Version 1.0. (See accompanying file
0008     LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0009 =============================================================================*/
0010 
0011 #if !defined(BOOST_CPP_DEFINED_GRAMMAR_HPP_F48287B2_DC67_40A8_B4A1_800EFBD67869_INCLUDED)
0012 #define BOOST_CPP_DEFINED_GRAMMAR_HPP_F48287B2_DC67_40A8_B4A1_800EFBD67869_INCLUDED
0013 
0014 #include <boost/wave/wave_config.hpp>
0015 
0016 #include <boost/assert.hpp>
0017 #include <boost/spirit/include/classic_core.hpp>
0018 #include <boost/spirit/include/classic_closure.hpp>
0019 #include <boost/spirit/include/classic_assign_actor.hpp>
0020 #include <boost/spirit/include/classic_push_back_actor.hpp>
0021 
0022 #include <boost/wave/token_ids.hpp>
0023 #include <boost/wave/util/pattern_parser.hpp>
0024 #include <boost/wave/grammars/cpp_defined_grammar_gen.hpp>
0025 
0026 #if !defined(spirit_append_actor)
0027 #define spirit_append_actor(actor) boost::spirit::classic::push_back_a(actor)
0028 #define spirit_assign_actor(actor) boost::spirit::classic::assign_a(actor)
0029 #endif // !defined(spirit_append_actor)
0030 
0031 // this must occur after all of the includes and before any code appears
0032 #ifdef BOOST_HAS_ABI_HEADERS
0033 #include BOOST_ABI_PREFIX
0034 #endif
0035 
0036 ///////////////////////////////////////////////////////////////////////////////
0037 namespace boost {
0038 namespace wave {
0039 namespace grammars {
0040 
0041 ///////////////////////////////////////////////////////////////////////////////
0042 //  define, whether the rule's should generate some debug output
0043 #define TRACE_CPP_DEFINED_GRAMMAR \
0044     bool(BOOST_SPIRIT_DEBUG_FLAGS_CPP & BOOST_SPIRIT_DEBUG_FLAGS_DEFINED_GRAMMAR) \
0045     /**/
0046 
0047 template <typename ContainerT>
0048 struct defined_grammar :
0049     public boost::spirit::classic::grammar<defined_grammar<ContainerT> >
0050 {
0051     defined_grammar(ContainerT &result_seq_)
0052     :   result_seq(result_seq_)
0053     {
0054         BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR_NAME(*this, "defined_grammar",
0055             TRACE_CPP_DEFINED_GRAMMAR);
0056     }
0057 
0058     template <typename ScannerT>
0059     struct definition
0060     {
0061         typedef boost::spirit::classic::rule<ScannerT> rule_t;
0062 
0063         rule_t defined_op;
0064         rule_t identifier;
0065 
0066         definition(defined_grammar const &self)
0067         {
0068             using namespace boost::spirit::classic;
0069             using namespace boost::wave;
0070             using namespace boost::wave::util;
0071 
0072             defined_op      // parens not required, see C++ standard 16.1.1
0073                 =   ch_p(T_IDENTIFIER)      // token contains 'defined'
0074                     >>  (
0075                             (   ch_p(T_LEFTPAREN)
0076                                 >>  identifier
0077                                 >>  ch_p(T_RIGHTPAREN)
0078                             )
0079                             |   identifier
0080                         )
0081                 ;
0082 
0083             identifier
0084                 =   ch_p(T_IDENTIFIER)
0085                     [
0086                         spirit_append_actor(self.result_seq)
0087                     ]
0088                 |   pattern_p(KeywordTokenType, TokenTypeMask|PPTokenFlag)
0089                     [
0090                         spirit_append_actor(self.result_seq)
0091                     ]
0092                 |   pattern_p(OperatorTokenType|AltExtTokenType,
0093                         ExtTokenTypeMask|PPTokenFlag)
0094                     [
0095                         spirit_append_actor(self.result_seq)
0096                     ]
0097                 |   pattern_p(BoolLiteralTokenType, TokenTypeMask|PPTokenFlag)
0098                     [
0099                         spirit_append_actor(self.result_seq)
0100                     ]
0101                 ;
0102 
0103             BOOST_SPIRIT_DEBUG_TRACE_RULE(defined_op, TRACE_CPP_DEFINED_GRAMMAR);
0104             BOOST_SPIRIT_DEBUG_TRACE_RULE(identifier, TRACE_CPP_DEFINED_GRAMMAR);
0105         }
0106 
0107         // start rule of this grammar
0108         rule_t const& start() const
0109         { return defined_op; }
0110     };
0111 
0112     ContainerT &result_seq;
0113 };
0114 
0115 ///////////////////////////////////////////////////////////////////////////////
0116 #undef TRACE_CPP_DEFINED_GRAMMAR
0117 
0118 ///////////////////////////////////////////////////////////////////////////////
0119 //
0120 //  The following parse function is defined here, to allow the separation of
0121 //  the compilation of the defined_grammar from the function
0122 //  using it.
0123 //
0124 ///////////////////////////////////////////////////////////////////////////////
0125 
0126 #if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION != 0
0127 #define BOOST_WAVE_DEFINED_GRAMMAR_GEN_INLINE
0128 #else
0129 #define BOOST_WAVE_DEFINED_GRAMMAR_GEN_INLINE inline
0130 #endif
0131 
0132 //  The parse_operator_define function is instantiated manually twice to
0133 //  simplify the explicit specialization of this template. This way the user
0134 //  has only to specify one template parameter (the lexer type) to correctly
0135 //  formulate the required explicit specialization.
0136 //  This results in no code overhead, because otherwise the function would be
0137 //  generated by the compiler twice anyway.
0138 
0139 template <typename LexIteratorT>
0140 BOOST_WAVE_DEFINED_GRAMMAR_GEN_INLINE
0141 boost::spirit::classic::parse_info<
0142     typename defined_grammar_gen<LexIteratorT>::iterator1_type
0143 >
0144 defined_grammar_gen<LexIteratorT>::parse_operator_defined (
0145     iterator1_type const &first, iterator1_type const &last,
0146     token_sequence_type &found_qualified_name)
0147 {
0148     using namespace boost::spirit::classic;
0149     using namespace boost::wave;
0150 
0151     defined_grammar<token_sequence_type> g(found_qualified_name);
0152     return boost::spirit::classic::parse (
0153         first, last, g, ch_p(T_SPACE) | ch_p(T_CCOMMENT));
0154 }
0155 
0156 template <typename LexIteratorT>
0157 BOOST_WAVE_DEFINED_GRAMMAR_GEN_INLINE
0158 boost::spirit::classic::parse_info<
0159     typename defined_grammar_gen<LexIteratorT>::iterator2_type
0160 >
0161 defined_grammar_gen<LexIteratorT>::parse_operator_defined (
0162     iterator2_type const &first, iterator2_type const &last,
0163     token_sequence_type &found_qualified_name)
0164 {
0165     using namespace boost::spirit::classic;
0166     using namespace boost::wave;
0167 
0168     defined_grammar<token_sequence_type> g(found_qualified_name);
0169     return boost::spirit::classic::parse (
0170         first, last, g, ch_p(T_SPACE) | ch_p(T_CCOMMENT));
0171 }
0172 
0173 #undef BOOST_WAVE_DEFINED_GRAMMAR_GEN_INLINE
0174 
0175 ///////////////////////////////////////////////////////////////////////////////
0176 }   // namespace grammars
0177 }   // namespace wave
0178 }   // namespace boost
0179 
0180 // the suffix header occurs after all of the code
0181 #ifdef BOOST_HAS_ABI_HEADERS
0182 #include BOOST_ABI_SUFFIX
0183 #endif
0184 
0185 #endif // !defined(BOOST_CPP_DEFINED_GRAMMAR_HPP_F48287B2_DC67_40A8_B4A1_800EFBD67869_INCLUDED)