From b4f561680a2a5169d1245271245e2b71822cb73a Mon Sep 17 00:00:00 2001 From: chriseth Date: Mon, 26 Oct 2015 15:13:36 +0100 Subject: Store docstrings in AST annotations. --- libsolidity/parsing/DocStringParser.h | 70 +++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 libsolidity/parsing/DocStringParser.h (limited to 'libsolidity/parsing/DocStringParser.h') diff --git a/libsolidity/parsing/DocStringParser.h b/libsolidity/parsing/DocStringParser.h new file mode 100644 index 00000000..f67b8bbd --- /dev/null +++ b/libsolidity/parsing/DocStringParser.h @@ -0,0 +1,70 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + 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. + + cpp-ethereum is distributed in the hope that it will be useful, + 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 + along with cpp-ethereum. If not, see . +*/ +/** + * @author Lefteris + * @date 2014, 2015 + * Parses a given docstring into pieces introduced by tags. + */ + +#pragma once + +#include +#include +#include + +namespace dev +{ +namespace solidity +{ + +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. + bool parse(std::string const& _docString, ErrorList& _errors); + + std::multimap 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 m_docTags; + DocTag* m_lastTag = nullptr; + ErrorList* m_errors = nullptr; + bool m_errorsOccurred = false; +}; + +} //solidity NS +} // dev NS -- cgit