object Parser extends ParserInstances
- Source
- Parser.scala
- Alphabetic
- By Inheritance
- Parser
- ParserInstances
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
-
final
case class
Error(failedAtOffset: Int, expected: NonEmptyList[Expectation]) extends Product with Serializable
Represents where a failure occurred and all the expectations that were broken
-
sealed abstract
class
Expectation extends AnyRef
An expectation reports the kind or parsing error and where it occured.
-
implicit final
class
Parser1Methods[A] extends AnyVal
Methods with complex variance type signatures due to covariance.
-
sealed
class
Soft[+A] extends AnyRef
If we can parse this then that, do so, if we fail that without consuming, rewind before this without consuming.
If we can parse this then that, do so, if we fail that without consuming, rewind before this without consuming. If either consume 1 or more, do not rewind
-
final
class
Soft01[+A] extends AnyVal
If we can parse this then that, do so, if we fail that without consuming, rewind before this without consuming.
If we can parse this then that, do so, if we fail that without consuming, rewind before this without consuming. If either consume 1 or more, do not rewind
-
final
class
Soft10[+A] extends Soft[A]
If we can parse this then that, do so, if we fail that without consuming, rewind before this without consuming.
If we can parse this then that, do so, if we fail that without consuming, rewind before this without consuming. If either consume 1 or more, do not rewind
-
final
class
With1[+A] extends AnyVal
Enables syntax to access product01, product10 and flatMap01 This helps us build Parser1 instances when starting from a Parser
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
val
Fail: Parser1[Nothing]
A parser that always fails with an epsilon failure
-
def
anyChar: Parser1[Char]
Parse 1 character from the string
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
backtrack[A](pa: Parser[A]): Parser[A]
If we fail, rewind the offset back so that we can try other branches.
If we fail, rewind the offset back so that we can try other branches. This tends to harm debuggability and ideally should be minimized
-
def
backtrack1[A](pa: Parser1[A]): Parser1[A]
If we fail, rewind the offset back so that we can try other branches.
If we fail, rewind the offset back so that we can try other branches. This tends to harm debuggability and ideally should be minimized
-
implicit
val
catInstancesParser: Monad[Parser] with Alternative[Parser] with Defer[Parser]
- Definition Classes
- ParserInstances
- implicit val catsInstancesParser1: FlatMap[Parser1] with Defer[Parser1] with MonoidK[Parser1]
-
def
char(c: Char): Parser1[Unit]
parse a single character
-
def
charIn(c0: Char, cs: Char*): Parser1[Char]
parse one of a given set of characters
-
def
charIn(cs: Iterable[Char]): Parser1[Char]
An empty iterable is the same as fail
-
def
charWhere(fn: (Char) ⇒ Boolean): Parser1[Char]
parse one character that matches a given function
-
def
charsWhile(fn: (Char) ⇒ Boolean): Parser[String]
Parse a string while the given function is true
-
def
charsWhile1(fn: (Char) ⇒ Boolean): Parser1[String]
Parse a string while the given function is true parses at least one character
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
defer[A](pa: ⇒ Parser[A]): Parser[A]
Lazily create a Parser This is useful to create some recursive parsers see Defer[Parser1].fix
-
def
defer1[A](pa: ⇒ Parser1[A]): Parser1[A]
Lazily create a Parser1 This is useful to create some recursive parsers see Defer[Parser1].fix
-
def
end: Parser[Unit]
succeeds when we are at the end
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
fail[A]: Parser1[A]
A parser that always fails with an epsilon failure
-
def
failWith[A](message: String): Parser1[A]
A parser that always fails with an epsilon failure and a given message this is generally used with flatMap to validate a result beyond the literal parsing.
A parser that always fails with an epsilon failure and a given message this is generally used with flatMap to validate a result beyond the literal parsing.
e.g. parsing a number then validate that it is bounded.
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
flatMap[A, B](pa: Parser[A])(fn: (A) ⇒ Parser[B]): Parser[B]
Standard monadic flatMap Avoid this function if possible.
Standard monadic flatMap Avoid this function if possible. If you can instead use product, ~, *>, or <* use that. flatMap always has to allocate a parser, and the parser is less amenable to optimization
-
def
flatMap01[A, B](pa: Parser[A])(fn: (A) ⇒ Parser1[B]): Parser1[B]
Standard monadic flatMap where you end with a Parser1 Avoid this function if possible.
Standard monadic flatMap where you end with a Parser1 Avoid this function if possible. If you can instead use product, ~, *>, or <* use that. flatMap always has to allocate a parser, and the parser is less amenable to optimization
-
def
flatMap10[A, B](pa: Parser1[A])(fn: (A) ⇒ Parser[B]): Parser1[B]
Standard monadic flatMap where you start with a Parser1 Avoid this function if possible.
Standard monadic flatMap where you start with a Parser1 Avoid this function if possible. If you can instead use product, ~, *>, or <* use that. flatMap always has to allocate a parser, and the parser is less amenable to optimization
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
ignoreCase(str: String): Parser[Unit]
Parse a potentially empty string, in a case-insensitive manner, or fail.
Parse a potentially empty string, in a case-insensitive manner, or fail. This backtracks on failure
-
def
ignoreCase1(str: String): Parser1[Unit]
Parse a given string, in a case-insensitive manner, or fail.
Parse a given string, in a case-insensitive manner, or fail. This backtracks on failure this is an error if the string is empty
-
def
ignoreCaseChar(c: Char): Parser1[Unit]
Ignore the case of a single character If you want to know if it is upper or lower, use .string to capture the string and then map to process the result.
-
def
ignoreCaseCharIn(c0: Char, cs: Char*): Parser1[Char]
Parse any single character in a set of characters as lower or upper case
-
def
ignoreCaseCharIn(cs: Iterable[Char]): Parser1[Char]
Parse any single character in a set of characters as lower or upper case
-
def
index: Parser[Int]
return the current position in the string we are parsing.
return the current position in the string we are parsing. This lets you record position information in your ASTs you are parsing
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
length(len: Int): Parser[String]
if len < 1, the same as pure("") else length1(len)
-
def
length1(len: Int): Parser1[String]
Parse the next len characters where len > 0 if (len < 1) throw IllegalArgumentException
-
def
map[A, B](p: Parser[A])(fn: (A) ⇒ B): Parser[B]
transform a Parser result
-
def
map1[A, B](p: Parser1[A])(fn: (A) ⇒ B): Parser1[B]
transform a Parser1 result
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
not(pa: Parser[Any]): Parser[Unit]
returns a parser that succeeds if the current parser fails.
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
oneOf[A](ps: List[Parser[A]]): Parser[A]
go through the list of parsers trying each as long as they are epsilon failures (don't advance) see @backtrack if you want to do backtracking.
go through the list of parsers trying each as long as they are epsilon failures (don't advance) see @backtrack if you want to do backtracking.
This is the same as parsers.foldLeft(fail)(_.orElse(_))
-
def
oneOf1[A](parsers: List[Parser1[A]]): Parser1[A]
go through the list of parsers trying each as long as they are epsilon failures (don't advance) see @backtrack if you want to do backtracking.
go through the list of parsers trying each as long as they are epsilon failures (don't advance) see @backtrack if you want to do backtracking.
This is the same as parsers.foldLeft(fail)(_.orElse1(_))
-
def
peek(pa: Parser[Any]): Parser[Unit]
a parser that consumes nothing when it succeeds, basically rewind on success
-
def
product[A, B](first: Parser[A], second: Parser[B]): Parser[(A, B)]
parse first then second
-
def
product01[A, B](first: Parser[A], second: Parser1[B]): Parser1[(A, B)]
product with the second argument being a Parser1
-
def
product10[A, B](first: Parser1[A], second: Parser[B]): Parser1[(A, B)]
product with the first argument being a Parser1
-
def
pure[A](a: A): Parser[A]
Don't advance in the parsed string, just return a This is used by the Applicative typeclass.
-
def
rep[A](p1: Parser1[A]): Parser[List[A]]
Repeat this parser 0 or more times note: this can wind up parsing nothing
-
def
rep1[A](p1: Parser1[A], min: Int): Parser1[NonEmptyList[A]]
Repeat this parser 1 or more times
-
def
rep1Sep[A](p1: Parser1[A], min: Int, sep: Parser[Any]): Parser1[NonEmptyList[A]]
Repeat 1 or more times with a separator
-
def
repAs[A, B](p1: Parser1[A])(implicit acc: Accumulator[A, B]): Parser[B]
Repeat this parser 0 or more times note: this can wind up parsing nothing
-
def
repAs1[A, B](p1: Parser1[A], min: Int)(implicit acc: Accumulator1[A, B]): Parser1[B]
Repeat this parser 1 or more times
-
def
repSep[A](p1: Parser1[A], min: Int, sep: Parser[Any]): Parser[List[A]]
Repeat 0 or more times with a separator
-
def
softProduct[A, B](first: Parser[A], second: Parser[B]): Parser[(A, B)]
softProduct, a variant of product A soft product backtracks if the first succeeds and the second is an epsilon-failure.
softProduct, a variant of product A soft product backtracks if the first succeeds and the second is an epsilon-failure. By contrast product will be a failure in that case
see @Parser.soft
-
def
softProduct01[A, B](first: Parser[A], second: Parser1[B]): Parser1[(A, B)]
softProduct with the second argument being a Parser1 A soft product backtracks if the first succeeds and the second is an epsilon-failure.
softProduct with the second argument being a Parser1 A soft product backtracks if the first succeeds and the second is an epsilon-failure. By contrast product will be a failure in that case
see @Parser.soft
-
def
softProduct10[A, B](first: Parser1[A], second: Parser[B]): Parser1[(A, B)]
softProduct with the first argument being a Parser1 A soft product backtracks if the first succeeds and the second is an epsilon-failure.
softProduct with the first argument being a Parser1 A soft product backtracks if the first succeeds and the second is an epsilon-failure. By contrast product will be a failure in that case
see @Parser.soft
-
def
start: Parser[Unit]
succeeds when we are at the start
-
def
string(pa: Parser[Any]): Parser[String]
Discard the result A and instead capture the matching string this is optimized to avoid internal allocations
-
def
string(str: String): Parser[Unit]
Parse a potentially empty string or fail.
Parse a potentially empty string or fail. This backtracks on failure
-
def
string1(pa: Parser1[Any]): Parser1[String]
Discard the result A and instead capture the matching string this is optimized to avoid internal allocations
-
def
string1(str: String): Parser1[Unit]
Parse a given string or fail.
Parse a given string or fail. This backtracks on failure this is an error if the string is empty
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
tailRecM[A, B](init: A)(fn: (A) ⇒ Parser[Either[A, B]]): Parser[B]
tail recursive monadic flatMaps This is a rarely used function, but needed to implement cats.FlatMap Avoid this function if possible.
tail recursive monadic flatMaps This is a rarely used function, but needed to implement cats.FlatMap Avoid this function if possible. If you can instead use product, ~, *>, or <* use that. flatMap always has to allocate a parser, and the parser is less amenable to optimization
-
def
tailRecM1[A, B](init: A)(fn: (A) ⇒ Parser1[Either[A, B]]): Parser1[B]
tail recursive monadic flatMaps on Parser1 This is a rarely used function, but needed to implement cats.FlatMap Avoid this function if possible.
tail recursive monadic flatMaps on Parser1 This is a rarely used function, but needed to implement cats.FlatMap Avoid this function if possible. If you can instead use product, ~, *>, or <* use that. flatMap always has to allocate a parser, and the parser is less amenable to optimization
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
val
unit: Parser[Unit]
A parser that returns unit
-
def
until(p: Parser[Any]): Parser[String]
parse zero or more characters as long as they don't match p
-
def
until1(p: Parser[Any]): Parser1[String]
parse one or more characters as long as they don't match p
-
def
void(pa: Parser[Any]): Parser[Unit]
discard the value in a Parser.
discard the value in a Parser. This is an optimization because we remove trailing map operations and don't allocate internal data structures This function is called internal to Functor.as and Apply.*> and Apply.<* so those are good uses.
-
def
void1(pa: Parser1[Any]): Parser1[Unit]
discard the value in a Parser1.
discard the value in a Parser1. This is an optimization because we remove trailing map operations and don't allocate internal data structures This function is called internal to Functor.as and Apply.*> and Apply.<* so those are good uses.
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
- object Expectation