diff options
author | Bill Wendling <isanbard@gmail.com> | 2010-12-08 13:03:15 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2010-12-08 13:03:15 +0000 |
commit | 4182a169306f6b43b49dcaa1fcb1b100a1d42b12 (patch) | |
tree | fdd285b10f3da31745ff9be6f2386cb0db41fad5 /llvm/utils/TableGen/TGLexer.cpp | |
parent | cf7731b40bcb162776fb2dca35aae72e60eb2496 (diff) | |
download | bcm5719-llvm-4182a169306f6b43b49dcaa1fcb1b100a1d42b12.tar.gz bcm5719-llvm-4182a169306f6b43b49dcaa1fcb1b100a1d42b12.zip |
Cleanup table a bit.
llvm-svn: 121250
Diffstat (limited to 'llvm/utils/TableGen/TGLexer.cpp')
-rw-r--r-- | llvm/utils/TableGen/TGLexer.cpp | 50 |
1 files changed, 32 insertions, 18 deletions
diff --git a/llvm/utils/TableGen/TGLexer.cpp b/llvm/utils/TableGen/TGLexer.cpp index 12fa39f0092..bdd1098d1e8 100644 --- a/llvm/utils/TableGen/TGLexer.cpp +++ b/llvm/utils/TableGen/TGLexer.cpp @@ -412,29 +412,43 @@ tgtok::TokKind TGLexer::LexBracket() { /// LexExclaim - Lex '!' and '![a-zA-Z]+'. tgtok::TokKind TGLexer::LexExclaim() { if (!isalpha(*CurPtr)) - return ReturnError(CurPtr-1, "Invalid \"!operator\""); + return ReturnError(CurPtr - 1, "Invalid \"!operator\""); const char *Start = CurPtr++; while (isalpha(*CurPtr)) ++CurPtr; // Check to see which operator this is. - unsigned Len = CurPtr-Start; - - if (Len == 3 && !memcmp(Start, "con", 3)) return tgtok::XConcat; - if (Len == 3 && !memcmp(Start, "sra", 3)) return tgtok::XSRA; - if (Len == 3 && !memcmp(Start, "srl", 3)) return tgtok::XSRL; - if (Len == 3 && !memcmp(Start, "shl", 3)) return tgtok::XSHL; - if (Len == 2 && !memcmp(Start, "eq", 2)) return tgtok::XEq; - if (Len == 9 && !memcmp(Start, "strconcat", 9)) return tgtok::XStrConcat; - if (Len == 5 && !memcmp(Start, "subst", 5)) return tgtok::XSubst; - if (Len == 7 && !memcmp(Start, "foreach", 7)) return tgtok::XForEach; - if (Len == 4 && !memcmp(Start, "cast", 4)) return tgtok::XCast; - if (Len == 3 && !memcmp(Start, "car", 3)) return tgtok::XCar; - if (Len == 3 && !memcmp(Start, "cdr", 3)) return tgtok::XCdr; - if (Len == 4 && !memcmp(Start, "null", 4)) return tgtok::XNull; - if (Len == 2 && !memcmp(Start, "if", 2)) return tgtok::XIf; - - return ReturnError(Start-1, "Unknown operator"); + switch (CurPtr - Start) { + default: + break; + case 2: + if (!memcmp(Start, "eq", 2)) return tgtok::XEq; + if (!memcmp(Start, "if", 2)) return tgtok::XIf; + break; + case 3: + if (!memcmp(Start, "car", 3)) return tgtok::XCar; + if (!memcmp(Start, "cdr", 3)) return tgtok::XCdr; + if (!memcmp(Start, "con", 3)) return tgtok::XConcat; + if (!memcmp(Start, "shl", 3)) return tgtok::XSHL; + if (!memcmp(Start, "sra", 3)) return tgtok::XSRA; + if (!memcmp(Start, "srl", 3)) return tgtok::XSRL; + break; + case 4: + if (!memcmp(Start, "cast", 4)) return tgtok::XCast; + if (!memcmp(Start, "null", 4)) return tgtok::XNull; + break; + case 5: + if (!memcmp(Start, "subst", 5)) return tgtok::XSubst; + break; + case 7: + if (!memcmp(Start, "foreach", 7)) return tgtok::XForEach; + break; + case 9: + if (!memcmp(Start, "strconcat", 9)) return tgtok::XStrConcat; + break; + } + + return ReturnError(Start - 1, "Unknown operator"); } |