Orocos Real-Time Toolkit  2.5.0
ScriptParser.hpp
00001 #ifndef RTT_SCRIPTING_PARSER_HPP
00002 #define RTT_SCRIPTING_PARSER_HPP
00003 
00004 #include "parser-types.hpp"
00005 
00006 #include <map>
00007 #include <string>
00008 #include <boost/function.hpp>
00009 #include <boost/shared_ptr.hpp>
00010 #include "../internal/DataSource.hpp"
00011 #include "../Service.hpp"
00012 
00013 namespace RTT
00014 {
00015     namespace scripting
00016     {
00017 
00021         class ScriptParser
00022         {
00023             // Our task we are parsing in :
00024             TaskContext* context;
00025             // The task that will execute it:
00026             ExecutionEngine* caller;
00027             // The storage for top-level variables
00028             Service::shared_ptr storage;
00029             our_pos_iter_t& mpositer;
00030             our_pos_iter_t saveStartPos;
00031             // running offset
00032             int ln_offset;
00033             std::string program_text;
00034 
00035             rule_t production;
00036             rule_t statement;
00037             rule_t program;
00038             rule_t function;
00039             rule_t statemachine;
00040 
00041             CommonParser* commonparser;
00042             StateGraphParser* stateparser;
00043             ProgramGraphParser* programparser;
00044 
00045             void clear();
00046 
00047             void seenstatement();
00048             void seenprogram();
00049             void seenfunction();
00050             void seenstatemachine();
00051 
00052         public:
00058             ScriptParser(iter_t& positer, TaskContext* tc, ExecutionEngine* caller);
00059             ~ScriptParser();
00060 
00067             void parse(iter_t& begin, iter_t end);
00068 
00078             base::DataSourceBase::shared_ptr parseExcerpt(iter_t& begin,
00079                     iter_t end);
00080 
00081         };
00082     }
00083 }
00084 
00085 #endif