private static string GetContext(IStringReader reader) { int minimum = Math.Max(reader.GetCursor() - 10, 0); int maximum = Math.Min(reader.GetCursor(), reader.GetLength()); StringBuilder builder = new StringBuilder($" at position {reader.GetCursor()}: "); if (minimum > 0) { builder.Append("..."); } builder.Append(reader.GetString()[minimum..maximum]);
public ReadResults Parse(IStringReader reader, DispatcherResources resources, out string result) { if (Type == StringType.GREEDY) { result = reader.GetRemaining(); reader.SetCursor(reader.GetLength()); return(ReadResults.Success()); } else if (Type == StringType.WORD) { return(reader.ReadUnquotedString(out result)); } else { return(reader.ReadString(out result)); } }