diff --git a/support/tools/TableGen/FileLexer.l b/support/tools/TableGen/FileLexer.l index 7289ca0bbba..c61e9ded3f7 100644 --- a/support/tools/TableGen/FileLexer.l +++ b/support/tools/TableGen/FileLexer.l @@ -32,6 +32,28 @@ static int ParseInt(const char *Str) { static int CommentDepth = 0; +int Fileparse(); + +void ParseFile(const std::string &Filename) { + FILE *F = stdin; + if (Filename != "-") { + F = fopen(Filename.c_str(), "r"); + + if (F == 0) { + std::cerr << "Could not open input file '" + Filename + "'!\n"; + abort(); + } + } + + Filein = F; + Filelineno = 1; + Fileparse(); + + if (F != stdin) + fclose(F); + Filein = stdin; +} + %} Comment \/\/.* diff --git a/support/tools/TableGen/FileParser.y b/support/tools/TableGen/FileParser.y index b82569ab742..d1f8308ce47 100644 --- a/support/tools/TableGen/FileParser.y +++ b/support/tools/TableGen/FileParser.y @@ -7,16 +7,13 @@ %{ #include "Record.h" #include "Support/StringExtras.h" -#include #include #include #define YYERROR_VERBOSE 1 int yyerror(const char *ErrorMsg); int yylex(); -extern FILE *Filein; extern int Filelineno; -int Fileparse(); static Record *CurRec = 0; typedef std::pair*> SubClassRefTy; @@ -24,27 +21,6 @@ typedef std::pair*> SubClassRefTy; static std::vector*>, Init*> > SetStack; -void ParseFile(const std::string &Filename) { - FILE *F = stdin; - if (Filename != "-") { - F = fopen(Filename.c_str(), "r"); - - if (F == 0) { - std::cerr << "Could not open input file '" + Filename + "'!\n"; - abort(); - } - } - - - Filein = F; - Filelineno = 1; - Fileparse(); - - if (F != stdin) - fclose(F); - Filein = stdin; -} - static std::ostream &err() { return std::cerr << "Parsing Line #" << Filelineno << ": "; } diff --git a/utils/TableGen/FileLexer.l b/utils/TableGen/FileLexer.l index 7289ca0bbba..c61e9ded3f7 100644 --- a/utils/TableGen/FileLexer.l +++ b/utils/TableGen/FileLexer.l @@ -32,6 +32,28 @@ static int ParseInt(const char *Str) { static int CommentDepth = 0; +int Fileparse(); + +void ParseFile(const std::string &Filename) { + FILE *F = stdin; + if (Filename != "-") { + F = fopen(Filename.c_str(), "r"); + + if (F == 0) { + std::cerr << "Could not open input file '" + Filename + "'!\n"; + abort(); + } + } + + Filein = F; + Filelineno = 1; + Fileparse(); + + if (F != stdin) + fclose(F); + Filein = stdin; +} + %} Comment \/\/.* diff --git a/utils/TableGen/FileParser.y b/utils/TableGen/FileParser.y index b82569ab742..d1f8308ce47 100644 --- a/utils/TableGen/FileParser.y +++ b/utils/TableGen/FileParser.y @@ -7,16 +7,13 @@ %{ #include "Record.h" #include "Support/StringExtras.h" -#include #include #include #define YYERROR_VERBOSE 1 int yyerror(const char *ErrorMsg); int yylex(); -extern FILE *Filein; extern int Filelineno; -int Fileparse(); static Record *CurRec = 0; typedef std::pair*> SubClassRefTy; @@ -24,27 +21,6 @@ typedef std::pair*> SubClassRefTy; static std::vector*>, Init*> > SetStack; -void ParseFile(const std::string &Filename) { - FILE *F = stdin; - if (Filename != "-") { - F = fopen(Filename.c_str(), "r"); - - if (F == 0) { - std::cerr << "Could not open input file '" + Filename + "'!\n"; - abort(); - } - } - - - Filein = F; - Filelineno = 1; - Fileparse(); - - if (F != stdin) - fclose(F); - Filein = stdin; -} - static std::ostream &err() { return std::cerr << "Parsing Line #" << Filelineno << ": "; }