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
|
|
|
*/
|
2020-07-17 14:54:12 +00:00
|
|
|
// SPDX-License-Identifier: GPL-3.0
|
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 <libsolidity/ast/ASTAnnotations.h>
|
2021-03-01 15:54:21 +00:00
|
|
|
#include <liblangutil/SourceLocation.h>
|
2018-12-17 18:28:10 +00:00
|
|
|
#include <string>
|
2015-10-26 14:13:36 +00:00
|
|
|
|
2019-12-11 16:31:36 +00:00
|
|
|
namespace solidity::langutil
|
2018-11-14 16:11:55 +00:00
|
|
|
{
|
|
|
|
class ErrorReporter;
|
|
|
|
}
|
|
|
|
|
2019-12-11 16:31:36 +00:00
|
|
|
namespace solidity::frontend
|
2015-10-26 14:13:36 +00:00
|
|
|
{
|
|
|
|
|
2020-05-01 22:37:25 +00:00
|
|
|
class StructuredDocumentation;
|
2021-03-01 15:54:21 +00:00
|
|
|
|
2015-10-26 14:13:36 +00:00
|
|
|
class DocStringParser
|
|
|
|
{
|
|
|
|
public:
|
2021-03-01 15:54:21 +00:00
|
|
|
/// @param _documentedNode the node whose documentation is parsed.
|
|
|
|
DocStringParser(StructuredDocumentation const& _documentedNode, langutil::ErrorReporter& _errorReporter):
|
|
|
|
m_node(_documentedNode),
|
|
|
|
m_errorReporter(_errorReporter)
|
|
|
|
{}
|
|
|
|
std::multimap<std::string, DocTag> parse();
|
2015-10-26 14:13:36 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
using iter = std::string::const_iterator;
|
|
|
|
|
|
|
|
iter parseDocTagLine(iter _pos, iter _end, bool _appending);
|
|
|
|
iter parseDocTagParam(iter _pos, iter _end);
|
2020-05-01 22:37:25 +00:00
|
|
|
|
2015-10-26 14:13:36 +00:00
|
|
|
/// 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);
|
|
|
|
|
2021-03-01 15:54:21 +00:00
|
|
|
StructuredDocumentation const& m_node;
|
|
|
|
langutil::ErrorReporter& m_errorReporter;
|
2015-10-26 14:13:36 +00:00
|
|
|
/// Mapping tag name -> content.
|
|
|
|
std::multimap<std::string, DocTag> m_docTags;
|
|
|
|
DocTag* m_lastTag = nullptr;
|
|
|
|
};
|
|
|
|
|
2019-12-11 16:31:36 +00:00
|
|
|
}
|