Esempio n. 1
0
        public void RunTests()
        {
            string [] fileArray = Directory.GetFiles(InitDirectory, "*.java");

            int i = 0;

            foreach (string fileName in fileArray)
            {
                MiniJavaCompiler compiler = new MiniJavaCompiler(fileName);

                Console.WriteLine("BEGIN RUN TEST FOR  [{0}]", fileName);
                compiler.Compile(OutputPath);
                Console.WriteLine("END RUN TEST FOR  [{0}]", fileName);
                Console.WriteLine();
                Console.WriteLine();
                if (!compiler.HasError)
                {
                    i++;
                }
            }
            Console.WriteLine("{0} from {1} completed", i, fileArray.Length);
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            //string fileName = @"test5.txt";
            //string fileName = @"linkedlist.java";
            //string fileName = @"samples\treevisitor.java";
            //string fileName = @"root_calc.txt";
            //Dictionary<CommandArgumentType, string> commands = new Dictionary<CommandArgumentType, string>();
            //commands.Add(CommandArgumentType.Input, fileName);
            //commands.Add(CommandArgumentType.OutputDirectory, string.Empty);
            //commands.Add(CommandArgumentType.OutputDirectory, @"samples\results");

            Dictionary <CommandArgumentType, string> commands = CommandHelper.ParseCommandArgs(args);

            try
            {
                MiniJavaCompiler compiler = new MiniJavaCompiler(commands[CommandArgumentType.Input]);
                compiler.Compile(commands[CommandArgumentType.OutputDirectory]);
            }
            catch (Exception ex)
            {
                Console.WriteLine("{0}: {1}", MessagesHelper.UnhandledError, ex);
                Console.WriteLine("{0}", MessagesHelper.HelpUsage);
            }
        }