parsley

package parsley

Members list

Concise view

Type members

Classlikes

class Failure[Err] extends Result[Err, Nothing] with Product with Serializable

This class is used for a parser failure, and contains the error message.

This class is used for a parser failure, and contains the error message.

Attributes

Err

the type of the error message generated by the failing parse.

_msg

the error message reported by the parser (passed lazily).

Companion:
object
Source:
Result.scala
Graph
Supertypes
trait Product
trait Equals
class Result[Err, Nothing]
class Object
trait Matchable
class Any
object Failure

Attributes

Companion:
class
Source:
Result.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Failure.type
final class Parsley[+A] extends AnyVal

This is the class that encapsulates the act of parsing and running an object of this class with parse will parse the string given as input to parse.

This is the class that encapsulates the act of parsing and running an object of this class with parse will parse the string given as input to parse.

Attributes

Version:

4.0.0

Note:

In order to construct an object of this class you must use the combinators; the class itself is opaque.

Companion:
object
Source:
Parsley.scala
Graph
Supertypes
class AnyVal
trait Matchable
class Any
object Parsley

This object contains the core "function-style" combinators: all parsers will likely require something from within!

This object contains the core "function-style" combinators: all parsers will likely require something from within!

In particular, it contains combinators for: controlling how input is consumed; injecting values into the parser, or failing; extracting position information from the parser; conditional execution of parsers; and more.

Attributes

Companion:
class
Source:
Parsley.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Parsley.type
sealed abstract class Result[+Err, +A]

This trait represents the result of a parser.

This trait represents the result of a parser.

Either a Success[A] or a Failure.

Attributes

A

the type of expected success result.

Source:
Result.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class Failure[Err]
class Success[A]
case class Success[A] extends Result[Nothing, A]

This class is used for when a parser succeeds, and contains its result.

This class is used for when a parser succeeds, and contains its result.

Attributes

A

the type of expected success result.

x

the result value of the successful parse.

Source:
Result.scala
Graph
Supertypes
trait Product
trait Equals
class Result[Nothing, A]
class Object
trait Matchable
class Any
object ap

This module contains ap1 through ap22, which allow for the application of a parser returning a function of arity N to N parsers.

This module contains ap1 through ap22, which allow for the application of a parser returning a function of arity N to N parsers.

The combinators contained in this module all sequence a number of parsers together, but are capable of combining the results generated by these parsers into a single value with a function of the correct arity produced by the first parser. This is a clean way of putting together multiple parsers and getting a meaningful result out.

Attributes

Since:

4.0.0

Example:

scala> import parsley.character.char
scala> import parsley.ap.{ap2, ap3}
scala> case class Add(x: Int, y: Int)
scala> val p = ap2(pure(Add), char('a') #> 4, char('b') #> 5)
scala> p.parse("ab")
val res0 = Success(Add(4, 5))
scala> val q = ap3(pure((x: Int, y: Int, z: Int) => x * y + z), char('a') #> 3, char('b') #> 2, char('c') #> 5)
scala> q.parse("abc")
val res1 = Success(11)
scala> q.parse("ab")
val res2 = Failure(..)
Source:
ap.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
ap.type
object character

This module contains many parsers to do with reading one or more characters.

This module contains many parsers to do with reading one or more characters. Almost every parser will need something from this module.

In particular, this module contains: combinators that can read specific characters; combinators that represent character classes and their negations; combinators for reading specific strings; as well as a selection of pre-made parsers to parse specific kinds of character, like digits and letters.

Attributes

Since:

2.2.0

Source:
character.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
object combinator

This module contains a huge number of pre-made combinators that are very useful for a variety of purposes.

This module contains a huge number of pre-made combinators that are very useful for a variety of purposes.

In particular, it contains combinators for: performing a parser iteratively, collecting all the results; querying whether or not any input is left; optionally performing parsers; parsing delimited constructions; handling multiple possible alternatives or parsers to sequence; handling more complex conditional execution; and more.

Attributes

Since:

2.2.0

Source:
combinator.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
object debug

This module contains the very useful debugging combinator, as well as breakpoints.

This module contains the very useful debugging combinator, as well as breakpoints.

Attributes

Source:
debug.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
debug.type
object extension

These implicit classes can be used to extend the core combinator set of Parsley.

These implicit classes can be used to extend the core combinator set of Parsley.

This may mean that importing them enables combinators that can be used on non-Parsley types, or might enable some syntactic sugar that is not part of the core combinator "style".

Attributes

Source:
extension.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

This module contains the definition of 23 basic generic parser bridge traits, which are used to implement the Parser Bridge pattern for types that do not require metadata.

This module contains the definition of 23 basic generic parser bridge traits, which are used to implement the Parser Bridge pattern for types that do not require metadata.

The traits within are designed to be extended by the companion object of some case class that is produced as the result of a parser: by using these traits, it enables a new apply method that makes it appear like the constructor is applied to the parsers themselves. This can be very useful for performing extra verification on the produced results, or to incorporate metadata into the result. Specifically, these traits are designed to be the bare-minimum functionaity, and do not interact with any metadata.

Attributes

Since:

4.0.0

Source:
genericbridges.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
object io

This module contains utilities to have parsers interact with IO, including the very useful parseFromFile method (exposed by ParseFromIO)

This module contains utilities to have parsers interact with IO, including the very useful parseFromFile method (exposed by ParseFromIO)

Attributes

Since:

3.0.0

Source:
io.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
io.type
object lift

This module contains lift1 through lift22, which allow for the application of a function of arity N to N parsers.

This module contains lift1 through lift22, which allow for the application of a function of arity N to N parsers.

The combinators contained in this module all sequence a number of parsers together, but are capable of combining the results generated by these parsers into a single value with a given function of the correct arity. This is a clean way of putting together multiple parsers and getting a meaningful result out.

Attributes

Since:

2.2.0

Example:

scala> import parsley.character.char
scala> import parsley.lift.{lift2, lift3}
scala> case class Add(x: Int, y: Int)
scala> val p = lift2(Add, char('a') #> 4, char('b') #> 5)
scala> p.parse("ab")
val res0 = Success(Add(4, 5))
scala> val q = lift3((x: Int, y: Int, z: Int) => x * y + z, char('a') #> 3, char('b') #> 2, char('c') #> 5)
scala> q.parse("abc")
val res1 = Success(11)
scala> q.parse("ab")
val res2 = Failure(..)
scala> val q2 = lift3[Int, Int, Int, Int](_ * _ + _, char('a') #> 3, char('b') #> 2, char('c') #> 5)
Source:
lift.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
lift.type
object registers

This module contains all the functionality and operations for using and manipulating registers.

This module contains all the functionality and operations for using and manipulating registers.

These often have a role in performing context-sensitive parsing tasks, where a Turing-powerful system is required. While flatMap is capable of such parsing, it is much less efficient than the use of registers, though slightly more flexible. In particular, the persist combinator enabled by RegisterMethods can serve as a drop-in replacement for flatMap in many scenarios.

Attributes

Since:

2.2.0

Source:
registers.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type