forked from OSchip/llvm-project
Handle missing newline at EOF more gracefully in MC AsmLexer.
If we see an EOF w/o a preceding end-of-line, return an EndOfStatement token before returning the Eof token. Based on patch by Stepan Dyatkovskiy. llvm-svn: 139798
This commit is contained in:
parent
07b3503f8b
commit
a9aa3c18e3
|
@ -375,8 +375,15 @@ AsmToken AsmLexer::LexToken() {
|
|||
return AsmToken(AsmToken::EndOfStatement,
|
||||
StringRef(TokStart, strlen(MAI.getSeparatorString())));
|
||||
}
|
||||
isAtStartOfLine = false;
|
||||
|
||||
// If we're missing a newline at EOF, make sure we still get an
|
||||
// EndOfStatement token before the Eof token.
|
||||
if (CurChar == EOF && !isAtStartOfLine) {
|
||||
isAtStartOfLine = true;
|
||||
return AsmToken(AsmToken::EndOfStatement, StringRef(TokStart, 1));
|
||||
}
|
||||
|
||||
isAtStartOfLine = false;
|
||||
switch (CurChar) {
|
||||
default:
|
||||
// Handle identifier: [a-zA-Z_.][a-zA-Z0-9_$.@]*
|
||||
|
|
Loading…
Reference in New Issue