Skip to content

Commit 5215cbf

Browse files
committed
comments
1 parent 2e7f7c3 commit 5215cbf

2 files changed

Lines changed: 39 additions & 0 deletions

File tree

‎simplecpp.cpp‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,14 @@ void simplecpp::TokenList::lineDirective(unsigned int fileIndex_, unsigned int l
726726

727727
static const std::string COMMENT_END("*/");
728728

729+
/**
730+
* Read a name or a number.
731+
* In a number, a ' digit separator is removed, so 1'000 gives "1000".
732+
* The stream is left after the last character of the token.
733+
* @param stream the stream to read from
734+
* @param ch the first character, already read from the stream
735+
* @return the name or number
736+
*/
729737
static simplecpp::TokenString readNameOrNumber(simplecpp::TokenList::Stream &stream, unsigned char ch)
730738
{
731739
simplecpp::TokenString currentToken;
@@ -740,6 +748,19 @@ static simplecpp::TokenString readNameOrNumber(simplecpp::TokenList::Stream &str
740748
return currentToken;
741749
}
742750

751+
/**
752+
* Read a // comment, up to but not including the newline.
753+
* A backslash followed by a newline continues the comment on the next line.
754+
* The backslash, and any spaces or tabs after it, are then replaced by a
755+
* newline in the comment text.
756+
* @param stream the stream to read from
757+
* @param ch the first '/', already read from the stream
758+
* @param location the location of the comment, used for warnings
759+
* @param multiline incremented for each continued line
760+
* @param outputList if not null, a portability warning is added when there is
761+
* whitespace between the backslash and the newline
762+
* @return the comment text, including the leading //
763+
*/
743764
static simplecpp::TokenString readLineComment(simplecpp::TokenList::Stream &stream, unsigned char ch, const simplecpp::Location &location, unsigned int &multiline, simplecpp::OutputList *outputList)
744765
{
745766
simplecpp::TokenString currentToken;

‎simplecpp.h‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,25 @@ namespace simplecpp {
429429
const Token* lastLineTok(int maxsize=1000) const;
430430
const Token* isLastLinePreprocessor(int maxsize=1000) const;
431431

432+
/**
433+
* Read a block comment, up to and including the closing star-slash.
434+
* Each backslash-newline is removed from the text. If the comment is
435+
* on a continued line or in a preprocessor directive, its newlines are
436+
* removed too, so that the directive keeps going after the comment.
437+
* @param stream the stream to read from. The first '/' is already
438+
* read, and the next character is '*'.
439+
* @param multiline incremented for each newline that is removed
440+
* @return the comment text
441+
*/
432442
TokenString readBlockComment(Stream &stream, unsigned int &multiline);
443+
/**
444+
* Read the text of a #error or #warning directive, up to but not
445+
* including the newline, and add it as one token. A backslash-newline
446+
* continues the text on the next line and is removed from it.
447+
* @param stream the stream to read from
448+
* @param ch the first character of the text, already read from the stream
449+
* @param location the location of the text. Updated to point after it.
450+
*/
433451
void readErrorText(Stream &stream, unsigned char ch, Location &location);
434452

435453
unsigned int fileIndex(const std::string &filename);

0 commit comments

Comments
 (0)