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 ProgramGraphParser* statementparser; 00045 00046 void clear(); 00047 00048 void seenstatement(); 00049 void seenprogram(); 00050 void seenfunction(); 00051 void seenstatemachine(); 00052 00053 error_status<> handle_no_function(scanner_t const& scan, parser_error<std::string, iter_t>&e ); 00054 00055 public: 00061 ScriptParser(iter_t& positer, TaskContext* tc, ExecutionEngine* caller); 00062 ~ScriptParser(); 00063 00070 void parse(iter_t& begin, iter_t end); 00071 00081 base::DataSourceBase::shared_ptr parseExcerpt(iter_t& begin, 00082 iter_t end); 00083 00084 }; 00085 } 00086 } 00087 00088 #endif