42 #include "../TaskContext.hpp" 46 #include "../internal/Exceptions.hpp" 47 #include "../base/AttributeBase.hpp" 56 #include <boost/bind.hpp> 57 #include <boost/lambda/lambda.hpp> 58 #include <boost/call_traits.hpp> 61 #include "../internal/mystd.hpp" 65 using namespace boost;
66 using namespace detail;
79 boost::spirit::classic::assertion<GraphSyntaxErrors> expect_state(state_expected);
80 boost::spirit::classic::assertion<GraphSyntaxErrors> expect_handle(handle_expected);
81 boost::spirit::classic::assertion<GraphSyntaxErrors> expect_transition(transition_expected);
82 boost::spirit::classic::assertion<std::string> expect_end(
"Ending '}' expected ( or could not find out what this line means ).");
83 boost::spirit::classic::assertion<std::string> expect_end_of_state(
"Exptected ending '}' at end of state ( or could not find out what this line means ).");
84 boost::spirit::classic::assertion<std::string> expect_if(
"Wrongly formatted \"if ... then select\" clause.");
85 boost::spirit::classic::assertion<std::string> expect_select(
"'select' statement required after emty transition program.");
86 boost::spirit::classic::assertion<std::string> expect_select_ident(
"'select' requires a valid state name.");
87 boost::spirit::classic::assertion<std::string> expect_comma(
"Expected a comma separator.");
88 boost::spirit::classic::assertion<std::string> expect_ident(
"Expected a valid identifier.");
89 boost::spirit::classic::assertion<std::string> expect_event_or_if(
"Expected an event name or an if clause in transition statement.");
90 boost::spirit::classic::assertion<std::string> expect_open(
"Open brace expected.");
91 boost::spirit::classic::assertion<std::string> expect_eof(
"Invalid input in file.");
92 boost::spirit::classic::assertion<std::string> expect_eol(
"Newline expected at end of statement.");
93 boost::spirit::classic::assertion<std::string> expect_semicolon(
"Semi colon expected after statement.");
94 boost::spirit::classic::assertion<std::string> expect_open_parenth(
"Open parenthesis expected." );
95 boost::spirit::classic::assertion<std::string> expect_close_parenth(
"Open parenthesis expected." );
96 boost::spirit::classic::assertion<std::string> expect_eventselect(
"'select' statement required after event or transition program.");
97 boost::spirit::classic::assertion<std::string> expect_eventargs(
"Could not parse arguments after event.");
108 curinstantiatedmachine(),
109 curmachinebuilder( 0 ),
110 curinitialstateflag( false ),
111 curfinalstateflag( false ),
113 curnonprecstate( 0 ),
121 conditionparser( new
ConditionParser( context, caller, *commonparser ) ),
122 valuechangeparser( new
ValueChangeParser(context, *commonparser, context->provides(), caller) ),
125 peerparser( new
PeerParser(context, *commonparser, true) )
127 BOOST_SPIRIT_DEBUG_RULE( production );
128 BOOST_SPIRIT_DEBUG_RULE( body );
129 BOOST_SPIRIT_DEBUG_RULE( rootmachineinstantiation );
130 BOOST_SPIRIT_DEBUG_RULE( statemachine );
131 BOOST_SPIRIT_DEBUG_RULE( machineinstantiation );
132 BOOST_SPIRIT_DEBUG_RULE( statemachinecontent );
133 BOOST_SPIRIT_DEBUG_RULE( varline );
134 BOOST_SPIRIT_DEBUG_RULE( state );
135 BOOST_SPIRIT_DEBUG_RULE( vardec );
136 BOOST_SPIRIT_DEBUG_RULE( subMachinedecl );
137 BOOST_SPIRIT_DEBUG_RULE( statecontent );
138 BOOST_SPIRIT_DEBUG_RULE( statecontentline );
139 BOOST_SPIRIT_DEBUG_RULE( entry );
140 BOOST_SPIRIT_DEBUG_RULE( preconditions );
141 BOOST_SPIRIT_DEBUG_RULE( precondition );
142 BOOST_SPIRIT_DEBUG_RULE( handle );
143 BOOST_SPIRIT_DEBUG_RULE( transitions );
144 BOOST_SPIRIT_DEBUG_RULE( transition );
145 BOOST_SPIRIT_DEBUG_RULE( exit );
146 BOOST_SPIRIT_DEBUG_RULE( transline );
147 BOOST_SPIRIT_DEBUG_RULE( eventline );
148 BOOST_SPIRIT_DEBUG_RULE( ifbranch );
149 BOOST_SPIRIT_DEBUG_RULE( elsebranch );
150 BOOST_SPIRIT_DEBUG_RULE( progselect );
151 BOOST_SPIRIT_DEBUG_RULE( program );
152 BOOST_SPIRIT_DEBUG_RULE( selector );
153 BOOST_SPIRIT_DEBUG_RULE( machineinstarguments );
154 BOOST_SPIRIT_DEBUG_RULE( machineinstargument );
155 BOOST_SPIRIT_DEBUG_RULE( machinememvar );
156 BOOST_SPIRIT_DEBUG_RULE( machinevariable );
157 BOOST_SPIRIT_DEBUG_RULE( machineparam );
158 BOOST_SPIRIT_DEBUG_RULE( machineconstant );
159 BOOST_SPIRIT_DEBUG_RULE( machinealias );
160 BOOST_SPIRIT_DEBUG_RULE( subMachinevarchange );
164 production = *body >> expect_eof(end_p);
166 body = statemachine[ boost::bind( &StateGraphParser::seenstatemachineend,
this ) ][boost::bind( &StateGraphParser::saveText,
this, _1, _2)]
167 | rootmachineinstantiation;
170 rootmachineinstantiation =
171 keyword_p(
"RootMachine")[boost::bind (&StateGraphParser::startrootmachineinstantiation,
this) ]
172 >> machineinstantiation[ boost::bind( &StateGraphParser::seenrootmachineinstantiation,
this ) ];
176 >> expect_ident( commonparser->
identifier[ boost::bind( &StateGraphParser::seenstatemachinename,
this, _1, _2 )] )
177 >> expect_open( ch_p(
'{' ) )
178 >> statemachinecontent
179 >> expect_end( ch_p(
'}' ) );
182 statemachinecontent = *( varline | transitions | transition) >> *( varline | state);
184 varline = vardec[lambda::var(commonparser->
skipeol) =
false] >> commonparser->
eos[lambda::var(commonparser->
skipeol) =
true];
186 vardec = subMachinedecl | machinememvar | machineparam;
188 machinememvar = ( machineconstant | machinevariable | machinealias )[boost::bind( &StateGraphParser::seenmachinevariable,
this )];
193 machineparam = valuechangeparser->
paramDefinitionParser()[boost::bind( &StateGraphParser::seenmachineparam,
this )];
196 >> machineinstantiation[boost::bind( &StateGraphParser::seensubMachineinstantiation,
this )];
198 machineinstantiation =
199 expect_ident( commonparser->
identifier[ boost::bind( &StateGraphParser::seenmachinetypename,
this, _1, _2 )] )
200 >> expect_ident( commonparser->
identifier[ boost::bind( &StateGraphParser::seeninstmachinename,
this, _1, _2 )] )
202 >> !machineinstarguments
203 >> expect_close_parenth( ch_p(
')' ) ) ) )[ boost::bind( &StateGraphParser::seenmachineinstantiation,
this )];
205 machineinstarguments =
206 machineinstargument >> *(
',' >> machineinstargument );
208 machineinstargument =
209 commonparser->
identifier[ boost::bind( &StateGraphParser::seenmachineinstargumentname,
this, _1, _2 )]
211 >> expressionparser->
parser()[ boost::bind( &StateGraphParser::seenmachineinstargumentvalue,
this )];
214 !(
keyword_p(
"initial" )[boost::bind( &StateGraphParser::seeninitialstate,
this )]
215 |
keyword_p(
"final" )[boost::bind( &StateGraphParser::seenfinalstate,
this )] )
217 >> expect_ident(commonparser->
identifier[ boost::bind( &StateGraphParser::statedef,
this, _1, _2 ) ])
218 >> expect_open(ch_p(
'{' ))
220 >> expect_end_of_state(ch_p(
'}' ))[ boost::bind( &StateGraphParser::seenstateend,
this ) ];
224 statecontent = *statecontentline;
235 | (machinememvar[lambda::var(commonparser->
skipeol) =
false] >> commonparser->
eos[lambda::var(commonparser->
skipeol) =
true]);
237 precondition =
keyword_p(
"precondition")
238 >> conditionparser->
parser()[ boost::bind( &StateGraphParser::seenprecondition,
this)] ;
240 preconditions = (
keyword_p(
"preconditions" )[ boost::bind( &StateGraphParser::inpreconditions,
this )]
241 >> expect_open( ch_p(
'{' ))
242 >> *transline[boost::bind(&StateGraphParser::seenendcondition,
this)]
243 >> expect_end( ch_p(
'}' ) )[
244 boost::bind( &StateGraphParser::seenpreconditions,
this )]) | precondition;
246 entry =
keyword_p(
"entry" )[ boost::bind( &StateGraphParser::inprogram,
this,
"entry" )]
247 >> expect_open(ch_p(
'{'))>> programBody >> expect_end(ch_p(
'}'))[
248 boost::bind( &StateGraphParser::seenentry,
this )];
250 run =
keyword_p(
"run" )[ boost::bind( &StateGraphParser::inprogram,
this,
"run" )]
251 >> expect_open(ch_p(
'{'))>> programBody >> expect_end(ch_p(
'}'))[
252 boost::bind( &StateGraphParser::seenrun,
this )];
254 exit =
keyword_p(
"exit" )[ boost::bind( &StateGraphParser::inprogram,
this,
"exit" )]
255 >> expect_open(ch_p(
'{')) >> programBody >> expect_end(ch_p(
'}'))[
256 boost::bind( &StateGraphParser::seenexit,
this )];
258 handle =
keyword_p(
"handle" )[ boost::bind( &StateGraphParser::inprogram,
this,
"handle" )]
259 >> expect_open(ch_p(
'{'))>> programBody >> expect_end(ch_p(
'}'))[
260 boost::bind( &StateGraphParser::seenhandle,
this )];
281 transitions = (
keyword_p(
"transitions" )
282 >> expect_open(ch_p(
'{'))
283 >> *((transline|eventline)[boost::bind(&StateGraphParser::seenendcondition,
this)])
284 >> expect_end(ch_p(
'}')) );
287 transition =
keyword_p(
"transition") >> expect_event_or_if( transline | eventline )[boost::bind(&StateGraphParser::seenendcondition,
this)];
288 transline = progselect | (ifbranch >> !elsebranch);
292 !peerparser->
parser() >> commonparser->
identifier[ boost::bind( &StateGraphParser::seeneventname,
this,_1,_2)]
293 >> expect_eventargs(argslist[ boost::bind( &StateGraphParser::seeneventargs,
this)])
294 >> expect_eventselect(transline[ boost::bind( &StateGraphParser::seeneventtrans,
this)]);
296 progselect = selector | (program >> (selector | eps_p[boost::bind( &StateGraphParser::noselect,
this )] ));
299 ifbranch =
keyword_p(
"if") >> conditionparser->
parser()[ boost::bind( &StateGraphParser::seencondition,
this)]
302 elsebranch =
keyword_p(
"else")[boost::bind( &StateGraphParser::seenelse,
this )]
306 ch_p(
'{')[ boost::bind( &StateGraphParser::inprogram,
this,
"transition" )]
308 >> expect_end(ch_p(
'}'))[boost::bind( &StateGraphParser::seentransprog,
this )];
310 selector =
keyword_p(
"select" ) >> expect_select_ident(( commonparser->
identifier[ boost::bind( &StateGraphParser::seenselect,
this, _1, _2) ]
311 >> *(
keyword_p(
"or") >> commonparser->
identifier[ boost::bind( &StateGraphParser::seenselect,
this, _1, _2) ])
312 )[lambda::var(commonparser->
skipeol) =
false]
313 >> commonparser->
eos[lambda::var(commonparser->
skipeol) =
true]);
322 ParsedStateMachinePtr ret;
323 if ( rootmachines.empty() )
325 std::vector<ParsedStateMachinePtr> vret =
values( rootmachines );
326 rootmachines.clear();
331 void StateGraphParser::seeninitialstate()
333 curinitialstateflag =
true;
336 void StateGraphParser::seenfinalstate()
338 curfinalstateflag =
true;
345 std::string def(s, f);
346 if ( curtemplate->getState( def ) != 0 )
348 assert( dynamic_cast<StateDescription*>( curtemplate->getState( def ) ) );
353 curstate = existingstate;
354 curstate->
setEntryPoint( mpositer.get_position().line - ln_offset );
358 curstate =
new StateDescription(def, mpositer.get_position().line - ln_offset );
359 curtemplate->addState( curstate );
364 void StateGraphParser::seenstateend()
366 if ( curinitialstateflag )
368 if ( curtemplate->getInitialState() )
370 else curtemplate->setInitialState( curstate );
372 if ( curfinalstateflag )
374 if ( curtemplate->getFinalState() )
376 else curtemplate->setFinalState( curstate );
382 curinitialstateflag =
false;
383 curfinalstateflag =
false;
385 cur_port_events.clear();
388 void StateGraphParser::inprogram(
const std::string& name)
392 assert( progParser != 0 );
405 void StateGraphParser::seenentry()
412 void StateGraphParser::seenexit()
419 void StateGraphParser::seenhandle()
426 void StateGraphParser::seenrun()
433 void StateGraphParser::seentransprog()
435 transProgram = finishProgram();
438 void StateGraphParser::seenelseprog()
445 void StateGraphParser::seenelse()
447 assert( curcondition);
451 void StateGraphParser::seencondition()
453 assert( !curcondition );
455 assert( curcondition );
456 conditionparser->
reset();
457 selectln = mpositer.get_position().line - ln_offset;
460 void StateGraphParser::seeneventname(
iter_t s,
iter_t f)
462 evname = string(s,f);
465 assert(evname.length());
470 if (peer->hasOperation(evname) ) {
473 evname,
"callback" );
476 if ( peer->hasService(evname) ==
false || peer->getService(evname)->hasOperation(
"read") ==
false) {
483 new ArgumentsParser( *expressionparser, context, peer->getService(evname),
487 argslist = argsparser->
parser();
490 void StateGraphParser::seeneventargs()
492 evargs = argsparser->
result();
497 void StateGraphParser::noselect()
501 doselect( curstate->
getName() );
508 std::string state_id(s,f);
512 void StateGraphParser::doselect(
const std::string& state_id )
515 if ( !state_id.empty() ) {
516 if ( curtemplate->getState( state_id ) != 0 )
518 next_state = curtemplate->getState( state_id );
523 curtemplate->addState( next_state );
525 assert( next_state );
530 selectln = mpositer.get_position().line - ln_offset;
532 if (evname.empty()) {
533 if (curcondition == 0)
535 }
else if ( peer->hasService(evname) && peer->getService(evname)->hasOperation(
"read") ) {
537 assert(peer->hasService(evname));
539 if ( global_port_events.count(evname) ){
543 if ( cur_port_events.count(evname) ){
554 evcondition = cur_port_events[evname]->clone();
558 evcondition = global_port_events[evname]->clone();
561 if (curcondition == 0) {
562 curcondition = evcondition;
580 assert( peer->provides()->hasMember(evname) );
582 if (curcondition == 0)
590 res = curtemplate->createEventTransition( peer->provides(), caller, evname, evargs, curstate, next_state, curcondition->
clone(), transProgram );
619 curtemplate->transitionSet( curstate, next_state, curcondition->
clone(), transProgram, rank--, selectln );
622 void StateGraphParser::seenendcondition() {
626 transProgram.reset();
629 void StateGraphParser::seeneventtrans() {
635 void StateGraphParser::seenprecondition()
637 assert( !curcondition );
639 assert( curcondition );
640 conditionparser->
reset();
641 selectln = mpositer.get_position().line - ln_offset;
643 curtemplate->preconditionSet(curstate, curcondition, selectln );
649 void StateGraphParser::seenstatemachineend()
651 assert( curtemplate );
652 assert( ! curstate );
658 if ( curtemplate->getInitialState() == 0 )
660 if ( curtemplate->getFinalState() == 0 )
663 if ( curtemplate->getStateList().empty() )
667 vector<string> states = curtemplate->getStateList();
668 for( vector<string>::const_iterator it = states.begin(); it != states.end(); ++it)
670 assert( dynamic_cast<StateDescription*>( curtemplate->getState( *it ) ) );
678 valuechangeparser->
store( curtemplate->getService() );
679 valuechangeparser->
reset();
683 assert( curtemplate->getInitCommand() == 0);
684 if ( varinitcommands.size() > 1 )
687 for ( std::vector<ActionInterface*>::iterator i = varinitcommands.begin();
688 i != varinitcommands.end(); ++i )
690 curtemplate->setInitCommand( comcom );
692 else if (varinitcommands.size() == 1 )
693 curtemplate->setInitCommand( *varinitcommands.begin() );
695 varinitcommands.clear();
698 for( StateMachine::ChildList::const_iterator it= curtemplate->getChildren().begin();
699 it != curtemplate->getChildren().end(); ++it ) {
709 curtemplate->finish();
715 machinebuilders[curmachinename] = scb;
727 skip_parser_t skip_parser = comment_p(
"#" ) | comment_p(
"//" ) | comment_p(
"/*",
"*/" ) | (space_p - eol_p) | commonparser->
skipper;
730 scanner_t scanner( begin, end, policies );
738 if ( ! production.parse( scanner ) )
745 mpositer.get_position().file, mpositer.get_position().line,
746 mpositer.get_position().column );
748 std::vector<ParsedStateMachinePtr> ret =
values( rootmachines );
749 rootmachines.clear();
752 catch(
const parser_error<std::string, iter_t>& e )
759 mpositer.get_position().file, mpositer.get_position().line,
760 mpositer.get_position().column );
762 catch(
const parser_error<GraphSyntaxErrors, iter_t>& )
769 mpositer.get_position().file, mpositer.get_position().line,
770 mpositer.get_position().column );
778 e.
copy(), mpositer.get_position().file,
779 mpositer.get_position().line, mpositer.get_position().column );
788 delete valuechangeparser;
789 delete expressionparser;
790 delete conditionparser;
794 void StateGraphParser::clear() {
797 valuechangeparser->
reset();
803 transProgram.reset();
811 delete curnonprecstate;
814 curmachinebuilder = 0;
815 curinstantiatedmachine.reset();
821 for( StateMachine::ChildList::const_iterator it= curtemplate->getChildren().begin();
822 it != curtemplate->getChildren().end(); ++it ) {
829 curtemplate->getService()->clear();
835 for ( std::vector<ActionInterface*>::iterator i = varinitcommands.begin();
836 i != varinitcommands.end(); ++ i )
838 varinitcommands.clear();
839 for ( std::vector<ActionInterface*>::iterator i = paraminitcommands.begin();
840 i != paraminitcommands.end(); ++ i )
842 paraminitcommands.clear();
843 for ( machinebuilders_t::iterator i = machinebuilders.begin();
844 i != machinebuilders.end(); ++i )
846 machinebuilders.clear();
850 void StateGraphParser::seenstatemachinename(
iter_t begin,
iter_t end ) {
852 curmachinename = std::string ( begin, end );
855 if ( machinebuilders.count( curmachinename ) != 0 )
862 curobject->setName( curmachinename );
863 curtemplate->setService( curobject );
870 curtemplate->setName( curmachinename,
false );
876 ln_offset = mpositer.get_position().line - 1;
878 saveStartPos = mpositer;
881 void StateGraphParser::saveText(
iter_t begin,
iter_t end ) {
882 assert( curmachinename.length() != 0 );
884 if ( machinebuilders.count( curmachinename ) == 0 )
887 machinebuilders[curmachinename]->item()->setText( std::string( saveStartPos, end) );
891 void StateGraphParser::inpreconditions() {
893 assert( curnonprecstate == 0 );
896 curtemplate->addState( curnonprecstate );
899 void StateGraphParser::seenpreconditions() {
900 curtemplate->transitionSet( curstate, curnonprecstate,
new ConditionTrue, rank--, mpositer.get_position().line - ln_offset );
902 curstate = curnonprecstate;
906 void StateGraphParser::startrootmachineinstantiation() {
910 void StateGraphParser::seenrootmachineinstantiation() {
913 if( rootmachines.find( curinstmachinename ) != rootmachines.end() )
915 rootmachines[curinstmachinename] = curinstantiatedmachine;
919 curinstantiatedmachine->setName( curinstmachinename,
true );
922 if ( context->
provides()->hasService( curinstmachinename ) )
926 context->
provides()->addService( curinstantiatedmachine->getService() );
928 curinstantiatedmachine.reset();
929 curinstmachinename.clear();
932 void StateGraphParser::seensubMachineinstantiation() {
933 if ( find_if( curtemplate->getChildren().begin(),
934 curtemplate->getChildren().end(),
935 boost::bind( equal_to<string>(), boost::bind(&
StateMachine::getName,_1), curinstmachinename )) != curtemplate->getChildren().end() )
943 if ( !context->
provides()->addService( curinstantiatedmachine->getService() ) )
945 "Name clash: name of instantiated machine \"" + curinstmachinename +
946 "\" already used as object name in task '"+context->
getName()+
"'." ));
949 curtemplate->addChild( curinstantiatedmachine );
951 curtemplate->getService()->addService( curinstantiatedmachine->getService() );
953 curinstantiatedmachine->setName(curinstmachinename,
false );
955 curinstantiatedmachine.reset();
956 curinstmachinename.clear();
959 void StateGraphParser::seenmachinetypename(
iter_t begin,
iter_t end ) {
960 assert( curmachinebuilder == 0 );
961 std::string name( begin, end );
962 machinebuilders_t::iterator i = machinebuilders.find( name );
963 if ( i == machinebuilders.end() )
965 curmachinebuilder = i->second;
968 void StateGraphParser::seeninstmachinename(
iter_t begin,
iter_t end ) {
969 assert( curmachinebuilder != 0 );
970 assert( curinstmachinename.empty() );
971 curinstmachinename = std::string( begin, end );
974 void StateGraphParser::seenmachineinstargumentname(
iter_t begin,
iter_t end ) {
975 assert( curmachineinstargumentname.empty() );
976 std::string name( begin, end );
977 curmachineinstargumentname = name;
980 void StateGraphParser::seenmachineinstargumentvalue() {
984 if ( curinstmachineparams.find( curmachineinstargumentname ) != curinstmachineparams.end() )
986 "In initialisation of StateMachine \"" + curinstmachinename +
987 "\": Parameter \"" + curmachineinstargumentname +
"\" initialised twice..." ));
988 curinstmachineparams[curmachineinstargumentname] = value;
989 curmachineinstargumentname.clear();
992 void StateGraphParser::seenmachineinstantiation()
1000 ParsedStateMachinePtr nsc( curmachinebuilder->
build( isroot ) );
1004 machineparams_t params = nsc->getParameters();
1008 for ( machineparamvalues_t::iterator i = curinstmachineparams.begin(); i != curinstmachineparams.end(); ++i )
1010 machineparams_t::iterator j = params.find( i->first );
1011 if ( j == params.end() )
1015 for ( machineparams_t::iterator i = params.begin(); i != params.end(); ++i )
1017 machineparamvalues_t::iterator j = curinstmachineparams.find( i->first );
1018 if ( j == curinstmachineparams.end() )
1020 "No value given for argument \"" + i->first +
"\" in instantiation of this StateMachine." ));
1021 #ifndef ORO_EMBEDDED 1023 paraminitcommands.push_back( i->second->getDataSource()->updateAction( j->second.get() ) );
1030 ActionInterface* ret = i->second->getDataSource()->updateAction( j->second.get());
1032 paraminitcommands.push_back( ret );
1038 curinstantiatedmachine = nsc;
1042 if ( paraminitcommands.size() > 0 )
1045 for ( std::vector<ActionInterface*>::iterator i = paraminitcommands.begin();
1046 i != paraminitcommands.end(); ++i )
1049 if ( curinstantiatedmachine->getInitCommand() )
1050 comcom->
add( curinstantiatedmachine->getInitCommand() );
1051 curinstantiatedmachine->setInitCommand( comcom );
1053 paraminitcommands.clear();
1055 curmachinebuilder = 0;
1056 curinstmachineparams.clear();
1059 curinstantiatedmachine->getService()->setName(curinstmachinename );
1062 void StateGraphParser::seenmachinevariable() {
1063 std::vector<ActionInterface*> acv = valuechangeparser->
assignCommands();
1064 for(std::vector<ActionInterface*>::iterator it = acv.begin(); it!=acv.end(); ++it)
1065 varinitcommands.push_back( *it );
1067 valuechangeparser->
clear();
1070 void StateGraphParser::seenmachineparam() {
1071 std::vector<std::string> pnames = valuechangeparser->
definedNames();
1072 std::vector<AttributeBase*> tbases = valuechangeparser->
definedValues();
1073 assert( pnames.size() == tbases.size() );
1074 for (
unsigned int i = 0; i < pnames.size(); ++i)
1075 curtemplate->addParameter( pnames[i] , tbases[i] );
1077 valuechangeparser->
clear();
ProgramInterface * getHandleProgram() const
Get the handle program of this State.
#define keyword_p(word)
Returns a rule which parses a keyword followed by a non-identifier character, newline or semicolon...
std::vector< base::DataSourceBase::shared_ptr > result()
Get the parsed internal::DataSource's.
DataSource is a base class representing a generic way to read data of type T.
void setEntryProgram(ProgramInterfacePtr entry)
std::vector< base::AttributeBase * > definedValues()
rule_t eos
End Of Statement Parser.
ConditionInterface * getParseResult()
Call this to get the parsed condition.
Service::shared_ptr provides()
Returns this Service.
rule_t & aliasDefinitionParser()
The parser that parses alias definitions.
A conditional that evaluates and caches another Condition.
void setHandleProgram(ProgramInterfacePtr handle)
void reset()
After reset, peer() == current context and object() == "this".
ProgramInterfacePtr bodyParserResult()
void setRunProgram(ProgramInterfacePtr run)
void setEntryPoint(int line)
This interface represents the concept of a condition which can be evaluated and return true or false...
const std::string & getName() const
This method must be overloaded to get a useful hierarchy.
const std::string & getName() const
Get the name of this state.
bool skipeol
Saves eol skipping state.
A conditional that evaluates true.
This class represents a state with all actions stored in an external program.
StateDescription * postponeState()
This function returns a new state that contains all the data of this state ( its handle, entry, exit programs, and its name and inited state ), while this state's data is reset ( i.e.
StateGraphParser(iter_t &positer, TaskContext *tc, ExecutionEngine *caller, CommonParser *cp)
void reset()
Completely clear all data and erase all parsed definitions from the taskcontext given in the construc...
virtual ConditionInterface * clone() const =0
The Clone Software Pattern.
Compose an 'AND' function of two Conditions.
parse_exception class that is used for various semantic errors for which it was not worth defining a ...
A Parser for Orocos Program Scripts.
boost::shared_ptr< ProgramInterface > ProgramInterfacePtr
A general compare condition.
virtual parse_exception * copy() const =0
void initBodyParser(const std::string &name, Service::shared_ptr stck, int offset)
Initialize the bodyParser to parse and store each statement it sees.
This is a parser that you construct to parse a set of arguments.
This is an exception class that keeps a parse_exception pointer along with the location in the file a...
This class contains some very common parser definitions.
void storeOffset()
Stores the current position in the input stream (iterator received from the constructor) in order to ...
This exception is thrown if the target and source type of an assignment of a DataSource with a base::...
parse_exception class that is used for various syntactic errors for which it was not worth defining a...
An execution engine serialises (executes one after the other) the execution of all commands...
A conditional that evaluates to the inverse of another Condition.
void store(Service::shared_ptr other)
Store allDefinedNames() in a service.
scanner< iter_t, scanner_pol_t > scanner_t
How we parse: this parser works like a stack-based RPN calculator.
ProgramInterface * getEntryProgram() const
Get the entry program of this State.
ParsedStateMachinePtr getParserResult()
Returns the last state machine instantiation of parser() or null if no instantiations were seen...
void setExitProgram(ProgramInterfacePtr exit)
skip_parser_iteration_policy< skip_parser_t > iter_pol_t
boost::shared_ptr< StateMachineService > getService() const
Get the peer and object from an invocation path like a.b.c.d() .
ServicePtr taskObject()
Returns the last matching Service or zero if not found.
functor_parser< eol_skip_functor > skipper
End Of Statement Parser.
Based on the software pattern 'command', this interface allows execution of action objects...
std::vector< std::string > definedNames()
base::DataSourceBase::shared_ptr getResult()
This is the uppermost exception class in the parser system.
This class is responsible for parsing constant definitions, variable definitions, variable change ins...
rule_t & bodyParser()
Parses a multi-line program, which you can retrieve with bodyParserResult().
A Condition which holds a boolean DataSource.
ProgramInterface * getRunProgram() const
Get the run program of this State.
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
parse_exception class that is used for fatal semantic errors for which it was not worth defining a pr...
A DataSource which holds a constant value and returns it in its get() method.
void clear()
Clear assignCommands(), definedValues() and definedNames().
rule_t & paramDefinitionParser()
The parser that parses state context parameter definitions.
rule_t & constantDefinitionParser()
the parser that parses definitions of constants.
rule_t & variableDefinitionParser()
the parser that parses variable definitions, don't forget to check assignCommand after a variable def...
virtual void add(base::ActionInterface *com)
add a command to the vect
The TaskContext is the C++ representation of an Orocos component.
Exception thrown when a factory is requested to create an object, but a wrong argument type was given...
std::vector< base::ActionInterface * > assignCommands()
ParsedStateMachinePtr build(bool instantiate)
Throws wrong_context_params_exception if params is wrong...
std::vector< typename MapT::mapped_type > values(const MapT &map)
rule_t & parser()
The parser tries to traverse a full peer-to-object path and throws if it got stuck in the middle...
Exception thrown when a factory is requested to create an object but the wrong number of arguments wa...
boost::intrusive_ptr< DataSourceBase > shared_ptr
Use this type to store a pointer to a DataSourceBase.
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
State machine created by the scripting engine which represents a parsed state machine.
rule_t & parser()
Returns the top-level parser for state machines.
A State contains an entry, run, handle and exit program.
This is a class containing a parse function for conditions.
scanner_policies< iter_pol_t > scanner_pol_t
Based on the software pattern 'composite', this class RTT_SCRIPTING_API allows composing command obje...
const ExecutionEngine * engine() const
Get a const pointer to the ExecutionEngine of this Task.
ProgramInterface * getExitProgram() const
Get the exit program of this State.
This class represents a stateMachine as a Service in the Orocos TaskContext system.
std::vector< ParsedStateMachinePtr > parse(iter_t &begin, iter_t end)
Exception thrown when a factory is requested to produce an asynchronous object while it is not availa...
virtual const std::string & getName() const
Returns the name of this TaskContext.