NIREP
|
00001 00004 #pragma once 00005 #ifndef _NIREP_FUNCTION_PARSE_ENGINE_H_ 00006 #define _NIREP_FUNCTION_PARSE_ENGINE_H_ 00007 00008 #include <string> 00009 #include <vector> 00010 #include <map> 00011 00012 struct Node { 00013 Node * root; 00014 std::vector<Node*> child; 00015 std::string function; 00016 }; 00017 00018 struct func_info { 00019 std::string func; 00020 std::string (*ptr)(std::vector<std::string>); 00021 }; 00022 00023 class NIREPFunctionParseEngine 00024 { 00025 public: 00026 Node * root; 00027 Node * node; 00028 Node * current; 00029 00030 std::vector<Node *> lst; 00031 std::vector<func_info> func_list; 00032 00033 std::string str; 00034 00035 std::map<std::string,std::string> cache; 00036 00037 int tablecnt; 00038 00039 public: 00040 NIREPFunctionParseEngine(void); 00041 public: 00042 ~NIREPFunctionParseEngine(void); 00043 00044 std::string CallBackHandler(); 00045 std::string Evaluate(); 00046 std::string functionHandler(std::string str, std::string::size_type loc); 00047 std::string operatorHandler(std::string str, std::string::size_type loc); 00048 std::string endHandler(std::string str, std::string::size_type loc); 00049 std::string DispatchCallBack(std::string func, std::vector<std::string> para); 00050 00051 std::string removeSpaceTabNewLineReturn(std::string str); 00052 00053 bool CheckMismatchParenthesis(std::string str); 00054 bool CheckUndefinedFunction(); 00055 00056 void EvaluateString(std::string str); 00057 void AddCallback(std::string fn, std::string (*func)(std::vector<std::string>)); 00058 void SetString(std::string str); 00059 void Delete(); 00060 00061 00062 00063 }; 00064 00065 #endif