31 #include "../Attribute.hpp" 33 #include "../TaskContext.hpp" 34 #include "../Service.hpp" 35 #include "../types/GlobalsRepository.hpp" 37 #include <boost/bind.hpp> 38 #include <boost/lexical_cast.hpp> 46 using namespace detail;
49 : commonparser(cp), peerparser(tc,cp), propparser(cp), context(tc)
51 BOOST_SPIRIT_DEBUG_RULE( constant );
52 BOOST_SPIRIT_DEBUG_RULE( const_float );
53 BOOST_SPIRIT_DEBUG_RULE( const_double );
54 BOOST_SPIRIT_DEBUG_RULE( const_int );
55 BOOST_SPIRIT_DEBUG_RULE( const_hex );
56 BOOST_SPIRIT_DEBUG_RULE( const_uint );
57 BOOST_SPIRIT_DEBUG_RULE( const_char );
58 BOOST_SPIRIT_DEBUG_RULE( const_bool );
59 BOOST_SPIRIT_DEBUG_RULE( const_string );
60 BOOST_SPIRIT_DEBUG_RULE( named_constant );
78 boost::bind( &ValueParser::seenfloatconstant,
this, _1 ) ] >> ch_p(
'f');
82 boost::bind( &ValueParser::seendoubleconstant,
this, _1 ) ];
84 const_hex = (str_p(
"0x") | str_p(
"0X")) >>
86 boost::bind( &ValueParser::seenhexconstant,
this, _1 ) ];
90 boost::bind( &ValueParser::seenintconstant,
this, _1 ) ];
94 boost::bind( &ValueParser::seenuintconstant,
this, _1 ) ] >> ch_p(
'u');
98 boost::bind( &ValueParser::seenboolconstant,
this, _1, _2 ) ];
100 const_char = (ch_p(
'\'') >> ch_p(
'\\') >> ch_p(
'0') >> ch_p(
'\''))[boost::bind( &ValueParser::seennull,
this)] |
101 confix_p(
"'", (c_escape_ch_p[ boost::bind( &ValueParser::seencharconstant,
this, _1 ) ]) ,
"'" );
103 const_string = lexeme_d[confix_p(
104 ch_p(
'"' ), *c_escape_ch_p[ boost::bind( &ValueParser::push_str_char,
this, _1 ) ],
'"' )[ boost::bind( &ValueParser::seenstring,
this ) ]];
107 (
keyword_p(
"done")[boost::bind( &ValueParser::seennamedconstant,
this, _1, _2 ) ]
109 ( peerparser.
locator()[boost::bind( &ValueParser::seenpeer,
this) ]
111 >> commonparser.
identifier[boost::bind( &ValueParser::seennamedconstant,
this, _1, _2 ) ]) )
115 void ValueParser::seenpeer() {
122 void ValueParser::seenboolconstant(
iter_t begin,
iter_t end )
124 std::string value( begin, end );
125 assert( value ==
"true" || value ==
"false" );
126 if ( value ==
"true" )
134 void ValueParser::seennamedconstant(
iter_t begin,
iter_t end )
136 std::string name( begin, end );
142 if ( task && propparser.
bag() && propparser.
property() ) {
144 if ( ! propparser.
bag()->
find( name ) ) {
154 if ( task && task->hasAttribute( name ) ) {
155 ret = task->getValue(name)->getDataSource();
158 if ( task && task->hasProperty( name ) ) {
159 ret = task->properties()->find(name)->getDataSource();
169 throw_(begin,
"Value " + name +
" not defined in "+ task->getName()+
".");
172 void ValueParser::seennull()
177 void ValueParser::seencharconstant(
iter_t c )
182 void ValueParser::seenhexconstant(
unsigned int i )
187 void ValueParser::seenintconstant(
int i )
192 void ValueParser::seenuintconstant(
unsigned int i )
197 void ValueParser::seenfloatconstant(
double i )
202 void ValueParser::seendoubleconstant(
double i )
222 void ValueParser::push_str_char(
char c )
227 void ValueParser::seenstring()
232 mcurstring.erase( mcurstring.end() - 1 );
#define keyword_p(word)
Returns a rule which parses a keyword followed by a non-identifier character, newline or semicolon...
void clear()
Clears this parser, not the repository where it stores its results.
void reset()
After reset, peer() == current context and object() == "this".
static shared_ptr Instance()
base::PropertyBase * property() const
parse_exception class that is used for various semantic errors for which it was not worth defining a ...
This class contains some very common parser definitions.
rule_t & locator()
The locator tries to go as far as possible in the peer-to-object path and will never throw...
void reset()
After reset, property() == 0 and bag == 0.
boost::shared_ptr< Service > shared_ptr
base::PropertyBase * find(const std::string &name) const
Find the base::PropertyBase with name name.
ServicePtr taskObject()
Returns the last matching Service or zero if not found.
void setPropertyBag(PropertyBag *pb)
Change the bag we want to traverse.
PropertyBag * bag() const
A DataSource which holds a constant value and returns it in its get() method.
rule_t & locator()
The locator tries to go as far as possible in the bag-to-property path and will never throw...
The TaskContext is the C++ representation of an Orocos component.
const std::string & getName() const
Get the name of the property.
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
virtual DataSourceBase::shared_ptr getDataSource() const =0
Get an assignable base::DataSource through which this PropertyBase can be manipulated.