public ParsingResult Process(string filePath) { if (!File.Exists(filePath)) { Logger.Error($"File {filePath} doesn't exist"); throw new FileNotFoundException(filePath); } using (var file = File.OpenRead(filePath)) { var result = new ParsingResult(); Logger.Info($"Reading content of {filePath}"); using (var reader = new StreamReader(file)) { var lexemBuffer = ""; while (!reader.EndOfStream) { char currentSymbol = (char)reader.Read(); if (!Char.IsWhiteSpace(currentSymbol)) { var processingResult = Process(currentSymbol, reader); if (processingResult.Item1.Equals(State.Error)) { throw new Exception($"Unsupported character '{currentSymbol}' detected after '{result.CommonSymbolTable.LastOrDefault()?.Lexem}'."); } else { result.AddLexemLog(processingResult); } } } } return(result); } }