mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-09 11:25:55 +00:00
Fixed some problems with the logic of parsing line comments by adding
isAtStartOfComment and using that instead in two places where a loop to check if the char was in MAI.getCommentString(). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82059 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -232,27 +232,30 @@ AsmToken AsmLexer::LexQuote() {
|
|||||||
StringRef AsmLexer::LexUntilEndOfStatement() {
|
StringRef AsmLexer::LexUntilEndOfStatement() {
|
||||||
TokStart = CurPtr;
|
TokStart = CurPtr;
|
||||||
|
|
||||||
while (*CurPtr != ';' && // End of statement marker.
|
while (!isAtStartOfComment(*CurPtr) && // Start of line comment.
|
||||||
|
*CurPtr != ';' && // End of statement marker.
|
||||||
*CurPtr != '\n' &&
|
*CurPtr != '\n' &&
|
||||||
*CurPtr != '\r' &&
|
*CurPtr != '\r' &&
|
||||||
(*CurPtr != 0 || CurPtr != CurBuf->getBufferEnd())) {
|
(*CurPtr != 0 || CurPtr != CurBuf->getBufferEnd())) {
|
||||||
// check for start of line comment.
|
|
||||||
for (const char *p = MAI.getCommentString(); *p != 0; ++p)
|
|
||||||
if (*CurPtr == *p)
|
|
||||||
break;
|
|
||||||
++CurPtr;
|
++CurPtr;
|
||||||
}
|
}
|
||||||
return StringRef(TokStart, CurPtr-TokStart);
|
return StringRef(TokStart, CurPtr-TokStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AsmLexer::isAtStartOfComment(char Char) {
|
||||||
|
for (const char *p = MAI.getCommentString(); *p != 0; ++p)
|
||||||
|
if (Char == *p)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
AsmToken AsmLexer::LexToken() {
|
AsmToken AsmLexer::LexToken() {
|
||||||
TokStart = CurPtr;
|
TokStart = CurPtr;
|
||||||
// This always consumes at least one character.
|
// This always consumes at least one character.
|
||||||
int CurChar = getNextChar();
|
int CurChar = getNextChar();
|
||||||
|
|
||||||
for (const char *p = MAI.getCommentString(); *p != 0; ++p)
|
if (isAtStartOfComment(CurChar))
|
||||||
if (CurChar == *p)
|
return LexLineComment();
|
||||||
return LexLineComment();
|
|
||||||
|
|
||||||
switch (CurChar) {
|
switch (CurChar) {
|
||||||
default:
|
default:
|
||||||
|
@@ -55,7 +55,8 @@ public:
|
|||||||
SMLoc getLoc() const;
|
SMLoc getLoc() const;
|
||||||
|
|
||||||
StringRef LexUntilEndOfStatement();
|
StringRef LexUntilEndOfStatement();
|
||||||
|
|
||||||
|
bool isAtStartOfComment(char Char);
|
||||||
|
|
||||||
/// EnterIncludeFile - Enter the specified file. This returns true on failure.
|
/// EnterIncludeFile - Enter the specified file. This returns true on failure.
|
||||||
bool EnterIncludeFile(const std::string &Filename);
|
bool EnterIncludeFile(const std::string &Filename);
|
||||||
|
Reference in New Issue
Block a user