parsley

package parsley

Members list

Packages

package parsley.errors
package parsley.expr
package parsley.syntax
package parsley.token

Type members

Classlikes

class Failure[Err] extends Result[Err, Nothing], Product, 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.

Type parameters

Err

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

Value parameters

_msg

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

Attributes

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

Attributes

Companion
class
Source
Result.scala
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
Supertypes
class AnyVal
trait Matchable
class Any
object Parsley extends PlatformSpecific

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
Supertypes
class Object
trait Matchable
class Any
Self type
Parsley.type

Attributes

Source
PlatformSpecific.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object 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.

Type parameters

A

the type of expected success result.

Attributes

Source
Result.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class Failure[Err]
class Success[A]
case class Success[A](x: 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.

Type parameters

A

the type of expected success result.

Value parameters

x

the result value of the successful parse.

Attributes

Source
Result.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Result[Nothing, A]
class Object
trait Matchable
class Any
Show all
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').as(4), char('b').as(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').as(3), char('b').as(2), char('c').as(5))
scala> q.parse("abc")
val res1 = Success(11)
scala> q.parse("ab")
val res2 = Failure(..)
Source
ap.scala
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
Supertypes
class Object
trait Matchable
class Any
Self type
character.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
Supertypes
class Object
trait Matchable
class Any
Self type
combinator.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
Supertypes
class Object
trait Matchable
class Any
Self type
debug.type
object generic

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.5.0

Source
generic.scala
Supertypes
class Object
trait Matchable
class Any
Self type
generic.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').as(4), char('b').as(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').as(3), char('b').as(2), char('c').as(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').as(3), char('b').as(2), char('c').as(5))
Source
lift.scala
Supertypes
class Object
trait Matchable
class Any
Self type
lift.type
object position

This module contains parsers that provide a way to extract position information during a parse.

This module contains parsers that provide a way to extract position information during a parse.

Position parsers can be important for when the final result of the parser needs to encode position information for later consumption: this is particularly useful for abstract syntax trees. Offset is also exposed by this interface, which may be useful for establishing a caret size in specialised error messages.

Attributes

Since

4.2.0

Source
position.scala
Supertypes
class Object
trait Matchable
class Any
Self type
position.type
object state

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

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

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 references, though slightly more flexible. In particular, the persist combinator enabled by StateCombinators can serve as a drop-in replacement for flatMap in many scenarios.

Attributes

Since

4.5.0

Source
state.scala
Supertypes
class Object
trait Matchable
class Any
Self type
state.type
object unicode

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.

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. Unlike character, this module handles full utf-16 codepoints, which can be up to two 16-bit characters long.

Attributes

Since

4.4.0

Source
unicode.scala
Supertypes
class Object
trait Matchable
class Any
Self type
unicode.type