File indexing completed on 2025-01-31 10:01:55
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #if !defined(BOOST_SPIRIT_GRAMMAR_HPP)
0011 #define BOOST_SPIRIT_GRAMMAR_HPP
0012
0013
0014 #if defined(BOOST_SPIRIT_THREADSAFE) && defined(BOOST_SPIRIT_SINGLE_GRAMMAR_INSTANCE)
0015 #undef BOOST_SPIRIT_SINGLE_GRAMMAR_INSTANCE
0016 #endif
0017
0018 #include <boost/spirit/home/classic/namespace.hpp>
0019 #include <boost/spirit/home/classic/core/parser.hpp>
0020 #include <boost/spirit/home/classic/core/non_terminal/parser_context.hpp>
0021 #include <boost/spirit/home/classic/core/non_terminal/impl/grammar.ipp>
0022
0023
0024 namespace boost { namespace spirit {
0025
0026 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
0027
0028
0029
0030
0031
0032
0033 template <typename DerivedT, typename ContextT = parser_context<> >
0034 struct grammar
0035 : public parser<DerivedT>
0036 , public ContextT::base_t
0037 , public context_aux<ContextT, DerivedT>
0038 BOOST_SPIRIT_GRAMMAR_ID
0039 {
0040 typedef grammar<DerivedT, ContextT> self_t;
0041 typedef DerivedT const& embed_t;
0042 typedef typename ContextT::context_linker_t context_t;
0043 typedef typename context_t::attr_t attr_t;
0044
0045 template <typename ScannerT>
0046 struct result
0047 {
0048 typedef typename match_result<ScannerT, attr_t>::type type;
0049 };
0050
0051 grammar() {}
0052 ~grammar() { impl::grammar_destruct(this); }
0053
0054 template <typename ScannerT>
0055 typename parser_result<self_t, ScannerT>::type
0056 parse_main(ScannerT const& scan) const
0057 { return impl::grammar_parser_parse<0>(this, scan); }
0058
0059 template <typename ScannerT>
0060 typename parser_result<self_t, ScannerT>::type
0061 parse(ScannerT const& scan) const
0062 {
0063 typedef typename parser_result<self_t, ScannerT>::type result_t;
0064 typedef parser_scanner_linker<ScannerT> scanner_t;
0065 BOOST_SPIRIT_CONTEXT_PARSE(scan, *this, scanner_t, context_t, result_t)
0066 }
0067
0068 template <int N>
0069 impl::entry_grammar<DerivedT, N, ContextT>
0070 use_parser() const
0071 { return impl::entry_grammar<DerivedT, N, ContextT>( this->derived()); }
0072
0073 BOOST_SPIRIT_GRAMMAR_STATE
0074 };
0075
0076
0077 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
0078
0079 }}
0080
0081 #undef BOOST_SPIRIT_GRAMMAR_ID
0082 #undef BOOST_SPIRIT_GRAMMAR_STATE
0083 #endif
0084