00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef PARSER_TYPES_HPP
00038 #define PARSER_TYPES_HPP
00039
00040 #include "rtt-scripting-config.h"
00041
00042 #include <boost/version.hpp>
00043
00044 #if BOOST_VERSION >= 103800
00045 #include <boost/spirit/include/classic.hpp>
00046 namespace boost_spirit = boost::spirit::classic;
00047 #else
00048 #include <boost/spirit.hpp>
00049 namespace boost_spirit = boost::spirit;
00050 #endif
00051 #include "../base/ActionInterface.hpp"
00052 #include "rtt-scripting-fwd.hpp"
00053
00054 #undef interface // To avoid name clash with namespace interface and Windows SDK objbase.h included through boost/spirit
00055
00056 namespace RTT
00057 { namespace scripting {
00058
00059 using namespace boost_spirit;
00060
00061 typedef std::string our_buffer_t;
00062 typedef our_buffer_t::iterator our_iterator_t;
00063 typedef position_iterator<our_iterator_t> our_pos_iter_t;
00064
00065
00066 typedef our_pos_iter_t iter_t;
00067
00068 #if 1
00069
00072 #if defined( WIN32 )
00073 #ifdef NDEBUG
00074 #pragma optimize( "", off)
00075 #endif
00076 #endif
00077
00082 struct RTT_SCRIPTING_API eol_skip_functor
00083 {
00084 private:
00085 eol_skip_functor();
00086 public:
00090 eol_skip_functor(bool& skipref) : skipeol(skipref) {}
00091 eol_skip_functor(eol_skip_functor const& orig) : skipeol( orig.skipeol ) {}
00092 bool& skipeol;
00093 typedef nil_t result_t;
00094
00095 template <typename ScannerT>
00096 std::ptrdiff_t
00097 operator()(ScannerT const& scan, result_t& result) const {
00098 if (scan.at_end() || skipeol == false )
00099 return -1;
00100
00101 std::size_t len = 0;
00102
00103 if ( *scan == '\r') {
00104 ++scan;
00105 ++len;
00106 }
00107
00108 if ( !scan.at_end() && *scan == '\n') {
00109 ++scan;
00110 ++len;
00111 }
00112 if ( len > 0 ) {
00113 return len;
00114 }
00115
00116 return -1;
00117 }
00118 };
00119 #if defined( WIN32 )
00120 #ifdef NDEBUG
00121 #pragma optimize( "", on)
00122 #endif
00123 #endif
00124
00127 # define SKIP_PARSER \
00128 ( comment_p( "#" ) | comment_p( "//" ) | \
00129 comment_p( "" ) | (space_p - eol_p) | functor_parser<eol_skip_functor>( eol_skip_functor(skipref) ) )
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139 typedef boost_spirit::alternative<boost_spirit::alternative<boost_spirit::alternative<boost_spirit::alternative<boost_spirit::confix_parser<boost_spirit::impl::string_as_parser::type,boost_spirit::kleene_star<boost_spirit::anychar_parser>,boost_spirit::alternative<boost_spirit::eol_parser,boost_spirit::end_parser>,boost_spirit::unary_parser_category,boost_spirit::non_nested,boost_spirit::is_lexeme>,boost_spirit::confix_parser<boost_spirit::impl::string_as_parser::type,boost_spirit::kleene_star<boost_spirit::anychar_parser>,boost_spirit::alternative<boost_spirit::eol_parser,boost_spirit::end_parser>,boost_spirit::unary_parser_category,boost_spirit::non_nested,boost_spirit::is_lexeme> >,boost_spirit::confix_parser<boost_spirit::impl::string_as_parser::type,boost_spirit::kleene_star<boost_spirit::anychar_parser>,boost_spirit::impl::string_as_parser::type,boost_spirit::unary_parser_category,boost_spirit::non_nested,boost_spirit::is_lexeme> >,boost_spirit::difference<boost_spirit::space_parser,boost_spirit::eol_parser> >,boost_spirit::functor_parser<eol_skip_functor> > skip_parser_t;
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150 #else
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162 # define SKIP_PARSER \
00163 ( comment_p( "#" ) | comment_p( "//" ) | \
00164 comment_p( "" ) | (space_p - eol_p) )
00165
00166
00167 typedef __typeof__( SKIP_PARSER ) skip_parser_t;
00168 #endif
00169 typedef skip_parser_iteration_policy<skip_parser_t> iter_pol_t;
00170 typedef scanner_policies<iter_pol_t> scanner_pol_t;
00171 typedef scanner<iter_t, scanner_pol_t> scanner_t;
00172 typedef rule<scanner_t> rule_t;
00173 typedef rule<lexeme_scanner<scanner_t>::type > lexeme_rule_t;
00174
00175 }}
00176
00177 #endif