aboutsummaryrefslogtreecommitdiff
path: root/utils/TableGen/FileParser.y
diff options
context:
space:
mode:
Diffstat (limited to 'utils/TableGen/FileParser.y')
-rw-r--r--utils/TableGen/FileParser.y14
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;
}