bool nbDoubleSafeChar() { if (nbDoubleSafeCharset(Text[P])) { StringValue.Append(Text[P++]); return(true); } return(false); }
private bool bBreak(string pres, Context c) { if (Text[P] == '\r') { StringValue.Append(@"\r"); P++; if (!EndOfString() && Text[P] == '\n') { StringValue.Append(@"\n"); P++; } } else if (Text[P] == '\n') { StringValue.Append(@"\n"); P++; } else { return(false); } if (EndOfString() || c == Context.NoBreak) { return(true); } // fold the string with escaping line break StringValue.AppendLine(@"\"); StringValue.Append(pres); // if the following line starts from space char, escape it. if (Text[P] == ' ') { StringValue.Append(@"\"); } return(true); }
private bool nsEscapedChar() { var c = Text[P]; string escaped; if (CharEscaping.TryGetValue(c, out escaped)) { StringValue.Append(escaped); } else { if (c < 0x100) { StringValue.Append(string.Format(@"\x{0:x2}", (int)c)); } else { StringValue.Append(string.Format(@"\u{0:x4}", (int)c)); } } P++; return(true); }
/// <summary> /// <para>Saves a part of the source text that is reduced in the <paramref name="rule"/> /// and append it to <see cref="StringValue"/>.</para> /// <para>If the rule does not match, nothing happens.</para> /// </summary> /// <param name="rule">Reduction rule to match.</param> /// <returns>true if <paramref name="rule"/> matches; otherwise false.</returns> protected bool Save(Func <bool> rule) { return (Save(rule, s => StringValue.Append(s))); }