Skip to content

Commit e55c224

Browse files
committed
Make commentscan.l reentrant
1 parent abf1e46 commit e55c224

File tree

11 files changed

+1822
-1639
lines changed

11 files changed

+1822
-1639
lines changed

src/commentscan.h

Lines changed: 58 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -16,74 +16,71 @@
1616
#ifndef COMMENTSCAN_H
1717
#define COMMENTSCAN_H
1818

19+
#include <memory>
1920
#include "types.h"
2021

2122
class Entry;
2223
class OutlineParserInterface;
2324

2425
/** @file
25-
* @brief Interface for the comment block parser */
26+
* @brief Interface for the comment block scanner */
2627

27-
/** Invokes the comment block parser with the request to preprocess a
28-
* single comment block.
29-
* @param[in] comment A string representing the actual comment block.
30-
* Note that leading *'s are already stripped from the comment block.
31-
* @param[in] fileName The name of the file in which the comment is found.
32-
* Mainly used for producing warnings.
33-
* @param[in] lineNr The line number at which the comment block was found.
34-
* @returns The prepocessed comment block
35-
*/
36-
QCString preprocessCommentBlock(const QCString &comment,
37-
const QCString &fileName,
38-
int lineNr);
39-
40-
/** Invokes the comment block parser with the request to parse a
41-
* single comment block.
42-
* @param[in] parser The language parse that invoked this function.
43-
* The comment block parse may invoke
44-
* ParserInterface::parsePrototype() in order to parse
45-
* the argument of a @@fn command.
46-
* @param[in] curEntry The Entry to which the comment block belongs.
47-
* Any information (like documentation) that is found in
48-
* the comment block will be stored in this entry.
49-
* @param[in] comment A string representing the actual comment block.
50-
* Note that leading *'s are already stripped from the comment block.
51-
* @param[in] fileName The name of the file in which the comment is found.
52-
* Mainly used for producing warnings.
53-
* @param[in,out] lineNr The line number at which the comment block was found.
54-
* When the function returns it will be set to the last line parsed.
55-
* @param[in] isBrief TRUE iff this comment block represents a brief description.
56-
* @param[in] isJavadocStyle TRUE iff this comment block is in "Javadoc" style.
57-
* This means that it starts as a brief description until the end of
58-
* the sentences is found and then proceeds as a detailed description.
59-
* @param[in] isInbody TRUE iff this comment block is located in the body of
60-
* a function.
61-
* @param[in,out] prot The protection level in which this comment block was
62-
* found. Commands in the comment block may override this.
63-
* @param[in,out] position The character position within \a comment where the
64-
* comment block starts. Typically used in case the comment block
65-
* contains multiple structural commands.
66-
* @param[out] newEntryNeeded Boolean that is TRUE if the comment block parser
67-
* finds that a the comment block finishes the entry and a new one
68-
* needs to be started.
69-
* @returns TRUE if the comment requires further processing. The
70-
* parameter \a newEntryNeeded will typically be true in this case and
71-
* \a position will indicate the offset inside the \a comment string
72-
* where to proceed parsing. FALSE indicates no further processing is
73-
* needed.
74-
*/
75-
bool parseCommentBlock(OutlineParserInterface *parser,
76-
Entry *curEntry,
77-
const QCString &comment,
78-
const QCString &fileName,
79-
int &lineNr,
80-
bool isBrief,
81-
bool isJavadocStyle,
82-
bool isInbody,
83-
Protection &prot,
84-
int &position,
85-
bool &newEntryNeeded
86-
);
28+
class CommentScanner
29+
{
30+
public:
31+
CommentScanner();
32+
~CommentScanner();
8733

34+
/** Invokes the comment block parser with the request to parse a
35+
* single comment block.
36+
* @param[in] parser The language parse that invoked this function.
37+
* The comment block parse may invoke
38+
* ParserInterface::parsePrototype() in order to parse
39+
* the argument of a @@fn command.
40+
* @param[in] curEntry The Entry to which the comment block belongs.
41+
* Any information (like documentation) that is found in
42+
* the comment block will be stored in this entry.
43+
* @param[in] comment A string representing the actual comment block.
44+
* Note that leading *'s are already stripped from the comment block.
45+
* @param[in] fileName The name of the file in which the comment is found.
46+
* Mainly used for producing warnings.
47+
* @param[in,out] lineNr The line number at which the comment block was found.
48+
* When the function returns it will be set to the last line parsed.
49+
* @param[in] isBrief TRUE iff this comment block represents a brief description.
50+
* @param[in] isJavadocStyle TRUE iff this comment block is in "Javadoc" style.
51+
* This means that it starts as a brief description until the end of
52+
* the sentences is found and then proceeds as a detailed description.
53+
* @param[in] isInbody TRUE iff this comment block is located in the body of
54+
* a function.
55+
* @param[in,out] prot The protection level in which this comment block was
56+
* found. Commands in the comment block may override this.
57+
* @param[in,out] position The character position within \a comment where the
58+
* comment block starts. Typically used in case the comment block
59+
* contains multiple structural commands.
60+
* @param[out] newEntryNeeded Boolean that is TRUE if the comment block parser
61+
* finds that a the comment block finishes the entry and a new one
62+
* needs to be started.
63+
* @returns TRUE if the comment requires further processing. The
64+
* parameter \a newEntryNeeded will typically be true in this case and
65+
* \a position will indicate the offset inside the \a comment string
66+
* where to proceed parsing. FALSE indicates no further processing is
67+
* needed.
68+
*/
69+
bool parseCommentBlock(OutlineParserInterface *parser,
70+
Entry *curEntry,
71+
const QCString &comment,
72+
const QCString &fileName,
73+
int &lineNr,
74+
bool isBrief,
75+
bool isJavadocStyle,
76+
bool isInbody,
77+
Protection &prot,
78+
int &position,
79+
bool &newEntryNeeded
80+
);
81+
private:
82+
struct Private;
83+
std::unique_ptr<Private> p;
84+
};
8885

8986
#endif

0 commit comments

Comments
 (0)