File indexing completed on 2025-01-18 09:53:40
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #if !defined(BOOST_CPP_PREDEF_MACROS_GRAMMAR_HPP_53858C9A_C202_4D60_AD92_DC9CAE4DBB43_INCLUDED)
0012 #define BOOST_CPP_PREDEF_MACROS_GRAMMAR_HPP_53858C9A_C202_4D60_AD92_DC9CAE4DBB43_INCLUDED
0013
0014 #include <boost/spirit/include/classic_core.hpp>
0015 #include <boost/spirit/include/classic_parse_tree.hpp>
0016 #include <boost/spirit/include/classic_confix.hpp>
0017 #include <boost/spirit/include/classic_lists.hpp>
0018
0019 #include <boost/wave/wave_config.hpp>
0020 #include <boost/wave/token_ids.hpp>
0021 #include <boost/wave/grammars/cpp_predef_macros_gen.hpp>
0022 #include <boost/wave/util/pattern_parser.hpp>
0023
0024
0025 #ifdef BOOST_HAS_ABI_HEADERS
0026 #include BOOST_ABI_PREFIX
0027 #endif
0028
0029
0030 namespace boost {
0031 namespace wave {
0032 namespace grammars {
0033
0034
0035
0036 #define TRACE_PREDEF_MACROS_GRAMMAR \
0037 bool(BOOST_SPIRIT_DEBUG_FLAGS_CPP & BOOST_SPIRIT_DEBUG_FLAGS_PREDEF_MACROS_GRAMMAR) \
0038
0039
0040
0041
0042 struct predefined_macros_grammar :
0043 public boost::spirit::classic::grammar<predefined_macros_grammar>
0044 {
0045 template <typename ScannerT>
0046 struct definition
0047 {
0048
0049 typedef boost::spirit::classic::rule<
0050 ScannerT, boost::spirit::classic::dynamic_parser_tag>
0051 rule_type;
0052
0053 rule_type plain_define, macro_definition, macro_parameters;
0054
0055 definition(predefined_macros_grammar const &)
0056 {
0057
0058 using namespace boost::spirit::classic;
0059 using namespace boost::wave;
0060 using namespace boost::wave::util;
0061
0062
0063 plain_define.set_id(BOOST_WAVE_PLAIN_DEFINE_ID);
0064 macro_parameters.set_id(BOOST_WAVE_MACRO_PARAMETERS_ID);
0065 macro_definition.set_id(BOOST_WAVE_MACRO_DEFINITION_ID);
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077 plain_define
0078 = ( ch_p(T_IDENTIFIER)
0079 | pattern_p(KeywordTokenType,
0080 TokenTypeMask|PPTokenFlag)
0081 | pattern_p(OperatorTokenType|AltExtTokenType,
0082 ExtTokenTypeMask|PPTokenFlag)
0083 | pattern_p(BoolLiteralTokenType,
0084 TokenTypeMask|PPTokenFlag)
0085 )
0086 >> !macro_parameters
0087 >> !macro_definition
0088 ;
0089
0090
0091 macro_parameters
0092 = confix_p(
0093 no_node_d[ch_p(T_LEFTPAREN) >> *ch_p(T_SPACE)],
0094 !list_p(
0095 ( ch_p(T_IDENTIFIER)
0096 | pattern_p(KeywordTokenType,
0097 TokenTypeMask|PPTokenFlag)
0098 | pattern_p(OperatorTokenType|AltExtTokenType,
0099 ExtTokenTypeMask|PPTokenFlag)
0100 | pattern_p(BoolLiteralTokenType,
0101 TokenTypeMask|PPTokenFlag)
0102
0103 #if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0
0104 | ch_p(T_ELLIPSIS)
0105 #endif
0106 ),
0107 no_node_d
0108 [
0109 *ch_p(T_SPACE) >> ch_p(T_COMMA) >> *ch_p(T_SPACE)
0110 ]
0111 ),
0112 no_node_d[*ch_p(T_SPACE) >> ch_p(T_RIGHTPAREN)]
0113 )
0114 ;
0115
0116
0117 macro_definition
0118 = no_node_d[ch_p(T_ASSIGN)]
0119 >> *anychar_p
0120 ;
0121
0122 BOOST_SPIRIT_DEBUG_TRACE_RULE(plain_define, TRACE_PREDEF_MACROS_GRAMMAR);
0123 BOOST_SPIRIT_DEBUG_TRACE_RULE(macro_definition, TRACE_PREDEF_MACROS_GRAMMAR);
0124 BOOST_SPIRIT_DEBUG_TRACE_RULE(macro_parameters, TRACE_PREDEF_MACROS_GRAMMAR);
0125 }
0126
0127
0128 rule_type const& start() const
0129 { return plain_define; }
0130 };
0131
0132 predefined_macros_grammar()
0133 {
0134 BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR_NAME(*this,
0135 "predefined_macros_grammar", TRACE_PREDEF_MACROS_GRAMMAR);
0136 }
0137
0138 };
0139
0140
0141 #undef TRACE_PREDEF_MACROS_GRAMMAR
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151 #if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION != 0
0152 #define BOOST_WAVE_PREDEF_MACROS_GRAMMAR_GEN_INLINE
0153 #else
0154 #define BOOST_WAVE_PREDEF_MACROS_GRAMMAR_GEN_INLINE inline
0155 #endif
0156
0157 template <typename LexIteratorT>
0158 BOOST_WAVE_PREDEF_MACROS_GRAMMAR_GEN_INLINE
0159 boost::spirit::classic::tree_parse_info<LexIteratorT>
0160 predefined_macros_grammar_gen<LexIteratorT>::parse_predefined_macro (
0161 LexIteratorT const &first, LexIteratorT const &last)
0162 {
0163 predefined_macros_grammar g;
0164 return boost::spirit::classic::pt_parse (first, last, g);
0165 }
0166
0167 #undef BOOST_WAVE_PREDEF_MACROS_GRAMMAR_GEN_INLINE
0168
0169
0170 }
0171 }
0172 }
0173
0174
0175 #ifdef BOOST_HAS_ABI_HEADERS
0176 #include BOOST_ABI_SUFFIX
0177 #endif
0178
0179 #endif