diff options
author | Chris Lattner <sabre@nondot.org> | 2003-07-30 19:55:10 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-07-30 19:55:10 +0000 |
commit | e623fe3d0af0935504cf0a9b41a3c6133d7dd420 (patch) | |
tree | 28efa02619e906e67683727752354ea6deeeb330 | |
parent | 90523906fa31c8f4e156dc7ef4a433a50d4b706d (diff) | |
download | external_llvm-e623fe3d0af0935504cf0a9b41a3c6133d7dd420.zip external_llvm-e623fe3d0af0935504cf0a9b41a3c6133d7dd420.tar.gz external_llvm-e623fe3d0af0935504cf0a9b41a3c6133d7dd420.tar.bz2 |
Minor reorganization, move ParseFile to the lexer
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7432 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | support/tools/TableGen/FileLexer.l | 22 | ||||
-rw-r--r-- | support/tools/TableGen/FileParser.y | 24 | ||||
-rw-r--r-- | utils/TableGen/FileLexer.l | 22 | ||||
-rw-r--r-- | utils/TableGen/FileParser.y | 24 |
4 files changed, 44 insertions, 48 deletions
diff --git a/support/tools/TableGen/FileLexer.l b/support/tools/TableGen/FileLexer.l index 7289ca0..c61e9de 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 b82569a..d1f8308 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 <iostream> #include <algorithm> #include <cstdio> #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<Record*, std::vector<Init*>*> SubClassRefTy; @@ -24,27 +21,6 @@ typedef std::pair<Record*, std::vector<Init*>*> SubClassRefTy; static std::vector<std::pair<std::pair<std::string, std::vector<unsigned>*>, 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 7289ca0..c61e9de 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 b82569a..d1f8308 100644 --- a/utils/TableGen/FileParser.y +++ b/utils/TableGen/FileParser.y @@ -7,16 +7,13 @@ %{ #include "Record.h" #include "Support/StringExtras.h" -#include <iostream> #include <algorithm> #include <cstdio> #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<Record*, std::vector<Init*>*> SubClassRefTy; @@ -24,27 +21,6 @@ typedef std::pair<Record*, std::vector<Init*>*> SubClassRefTy; static std::vector<std::pair<std::pair<std::string, std::vector<unsigned>*>, 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 << ": "; } |