public override string ToString() { StringBuilder builder = new StringBuilder(); builder.AppendFormat("[Parser Location={0} CurrentStateLength={1}", position, currentStateLength); builder.AppendLine(); builder.Append(' ', 2); builder.AppendLine("Stack="); XObject rootOb = null; foreach (XObject ob in nodes) { rootOb = ob; builder.Append(' ', 4); builder.Append(ob.ToString()); builder.AppendLine(); } builder.Append(' ', 2); builder.AppendLine("States="); XmlParserState s = currentState; while (s != null) { builder.Append(' ', 4); builder.Append(s.ToString()); builder.AppendLine(); s = s.Parent; } if (buildTree && rootOb != null) { builder.Append(' ', 2); builder.AppendLine("Tree="); rootOb.BuildTreeString(builder, 3); } if (buildTree && errors.Count > 0) { builder.Append(' ', 2); builder.AppendLine("Errors="); foreach (Error err in errors) { builder.Append(' ', 4); builder.AppendFormat("[{0}@{1}:{2}, {3}]\n", err.ErrorType, err.Region.Begin.Line, err.Region.Begin.Column, err.Message); } } builder.AppendLine("]"); return(builder.ToString()); }
public override string ToString() { StringBuilder builder = new StringBuilder(); builder.AppendFormat("[Parser Location={0} CurrentStateLength={1}", Position, CurrentStateLength); builder.AppendLine(); builder.Append(' ', 2); builder.AppendLine("Stack="); XObject rootOb = null; foreach (XObject ob in Nodes) { rootOb = ob; builder.Append(' ', 4); builder.Append(ob.ToString()); builder.AppendLine(); } builder.Append(' ', 2); builder.AppendLine("States="); XmlParserState s = CurrentState; while (s != null) { builder.Append(' ', 4); builder.Append(s.ToString()); builder.AppendLine(); s = s.Parent; } if (BuildTree && rootOb != null) { builder.Append(' ', 2); builder.AppendLine("Tree="); rootOb.BuildTreeString(builder, 3); } if (BuildTree && Diagnostics.Count > 0) { builder.Append(' ', 2); builder.AppendLine("Errors="); foreach (XmlDiagnosticInfo err in Diagnostics) { builder.Append(' ', 4); builder.AppendLine($"[{err.Severity}@{err.Span}: {err.Message}]"); } } builder.AppendLine("]"); return(builder.ToString()); }