[llvm-commits] CVS: llvm/utils/TableGen/FileParser.y TableGen.cpp
Chris Lattner
lattner at cs.uiuc.edu
Wed Jul 30 14:49:00 PDT 2003
Changes in directory llvm/utils/TableGen:
FileParser.y updated: 1.10 -> 1.11
TableGen.cpp updated: 1.8 -> 1.9
---
Log message:
Make tablegen take an input filename to parse if one is specified, otherwise
use stdin.
---
Diffs of the changes:
Index: llvm/utils/TableGen/FileParser.y
diff -u llvm/utils/TableGen/FileParser.y:1.10 llvm/utils/TableGen/FileParser.y:1.11
--- llvm/utils/TableGen/FileParser.y:1.10 Wed Jul 30 00:17:35 2003
+++ llvm/utils/TableGen/FileParser.y Wed Jul 30 14:48:02 2003
@@ -24,12 +24,24 @@
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;
}
Index: llvm/utils/TableGen/TableGen.cpp
diff -u llvm/utils/TableGen/TableGen.cpp:1.8 llvm/utils/TableGen/TableGen.cpp:1.9
--- llvm/utils/TableGen/TableGen.cpp:1.8 Tue Jul 29 18:00:08 2003
+++ llvm/utils/TableGen/TableGen.cpp Wed Jul 30 14:48:02 2003
@@ -29,13 +29,16 @@
Class("class", cl::desc("Print Enum list for this class"),
cl::value_desc("class name"));
- cl::opt<std::string>
- OutputFilename("o", cl::desc("Output filename"), cl::value_desc("filename"),
- cl::init("-"));
+ cl::opt<std::string>
+ OutputFilename("o", cl::desc("Output filename"), cl::value_desc("filename"),
+ cl::init("-"));
+
+ cl::opt<std::string>
+ InputFilename(cl::Positional, cl::desc("<input file>"), cl::init("-"));
}
-void ParseFile();
+void ParseFile(const std::string &Filename);
RecordKeeper Records;
@@ -379,7 +382,7 @@
int main(int argc, char **argv) {
cl::ParseCommandLineOptions(argc, argv);
- ParseFile();
+ ParseFile(InputFilename);
std::ostream *Out = &std::cout;
if (OutputFilename != "-") {
More information about the llvm-commits
mailing list