Ejemplo n.º 1
0
 /**
  * Returns a parser that produces the given stream of characters or fails otherwise.
  *
  * @param missing The error if the producing stream could not supply more characters.
  * @param sat The error if a character was produced that is not the given stream of characters.
  * @param cs The stream of characters to produce.
  * @return A parser that produces the given stream of characters or fails otherwise.
  */
 public static <E> Parser<Stream<Character>, Stream<Character>, E> characters(
     final F0<E> missing, final F<Character, E> sat, final Stream<Character> cs) {
   return cs.isEmpty()
       ? Parser.<Stream<Character>, Stream<Character>, E>value(Stream.<Character>nil())
       : character(missing, sat, cs.head())
           .bind(characters(missing, sat, cs.tail()._1()), Stream.<Character>cons_());
 }
Ejemplo n.º 2
0
 /**
  * Returns the first character of this string.
  *
  * @return The first character of this string, or error if the string is empty.
  */
 public char head() {
   return s.head();
 }
Ejemplo n.º 3
0
 public String toStringLazy() {
   return s.isEmpty() ? "" : "LazyString(" + Show.charShow.showS(s.head()) + ", ?)";
 }