public void ParseFile([CanBeNull] string[] hLines) { if (hLines == null) { return; } CommandTable.Clear(); CommandList.Clear(); DataTable.Clear(); DataList.Clear(); var currentSection = EFileSection.Undefined; foreach (var hLine in hLines) { var line = hLine; // Check for comments var commentIndex = line.IndexOf("@", StringComparison.Ordinal); if (commentIndex > -1) { line = line.Substring(0, commentIndex); } commentIndex = line.IndexOf("//", StringComparison.Ordinal); if (commentIndex > -1) { line = line.Substring(0, commentIndex); } // Remove leading, ending spaces, tabs line = line.Trim(' ', '\t'); if (string.IsNullOrEmpty(line)) { continue; } // Check for sections if (line.StartsWith(".", StringComparison.Ordinal)) { if (line.StartsWith(".text", StringComparison.Ordinal)) { currentSection = EFileSection.Text; continue; } if (line.StartsWith(".data", StringComparison.Ordinal)) { currentSection = EFileSection.Data; continue; } if (line.StartsWith(".global", StringComparison.Ordinal) || line.StartsWith(".globl", StringComparison.Ordinal)) { var split = line.Split(new [] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries); if (split.Length != 2) { throw new ArgumentException(); } EntryFunction = split[1]; continue; } if (line.StartsWith(".align", StringComparison.Ordinal)) { var split = line.Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries); if (split.Length != 2) { throw new ArgumentException(); } ParseAlign(split[1]); continue; } if (line.StartsWith(".type", StringComparison.Ordinal)) { // TODO: Implement missing member continue; } if (line.StartsWith(".Lfe", StringComparison.Ordinal)) { // TODO: Implement missing member continue; } if (line.StartsWith(".size", StringComparison.Ordinal)) { // TODO: Implement missing member continue; } if (line.Equals(".end", StringComparison.Ordinal)) { // End of file return; } } switch (currentSection) { case EFileSection.Undefined: break; case EFileSection.Text: ParseTextSection(line); break; case EFileSection.Data: ParseDataSection(line); break; case EFileSection.Comm: break; default: throw new ArgumentOutOfRangeException(); } } }