static void Main(string[] args)
        {
            bool        fileArg  = false;
            TaskState   task     = new TaskState();
            OptionState opResult = OptionState.clear;

            if (args.Length == 0)
            {
                Usage("No arguments");
            }
            for (int i = 1; i < args.Length; i++)
            {
                if (args[i][0] == '/' || args[i][0] == '-')
                {
                    string arg = args[i].Substring(1);
                    opResult = task.ParseCommandLineOption(args, ref i, arg);
                    if (opResult != OptionState.clear &&
                        opResult != OptionState.needCodepageHelp &&
                        opResult != OptionState.needUsage)
                    {
                        BadOption(arg, opResult);
                    }
                }
            }
            fileArg = true;
            if (task.Version)
            {
                task.Msg.WriteLine("Rolex version: " + task.VerString);
            }
            if (opResult == OptionState.needCodepageHelp)
            {
                CodepageHelp(fileArg);
            }
            if (opResult == OptionState.unknownArg)
            {
                Usage(null); // print usage and abort
            }
            else if (!fileArg)
            {
                Usage("No filename");
            }
            else if (opResult == OptionState.needUsage)
            {
                Usage();     // print usage but do not abort
            }
            try
            {
                task.Process2(args[0]);
            }

            /*catch (Exception ex)
             * {
             *  if (ex is TooManyErrorsException)
             *      return;
             *  Console.Error.WriteLine(ex.Message);
             *  throw;
             * }*/
            finally
            {
                if (task.ErrNum + task.WrnNum > 0 || task.Listing)
                {
                    task.MakeListing();
                }
                if (task.ErrNum + task.WrnNum > 0)
                {
                    task.ErrorReport();
                }
                else if (task.Verbose)
                {
                    task.Msg.WriteLine("Rolex <" + task.FileName + "> Completed successfully");
                }
                task.Dispose();
            }
            if (task.ErrNum > 0)
            {
                Environment.Exit(1);
            }
            else
            {
                Environment.Exit(0);
            }
        }
Beispiel #2
0
        private static void GenerateScanner(string[] args)
        {
            bool        fileArg  = false;
            TaskState   task     = new TaskState();
            OptionState opResult = OptionState.clear;

            if (args.Length == 0)
            {
                Usage("No arguments");
            }
            for (int i = 0; i < args.Length; i++)
            {
                if (args[i][0] == '/' || args[i][0] == '-')
                {
                    string arg = args[i].Substring(1);
                    opResult = task.ParseOption(arg);
                    if (opResult != OptionState.clear &&
                        opResult != OptionState.needCodepageHelp &&
                        opResult != OptionState.needUsage)
                    {
                        BadOption(arg, opResult);
                    }
                }
                else if (i != args.Length - 1)
                {
                    Usage("Too many arguments");
                }
                else
                {
                    fileArg = true;
                }
            }
            if (task.Version)
            {
                task.Msg.WriteLine("GPLEX version: " + task.VerString);
            }
            if (opResult == OptionState.needCodepageHelp)
            {
                CodepageHelp(fileArg);
            }
            if (opResult == OptionState.errors)
            {
                Usage(null); // print usage and abort
            }
            else if (!fileArg)
            {
                Usage("No filename");
            }
            else if (opResult == OptionState.needUsage)
            {
                Usage(); // print usage but do not abort
            }
            try
            {
                task.Process(args[args.Length - 1]);
            }
            catch (Exception ex)
            {
                if (ex is TooManyErrorsException)
                {
                    return;
                }
                Console.Error.WriteLine(ex.Message);
                throw;
            }
            finally
            {
                if (task.ErrNum + task.WrnNum > 0 || task.Listing)
                {
                    task.MakeListing();
                }
                if (task.ErrNum + task.WrnNum > 0)
                {
                    task.ErrorReport();
                }
                else if (task.Verbose)
                {
                    task.Msg.WriteLine("GPLEX <" + task.FileName + "> Completed successfully");
                }
                task.Dispose();
            }
        }
Beispiel #3
0
 public void Dispose()
 {
     TaskState.Dispose();
 }