* added classes that represent different name kinds * rewrote NameResolvers to return the new name classes instead of NameElement and NameHierarchy * removed DataType classes since their functionality moved to the CxxTypeName class.
81 lines
1.8 KiB
C++
81 lines
1.8 KiB
C++
#include "data/parser/ParserClient.h"
|
|
|
|
#include <sstream>
|
|
|
|
#include "data/parser/ParseLocation.h"
|
|
#include "utility/utilityString.h"
|
|
|
|
std::string ParserClient::addAccessPrefix(const std::string& str, AccessKind access)
|
|
{
|
|
switch (access)
|
|
{
|
|
case ACCESS_PUBLIC:
|
|
return "public " + str;
|
|
case ACCESS_PROTECTED:
|
|
return "protected " + str;
|
|
case ACCESS_PRIVATE:
|
|
return "private " + str;
|
|
case ACCESS_DEFAULT:
|
|
return "default " + str;
|
|
default:
|
|
break;
|
|
}
|
|
return str;
|
|
}
|
|
|
|
std::string ParserClient::addStaticPrefix(const std::string& str, bool isStatic)
|
|
{
|
|
if (isStatic)
|
|
{
|
|
return "static " + str;
|
|
}
|
|
return str;
|
|
}
|
|
|
|
std::string ParserClient::addConstPrefix(const std::string& str, bool isConst, bool atFront)
|
|
{
|
|
if (isConst)
|
|
{
|
|
return atFront ? "const " + str : str + " const";
|
|
}
|
|
return str;
|
|
}
|
|
|
|
std::string ParserClient::addLocationSuffix(const std::string& str, const ParseLocation& location)
|
|
{
|
|
std::stringstream ss;
|
|
ss << str;
|
|
ss << " <" << location.startLineNumber << ":" << location.startColumnNumber << " ";
|
|
ss << location.endLineNumber << ":" << location.endColumnNumber << ">";
|
|
return ss.str();
|
|
}
|
|
|
|
std::string ParserClient::addLocationSuffix(
|
|
const std::string& str, const ParseLocation& location, const ParseLocation& scopeLocation
|
|
){
|
|
if (!location.isValid())
|
|
{
|
|
return addLocationSuffix(str, scopeLocation);
|
|
}
|
|
else if (!scopeLocation.isValid())
|
|
{
|
|
return addLocationSuffix(str, location);
|
|
}
|
|
|
|
std::stringstream ss;
|
|
ss << str;
|
|
ss << " <" << scopeLocation.startLineNumber << ":" << scopeLocation.startColumnNumber;
|
|
ss << " <" << location.startLineNumber << ":" << location.startColumnNumber << " ";
|
|
ss << location.endLineNumber << ":" << location.endColumnNumber << "> ";
|
|
ss << scopeLocation.endLineNumber << ":" << scopeLocation.endColumnNumber << ">";
|
|
return ss.str();
|
|
}
|
|
|
|
ParserClient::ParserClient()
|
|
{
|
|
}
|
|
|
|
ParserClient::~ParserClient()
|
|
{
|
|
}
|