OperatorSugar

parsley.extension$.OperatorSugar
final implicit class OperatorSugar[P, +A](p: P)(implicit con: P => Parsley[A])

This class enables "operator-style" alternative combinators on parsers.

This extension class exposes a collection of "operator-style" combinators on values that are convertible to parsers that are plain syntactic sugar for other functionality in the library; they are potentially less readable than the combinators they replace, so should be used sparingly.

Type parameters

P

the type of base value that this class is used on (the conversion to Parsley) is summoned automatically.

Value parameters

con

a conversion that allows values convertible to parsers to be used.

p

the value that this class is enabling methods on.

Attributes

Constructor

This constructor should not be called manually, it is designed to be used via Scala's implicit resolution.

Since

4.0.0

Source
extension.scala
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def *: Parsley[List[A]]

This combinator, pronounced "star", will parse this parser zero or more times returning a list of the parsed results.

This combinator, pronounced "star", will parse this parser zero or more times returning a list of the parsed results.

Equivalent to many, but as a postfix operator: many(p) is the same as p.*.

Attributes

See also

many for more details.

Note

an alias for many.

Source
extension.scala
def +: Parsley[List[A]]

This combinator, pronounced "plus", will parse this parser one or more times returning a list of the parsed results.

This combinator, pronounced "plus", will parse this parser one or more times returning a list of the parsed results.

Equivalent to some, but as a postfix operator: some(p) is the same as p.+.

Attributes

See also

some for more details.

Note

an alias for some.

Source
extension.scala
def -(q: Parsley[_]): Parsley[A]

This combinator, pronounced "and not", first parses its argument q, and if it fails, it will parse this parser, returning its result.

This combinator, pronounced "and not", first parses its argument q, and if it fails, it will parse this parser, returning its result.

First q is parsed, which will never consume input regardless of failure or success. If it failed, then this parser is executed and its result is returned. If either q succeeds or this parser fails, the combinator fails.

Value parameters

q

the parser to quotient this parser by.

Attributes

Returns

a parser that only parses this parser if q cannot parse.

Example

// a less efficient version of a keyword: it's more efficient to not have to read the entire keyword twice
def keyword(kw: String): Parsley[Unit] = {
   string(kw).void - identifier
}
Source
extension.scala
def ?: Parsley[Option[A]]

This combinator, pronounced "option", will try parsing this parser wrapping its result in Some, and return None if it fails.

This combinator, pronounced "option", will try parsing this parser wrapping its result in Some, and return None if it fails.

Equivalent to option, but as a postfix operator: option(p) is the same as p.?.

Attributes

See also

option for more details.

Note

an alias for option.

Source
extension.scala

This combinator, pronounced "not", will succeed when this parser fails, and vice-versa, never consuming input.

This combinator, pronounced "not", will succeed when this parser fails, and vice-versa, never consuming input.

Equivalent to notFollowedBy, but as a prefix operator: notFollowedBy(p) is the same as !p.

Attributes

See also

notFollowedBy for more details.

Note

an alias for notFollowedBy.

Source
extension.scala