- unsigned Len = CurPtr-Start;
-
- if (Len == 3 && !memcmp(Start, "con", 3)) return CONCATTOK;
- if (Len == 3 && !memcmp(Start, "sra", 3)) return SRATOK;
- if (Len == 3 && !memcmp(Start, "srl", 3)) return SRLTOK;
- if (Len == 3 && !memcmp(Start, "shl", 3)) return SHLTOK;
- if (Len == 9 && !memcmp(Start, "strconcat", 9)) return STRCONCATTOK;
-
- return ReturnError(Start-1, "Unknown operator");
-}
-
-//===----------------------------------------------------------------------===//
-// Interfaces used by the Bison parser.
-//===----------------------------------------------------------------------===//
-
-int Fileparse();
-static TGLexer *TheLexer;
-
-namespace llvm {
-
-std::ostream &err() {
- return TheLexer->err();
-}
-
-/// ParseFile - this function begins the parsing of the specified tablegen
-/// file.
-///
-void ParseFile(const std::string &Filename,
- const std::vector<std::string> &IncludeDirs) {
- std::string ErrorStr;
- MemoryBuffer *F = MemoryBuffer::getFileOrSTDIN(&Filename[0], Filename.size(),
- &ErrorStr);
- if (F == 0) {
- cerr << "Could not open input file '" + Filename + "': " << ErrorStr <<"\n";
- exit(1);
- }
-
- assert(!TheLexer && "Lexer isn't reentrant yet!");
- TheLexer = new TGLexer(F);
-
- // Record the location of the include directory so that the lexer can find
- // it later.
- TheLexer->setIncludeDirs(IncludeDirs);
-
- Fileparse();
-
- // Cleanup
- delete TheLexer;
- TheLexer = 0;
+ tgtok::TokKind Kind =
+ StringSwitch<tgtok::TokKind>(StringRef(Start, CurPtr - Start))
+ .Case("eq", tgtok::XEq)
+ .Case("if", tgtok::XIf)
+ .Case("head", tgtok::XHead)
+ .Case("tail", tgtok::XTail)
+ .Case("con", tgtok::XConcat)
+ .Case("shl", tgtok::XSHL)
+ .Case("sra", tgtok::XSRA)
+ .Case("srl", tgtok::XSRL)
+ .Case("cast", tgtok::XCast)
+ .Case("empty", tgtok::XEmpty)
+ .Case("subst", tgtok::XSubst)
+ .Case("foreach", tgtok::XForEach)
+ .Case("strconcat", tgtok::XStrConcat)
+ .Default(tgtok::Error);
+
+ return Kind != tgtok::Error ? Kind : ReturnError(Start-1, "Unknown operator");