42 #include "../Service.hpp" 43 #include "../types/Types.hpp" 44 #include "../Attribute.hpp" 45 #include "../TaskContext.hpp" 46 #include "../types/GlobalsRepository.hpp" 49 #include <boost/bind.hpp> 50 #include <boost/lambda/bind.hpp> 51 #include <boost/lambda/construct.hpp> 60 using namespace detail;
64 using namespace boost;
67 boost::spirit::classic::assertion<std::string> expect_open(
"Open brace expected.");
68 boost::spirit::classic::assertion<std::string> expect_close(
"Closing brace expected (or could not find out what this line means).");
69 boost::spirit::classic::assertion<std::string> expect_type(
"Unknown type. Please specify a type.");
70 boost::spirit::classic::assertion<std::string> expect_def(
"Expected a type definition. Please specify a type.");
71 boost::spirit::classic::assertion<std::string> expect_expr(
"Expected a valid expression.");
72 boost::spirit::classic::assertion<std::string> expect_ident(
"Expected a valid identifier.");
73 boost::spirit::classic::assertion<std::string> expect_init(
"Expected an initialisation value of the variable.");
74 boost::spirit::classic::assertion<std::string> expect_cis(
"Expected a initialisation ('=') of const.");
75 boost::spirit::classic::assertion<std::string> expect_ais(
"Expected a initialisation ('=') of alias.");
76 boost::spirit::classic::assertion<std::string> expect_index(
"Expected an index: [index].");
77 boost::spirit::classic::assertion<std::string> expect_integer(
"Expected a positive integer expression.");
78 boost::spirit::classic::assertion<std::string> expect_change(
"Expected a variable assignment after 'set'.");
79 boost::spirit::classic::assertion<std::string> expect_decl(
"Expected a declaration list.");
84 : type( 0 ), context( pc ), mstore( storage ? storage : pc->provides() ),
85 expressionparser( pc, caller, cp ), commonparser(cp), sizehint(-1),
94 BOOST_SPIRIT_DEBUG_RULE(
vardecl );
104 # define RULE( name, def ) \ 105 boost_spirit::contiguous<boost_spirit::positive<boost_spirit::chset<char> > > name = (def) 113 chset<> identchar(
"a-zA-Z-_0-9/<>." );
114 RULE( type_name, lexeme_d[ +identchar ] );
134 >> expect_ais( ch_p(
'=') )
170 assert( expr.get() );
174 if ( i.get() == 0 ) {
177 (
"Attempt to initialize "+typen+
" "+
valuename+
" with a "+expr->getTypeName()+
", expected an integer expression. Use ' = "+expr->getTypeName()+
"( arg )' instead to use the constructor." );
179 if ( i->get() < 0 ) {
180 std::stringstream value;
184 (
"Attempt to initialize "+typen+
" "+
valuename+
" with an expression leading to a negative number "+value.str()
185 +
". Initialization expressions are evaluated once at parse time !" );
187 if ( i->get() == 0 ) {
189 "Attempt to initialize "<<typen<<
" "<<
valuename<<
" with an expression leading to zero (0)" 190 <<
". Initialization expressions are evaluated once at parse time !" <<
Logger::endl;
211 (
"Attempt to initialize a const "+
type->
getTypeName()+
" with a "+expr->getTypeName()+
"." );
222 std::string name( begin, end );
223 if (
mstore->getValue( name ) ) {
226 "\" is already defined in " +
mstore->getName() );
234 std::string name( begin, end );
250 "Attempt to define an alias of type "+
type->
getTypeName()+
" to an expression of type "+expr->getTypeName()+
"." );
252 mstore->setValue( alias );
307 (
"Attempt to initialize a var "+var->
getDataSource()->getTypeName()+
" with a "+ expr->getTypeName() +
"." );
319 if ( o->getValue( *it ) == 0 ) {
320 o->setValue(
mstore->getValue(*it)->clone() );
330 vector<string> predefinednames = s->getAttributeNames();
331 for(std::vector<std::string>::iterator it = predefinednames.begin();
332 it != predefinednames.end(); ++it) {
333 if (
mstore->getValue(*it) == 0) {
335 mstore->setValue( s->getValue(*it)->clone() );
361 mstore->removeValue( *it );
boost::shared_ptr< types::TypeInfoRepository > typerepos
void storedefinitionname(iter_t begin, iter_t end)
void load(Service::shared_ptr source)
rule_t & aliasDefinitionParser()
const std::string & getTypeName() const
rule_t & bareDefinitionParser()
rule_t valuechange_parsers
This interface represents the concept of a condition which can be evaluated and return true or false...
virtual DataSourceBase::shared_ptr getDataSource() const =0
Service::shared_ptr mstore
ConditionInterface * getCmdResult()
std::vector< scripting::ConditionInterface * > conditions
This class contains some very common parser definitions.
void seenconstantdefinition()
boost::shared_ptr< Service > shared_ptr
void store(Service::shared_ptr other)
std::vector< base::AttributeBase * > definedvalues
base::AttributeBase * buildConstant(std::string name, base::DataSourceBase::shared_ptr source, int sizehint) const
void seenaliasdefinition()
std::vector< base::ActionInterface * > assigncommands
static std::ostream & endl(std::ostream &__os)
Based on the software pattern 'command', this interface allows execution of action objects...
CommonParser & commonparser
base::DataSourceBase::shared_ptr getResult()
base::AttributeBase * buildAlias(std::string name, base::DataSourceBase::shared_ptr b) const
std::vector< std::string > definednames
ExpressionParser expressionparser
base::AttributeBase * buildVariable(std::string name, int sizehint) const
rule_t & paramDefinitionParser()
rule_t & constantDefinitionParser()
std::vector< std::string > alldefinednames
rule_t & variableDefinitionParser()
rule_t constantdefinition
void seenbaredefinition()
boost::intrusive_ptr< DataSourceBase > shared_ptr
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
void seenvariabledefinition()
ValueChangeParser(TaskContext *tc, CommonParser &cp, Service::shared_ptr storage, ExecutionEngine *caller)
void seentype(iter_t begin, iter_t end)
rule_t variabledefinition