mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-03 10:54:42 +00:00
MCParser: add a single token lookahead
Some of the more complex directive and macro handling for GAS compatibility requires lookahead. Add a single token lookahead in the MCAsmLexer. llvm-svn: 201058
This commit is contained in:
parent
d7d93a1068
commit
360c5ac6fd
@ -47,6 +47,8 @@ public:
|
||||
virtual StringRef LexUntilEndOfStatement();
|
||||
StringRef LexUntilEndOfLine();
|
||||
|
||||
virtual const AsmToken peekTok(bool ShouldSkipSpace = true);
|
||||
|
||||
bool isAtStartOfComment(char Char);
|
||||
bool isAtStatementSeparator(const char *Ptr);
|
||||
|
||||
|
@ -160,6 +160,9 @@ public:
|
||||
return CurTok;
|
||||
}
|
||||
|
||||
/// peekTok - Look ahead at the next token to be lexed.
|
||||
virtual const AsmToken peekTok(bool ShouldSkipSpace = true) = 0;
|
||||
|
||||
/// getErrLoc - Get the current error location
|
||||
const SMLoc &getErrLoc() {
|
||||
return ErrLoc;
|
||||
|
@ -439,6 +439,28 @@ StringRef AsmLexer::LexUntilEndOfLine() {
|
||||
return StringRef(TokStart, CurPtr-TokStart);
|
||||
}
|
||||
|
||||
const AsmToken AsmLexer::peekTok(bool ShouldSkipSpace) {
|
||||
const char *SavedTokStart = TokStart;
|
||||
const char *SavedCurPtr = CurPtr;
|
||||
bool SavedAtStartOfLine = isAtStartOfLine;
|
||||
bool SavedSkipSpace = SkipSpace;
|
||||
|
||||
std::string SavedErr = getErr();
|
||||
SMLoc SavedErrLoc = getErrLoc();
|
||||
|
||||
SkipSpace = ShouldSkipSpace;
|
||||
AsmToken Token = LexToken();
|
||||
|
||||
SetError(SavedErrLoc, SavedErr);
|
||||
|
||||
SkipSpace = SavedSkipSpace;
|
||||
isAtStartOfLine = SavedAtStartOfLine;
|
||||
CurPtr = SavedCurPtr;
|
||||
TokStart = SavedTokStart;
|
||||
|
||||
return Token;
|
||||
}
|
||||
|
||||
bool AsmLexer::isAtStartOfComment(char Char) {
|
||||
// FIXME: This won't work for multi-character comment indicators like "//".
|
||||
return Char == *MAI.getCommentString();
|
||||
|
Loading…
x
Reference in New Issue
Block a user