public IEnumerable<int> Parse(string message) { var lexer = new StringCalculatorLexer(message); var delimiters = new HashSet<string>(); string numbersString = null; foreach (var token in lexer.Read()) { if (token is DelimiterToken) { delimiters.Add(token.Content); } if (token is NumbersToken) { numbersString = token.Content; } } if (string.IsNullOrEmpty(numbersString)) { return Enumerable.Empty<int>(); } var numberSplitter = delimiters.Any() ? delimiters.GenerateSplitter() : _defaultSplitter; return numberSplitter .Split(numbersString) .Select(int.Parse); }