Antlr3.AntlrTool.ProcessArgs C# (CSharp) Method

ProcessArgs() public method

public ProcessArgs ( string args ) : void
args string
return void
        public virtual void ProcessArgs(string[] args)
        {
            if (verbose)
            {
                ErrorManager.Info("ANTLR Parser Generator  Version " + AssemblyInformationalVersion);
                showBanner = false;
            }

            if (args == null || args.Length == 0)
            {
                Help();
                return;
            }

            for (int i = 0; i < args.Length; i++)
            {
                switch (args[i])
                {
                case "-o":
                case "-fo":
                    if (i + 1 >= args.Length)
                    {
                        Console.Error.WriteLine("missing output directory with -fo/-o option; ignoring");
                    }
                    else
                    {
                        if (args[i] == "-fo")
                            ForceAllFilesToOutputDir = true;
                        i++;
                        outputDirectory = args[i];
                        if (outputDirectory.LastIndexOfAny(new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }) == outputDirectory.Length - 1)
                            outputDirectory = outputDirectory.Substring(0, OutputDirectory.Length - 1);

                        haveOutputDir = true;
                        if (System.IO.File.Exists(outputDirectory))
                        {
                            ErrorManager.Error(ErrorManager.MSG_OUTPUT_DIR_IS_FILE, outputDirectory);
                            LibraryDirectory = ".";
                        }
                    }

                    break;

                case "-lib":
                    if (i + 1 >= args.Length)
                    {
                        Console.Error.WriteLine("missing library directory with -lib option; ignoring");
                    }
                    else
                    {
                        i++;
                        LibraryDirectory = args[i];
                        if (LibraryDirectory.LastIndexOfAny(new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }) == LibraryDirectory.Length - 1)
                        {
                            LibraryDirectory = LibraryDirectory.Substring(0, LibraryDirectory.Length - 1);
                        }

                        if (!System.IO.Directory.Exists(libDirectory))
                        {
                            ErrorManager.Error(ErrorManager.MSG_DIR_NOT_FOUND, LibraryDirectory);
                            LibraryDirectory = ".";
                        }
                    }

                    break;

                case "-language":
                    if (i + 1 >= args.Length)
                    {
                        Console.Error.WriteLine("missing language name; ignoring");
                    }
                    else
                    {
                        i++;
                        ForcedLanguageOption = args[i];
                    }

                    break;

                case "-nfa":
                    Generate_NFA_dot = true;
                    break;

                case "-dfa":
                    Generate_DFA_dot = true;
                    break;

                case "-dgml":
                    GenerateDgmlGraphs = true;
                    break;

                case "-debug":
                    Debug = true;
                    break;

                case "-trace":
                    Trace = true;
                    break;

                case "-report":
                    Report = true;
                    break;

                case "-profile":
                    Profile = true;
                    break;

                case "-print":
                    PrintGrammar = true;
                    break;

                case "-depend":
                    Depend = true;
                    break;

                case "-testmode":
                    TestMode = true;
                    break;

                case "-verbose":
                    Verbose = true;
                    break;

                case "-version":
                    Version();
                    exitNow = true;
                    break;

                case "-make":
                    Make = true;
                    break;

                case "-message-format":
                    if (i + 1 >= args.Length)
                    {
                        Console.Error.WriteLine("missing output format with -message-format option; using default");
                    }
                    else
                    {
                        i++;
                        ErrorManager.SetFormat(args[i]);
                    }

                    break;

                case "-Xgrtree":
                    internalOption_PrintGrammarTree = true;
                    break;

                case "-Xdfa":
                    internalOption_PrintDFA = true;
                    break;

                case "-Xnoprune":
                    DFAOptimizer.PRUNE_EBNF_EXIT_BRANCHES = false;
                    break;

                case "-Xnocollapse":
                    DFAOptimizer.COLLAPSE_ALL_PARALLEL_EDGES = false;
                    break;

                case "-Xdbgconversion":
                    NFAToDFAConverter.debug = true;
                    break;

                case "-Xmultithreaded":
                    //NFAToDFAConverter.SINGLE_THREADED_NFA_CONVERSION = false;
                    Console.Error.WriteLine("Multithreaded NFA conversion is not currently supported.");
                    break;

                case "-Xnomergestopstates":
                    DFAOptimizer.MergeStopStates = false;
                    break;

                case "-Xdfaverbose":
                    internalOption_ShowNFAConfigsInDFA = true;
                    break;

                case "-Xwatchconversion":
                    internalOption_watchNFAConversion = true;
                    break;

            #if DEBUG
                case "-XdbgST":
                    CodeGenerator.LaunchTemplateInspector = true;
                    break;
            #endif

                case "-Xmaxinlinedfastates":
                    if (i + 1 >= args.Length)
                    {
                        Console.Error.WriteLine("missing max inline dfa states -Xmaxinlinedfastates option; ignoring");
                    }
                    else
                    {
                        i++;
                        CodeGenerator.MaxAcyclicDfaStatesInline = int.Parse(args[i]);
                    }

                    break;

                case "-Xmaxswitchcaselabels":
                    if (i + 1 >= args.Length)
                    {
                        Console.Error.WriteLine("missing max switch case labels -Xmaxswitchcaselabels option; ignoring");
                    }
                    else
                    {
                        i++;
                        int value;
                        if (int.TryParse(args[i], out value))
                            CodeGenerator.MaxSwitchCaseLabels = value;
                        else
                            Console.Error.WriteLine(string.Format("invalid value '{0}' for max switch case labels -Xmaxswitchcaselabels option; ignoring", args[i]));
                    }

                    break;

                case "-Xminswitchalts":
                    if (i + 1 >= args.Length)
                    {
                        Console.Error.WriteLine("missing min switch alternatives -Xminswitchalts option; ignoring");
                    }
                    else
                    {
                        i++;
                        int value;
                        if (int.TryParse(args[i], out value))
                            CodeGenerator.MinSwitchAlts = value;
                        else
                            Console.Error.WriteLine(string.Format("invalid value '{0}' for min switch alternatives -Xminswitchalts option; ignoring", args[i]));
                    }

                    break;

                case "-Xm":
                    if (i + 1 >= args.Length)
                    {
                        Console.Error.WriteLine("missing max recursion with -Xm option; ignoring");
                    }
                    else
                    {
                        i++;
                        NFAContext.MAX_SAME_RULE_INVOCATIONS_PER_NFA_CONFIG_STACK = int.Parse(args[i]);
                    }

                    break;

                case "-Xmaxdfaedges":
                    if (i + 1 >= args.Length)
                    {
                        Console.Error.WriteLine("missing max number of edges with -Xmaxdfaedges option; ignoring");
                    }
                    else
                    {
                        i++;
                        DFA.MAX_STATE_TRANSITIONS_FOR_TABLE = int.Parse(args[i]);
                    }

                    break;

                case "-Xconversiontimeout":
                    if (i + 1 >= args.Length)
                    {
                        Console.Error.WriteLine("missing max time in ms -Xconversiontimeout option; ignoring");
                    }
                    else
                    {
                        i++;
                        DFA.MAX_TIME_PER_DFA_CREATION = TimeSpan.FromMilliseconds(int.Parse(args[i]));
                    }

                    break;

                case "-Xnfastates":
                    DecisionProbe.verbose = true;
                    break;

                case "-Xsavelexer":
                    deleteTempLexer = false;
                    break;

                case "-Xtimer":
                    _showTimer = true;
                    break;

                case "-Xcachetemplates":
                    EnableTemplateCache = true;
                    break;

                case "-Xrepeat":
                    break;

                case "-X":
                    ExtendedHelp();
                    break;

                default:
                    if (args[i][0] != '-')
                    {
                        // Must be the grammar file
                        AddGrammarFile(args[i]);
                    }

                    break;
                }
            }
        }