private static string FormatMessage(TokenType[] tokenTypes, int offset) { if (tokenTypes.Length == 0) { return string.Format("Expected (unkonwn) at character {0}.", offset); } if (tokenTypes.Length == 1) { return string.Format("Expected {0} at character {1}.", tokenTypes[0], offset); } var tokenTypeList = string.Join(", ", tokenTypes.Take(tokenTypes.Length - 1).Select(t => t.ToString())) + " or " + tokenTypes[tokenTypes.Length - 1]; return string.Format("Expected {0} at character {1}.", tokenTypeList, offset); }