예제 #1
0
 bool nbDoubleSafeChar()
 {
     if (nbDoubleSafeCharset(Text[P]))
     {
         StringValue.Append(Text[P++]);
         return(true);
     }
     return(false);
 }
예제 #2
0
            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);
            }
예제 #3
0
            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);
            }
예제 #4
0
파일: Parser.cs 프로젝트: mlaily/YamlSharp
 /// <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)));
 }