Packages

  • package root

    This is the documentation for Parsley.

    This is the documentation for Parsley.

    Package structure

    The parsley package contains the Parsley class, as well as the Result, Success, and Failure 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.
    • 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.extension contains syntactic sugar combinators exposed as implicit classes.
    • parsley.expr contains the following sub modules:
      • parsley.expr.chain contains combinators used in expression parsing
      • parsley.expr.precedence is a builder for expression parsers built on a precedence table.
      • parsley.expr.infix contains combinators used in expression parsing, but with more permissive types than their equivalents in chain.
      • parsley.expr.mixed contains combinators that can be used for expression parsing, but where different fixities may be mixed on the same level: this is rare in practice.
    • 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 a Parsley[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.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.ap contains functions which allow for the application of a parser returning a function to several parsers returning each of the argument types.
    • parsley.registers contains combinators that interact with the context-sensitive functionality in the form of registers.
    • parsley.token contains the Lexer class that provides a host of helpful lexing combinators when provided with the description of a language.
    • parsley.position contains parsers for extracting position information.
    • parsley.genericbridges contains some basic implementations of the Parser Bridge pattern (see Design Patterns for Parser Combinators in Scala, or the parsley wiki): these can be used before more specialised generic bridge traits can be constructed.
    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.

    Definition Classes
    parsley
  • 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.

    Definition Classes
    parsley
  • 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.

    Definition Classes
    parsley
  • 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.
    Definition Classes
    parsley
  • Failure
  • Parsley
  • Result
  • Success
  • ap
  • character
  • combinator
  • debug
  • extension
  • genericbridges
  • lift
  • position
  • registers
c

parsley

Result

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

This trait represents the result of a parser.

Either a Success[A] or a Failure.

A

the type of expected success result.

Source
Result.scala
Linear Supertypes
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Result
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def get: A

    Returns the successful value within the result.

    Returns the successful value within the result.

    This is equivalent to:

    result match {
      case Success(x) => x
      case _          => throw new Exception
    }
    Since

    1.7.0

    Exceptions thrown

    java.util.NoSuchElementException if the result is a failure.

    Note

    the result must not be a failure.

  2. abstract def isFailure: Boolean

    Returns true if this is a Failure, false otherwise.

    Returns true if this is a Failure, false otherwise.

    Since

    1.7.0

  3. abstract def isSuccess: Boolean

    Returns true if this is a Success, false otherwise.

    Returns true if this is a Success, false otherwise.

    Since

    1.7.0

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  6. def contains[B >: A](elem: B): Boolean

    Returns true if this result is a Success and its value is equal to elem (as determined by ==), returns false otherwise.

    Returns true if this result is a Success and its value is equal to elem (as determined by ==), returns false otherwise.

    elem

    the element to test.

    returns

    true if this is a Success value equal to elem.

    Since

    1.7.0

  7. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  8. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  9. def exists(p: (A) ⇒ Boolean): Boolean

    Returns false if Failure or returns the result of the application of the given predicate to the Success value.

    Returns false if Failure or returns the result of the application of the given predicate to the Success value.

    Since

    1.7.0

  10. def filterOrElse[Errʹ >: Err](p: (A) ⇒ Boolean, msg: ⇒ Errʹ): Result[Errʹ, A]

    Returns Success with the existing value of Success if this is a Success and the given predicate p holds for the right value, or Failure(msg) if this is a Success and the given predicate p does not hold for the right value, or Failure with the existing value of Failure if this is a Failure.

    Returns Success with the existing value of Success if this is a Success and the given predicate p holds for the right value, or Failure(msg) if this is a Success and the given predicate p does not hold for the right value, or Failure with the existing value of Failure if this is a Failure.

    Since

    1.7.0

  11. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  12. def flatMap[B, Errʹ >: Err](f: (A) ⇒ Result[Errʹ, B]): Result[Errʹ, B]

    Returns the result of applying f to this result if it is a success.

    Returns the result of applying f to this result if it is a success. Returns a failure if this result is a failure. Differs from map as f returns a result instead of just a value.

    Since

    1.7.0

  13. def flatten[B, Errʹ >: Err](implicit ev: <:<[A, Result[Errʹ, B]]): Result[Errʹ, B]

    Returns the nested result if this result is a success, otherwise return this failure.

    Returns the nested result if this result is a success, otherwise return this failure.

    Equivalent to flatMap(identity[Result[Errʹ, B]]).

    Since

    1.7.0

  14. def fold[B](ferr: (Err) ⇒ B, fa: (A) ⇒ B): B

    Returns the result of applying ferr to this result's error if this is a Failure or fa to the result stored in the Success otherwise.

    Returns the result of applying ferr to this result's error if this is a Failure or fa to the result stored in the Success otherwise.

    ferr

    the function to apply if this is a Failure.

    fa

    the function to apply if this is a Success.

    returns

    the results of applying the function

    Since

    1.7.0

  15. def forall(f: (A) ⇒ Boolean): Boolean

    Returns true if this result is a Failure or returns the result of the application of the given predicate to the Success value.

    Returns true if this result is a Failure or returns the result of the application of the given predicate to the Success value.

    Since

    1.7.0

  16. def foreach[U](f: (A) ⇒ U): Unit

    Executes the procedure f if this is a Success.

    Executes the procedure f if this is a Success. Otherwise, do nothing.

    This is equivalent to:

    result match {
      case Success(x) => f(x)
      case _          => ()
    }
    f

    The side-effecting function to execute.

    Since

    1.7.0

  17. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  18. def getOrElse[B >: A](default: ⇒ B): B

    Returns the value from this Success or the result of evaluating default if this is a Failure.

    Returns the value from this Success or the result of evaluating default if this is a Failure.

    Since

    1.7.0

  19. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  20. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  21. def map[B](f: (A) ⇒ B): Result[Err, B]

    Returns a Success containing the result of applying f to this result's value if this is a success.

    Returns a Success containing the result of applying f to this result's value if this is a success. Otherwise, returns a failure.

    Since

    1.7.0

  22. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  23. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  24. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  25. def orElse[B >: A, Errʹ >: Err](alternative: ⇒ Result[Errʹ, B]): Result[Errʹ, B]

    Returns this result if it is a Success, otherwise return the result of evaluating alternative.

    Returns this result if it is a Success, otherwise return the result of evaluating alternative.

    Since

    1.7.0

  26. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  27. def toEither: Either[Err, A]

    Converts the Result into a Either where Failure maps to a Left[Err].

    Converts the Result into a Either where Failure maps to a Left[Err].

    Since

    1.7.0

  28. def toOption: Option[A]

    Returns a Some containing the Success value if it exists or a None if this is a Failure.

    Returns a Some containing the Success value if it exists or a None if this is a Failure.

    Since

    1.7.0

  29. def toSeq: Seq[A]

    Returns a Seq containing the Success value if it exists or an empty Seq if this is a Failure.

    Returns a Seq containing the Success value if it exists or an empty Seq if this is a Failure.

    Since

    1.7.0

  30. def toString(): String
    Definition Classes
    AnyRef → Any
  31. def toTry: Try[A]

    Converts the Result into a Try where Failure maps to a plain Exception.

    Converts the Result into a Try where Failure maps to a plain Exception.

    Since

    1.7.0

  32. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  33. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  34. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()

Inherited from AnyRef

Inherited from Any

Ungrouped