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
- All
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
1.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, thenattempt
ensures 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 ifp
failed 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
p
andq
depending 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
b
returnsLeft
then this parser is executed with the result- q
If
b
returnsRight
then this parser is executed with the result- returns
Either the result from
p
orq
depending onb
.
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @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
empty
parser 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: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- 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
p
without consuming any input.Parses
p
without consuming any input. Ifp
fails and consumes input then so doeslookAhead(p)
. Combine withattempt
if 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 parserp
fails.notFollowedBy(p)
only succeeds when parserp
fails. 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 pure function (or monadic return) for parsers.
This is the traditional applicative pure function (or monadic return) 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
q
depending on whether or notp
returns aLeft
. It can be used to implementbranch
and other selective operations, however it is more efficiently implemented withbranch
itself.- p
The first parser to parse
- q
If
p
returnsLeft
then this parser is executed with the result- returns
Either the result from
p
if it returnedLeft
or the result ofq
applied to theRight
fromp
-
def
sequence[A](ps: Parsley[A]*): Parsley[List[A]]
Evaluate each of the parsers in
ps
sequentially from left to right, collecting the results.Evaluate each of the parsers in
ps
sequentially 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
ps
sequentially from left to right, ignoring the results.Evaluate each of the parsers in
ps
sequentially 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
sequence
but produces a list of parsers to sequence by applying the functionf
to each element inxs
.Like
sequence
but produces a list of parsers to sequence by applying the functionf
to each element inxs
.- f
The function to map on each element of
xs
to produce parsers- xs
Values to generate parsers from
- returns
The list containing results formed by executing each parser generated from
xs
andf
in 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( ... )
-
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()
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.io
contains extension methods to run parsers with input sourced from IO sources.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. These are sub-categorised into the following sub modules:parsley.implicits.character
contains implicits to allow you to use character and string literals as parsers.parsley.implicits.combinator
contains implicits related to combinators, such as the ability to make any parser into aParsley[Unit]
automatically.parsley.implicits.lift
enables postfix application of the lift combinator onto a function (or value).parsley.implicits.zipped
enables 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.zipped
method for building tuples out of several combinators.parsley.errors
contains modules to deal with error messages, their refinement and generation.parsley.errors.combinator
provides combinators that can be used to either produce more detailed errors as well as refine existing errors.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.