parser-types.hpp
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 <boost/version.hpp>
00041
00042 #if BOOST_VERSION >= 103800
00043 #include <boost/spirit/include/classic.hpp>
00044 namespace boost_spirit = boost::spirit::classic;
00045 #else
00046 #include <boost/spirit.hpp>
00047 namespace boost_spirit = boost::spirit;
00048 #endif
00049 #include "../CommandInterface.hpp"
00050
00051 namespace RTT
00052 {
00053 class ProgramGraph;
00054 class VertexNode;
00055 class EdgeCondition;
00056 }
00057
00058 namespace RTT
00059 {
00060 template< class T>
00061 class Property;
00062 class PropertyBag;
00063 class PropertyBase;
00064 class ConditionInterface;
00065 }
00066
00067 namespace RTT
00068 {
00069 class TaskContext;
00070
00071 namespace detail {
00072 class ExpressionParser;
00073 class ArgumentsParser;
00074 }
00075
00076
00077
00078
00079
00080
00081 using namespace boost_spirit;
00082
00083 typedef std::string our_buffer_t;
00084 typedef our_buffer_t::iterator our_iterator_t;
00085 typedef position_iterator<our_iterator_t> our_pos_iter_t;
00086
00087
00088 typedef our_pos_iter_t iter_t;
00089
00090
00091
00092
00093
00094
00095
00096
00097 # define RULE( name, def ) \
00098 boost_spirit::contiguous<boost_spirit::sequence<boost_spirit::alpha_parser,boost_spirit::kleene_star<boost_spirit::chset<char> > > > name = (def)
00099
00100
00101
00102
00103
00104
00105 #if 1
00106
00110 struct eol_skip_functor
00111 {
00115 static bool skipeol;
00116 typedef nil_t result_t;
00117
00118 template <typename ScannerT>
00119 std::ptrdiff_t
00120 operator()(ScannerT const& scan, result_t& result) const {
00121 if (scan.at_end() || skipeol == false )
00122 return -1;
00123
00124 std::size_t len = 0;
00125
00126 if ( *scan == '\r') {
00127 ++scan;
00128 ++len;
00129 }
00130
00131 if ( !scan.at_end() && *scan == '\n') {
00132 ++scan;
00133 ++len;
00134 }
00135 if ( len > 0 ) {
00136 return len;
00137 }
00138
00139 return -1;
00140 }
00141 };
00142
00146 extern functor_parser<eol_skip_functor> eol_skip_p;
00147
00148 # define SKIP_PARSER \
00149 ( comment_p( "#" ) | comment_p( "//" ) | \
00150 comment_p( "" ) | (space_p - eol_p) | eol_skip_p )
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160 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<RTT::eol_skip_functor> > skip_parser_t;
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170 #else
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182 # define SKIP_PARSER \
00183 ( comment_p( "#" ) | comment_p( "//" ) | \
00184 comment_p( "" ) | (space_p - eol_p) )
00185
00186
00187 typedef __typeof__( SKIP_PARSER ) skip_parser_t;
00188 #endif
00189 typedef skip_parser_iteration_policy<skip_parser_t> iter_pol_t;
00190 typedef scanner_policies<iter_pol_t> scanner_pol_t;
00191 typedef scanner<iter_t, scanner_pol_t> scanner_t;
00192 typedef rule<scanner_t> rule_t;
00193 typedef rule<lexeme_scanner<scanner_t>::type > lexeme_rule_t;
00194
00195 }
00196
00197 #endif