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 separators

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

Source
Lexer.scala
Since

4.0.0

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. separators
  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. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  6. def commaSep[A](p: Parsley[A]): Parsley[List[A]]

    This combinator parses zero or more occurrences of p, separated by commas.

    This combinator parses zero or more occurrences of p, separated by commas.

    Behaves just like commaSep1, except does not require an initial p, returning the empty list instead.

    p

    the parser whose results are collected into a list.

    returns

    a parser that parses p delimited by commas, returning the list of p's results.

    Example:
    1. scala> ...
      scala> val stmts = lexer.lexeme.separators.commaSep(int)
      scala> stmts.parse("7, 3,2")
      val res0 = Success(List(7, 3, 2))
      scala> stmts.parse("")
      val res1 = Success(Nil)
      scala> stmts.parse("1")
      val res2 = Success(List(1))
      scala> stmts.parse("1, 2, ")
      val res3 = Failure(..) // no trailing comma allowed
    Since

    4.0.0

  7. def commaSep1[A](p: Parsley[A]): Parsley[List[A]]

    This combinator parses one or more occurrences of p, separated by commas.

    This combinator parses one or more occurrences of p, separated by commas.

    First parses a p. Then parses a comma followed by p until there are no more commas. The results of the p's, x1 through xn, are returned as List(x1, .., xn). If p fails having consumed input, the whole parser fails. Requires at least one p to have been parsed.

    p

    the parser whose results are collected into a list.

    returns

    a parser that parses p delimited by commas, returning the list of p's results.

    Example:
    1. scala> ...
      scala> val stmts = lexer.lexeme.separators.commaSep1(int)
      scala> stmts.parse("7, 3,2")
      val res0 = Success(List(7, 3, 2))
      scala> stmts.parse("")
      val res1 = Failure(..)
      scala> stmts.parse("1")
      val res2 = Success(List(1))
      scala> stmts.parse("1, 2, ")
      val res3 = Failure(..) // no trailing comma allowed
    Since

    4.0.0

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

    This combinator parses zero or more occurrences of p, separated by semi-colons.

    This combinator parses zero or more occurrences of p, separated by semi-colons.

    Behaves just like semiSep1, except does not require an initial p, returning the empty list instead.

    p

    the parser whose results are collected into a list.

    returns

    a parser that parses p delimited by semi-colons, returning the list of p's results.

    Example:
    1. scala> ...
      scala> val stmts = lexer.lexeme.separators.semiSep(int)
      scala> stmts.parse("7; 3;2")
      val res0 = Success(List(7; 3; 2))
      scala> stmts.parse("")
      val res1 = Success(Nil)
      scala> stmts.parse("1")
      val res2 = Success(List(1))
      scala> stmts.parse("1; 2; ")
      val res3 = Failure(..) // no trailing semi-colon allowed
    Since

    4.0.0

  18. def semiSep1[A](p: Parsley[A]): Parsley[List[A]]

    This combinator parses one or more occurrences of p, separated by semi-colons.

    This combinator parses one or more occurrences of p, separated by semi-colons.

    First parses a p. Then parses a semi-colon followed by p until there are no more semi-colons. The results of the p's, x1 through xn, are returned as List(x1, .., xn). If p fails having consumed input, the whole parser fails. Requires at least one p to have been parsed.

    p

    the parser whose results are collected into a list.

    returns

    a parser that parses p delimited by semi-colons, returning the list of p's results.

    Example:
    1. scala> ...
      scala> val stmts = lexer.lexeme.separators.semiSep1(int)
      scala> stmts.parse("7; 3;2")
      val res0 = Success(List(7; 3; 2))
      scala> stmts.parse("")
      val res1 = Failure(..)
      scala> stmts.parse("1")
      val res2 = Success(List(1))
      scala> stmts.parse("1; 2; ")
      val res3 = Failure(..) // no trailing semi-colon allowed
    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