Packages

  • package root
    Definition Classes
    root
  • package parsley
    Definition Classes
    root
  • 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
  • class Lexer extends AnyRef

    This class provides a large selection of functionality concerned with lexing.

    This class provides a large selection of functionality concerned with lexing.

    This class provides lexing functionality to parsley, however it is guaranteed that nothing in this class is not implementable purely using parsley's pre-existing functionality. These are regular parsers, but constructed in such a way that they create a clear and logical separation from the rest of the parser.

    The class is broken up into several internal "modules" that group together similar kinds of functionality. Importantly, the lexemes and nonlexemes objects separate the underlying token implementations based on whether or not they consume whitespace or not. Functionality is broadly duplicated across both of these modules: lexemes should be used by a wider parser, to ensure whitespace is handled uniformly; and nonlexemes should be used to define further composite tokens or in special circumstances where whitespace should not be consumed.

    It is possible that some of the implementations of parsers found within this class may have been hand-optimised for performance: care will have been taken to ensure these implementations precisely match the semantics of the originals.

    Definition Classes
    token
    Annotations
    @deprecatedInheritance( ... , "4.1.0" )
  • object lexeme extends Lexeme

    This object is concerned with lexemes: these are tokens that are treated as "words", such that whitespace will be consumed after each has been parsed.

    This object is concerned with lexemes: these are tokens that are treated as "words", such that whitespace will be consumed after each has been parsed.

    Ideally, a wider parser should not be concerned with handling whitespace, as it is responsible for dealing with a stream of tokens. With parser combinators, however, it is usually not the case that there is a separate distinction between the parsing phase and the lexing phase. That said, it is good practice to establish a logical separation between the two worlds. As such, this object contains parsers that parse tokens, and these are whitespace-aware. This means that whitespace will be consumed after any of these parsers are parsed. It is not, however, required that whitespace be present.

    Definition Classes
    Lexer
    Since

    4.0.0

  • enclosing
  • numeric
  • separators
  • text

object enclosing

This object contains helper combinators for parsing terms enclosed by common symbols.

Source
Lexer.scala
Since

4.0.0

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

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. def angles[A](p: ⇒ Parsley[A]): Parsley[A]

    This combinator parses a p enclosed within angle brackets.

    This combinator parses a p enclosed within angle brackets.

    First parse an open bracket, any whitespace, then parse, p, producing x. Finally, parse a closing bracket and any whitespace. If all three parts succeeded, then return x. If any of them failed, this combinator fails.

    p

    the parser to parse between parentheses.

    returns

    a parser that reads an open bracket, then p, then a closing bracket and returns the result of p.

    Example:
    1. scala> ...
      scala> val p = lexer.nonlexeme.enclosing.brackets(int)
      scala> p.parse("< 5>")
      val res0 = Success(5)
      scala> p.parse("<5")
      val res1 = Failure(...)
      scala> p.parse("5>")
      val res2 = Failure(...)
    Since

    4.0.0

  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. def braces[A](p: ⇒ Parsley[A]): Parsley[A]

    This combinator parses a p enclosed within braces.

    This combinator parses a p enclosed within braces.

    First parse an open brace, any whitespace, then parse, p, producing x. Finally, parse a closing brace and any whitespace. If all three parts succeeded, then return x. If any of them failed, this combinator fails.

    p

    the parser to parse between parentheses.

    returns

    a parser that reads an open brace, then p, then a closing brace and returns the result of p.

    Example:
    1. scala> ...
      scala> val p = lexer.nonlexeme.enclosing.braces(int)
      scala> p.parse("{ 5}")
      val res0 = Success(5)
      scala> p.parse("{5")
      val res1 = Failure(...)
      scala> p.parse("5}")
      val res2 = Failure(...)
    Since

    4.0.0

  7. def brackets[A](p: ⇒ Parsley[A]): Parsley[A]

    This combinator parses a p enclosed within square brackets.

    This combinator parses a p enclosed within square brackets.

    First parse an open bracket, any whitespace, then parse, p, producing x. Finally, parse a closing bracket and any whitespace. If all three parts succeeded, then return x. If any of them failed, this combinator fails.

    p

    the parser to parse between parentheses.

    returns

    a parser that reads an open bracket, then p, then a closing bracket and returns the result of p.

    Example:
    1. scala> ...
      scala> val p = lexer.nonlexeme.enclosing.brackets(int)
      scala> p.parse("[ 5]")
      val res0 = Success(5)
      scala> p.parse("[5")
      val res1 = Failure(...)
      scala> p.parse("5]")
      val res2 = Failure(...)
    Since

    4.0.0

  8. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  9. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  10. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  11. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  12. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  13. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  14. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  15. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  16. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  17. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  18. def parens[A](p: ⇒ Parsley[A]): Parsley[A]

    This combinator parses a p enclosed within parentheses.

    This combinator parses a p enclosed within parentheses.

    First parse an open parenthesis, any whitespace, then parse, p, producing x. Finally, parse a closing parenthesis and any whitespace. If all three parts succeeded, then return x. If any of them failed, this combinator fails.

    p

    the parser to parse between parentheses.

    returns

    a parser that reads an open parenthesis, then p, then a closing parenthesis and returns the result of p.

    Example:
    1. scala> ...
      scala> val p = lexer.nonlexeme.enclosing.parens(int)
      scala> p.parse("( 5)")
      val res0 = Success(5)
      scala> p.parse("(5")
      val res1 = Failure(...)
      scala> p.parse("5)")
      val res2 = Failure(...)
    Since

    4.0.0

  19. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  20. def toString(): String
    Definition Classes
    AnyRef → Any
  21. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  22. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  23. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()

Inherited from AnyRef

Inherited from Any

Ungrouped