Converted to use flex for tokenizing input so we can use an easier to
understand recursive descent parser, we can easily handle more syntax
variety, and we can more easily change the configuration items accepted.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15732 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/llvmc/CompilerDriver.cpp b/tools/llvmc/CompilerDriver.cpp
index f1d3e58..ff63b21 100644
--- a/tools/llvmc/CompilerDriver.cpp
+++ b/tools/llvmc/CompilerDriver.cpp
@@ -29,8 +29,38 @@
     if ( dotpos = std::string::npos ) return "";
     return fullName.substr(dotpos+1);
   }
+
   const char OutputSuffix[] = ".o";
 
+  void WriteAction(CompilerDriver::Action* a) {
+    std::cerr << a->program;
+    std::vector<std::string>::iterator I = a->args.begin();
+    while (I != a->args.end()) {
+      std::cerr << " " + *I;
+      ++I;
+    }
+    std::cerr << "\n";
+  }
+
+  void DumpConfigData(CompilerDriver::ConfigData* cd, const std::string& type ){
+    std::cerr << "Configuration Data For '" << cd->langName << "' (" << type 
+      << ")\n";
+    std::cerr << "translator.preprocesses=" << cd->TranslatorPreprocesses 
+      << "\n";
+    std::cerr << "translator.groks_dash_O=" << cd->TranslatorGroksDashO << "\n";
+    std::cerr << "translator.optimizes=" << cd->TranslatorOptimizes << "\n";
+    std::cerr << "preprocessor.needed=" << cd->PreprocessorNeeded << "\n";
+    std::cerr << "PreProcessor: ";
+    WriteAction(&cd->PreProcessor);
+    std::cerr << "Translator: ";
+    WriteAction(&cd->Translator);
+    std::cerr << "Optimizer: ";
+    WriteAction(&cd->Optimizer);
+    std::cerr << "Assembler: ";
+    WriteAction(&cd->Assembler);
+    std::cerr << "Linker: ";
+    WriteAction(&cd->Linker);
+  }
 }
 
 
@@ -80,21 +110,13 @@
   }
   assert(pat != 0 && "Invalid command pattern");
   Action* a = new Action(*pat);
-  a->args[pat->inputAt] = input;
-  a->args[pat->outputAt] = output;
+  if (pat->inputAt < a->args.size())
+    a->args[pat->inputAt] = input;
+  if (pat->outputAt < a->args.size())
+    a->args[pat->outputAt] = output;
   return a;
 }
 
-void CompilerDriver::WriteAction(Action* a) {
-  std::cerr << a->program;
-  std::vector<std::string>::iterator I = a->args.begin();
-  while (I != a->args.end()) {
-    std::cerr << " " + *I;
-    ++I;
-  }
-  std::cerr << "\n";
-}
-
 void CompilerDriver::DoAction(Action*a)
 {
   if (isVerbose)
@@ -170,6 +192,8 @@
     if (cd == 0)
       error(std::string("Files of type '") + I->second + 
             "' are not recognized." ); 
+    if (isDebug)
+      DumpConfigData(cd,I->second);
 
     // We have valid configuration data, now figure out where the output
     // of compilation should end up.