virtual StringRef LexUntilEndOfStatement();
StringRef LexUntilEndOfLine();
+ virtual const AsmToken peekTok(bool ShouldSkipSpace = true);
+
bool isAtStartOfComment(char Char);
bool isAtStatementSeparator(const char *Ptr);
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;
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();