예제 #1
0
        static void Main(string[] args)
        {
            string sourcepath = null, outputpath = null;
            bool isDisplay = false;
            bool isDisplayBinary = false;
            bool isOutputCOE = false;

            //arg input
            if (args.Length == 0)
            {
                ShowHelp();
                return;
            }
            else
            {
                sourcepath = args[args.Length - 1];
                if (args[args.Length - 1].EndsWith(".c"))
                {
                    outputpath = args[args.Length - 1].Substring(0, args[args.Length - 1].Length - 2);
                }
            }
            outputpath += ".txt";

            for (int i = 0; i < args.Length; i++)
            {
                switch (args[i])
                {
                    case "-h":
                    case "--help":
                        ShowHelp();
                        return;
                    case "-o":
                    case "--obj":
                        outputpath = args[i + 1];
                        break;
                    case "-d":
                    case "--display":
                        isDisplay = true;
                        break;
                    case "-b":
                        isDisplay = true;
                        isDisplayBinary = true;
                        break;
                    case "-t":
                        break;
                    case "-c":
                        isOutputCOE = true;
                        outputpath = outputpath.Substring(0, outputpath.Length - 4) + ".coe";
                        break;
                }
            }

            //do compile
            MIPS246.Core.Compiler.Compiler compiler = new MIPS246.Core.Compiler.Compiler(sourcepath, outputpath);
            if (compiler.DoCompile() == true)
            {
                if (isDisplay == true)
                {
                    compiler.Display(isDisplayBinary);
                }
                compiler.Output(isOutputCOE, outputpath);
            }
            else
            {
                compiler.DisplayError();
                return;
            }

            Console.ReadLine();
        }
예제 #2
0
        static void Main(string[] args)
        {
            string sourcepath = null, outputpath = null;
            bool   isDisplay       = false;
            bool   isDisplayBinary = false;
            bool   isOutputCOE     = false;

            if (args.Length == 0)
            {
                ShowHelp();
                return;
            }
            else
            {
                sourcepath = args[args.Length - 1];
                if (args[args.Length - 1].EndsWith(".c"))
                {
                    outputpath = args[args.Length - 1].Substring(0, args[args.Length - 1].Length - 2);
                }
            }
            outputpath += ".txt";

            for (int i = 0; i < args.Length; i++)
            {
                switch (args[i])
                {
                case "-h":
                case "--help":
                    ShowHelp();
                    return;

                case "-o":
                case "--obj":
                    outputpath = args[i + 1];
                    break;

                case "-d":
                case "--display":
                    isDisplay = true;
                    break;

                case "-b":
                    isDisplay       = true;
                    isDisplayBinary = true;
                    break;

                case "-t":
                    break;

                case "-c":
                    isOutputCOE = true;
                    outputpath  = outputpath.Substring(0, outputpath.Length - 4) + ".coe";
                    break;
                }
            }

            MIPS246.Core.Compiler.Compiler compiler = new MIPS246.Core.Compiler.Compiler(sourcepath, outputpath);
            if (compiler.DoCompile() == true)
            {
                if (isDisplay == true)
                {
                    compiler.Display(isDisplayBinary);
                }
                compiler.Output(isOutputCOE, outputpath);
            }
            else
            {
                compiler.DisplayError();
                return;
            }

            Console.ReadLine();
        }