/src/solidity/libsolidity/parsing/DocStringParser.h
Line | Count | Source |
1 | | /* |
2 | | This file is part of solidity. |
3 | | |
4 | | solidity is free software: you can redistribute it and/or modify |
5 | | it under the terms of the GNU General Public License as published by |
6 | | the Free Software Foundation, either version 3 of the License, or |
7 | | (at your option) any later version. |
8 | | |
9 | | solidity is distributed in the hope that it will be useful, |
10 | | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | | GNU General Public License for more details. |
13 | | |
14 | | You should have received a copy of the GNU General Public License |
15 | | along with solidity. If not, see <http://www.gnu.org/licenses/>. |
16 | | */ |
17 | | // SPDX-License-Identifier: GPL-3.0 |
18 | | /** |
19 | | * @author Lefteris <lefteris@ethdev.com> |
20 | | * @date 2014, 2015 |
21 | | * Parses a given docstring into pieces introduced by tags. |
22 | | */ |
23 | | |
24 | | #pragma once |
25 | | |
26 | | #include <libsolidity/ast/ASTAnnotations.h> |
27 | | #include <liblangutil/SourceLocation.h> |
28 | | #include <string> |
29 | | |
30 | | namespace solidity::langutil |
31 | | { |
32 | | class ErrorReporter; |
33 | | } |
34 | | |
35 | | namespace solidity::frontend |
36 | | { |
37 | | |
38 | | class StructuredDocumentation; |
39 | | |
40 | | class DocStringParser |
41 | | { |
42 | | public: |
43 | | /// @param _documentedNode the node whose documentation is parsed. |
44 | | DocStringParser(StructuredDocumentation const& _documentedNode, langutil::ErrorReporter& _errorReporter): |
45 | | m_node(_documentedNode), |
46 | | m_errorReporter(_errorReporter) |
47 | 10.8k | {} |
48 | | std::multimap<std::string, DocTag> parse(); |
49 | | |
50 | | private: |
51 | | using iter = std::string::const_iterator; |
52 | | |
53 | | iter parseDocTagLine(iter _pos, iter _end, bool _appending); |
54 | | iter parseDocTagParam(iter _pos, iter _end); |
55 | | |
56 | | /// Parses the doc tag named @a _tag, adds it to m_docTags and returns the position |
57 | | /// after the tag. |
58 | | iter parseDocTag(iter _pos, iter _end, std::string const& _tag); |
59 | | |
60 | | /// Creates and inserts a new tag and adjusts m_lastTag. |
61 | | void newTag(std::string const& _tagName); |
62 | | |
63 | | StructuredDocumentation const& m_node; |
64 | | langutil::ErrorReporter& m_errorReporter; |
65 | | /// Mapping tag name -> content. |
66 | | std::multimap<std::string, DocTag> m_docTags; |
67 | | DocTag* m_lastTag = nullptr; |
68 | | }; |
69 | | |
70 | | } |