/// <summary> /// Json文字列をパースします。これは<see cref="Parse(JsonScanner)"/>の一部で使用されます。 /// </summary> /// <param name="scanner">指定するスキャナ。</param> /// <returns>パースに成功した場合文字列をさらに返します。</returns> private static string ParseString(JsonScanner scanner) { const string b = "\b"; const string f = "\f"; const string n = "\n"; const string r = "\r"; const string t = "\t"; scanner.Empty(); if (!scanner.CheckAdvance(IsDoubleQuote)) { throw new ArgumentMapParseException("string -> double quotation mark required", scanner.Itext.PositionInfo); } while (!scanner.CheckAdvance(IsDoubleQuote)) { if (scanner.CheckAdvance(IsBackslash)) { if (scanner.CheckAddAdvance(IsDoubleQuote)) { continue; } if (scanner.CheckAddAdvance(IsBackslash)) { continue; } if (scanner.CheckAddAdvance(IsSlash)) { continue; } if (scanner.CheckAdvance(IsSmallB)) { scanner.Add(b); } else if (scanner.CheckAdvance(IsSmallF)) { scanner.Add(f); } else if (scanner.CheckAdvance(IsSmallN)) { scanner.Add(n); } else if (scanner.CheckAdvance(IsSmallR)) { scanner.Add(r); } else if (scanner.CheckAdvance(IsSmallT)) { scanner.Add(t); } else if (scanner.CheckAdvance(IsSmallU)) { var codepoint = 0; for (var i = 0; i < 4; i++) { try { codepoint = codepoint * 16 + scanner.Current.ToHexValue(); scanner.Advance(); } catch (Exception) { break; } } scanner.Add(Convert.ToChar(codepoint).ToString()); } else { throw new ArgumentMapParseException("string -> not supported escape", scanner.Itext.PositionInfo); } } else if (scanner.Check(IsControl)) { throw new ArgumentMapParseException("string -> control character", scanner.Itext.PositionInfo); } else { scanner.AddAdvance(); } } return(scanner.Scan); }