2014-12-04 16:19:47 +00:00
|
|
|
|
2014-12-03 15:40:37 +00:00
|
|
|
#include <libsolidity/InterfaceHandler.h>
|
|
|
|
#include <libsolidity/AST.h>
|
|
|
|
#include <libsolidity/CompilerStack.h>
|
2015-01-08 23:22:06 +00:00
|
|
|
using namespace std;
|
2014-12-03 15:40:37 +00:00
|
|
|
|
2014-12-04 22:55:47 +00:00
|
|
|
namespace dev
|
|
|
|
{
|
|
|
|
namespace solidity
|
|
|
|
{
|
2014-12-03 15:40:37 +00:00
|
|
|
|
2014-12-03 16:46:04 +00:00
|
|
|
/* -- public -- */
|
|
|
|
|
2014-12-03 15:40:37 +00:00
|
|
|
InterfaceHandler::InterfaceHandler()
|
|
|
|
{
|
2014-12-05 14:50:39 +00:00
|
|
|
m_lastTag = DocTagType::NONE;
|
2014-12-03 15:40:37 +00:00
|
|
|
}
|
|
|
|
|
2014-12-12 15:49:26 +00:00
|
|
|
std::unique_ptr<std::string> InterfaceHandler::getDocumentation(ContractDefinition const& _contractDef,
|
2014-12-05 14:50:39 +00:00
|
|
|
DocumentationType _type)
|
2014-12-03 15:40:37 +00:00
|
|
|
{
|
|
|
|
switch(_type)
|
|
|
|
{
|
2014-12-05 14:50:39 +00:00
|
|
|
case DocumentationType::NATSPEC_USER:
|
2014-12-03 15:40:37 +00:00
|
|
|
return getUserDocumentation(_contractDef);
|
2014-12-05 14:50:39 +00:00
|
|
|
case DocumentationType::NATSPEC_DEV:
|
2014-12-03 15:40:37 +00:00
|
|
|
return getDevDocumentation(_contractDef);
|
2014-12-05 14:50:39 +00:00
|
|
|
case DocumentationType::ABI_INTERFACE:
|
2014-12-03 15:40:37 +00:00
|
|
|
return getABIInterface(_contractDef);
|
2015-01-08 23:22:06 +00:00
|
|
|
case DocumentationType::ABI_SOLIDITY_INTERFACE:
|
|
|
|
return getABISolidityInterface(_contractDef);
|
2014-12-03 15:40:37 +00:00
|
|
|
}
|
|
|
|
|
2014-12-05 11:08:26 +00:00
|
|
|
BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Unknown documentation type"));
|
2014-12-03 15:40:37 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2014-12-12 15:49:26 +00:00
|
|
|
std::unique_ptr<std::string> InterfaceHandler::getABIInterface(ContractDefinition const& _contractDef)
|
2014-12-03 15:40:37 +00:00
|
|
|
{
|
|
|
|
Json::Value methods(Json::arrayValue);
|
|
|
|
|
2015-01-08 23:27:26 +00:00
|
|
|
for (auto const& it: _contractDef.getInterfaceFunctions())
|
2014-12-03 15:40:37 +00:00
|
|
|
{
|
|
|
|
Json::Value method;
|
|
|
|
Json::Value inputs(Json::arrayValue);
|
|
|
|
Json::Value outputs(Json::arrayValue);
|
|
|
|
|
2014-12-04 00:27:38 +00:00
|
|
|
auto populateParameters = [](std::vector<ASTPointer<VariableDeclaration>> const& _vars)
|
2014-12-03 15:40:37 +00:00
|
|
|
{
|
|
|
|
Json::Value params(Json::arrayValue);
|
|
|
|
for (ASTPointer<VariableDeclaration> const& var: _vars)
|
|
|
|
{
|
|
|
|
Json::Value input;
|
|
|
|
input["name"] = var->getName();
|
|
|
|
input["type"] = var->getType()->toString();
|
|
|
|
params.append(input);
|
|
|
|
}
|
|
|
|
return params;
|
|
|
|
};
|
|
|
|
|
2015-01-08 23:27:26 +00:00
|
|
|
method["name"] = it.second->getName();
|
|
|
|
method["constant"] = it.second->isDeclaredConst();
|
|
|
|
method["inputs"] = populateParameters(it.second->getParameters());
|
|
|
|
method["outputs"] = populateParameters(it.second->getReturnParameters());
|
2014-12-03 15:40:37 +00:00
|
|
|
methods.append(method);
|
|
|
|
}
|
|
|
|
return std::unique_ptr<std::string>(new std::string(m_writer.write(methods)));
|
|
|
|
}
|
|
|
|
|
2015-01-08 23:22:06 +00:00
|
|
|
unique_ptr<string> InterfaceHandler::getABISolidityInterface(ContractDefinition const& _contractDef)
|
|
|
|
{
|
|
|
|
string ret = "contract " + _contractDef.getName() + "{";
|
2015-01-09 10:51:52 +00:00
|
|
|
for (auto const& it: _contractDef.getInterfaceFunctions())
|
2015-01-08 23:22:06 +00:00
|
|
|
{
|
2015-01-09 10:51:52 +00:00
|
|
|
FunctionDefinition const* f = it.second;
|
2015-01-08 23:22:06 +00:00
|
|
|
auto populateParameters = [](vector<ASTPointer<VariableDeclaration>> const& _vars)
|
|
|
|
{
|
|
|
|
string r = "";
|
|
|
|
for (ASTPointer<VariableDeclaration> const& var: _vars)
|
|
|
|
r += (r.size() ? "," : "(") + var->getType()->toString() + " " + var->getName();
|
|
|
|
return r.size() ? r + ")" : "()";
|
|
|
|
};
|
|
|
|
ret += "function " + f->getName() + populateParameters(f->getParameters()) + (f->isDeclaredConst() ? "constant " : "");
|
|
|
|
if (f->getReturnParameters().size())
|
|
|
|
ret += "returns" + populateParameters(f->getReturnParameters());
|
|
|
|
else if (ret.back() == ' ')
|
|
|
|
ret.pop_back();
|
|
|
|
ret += "{}";
|
|
|
|
}
|
|
|
|
return unique_ptr<string>(new string(ret + "}"));
|
|
|
|
}
|
|
|
|
|
2014-12-12 15:49:26 +00:00
|
|
|
std::unique_ptr<std::string> InterfaceHandler::getUserDocumentation(ContractDefinition const& _contractDef)
|
2014-12-03 15:40:37 +00:00
|
|
|
{
|
|
|
|
Json::Value doc;
|
|
|
|
Json::Value methods(Json::objectValue);
|
|
|
|
|
2015-01-08 23:27:26 +00:00
|
|
|
for (auto const& it: _contractDef.getInterfaceFunctions())
|
2014-12-03 15:40:37 +00:00
|
|
|
{
|
|
|
|
Json::Value user;
|
2015-01-08 23:27:26 +00:00
|
|
|
auto strPtr = it.second->getDocumentation();
|
2014-12-03 15:40:37 +00:00
|
|
|
if (strPtr)
|
|
|
|
{
|
2014-12-04 16:19:47 +00:00
|
|
|
resetUser();
|
2014-12-10 12:13:12 +00:00
|
|
|
parseDocString(*strPtr, CommentOwner::FUNCTION);
|
2014-12-04 17:12:52 +00:00
|
|
|
if (!m_notice.empty())
|
|
|
|
{// since @notice is the only user tag if missing function should not appear
|
|
|
|
user["notice"] = Json::Value(m_notice);
|
2015-01-13 15:15:32 +00:00
|
|
|
methods[it.second->getCanonicalSignature()] = user;
|
2014-12-04 17:12:52 +00:00
|
|
|
}
|
2014-12-03 15:40:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
doc["methods"] = methods;
|
|
|
|
|
|
|
|
return std::unique_ptr<std::string>(new std::string(m_writer.write(doc)));
|
|
|
|
}
|
|
|
|
|
2014-12-12 15:49:26 +00:00
|
|
|
std::unique_ptr<std::string> InterfaceHandler::getDevDocumentation(ContractDefinition const& _contractDef)
|
2014-12-03 15:40:37 +00:00
|
|
|
{
|
2014-12-04 17:12:52 +00:00
|
|
|
// LTODO: Somewhere in this function warnings for mismatch of param names
|
|
|
|
// should be thrown
|
2014-12-03 16:46:04 +00:00
|
|
|
Json::Value doc;
|
|
|
|
Json::Value methods(Json::objectValue);
|
|
|
|
|
2014-12-10 12:13:12 +00:00
|
|
|
auto contractDoc = _contractDef.getDocumentation();
|
|
|
|
if (contractDoc)
|
|
|
|
{
|
|
|
|
m_contractAuthor.clear();
|
|
|
|
m_title.clear();
|
|
|
|
parseDocString(*contractDoc, CommentOwner::CONTRACT);
|
|
|
|
|
|
|
|
if (!m_contractAuthor.empty())
|
|
|
|
doc["author"] = m_contractAuthor;
|
|
|
|
|
|
|
|
if (!m_title.empty())
|
|
|
|
doc["title"] = m_title;
|
|
|
|
}
|
|
|
|
|
2015-01-08 23:27:26 +00:00
|
|
|
for (auto const& it: _contractDef.getInterfaceFunctions())
|
2014-12-03 16:46:04 +00:00
|
|
|
{
|
|
|
|
Json::Value method;
|
2015-01-08 23:27:26 +00:00
|
|
|
auto strPtr = it.second->getDocumentation();
|
2014-12-03 16:46:04 +00:00
|
|
|
if (strPtr)
|
|
|
|
{
|
2014-12-04 16:19:47 +00:00
|
|
|
resetDev();
|
2014-12-10 12:13:12 +00:00
|
|
|
parseDocString(*strPtr, CommentOwner::FUNCTION);
|
2014-12-03 16:46:04 +00:00
|
|
|
|
2014-12-04 17:12:52 +00:00
|
|
|
if (!m_dev.empty())
|
|
|
|
method["details"] = Json::Value(m_dev);
|
2014-12-10 12:13:12 +00:00
|
|
|
|
|
|
|
if (!m_author.empty())
|
|
|
|
method["author"] = m_author;
|
|
|
|
|
2014-12-04 16:19:47 +00:00
|
|
|
Json::Value params(Json::objectValue);
|
|
|
|
for (auto const& pair: m_params)
|
|
|
|
params[pair.first] = pair.second;
|
2014-12-04 22:55:47 +00:00
|
|
|
|
2014-12-04 17:12:52 +00:00
|
|
|
if (!m_params.empty())
|
|
|
|
method["params"] = params;
|
2014-12-10 12:13:12 +00:00
|
|
|
|
2014-12-04 17:12:52 +00:00
|
|
|
if (!m_return.empty())
|
|
|
|
method["return"] = m_return;
|
|
|
|
|
|
|
|
if (!method.empty()) // add the function, only if we have any documentation to add
|
2015-01-13 15:15:32 +00:00
|
|
|
methods[it.second->getCanonicalSignature()] = method;
|
2014-12-03 16:46:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
doc["methods"] = methods;
|
|
|
|
|
|
|
|
return std::unique_ptr<std::string>(new std::string(m_writer.write(doc)));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -- private -- */
|
2014-12-04 16:19:47 +00:00
|
|
|
void InterfaceHandler::resetUser()
|
|
|
|
{
|
|
|
|
m_notice.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void InterfaceHandler::resetDev()
|
|
|
|
{
|
|
|
|
m_dev.clear();
|
2014-12-10 12:13:12 +00:00
|
|
|
m_author.clear();
|
2014-12-04 17:12:52 +00:00
|
|
|
m_return.clear();
|
2014-12-04 16:19:47 +00:00
|
|
|
m_params.clear();
|
|
|
|
}
|
|
|
|
|
2014-12-05 11:27:18 +00:00
|
|
|
static inline std::string::const_iterator skipLineOrEOS(std::string::const_iterator _nlPos,
|
|
|
|
std::string::const_iterator _end)
|
2014-12-04 16:19:47 +00:00
|
|
|
{
|
2014-12-05 01:10:54 +00:00
|
|
|
return (_nlPos == _end) ? _end : ++_nlPos;
|
2014-12-04 16:19:47 +00:00
|
|
|
}
|
|
|
|
|
2014-12-05 01:10:54 +00:00
|
|
|
std::string::const_iterator InterfaceHandler::parseDocTagLine(std::string::const_iterator _pos,
|
|
|
|
std::string::const_iterator _end,
|
|
|
|
std::string& _tagString,
|
2014-12-18 13:43:35 +00:00
|
|
|
DocTagType _tagType,
|
|
|
|
bool _appending)
|
2014-12-04 16:19:47 +00:00
|
|
|
{
|
2014-12-05 01:10:54 +00:00
|
|
|
auto nlPos = std::find(_pos, _end, '\n');
|
2014-12-18 15:27:17 +00:00
|
|
|
if (_appending && _pos < _end && *_pos != ' ')
|
2014-12-18 13:43:35 +00:00
|
|
|
_tagString += " ";
|
2014-12-05 01:10:54 +00:00
|
|
|
std::copy(_pos, nlPos, back_inserter(_tagString));
|
2014-12-04 16:19:47 +00:00
|
|
|
m_lastTag = _tagType;
|
2014-12-05 01:10:54 +00:00
|
|
|
return skipLineOrEOS(nlPos, _end);
|
2014-12-04 16:19:47 +00:00
|
|
|
}
|
|
|
|
|
2014-12-05 01:10:54 +00:00
|
|
|
std::string::const_iterator InterfaceHandler::parseDocTagParam(std::string::const_iterator _pos,
|
|
|
|
std::string::const_iterator _end)
|
2014-12-04 16:19:47 +00:00
|
|
|
{
|
|
|
|
// find param name
|
2014-12-05 01:10:54 +00:00
|
|
|
auto currPos = std::find(_pos, _end, ' ');
|
|
|
|
if (currPos == _end)
|
2014-12-05 11:08:26 +00:00
|
|
|
BOOST_THROW_EXCEPTION(DocstringParsingError() << errinfo_comment("End of param name not found" + std::string(_pos, _end)));
|
2014-12-04 22:55:47 +00:00
|
|
|
|
2014-12-04 16:19:47 +00:00
|
|
|
|
2014-12-05 01:10:54 +00:00
|
|
|
auto paramName = std::string(_pos, currPos);
|
2014-12-04 16:19:47 +00:00
|
|
|
|
|
|
|
currPos += 1;
|
2014-12-05 01:10:54 +00:00
|
|
|
auto nlPos = std::find(currPos, _end, '\n');
|
|
|
|
auto paramDesc = std::string(currPos, nlPos);
|
2014-12-04 16:19:47 +00:00
|
|
|
m_params.push_back(std::make_pair(paramName, paramDesc));
|
|
|
|
|
2014-12-05 14:50:39 +00:00
|
|
|
m_lastTag = DocTagType::PARAM;
|
2014-12-05 01:10:54 +00:00
|
|
|
return skipLineOrEOS(nlPos, _end);
|
2014-12-04 16:19:47 +00:00
|
|
|
}
|
|
|
|
|
2014-12-05 01:10:54 +00:00
|
|
|
std::string::const_iterator InterfaceHandler::appendDocTagParam(std::string::const_iterator _pos,
|
|
|
|
std::string::const_iterator _end)
|
2014-12-04 16:19:47 +00:00
|
|
|
{
|
|
|
|
// Should never be called with an empty vector
|
2014-12-17 15:23:18 +00:00
|
|
|
solAssert(!m_params.empty(), "Internal: Tried to append to empty parameter");
|
2014-12-05 01:10:54 +00:00
|
|
|
|
2014-12-04 16:19:47 +00:00
|
|
|
auto pair = m_params.back();
|
2014-12-18 15:27:17 +00:00
|
|
|
if (_pos < _end && *_pos != ' ')
|
2014-12-18 13:43:35 +00:00
|
|
|
pair.second += " ";
|
2014-12-05 01:10:54 +00:00
|
|
|
auto nlPos = std::find(_pos, _end, '\n');
|
|
|
|
std::copy(_pos, nlPos, back_inserter(pair.second));
|
2014-12-04 16:19:47 +00:00
|
|
|
|
|
|
|
m_params.at(m_params.size() - 1) = pair;
|
|
|
|
|
2014-12-05 01:10:54 +00:00
|
|
|
return skipLineOrEOS(nlPos, _end);
|
2014-12-04 16:19:47 +00:00
|
|
|
}
|
|
|
|
|
2014-12-05 01:10:54 +00:00
|
|
|
std::string::const_iterator InterfaceHandler::parseDocTag(std::string::const_iterator _pos,
|
|
|
|
std::string::const_iterator _end,
|
2014-12-10 12:13:12 +00:00
|
|
|
std::string const& _tag,
|
|
|
|
CommentOwner _owner)
|
2014-12-03 16:46:04 +00:00
|
|
|
{
|
2014-12-04 17:12:52 +00:00
|
|
|
// LTODO: need to check for @(start of a tag) between here and the end of line
|
2014-12-10 15:44:54 +00:00
|
|
|
// for all cases. Also somehow automate list of acceptable tags for each
|
|
|
|
// language construct since current way does not scale well.
|
2014-12-05 14:50:39 +00:00
|
|
|
if (m_lastTag == DocTagType::NONE || _tag != "")
|
2014-12-03 16:46:04 +00:00
|
|
|
{
|
2014-12-04 08:42:38 +00:00
|
|
|
if (_tag == "dev")
|
2014-12-18 13:43:35 +00:00
|
|
|
return parseDocTagLine(_pos, _end, m_dev, DocTagType::DEV, false);
|
2014-12-04 08:42:38 +00:00
|
|
|
else if (_tag == "notice")
|
2014-12-18 13:43:35 +00:00
|
|
|
return parseDocTagLine(_pos, _end, m_notice, DocTagType::NOTICE, false);
|
2014-12-04 17:12:52 +00:00
|
|
|
else if (_tag == "return")
|
2014-12-18 13:43:35 +00:00
|
|
|
return parseDocTagLine(_pos, _end, m_return, DocTagType::RETURN, false);
|
2014-12-10 12:13:12 +00:00
|
|
|
else if (_tag == "author")
|
|
|
|
{
|
|
|
|
if (_owner == CommentOwner::CONTRACT)
|
2014-12-18 13:43:35 +00:00
|
|
|
return parseDocTagLine(_pos, _end, m_contractAuthor, DocTagType::AUTHOR, false);
|
2014-12-10 15:44:54 +00:00
|
|
|
else if (_owner == CommentOwner::FUNCTION)
|
2014-12-18 13:43:35 +00:00
|
|
|
return parseDocTagLine(_pos, _end, m_author, DocTagType::AUTHOR, false);
|
2014-12-10 12:13:12 +00:00
|
|
|
else
|
|
|
|
// LTODO: for now this else makes no sense but later comments will go to more language constructs
|
|
|
|
BOOST_THROW_EXCEPTION(DocstringParsingError() << errinfo_comment("@author tag is legal only for contracts"));
|
|
|
|
}
|
|
|
|
else if (_tag == "title")
|
|
|
|
{
|
|
|
|
if (_owner == CommentOwner::CONTRACT)
|
2014-12-18 13:43:35 +00:00
|
|
|
return parseDocTagLine(_pos, _end, m_title, DocTagType::TITLE, false);
|
2014-12-10 12:13:12 +00:00
|
|
|
else
|
|
|
|
// LTODO: Unknown tag, throw some form of warning and not just an exception
|
|
|
|
BOOST_THROW_EXCEPTION(DocstringParsingError() << errinfo_comment("@title tag is legal only for contracts"));
|
|
|
|
}
|
2014-12-04 16:19:47 +00:00
|
|
|
else if (_tag == "param")
|
2014-12-05 01:10:54 +00:00
|
|
|
return parseDocTagParam(_pos, _end);
|
2014-12-04 08:42:38 +00:00
|
|
|
else
|
2014-12-05 01:10:54 +00:00
|
|
|
// LTODO: Unknown tag, throw some form of warning and not just an exception
|
2014-12-05 11:08:26 +00:00
|
|
|
BOOST_THROW_EXCEPTION(DocstringParsingError() << errinfo_comment("Unknown tag " + _tag + " encountered"));
|
2014-12-03 16:46:04 +00:00
|
|
|
}
|
|
|
|
else
|
2014-12-10 12:13:12 +00:00
|
|
|
return appendDocTag(_pos, _end, _owner);
|
2014-12-04 16:19:47 +00:00
|
|
|
}
|
|
|
|
|
2014-12-05 01:10:54 +00:00
|
|
|
std::string::const_iterator InterfaceHandler::appendDocTag(std::string::const_iterator _pos,
|
2014-12-10 12:13:12 +00:00
|
|
|
std::string::const_iterator _end,
|
|
|
|
CommentOwner _owner)
|
2014-12-04 16:19:47 +00:00
|
|
|
{
|
2014-12-04 22:55:47 +00:00
|
|
|
switch (m_lastTag)
|
2014-12-03 16:46:04 +00:00
|
|
|
{
|
2014-12-10 12:13:12 +00:00
|
|
|
case DocTagType::DEV:
|
2014-12-18 13:43:35 +00:00
|
|
|
return parseDocTagLine(_pos, _end, m_dev, DocTagType::DEV, true);
|
2014-12-10 12:13:12 +00:00
|
|
|
case DocTagType::NOTICE:
|
2014-12-18 13:43:35 +00:00
|
|
|
return parseDocTagLine(_pos, _end, m_notice, DocTagType::NOTICE, true);
|
2014-12-10 12:13:12 +00:00
|
|
|
case DocTagType::RETURN:
|
2014-12-18 13:43:35 +00:00
|
|
|
return parseDocTagLine(_pos, _end, m_return, DocTagType::RETURN, true);
|
2014-12-10 12:13:12 +00:00
|
|
|
case DocTagType::AUTHOR:
|
|
|
|
if (_owner == CommentOwner::CONTRACT)
|
2014-12-18 13:43:35 +00:00
|
|
|
return parseDocTagLine(_pos, _end, m_contractAuthor, DocTagType::AUTHOR, true);
|
2014-12-10 15:44:54 +00:00
|
|
|
else if (_owner == CommentOwner::FUNCTION)
|
2014-12-18 13:43:35 +00:00
|
|
|
return parseDocTagLine(_pos, _end, m_author, DocTagType::AUTHOR, true);
|
2014-12-10 12:13:12 +00:00
|
|
|
else
|
|
|
|
// LTODO: Unknown tag, throw some form of warning and not just an exception
|
|
|
|
BOOST_THROW_EXCEPTION(DocstringParsingError() << errinfo_comment("@author tag in illegal comment"));
|
|
|
|
case DocTagType::TITLE:
|
|
|
|
if (_owner == CommentOwner::CONTRACT)
|
2014-12-18 13:43:35 +00:00
|
|
|
return parseDocTagLine(_pos, _end, m_title, DocTagType::TITLE, true);
|
2014-12-10 12:13:12 +00:00
|
|
|
else
|
|
|
|
// LTODO: Unknown tag, throw some form of warning and not just an exception
|
|
|
|
BOOST_THROW_EXCEPTION(DocstringParsingError() << errinfo_comment("@title tag in illegal comment"));
|
|
|
|
case DocTagType::PARAM:
|
|
|
|
return appendDocTagParam(_pos, _end);
|
|
|
|
default:
|
|
|
|
BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Internal: Illegal documentation tag type"));
|
|
|
|
break;
|
2014-12-05 01:10:54 +00:00
|
|
|
}
|
2014-12-03 16:46:04 +00:00
|
|
|
}
|
|
|
|
|
2014-12-05 11:27:18 +00:00
|
|
|
static inline std::string::const_iterator getFirstSpaceOrNl(std::string::const_iterator _pos,
|
|
|
|
std::string::const_iterator _end)
|
|
|
|
{
|
|
|
|
auto spacePos = std::find(_pos, _end, ' ');
|
|
|
|
auto nlPos = std::find(_pos, _end, '\n');
|
|
|
|
return (spacePos < nlPos) ? spacePos : nlPos;
|
|
|
|
}
|
|
|
|
|
2014-12-10 12:13:12 +00:00
|
|
|
void InterfaceHandler::parseDocString(std::string const& _string, CommentOwner _owner)
|
2014-12-03 16:46:04 +00:00
|
|
|
{
|
2014-12-05 01:10:54 +00:00
|
|
|
auto currPos = _string.begin();
|
|
|
|
auto end = _string.end();
|
2014-12-03 16:46:04 +00:00
|
|
|
|
2014-12-05 01:10:54 +00:00
|
|
|
while (currPos != end)
|
2014-12-04 08:42:38 +00:00
|
|
|
{
|
2014-12-05 01:10:54 +00:00
|
|
|
auto tagPos = std::find(currPos, end, '@');
|
|
|
|
auto nlPos = std::find(currPos, end, '\n');
|
2014-12-03 16:46:04 +00:00
|
|
|
|
2014-12-05 01:10:54 +00:00
|
|
|
if (tagPos != end && tagPos < nlPos)
|
|
|
|
{
|
|
|
|
// we found a tag
|
2014-12-05 11:27:18 +00:00
|
|
|
auto tagNameEndPos = getFirstSpaceOrNl(tagPos, end);
|
2014-12-05 01:10:54 +00:00
|
|
|
if (tagNameEndPos == end)
|
2014-12-05 11:08:26 +00:00
|
|
|
BOOST_THROW_EXCEPTION(DocstringParsingError() <<
|
|
|
|
errinfo_comment("End of tag " + std::string(tagPos, tagNameEndPos) + "not found"));
|
2014-12-05 01:10:54 +00:00
|
|
|
|
2014-12-10 12:13:12 +00:00
|
|
|
currPos = parseDocTag(tagNameEndPos + 1, end, std::string(tagPos + 1, tagNameEndPos), _owner);
|
2014-12-05 01:10:54 +00:00
|
|
|
}
|
2014-12-05 14:50:39 +00:00
|
|
|
else if (m_lastTag != DocTagType::NONE) // continuation of the previous tag
|
2014-12-18 13:43:35 +00:00
|
|
|
currPos = appendDocTag(currPos, end, _owner);
|
2015-01-12 14:29:44 +00:00
|
|
|
else if (currPos != end)
|
|
|
|
{
|
|
|
|
if (nlPos == end) //end of text
|
|
|
|
return;
|
|
|
|
// else skip the line if a newline was found
|
2014-12-05 11:08:26 +00:00
|
|
|
currPos = nlPos + 1;
|
2015-01-12 14:29:44 +00:00
|
|
|
}
|
2014-12-04 08:42:38 +00:00
|
|
|
}
|
2014-12-03 15:40:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} //solidity NS
|
|
|
|
} // dev NS
|