diff options
Diffstat (limited to 'llvm/lib/TableGen/TGLexer.cpp')
-rw-r--r-- | llvm/lib/TableGen/TGLexer.cpp | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/llvm/lib/TableGen/TGLexer.cpp b/llvm/lib/TableGen/TGLexer.cpp index d3dd27cbbb3..f833782e203 100644 --- a/llvm/lib/TableGen/TGLexer.cpp +++ b/llvm/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<tgtok::TokKind>(StringRef(Start, CurPtr - Start)) |