2015-10-26 14:13:36 +00:00
|
|
|
/*
|
2016-11-18 23:13:20 +00:00
|
|
|
This file is part of solidity.
|
2015-10-26 14:13:36 +00:00
|
|
|
|
2016-11-18 23:13:20 +00:00
|
|
|
solidity is free software: you can redistribute it and/or modify
|
2015-10-26 14:13:36 +00:00
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
2016-11-18 23:13:20 +00:00
|
|
|
solidity is distributed in the hope that it will be useful,
|
2015-10-26 14:13:36 +00:00
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2016-11-18 23:13:20 +00:00
|
|
|
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
2015-10-26 14:13:36 +00:00
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* @author Lefteris <lefteris@ethdev.com>
|
|
|
|
* @date 2014, 2015
|
|
|
|
* Parses a given docstring into pieces introduced by tags.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <libsolidity/ast/ASTAnnotations.h>
|
|
|
|
|
|
|
|
namespace dev
|
|
|
|
{
|
|
|
|
namespace solidity
|
|
|
|
{
|
|
|
|
|
2017-05-11 13:26:35 +00:00
|
|
|
class ErrorReporter;
|
|
|
|
|
2015-10-26 14:13:36 +00:00
|
|
|
class DocStringParser
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/// Parse the given @a _docString and stores the parsed components internally.
|
|
|
|
/// @returns false on error and appends the error to @a _errors.
|
2017-05-11 13:26:35 +00:00
|
|
|
bool parse(std::string const& _docString, ErrorReporter& _errorReporter);
|
2015-10-26 14:13:36 +00:00
|
|
|
|
|
|
|
std::multimap<std::string, DocTag> const& tags() const { return m_docTags; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
using iter = std::string::const_iterator;
|
|
|
|
void resetUser();
|
|
|
|
void resetDev();
|
|
|
|
|
|
|
|
iter parseDocTagLine(iter _pos, iter _end, bool _appending);
|
|
|
|
iter parseDocTagParam(iter _pos, iter _end);
|
|
|
|
iter appendDocTagParam(iter _pos, iter _end);
|
|
|
|
void parseDocString(std::string const& _string);
|
|
|
|
iter appendDocTag(iter _pos, iter _end);
|
|
|
|
/// Parses the doc tag named @a _tag, adds it to m_docTags and returns the position
|
|
|
|
/// after the tag.
|
|
|
|
iter parseDocTag(iter _pos, iter _end, std::string const& _tag);
|
|
|
|
|
|
|
|
/// Creates and inserts a new tag and adjusts m_lastTag.
|
|
|
|
void newTag(std::string const& _tagName);
|
|
|
|
|
|
|
|
void appendError(std::string const& _description);
|
|
|
|
|
|
|
|
/// Mapping tag name -> content.
|
|
|
|
std::multimap<std::string, DocTag> m_docTags;
|
|
|
|
DocTag* m_lastTag = nullptr;
|
2017-05-11 13:26:35 +00:00
|
|
|
ErrorReporter* m_errorReporter = nullptr;
|
2015-10-26 14:13:36 +00:00
|
|
|
bool m_errorsOccurred = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
} //solidity NS
|
|
|
|
} // dev NS
|