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.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.syntax contains several implicits to add syntactic sugar to the combinators. These are sub-categorised into the following sub modules:
      • parsley.syntax.character contains implicits to allow you to use character and string literals as parsers.
      • parsley.syntax.lift enables postfix application of the lift combinator onto a function (or value).
      • parsley.syntax.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.syntax.extension contains syntactic sugar combinators exposed as implicit classes.
    • 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.state contains combinators that interact with the context-sensitive functionality in the form of state.
    • 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.generic 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 tokenextractors

    This package contains implementations of token extractors that can be mixed into ErrorBuilder to decide how to extract unexpected tokens from the residual input left over from a parse error.

    This package contains implementations of token extractors that can be mixed into ErrorBuilder to decide how to extract unexpected tokens from the residual input left over from a parse error.

    These are common strategies, and something here is likely to be what is needed. They are all careful to handle unprintable characters and whitespace in a sensible way, and account for unicode codepoints that are wider than a single 16-bit character.

    Definition Classes
    errors
    Since

    4.0.0

  • DefaultErrorBuilder
  • ErrorBuilder
  • ErrorGen
  • SpecializedGen
  • Token
  • VanillaGen
  • combinator
  • patterns

object DefaultErrorBuilder

Helper functions used to build the DefaultErrorBuilder error messages.

Source
DefaultErrorBuilder.scala
Since

4.3.0

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. DefaultErrorBuilder
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

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 val EndOfInput: String("end of input")
  5. final val ErrorLineStart: String(">")
  6. final val NumLinesAfter: Int(1)
  7. final val NumLinesBefore: Int(1)
  8. final val Unknown: String("unknown parse error")
  9. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  10. def blockError(header: String, lines: Iterable[String], indent: Int): String

    Forms an error with the given header followed by a colon, a newline, then the remainder of the lines indented.

    Forms an error with the given header followed by a colon, a newline, then the remainder of the lines indented.

    Since

    4.3.0

  11. def caretLine(caretAt: Int, caretWidth: Int): String

    Generates a line of ^ characters as wide as specified starting as seen in as the given position, accounting for the length of the ErrorLineStart too.

    Generates a line of ^ characters as wide as specified starting as seen in as the given position, accounting for the length of the ErrorLineStart too.

    Since

    4.3.0

  12. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  13. def combineInfoWithLines(info: Seq[String], lines: Seq[String]): Seq[String]

    Joins together the given sequences: if the first is empty, then Unknown is prepended onto lines instead.

    Joins together the given sequences: if the first is empty, then Unknown is prepended onto lines instead.

    Since

    4.3.0

  14. def combineMessages(alts: Seq[String]): Seq[String]

    Filters out any empty messages and returns the rest.

    Filters out any empty messages and returns the rest.

    Since

    4.3.0

  15. def disjunct(alts: Iterable[String], oxfordComma: Boolean): Option[String]

    Combines the alternatives, separated by commas/semicolons, with the final two separated by "or".

    Combines the alternatives, separated by commas/semicolons, with the final two separated by "or". If the elements contain a comma, then semicolon is used as the list separator.

    oxfordComma

    decides whether or not to employ an Oxford comma when there more than two elements to join: this helps prevent ambiguity in the list.

    Since

    4.3.0

  16. def disjunct(alts: Iterable[String]): Option[String]

    Combines the alternatives, separated by commas/semicolons, with the final two separated by "or".

    Combines the alternatives, separated by commas/semicolons, with the final two separated by "or". An Oxford comma is added if there are more than two elements, as this helps prevent ambiguity in the list. If the elements contain a comma, then semicolon is used as the list separator.

    Since

    4.3.0

  17. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  18. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  19. def expected(alts: Option[String]): Option[String]

    Adds "expected " before the given alternatives should they exist.

    Adds "expected " before the given alternatives should they exist.

    Since

    4.3.0

  20. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  21. def format(pos: String, source: Option[String], lines: Seq[String]): String

    Forms an error message with blockError, with two spaces of indentation and incorporating the source file and position into the header.

    Forms an error message with blockError, with two spaces of indentation and incorporating the source file and position into the header.

    Since

    4.3.0

  22. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  23. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  24. def indentAndUnlines(lines: Iterable[String], indent: Int): String

    Indents and concatenates the given lines by the given depth.

    Indents and concatenates the given lines by the given depth.

    Since

    4.3.0

  25. def inputLine(line: String): String

    Adds the ErrorLineStart character to the front of the given line.

    Adds the ErrorLineStart character to the front of the given line.

    Since

    4.3.0

  26. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  27. def lineInfo(line: String, linesBefore: Seq[String], linesAfter: Seq[String], errorPointsAt: Int, errorWidth: Int): Seq[String]

    Constructs error context by concatenating them together with a "caret line" underneath the focus line, line, where the error occurs.

    Constructs error context by concatenating them together with a "caret line" underneath the focus line, line, where the error occurs.

    Since

    4.3.0

  28. def message(msg: String): String

    Returns the given message unchanged.

    Returns the given message unchanged.

    Since

    4.3.0

  29. def named(item: String): String

    Returns the given item unchanged.

    Returns the given item unchanged.

    Since

    4.3.0

  30. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  31. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  32. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  33. def pos(line: Int, col: Int): String

    Pairs the line and column up in the form (line m, column n).

    Pairs the line and column up in the form (line m, column n).

    Since

    4.3.0

  34. def raw(item: String): String

    If the given item is either a whitespace character or is otherwise "unprintable", a special name is given to it, otherwise the item is enclosed in double-quotes.

    If the given item is either a whitespace character or is otherwise "unprintable", a special name is given to it, otherwise the item is enclosed in double-quotes.

    Since

    4.3.0

  35. def reason(reason: String): String

    Returns the given reason unchanged.

    Returns the given reason unchanged.

    Since

    4.3.0

  36. def source(sourceName: Option[String]): Option[String]

    If the sourceName exists, wraps it in quotes and adds file onto the front.

    If the sourceName exists, wraps it in quotes and adds file onto the front.

    Since

    4.3.0

  37. def specializedError(msgs: Seq[String], lines: Seq[String]): Seq[String]

    Forms a specialized error by combining all components in sequence, if there are no msgs, then Unknown is used instead.

    Forms a specialized error by combining all components in sequence, if there are no msgs, then Unknown is used instead.

    Since

    4.3.0

  38. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  39. def toString(): String
    Definition Classes
    AnyRef → Any
  40. def unexpected(item: Option[String]): Option[String]

    Adds "unexpected " before the given item should it exist.

    Adds "unexpected " before the given item should it exist.

    Since

    4.3.0

  41. def vanillaError(unexpected: Option[String], expected: Option[String], reasons: Iterable[String], lines: Seq[String]): Seq[String]

    Forms a vanilla error by combining all the components in sequence, if there is no information other than the lines, Unknown is used instead.

    Forms a vanilla error by combining all the components in sequence, if there is no information other than the lines, Unknown is used instead.

    Since

    4.3.0

  42. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  43. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  44. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()

Inherited from AnyRef

Inherited from Any

Ungrouped