Exemplo n.º 1
0
        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")
            });
Exemplo n.º 2
0
        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));
        }