diff options
| author | Chris Lattner <sabre@nondot.org> | 2003-07-30 19:48:02 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2003-07-30 19:48:02 +0000 |
| commit | 90523906fa31c8f4e156dc7ef4a433a50d4b706d (patch) | |
| tree | 87e30faa14fcfd36792a0c53aff7a0de5ddd7ab4 /utils/TableGen/FileParser.y | |
| parent | 35c7444e52efaeae5d9cc1024350edb25dae5447 (diff) | |
Make tablegen take an input filename to parse if one is specified, otherwise
use stdin.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7431 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/FileParser.y')
| -rw-r--r-- | utils/TableGen/FileParser.y | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/utils/TableGen/FileParser.y b/utils/TableGen/FileParser.y index 55938f47ea..b82569ab74 100644 --- a/utils/TableGen/FileParser.y +++ b/utils/TableGen/FileParser.y @@ -24,12 +24,24 @@ typedef std::pair<Record*, std::vector<Init*>*> SubClassRefTy; static std::vector<std::pair<std::pair<std::string, std::vector<unsigned>*>, Init*> > SetStack; -void ParseFile() { +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; } |
