39 #include "../internal/DataSourceCommand.hpp" 42 #include "../internal/GlobalEngine.hpp" 48 using namespace boost;
52 using namespace detail;
57 log(
Debug) <<
"WARNING: Parser does not know which TaskContext is executing (calling) the parsed code. Using Global Engine. Please specify the caller explicitly in order to avoid any asynchronous operation problems." <<endlog();
64 our_pos_iter_t parsebegin( script.begin(), script.end(), filename );
71 gram.parse( parsebegin, parseend );
76 exc.
copy(), parsebegin.get_position().file,
77 parsebegin.get_position().line, parsebegin.get_position().column );
84 our_pos_iter_t parsebegin(
function.begin(),
function.end(), filename );
85 our_pos_iter_t parseend(
function.end(),
function.end(), filename );
96 our_pos_iter_t parsebegin( program.begin(), program.end(), filename );
112 our_pos_iter_t parsebegin( program.begin(), program.end(), filename );
120 ret = gram.
parse( parsebegin, parseend );
125 exc.
copy(), parsebegin.get_position().file,
126 parsebegin.get_position().line, parsebegin.get_position().column );
135 our_pos_iter_t parsebegin( scopy.begin(), scopy.end(),
"teststring" );
136 our_pos_iter_t parseend( scopy.end(), scopy.end(),
"teststring" );
143 parse( parsebegin, parseend, parser.parser(),
SKIP_PARSER );
149 catch(
const parser_error<std::string, iter_t>& e )
179 catch(
const parser_error<std::string, iter_t>& e )
210 parse( parsebegin, parseend, parser.parser(),
SKIP_PARSER );
216 catch(
const parser_error<std::string, iter_t>& e )
223 std::vector<ActionInterface*> acv = parser.assignCommands();
225 if ( acv.empty() && parser.lastDefinedValue() ) {
226 return parser.lastDefinedValue()->getDataSource();
228 if ( acv.size() == 1 ) {
235 return parser.lastDefinedValue()->getDataSource();
237 else if (acv.size() > 1) {
ParsedFunctions parseFunction(const std::string &s, TaskContext *, const std::string &filename="stream")
Reads out the string, parses it, and returns a new FunctionGraph.
Service::shared_ptr provides()
Returns this Service.
This is not a parser in the Boost.spirit sense of the word, it's just a class used to hold the parser...
#define SKIP_PARSER
When using this macro, you must have a boolean variable skipref defined.
This interface represents the concept of a condition which can be evaluated and return true or false...
virtual void readArguments()=0
This is invoked some time before execute() at a time when the action may read its function arguments...
base::DataSourceBase::shared_ptr parseValueStatement(const std::string &s, TaskContext *)
Parses a whole value manipulation/creation statement.
A Parser for Orocos Program Scripts.
virtual parse_exception * copy() const =0
This is an exception class that keeps a parse_exception pointer along with the location in the file a...
void runScript(std::string const &code, TaskContext *mowner, ScriptingService *service, std::string const &filename)
Runs all statements in code.
This class contains some very common parser definitions.
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...
How we parse: this parser works like a stack-based RPN calculator.
ConditionInterface * parseCondition(const std::string &s, TaskContext *)
Parses the string as a condition, and returns a new ConditionInterface.
position_iterator< our_iterator_t > our_pos_iter_t
ParsedStateMachines parseStateMachine(const std::string &s, TaskContext *, const std::string &filename="stream")
Reads out the string, parses it, and returns a new ParsedStateMachine.
static RTT_API ExecutionEngine * Instance()
This is an overloaded member function, provided for convenience. It differs from the above function o...
virtual bool execute()=0
Execute the functionality of this action.
std::vector< ProgramInterfacePtr > ParsedPrograms
List of parsed programs.
virtual void reset()
Some conditions need to be reset at some points.
Based on the software pattern 'command', this interface allows execution of action objects...
base::DataSourceBase::shared_ptr getResult()
This is the uppermost exception class in the parser system.
std::vector< ProgramInterfacePtr > ParsedFunctions
List of parsed functions.
This class is responsible for parsing constant definitions, variable definitions, variable change ins...
base::DataSourceBase::shared_ptr parseExpression(const std::string &s, TaskContext *)
Parses the expression in s.
std::vector< ProgramInterfacePtr > parse(iter_t &begin, iter_t end)
Tries to parse programs, returns the generated programs on success.
std::vector< ProgramInterfacePtr > parseFunction(iter_t &begin, iter_t end)
A class that wraps a Command in a internal::DataSource<bool> interface.
An exception which a parser may throw to indicate that it failed to understand the input...
ParsedPrograms parseProgram(const std::string &s, TaskContext *, const std::string &filename="stream")
Reads out the string, parses it, and returns a new ProgramGraph.
The TaskContext is the C++ representation of an Orocos component.
std::vector< ParsedStateMachinePtr > ParsedStateMachines
List of parsed State Machines.
Parsers and executes any RTT script you throw at it.
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.
This interface allows to load program scripts and state machines and allows execution of code...
This is a class containing a parse function for conditions.
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.
std::vector< ParsedStateMachinePtr > parse(iter_t &begin, iter_t end)
base::DataSourceBase::shared_ptr parseValueChange(const std::string &s, TaskContext *)
Parses a change of a value in s.