From 90523906fa31c8f4e156dc7ef4a433a50d4b706d Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 30 Jul 2003 19:48:02 +0000 Subject: 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 --- utils/TableGen/FileParser.y | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'utils/TableGen/FileParser.y') 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*> SubClassRefTy; static std::vector*>, 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; } -- cgit v1.2.3-70-g09d2