private static void ShowError(FileLineSource fileSource, string type, string message) { Console.Write($"{type} error: ".Pastel(Color.Tomato)); Console.WriteLine(message); Console.Write($"\nLine {fileSource.ProcessedLines}: "); Console.WriteLine($"{fileSource.CurrentLine}\n".Pastel(Color.Teal)); }
public Task StartAsync(CancellationToken cancellationToken) { if (config.SourceFilename == null) { Usage(); } logger.LogInformation("start async"); if (!config.QuietOutput) { config.ToConsole(); } FileLineSource rawFileSource = new FileLineSource(config.SourceFilename); ILineSource lineSource = new CommentStrippingLineSource( new WhitespaceRemovalLineSource( rawFileSource)); try { var start = DateTime.Now; parser.ParseAllLines(lineSource); CodeGenerator.GenerateCode(parser.Instructions); Ram.Save(config.BinaryFilename); SymbolTable.Save(config.SymbolFilename); if (!config.QuietOutput) { Console.WriteLine("\nSymbols\n"); SymbolTable.ToConsole(); } Console.WriteLine($"\nAssembled {lineSource.ProcessedLines} lines in {(DateTime.Now - start).TotalMilliseconds} (ms)\n"); } catch (AssemblerException e) { ShowError(rawFileSource, "Assembler", e.Message); } catch (Exception otherException) { ShowError(rawFileSource, "Internal", otherException.Message); } applicationLifetime.StopApplication(); return(Task.CompletedTask); }