From 450382f8929fb3d0c9f2f50a1261fa24f224c266 Mon Sep 17 00:00:00 2001 From: Nicolai Haehnle Date: Fri, 9 Mar 2018 18:32:04 +0000 Subject: [PATCH] TableGen: Remove space at EOL in TGLexer.{h,cpp} Change-Id: Ica5f39470174e85f173d3b6db95789033f75ce17 llvm-svn: 327158 --- lib/TableGen/TGLexer.cpp | 50 ++++++++++++++++++++-------------------- lib/TableGen/TGLexer.h | 18 +++++++-------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/lib/TableGen/TGLexer.cpp b/lib/TableGen/TGLexer.cpp index d3dd27cbbb3..f833782e203 100644 --- a/lib/TableGen/TGLexer.cpp +++ b/lib/TableGen/TGLexer.cpp @@ -56,7 +56,7 @@ int TGLexer::getNextChar() { // a random nul in the file. Disambiguate that here. if (CurPtr-1 != CurBuf.end()) return 0; // Just whitespace. - + // If this is the end of an included file, pop the parent file off the // include stack. SMLoc ParentIncludeLoc = SrcMgr.getParentIncludeLoc(CurBuffer); @@ -66,9 +66,9 @@ int TGLexer::getNextChar() { CurPtr = ParentIncludeLoc.getPointer(); return getNextChar(); } - + // Otherwise, return end of file. - --CurPtr; // Another call to lex will return EOF again. + --CurPtr; // Another call to lex will return EOF again. return EOF; } case '\n': @@ -80,7 +80,7 @@ int TGLexer::getNextChar() { *CurPtr != CurChar) ++CurPtr; // Eat the two char newline sequence. return '\n'; - } + } } int TGLexer::peekNextChar(int Index) { @@ -115,7 +115,7 @@ tgtok::TokKind TGLexer::LexToken() { case '=': return tgtok::equal; case '?': return tgtok::question; case '#': return tgtok::paste; - + case 0: case ' ': case '\t': @@ -154,7 +154,7 @@ tgtok::TokKind TGLexer::LexToken() { switch (NextNextChar) { default: break; - case '0': case '1': + case '0': case '1': if (NextChar == 'b') return LexNumber(); LLVM_FALLTHROUGH; @@ -184,24 +184,24 @@ tgtok::TokKind TGLexer::LexToken() { /// LexString - Lex "[^"]*" tgtok::TokKind TGLexer::LexString() { const char *StrStart = CurPtr; - + CurStrVal = ""; - + while (*CurPtr != '"') { // If we hit the end of the buffer, report an error. if (*CurPtr == 0 && CurPtr == CurBuf.end()) return ReturnError(StrStart, "End of file in string literal"); - + if (*CurPtr == '\n' || *CurPtr == '\r') return ReturnError(StrStart, "End of line in string literal"); - + if (*CurPtr != '\\') { CurStrVal += *CurPtr++; continue; } ++CurPtr; - + switch (*CurPtr) { case '\\': case '\'': case '"': // These turn into their literal character. @@ -215,7 +215,7 @@ tgtok::TokKind TGLexer::LexString() { CurStrVal += '\n'; ++CurPtr; break; - + case '\n': case '\r': return ReturnError(CurPtr, "escaped newlines not supported in tblgen"); @@ -229,7 +229,7 @@ tgtok::TokKind TGLexer::LexString() { return ReturnError(CurPtr, "invalid escape in string literal"); } } - + ++CurPtr; return tgtok::StrVal; } @@ -237,10 +237,10 @@ tgtok::TokKind TGLexer::LexString() { tgtok::TokKind TGLexer::LexVarName() { if (!isalpha(CurPtr[0]) && CurPtr[0] != '_') return ReturnError(TokStart, "Invalid variable name"); - + // Otherwise, we're ok, consume the rest of the characters. const char *VarNameStart = CurPtr++; - + while (isalpha(*CurPtr) || isdigit(*CurPtr) || *CurPtr == '_') ++CurPtr; @@ -309,7 +309,7 @@ bool TGLexer::LexInclude() { PrintError(getLoc(), "Could not find include file '" + Filename + "'"); return true; } - + DependenciesMapTy::const_iterator Found = Dependencies.find(IncludedFile); if (Found != Dependencies.end()) { PrintError(getLoc(), @@ -348,7 +348,7 @@ void TGLexer::SkipBCPLComment() { bool TGLexer::SkipCComment() { ++CurPtr; // skip the star. unsigned CommentDepth = 1; - + while (true) { int CurChar = getNextChar(); switch (CurChar) { @@ -358,7 +358,7 @@ bool TGLexer::SkipCComment() { case '*': // End of the comment? if (CurPtr[0] != '/') break; - + ++CurPtr; // End the */. if (--CommentDepth == 0) return false; @@ -384,7 +384,7 @@ tgtok::TokKind TGLexer::LexNumber() { const char *NumStart = CurPtr; while (isxdigit(CurPtr[0])) ++CurPtr; - + // Requires at least one hex digit. if (CurPtr == NumStart) return ReturnError(TokStart, "Invalid hexadecimal number"); @@ -423,7 +423,7 @@ tgtok::TokKind TGLexer::LexNumber() { else if (CurPtr[-1] == '+') return tgtok::plus; } - + while (isdigit(CurPtr[0])) ++CurPtr; CurIntVal = strtoll(TokStart, nullptr, 10); @@ -440,9 +440,9 @@ tgtok::TokKind TGLexer::LexBracket() { while (true) { int Char = getNextChar(); if (Char == EOF) break; - + if (Char != '}') continue; - + Char = getNextChar(); if (Char == EOF) break; if (Char == ']') { @@ -450,7 +450,7 @@ tgtok::TokKind TGLexer::LexBracket() { return tgtok::CodeFragment; } } - + return ReturnError(CodeStart-2, "Unterminated Code Block"); } @@ -458,11 +458,11 @@ tgtok::TokKind TGLexer::LexBracket() { tgtok::TokKind TGLexer::LexExclaim() { if (!isalpha(*CurPtr)) return ReturnError(CurPtr - 1, "Invalid \"!operator\""); - + const char *Start = CurPtr++; while (isalpha(*CurPtr)) ++CurPtr; - + // Check to see which operator this is. tgtok::TokKind Kind = StringSwitch(StringRef(Start, CurPtr - Start)) diff --git a/lib/TableGen/TGLexer.h b/lib/TableGen/TGLexer.h index c2222472195..2ffc2efdc30 100644 --- a/lib/TableGen/TGLexer.h +++ b/lib/TableGen/TGLexer.h @@ -30,7 +30,7 @@ namespace tgtok { enum TokKind { // Markers Eof, Error, - + // Tokens with no info. minus, plus, // - + l_square, r_square, // [ ] @@ -56,7 +56,7 @@ namespace tgtok { // Binary constant. Note that these are sized according to the number of // bits given. BinaryIntVal, - + // String valued tokens. Id, StrVal, VarName, CodeFragment }; @@ -65,7 +65,7 @@ namespace tgtok { /// TGLexer - TableGen Lexer class. class TGLexer { SourceMgr &SrcMgr; - + const char *CurPtr; StringRef CurBuf; @@ -95,11 +95,11 @@ public: const DependenciesMapTy &getDependencies() const { return Dependencies; } - + tgtok::TokKind getCode() const { return CurCode; } const std::string &getCurStrVal() const { - assert((CurCode == tgtok::Id || CurCode == tgtok::StrVal || + assert((CurCode == tgtok::Id || CurCode == tgtok::StrVal || CurCode == tgtok::VarName || CurCode == tgtok::CodeFragment) && "This token doesn't have a string value"); return CurStrVal; @@ -115,13 +115,13 @@ public: } SMLoc getLoc() const; - + private: /// LexToken - Read the next token and return its code. tgtok::TokKind LexToken(); - + tgtok::TokKind ReturnError(const char *Loc, const Twine &Msg); - + int getNextChar(); int peekNextChar(int Index); void SkipBCPLComment(); @@ -134,7 +134,7 @@ private: tgtok::TokKind LexBracket(); tgtok::TokKind LexExclaim(); }; - + } // end namespace llvm #endif