public static string Parse(string command) { var type = Parser.GetCommandType(command); return(type switch { CommandType.A => TranslateAInstruction(command), CommandType.C => TranslateCInstruction(command), _ => throw new ArgumentOutOfRangeException(nameof(command), "Only A & C instructions should be parsed") });
private static bool IsInstruction(string line) { if (string.IsNullOrWhiteSpace(line) || line.StartsWith("//")) { return(false); } var type = Parser.GetCommandType(line); return(!(type is CommandType.L || type is CommandType.Unrecognized)); }