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, 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.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.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 the Lexer 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.
    Definition Classes
    root
  • package parsley
    Definition Classes
    root
  • package errors
    Definition Classes
    parsley
  • DefaultErrorBuilder
  • ErrorBuilder
  • combinator
  • revisions

trait ErrorBuilder[Err] extends AnyRef

This typeclass specifies how an error generated by a parser should be formatted. An instance of this trait is required when calling parse (or similar). By default, Parsley defines its own instance for ErrorBuilder[String] found in the ErrorBuilder companion object.

To implement this trait, you will need to define a number of methods as well as decide on the representation types for a variety of different components. The relation between the various methods is closely linked to the types that they both produce and consume. If you only want to change the basics of formatting without having to define the entire instance, you can inherit from DefaultErrorBuilder, but this will lock in your implementation types (type aliases cannot be overriden in Scala).

Err

The final result type of the error message

Since

3.0.0

Linear Supertypes
AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ErrorBuilder
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Type Members

  1. abstract type EndOfInput <: Item

    Represents the end of the input.

    Represents the end of the input.

    Since

    3.0.0

  2. abstract type ErrorInfoLines

    The representation type of the main body within the error message

    The representation type of the main body within the error message

    Since

    3.0.0

  3. abstract type ExpectedItems

    The representation of all the different possible tokens that could have prevented an error.

  4. abstract type ExpectedLine

    The representation of the information regarding the solving tokens.

    The representation of the information regarding the solving tokens.

    Since

    3.0.0

  5. abstract type Item

    The base type of Raw, Named and EndOfInput that represents the individual items within the error.

    The base type of Raw, Named and EndOfInput that represents the individual items within the error.

    Since

    3.0.0

  6. abstract type LineInfo

    The representation of the line of input where the error occurred.

    The representation of the line of input where the error occurred.

    Since

    3.0.0

  7. abstract type Message

    The representation of a reason or a message generated by the parser.

    The representation of a reason or a message generated by the parser.

    Since

    3.0.0

  8. abstract type Messages

    The representation of the combined reasons or failure messages from the parser.

  9. abstract type Named <: Item

    This represents "named" tokens, which have been provided with a label.

    This represents "named" tokens, which have been provided with a label.

    Since

    3.0.0

  10. abstract type Position

    The representation type of position information within the generated message

    The representation type of position information within the generated message

    Since

    3.0.0

  11. abstract type Raw <: Item

    This represents "raw" tokens, where are those without labels: i.e.

    This represents "raw" tokens, where are those without labels: i.e. they come direct from the input, or the characters that the parser is trying to read.

    Since

    3.0.0

  12. abstract type Source

    The representation of the file information

    The representation of the file information

    Since

    3.0.0

  13. abstract type UnexpectedLine

    The representation of the information regarding the problematic token.

    The representation of the information regarding the problematic token.

    Since

    3.0.0

