Packages

  • package root
    Definition Classes
    root
  • package parsley
    Definition Classes
    root
  • package errors

    This package contains various functionality relating to the generation and formatting of error messages.

    This package contains various functionality relating to the generation and formatting of error messages.

    In particular, it includes a collection of combinators for improving error messages within the parser, including labelling and providing additional information. It also contains combinators that can be used to valid data produced by a parser, to ensure it conforms to expected invariances, producing good quality error messages if this is not the case. Finally, this package contains ways of changing the formatting of error messages: this can either be changing how the default String-based errors are formatted, or by injectiing Parsley's errors into a custom error object.

  • package expr

    This package contains various functionality relating to the parsing of expressions..

    This package contains various functionality relating to the parsing of expressions..

    This includes the "chain" combinators, which tackle the left-recursion problem and allow for the parsing and combining of operators with values. It also includes functionality for constructing larger precedence tables, which may even vary the type of each layer in the table, allowing for strongly-typed expression parsing.

  • package implicits

    This package contains various functionality that involve Scala's implicits mechanism.

    This package contains various functionality that involve Scala's implicits mechanism.

    This includes conversions from scala literals into parsers, as well as enabling new syntax on regular Scala values (such as Parsley's lift or zipped syntax). Automatic conversion to Parsley[Unit] is also supported within this package.

  • package token

    This package provides a wealth of functionality for performing common lexing tasks.

    This package provides a wealth of functionality for performing common lexing tasks.

    It is organised as follows:

    • the main parsing functionality is accessed via Lexer, which provides implementations for the combinators found in the sub-packages given a LexicalDesc.
    • the descriptions sub-package is how a lexical structure can be described, providing the configuration that alters the behaviour of the parsers produced by the Lexer.
    • the other sub-packages contain the high-level interfaces that the Lexer exposes, which can be used to pass whitespace-aware and non-whitespace-aware combinators around in a uniform way.
    • the predicate module contains functionality to help define boolean predicates on characters or unicode codepoints.
  • Failure
  • Parsley
  • Result
  • Success
  • ap
  • character
  • combinator
  • debug
  • extension
  • genericbridges
  • io
  • lift
  • registers
p

parsley

package parsley

Ordering
  1. Alphabetic
Visibility
  1. Public
  2. Protected

Package Members

  1. package errors

    This package contains various functionality relating to the generation and formatting of error messages.

    This package contains various functionality relating to the generation and formatting of error messages.

    In particular, it includes a collection of combinators for improving error messages within the parser, including labelling and providing additional information. It also contains combinators that can be used to valid data produced by a parser, to ensure it conforms to expected invariances, producing good quality error messages if this is not the case. Finally, this package contains ways of changing the formatting of error messages: this can either be changing how the default String-based errors are formatted, or by injectiing Parsley's errors into a custom error object.

  2. package expr

    This package contains various functionality relating to the parsing of expressions..

    This package contains various functionality relating to the parsing of expressions..

    This includes the "chain" combinators, which tackle the left-recursion problem and allow for the parsing and combining of operators with values. It also includes functionality for constructing larger precedence tables, which may even vary the type of each layer in the table, allowing for strongly-typed expression parsing.

  3. package implicits

    This package contains various functionality that involve Scala's implicits mechanism.

    This package contains various functionality that involve Scala's implicits mechanism.

    This includes conversions from scala literals into parsers, as well as enabling new syntax on regular Scala values (such as Parsley's lift or zipped syntax). Automatic conversion to Parsley[Unit] is also supported within this package.

  4. package token

    This package provides a wealth of functionality for performing common lexing tasks.

    This package provides a wealth of functionality for performing common lexing tasks.

    It is organised as follows:

    • the main parsing functionality is accessed via Lexer, which provides implementations for the combinators found in the sub-packages given a LexicalDesc.
    • the descriptions sub-package is how a lexical structure can be described, providing the configuration that alters the behaviour of the parsers produced by the Lexer.
    • the other sub-packages contain the high-level interfaces that the Lexer exposes, which can be used to pass whitespace-aware and non-whitespace-aware combinators around in a uniform way.
    • the predicate module contains functionality to help define boolean predicates on characters or unicode codepoints.

Type Members

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

    Err

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

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

    Version

    4.0.0

    Note

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

  3. sealed abstract class Result[+Err, +A] extends AnyRef

    This trait represents the result of a parser.

    This trait represents the result of a parser.

    Either a Success[A] or a Failure.

    A

    the type of expected success result.

  4. case class Success[A] extends Result[Nothing, A] with Product with Serializable

    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.

    A

    the type of expected success result.

Value Members

  1. object Failure extends Serializable
  2. 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.

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

    Example:
    1. 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(..)
    Since

    4.0.0

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

    Since

    2.2.0

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

    Since

    2.2.0

  6. object debug

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

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

  8. object genericbridges

    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.

    Since

    4.0.0

  9. 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)

    Since

    3.0.0

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

    Example:
    1. 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)
    Since

    2.2.0

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

    Since

    2.2.0

Ungrouped