private bool ParseStringQ2() { if (_reader.GetCurrent() != '"') { return(false); } _reader.Read(); int c = 0; int i = 0; while (YamlCharacter.Is(c = _reader.Read(), YamlCharacterType.LineSP)) { if (c == '"' && _reader.GetPrevious() != '\\') { break; } i++; } if (c != '"') { throw new ParserException("unterminated string", _line); } if (i != 0) { return(true); } return(false); }
public bool ParseNewline() { _line++; using (Marker mark = _reader.GetMarker()) { int c = _reader.Read(); if (c == -1) { return(true); } else if (c == 13 && _reader.Peek() == 10) { _reader.Read(); //read in the 10 since we only peeked it before return(true); } else if (YamlCharacter.Is(c, YamlCharacterType.LineBreak)) { return(true); } mark.Reset(); _line--; return(false); } }
/// <summary> /// Returns the length of the Indent without consuming it. /// </summary> /// <returns></returns> public int ParseIndent() { using (Marker mark = _reader.GetMarker()) { int i = this._reader.ReadWhile(delegate(int c) { return(YamlCharacter.Is(c, YamlCharacterType.Indent)); }); mark.Reset(); return(i); } }
/// <summary> /// Consumes an indent with a length of 'n'. /// </summary> /// <param name="n"></param> /// <returns></returns> public bool ParseIndent(int n) { using (Marker marker = _reader.GetMarker()) { int i = this._reader.ReadWhile(delegate(int c) { return(YamlCharacter.Is(c, YamlCharacterType.Indent)); }); if (i != n) { marker.Reset(); return(false); } else { return(true); } } }
/// <summary> /// Parses a string of the given type /// </summary> /// <param name="type"></param> /// <returns>A string of the parsed characters or null if no matching characters are available for parsing</returns> public string ParseArray(YamlCharacterType type) { using (Marker mark = _reader.GetMarker()) { int i = this._reader.ReadWhile(delegate(int c) { return(YamlCharacter.Is(c, type)); }); if (i != 0) { return(mark.GetString()); } else { return(null); } } }