BSPGenerationTools.StartupFileGenerator.ParseInterruptVectors C# (CSharp) Method

ParseInterruptVectors() public static method

public static ParseInterruptVectors ( string file, string tableStart, string tableEnd, string vectorLineA, string vectorLineB, string ignoredLine, string macroDef, int nameGroup, int commentGroup ) : InterruptVector[]
file string
tableStart string
tableEnd string
vectorLineA string
vectorLineB string
ignoredLine string
macroDef string
nameGroup int
commentGroup int
return InterruptVector[]
        public static InterruptVector[] ParseInterruptVectors(string file, string tableStart, string tableEnd, string vectorLineA, string vectorLineB, string ignoredLine, string macroDef, int nameGroup, int commentGroup)
        {
            var rgTableStart = new Regex(tableStart);
            var rgTableEnd = new Regex(tableEnd);
            var rgVectorLineA = new Regex(vectorLineA);
            var rgVectorLineB = vectorLineB == null ? null : new Regex(vectorLineB);
            var rgIgnoredLine = new Regex(ignoredLine);
            var rgMacroDef = (macroDef == null) ? null : new Regex(macroDef);

            Dictionary<string, string> macroValues = new Dictionary<string, string>();

            bool insideTable = false;
            List<InterruptVector> result = new List<InterruptVector>();
            foreach(var line in File.ReadAllLines(file))
            {
                if (!insideTable)
                {
                    if (rgMacroDef != null)
                    {
                        var m = rgMacroDef.Match(line);
                        if (m.Success)
                            macroValues[m.Groups[1].Value] = m.Groups[2].Value;
                    }

                    if (rgTableStart.IsMatch(line))
                    {
                        insideTable = true;
                        continue;
                    }
                }
                else
                {
                    if (string.IsNullOrWhiteSpace(line) || rgIgnoredLine.IsMatch(line))
                        continue;
                    else if (rgTableEnd.IsMatch(line))
                        break;

                    var m = rgVectorLineA.Match(line);
                    if (!m.Success && vectorLineB != null)
                        m = rgVectorLineB.Match(line);

                    if (!m.Success)
                        throw new Exception("Cannot parse interrupt vector table definition line: " + line);

                    InterruptVector vec = new InterruptVector { Name = m.Groups[nameGroup].Value };
                    if (m.Groups.Count > commentGroup)
                        vec.OptionalComment = m.Groups[commentGroup].Value;

                    string val;
                    if (vec.Name == "0")
                        vec = null;
                    else if (macroValues.TryGetValue(vec.Name, out val))
                        vec.SpecialVectorValue = val;

                    result.Add(vec);
                }
            }

            return result.ToArray();
        }
StartupFileGenerator