Abstract Value Members

  1. abstract def combineExpectedItems(alts: Set[Item]): ExpectedItems

    Details how to combine the various expected items into a single representation.

    Details how to combine the various expected items into a single representation.

    alts

    The possible items that fix the error

    Since

    3.0.0

  2. abstract def combineMessages(alts: Set[Message]): Messages

    Details how to combine any reasons or messages generated within a single error.

    Details how to combine any reasons or messages generated within a single error. Reasons are used by vanilla messages and messages are used by specialised messages.

    alts

    The messages to combine (see the message or reason methods)

    Since

    3.0.0

  3. abstract val endOfInput: EndOfInput

    Value that represents the end of the input in the error message.

    Value that represents the end of the input in the error message.

    Since

    3.0.0

  4. abstract def expected(alts: ExpectedItems): ExpectedLine

    Describes how to handle the information about the tokens that could have avoided the error.

    Describes how to handle the information about the tokens that could have avoided the error.

    alts

    The tokens that could have prevented the error (see the combineExpectedItems method)

    Since

    3.0.0

  5. abstract def format(pos: Position, source: Source, lines: ErrorInfoLines): Err

    This is the top level function, which finally compiles all the formatted sub-parts into a finished value of type Err.

    This is the top level function, which finally compiles all the formatted sub-parts into a finished value of type Err.

    pos

    This is the representation of the position of the error in the input (see the pos method)

    source

    This is the representation of the filename (if it exists) (see the source method)

    lines

    This is the main body of the error message (see vanillaError or specialisedError methods)

    returns

    The final assembled error message

    Since

    3.0.0

  6. abstract def lineInfo(line: String, errorPointsAt: Int): LineInfo

    Describes how to format the information about the line that the error occured on.

    Describes how to format the information about the line that the error occured on.

    line

    The full line of input that produced this error message

    errorPointsAt

    The offset into the line that the error points at

    Since

    3.0.0

  7. abstract def message(msg: String): Message

    Describes how to represent the messages produced by the fail combinator (or any that are implemented using it).

    Describes how to represent the messages produced by the fail combinator (or any that are implemented using it).

    msg

    The message produced by the parser

    Since

    3.0.0

  8. abstract def named(item: String): Named

    Formats a named item generated by a label.

    Formats a named item generated by a label.

    item

    The name given to the label

    Since

    3.0.0

  9. abstract def pos(line: Int, col: Int): Position

    Formats a position into the representation type given by Position.

    Formats a position into the representation type given by Position.

    line

    The line the error occurred at

    col

    The column the error occurred at

    returns

    A representation of the position

    Since

    3.0.0

  10. abstract def raw(item: String): Raw

    Formats a raw item generated by either the input string or a input reading combinator without a label.

    Formats a raw item generated by either the input string or a input reading combinator without a label.

    item

    The raw, unprocessed input

    Since

    3.0.0

  11. abstract def reason(reason: String): Message

    Describes how to represent the reasons behind a parser fail.

    Describes how to represent the reasons behind a parser fail. These reasons originate from the explain combinator.

    reason

    The reason produced by the parser

    Since

    3.0.0

  12. abstract def source(sourceName: Option[String]): Source

    Formats the name of the file if it exists into the type give by Source

    Formats the name of the file if it exists into the type give by Source

    sourceName

    The source name of the file, if any

    Since

    3.0.0

  13. abstract def specialisedError(msgs: Messages, line: LineInfo): ErrorInfoLines

    Specialised errors are triggered by fail and any combinators that are implemented in terms of fail.

    Specialised errors are triggered by fail and any combinators that are implemented in terms of fail. These errors take precedence over the vanilla errors, and contain less, more specialised, information

    msgs

    Information detailing the error (see the combineMessages method)

    line

    Representation of the line of input that this error occured on (see the lineInfo method)

    Since

    3.0.0

  14. abstract def unexpected(item: Option[Item]): UnexpectedLine

    Describes how to handle the (potentially missing) information about what token(s) caused the error.

    Describes how to handle the (potentially missing) information about what token(s) caused the error.

    item

    The Item that caused this error

    Since

    3.0.0

  15. abstract def vanillaError(unexpected: UnexpectedLine, expected: ExpectedLine, reasons: Messages, line: LineInfo): ErrorInfoLines

    Vanilla errors are those produced such that they have information about both expected and unexpected tokens.

    Vanilla errors are those produced such that they have information about both expected and unexpected tokens. These are usually the default, and are not produced by fail (or any derivative) combinators.

    unexpected

    Information about which token(s) caused the error (see the unexpected method)

    expected

    Information about which token(s) would have avoided the error (see the expected method)

    reasons

    Additional information about why the error occured (see the combineMessages method)

    line

    Representation of the line of input that this error occured on (see the lineInfo method)

    Since

    3.0.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(classOf[java.lang.CloneNotSupportedException]) @native()
  6. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  7. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  8. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  9. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  10. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  11. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  12. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  13. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  14. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  15. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  16. def toString(): String
    Definition Classes
    AnyRef → Any
  17. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  18. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  19. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()

Inherited from AnyRef

Inherited from Any

Ungrouped