public static FunctionStackInfo Create(LineInstance suFileLine) { if (!LineRegex.IsMatch(suFileLine.Line)) { throw new ArgumentException($"Line '{ suFileLine }' does not match SU file line", nameof(suFileLine)); } var matches = LineRegex.Match(suFileLine.Line); var file = matches.Groups[1].Value; var line = uint.Parse(matches.Groups[2].Value); var column = uint.Parse(matches.Groups[3].Value); var name = matches.Groups[4].Value; var bytes = uint.Parse(matches.Groups[5].Value); var qualifier = ParseQualifier(matches.Groups[6].Value.Trim()); return(Create(Path.Combine(Path.GetDirectoryName(suFileLine.FileName), file).Replace("\\Debug\\", "\\"), name, line, column, bytes, qualifier)); }
public static FunctionStackInfo Create(string suFileLine) { if (!LineRegex.IsMatch(suFileLine)) { throw new ArgumentException($"Line '{ suFileLine }' does not match SU file line", nameof(suFileLine)); } var matches = LineRegex.Match(suFileLine); var file = matches.Groups[1].Value; var line = uint.Parse(matches.Groups[2].Value); var column = uint.Parse(matches.Groups[3].Value); var name = matches.Groups[4].Value; var bytes = uint.Parse(matches.Groups[5].Value); var qualifier = ParseQualifier(matches.Groups[6].Value.Trim()); return(Create(file, name, line, column, bytes, qualifier)); }
protected override IList <string> SplitToLines(string serialized) { _sideboardIndicator = getSideboardIndicator(serialized); var lines = serialized.Trim().Split(Array.From("\r\n", "\r", "\n"), StringSplitOptions.None); var result = new List <string>(); foreach (string line in lines) { var match = LineRegex.Match(line); if (line == string.Empty) { if (result.Count > 0 && result[result.Count - 1] != string.Empty) { result.Add(line); } } else if (isSideboardIndicator(line)) { result.Add(line); } else if (match.Success && isKnownMtgoName(match.Groups["name"].Value)) { result.Add(line); } else if (line.IndexOf("\t", Str.Comparison) >= 0) { var parts = line.Split(Array.From('\t'), StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < parts.Length; i++) { if (isKnownMtgoName(parts[i])) { if (i > 0 && parts[i - 1].All(char.IsDigit)) { result.Add(parts[i - 1] + ' ' + parts[i]); } else if (i < parts.Length - 1 && parts[i + 1].All(char.IsDigit)) { result.Add(parts[i + 1] + ' ' + parts[i]); } break; } } } else { var splits = _splitterRegex.Matches(line) .OfType <Match>() .Select(m => m.Index) .ToList(); if (splits.Count > 0) { splits.Add(line.Length); } for (int i = 0; i < splits.Count - 1; i++) { string substring = line.Substring(splits[i], splits[i + 1] - splits[i]).TrimEnd(); if (LineRegex.IsMatch(substring)) { result.Add(substring); } } } } return(result); }