Example #1
0
 /// <summary>
 /// Read the string up to the <see cref="Rune"/> where <paramref name="matcher"/> returns true or until EOF is reached.
 /// The matched character is put in <paramref name="matched"/>.
 /// </summary>
 /// <param name="parser">A parser on which to operate.</param>
 /// <param name="matcher">A predicate to test for when to terminate the read.</param>
 /// <param name="matched">The character that was finally matched, or 0 if the end of the stream was reached.</param>
 /// <returns>A parser string containing the read characters.</returns>
 public static ParserString ReadUntil(this ITextParser parser, Predicate <Rune> matcher, out ParserValue matched)
 {
     return(parser.ReadUntil(matcher, null, out matched));
 }
Example #2
0
 /// <summary>
 /// Read the string up to the <see cref="Rune"/> where <paramref name="matcher"/> returns true or until EOF is reached.
 /// </summary>
 /// <param name="parser">A parser on which to operate.</param>
 /// <param name="matcher">A predicate to test for when to terminate the read.</param>
 /// <returns>A parser string containing the read characters.</returns>
 public static ParserString ReadUntil(this ITextParser parser, Predicate <Rune> matcher)
 {
     return(parser.ReadUntil(matcher, out _));
 }
Example #3
0
 /// <summary>
 /// Read the string up to the <see cref="Rune"/> which is equal to <paramref name="r"/> or until EOF is reached.
 /// </summary>
 /// <param name="parser">A parser on which to operate.</param>
 /// <param name="r"></param>
 /// <returns>A parser string containing the read characters.</returns>
 public static ParserString ReadUntil(this ITextParser parser, Rune r)
 {
     return(parser.ReadUntil(rune => rune == r));
 }
Example #4
0
 /// <summary>
 /// Read the string up to the <see cref="Rune"/> whose value is equal to <paramref name="c"/> or until EOF is reached.
 /// </summary>
 /// <param name="parser">A parser on which to operate.</param>
 /// <param name="c">A character to find in the stream</param>
 /// <returns>A parser string containing the read characters.</returns>
 public static ParserString ReadUntil(this ITextParser parser, char c)
 {
     return(parser.ReadUntil(new Rune(c)));
 }
Example #5
0
 /// <summary>
 /// Read the string up to the <see cref="Rune"/> where <paramref name="matcher"/> returns false or until EOF is reached.
 /// The matched character is put in <paramref name="matched"/>.
 /// If <paramref name="escape"/> is set to a non-null value, the character immediately following the escape-character
 /// is always matched, even if <paramref name="matcher"/> returns false.
 /// </summary>
 /// <param name="parser">A parser on which to operate.</param>
 /// <param name="matcher">A predicate that receives a <see cref="Rune"/> and returns whether to continue reading.</param>
 /// <param name="escape">A character to use to escape the matched character, or null to not allow escaping of characters.</param>
 /// <param name="matched">The character that was finally matched, or 0 if the end of the stream was reached.</param>
 /// <returns>A parser string containing the read characters.</returns>
 public static ParserString ReadWhile(this ITextParser parser, Predicate <Rune> matcher, Rune?escape, out ParserValue matched)
 {
     return(parser.ReadUntil(r => !matcher(r), escape, out matched));
 }
Example #6
0
 /// <summary>
 /// Read the string up to any <see cref="Rune"/> that is included in <paramref name="runes"/> or until EOF is reached.
 /// The matched character is put in <paramref name="matched"/>.
 /// </summary>
 /// <param name="parser">A parser on which to operate.</param>
 /// <param name="runes">The runes to find in the stream</param>
 /// <param name="matched">The character that was finally matched, or 0 if the end of the stream was reached.</param>
 /// <returns>A parser string containing the read characters.</returns>
 public static ParserString ReadUntilAny(this ITextParser parser, Rune[] runes, out ParserValue match)
 {
     return(parser.ReadUntil(runes.Contains, out match));
 }