object Parsley
This object contains the core "function-style" combinators as well as the implicit classes which provide the "method-style" combinators. All parsers will likely require something from within!
- Alphabetic
- By Inheritance
- Parsley
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- implicit final class LazyChooseParsley[P, +A] extends AnyRef
This class exposes a ternary operator on pairs of parsers.
This class exposes a ternary operator on pairs of parsers.
- Version
1.0.0
- implicit final class LazyMapParsley[-A, +B] extends AnyRef
This class exposes the
<#>combinator on functions.This class exposes the
<#>combinator on functions.- Version
1.0.0
- implicit final class LazyParsley[P, +A] extends AnyRef
This class exposes the commonly used combinators in Parsley.
This class exposes the commonly used combinators in Parsley. For a description of why the library is designed in this way, see: the Parsley wiki
- Version
3.0.0
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 attempt[A](p: => Parsley[A]): Parsley[A]
Given a parser
p, attempts to parsep.Given a parser
p, attempts to parsep. If the parser fails, thenattemptensures that no input was consumed. This allows for backtracking capabilities, disabling the implicit cut semantics offered by<|>.- p
The parser to run
- returns
The result of
p, or ifpfailed ensures the parser state was as it was on entry.
- def branch[A, B, C](b: => Parsley[Either[A, B]], p: => Parsley[(A) => C], q: => Parsley[(B) => C]): Parsley[C]
This is one of the core operations of a selective functor.
This is one of the core operations of a selective functor. It will conditionally execute one of
pandqdepending on the result fromb. This can be used to implement conditional choice within a parser without relying on expensive monadic operations.- b
The first parser to parse
- p
If
breturnsLeftthen this parser is executed with the result- q
If
breturnsRightthen this parser is executed with the result- returns
Either the result from
porqdepending onb.
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- val col: Parsley[Int]
This parser consumes no input and returns the current column number reached in the input stream
This parser consumes no input and returns the current column number reached in the input stream
- returns
The column number the parser is currently at
- val empty: Parsley[Nothing]
The
emptyparser consumes no input and fails softly (that is to say, no error message) - 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 join[A](p: => Parsley[Parsley[A]]): Parsley[A]
This function is an alias for
_.flatten.This function is an alias for
_.flatten. Provides namesake to Haskell. - val line: Parsley[Int]
This parser consumes no input and returns the current line number reached in the input stream
This parser consumes no input and returns the current line number reached in the input stream
- returns
The line number the parser is currently at
- def lookAhead[A](p: => Parsley[A]): Parsley[A]
Parses
pwithout consuming any input.Parses
pwithout consuming any input. Ifpfails and consumes input then so doeslookAhead(p). Combine withattemptif this is undesirable.- p
The parser to look ahead at
- returns
The result of the lookahead
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def notFollowedBy(p: Parsley[_]): Parsley[Unit]
notFollowedBy(p)only succeeds when parserpfails.notFollowedBy(p)only succeeds when parserpfails. This parser does not consume any input. This parser can be used to implement the 'longest match' rule. For example, when recognising keywords, we want to make sure that a keyword is not followed by a legal identifier character, in which case the keyword is actually an identifier. We can program this behaviour as follows:attempt(kw *> notFollowedBy(alphaNum))
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- val pos: Parsley[(Int, Int)]
This parser consumes no input and returns the current position reached in the input stream
This parser consumes no input and returns the current position reached in the input stream
- returns
Tuple of line and column number that the parser has reached
- def pure[A](x: A): Parsley[A]
This is the traditional applicative
purefunction for parsers.This is the traditional applicative
purefunction for parsers. It consumes no input and does not influence the state of the parser, but does return the value provided. Useful to inject pure values into the parsing process.- x
The value to be returned from the parser
- returns
A parser which consumes nothing and returns
x
- def select[A, B](p: => Parsley[Either[A, B]], q: => Parsley[(A) => B]): Parsley[B]
This is one of the core operations of a selective functor.
This is one of the core operations of a selective functor. It will conditionally execute one of
qdepending on whether or notpreturns aLeft. It can be used to implementbranchand other selective operations, however it is more efficiently implemented withbranchitself.- p
The first parser to parse
- q
If
preturnsLeftthen this parser is executed with the result- returns
Either the result from
pif it returnedLeftor the result ofqapplied to theRightfromp
- def sequence[A](ps: Parsley[A]*): Parsley[List[A]]
Evaluate each of the parsers in
pssequentially from left to right, collecting the results.Evaluate each of the parsers in
pssequentially from left to right, collecting the results.- ps
Parsers to be sequenced
- returns
The list containing results, one from each parser, in order
- def skip(ps: Parsley[_]*): Parsley[Unit]
Evaluate each of the parsers in
pssequentially from left to right, ignoring the results.Evaluate each of the parsers in
pssequentially from left to right, ignoring the results.- ps
Parsers to be performed
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- def traverse[A, B](f: (A) => Parsley[B], xs: A*): Parsley[List[B]]
Like
sequencebut produces a list of parsers to sequence by applying the functionfto each element inxs.Like
sequencebut produces a list of parsers to sequence by applying the functionfto each element inxs.- f
The function to map on each element of
xsto produce parsers- xs
Values to generate parsers from
- returns
The list containing results formed by executing each parser generated from
xsandfin sequence
- val unit: Parsley[Unit]
Returns
().Returns
(). Defined aspure(())but aliased for sugar - def void(p: Parsley[_]): Parsley[Unit]
converts a parser's result to ()
- 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()
This is the documentation for Parsley.
Package structure
The parsley package contains the
Parsleyclass, as well as theResult,Success, andFailuretypes. 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.Parsleycontains the bulk of the core "function-style" combinators, as well as the implicit classes which enable the "method-style" combinators.parsley.combinatorcontains many helpful combinators that simplify some common parser patterns.parsley.charactercontains the combinators needed to read characters and strings, as well as combinators to match specific sub-sets of characters.parsley.debugcontains debugging combinators, helpful for identifying faults in parsers.parsley.iocontains extension methods to run parsers with input sourced from IO sources.parsley.exprcontains the following sub modules:parsley.expr.chaincontains combinators used in expression parsingparsley.expr.precedenceis a builder for expression parsers built on a precedence table.parsley.implicitscontains several implicits to add syntactic sugar to the combinators. These are sub-categorised into the following sub modules:parsley.implicits.charactercontains implicits to allow you to use character and string literals as parsers.parsley.implicits.combinatorcontains implicits related to combinators, such as the ability to make any parser into aParsley[Unit]automatically.parsley.implicits.liftenables postfix application of the lift combinator onto a function (or value).parsley.implicits.zippedenables boths a reversed form of lift where the function appears on the right and is applied on a tuple (useful when type inference has failed) as well as a.zippedmethod for building tuples out of several combinators.parsley.errorscontains modules to deal with error messages, their refinement and generation.parsley.errors.combinatorprovides combinators that can be used to either produce more detailed errors as well as refine existing errors.parsley.liftcontains 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.registerscontains combinators that interact with the context-sensitive functionality in the form of registers.parsley.tokencontains theLexerclass that provides a host of helpful lexing combinators when provided with the description of a language.parsley.unsafecontains unsafe (and not thread-safe) ways of speeding up the execution of a parser.