-//===----------------------------------------------------------------------===//
-// 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;
-}
-} // End llvm namespace
-
-
-int Filelex() {
- assert(TheLexer && "No lexer setup yet!");
- int Tok = TheLexer->LexToken();
- if (Tok == YYERROR)
- exit(1);
- return Tok;
-}