llvm.org GIT mirror llvm / 537dca9
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201058 91177308-0d34-0410-b5e6-96231b3b80d8 Saleem Abdulrasool 6 years ago
3 changed file(s) with 27 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
4646 virtual StringRef LexUntilEndOfStatement();
4747 StringRef LexUntilEndOfLine();
4848
49 virtual const AsmToken peekTok(bool ShouldSkipSpace = true);
50
4951 bool isAtStartOfComment(char Char);
5052 bool isAtStatementSeparator(const char *Ptr);
5153
159159 return CurTok;
160160 }
161161
162 /// peekTok - Look ahead at the next token to be lexed.
163 virtual const AsmToken peekTok(bool ShouldSkipSpace = true) = 0;
164
162165 /// getErrLoc - Get the current error location
163166 const SMLoc &getErrLoc() {
164167 return ErrLoc;
436436 ++CurPtr;
437437 }
438438 return StringRef(TokStart, CurPtr-TokStart);
439 }
440
441 const AsmToken AsmLexer::peekTok(bool ShouldSkipSpace) {
442 const char *SavedTokStart = TokStart;
443 const char *SavedCurPtr = CurPtr;
444 bool SavedAtStartOfLine = isAtStartOfLine;
445 bool SavedSkipSpace = SkipSpace;
446
447 std::string SavedErr = getErr();
448 SMLoc SavedErrLoc = getErrLoc();
449
450 SkipSpace = ShouldSkipSpace;
451 AsmToken Token = LexToken();
452
453 SetError(SavedErrLoc, SavedErr);
454
455 SkipSpace = SavedSkipSpace;
456 isAtStartOfLine = SavedAtStartOfLine;
457 CurPtr = SavedCurPtr;
458 TokStart = SavedTokStart;
459
460 return Token;
439461 }
440462
441463 bool AsmLexer::isAtStartOfComment(char Char) {