data: Extended CxxParser to detect elements

Detects most elements in the code, currently classes, structs, global variables, fields, functions, methods, namespaces
and enums. The structs ParseLocation and ParseVariable are helper objects to transmit information to the ParserClient.
Currently the parsed information only gets logged in the Storage.

review id = 15

fortune cookie message = In dreams and in life, nothing is impossible.
This commit is contained in:
Eberhard Graether
2014-05-19 12:51:00 +02:00
parent bb6640369a
commit 38c8aaebe8
15 changed files with 738 additions and 68 deletions
+56 -3
View File
@@ -2,6 +2,8 @@
#include <sstream>
#include "data/parser/ParseLocation.h"
#include "data/parser/ParseVariable.h"
#include "utility/logging/logging.h"
Storage::Storage()
@@ -12,10 +14,61 @@ Storage::~Storage()
{
}
void Storage::addClass(const ParseObject& object)
void Storage::onClassParsed(const ParseLocation& location, const std::string& fullName, AccessType access)
{
log("class", fullName, location);
}
void Storage::onStructParsed(const ParseLocation& location, const std::string& fullName, AccessType access)
{
log("struct", fullName, location);
}
void Storage::onGlobalVariableParsed(const ParseLocation& location, const ParseVariable& variable)
{
log("global", variable.fullName, location);
}
void Storage::onFieldParsed(const ParseLocation& location, const ParseVariable& variable, AccessType access)
{
log("field", variable.fullName, location);
}
void Storage::onFunctionParsed(
const ParseLocation& location, const std::string& fullName, const std::string& returnTypeName,
const std::vector<ParseVariable>& parameters
)
{
log("function", fullName, location);
}
void Storage::onMethodParsed(
const ParseLocation& location, const std::string& fullName, const std::string& returnTypeName,
const std::vector<ParseVariable>& parameters, AccessType access, AbstractionType abstraction,
bool isConst, bool isStatic
)
{
log("method", fullName, location);
}
void Storage::onNamespaceParsed(const ParseLocation& location, const std::string& fullName)
{
log("namespace", fullName, location);
}
void Storage::onEnumParsed(const ParseLocation& location, const std::string& fullName, AccessType access)
{
log("enum", fullName, location);
}
void Storage::onEnumFieldParsed(const ParseLocation& location, const std::string& fullName)
{
log("enum field", fullName, location);
}
void Storage::log(std::string type, std::string str, const ParseLocation& location) const
{
std::stringstream info;
info << "class " << object.name
<< " <" << object.fileName << " " << object.lineNumber << ":" << object.columnNumber << ">";
info << type << ": " << str << " <" << location.file << " " << location.line << ":" << location.column << ">";
LOG_INFO(info.str());
}