llvm.org GIT mirror llvm / 9052390
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 Chris Lattner 16 years ago
4 changed file(s) with 48 addition(s) and 18 deletion(s). Raw diff Collapse all Expand all
2323 static std::vector*>,
2424 Init*> > SetStack;
2525
26 void ParseFile() {
26 void ParseFile(const std::string &Filename) {
2727 FILE *F = stdin;
28 if (Filename != "-") {
29 F = fopen(Filename.c_str(), "r");
30
31 if (F == 0) {
32 std::cerr << "Could not open input file '" + Filename + "'!\n";
33 abort();
34 }
35 }
36
2837
2938 Filein = F;
3039 Filelineno = 1;
3140 Fileparse();
41
42 if (F != stdin)
43 fclose(F);
3244 Filein = stdin;
3345 }
3446
2828 Class("class", cl::desc("Print Enum list for this class"),
2929 cl::value_desc("class name"));
3030
31 cl::opt
32 OutputFilename("o", cl::desc("Output filename"), cl::value_desc("filename"),
33 cl::init("-"));
34 }
35
36
37 void ParseFile();
31 cl::opt
32 OutputFilename("o", cl::desc("Output filename"), cl::value_desc("filename"),
33 cl::init("-"));
34
35 cl::opt
36 InputFilename(cl::Positional, cl::desc(""), cl::init("-"));
37 }
38
39
40 void ParseFile(const std::string &Filename);
3841
3942 RecordKeeper Records;
4043
378381
379382 int main(int argc, char **argv) {
380383 cl::ParseCommandLineOptions(argc, argv);
381 ParseFile();
384 ParseFile(InputFilename);
382385
383386 std::ostream *Out = &std::cout;
384387 if (OutputFilename != "-") {
2323 static std::vector*>,
2424 Init*> > SetStack;
2525
26 void ParseFile() {
26 void ParseFile(const std::string &Filename) {
2727 FILE *F = stdin;
28 if (Filename != "-") {
29 F = fopen(Filename.c_str(), "r");
30
31 if (F == 0) {
32 std::cerr << "Could not open input file '" + Filename + "'!\n";
33 abort();
34 }
35 }
36
2837
2938 Filein = F;
3039 Filelineno = 1;
3140 Fileparse();
41
42 if (F != stdin)
43 fclose(F);
3244 Filein = stdin;
3345 }
3446
2828 Class("class", cl::desc("Print Enum list for this class"),
2929 cl::value_desc("class name"));
3030
31 cl::opt
32 OutputFilename("o", cl::desc("Output filename"), cl::value_desc("filename"),
33 cl::init("-"));
34 }
35
36
37 void ParseFile();
31 cl::opt
32 OutputFilename("o", cl::desc("Output filename"), cl::value_desc("filename"),
33 cl::init("-"));
34
35 cl::opt
36 InputFilename(cl::Positional, cl::desc(""), cl::init("-"));
37 }
38
39
40 void ParseFile(const std::string &Filename);
3841
3942 RecordKeeper Records;
4043
378381
379382 int main(int argc, char **argv) {
380383 cl::ParseCommandLineOptions(argc, argv);
381 ParseFile();
384 ParseFile(InputFilename);
382385
383386 std::ostream *Out = &std::cout;
384387 if (OutputFilename != "-") {