Ejemplo n.º 1
0
 public static void Main(string[] args)
 {
     string targetLanguage = args[0];
     string sourceFilePath = args[1];
     string outputFilePath = args[2];
     var parser = ParserWrapper.Parse(sourceFilePath, Console.Out);
     var symbolTable = new SymbolTable();
     symbolTable.FindSymbols(parser.RootNode);
     Print(parser.RootNode, 0);
     File.Delete(outputFilePath);
     using (var file = File.OpenWrite(outputFilePath))
     using (var writer = new StreamWriter(file))
     {
         ICodeGenerator generator;
         if (targetLanguage == "cil")
             generator = new CilCodeGenerator(writer);
         else if (targetLanguage == "jasmin")
             generator = new JasminCodeGenerator(writer);
         else if (targetLanguage == "javascript")
             generator = new JavaScriptCodeGenerator(writer);
         else
         {
             Console.WriteLine("Unsupported target language: '{0}' (must be 'cil', 'jasmin', or 'javascript')", targetLanguage);
             return;
         }
         generator.Generate(parser.RootNode);
     }
 }