object combinator
This module contains a huge number of pre-made combinators that are very useful for a variety of purposes.
- Alphabetic
- By Inheritance
- combinator
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
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
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def attemptChoice[A](ps: Parsley[A]*): Parsley[A]
attemptChoice(ps)
tries to apply the parsers in the listps
in order, until one of them succeeds.attemptChoice(ps)
tries to apply the parsers in the listps
in order, until one of them succeeds. Returns the value of the succeeding parser. Utilises<\>
vs choice's<|>
. - def between[A](open: => Parsley[_], close: => Parsley[_], p: => Parsley[A]): Parsley[A]
between(open, close, p)
parsesopen
, followed byp
andclose
.between(open, close, p)
parsesopen
, followed byp
andclose
. Returns the value returned byp
. - def choice[A](ps: Parsley[A]*): Parsley[A]
choice(ps)
tries to apply the parsers in the listps
in order, until one of them succeeds.choice(ps)
tries to apply the parsers in the listps
in order, until one of them succeeds. Returns the value of the succeeding parser. - def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def decide[A](p: => Parsley[Option[A]], q: => Parsley[A]): Parsley[A]
decide(p, q)
removes the option from inside parserp
, if it returnedNone
thenq
is executed. - def decide[A](p: => Parsley[Option[A]]): Parsley[A]
decide(p)
removes the option from inside parserp
, and if it returnedNone
will fail. - def endBy[A, B](p: => Parsley[A], sep: => Parsley[B]): Parsley[List[A]]
endBy(p, sep)
parses *zero* or more occurrences ofp
, separated and ended bysep
.endBy(p, sep)
parses *zero* or more occurrences ofp
, separated and ended bysep
. Returns a list of values returned byp
. - def endBy1[A, B](p: => Parsley[A], sep: => Parsley[B]): Parsley[List[A]]
endBy1(p, sep)
parses *one* or more occurrences ofp
, separated and ended bysep
.endBy1(p, sep)
parses *one* or more occurrences ofp
, separated and ended bysep
. Returns a list of values returned byp
. - val eof: Parsley[Unit]
This parser only succeeds at the end of the input.
This parser only succeeds at the end of the input. This is a primitive parser.
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def many[A](p: => Parsley[A]): Parsley[List[A]]
many(p)
executes the parserp
zero or more times.many(p)
executes the parserp
zero or more times. Returns a list of the returned values ofp
. - def manyN[A](n: Int, p: => Parsley[A]): Parsley[List[A]]
manyN(n, p)
applies the parserp
*n* or more times.manyN(n, p)
applies the parserp
*n* or more times. Returns a list of the returned values ofp
. - def manyUntil[A, B](p: => Parsley[A], end: => Parsley[B]): Parsley[List[A]]
manyUntil(p, end)
applies parserp
zero or more times until the parserend
succeeds.manyUntil(p, end)
applies parserp
zero or more times until the parserend
succeeds. Returns a list of values returned byp
. This parser can be used to scan comments. - val more: Parsley[Unit]
This parser only succeeds if there is still more input.
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def option[A](p: => Parsley[A]): Parsley[Option[A]]
option(p)
tries to apply parserp
.option(p)
tries to apply parserp
. Ifp
fails without consuming input, it returnsNone
, otherwise it returnsSome
of the value returned byp
. - def optional(p: => Parsley[_]): Parsley[Unit]
optional(p) tries to apply parser
p
.optional(p) tries to apply parser
p
. It will parsep
or nothing. It only fails ifp
fails after consuming input. It discards the result ofp
. - def optionally[A](p: => Parsley[_], x: => A): Parsley[A]
optionally(p, x) tries to apply parser
p
.optionally(p, x) tries to apply parser
p
. It will always result inx
regardless of whether or notp
succeeded orp
failed without consuming input. - def repeat[A](n: Int, p: => Parsley[A]): Parsley[List[A]]
repeat(n, p)
parsesn
occurrences ofp
.repeat(n, p)
parsesn
occurrences ofp
. Ifn
is smaller or equal to zero, the parser ispure(Nil)
. Returns a list ofn
values returned byp
. - def sepBy[A, B](p: => Parsley[A], sep: => Parsley[B]): Parsley[List[A]]
sepBy(p, sep)
parses *zero* or more occurrences ofp
, separated bysep
.sepBy(p, sep)
parses *zero* or more occurrences ofp
, separated bysep
. Returns a list of values returned byp
. - def sepBy1[A, B](p: => Parsley[A], sep: => Parsley[B]): Parsley[List[A]]
sepBy1(p, sep)
parses *one* or more occurrences ofp
, separated bysep
.sepBy1(p, sep)
parses *one* or more occurrences ofp
, separated bysep
. Returns a list of values returned byp
. - def sepEndBy[A, B](p: => Parsley[A], sep: => Parsley[B]): Parsley[List[A]]
sepEndBy(p, sep)
parses *zero* or more occurrences ofp
, separated and optionally ended bysep
.sepEndBy(p, sep)
parses *zero* or more occurrences ofp
, separated and optionally ended bysep
. Returns a list of values returned byp
. - def sepEndBy1[A, B](p: => Parsley[A], sep: => Parsley[B]): Parsley[List[A]]
sepEndBy1(p, sep)
parses *one* or more occurrences ofp
, separated and optionally ended bysep
.sepEndBy1(p, sep)
parses *one* or more occurrences ofp
, separated and optionally ended bysep
. Returns a list of values returned byp
. - def skipMany[A](p: => Parsley[A]): Parsley[Unit]
skipMany(p)
executes the parserp
zero or more times and ignores the results.skipMany(p)
executes the parserp
zero or more times and ignores the results. Returns()
- def skipManyN[A](n: Int, p: => Parsley[A]): Parsley[Unit]
skipManyN(n, p)
applies the parserp
*n* or more times, skipping its result. - def skipSome[A](p: => Parsley[A]): Parsley[Unit]
skipSome(p)
applies the parserp
*one* or more times, skipping its result. - def some[A](p: => Parsley[A]): Parsley[List[A]]
some(p)
applies the parserp
*one* or more times.some(p)
applies the parserp
*one* or more times. Returns a list of the returned values ofp
. - def someUntil[A, B](p: => Parsley[A], end: => Parsley[B]): Parsley[List[A]]
someUntil(p, end)
applies parserp
one or more times until the parserend
succeeds.someUntil(p, end)
applies parserp
one or more times until the parserend
succeeds. Returns a list of values returned byp
. - final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- def when(p: => Parsley[Boolean], q: => Parsley[Unit]): Parsley[Unit]
when(p, q)
will first performp
, and if the result istrue
will then executeq
or else return unit.when(p, q)
will first performp
, and if the result istrue
will then executeq
or else return unit.- p
The first parser to parse
- q
If
p
returnstrue
then this parser is executed- returns
()
- def whileP(p: => Parsley[Boolean]): Parsley[Unit]
whileP(p)
will continue to runp
until it returnsfalse
.whileP(p)
will continue to runp
until it returnsfalse
. This is often useful in conjunction with stateful parsers.- p
The parser to continuously execute
- returns
()
This is the documentation for Parsley.
Package structure
The parsley package contains the
Parsley
class, as well as theResult
,Success
, andFailure
types. In addition to these, it also contains the following packages and "modules" (a module is defined as being an object which mocks a package):parsley.Parsley
contains the bulk of the core "function-style" combinators, as well as the implicit classes which enable the "method-style" combinators.parsley.combinator
contains many helpful combinators that simplify some common parser patterns.parsley.character
contains the combinators needed to read characters and strings, as well as combinators to match specific sub-sets of characters.parsley.debug
contains debugging combinators, helpful for identifying faults in parsers.parsley.expr
contains the following sub modules:parsley.expr.chain
contains combinators used in expression parsingparsley.expr.precedence
is a builder for expression parsers built on a precedence table.parsley.implicits
contains several implicits to add syntactic sugar to the combinators, such as being able to use character and string literals directly as parsers, as well as enabling lifting of functions to work on parsers.parsley.lift
contains functions which lift functions that work on regular types to those which now combine the results of parsers returning those same types. these are ubiquitous.parsley.registers
contains combinators that interact with the context-sensitive functionality in the form of registers.parsley.token
contains theLexer
class that provides a host of helpful lexing combinators when provided with the description of a language.parsley.unsafe
contains unsafe (and not thread-safe) ways of speeding up the execution of a parser.In addition to the modules and packages outlined above, this version of Parsley (up to version 3.0), also includes the so-called
old-style
API, which is deprecated (see the Parsley wiki for a discussion of these differences). You should use the modules described above, and avoid the following:parsley.BitGen
parsley.Char
parsley.CharSet
parsley.Combinator
parsley.ExpressionParser
parsley.Impl
parsley.Implicits
parsley.LanguageDef
parsley.NotRequired
parsley.Parser
parsley.Predicate
parsley.Reg
parsley.TokenParser