Packages

c

cats.parse

Parser1

sealed abstract class Parser1[+A] extends Parser[A]

Parser1[A] is a Parser[A] that will always consume one-or-more characters on a successful parse.

Since Parser1 is guaranteed to consume input it provides additional methods which would be unsafe when used on parsers that succeed without consuming input, such as rep.

When a Parser1 is composed with a Parser the result is usually a Parser1. Parser1 overrides many of Parser's methods to refine the return type. In other cases, callers may need to use the with1 helper method to refine the type of their expressions.

Parser1 doesn't provide any additional guarantees over Parser on what kind of parsing failures it can return.

Source
Parser.scala
Linear Supertypes
Parser[A], AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Parser1
  2. Parser
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def parseMut(state: State): A

    Internal (mutable) parsing method.

    Internal (mutable) parsing method.

    This method should only be called internally by parser instances.

    Attributes
    protected
    Definition Classes
    Parser

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. def *>[B](that: Parser[B]): Parser1[B]

    Compose two parsers, ignoring the values extracted by the left-hand parser.

    Compose two parsers, ignoring the values extracted by the left-hand parser.

    x *> y is equivalent to (x.void ~ y).map(_._2).

  4. def <*[B](that: Parser[B]): Parser1[A]

    Compose two parsers, ignoring the values extracted by the right-hand parser.

    Compose two parsers, ignoring the values extracted by the right-hand parser.

    x <* y is equivalent to (x.void ~ y).map(_._1).

  5. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  6. def ?: Parser[Option[A]]

    Convert epsilon failures into None values.

    Convert epsilon failures into None values.

    Normally if a parser fails to consume any input it fails with an epsilon failure. The ? method converts these failures into None values (and wraps other values in Some(_)).

    If the underlying parser failed with other errors, this parser will still fail.

    Definition Classes
    Parser
  7. def as[B](b: B): Parser1[B]

    This method overrides Parser#as to refine the return type.

    This method overrides Parser#as to refine the return type.

    Definition Classes
    Parser1Parser
  8. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  9. def backtrack: Parser1[A]

    This method overrides Parser#backtrack to refine the return type.

    This method overrides Parser#backtrack to refine the return type.

    Definition Classes
    Parser1Parser
  10. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  11. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  12. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  13. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  14. def flatMap[B](fn: (A) ⇒ Parser[B]): Parser1[B]

    This method overrides Parser#flatMap to refine the return type.

    This method overrides Parser#flatMap to refine the return type.

    Definition Classes
    Parser1Parser
  15. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  16. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  17. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  18. def map[B](fn: (A) ⇒ B): Parser1[B]

    This method overrides Parser#map to refine the return type.

    This method overrides Parser#map to refine the return type.

    Definition Classes
    Parser1Parser
  19. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  20. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  21. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  22. def orElse[A1 >: A](that: Parser[A1]): Parser[A1]

    If this parser fails to parse its input with an epsilon error, try the given parser instead.

    If this parser fails to parse its input with an epsilon error, try the given parser instead.

    If this parser fails with an arresting error, the next parser won't be tried.

    Backtracking may be used on the left parser to allow the right one to pick up after any error, resetting any state that was modified by the left parser.

    Definition Classes
    Parser
  23. def orElse1[A1 >: A](that: Parser1[A1]): Parser1[A1]

    If this parser fails to parse its input with an epsilon error, try the given parser instead.

    If this parser fails to parse its input with an epsilon error, try the given parser instead.

    This method is similar to Parser#orElse, but since both arguments are known to be Parser1 values, the result is known to be a Parser1 as well.

  24. final def parse(str: String): Either[Error, (String, A)]

    Attempt to parse an A value out of str.

    Attempt to parse an A value out of str.

    This method will either return a failure, or else the remaining string and the parsed value.

    To require the entire input to be consumed, see parseAll.

    Definition Classes
    Parser
  25. final def parseAll(str: String): Either[Error, A]

    Attempt to parse all of the input str into an A value.

    Attempt to parse all of the input str into an A value.

    This method will return a failure unless all of str is consumed during parsing.

    p.parseAll(s) is equivalent to (p <* Parser.end).parse(s).map(_._2).

    Definition Classes
    Parser
  26. def peek: Parser[Unit]

    Return a parser that succeeds (consuming nothing and extracting nothing) if the current parser would also succeed.

    Return a parser that succeeds (consuming nothing and extracting nothing) if the current parser would also succeed.

    This parser expects the underlying parser to succeed, and will unconditionally backtrack after running it.

    Definition Classes
    Parser
  27. def rep(min: Int): Parser[List[A]]

    Use this parser to parse at least min values (where min >= 0).

    Use this parser to parse at least min values (where min >= 0).

    If min is zero, this parser may succeed without consuming input in the case where zero values are parsed. If min is known to be greater than zero, consider using rep1(min) instead.

    Like rep, arresting failures in the underlying parser will result in an arresting failure. Unlike rep, this method may also return an arresting failure if it has not parsed at least min values (but has consumed input).

  28. def rep: Parser[List[A]]

    Use this parser to parse zero-or-more values.

    Use this parser to parse zero-or-more values.

    This parser may succeed without consuming input in the case where zero values are parsed.

    If the underlying parser hits an arresting failure, the entire parse is also an arresting failure. If the underlying parser hits an epsilon failure, the parsed values (if any) are returned in a list as a successful parse.

  29. def rep1(min: Int): Parser1[NonEmptyList[A]]

    Use this parser to parse at least min values (where min >= 1).

    Use this parser to parse at least min values (where min >= 1).

    This method behaves likes rep1, except that if fewer than min values are produced an arresting failure will be returned.

  30. def rep1: Parser1[NonEmptyList[A]]

    Use this parser to parse one-or-more values.

    Use this parser to parse one-or-more values.

    This parser behaves like rep, except that it must produce at least one value, and is guaranteed to consume input on successful parses.

  31. def soft: Soft10[A]

    This method overrides Parser#soft to refine the return type.

    This method overrides Parser#soft to refine the return type.

    Definition Classes
    Parser1Parser
  32. def string: Parser1[String]

    This method overrides Parser#string to refine the return type.

    This method overrides Parser#string to refine the return type.

    Definition Classes
    Parser1Parser
  33. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  34. def toString(): String
    Definition Classes
    AnyRef → Any
  35. def unary_!: Parser[Unit]

    Return a parser that succeeds (consuming nothing, and extracting nothing) if the current parser would fail.

    Return a parser that succeeds (consuming nothing, and extracting nothing) if the current parser would fail.

    This parser expects the underlying parser to fail, and will unconditionally backtrack after running it.

    Definition Classes
    Parser
  36. def void: Parser1[Unit]

    This method overrides Parser#void to refine the return type.

    This method overrides Parser#void to refine the return type.

    Definition Classes
    Parser1Parser
  37. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  38. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  39. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  40. def with1: With1[A]

    Wrap this parser in a helper class, enabling better composition with Parser1 values.

    Wrap this parser in a helper class, enabling better composition with Parser1 values.

    For example, with p: Parser[Int] and p1: Parser[Double]:

    val a1: Parser[(Int, Double)] = p ~ p1 val a2: Parser1[(Int, Double)] = p.with1 ~ p1

    val b1: Parser[Double] = p *> p1 val b2: Parser1[Double] = p.with1 *> p1

    val c1: Parser[Int] = p <* p1 val c2: Parser1[Int] = p.with1 <* p1

    Without using with1, these methods will return Parser values since they are not known to return Parser1 values instead.

    Definition Classes
    Parser
  41. def ~[B](that: Parser[B]): Parser1[(A, B)]

    This method overrides Parser#~ to refine the return type.

    This method overrides Parser#~ to refine the return type.

    Definition Classes
    Parser1Parser

Inherited from Parser[A]

Inherited from AnyRef

Inherited from Any

Ungrouped