From c2955dee564e52da78154b6f93089e06db50988c Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Wed, 31 Dec 2014 21:27:09 +0100 Subject: [PATCH] [DEV] update function interface --- eci/File.cpp | 90 ++++++++++++++++++++++++++++++++++++++++-- eci/File.h | 3 ++ eci/Function.h | 5 +++ eci/lang/ParserCpp.cpp | 2 +- 4 files changed, 96 insertions(+), 4 deletions(-) diff --git a/eci/File.cpp b/eci/File.cpp index 96a4b29..6e3b829 100644 --- a/eci/File.cpp +++ b/eci/File.cpp @@ -16,22 +16,106 @@ static std::string getValue(const std::string& _file, const std::shared_ptrgetStartPos(), _it->getStopPos()-_it->getStartPos()); } +eci::Variable getVariableWithType(const std::string& _value) { + eci::Variable ret; + if (_value == "void") { + + } else if ( _value == "int" + || _value == "int32_t" + || _value == "signed int") { + + } else if ( _value == "unsigned int" + || _value == "uint32_t") { + + } else if ( _value == "short" + || _value == "int16_t" + || _value == "signed short") { + + } else if ( _value == "unsigned short" + || _value == "uint16_t") { + + } else if ( _value == "char" + || _value == "int8_t" + || _value == "signed char") { + + } else if ( _value == "unsigned char" + || _value == "uint8_t") { + + } else if ( _value == "long" + || _value == "int64_t" + || _value == "signed long") { + + } else if ( _value == "unsigned long" + || _value == "uint64_t") { + + } else if (_value == "bool") { + + } else if (_value == "size_t") { + + } else { + ECI_ERROR("get variable with type : " << _value << "' << NOT parsed !!!!" ); + } + return ret; +} + eci::File::File(const std::string& _filename) { m_fileName = _filename; m_fileData = etk::FSNodeReadAllData(_filename); eci::ParserCpp tmpParser; tmpParser.parse(m_fileData); + + // all we need all the time: + std::vector returnList; + std::vector argumentList; + std::string name; std::string value; + std::shared_ptr lastClass; + std::shared_ptr lastFunction; + std::shared_ptr lastVariable; + enum eci::visibility lastVisibility = eci::visibilityPublic; + for (auto &it : tmpParser.m_result.m_list) { + value = getValue(m_fileData, it); switch (it->getTockenId()) { case tokenCppVisibility: - ECI_INFO("get visibility : " << getValue(m_fileData, it) << "'" ); + ECI_INFO("get visibility : " << value << "'" ); + if (value == "private") { + lastVisibility = eci::visibilityPrivate; + } else if (value == "public") { + lastVisibility = eci::visibilityPublic; + } else if (value == "protected") { + lastVisibility = eci::visibilityProtected; + //} else if (value == "inline") { + + //} else if (value == "const") { + + //} else if (value == "virtual") { + + //} else if (value == "friend") { + + //} else if (value == "extern") { + + //} else if (value == "register") { + + //} else if (value == "static") { + + //} else if (value == "volatile") { + + } else { + ECI_ERROR("get visibility : " << value << "' << NOT parsed !!!!" ); + } break; case tokenCppType: - ECI_INFO("get type : " << getValue(m_fileData, it) << "'" ); + ECI_INFO("get type : " << value << "'" ); + if (name == "") { + returnList.push_back(getVariableWithType(value)); + } else { + ECI_ERROR(" get type : " << value << "' after name !!!" ); + } break; case tokenCppString: - ECI_INFO("get string : " << getValue(m_fileData, it) << "'" ); + ECI_INFO("get string : " << value << "'" ); + name = value; break; } } diff --git a/eci/File.h b/eci/File.h index 77f3967..e390577 100644 --- a/eci/File.h +++ b/eci/File.h @@ -23,6 +23,9 @@ namespace eci { protected: std::string m_fileName; //!< Name of the file. std::string m_fileData; //!< Data of the file. + std::vector> m_listFunction; // all function in the file + std::vector> m_listClass; // all class in the file + std::vector> m_listVariable; // all variable in the file }; } diff --git a/eci/Function.h b/eci/Function.h index 06f2269..7c34a13 100644 --- a/eci/Function.h +++ b/eci/Function.h @@ -29,6 +29,11 @@ namespace eci { std::vector m_arguments; //!< return value. std::vector> call(const std::vector>& _input); + + // 3 step: + // - first get Tockens (returns , names, const, parameters, codes + // - interpreted all of this ... no link on variables + // - all is linked }; } diff --git a/eci/lang/ParserCpp.cpp b/eci/lang/ParserCpp.cpp index ea7dfd8..7a20cbe 100644 --- a/eci/lang/ParserCpp.cpp +++ b/eci/lang/ParserCpp.cpp @@ -35,7 +35,7 @@ eci::ParserCpp::ParserCpp() { m_lexer.append(tokenCppHookOut, "\\]"); m_lexer.append(tokenCppBranch, "\\b(return|goto|if|else|case|default|break|continue|while|do|for)\\b"); m_lexer.append(tokenCppSystem, "\\b(new|delete|try|catch)\\b"); - m_lexer.append(tokenCppType, "\\b(bool|char(16_t|32_t)?|double|float|u?int(8|16|32|64|128)?(_t)?|long|short|signed|size_t|unsigned|void|(I|U)(8|16|32|64|128))\\b"); + m_lexer.append(tokenCppType, "\\b(bool|char(16_t|32_t)?|double|float|u?int(8|16|32|64|128)?(_t)?|long|short|signed|size_t|unsigned|void)\\b"); m_lexer.append(tokenCppVisibility, "\\b(inline|const|virtual|private|public|protected|friend|const|extern|register|static|volatile)\\b"); m_lexer.append(tokenCppContener, "\\b(class|namespace|struct|union|enum)\\b"); m_lexer.append(tokenCppTypeDef, "\\btypedef\\b");